Repository navigation
fix(workflows): enforce text projection line bounds - #331
Merged
tt-a1i merged 1 commit intoSep 1, 2026
Merged
Conversation
tt-a1i
approved these changes
Sep 1, 2026
tt-a1i
left a comment
Collaborator
There was a problem hiding this comment.
Reviewed at exact head ded53f0. The change enforces the existing maxBytes/maxLines projection contract without altering canonical Workflow results or persisted artifacts. CI and focused boundary coverage are green; no blocking findings.
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.
Problem
Closes #329.
projectText()detects overflow with bothmaxBytesandmaxLines, but the existing head/tail projection only applies byte limits. Its final validation also checks only the byte count.A 40-line, 149-byte input projected with
maxLines: 3andmaxBytes: 2048therefore produces 85 lines and duplicates the complete input around the omission marker. The footer reportsshowing 298 B of 149 B, confirming that the selected head and tail overlap.This affects bounded Workflow result messages, completion batches, handoffs, and operator-facing completion reports.
Value
This change makes the
{ maxBytes, maxLines }contract dependable. A caller that allocates 400 lines can treat that value as a hard upper bound rather than a hint that is checked once and then lost during projection. The byte limit cannot replace the line limit: logs, file lists, and compact records can contain hundreds of short lines while remaining well below their byte budget.For model-facing Workflow results, enforcing both limits keeps projected output within the context shape selected by the caller. The current bug can turn a small line-only overflow into a larger result by including the same source text as both the head and the tail. Removing that overlap avoids spending context on duplicate evidence and leaves the available projection budget for distinct information from the beginning and end of the result.
This also improves the quality of the evidence presented to the model. Repeating the same conclusion or error text can give it disproportionate weight during synthesis, even though the repetition was introduced by the projection layer rather than the Workflow itself. A non-overlapping head/tail projection preserves more of the source's actual coverage and does not manufacture repetition.
The same helper is used for parent-model result delivery, background completion batches, downstream handoffs, and expanded operator reports. Fixing the shared projection contract gives those paths consistent behavior without adding separate truncation rules to each Workflow surface.
Finally, projection diagnostics become internally consistent. A footer such as
showing 298 B of 149 Bis impossible when the selected source ranges do not overlap, and the reported bounds once again describe the text that was actually returned.The change is limited to derived projections. Workflow execution, canonical results, persisted audit artifacts, and configured production limits are unchanged. Content that already fits both limits still passes through byte-for-byte, while the exact source remains recoverable from the existing artifacts when projection is required.
Approach
Validation
Passed:
git diff --checkTarget-file Biome format check
Target-file Biome lint with
--error-on-warningsbun run lint— 280 files checkedtsc --noEmitnode scripts/check-config-contract.mjs— 14 persisted fields checkednode scripts/check-discipline-ledger.mjs— 12 append-only rows checkedRelevant Node tests:
Result: 40 passed, 0 failed.
Not completed cleanly in the existing Windows checkout:
bun run checkreachesformat:check, which reports 262 formatting diagnostics caused by pre-existing CRLF working-tree files outside this PR. Both changed files pass the same formatter, and full lint plus type checking pass separately.bun run testreaches the existing Windowsbackground-terminalsprocess-termination failures and then stops making progress. Four failures were observed in that area before the run was interrupted. This matches test: eliminate Windows background-terminal process-test flakes in the full suite #304; this PR does not modify background terminal code.No benchmark was run because the change affects bounded text selection rather than a performance-sensitive execution path.
Impact