Repository navigation
Fixture/snapshot tests for split, merge, overlap, and the analyzer - #13
Merged
Merged
Conversation
Deferred since v3.1; now that the Chunkability score makes chunking behavior load-bearing, any change to it should fail a test. 30 tests, node:test only — no new dependencies. Run: npm test. - api/chunk.js gains named exports for the test surface; runtime is unchanged (Vercel only uses the default handler) - tests/chunking.test.js: recursiveSplit limits/ordering/paragraph preference/force-split, mergeSmallChunks, addOverlap (prefix content, recorded count, the exact 29-word clamp from the page that started this, no-op paths), initialism, Flesch-Kincaid ordering - tests/analyzer.test.js: one isolated scenario per flag, including the single-word-heading skip, UWM initialism anchoring, near-duplicates counted once per pair, and overlap-prefix exclusion; per-chunk-average score math; determinism; empty input - tests/fixture-snapshot.test.js: two committed HTML fixtures through the full offline pipeline, deep-equal against committed snapshots (UPDATE_SNAPSHOTS=1 npm test to regenerate intentionally). nested-sections.html is the regression fixture for the v3.3 parent-swallows-child extraction fix - Snapshots use the estimate tokenizer so they don't churn with gpt-tokenizer versions - .github/workflows/test.yml runs the suite on PRs and main pushes - npm test uses a glob: the directory form of node --test fails silently on Node 22.22 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
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.
Stacked on #12 (v3.4). Merge order: #10 → #11 → #12 → #13, retargeting each to main as its base lands.
Why
Deferred since v3.1 — and now overdue: the Chunkability score makes chunking behavior load-bearing, so an accidental change to splitting, merging, overlap, or extraction silently changes client-facing scores. Now it fails a test instead. 30 tests, ~0.6s,
node:testonly — zero new dependencies. Run withnpm test.What's covered
Unit — chunking primitives (
tests/chunking.test.js):recursiveSplit(respects limits, preserves every word in order, prefers paragraph boundaries, force-splits giant sentences),mergeSmallChunks,addOverlap(prefix equals the previous chunk's tail,overlap_word_countrecorded, the exact 29-word clamp case from the page Chuck screenshotted, no-op paths),initialism, and Flesch-Kincaid determinism/ordering.Unit — analyzer (
tests/analyzer.test.js): one isolated scenario per flag — dangling-reference, thin, oversized, generic-heading (and its answer-buried skip), answer-buried (and the single-word-heading skip), no-entity-anchor (and UWM-style initialism anchoring), near-duplicate (flags both chunks, counted once as a pair), overlap-prefix exclusion from duplicate/thin checks, readability info flags — plus the per-chunk-average score math (85/B case with exacttop_fixes), full determinism, and empty input → null.Fixture snapshots (
tests/fixture-snapshot.test.js): two committed HTML fixtures run through the full offline pipeline (extractSourceMetadata → buildChunks → enhanceChunks → analyzeChunks), with the entire result deep-equaled against committed*.snapshot.json. Intentional behavior changes regenerate withUPDATE_SNAPSHOTS=1 npm test, so the diff shows up in review.nested-sections.htmlis the dedicated regression fixture for the v3.3 parent-swallows-child extraction fix, with explicit asserts on top of the snapshot. Snapshots use the estimate tokenizer so they don't churn with gpt-tokenizer releases.Plumbing
api/chunk.jsgains a named-export block for the test surface — runtime unchanged (Vercel only uses the default handler; verified the running API afterward).github/workflows/test.ymlrunsnpm ci && npm teston PRs and pushes to main (Node 22)npm testuses a quoted glob because the directory form ofnode --testfails silently on Node 22.22🤖 Generated with Claude Code