feat(FAFF-915): trim adversarial-review context to diff-relevant regions - #793
Merged
alechill merged 6 commits intoAug 31, 2026
Conversation
alechill
added a commit
that referenced
this pull request
Aug 31, 2026
Signed-off-by: Alec Hill <alec@shftwst.dev>
Contributor
|
Ready to land. Run this locally in a real terminal: |
…relevant regions Signed-off-by: Alec Hill <alec@shftwst.dev>
Add a diff-relevance filter to review-call.mjs that trims the --context bundle to the regions the diff references before assembly, so a reasoning-ON review of a large payload fits under the empty-out knee. Gated by a byte threshold (byte-identical below it and when --context-trim-bytes 0 disables it); conservative (never drops a diff-touched line); identifier anchors are frequency-capped and a retained-fraction ceiling forces head-retention so a recurring symbol cannot under-trim. Pure and deterministic, so the trimmed context stays identical across the four spec-review lenses and the shared-prefix cache holds. Signed-off-by: Alec Hill <alec@shftwst.dev>
…line desync, headReduce clamp Adversarial code review flagged: (1) a basename-only touched-range key could cross-apply one file's ranges to another same-basename context file — now keyed by full path with exact-or-suffix pathsMatch; (2) a truly empty context line inside a hunk did not advance the new-file line counter, desyncing later touched ranges — now treated as a context line; (3) headReduce could emit a bogus elided count for a negative headLines — now clamped. Tests added for each. Signed-off-by: Alec Hill <alec@shftwst.dev>
…ormalization Round-2 adversarial review flagged: (1) a CRLF-terminated diff's blank context line arrived as a bare CR and did not advance the new-file counter; (2) an added line whose content begins with '+++ ' was misread as a file header; (3) hunks were not bounded by their declared line counts, so a truncated/overrun hunk shifted ranges. Rewrote parseDiffTouched to strip a trailing CR and to bound each hunk by its declared -a,b +c,d counts, so structural tokens are only recognised between hunks and in-hunk body content is parsed correctly. Tests added for CRLF, an in-hunk '+++ ' body line, and multi-file hunk-length attribution. Signed-off-by: Alec Hill <alec@shftwst.dev>
…e ceiling + pure-insertion parse Round-3 review re-raised the retained-ceiling 'drops touched lines' claim (a recurring false positive: the !hasTouched guard exempts any touched file from the ceiling). Added a test proving a touched file over the 0.8 ceiling keeps every touched line beyond headLines, clarified the guard comment, and added a pure-insertion (@@ -0,0 +1,N @@) parse test. Softened the pathsMatch comment to state the bare-basename suffix match is keep-only-safe (over-retains, never under-retains). Signed-off-by: Alec Hill <alec@shftwst.dev>
Signed-off-by: Alec Hill <alec@shftwst.dev>
alechill
force-pushed
the
faff-915-trim-adversarial-review-context-to-diff-relevant-regions
branch
from
August 31, 2026 15:03
a7655f8 to
93e2869
Compare
alechill
deleted the
faff-915-trim-adversarial-review-context-to-diff-relevant-regions
branch
August 31, 2026 15:12
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.
Summary
Adds a diff-relevance filter to
review-call.mjsthat trims the--contextbundle to the regions the diff references before the review payload is assembled. Reasoning-ON reviewers empty out on large payloads (FAFF‑906: the model spends its whole output budget reasoning and emits zero findings); the context bundle is most of that payload while the diff only touches a few regions. Trimming it roughly halves the payload so a reasoning-ON review fits under the empty-out knee. This is the targeted context-trim (the lighter fix), not the general decomposer (FAFF‑916, cancelled).Closes FAFF‑915.
Approach
trimContextFiles({ contextFiles, diff, ... })applied between reading the--contextfiles andassembleUserMessageinmain.--context-trim-bytes 0disables it entirely.Acceptance Criteria
Verified:
test/adversarial-call.test.mjsFAFF‑915 tests 3, 5, 6 — passingreport.bytesAfter <= 0.6 * report.bytesBeforeon the fixed fixture.Verified: FAFF‑915 test 4 — passing
assembleUserMessageoutput is byte-identical and the existing suite passes unchanged.Verified: FAFF‑915 test 1 + full suite
node --test test/adversarial-call.test.mjs→ 284 passVerified: FAFF‑915 tests 7 and "touched over the ceiling keeps all touched lines" — passing
--context-trim-bytes 0disables the trim.Verified: FAFF‑915 test 2 — passing
Verified: FAFF‑915 test 11 — passing
Verified: CLI end-to-end —
[note] FAFF‑915 context trim: 4800 → 693 context byteson fire, silent when disabledVerified: FAFF‑915 test 16 — passing
Verified: FAFF‑915 tests 9, 10 — passing
faff validate-adapters, unit suite,faff lint-refsclean.Verified: validate-adapters PASS (20 slot skills), lint-refs PASS, gate ladder signal pass
Review
Adversarial code review: 4 rounds, terminal verdict
pass. Resolved: full-path range matching, blank/CRLF context-line desync, hunk-length-aware parsing, headReduce clamp. Residual findings were non-gating (a refuted false positive, malformed-input-only edges, documented low-risk items).Closes FAFF-915