Rebuild /compare to diff two extraction.json runs side-by-side#17
Open
Khaostica wants to merge 1 commit into
Open
Rebuild /compare to diff two extraction.json runs side-by-side#17Khaostica wants to merge 1 commit into
Khaostica wants to merge 1 commit into
Conversation
Replaces the placeholder /compare page with a real side-by-side viewer that
walks both extraction trees, preserves per-value evidence, and reports
confidence deltas.
- lib/pipeline/extraction-diff.ts: pure diff function over {value, evidence}
fields, scalar sets (workload_tags etc), and keyed row lists (cpu_skus,
pcie_slots) with slug/id/sku/name preference and positional fallback.
- app/api/compare/route.ts: GET /api/compare?left=<slug>&right=<slug>.
- app/compare/page.tsx + _components/{ComparePicker,DiffTable}.tsx: server
component shell with client-side pickers, collapse-unchanged toggle, and
expand-evidence cells.
- tests/unit/extraction-diff.test.ts: 13 unit tests covering identity, scalar
changes, add/remove, set diffs, keyed-row diffs, positional fallback, and
confidence-delta semantics.
Cross-category comparison is rejected by both the API (409) and the page;
run-id comparison (two runs of the same product) is intentionally deferred.
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
Rebuilds
/comparefrom a placeholder into a real side-by-side diff viewer for twoextraction.jsontrees. Walks every field, preserves per-valueevidenceblocks (source, page, quote, confidence), and surfaces confidence deltas.What's in here
lib/pipeline/extraction-diff.ts— purediffExtractions(left, right)function. Handles{ value, evidence }scalars, scalar sets (multiset semantics — reorder is unchanged), and keyed row lists (slug | id | sku | name | code, with positional fallback). Identity keys (vendor,slug,extraction_metadata,sources, …) are excluded from diff rows and surfaced as page-header context.app/api/compare/route.ts—GET /api/compare?left=<slug>&right=<slug>.400on missing/equal params,404on unresolved slug,409on cross-category attempt.app/compare/page.tsx+_components/{ComparePicker,DiffTable}.tsx— server-component shell with URL-synced client pickers, summary pills, collapse-unchanged toggle, expand-evidence cells, keyed-list groups./comparebetween Audit and Usage.tests/unit/extraction-diff.test.tscovering identity capture, identical-tree no-op, scalar change with evidence, null-equality, added/removed asymmetry, set diff with reorder, keyed-row diff byslug, positional fallback, and confidence-delta semantics.Run-id comparison (two runs of the same product) is intentionally deferred; see the linked issue for the follow-up.
Related Issues
Closes #16.
Type of Change
Testing
tests/unit/extraction-diff.test.ts, 13 cases, all green.npx tsc --noEmitclean;npx vitest run48/48;npx next buildsucceeds and registers/compare+/api/compare.npm run devshows the empty-state on the bundled sample (only one extraction on disk); the diff path is covered by unit tests until a second sample lands.Checklist
extraction-diff.tsand the API route).