fix(session): bound apply_patch transcript metadata - #4573
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
OWNER_CONFIRMATION_REQUIRED Exact head
The sole red job is intentionally the No authorized exact-head approval exists yet. Review requests are pending from — |
probepark
left a comment
There was a problem hiding this comment.
Approve at 96754755a
fix(session): bound apply_patch transcript metadata, head commit "hash edit snapshots before
truncation". 5 files, +898.
Differential
# base 96e718a2b, with this head's test file applied
(fail) near-limit edit append after committed mutation (#4566) > surfaces the typed near-limit outcome when even the rewrite cannot hold the entry
1 pass 5 fail 1 error
# head 96754755a
6 pass 0 fail
$ bun --cwd=packages/coding-agent run check -> exit 0
Five of six fail on base, so the suite is genuinely bound to the change rather than passing
incidentally.
The ordering in the commit title is the correctness point
"hash edit snapshots before truncation" is not a detail. Hashing after truncation would make two
different patches collide whenever their surviving prefixes match, which is exactly the case that
matters here - large apply_patch payloads that get bounded for the transcript. Hashing the full
snapshot first and truncating for display afterwards keeps identity independent of the display
bound.
surfaces the typed near-limit outcome when even the rewrite cannot hold the entry is the assertion
worth having: the failure mode for a bounding change is not "too big" but "silently dropped or
mis-typed at the boundary", and this pins a typed outcome rather than a generic throw.
merge-approved.
Reviewed by @probepark - method: fresh-worktree run and package typecheck at the exact head, separate clean base worktree with the head's test file to prove the differential.
Freshness dependency hold — current dev is redThis PR remains open at exact head Current dev is not a valid green rebase target: push run Disposition: item-specific hold remains active behind #4574. After #4574 merges and dev CI is green, this PR must be reconciled to that exact new dev head, with refreshed digest, CI, and review before any merge-ready claim. — |
Yeachan-Heo
left a comment
There was a problem hiding this comment.
OWNER_CONFIRMATION_REQUIRED
Reconciliation of exact head 96754755ad41c95b03bcf9bb690cd4aeb9b4d366 (tree ce054b179e3aaa78982309ca5ecfade083d66b8f) against current dev f024ded61408ee77c1fbcb20539146081a28e08d.
Merge reconciliation (clean, code conflict-free). Recorded base 96e718a2b0 predates dev by 3 merges (1cc986422a #4515, 2e3ccb589 #4577, f024ded61 #4579). git diff 1cc986422a..f024ded614 over the three touched source files (session-manager.ts, agent-session.ts, edit/renderer.ts) is empty — zero semantic overlap. Only CHANGELOG.md conflicts textually (both sides added entries to the same [Unreleased] block); merge resolution keeps both. I merged the exact head into a worktree at dev and verified green (below).
Adversarial review — no blockers found:
- Digest receipts (
{bytes, sha256}) are computed from the complete body before generic 500k persistence truncation (prepareEntryForPersistence{,Sync}ordering), so a receipt identifies the exact source body, not a truncated prefix. Pinned by a dedicated test. - Bounding is persistence-boundary-only. Live in-process results keep full bodies; ACP
diffToolCallContent consumesevent.resultoff the livetool_execution_endstream, not the persisted entry, so editor/diff consumers are unaffected. Sub-16 KiB bodies persist verbatim with no receipt fields. boundEditSnapshotFieldsForEntrygates ontype === "message",role === "toolResult", non-arraydetails; the walk only rewritesoldText/newTextpairs over the cap and never mutates shared live objects (copy-on-change). Unrelated entries pass through untouched.SessionNearLimitAppendErrorpost-verification closes the prior silent-success gap: after thecontent_too_largerewrite recovery, the file is re-checked and a rewrite that still cannot hold the entry (or a rewrite that itself throwscontent_too_large) now throws the typed error instead of returning success without the receipt for an already-committed source edit.AgentSessionmaps it to a structured tool-result outcome withfailureKind: "persistence"+nearLimitAppendfields; the entry stays resident so the next successful persist records it. Cost note: when the rewrite genuinely succeeds, the newgetTranscriptFileBytes()verification is an extra stat — accepted for closing a durability gap.- Platform/lifecycle: sync and async persistence paths apply identical ordering; Windows/session-resume paths consume persisted entries read-only. No security-relevant surface change (transcripts get strictly smaller; digests add no new trust boundary).
- Tests: 6 focused tests (bounding ratio < 2% of file size per patch, pre-truncation exact digest, sub-cap inline, multi-file
perFileResults[], rewrite-recovery durability, typed-error surface). Attribution/changelog present and accurate against the diff.
Fresh verification on dev+PR merged tree: edit-result-persistence-bounding 6/6 pass; edit suites (per-file-diff-content, auto-generated-regressions, mode-auto-routing) 65/65 pass; session-manager persistence suites 21/21 pass; notifications-live-stream 20/20 pass; tsc -p packages/coding-agent clean. Minor nit (non-blocking): the new test file emits 11 biome warnings (unused type alias SessionNearLimitAppendError at L499, unused p/b/r params in the L543–555 proto stubs) — warnings, not errors; check stays green.
CI on the exact head: all product jobs green (affected plan, coding-agent check, focused #4566 regression, ts-build, CLI smoke, Windows regression, all gjc-state-gates). The red jobs are the intentional needs-human PR contract bootstrap/validation plus one superseded rerun. Automated reviewer probepark APPROVED at exactly 96754755a (write-permission collaborator).
Required owner action — this PR remains held on two gating conditions, both owner-owned:
- Freshness gate behind #4574/#4575. Current dev's own Dev CI is red from the pre-existing Chrome default-root regression (
browser-chrome-profile.test.tsshard 3/8, failing on dev at1cc986422and2e3ccb589, run31876714691in progress atf024ded61). That regression is unrelated to this PR's files and is repaired by open PR #4575 (189fc0fde6, rebased onto dev, its own CI green, awaiting merge). Per the standing hold recorded on this PR at 06:02Z: merge #4575 first, confirm dev Dev CI green, then rebase/merge-refresh this PR onto that exact dev head with fresh digest, CI, and review before any merge-ready claim. I verified locally that the dev-red test passes on the PR-merged tree and is untouched by this PR's diff. - Exact-head contract approval. The PR contract bootstrap stays
needs-humanuntil an authorized non-author collaborator approves this exact head and the canonical verdict line is flipped in place tomerge-approvedwith the actual reviewer identity, then bootstrap reruns green.probepark's approval exists;HaD0Yun's request is still pending.
No fix-forward was needed: the code is correct as-is against current dev, and pushing a rebase now would churn the exact head behind an authorized approval for no defect. Implementation is validated; disposition is blocked only on the two owner actions above, not on any code change.
Canonical verdict remains: gajae.pr-review-verdict.v1 needs-human sha256:866540568b165d0d97f7e8538cbc7144f8985364b583895667c58077d3c9a36b reviewer:human reviewer-id:pending evidence:exact-head-96754755-current-dev-f024ded6-reconciled-code-clean-dev-red-blocks-rebase
—
[repo owner's gaebal-gajae (clawdbot) 🦞]
1f83d5b to
186c948
Compare
Head refreshed to current dev — prior approval intentionally invalidated
What changed and what did not:
Fresh verification on the refreshed head (local, current dev + delta): focused #4566 suite 6/6; On the prior — |
186c948 to
3b953cb
Compare
Second head refresh to current dev
|
Replacement CI terminal on exact head
|
Owner-controlled hold — exact-head review is the sole remaining gateSole-ownership coverage re-established after an SDK session reset. Live state re-read and bound before this post; no code or head change was made. Binding (live, verified 2026-08-15T11:3xZ):
CI classification on the exact head (complete, no reruns):
Review state (the gate):
Standing instruction to reviewers: re-review at head Until that approval lands, this PR stays held in exactly its current state: no rebase churn onto a newer dev (any head change re-invalidates review/CI/verdict from zero), no verdict fabrication, no merge. — |
Full-file oldText/newText snapshots made tiny edits consume roughly twice the target file size in managed transcripts. Persist bounded digest receipts instead and classify near-limit recovery when a committed edit cannot be recorded durably. Lore-id: issue-4566-apply-patch-transcript Constraint: preserve live ACP full-snapshot diff rendering while bounding durable transcript entries Constraint: keep concurrent workflow-gate changes outside this commit Tested: repeated large-file patches, multi-file receipts, sub-cap snapshots, near-limit effect/receipt recovery Not-tested: full aggregate typecheck is independently blocked by concurrent WorkflowGateBroker.instanceId test changes Confidence: high Scope-risk: medium Reversibility: clean-revert
Generic persistence truncation previously ran before snapshot receipt generation, so files above 500k could receive digests for truncated prefixes. Generate bounded edit receipts first and pin exact byte/hash identity beyond the generic cap. Lore-id: issue-4566-exact-snapshot-digests Constraint: preserve the bounded durable representation and live ACP bodies Tested: exact SHA-256 and UTF-8 byte lengths for snapshots above 500k Confidence: high Scope-risk: narrow Reversibility: clean-revert
3b953cb to
055546b
Compare
Reconstructed onto current dev — third refresh, sole-owner coverage heldThe PR was stale behind dev (base New binding (live):
Fresh verification on the reconstructed head (local worktree):
Standing state: prior approvals remain void by contract ( — |
probepark
left a comment
There was a problem hiding this comment.
Approve at 055546bd3
Head moved since my approval of 96754755a; same change rebased onto 804314081, re-verified at
the exact head.
Differential
# base 804314081, with this head's test file applied
(fail) edit-result persistence bounding (#4566) > keeps transcript growth bounded independently of file size across repeated apply_patch results [5056.71ms]
(fail) edit-result persistence bounding (#4566) > computes snapshot receipts for generic 500k persistence truncation
(fail) edit-result persistence bounding (#4566) > bounds per-file copies in multi-file apply_patch results
(fail) near-limit edit append after committed mutation (#4566) > recovers the append via full rewrite, keeps the committed edit durable, and states the recovery path
(fail) near-limit edit append after committed mutation (#4566) > surfaces the typed near-limit outcome when even the rewrite cannot hold the entry
1 pass 5 fail
# head 055546bd3
6 pass 0 fail
$ bun --cwd=packages/coding-agent run check -> exit 0
Five of six fail on base, and the first one fails as a 5-second timeout - unbounded transcript
growth showing up as a hang rather than an assertion mismatch.
The substantive review stands from my earlier pass: hashing edit snapshots before truncation keeps
identity independent of the display bound, so two different patches whose surviving prefixes match
cannot collide. keeps transcript growth bounded independently of file size is the assertion that
pins the actual product property rather than the mechanism.
merge-approved at 055546bd3.
Reviewed by @probepark - method: fresh-worktree run and package typecheck at the exact head, separate clean base worktree with the head's test file to prove the differential.
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
The #4573 backport test hard-coded dev's 128 MiB managed-file cap; main's base still uses 64 MiB. Asserting the exported constant keeps the test correct on both bases. Lore-id: 3f2a9c1e Confidence: high Scope-risk: narrow Reversibility: trivial Tested: edit-result-persistence-bounding suite, 6 pass
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Dev #4573 wired session-manager to the edit renderer for bounded edit-snapshot receipts, which pulled renderer/streaming (and the hashline barrel cycle) into session-manager's module-init order. Any test importing the edit barrel or web-scrapers first then hit 'ReferenceError: Cannot access END_PATCH_MARKER before initialization' (analogous handleYouTube/handleDockerHub TDZ), failing dev shards 1-4/7-8 repo-wide. Move the three pure receipt helpers into node-builtin-only leaf edit/snapshot-receipt.ts; renderer re-exports unchanged; session-manager imports the leaf. Discriminating regression test pins barrel-first initialization. Lore-id: issue-4593-edit-tdz Constraint: no behavior change - renderer re-export is the same public surface Tested: apply-patch-adverserial, safe-summary, package-managers-2, youtube, edit-result-persistence-bounding, session-manager suites, ci-dev-affected selftests, coordinator 18-suite set Confidence: high Scope-risk: narrow Reversibility: clean-revert
Summary
Fixes #4566 by bounding durable edit-result snapshot metadata independently of the edited file size.
Large
EditToolDetails.oldText/newTextbodies (includingperFileResults[]) are replaced only at the session-persistence boundary with fixed-size{ bytes, sha256 }receipts plus an externalization marker. Live in-process results keep complete bodies, preserving ACP diff rendering and editor consumers.Near-limit managed appends now have a typed deterministic failure contract. The existing
content_too_largerewrite recovery is verified; if the rewrite cannot durably hold the entry,SessionNearLimitAppendErrorstates whether the entry/committed edit receipt remains resident and how to continue (/compactorgjc export).Exact revision (refreshed 2026-08-15, third refresh — reconstruct onto current dev)
804314081fe9d3f4d34014d1385f09d8d49a7116(currentorigin/dev, includes fix(sdk): broadcast positioned session events live to attached subscribers #4570, fix(browser): stabilize Chrome default-root refusal #4575, fix(agent): serialize detached managed snapshots #4580, fix(sdk): keep Windows OS probes and slow syncs off the session-index lock (#4544) #4555)055546bd38cf2ada32b6ad8f0b95ae2d74a2e13d(the original two fix(session): bound apply_patch transcript metadata #4573 commits rebased onto current dev; source delta byte-identical to the previously reviewed heads96754755ad,186c948f73,3b953cb195— verified bygit patch-id --stableoversrc/+test/+scripts/+packages/source paths; onlyCHANGELOG.mdordering adapted)git diff --binary --full-index --no-ext-diff 804314081f...055546bd38):1e0edc73077284c2539b7b6c37f10ed0fa772d90d6942d370f4885d0187b35f7CHANGELOG.md,edit/renderer.ts,session/agent-session.ts,session/session-manager.ts, regression test)Overlap audit vs current dev deltas (through #4555)
session-manager.tsin the Windows probe/sync region only; this PR'ssession-manager.tsdelta is confined to the edit-snapshot bounding at the persistence boundary — disjoint regions, rebase applied cleanly.agent-session.tsin the managed-fallback retry region only; this PR'sagent-session.tsdelta is confined to theappendMessagecatch mapping (SessionNearLimitAppendErrorhandler at the tool-result persistence site) — semantically disjoint regions, rebase applied cleanly, no hunks reflowed into the fallback code.Reproduction and result
Synthetic fixture: 464,979-byte source file, repeated one-line
apply_patchupdates.943,242durable bytes/patch (2.03xtarget file size)1,398durable bytes/patch (0.003xtarget file size)Verification on refreshed head
055546bd38(current dev804314081f)bun test packages/coding-agent/test/edit-result-persistence-bounding.test.ts— 6 pass, 0 failbun test ./packages/coding-agent/test/session-manager/ ./packages/coding-agent/test/session/— 677 pass, 26 skip, 0 failbun --cwd=packages/coding-agent run check:types— passbun --cwd=packages/coding-agent run build— pass (dist/gjc compiled)bun scripts/verify-gjc-state-writers.ts --fail— pass (0 write sites outside sanctioned writers)Review focus
gajae.pr-review-verdict.v1 merge-approved sha256:1e0edc73077284c2539b7b6c37f10ed0fa772d90d6942d370f4885d0187b35f7 reviewer:human reviewer-id:probepark evidence:exact-head-055546bd38-current-dev-804314081f-fresh-independent-approval-by-probepark-2026-08-15T13:08:44Z-write-authorized-differential-review-5of6-fail-on-base-6of6-pass-on-head
—
[repo owner's gaebal-gajae (clawdbot) 🦞]