Repository navigation
followup: close 8 pre-existing test failures (pdf fixtures + UI build wiring) - #2
Merged
Merged
Conversation
…d chores Followup PR scoping for the 8 unchanged pre-existing test failures called out in the audit PR (S1-S3 + H1-H5 + M1-M9 sweep, merged at d544ea7). Both chores are single-concern, single-commit-shaped, and small (≤30 LOC each). Synopses include exact file:line refs, failure modes, fix options, and acceptance criteria so each can be executed independently. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zaynram
marked this pull request as ready for review
May 29, 2026 16:58
Closes chore pdf-test-fakectx-pdfviews-fixture. S1's §13 v1.1 amendment introduced ctx.pdfViews: Map<paper_id, viewUUID> as the viewUUID resolution surface (refreshExtraction at pdf.ts:141 does `ctx.pdfViews.get(args.paper_id)`). fakeCtx never populated it, leaving the 5 refresh-extraction tests failing at TypeError. Production code path is unchanged; the gap was test-only. Extend fakeCtx with an optional `paperId` opt that seeds `<paperId> -> view-<paperId>`. Each failing test now passes its paper_id via the same fakeCtx call. Suite: 6/6 pdf.test.ts pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Followup to PR #1 that resolves the 8 pre-existing test failures via two small, isolated fixes: seeding ctx.pdfViews in the pdf.test.ts fakeCtx helper, and fixing the build:ui/measure-bundle package scripts that were running with the wrong cwd.
Changes:
- Extend
fakeCtxinpdf.test.tsto accept apaperIdopt and pre-populatepdfViewswithview-<paperId>, updating all 5refresh-extractiontests accordingly. - Drop
--cwd=scriptsfrom thebuild:uiandmeasure-bundlescripts inpackage.jsonso repo-root-relative paths inside the scripts resolve correctly. - Document both chores in
.claude/context/chores.xmlwith statusclosedand fulfillment SHAs.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/server/tools/pdf.test.ts | Seeds ctx.pdfViews via new paperId opt on fakeCtx; updates 5 callers. |
| package.json | Switches build:ui and measure-bundle from bun --cwd=scripts <name> to bun scripts/<name>.ts. |
| .claude/context/chores.xml | Records both chores as closed with fulfillment commit refs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Closes chore fix-build-ui-script-cwd-paths. `bun --cwd=scripts X` shifted
cwd to scripts/ before running the script, but build-ui.ts and
measure-bundle.ts both pass repo-root-relative paths internally
("src/ui/index.html", "build/ui") that no longer resolve from scripts/.
Result: bun run build:ui exited with FileNotFound for src/ui; bundle.test.ts
beforeAll silently swallowed the build error and the 3 bundle-budget
assertions failed on missing artifacts.
Fix is option A from the chore: drop --cwd=scripts and call the script
file directly. Other --cwd=scripts entries (build:pdf, build:vec,
build:plugin) left untouched — out of chore scope; their bodies may
genuinely depend on cwd=scripts and no failing test exercises them.
Suite reaches 297 pass / 8 skip / 0 fail (was 289 / 8 / 8 on PR1).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Test fixtures resolve vec0 via runtime/vendor/sqlite-vec/vec0.so (tests/util/vec0.ts). runtime/ is gitignored per CLAUDE.md (per-user state), so CI must materialize vec0 before bun test runs — otherwise loadExtension fails and 23+ tests cascade-fail through the chunk_vec virtual table. The Smoke step that previously ran AFTER test compiled vec0 to /tmp/ which the test fixtures don't look for. Replace that flow by calling bun run build:vec before bun test; build-vec0 emits to the canonical runtime/vendor location and caches by file existence. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…arent
When invoked as a script via \`bun run build:vec\`, the if-main block
passed util.subpath("build/vendor/sqlite-vec") — a DIRECTORY — to
compileVec0FromSource, which then handed it to gcc as the -o output.
ld errored "cannot open output file ...: No such file or directory"
because the parent dir wasn't created either.
Fix: append the platform-specific filename (vec0.{so,dylib,dll}) when
calling compileVec0FromSource at script entry, and mkdirSync the parent
of destPath inside the compile function before invoking the compiler.
Verified locally by deleting build/vendor/sqlite-vec + runtime/vendor/
sqlite-vec and running bun run build:vec — both locations now populated
with the compiled vec0.so. Suite remains at 297 pass / 0 fail.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bun:test mock.module() is process-global; the unscoped mock.module at ingest.test.ts module-load time persisted into later test files (roots.test.ts), making allPdfRoots return ["/tmp"] for tests that needed the real DB-backed lookup. Local bun 1.3.14 happens to isolate this; CI's 1.3.11 surfaces it as roots.add seeing setRoots called with ["/tmp"] instead of the test's tmpdir-rooted paths. Snapshot the real default-pdf-root exports at module load, install the mock in beforeAll, and re-mock with the real exports in afterAll. The hygiene is bun-version-agnostic and the right pattern regardless. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zaynram
added a commit
that referenced
this pull request
Jun 6, 2026
…inels (#2) Cowork field test (2026-06-05): refresh-extraction reported chunks_written:1 on a failed extraction and silently poisoned the corpus with the child's error text. Root cause: the vendored pdf child returns failures as the standard MCP error envelope `{ content:[{type:"text",text:<msg>}], isError:true }`, and the SDK's `callTool` does NOT throw on `isError` (it's an in-band tool error for the model to read). `getText` flattened that error text and returned it as if it were document text, so refreshExtraction chunked + embedded the one-line sentinel. Fix: extract a pure `parseGetTextResult` that throws `PDF_GET_TEXT_FAILED` on the isError envelope and flattens the success content otherwise; `getText` routes through it. The failure now propagates out of refreshExtraction instead of writing a bogus single chunk. The child responded (it's alive), so the liveness stamp is kept. Pure helper ⇒ unit-tested directly (isError throws / success flattens / bare-string passthrough / labelled error when isError has no message), mirroring sanitizeRoots + buildClientCapabilities. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
zaynram
added a commit
that referenced
this pull request
Jun 6, 2026
…pagates get_text errors, writes zero chunks The parseGetTextResult unit tests (lifecycle.test.ts) prove the seam throws on the vendor isError envelope, and getText routes through it (lifecycle.ts:320). This adds the caller-layer proof the advisor required: the field report's #2 is about refreshExtraction, which must propagate the failure instead of chunking the error sentinel and reporting chunks_written:1. Highest fidelity short of a real spawn: the stubbed getText runs the REAL parseGetTextResult on an isError envelope (exactly what the production handle does), so the test exercises the wired path child-error → getText throws → caller propagates — not a hand-rolled stand-in. Asserts refreshExtraction rejects with PDF_GET_TEXT_FAILED AND that zero paper_chunks / chunk_vec rows were written (the "not chunks_written:1" claim in concrete form). A swallowing try/catch in the caller would flip the rejection assertion red, so this also guards the no-downgrade property by construction. Verified clean across all three layers: seam (helper unit tests), wiring (getText returns parseGetTextResult at lifecycle.ts:320), caller (this test). 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.
Summary
Followup to #1 (audit-driven hardening, merged at
d544ea7). Scopes the 8 unchanged pre-existing test failures called out in that PR's verification section into two atomic chores. Currently chore-only — no implementation yet — so the user can direct execution per chore.Scope (two chores)
1.
pdf-test-fakectx-pdfviews-fixtureBlast radius:
src/server/tools/pdf.test.tsonly.Closes: 5
refresh-extractiontests failing withTypeError: undefined is not an object (evaluating 'ctx.pdfViews.get').Root cause: S1's §13 v1.1 amendment added
ctx.pdfViews: Map<paper_id, viewUUID>as the viewUUID resolution surface;fakeCtx(pdf.test.ts:63-92) wasn't updated to populate it. Production path (realscholar.pdf.open) works fine.Fix: extend
fakeCtxto acceptpdfViewsarg; pre-populate per test.Estimate: ≤30 LOC, single commit.
2.
fix-build-ui-script-cwd-pathsBlast radius:
package.json(+ optionallyscripts/build-ui.ts,scripts/measure-bundle.ts).Closes: 3
bundle.test.tstests failing on missingbuild/ui/app.htmlandbuild/ui/bundle-budget.json.Root cause:
bun --cwd=scripts build-uishifts cwd toscripts/before runningbuild-ui.ts, but the script passes repo-root-relative paths ("src/ui/index.html","build/ui") that no longer resolve.bundle.test.tsbeforeAll swallows the build error silently.Fix: drop
--cwd=scriptsfrom both scripts (preferred), OR anchor paths toimport.meta.dirin the script files.Estimate: ≤5 LOC, single commit.
Why two chores instead of one bundle
reject-monolithic-scopesdiscipline: these are independent concerns with different blast radii (test fixture vs build pipeline). Splitting lets each land + verify independently and keeps each commit focused.State
main(post-merge, d544ea7).claude/context/chores.xmlwith file:line refs, failure modes, fix options, acceptance criteriapdf-test-fakectx-pdfviews-fixture(single commit, ~30 LOC)fix-build-ui-script-cwd-paths(single commit, ~5 LOC)bunx tsc --noEmitcleanTest plan
bun run build:uisucceeding)🤖 Generated with Claude Code