fix(retained): clamp over-bound strings in the retained delta copy - #192
Merged
Conversation
…stead of killing the stream A codex director at xhigh effort emits legitimate single events holding a whole charter or ledger (measured 2026-08-31: strings to 1,048,547 chars in one rollout event, against the envelope contract's 16,384). The retained write threw from RuntimeEventEnvelopeSchema inside commitDelta, and the throw propagated through RunReplayLog.append into DeltaRunStream.pump — the LIVE stream died with the caller's work: three 10-minute director attempts lost per run, every codex director husked. The retained copy is now clamped per string to the contract bound with a marked truncation carrying the original length; the schema still validates after the clamp, so a contract drift fails loudly. The in-memory replay log keeps the full delta. Regression test appends a 1.12M-char content string: the append succeeds, reasoning is untouched, the marker names the length. The 10 pre-existing 'retained Agent Interface sessions' failures (409 vs 202) reproduce identically on the pre-edit tree — tree-state, not this change.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Codex directors at xhigh emit single events with megabyte strings (measured: 1,048,547 chars vs the contract's 16,384). The retained-store refusal killed the live stream via commitDelta → every codex director husked at 0 iterations after three 10-minute dead attempts. Fix: clamp the RETAINED copy per string (marked truncation with original length), keep the live/in-memory replay full, let the schema still validate post-clamp. Regression test included; tsc clean; the 10 pre-existing
retained Agent Interface sessionsfailures reproduce on the pre-edit tree (verified by stash-rerun).🤖 Generated with Claude Code