Skip to content

audit-driven hardening: S1-S3 + H1-H5 + M1-M9 + review followups - #1

Merged
zaynram merged 33 commits into
mainfrom
worktree-pre-v1-roadmap
May 29, 2026
Merged

zaynram merged 33 commits into
mainfrom
worktree-pre-v1-roadmap

Conversation

@zaynram

@zaynram zaynram commented May 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

Retrospective PR for the 33-commit pre-v1 audit-hardening sweep on worktree-pre-v1-roadmap. Three waves of audit work plus a review-driven followup wave, all landed via TDD with one commit per item.

Scope

Showstoppers (S1-S3) — must-fix before personal-use ship:

  • S1 — pdf-viewer interop rewrite + §13 v1.1 spec amendment (drop inbound reconciliation; push-only annotation flow; vendor {viewUUID, action} wire envelope; scholar.pdf.open view registration; real-vendor contract test gated by SCHOLAR_PDF_E2E=1)
  • S2 — start-server.ts forwards argv to child + propagates SIGINT exit code instead of always exiting 0
  • S3 — Ollama embed/chat wrapped in AbortSignal.timeout (defaults: embed 60s, chat 120s; env-overridable)

High-priority hardening (H1-H5):

  • H1 — argv-form tar neutralizes shell metachars in corpus export
  • H2 — view-opener tools emit structuredContent envelope
  • H3 — papers.test.ts switched to applyMigrations (eliminates schema drift)
  • H4 — resolveVec0Path dev fallback anchored to import.meta.dir, not process.cwd()
  • H5 — applyMigrations asserts PRAGMA foreign_keys=1 before migrating

Medium defensive (M1-M9) — eight Red→Green TDD cycles + one documented acceptance:

  • M1 parent-dir fsync after rename; M3 toTightFloat32 Float32Array bind wrap; M4 embedDim JSON convention; M5 RRF vec LIMIT 200→1000; M6 chunker tail-drop ≤1-word; M7 countBundledMigrations narrowed catch; M8 §13 v1.1 write-then-push idempotency test; M9 realpathSync(root) wrapped in PathEscapeError; M2 Win32 Job Object race documented (closure deferred until Win32 test rig)

Review followups (6 commits) — from /pr-review-toolkit:review-pr on this branch:

  • A1 RawDdlInvariantError thrown when chunk_vec.created='true' && embedDim===null (silently-degraded still_indexing=true was invisible)
  • A2 PathEscapeError preserves underlying realpath err.code via Error.cause
  • M5/M1/M3/M8 test refinements pinning the fixes (each verified Red against the pre-fix state via temp-revert)

Verification

  • Suite: 289 pass / 8 skip / 8 unchanged pre-existing failures
  • Typecheck: bunx tsc --noEmit clean
  • Pre-existing failures (out of scope, tracked for followup PR):
    • 5 pdf.test.ts refresh-extraction tests — fakeCtx not updated to populate ctx.pdfViews after S1's §13 v1.1 amendment
    • 3 UI bundle tests (build/ui/app.html, bundle size, bundle-budget.json) — need bun run build:ui wired into test setup

Test plan

  • Full suite green except for the 8 pre-existing failures documented above
  • Typecheck clean
  • Each TDD cycle verified Red against pre-fix state (where applicable)
  • ROADMAP.md reflects landed status with commit SHAs per batch
  • Followup PR addresses the 8 pre-existing failures (next branch)

🤖 Generated with Claude Code

zaynram and others added 30 commits May 27, 2026 21:26
Replace Bun.$ with Bun.spawn so the wrapper has a handle on the child.
Pass process.argv.slice(2) so `scholar --help` and the CLI `--call`
surface added in foundation-009 actually reach the binary. The pre-S2
wrapper dropped argv on the floor, silently degrading every flag to
stdio-server mode.

SIGINT handler now forwards to the child instead of `process.exit(0)`,
and the parent awaits `child.exited` so its exit code mirrors the
child's. Ctrl-C during a corpus operation no longer reports success
while the child died mid-write.

tests/start-server.test.ts spawns the wrapper against a fixture
SCHOLAR_ROOT with a stub `build/scholar` binary. The stub observes
argv (--help marker) and signals (handler exits 42 on SIGINT), so
both regressions are visible at the test boundary.

Roadmap: S2.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Audit S1 amendment: production-readiness audit (docs/audits/ROADMAP.md)
found that §13 v1.0 referenced `list_annotations` 6+ times but
`@modelcontextprotocol/server-pdf@1.7.2` exposes no such verb. Vendor's
PdfCommand union has no full-enumeration capability; `get_viewer_state`
returns only `selectedAnnotationIds`. Bidirectional reconciliation is
unimplementable without forking the vendor (violates §7.2). Decision (A)
from the audit roadmap is adopted: push-only propagation.

Section changes:
  §2  In-scope annotation surface — push-only model.
  §5.12 pdf.ts file desc — drop search-text + extract-anchors proxies.
  §7.6 PdfChild.interact signature — `(commands[], opts?)` →
       `(cmd: PdfCommand, opts: {viewUUID, signal?, timeoutMs?})`.
       PdfCommand imported from `src/vendor/pdf-server/dist/src/commands.d.ts`
       (vendor's source of truth).
       getText signature — `(viewUUID, opts?)` → `(opts: {viewUUID, ...})`.
  §7.6 ServerContext.pdfViews: Map<string, string> — process-local
       paper_id → viewUUID map. Populated by scholar.pdf.open; consumed
       by annotations.{upsert,delete} and pdf.refresh-extraction.
  §8.2 annotation_tombstones + reconcile_state — retired (no consumer
       under push-only). annotations.deleted_at + rect comments updated.
       paper_dirty_idx dropped (reconciler is gone).
  §9.2 Paper-detail PDF panel — annotation paragraph rewritten to
       describe push-only forwarding via paper_id → viewUUID map.
  §10  Tool catalogue — `scholar.pdf.search-text` and `extract-anchors`
       removed. `scholar.pdf.open` rewritten as a real proxy to vendor
       display_pdf that populates ctx.pdfViews. refresh-extraction
       described as map-consumer.
  §13  Full rewrite. Reconciler retired; three handlers (upsert/delete/
       list) become synchronous DB-write-then-push. New "viewUUID
       propagation" subsection. New failure-semantics subsection.
       Cycle-6.7 verification requirements rewritten — the load-bearing
       new test is the S1 contract test against the real vendor process
       (catches wire-envelope mistakes that handler-level mocks hide).
  §16  Risks table — old LWW row replaced with NO_OPEN_VIEWER failure
       row; new "Vendor-tool truth invariant" row pins the spec ≠
       invented-capability rule.
  §17  Decisions log — tombstones, reconcile-on-read, and reconciler
       algorithm entries marked superseded; new "drop inbound
       reconciliation" entry with full option weighing and knock-on
       effects.

No code changes in this commit — code work happens in a follow-up commit
after spec sign-off (per persona "design stage = low autonomy").

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…lope

S1 audit (2026-05-27, §13 v1.1): vendor @modelcontextprotocol/server-pdf@1.7.2
exposes a single `interact` tool that demands {viewUUID, action, ...rest}.
v1.0 code path enqueued {type: action, ...} without viewUUID — silent miss.

- PdfChild.interact now takes (cmd: PdfCommand, opts: {viewUUID, signal?,
  timeoutMs?})
- PdfChild.getText routes through interact({action: "get_text"}, {viewUUID})
  (vendor exposes no separate get_text tool — was an invented call)
- PdfChild.displayPdf added — separate vendor tool, returns viewUUID
- ServerContext.pdfViews: Map<paper_id, viewUUID>, populated by scholar.pdf.open
- lifecycle.test.ts FIXTURE 4 uses handle.displayPdf() (was a broken
  interact call masquerading as display_pdf)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ration

§13 v1.1 amendment (S1 audit, 2026-05-27):

- annotations.ts: drop reconcile() (depended on list_annotations — a vendor
  tool that does not exist). list = pure DB read. upsert/delete throw
  NO_OPEN_VIEWER if ctx.pdfViews has no entry for paper_id.
  serializeForViewer maps scholar rows → vendor's NoteAnnotation shape
  ({id, type: "note", page, x, y, content}); the v1.0 ad-hoc rect-bearing
  shape was being silently rejected by the vendor's PdfAnnotationDef union.
- annotations.test.ts: 22 tests covering NO_ACTIVE_CORPUS, NO_OPEN_VIEWER,
  write-then-push, idempotency, §12.0 sanitization, rect validation,
  paper-level note vendor shape, scholar.pdf.open ctx.pdfViews registration,
  and the posture-B (no sqlite3-mcp) guard. v1.0 reconciler tests
  (Red-4/5/7b/7c/8b/9) retired with the reconciler.
- pdf.ts: refreshExtraction resolves viewUUID via ctx.pdfViews (was using
  paper_id as viewUUID — third broken assumption the audit surfaced).
  New scholar.pdf.open(paper_id, source) proxies vendor display_pdf and
  populates ctx.pdfViews. v1.0 proxy stubs (open/search-text/extract-anchors)
  dropped — they never mapped to real vendor tools.
- Test fixtures (6 files): added displayPdf stub to mockPdf objects so the
  new PdfChild interface satisfies strict TS.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
New file lifecycle.contract.test.ts — gated by SCHOLAR_PDF_E2E=1 — spawns
the real vendored pdf-server and exercises:

- C1: navigate via the §13 v1.1 envelope {viewUUID, action: "navigate", page}
- C2: add_annotations + remove_annotations with vendor's NoteAnnotation
      shape ({id, type: "note", page, x, y, content})

If serializeForViewer drifts from the vendor's PdfAnnotationDef union, or
if interact()'s envelope translator regresses, these fixtures fail at the
wire level rather than at a downstream user-visible bug. Re-vendor
reviewers read this file to know what wire shapes scholar relies on
(§16 vendor-truth invariant).

Notes on what is intentionally NOT covered:
- get_text: requires a live viewer process to complete (envelope is
  already covered indirectly by C1+C2 going through the same translator).
- list_annotations: vendor does not expose this command (the entire point
  of the §13 amendment).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The §13 v1.1 code amendment introduced PdfChild.displayPdf() to wrap the
vendor's `display_pdf` tool (separate from interact). The §7.6 contract
block missed the corresponding entry — adding it now so the spec and the
TypeScript interface match.

No behavioral change; spec text follow-up only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
S1 (pdf-viewer interop rewrite + §13 amendment) is complete on
worktree-s1-pdf-interop-and-13-amendment (a2659b9 → 31d5692). Roadmap
checklist updated to reflect what landed; future audits will refer to
these commits when triaging regressions in the interop surface.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
After consolidating S1 work onto the S2 branch via cherry-pick, the
`worktree-s1-pdf-interop-and-13-amendment` branch was deleted and
`worktree-s2-cli-argv-sigint` was renamed to `worktree-pre-v1-roadmap`
to reflect that this branch now carries both batches and will accumulate
remaining roadmap work (S3, H1–H5, optionally M1–M9). Commit SHAs are
updated to the live cherry-picked equivalents; the originals are
dangling refs reachable only via reflog until GC.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Audit S3: embed and chat had no timeouts — a hung Ollama process would
stall every caller indefinitely. postJson() now takes a timeoutMs arg;
embed passes 60s, chat passes 120s (matching the roadmap budgets). The
TimeoutError surface stays OllamaUnavailableError so existing catch
sites need no changes.

Defaults are env-overridable (SCHOLAR_OLLAMA_{EMBED,CHAT}_TIMEOUT_MS)
following the baseUrl() pattern, so the regression tests can run in
~0.5s instead of waiting 60s of real time.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
corpus.export composed `sh -c "tar ... -C \"$(dirname '${src}')\" ..."`,
interpolating runtime-root into a shell string. Any quote/backtick/`$()` in
the runtime root broke the command — and worse, opened arbitrary execution
under operator-controlled state. Switch to argv-form spawn; --zstd is
supported by GNU tar ≥1.31 and libarchive ≥3.3.3, so the pipeline-to-zstd
is no longer required.

Test pins success against a hostile path (`scholar-export-dir"ty`) rather
than argv[0] === 'tar', so the implementation can swap to bsdtar later
without retest.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
scholar.paper.show / scholar.corpus.show / scholar.pdf.open returned their
{openView: ...} payload as a JSON-stringified text block only. MCP clients
following the spec dispatch UI on structuredContent, not on text-block
parsing, so the view never opened in compliant hosts.

Wrap the result in both content (text) and structuredContent when the tool
opted into the view-opener shape (handler return includes `openView`).
Non-view tools (e.g. corpus.list) keep the lean text-only envelope.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
seededDb() hand-rolled the papers/paper_chunks DDL inline. The fixture had
silently drifted out of sync with the production schema — missing the
`abstract` column among others — so the search/update tests under it could
have masked real breakage in the columns they didn't touch.

Replace inline DDL with applyMigrations(drizzle(...)). chunk_vec lives in
runRawDdl which applyMigrations already invokes, but only after migrate()
seeds the empty `settings` table; so we apply, set
`settings.chunk_vec.created`, then re-run runRawDdl so chunk_vec
materializes for the non-deferred branch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
resolveVec0Path's dev fallback was process.cwd(), so any launch that
chdir'd away from the repo root (tests, server bootstraps, smoke harnesses)
resolved a non-existent path and crashed on vec0 load.

Anchor to `import.meta.dir` so the path is a fixed offset from the
source file. CLAUDE_PLUGIN_ROOT remains the packaged-binary override.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
PRAGMA foreign_keys is per-connection and defaults to OFF on every fresh
bun:sqlite Database. The §8 schema relies on onDelete: "cascade" clauses
for data integrity. If any caller bypassed openWithPragmas (or future code
ever forgot the pragma), migrate() succeeded silently and the cascades
were inert at runtime — orphan rows would accumulate without warning.

Fail loud: at the start of applyMigrations, query PRAGMA foreign_keys and
throw if it's not 1. The error names openWithPragmas as the canonical
constructor, so the fix is obvious from the message alone.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
resolveUnderRoot's leaf-stat is guarded but realpathSync(root) was not, so
a missing or unreadable root path leaked raw ENOENT to callers that only
catch PathEscapeError. The most common trigger (per the audit) is a backup
destination resolved before the corpus root directory has been created.

Test had to be carefully constructed: passing a non-existent leaf hits the
existing leaf-stat catch and masks the bug. The regression test uses a real
leaf file and a missing root so the unguarded realpathSync(root) is the
first thing that fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
POSIX rename is atomic for file content but the directory entry isn't
durable until the parent directory is itself fsync'd. Without this step, an
OS-crash immediately after the rename can lose the new directory entry —
the file content is on disk but the dir-entry points at the prior inode.

Open the runtime root with O_RDONLY|O_DIRECTORY, sync the descriptor, close
it. Linux/POSIX only: Win32 has no equivalent directory-fsync, so the
branch is gated on platform.

Regression test spies on fs.promises.open and asserts at least one post-
write open call with O_DIRECTORY flag against the runtime root.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… only (M7)

The broad try/catch turned every scan error into "0 bundled migrations" —
defeating the newer-plugin guard for any failure mode (permission, ENOTDIR,
etc.) other than the load-bearing "folder absent" case it was meant to
protect (foundation ships an empty journal pre-Task-1.4).

Replace with an explicit existsSync check; let scan errors propagate so the
caller sees a real exception instead of a silently-wrong count.

Function exported so the narrowing can be regression-tested directly:
- file-as-folder path now throws ENOTDIR (previously: returned 0).
- missing-folder path still returns 0 (the load-bearing case is preserved).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…t (M8)

§13 v1.1's "write-then-push" contract guarantees that a pdf.interact failure
leaves the DB row intact and re-pushable. The constraint was implicit in
the natural code flow; this commit makes it an explicit regression.

Pattern: dispatch upsert with an interactImpl that throws on first call,
verify the rejection, then read the row directly from the DB and confirm
its id/body. Retry the upsert with the captured id and verify the existing-
id branch emits update_annotations (not a second add_annotations).

No source changes — the current implementation already honors the contract.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
bun:sqlite serializes the underlying ArrayBuffer for typed-array blob
parameters. Today's Bun respects byteOffset + byteLength so view-over-
larger-buffer inputs bind correctly — but ctx.embed is test-injectable and
future driver swaps may not preserve that invariant. The audit flagged
this defensively (confidence 60).

Add toTightFloat32 in sqlite-vec.ts: identity-returns tightly-packed inputs
(zero-copy fast path), Float32Array.from-copies views over larger buffers.
Wire it into both bind sites:
- papers.ts:122 — search query vector
- pdf.ts:210  — chunk_vec upsert during refresh

Tests:
- unit: toTightFloat32 identity vs copy paths.
- integration: searchPapers with an injected embed that returns a view at
  non-zero offset of a larger buffer still picks the right paper.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
pdf.ts:materializeChunkVec writes settings.embed.dim via JSON.stringify(num)
and ConfigAccessor.get reads via JSON.parse. The raw-ddl embedDim reader,
however, used Number(raw) — which accepts non-JSON forms like "0x300" (=
768) that the canonical reader rejects. Two readers, two contracts, same
table; the audit (finding #14, M4) called this out as a future-regression
invitation.

Switch to a JSON.parse + typeof === "number" guard with a try/catch fallback
to null for non-JSON values. Regression test seeds embed.dim with "0x300"
(legal under Number, illegal under JSON.parse) and asserts chunk_vec is
NOT created — previously the lenient parse would have allowed it.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
A paper of exactly WINDOW_WORDS+1 (=385) words produced a 49-word tail
chunk that was 48 words of overlap + 1 net new word. The chunk burned a
full embedding round-trip for one word of new signal, and the resulting
near-duplicate vector polluted the hybrid-search vec_rank.

Drop the tail when `slice.length <= OVERLAP_WORDS + 1` (i.e., new content
≤ 1 word), gated on `start > 0` so single-chunk inputs are unaffected.

Tests pin both sides of the boundary:
- 385 words → 1 chunk (tail dropped — was 2 chunks pre-fix).
- 386 words → 2 chunks (50-word tail kept — 2 new words is meaningful).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The per-paper aggregation step downstream picks MIN(d) per paper_id, so
the global LIMIT must be large enough that several distinct papers each
get at least one chunk represented in the candidate set. The old LIMIT
200 starved paper diversity on corpora where any one paper had ≥200
close-ranking chunks — the per-paper aggregation collapsed to a single
hot paper instead of surfacing other relevant ones.

1000 covers the personal-use scale (audit budget: 5k chunks per corpus).
The structurally tighter KNN-per-paper subquery rewrite (audit's primary
suggestion) is deferred — it changes vec0 scan shape and needs a real
benchmark before adoption.

No new test: the change is a one-line constant tuning, and the boundary
where the old limit bit (>200 close chunks concentrated in one paper) is
hard to construct reliably without a real-scale fixture. Existing hybrid-
search tests verify no regression at small scales.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…ce (M2)

The race window between StdioClientTransport's spawn and the subsequent
AssignProcessToJobObject call (via attachJobObject) is microseconds wide
and only matters for a child that exits synchronously between the two
calls. Accepted at v1: the primary purpose of the job is parent-death
cleanup of long-lived children, not coverage of the synchronous-crash case.

Closing the race would require CreateProcess with CREATE_SUSPENDED +
AssignProcessToJobObject before ResumeThread, which means reimplementing
the StdioClientTransport spawn path. Deferred until a Win32 test rig
exists — flagged in ROADMAP.md under M2 as documented-only acceptance.

No source behavior change. Comment-only.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Eight items shipped as Red→Green TDD (M1, M3-M9); M2 documented as
acceptance only (Win32 race closure deferred until test rig exists).
Suite: 285 pass / 8 skip / 8 unchanged pre-existing failures; tsc clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…c (A1)

Settings can desynchronize across chunk_vec.created and embed.dim (manual
edit, downgrade artifact, partial write). Pre-A1 the call silently no-op'd
when created='true' and dim was missing/invalid, leaving the user with a
permanent still_indexing=true and no diagnostic. Surface the inconsistency
loudly so the bug is debuggable at first open.

RunRawDdl signature is §7.6-frozen (no logger arg available), so throw is
the only structured option. M4's hex-rejection test promoted from
"silent skip" to "loud throw" for consistency.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…eError (A2)

M9's wrap discarded err.code (ENOENT vs EACCES vs ELOOP), err.message, and
the original stack frame — making a genuine FS bug indistinguishable from
"missing root" at the catch site. Bun/V8 supports Error.cause natively; pass
it through so debuggers and log readers keep the diagnostic without weakening
the typed boundary.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…test

Audit pr-test-analyzer flagged M5 (commit ed95d9c) as cheaply testable but
unpinned. Construction: paper A saturates ranks 1..250 with near-zero cosine
distances; paper B's chunks land at ~rank 251, paper C's at ~rank 256. Query
embedding aligned with A's geometry, lex-non-matching query string isolates
the vec_rank path. Verified Red against LIMIT 200 (B/C absent), Green at
LIMIT 1000.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
zaynram and others added 3 commits May 29, 2026 11:37
Audit pr-test-analyzer flagged the M1 test as false-reassurance: spying on
fsp.open caught the directory-handle open but not the load-bearing
.sync() call. Removing the await dir.sync() left the test green. Wrap each
O_DIRECTORY-flagged FileHandle returned from open with spyOn(handle, "sync")
and assert at least one was actually invoked. Verified Red against the
sync-removed pre-fix scenario, Green against the M1 fix.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Audit pr-test-analyzer flagged the original M3 integration test as
false-reassurance: removing the toTightFloat32 wrap from papers.ts left it
green because bun:sqlite happens to honor view bind. Replace with a
spyOn(vecModule, "toTightFloat32") that pins the CALL — verified Red when
the wrap is removed from papers.ts, Green at the M3 fix. The spy also
asserts the wrap saw a non-tight (view-over-larger) input so we know the
captured call is the qvec path, not some incidental invocation.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Audit pr-test-analyzer flagged the delete-path as uncovered: M8's original
test only pinned the upsert flow. Delete commits a tombstone in phase-1; if
phase-2 (remove_annotations push) throws, the retry short-circuits at
`already_tombstoned` and does NOT re-push. This is the intentional v1.1
asymmetry — the viewer's stale display reconciles on next paper open, not
via scholar-initiated catch-up (matching the §13 v1.1 "no inbound
reconciliation" stance applied to outbound failure).

Pin the asymmetry as a regression test so any future change to make delete
re-pushable surfaces as a deliberate spec edit, not silent drift.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 29, 2026 16:49
@zaynram
zaynram merged commit d544ea7 into main May 29, 2026
0 of 2 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@zaynram
zaynram deleted the worktree-pre-v1-roadmap branch May 29, 2026 16:50
zaynram added a commit that referenced this pull request Jun 6, 2026
)

Cowork field test (2026-06-05): every scholar view was invisible. Render
Layers 1+2 were already shipped — view-opener tools carry `_meta.ui.resourceUri`
and the UI resource is served with `text/html;profile=mcp-app` — but a host
checks whether the SERVER itself speaks MCP Apps via
`capabilities.extensions["io.modelcontextprotocol/ui"]` in the initialize result
BEFORE it renders any `_meta.ui` iframe. That third layer was missing, so all the
view hints were inert.

`declareUiAppCapability` registers the extension via the low-level server's
`registerCapabilities` (merges with the auto-registered tools/resources caps;
must run pre-connect — registerUiResource is always called before connect, so
folding it in there makes "serve the UI resource ⟹ advertise the extension" true
by construction). The value is the spec's `{ mimeTypes }` shape carrying exactly
the mime scholar serves, not a bare `{}` — satisfies a host that reads the
sub-field and one that only checks presence.

Note: ext-apps' own server helpers declare NO server-side extension
(getUiCapability only READS the client's), so the id+mime are hardcoded locally,
mirroring MCP_APP_MIME — the server bundle still imports no ext-apps. The
directions are orthogonal; server-side declaration is purely additive.

Test: a real SDK client over an in-memory transport asserts the extension (with
its mimeTypes) survives onto the SERIALIZED initialize result, not merely that
registerCapabilities was called.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

2 participants