Repository navigation
feat(serve): add review diff view with word highlights and risk-ordered change lanes (STA-395) - #257
Merged
Merged
Conversation
…ane (STA-395)
Pure-Go diff engine in internal/diff (stdlib only): unified full.diff
parser, histogram line diff with Myers fallback and an indent heuristic,
word-level intraline spans, collapsed-gap tracking, and deterministic
9-lane classification in risk order. Query layer Diff composes lanes,
files with word spans, anchored findings, and sources from the confined
bundle; GET /v1/roots/{root}/bundles/{bundle}/diff serves it read-only
and report --html snapshots it. Embedded UI gains a Diff tab with
unified/side-by-side toggle, lane table, word highlights, collapsed gaps,
and anchored findings (all DOM via createElement/textContent).
Size (make size, narrowed ceilings raised to next 10 kB with headroom):
darwin/amd64 20262784 (budget 20280000), darwin/arm64 18381506
(18390000), linux/amd64 19923104 (19940000), linux/arm64 17957024
(17970000), windows/amd64 20351488 (20360000), windows/arm64 18119680
(18130000); deps 0.
- Resolve scripts/size-baseline.txt: taking STA-395 ceilings (max) - Merges STA-468 azure-post changes, docs/manual.md auto-merges cleanly at separate hunks with zero conflict markers Byte ceilings in this merge: - Proceeding to measure sizes; final ratchet updated in follow-up Fix R1 commit.
B1 toInt handles json.Number (UseNumber): added json.Number/float64 cases matching budget.go, sorted by_lens keys deterministically, added query + HTTP tests writing real findings.json and asserting anchored findings (path/line/side) and non-zero findings/by_lens. B2 parser hunk tracking: added oldRem/newRem from @@ headers; while in hunk lines starting with +,-,space or single-backslash are content never metadata (---/+++/index/rename/copy). Fixed double-backslash raw literal to single-backslash. Fixture tests for -- sql comment, +++ x, --- a/fake inside hunk, index inside hunk, diff-of-a-diff, single-backslash marker, hunk count expiry. B3 histogramAnchor determinism: scan a in index order with earliest-position tie-break (total then pa then pb) instead of Go map iteration; test runs 64 tied inputs asserting one exact literal edit script EQ[a,b,a,b] DEL[x] INS[y] EQ[a,b]. B4 readDiffText/diff.Parse errors propagate to partial:true and errors[] via errRow; loadDiffFiles now returns ErrRows with diff-too-large/diff-missing/diff-parse-error codes, buildDiffView/diffPayload wire partial and errors. Tests for oversized (11MiB) and missing full.diff assert partial true + non-empty errors. B5 git histogram parity: TestDiffLinesHistogramMatchesGit now compares deleted/added texts per @@ hunk against real git diff --diff-algorithm=histogram on multi-case corpus (simple, inserts, deletes, replace, dupes, blankSlide); trivial delete-all fails both parity and count minimality, proving real hunk-boundary check. TestIndentationHeuristicSlides now exercises production DiffLines (flipping linesDiff to false fails). TestDiffWordPassMutation proves word pass via anySpans. B6 lane classification: isConfigBase uses lowercase/EqualFold-style switch so Makefile/Dockerfile/Dockerfile.dev/cmd/Makefile classify as config (pinned literal), stripSpace collapsed to Join(Fields," ") so indentation/multiple/trailing-space edits stay whitespace while msg:=\"a b\"->\"ab\" stays source (pinned both), WhatsApp separators normalized \\->/ for path lanes (pinned). B7 word spans: PairWordSpans flushes on context lines, pairing only contiguous del run immediately followed by add run inside a block; cross-boundary del/ctx/add gets unpaired all-changed spans, proven by del alpha one / ctx separator / add beta two test asserting single-span unpaired. B8 HTTP diff_test.go mirrors compare: 200 + serve envelope + lanes order + collapsed gap + anchored finding from real findings.json (json.Number line 1 RIGHT), works with interactive OFF, POST 405, missing token 401, foreign Origin 403, unknown bundle 404. B9 dark mode: diff backgrounds (#d9f2e2 etc) moved to :root custom properties and @media dark overrides matching --ink #e7edf2 contrast; no hardcoded hex in component rules; TestUIBudget/TestCSPAssets clean. Also: remove unused DiffView alias; docs/manual.md sources[] wording now view-level + anchored findings/by_lens; size ratchet next-10kB with >=8192 headroom. Measured binary sizes (release -s -w): darwin/amd64 20365872 -> budget 20380000 (14128 headroom) darwin/arm64 18464786 -> budget 18480000 (15214 headroom) linux/amd64 20025504 -> budget 20040000 (14496 headroom) linux/arm64 18022560 -> budget 18040000 (17440 headroom) windows/amd64 20457984 -> budget 20470000 (12016 headroom) windows/arm64 18209280 -> budget 18220000 (10720 headroom) UI static total 48045 bytes well under 96KiB (98304). Mutation proofs: - indent heuristic: DiffLines equals LinesWithHeuristic(true) and not false (flip fails) - git histogram: delete-all/insert-all fails hunk parity and count minimality - word pass: dropping PairWordSpans fails TestDiffWordPassMutation (anySpans false)
# Conflicts: # scripts/size-baseline.txt
… determinism pin, manual polish F1: diffFixtureFiles gains a second hunk (@@ -40) and two anchored findings on lenses alpha/zeta; TestDiffRoute asserts hunks[1].gap_before == 37 (40 - (1+2)) exactly and that by_lens keys render alpha before zeta in the raw envelope body. F2: TestHistogramDeterminismAnchorSensitive pins the tied pair a=[a a a a a b] b=[b a b b b b]: histogramAnchor returns "a" (both totals 6, earliest position breaks the tie) and DiffLines returns the exact literal INS[b] EQ[a] DEL[a,a,a,a] EQ[b] INS[b,b,b] across 64 runs. Mutation-checked: flipping the tie-break to pick "b" fails the new test at the anchor assertion, then reverts green. Polish: manual Review diff now says data.sources[], keeps by_lens lane-level, and notes line-less findings are excluded from lane counts and row anchors (per addFinding). No-newline marker comment reframed as a style/parser pin. Size re-measure (growth is STA-395 serve layer + merged PRs #251 STA-469 + #254 STA-341; each ceiling raised to the next 10 kB with >=8192B headroom): darwin/amd64 20525456, darwin/arm64 18617330, linux/amd64 20181152, linux/arm64 18153632, windows/amd64 20615680, windows/arm64 18351616, deps 0.
Merge STA-423 fix --recipe (7c13a29) into STA-395 diff view (4b555e0). docs/manual.md auto-merges with both the diff-view (by_lens, gap_before) and fix --recipe sections intact; only scripts/size-baseline.txt conflicts, resolved by taking the higher ceiling per platform then measuring the merged binary. Measured sizes (make size, -s -w, version 0.0.0): - darwin/amd64: 20541936 bytes → ceiling 20560000 - darwin/arm64: 18633970 bytes → ceiling 18650000 - linux/amd64: 20197536 bytes → ceiling 20210000 - linux/arm64: 18153632 bytes → ceiling 18170000 (unchanged, 16368 headroom) - windows/amd64: 20633088 bytes → ceiling 20650000 - windows/arm64: 18367488 bytes → ceiling 18380000 All ceilings raised only to the next 10 kB boundary leaving >=8192 bytes headroom after merge growth.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 10 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
SutuSebastian
added a commit
that referenced
this pull request
Nov 24, 2026
Merge commit resolving scripts/size-baseline.txt conflict, taking the higher (larger) baseline for each platform from both sides: darwin/amd64 20560000, darwin/arm64 18650000, linux/amd64 20210000, linux/arm64 18170000, windows/amd64 20650000, windows/arm64 18380000. docs/manual.md auto-merged cleanly with no conflict markers.
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
Implements STA-395: adds a pure-Go review diff engine (
internal/diff), deterministic risk-ordered change lanes, anchored findings, server-computed word-level highlights, and averdict serveDiff tab (unified + side-by-side) with dark-mode support and staticreport --htmlsnapshot export.What changed
internal/diff, stdlib-only, zero new deps):full.diffparser with active hunk-remainder tracking (content lines beginning with--,+++,---,index,rename,copynever corrupt metadata;\ No newline at end of filehandled cleanly).DiffLines), verified against realgit diff --diff-algorithm=histogramhunks.PairWordSpans) and collapsed unchanged-line gap tracking (gap_before).schema,source,config,tests,docs,generated,lockfiles,renamed,whitespace) in risk order with case-insensitive config bases (Makefile/Dockerfile), collapsed-whitespace detection, and Windows\path normalization.verdict serveroute, & HTML export (internal/core/query/diff.go,internal/serve/):Layer.Diffover root-confinedfull.diff+findings.jsonwithdata.sources[]traceability,partial/errors[]propagation on oversized/unreadable diffs, anchored findings (json.Numberline support), and deterministic sortedby_lenscounts.GET /v1/roots/{root}/bundles/{bundle}/diff(works without--interactive, guarded bys.guard, full HTTP test matrix ininternal/serve/diff_test.go) and static export support ininternal/serve/export.go.internal/webui/static/):… N unchanged linescollapsed gaps, anchored finding cards, and dark-mode CSS custom properties (48,045 / 98,304bytes, zeroinnerHTML/eval/inline code,28/28app.test.mjspassing).Verification
maxR1 → Muse Ember Fix R1 → DeepSeek FlashmaxR2 → Muse Ember Fix R2 → DeepSeek FlashmaxR3 APPROVE, with independently reproduced mutation proofs for indent sliding, git histogram hunk parity, deterministic anchor tie-break, word spans,gap_before, andby_lensorder).158/158evals (make evals), fullgo test -race -shuffle=on -count=1 ./...green,make build,make vet,make deadcode(0 new),make schemas-check,cmd/tsgen&gen-ts-types.mjs --checkcurrent,make cross(6/6),make size(all 6 targets ≥8 KB headroom),golangci-lint run ./...(0 issues),bun test(28/28),gofmt -l .empty.Closes STA-395 (and unblocks STA-493 Tier C
--allow-post).