feat(core): array drift summarization in classifyDiff (ADR 0017)#341
Merged
Conversation
Replace classifyDiff's first-wins `change|path` dedup with group-then-summarize. The old dedup silently dropped *heterogeneous* per-element drift (two distinct type-transitions at the same `[]` path collapsed to one, the second discarded). Now: - group diffs by `change|path`; homogeneity = identical `detail` string - homogeneous array group -> one summary finding `all N elements: <detail>` (or `1 element: …` for a lone element) + a `sample` concrete-index path - heterogeneous -> one finding per distinct detail variant, each with its own count + sample; proportional to distinct problems, never per-element - `ignore`/`severity` apply after grouping (unchanged semantics) `DriftFinding` gains one optional `sample?: string` (concrete-index path, array summaries only). `diff.ts` stays index-precise — precision is what makes heterogeneity detectable; per-element values stay recoverable from `.inspect().raw`. Flips ADR 0017 to Accepted. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
group-then-summarize in classifyDiff adds ~0.04/~0.03 KB gzip on the shared
drift/classify path (can't move to a subpath; feeds both the drift event and
Inspection.findings). Whole entry 23.95→24.20, import { stitch } 19.45→19.70 KB;
measured 23.99/19.48, restoring the gate's ~0.2 KB headroom. Advertised size
quotes unchanged (~19/~24 kB, check:size-docs green).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Implements ADR 0017 (flipped to Accepted in this PR). First of three stacked implementation PRs for ADR 0016's deferrals; supersedes the docs-only #337.
What & why
classifyDiff's old first-winschange|pathdedup silently dropped heterogeneous per-element drift — two distinct type-transitions at the same[]path collapsed to one, the second discarded. This replaces it with group-then-summarize:change|path; homogeneity = identicaldetailstringall N elements: <detail>(or1 element: …for a lone element) + asampleconcrete-index path (items[3].x)sample; proportional to distinct problems, never per-elementignore/severityapply after grouping (semantics unchanged)DriftFindinggains one optionalsample?: string.diff.tsstays index-precise — that precision is what makes heterogeneity detectable; per-element values stay recoverable from.inspect().raw.Verification
Pre-commit gate green (format, lint, monorepo typecheck).
packages/coretests: 1083 passed, incl. 6 new array cases (homogeneous, heterogeneous, single-outlier-no-flood, scalar-array, single-element).Notes
🤖 Generated with Claude Code