release: bump to 2.1.2 (EK production chain + View V0–V3 bar)

Ship evidence/closure invalidation, verify/adjudicate, reuse_execute and
agent bind/publish gates, document.extract, KnowledgePresentation + SSE
page_token, and upload max_bytes with the 45-test offline gate.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-10-24 22:52:03 +08:00
1 parent 0b80ff8e50
commit dc853fb580
38 files changed
+3045 -298

No files matched your search

+20 -2
View File
@@ -81,7 +81,16 @@ func (st *state) handleUpload(w http.ResponseWriter, r *http.Request, routePath
_, hadCookie := session.IDFromCookie(r.Header.Get("Cookie"))
sid, _, setCookie := resolveSession(r)
if err := r.ParseMultipartForm(32 << 20); err != nil {
// M01: hard-limit request body before multipart parse (32MiB was only in-memory
// form budget, not a request total). Cap at configured MaxBytes + 1MiB overhead.
maxBody := int64(cfg.MaxBytes)
if maxBody <= 0 {
maxBody = 32 << 20
}
overhead := int64(1 << 20)
r.Body = http.MaxBytesReader(w, r.Body, maxBody+overhead)
if err := r.ParseMultipartForm(maxBody + overhead); err != nil {
jsonErr(w, http.StatusBadRequest, fmt.Sprintf("multipart: %v", err))
return
}
@@ -109,11 +118,20 @@ func (st *state) handleUpload(w http.ResponseWriter, r *http.Request, routePath
return
}
defer f.Close()
b, err := io.ReadAll(f)
// Stream-capped read: never buffer more than MaxBytes.
lim := maxBody
if lim <= 0 {
lim = 32 << 20
}
b, err := io.ReadAll(io.LimitReader(f, lim+1))
if err != nil {
jsonErr(w, http.StatusBadRequest, fmt.Sprintf("read file: %v", err))
return
}
if int64(len(b)) > lim {
jsonErr(w, http.StatusRequestEntityTooLarge, "file exceeds max_bytes")
return
}
fileBytes = b
} else {
// Fallback: walk File map keys.
@@ -0,0 +1,45 @@
package httpx
import (
"bytes"
"mime/multipart"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func TestHandleUploadRejectsOversizedBeforeFullBuffer(t *testing.T) {
st := &state{
uploadRoutes: map[string]any{
"/upload": map[string]any{
"field": "file",
"storage_url": "memory://t",
"prefix": "u",
"max_bytes": float64(64),
},
},
}
cfg := parseUploadRoute(st.uploadRoutes["/upload"])
var body bytes.Buffer
w := multipart.NewWriter(&body)
part, err := w.CreateFormFile("file", "big.txt")
if err != nil {
t.Fatal(err)
}
if _, err := part.Write([]byte(strings.Repeat("x", 200))); err != nil {
t.Fatal(err)
}
_ = w.Close()
req := httptest.NewRequest(http.MethodPost, "/upload", &body)
req.Header.Set("Content-Type", w.FormDataContentType())
rr := httptest.NewRecorder()
st.handleUpload(rr, req, "/upload", cfg)
if rr.Code == http.StatusOK {
t.Fatalf("expected reject for oversized upload, got %d body=%s", rr.Code, rr.Body.String())
}
if rr.Code != http.StatusRequestEntityTooLarge && rr.Code != http.StatusBadRequest {
t.Fatalf("expected 413 or 400, got %d body=%s", rr.Code, rr.Body.String())
}
}