# Aggregate upload buffering — tracker20 progress (2026-11-14)

**Subsequent parser repair (23):** the current API/PIM pre-parser cap is16KiB
for non-multipart bodies; multipart/form-data retains1100KiB. Large logical
fields must use multipart. This note's earlier uniform-cap measurements remain
historical evidence; see `.scratch/bounded-parsers.md` for the dense-field
counterexample and final regression/resource results.

## Scope and state

The measured whole-body PDF-upload counterexample is repaired and dev-verified.
Tracker20 remains OPEN: aggregate image/font/render/parser amplification and
native/representative/coexistence acceptance are not certified. No production
or preserved18087 installation is authorised/implied. Source integration is
uncommitted; original dirty checkout, :8080, :18087, signature preview and PHP
service are not altered. Metadata18 and PIM19 remain source-only too; never use
old PIM Resync on preserved18087.

Worktree: `/tmp/signet-roadmap-20261112/uploads`, `fix/bounded-uploads`, base9876b79
with the complete uncommitted integration overlay. No third-party code was
changed. Matching Alpine kcgi0.13.4 source confirms complete FastCGI-body buffers
and reconstructed parent fields; its public options do not provide streaming
uploads. Source archive SHA512:
`53acccc5ad59958c359f1c46a5e08a66926d06f6adb9096226a197ed7334c556de9a4af8e0c292090884747cc42762ef1d810e2824daaa0041ba5568a153aea9`.

## Retained policy, changed transport

- PDFs still accept up to **33,554,432 bytes (32 MiB)**. The browser uses256KiB
  application-level chunks, not HTTP Transfer-Encoding as a streaming workaround.
- lighttpd caps every `/api` and `/pim-api` FastCGI prefix at1100KiB **before**
  kcgi parses a body, including unknown suffixes and normalised/encoded paths.
  Native configuration must retain this cap and backend isolation. DAM/WebDAV's
  existing34000KiB cap is unchanged; no organisation ACL/writer policy is added.
- Existing small multipart PDF uploads and templates still work. A large legacy
  single multipart body now returns413; non-browser clients must adopt chunks.
  This is an explicit transport change, not a silent reduction of file capacity.
  Multipart JSON/signature fields at the existing1MiB limit still pass; encoded
  request overhead also counts toward the1100KiB transport cap.
- `POST /docs` accepts `total_size` and the first PDF chunk, responds201 with
  `id`, `upload_offset`, `upload_total`. First bytes retain `%PDF-` validation.
  `POST /docs/:id/upload` accepts `offset` and `file`, responds200 with the
  acknowledged offset/total. PostgreSQL builds the new JSON acknowledgements;
  duplicate chunks do not perform another counter update. No new document status or independent upload
  session/cleanup service is introduced.
- Additive migration003 stores nullable `source_total`/`source_received`.
  NULL/NULL preserves every legacy/template source; matching counters mean
  complete. A partial upload is an ordinary private DRAFT. It cannot be edited,
  submitted, made into a template or downloaded (including by admin).
- Current drafter role plus exact creator ownership and a PostgreSQL row lock
  guard chunks. Acknowledged prefixes cannot be replaced: retries compare actual
  bytes. Out-of-order/conflicting bodies fail409. Completed sources cannot be
  overwritten. File/counter ordering is file fsync, final rename when complete,
  directory fsync, SQL update/COMMIT. Unknown commit outcomes retain files.
  A retry reconciles a final filename with an older SQL counter under the same
  row lock; publication alone never grants download/readiness.
- Browser disables duplicate creation and shows native accessible progress.
  Only identified chunks get one transient retry; creation is not blindly
  retried. Failure navigates to a safe incomplete-draft view; deletion removes
  the partial file. UI restart/resume is intentionally not added: discard and
  upload again. Private signatures/organisation references/routing are unchanged.

## Evidence

Baseline repeated probe:18,572→85,804KiB held; a second run19,532→85,684KiB
held and **182,624KiB sampled transient aggregate peak**. Logs:
`/tmp/signet-upload-{baseline,transient-baseline,transient-samples}.log`.
The original stable held excess independently proves the budget failure; samples
are not an absolute instantaneous maximum.

Protocol red: `/tmp/signet-upload-contract-red.log`,
`FAIL - bounded upload initial offset missing` against the unchanged PIM19 image.

Latest clean product image/container `signet-upload-final-r3`, loopback18100,
container `d40b2794e49057019cbb9dd5acbef27144542a76e2b2215288b8be5c1000fd7e`.
All five owned PIM/upload investigation containers were subsequently stopped
gracefully and retained. Preserved18087 still responds200; no fixture is left
running as an implicit replacement preview.

- Clean `-Wall -Wextra` build, full E2E ends **all passed**, renderer contracts
  including hangs/recovery/replay pass. Logs `/tmp/signet-upload-final-r3-{build,e2e,render}.log`.
- Migration fixture preserves original fields/NULL source meaning, applies003
  twice, rejects invalid counter pairs/ranges in its own temporary database.
- HTTP contract covers roles/ownership, no partial source access/admin bypass,
  save/template/submit gates, chunk limits, concurrent exact retries, discarded
  uncommitted suffix, deferred COMMIT failure **after final rename**, private
  incomplete state, recovery, exact assembled bytes, cancellation, small legacy
  compatibility and encoded/unknown prefix pre-parser413 responses.
- Harder two-file probe accepts **two complete32MiB files**, hashes downloaded
  source bytes independently, adds ignored fields bringing initial multipart
  bodies near the1100KiB cap, and rejects both32MiB Content-Length and unknown-
  length HTTP chunked legacy bodies before kcgi. Aggregate signet/signetd/
  lighttpd cohorts include kcgi helpers. Excludes root fixture/curl/sampler,
  PostgreSQL and Redis (not an assertion about their shared-service footprint).
  Baseline **24,180KiB**, held **26,388KiB**, sampled peak **29,660KiB**
  (30,371,840 bytes). `/tmp/signet-upload-final-r3-rss.log` explicitly reports
  `budget_result=within_for_fixture; native/resource gate remains OPEN`.
  Nominal1ms sleep plus /proc scanning, not a certified1kHz atomic sample.
- `node test/upload-client.mjs`: real helper accepts exact32MiB in128 bounded
  slices; over-limit rejected before creation, tail, exact transient retry,
  no conflict/initial-creation retry and stalled progress checks pass.
- `test/upload-browser.mjs`: real Chrome, first chunk gated to inspect disabled
  duplicate button/progress/private incomplete state; valid exact32MiB two-page
  PDF uploaded and source hash verified; forced chunk conflict shows safe
  incomplete view and deletion succeeds, no page errors. SHA256
  `bf5434eb60f750d2dc282330542d9e2f21eca5525a49fd6bc9d8e3cc38a0afb7`,
  document `aff88622-7256-4631-b91e-9acc73154d27` (synthetic disposable only).
  `/tmp/signet-upload-final-browser{.log,/}`; progress/complete/incomplete images reviewed.
  Native qpdf check and pdfinfo confirm valid two-page33554432-byte PDF:
  `/tmp/signet-upload-max-pdf-check.log`.
- Retained full browser signing flow passes edit/save, both-page proof,
  keyboard/pointer placement, check-only, enrolment, final release and events.
  `/tmp/signet-upload-final-signing-browser{.log,/}`, synthetic document
  `12f35dec-9003-463c-8d3d-33ba32bb776c`.

Tested product source (all native C/headers, UI, schema/migrations, Makefile and
configs) SHA256 matches the worktree exactly; manifests
`/tmp/signet-upload-product-{host,image}.sha256`. The stronger HTTP contract is
included in the final-r3 image/full E2E. Intermediate-r2 contract strengthening
also passed separately (`/tmp/signet-upload-strengthened-contract.log`); its
harder upload fixture peaked27,164KiB. Earlier evidence is retained, not an
absolute peak guarantee or a claim that different runs have identical residency.
Owned probe/commit triggers and holder activity were checked absent after tests.

Private0700 backup:
`/Users/saikrupa/.local/var/signet-feature-backups/bounded-uploads-20261114T181856Z`.
Contains pre/post integration source, patch/status, exact source manifests and
synthetic test/browser/image evidence. No runtime user backup or preview upgrade
is implied. Skill-link loops were excluded from directory comparison, not changed;
tar retains symlinks without following them. Selective integration copies only
the24 documented changed/new paths; all prior signature/restart/metadata/PIM
changes remain present. No commit/push.

## Remaining gates / rollout precautions

Request-byte caps are NOT whole-parser heap bounds: field cardinality, yyjson/
libpq expansion, PIM catalogs/replies, simultaneous image/font codecs, complex
PDF subprocesses and representative mixed workload still require accounting and
containment. No CPU/RSS/cgroup/native certification follows from this fixture.
Allocation-failure work21 and actual error logging/capture22 remain open.

A future approved installation must coordinate migration003, API, browser and
both lighttpd configs. Stop writers/take verified coordinated DB/files/queue/
config backups first. Do not roll back to an old API while incomplete uploads
exist: it ignores the new readiness guards. Complete or explicitly discard them
under the new API with owner approval, or reconcile a paired DB/files restore
with all newer activity. Never blindly restore a pre-activity backup. Retain
partial files/counters together in backups; interrupted initial creation can
leave an unreferenced private directory, not an automatically deletable record.
No automatic sweep, replacement API, production namespace/capacity decision or
native service reconfiguration is introduced.
