Skip to content

feat(core): array drift summarization in classifyDiff (ADR 0017)#341

Merged
rejifald merged 3 commits into
mainfrom
feat/adr-0017-array-drift-summarization
Jun 30, 2026
Merged

feat(core): array drift summarization in classifyDiff (ADR 0017)#341
rejifald merged 3 commits into
mainfrom
feat/adr-0017-array-drift-summarization

Conversation

@rejifald

Copy link
Copy Markdown
Owner

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-wins change|path dedup 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:

  • 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 (items[3].x)
  • 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 (semantics unchanged)

DriftFinding gains one optional sample?: string. diff.ts stays 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/core tests: 1083 passed, incl. 6 new array cases (homogeneous, heterogeneous, single-outlier-no-flood, scalar-array, single-element).

Notes

  • Independent of 0018/0019 — builds on merged ADR 0015. Mergeable on its own.

🤖 Generated with Claude Code

rejifald and others added 2 commits June 29, 2026 00:00
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>
@rejifald rejifald closed this Jun 30, 2026
@rejifald rejifald reopened this Jun 30, 2026
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>
@rejifald rejifald merged commit c58a90a into main Jun 30, 2026
9 checks passed
@rejifald rejifald deleted the feat/adr-0017-array-drift-summarization branch June 30, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant