test(smoke): prove C2 semantic live + fix #166 restore timeout + staging debris sweep - #173
Merged
Conversation
…ing debris sweep Adds a staging-only POST /vault/<name>/__test/embed-run hook (mirrors __test/transcribe-run) so smoke-staging can drive the embedding drain deterministically, then create-note → drain → near_text query a distinctive, paraphrasable note and assert it ranks by meaning — the one thing vitest-workerd can't prove for C2 (real bge-m3 inference). 404-pinned in production via smoke-prod, same as the transcription hook. Also fixes cloud#166: the restore round-trip section now carries an explicit, generous fetch timeout (rather than an implicit default) on every leg of the sweep → restore → round-trip chain, and a new operator-run scripts/staging-sweep.ts frees D1 vault-ownership rows for the smoke's own throwaway prefixes so the fleet doesn't keep growing — structurally staging-only (no TARGET=prod escape hatch). rc.90 → rc.91. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XLZtmuSs1RirWGMGyCB1QB
unforced
added a commit
that referenced
this pull request
Jul 17, 2026
…eremony code entry, post-consent return path (#174) Every magic-link mint now also produces a 6-digit sign-in code bound to the same single-use token row (migration 0021); POST /auth/code verifies+consumes it through the identical resolveVerifiedUser + finishPrimaryAuth chokepoints as GET /auth/verify, including the authorize-resume rider. The console login, OAuth authorize login, and "check your email" pages gain a "have a code?" disclosure. The OAuth consent-approve post-redirect bridge names the connecting client and carries a 3-second watchdog instead of a bare spinner (the "Authorized, now what" dead end). rc.91 (#173) is in review on ag-unforced-dev — this PR branches from main. Claude-Session: https://claude.ai/code/session_01XLZtmuSs1RirWGMGyCB1QB Co-authored-by: Claude Fable 5 <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
Two bundled items, both in
scripts/smoke-staging.tsterritory:1. Semantic live-smoke coverage (C2, merged rc.90, deployed to staging)
C2 ships embed-on-write via the DO alarm +
near_text/semanticon REST/MCP, powered by live Workers AIbge-m3— whichvitest-workerdcannot exercise (documented residual in PR #170's own body: "What only a live smoke can prove"). This PR closes that gap:POST /vault/<name>/__test/embed-run(workers/vault/src/vault-do.ts) — mirrors__test/transcribe-runexactly: loopsdrainEmbeddingsOnce()(the same private method the DO alarm calls) until the queue reports nothing left or a 10-wake bound is hit, so the smoke can drive the embedding drain deterministically instead of waiting on the real alarm's async fire. 404 in production and under vitest (ENVIRONMENT !== "staging").scripts/smoke-prod.tspins the same 404 posture (mirrors the existing__test/transcribe-runpin).__test/embed-run, then queriesGET /api/notes?semantic=true&near_text=<paraphrase with zero shared keywords>and asserts the note ranks in the top 3 by meaning. Also asserts the landing'sembeddings: {enabled}capability and that the response never comes backsemantic_unavailableor carries anembeddings_pendingwarning (proving the drain fully caught the vault up).Honesty note (as requested): these semantic smoke steps get their first real run on the next staging deploy — this PR cannot itself prove they pass against live
bge-m3inference, only that they typecheck and don't collide with the existing 332-testworkers/vaultsuite (which still passes unchanged, no live inference under the pool).2. cloud#166 — the snapshot-restore smoke timeout
Root-caused as debris growth (staging at ~140 smoke-created vaults) making the section's round trip (snapshot sweep → R2 → new-vault DO import) slow enough to cross an implicit client-side fetch timeout, 2 consecutive runs.
scripts/smoke-staging.ts§17: every fetch in the restore round-trip section now carries an explicitAbortSignal.timeout(120_000)(2 min) — replacing whatever implicit default was being hit with a generous, self-documenting budget for a genuinely heavy round trip.scripts/staging-sweep.ts: operator-run debris sweep. Deletes the D1vaultsownership row for vaults matching the smoke's own throwaway prefixes (box-,imp-,arrive-,tierbox-,mockbox-,enforcebox-) older than a configurable cutoff (default 1 day), dry-run by default (--yesto apply). Never wired into CI/deploy — pure operator lever. Structurally staging-only: noTARGET=prodescape hatch exists at all (unlikebackfill-plans.ts/set-operator-role.ts), plus a defense-in-depth assertion on the hardcoded D1 database name. Never touches the literaldemovault. Documented limitation: there is no vault-teardown verb anywhere in this codebase (DELETE /account/vaults/:nameis still a501stub), so this frees the D1 ownership row only — the underlying DO storage + any R2 attachments are left orphaned but harmless (hibernated, near-zero cost, unreachable once unowned).rc.90 → rc.91.
Test plan
cd workers/vault && bun run typecheck— cleancd workers/vault && bun x vitest run— 332 passed | 1 todo (unchanged from PR feat(vault-do): semantic search via Workers AI — embed-on-write drain + near_text (C2) #170's 329+1 baseline plus 3 from main having moved; the new__test/embed-runroute has no dedicated unit test — it's a thin loop over the already-unit-testeddrainEmbeddingsOnce, same coverage posture as__test/transcribe-run)bun run typecheck— cleanbun run test— 153 passed (unchanged)workers/identity— untouched by this PR, not re-runscripts/*.tssanity-typechecked against the repo's actual tsconfig compiler options (scripts/ isn't in the root tsconfig'sinclude, so it isn't part of any CI gate today) — zero new errors; the handful of pre-existingunknown-JSON warnings elsewhere insmoke-staging.ts/smoke-prod.tsare untouched lines, not part of this diffbash scripts/deploy-staging.sh+bun scripts/smoke-staging.tsbefore considering this done, andbun scripts/staging-sweep.ts(dry-run first) to actually clear the current ~140-vault debrisDo not merge — reviewer pending.
🤖 Generated with Claude Code
https://claude.ai/code/session_01XLZtmuSs1RirWGMGyCB1QB