Repository navigation
fix(service-knowledge): a build that loses its lease stops at the next page, and a stalled build is cancelled - #37570
objectstack-fleet[bot] wants to merge 9 commits into
Conversation
…ease is lost, and is cancelled when it stalls Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
…d completes nothing; an exhausted search is CONCURRENT_MODIFICATION Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
…or fence; changeset Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
…t the bound Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
…bounds like a find Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 3 package(s): 4 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
What this run could not see
Coarse fallback — 43 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin a718701b273db47dc444a7783be98108e3e86ac9 && git checkout a718701b273db47dc444a7783be98108e3e86ac9
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6 fda121f9a6edf2713f0a03d3a622b0819ee6fd05 && git checkout -B drift-repro 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6 && git merge --no-ff fda121f9a6edf2713f0a03d3a622b0819ee6fd05
node scripts/docs-audit/affected-docs.mjs --json 0f6a1e518f3c4639b03f86a8c07d9d08d91bddb6
|
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract-review-claim: session_01Utp6CYtTDvfPQDzMbZnN5X · head 50bac35 · 2026-11-26T14:29Z |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X Contract reviewServed-tier: Inputs: card #37465 (body, triage, three scope notes, claim and its amend, both os-dev-reports), PR #37570 (body, 9 files), the net diff against ① Derived judgmentsAccept-set and public-surface changes the diff implies:
Seat questions:
② Semver level
③ Boundary flags
Findings:
No must-fix: the card's acceptance holds. The per-page lease check has its lapsed-mid-walk test, the bound has its never-answering-embed test with the lease released and the next build Implemented-by: VERDICT: PASS |
|
repo:objectstack#5 · os-bill · session_01Utp6CYtTDvfPQDzMbZnN5X 席位核对Head-sha:
|
…ng, and a hung listing, purge or completion frees the source's walk Also: the pgvector lost-lock remedy names the transaction-mode pooler; the CLI's build view knows lease-lost and timed-out; the docs cross-reference the builder lock's idle time. Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6Cb4BAjgQ43tqy1DvVJ Co-authored-by: Claude <noreply@anthropic.com>
Requested by Bill · project thread
Fixes #37465
Clause-②: yes (widening)
Metadata-protocol: none
维护者速读
What changes
Cluster lease fence (service-knowledge).
rebuildSourcenow runs its walk under a build fence (startBuildFence,knowledge-build.ts), andwalkObjectSourceasks the fence before each page:isHeld() === false, when a renewal failed and the handle no longer holds the lease, or when no renewal has succeeded withinBUILD_LEASE_MS. The last case covers a lock store that does not answer, or a renewal that hangs.lease-lostand the lease is released.completeBuild.Stall bound (service-knowledge).
BUILD_STALL_LIMIT_MSis a fixed 15-minute ceiling on the time between two pages (and before the first, and after the last). It is not a settings key and not an option, so ADR-0049's key-with-reader rule has no key to apply to.timed-out, the lease is released, and nothing is purged or completed.engine.find,adapter.upsert,adapter.delete,beginBuild) against the bound, so a hung embed call no longer holds the source's walk chain, and the next rebuild runs at once.rebuildSourcealso races the whole walk, which covers a hang in the listing, the purge orcompleteBuild.pgvector builder-lock fence.
ctx.reason === 'reindex', for a build this adapter began) first checks inpg_locks, on the lock's own session, that the source's advisory lock is still held. If it is not, the write is refused withLOCK_CONFLICT(409) before anything is embedded.completeBuildcompletes only the build this adapter began, and only the generation that build began. Otherwise it is refused withLOCK_CONFLICTand switches, records and deletes nothing.beginBuild, so a lock whose session ended is no longer kept.N3. A pgvector search that meets three generation switches is refused with
CONCURRENT_MODIFICATION(409). The rows forCONCURRENT_MODIFICATIONandLOCK_CONFLICTleavescripts/error-status-unpinned-baseline.json.check:error-status-conformancerequired theLOCK_CONFLICTremoval too, because the new pgvector refusals declare its status.N2. Measured live:
beginBuildunder the active fingerprint already retires a building generation of another fingerprint. This PR pins that with a live test and states it in the docs; no code change was needed. What remains is that no build is due after a revert (readIndexStatereadscurrent), so the stale generation stays until the next build of any kind. See Acceptance notes.N4 is not implemented. Two sweeps of one retired generation need two lock holders at once. The fence now refuses a lapsed builder's
completeBuild, andbeginBuildsweeps only under a freshly checked lock.knowledge-turso (measured, not changed). It has no builder lock:
beginBuildtakes up any generation under the same fingerprint, so there is no builder identity for an "own generation" check beyond the fingerprint, whichcompleteBuildalready requires. Its cluster-lease protection is the service-level fence in this PR.Docs.
content/docs/ai/knowledge-rag.mdxadds generation item 6 (the pgvector fence), extends item 5 (the reverted fingerprint) and adds a paragraph on the two stops in "The first build, and rebuilding a source". None of these sections is one that #37442 edits.Widening. The exported
KnowledgeBuildRecord.statusgainslease-lostandtimed-out. Nothing else becomes newly exported from the package entry.Files to read first (by risk)
packages/services/service-knowledge/src/knowledge-service.ts,rebuildSource: the race onfence.cancelled, and the status taken fromfence.stop()when the walk returnsok: false.packages/plugins/knowledge-pgvector/src/pgvector-adapter.ts:holdsBuilderLock(thepg_lockskey split intoclassid/objid) and thecompleteBuildown-generation check.packages/services/service-knowledge/src/knowledge-build.ts,startBuildFence: the local lease expiry (heldUntil) for a renewal that never settles.Two-minute verification
pnpm --filter @objectstack/service-knowledge exec vitest run src/__tests__/knowledge-build-fence.test.tsshould report 8 passed. The first case shows 1 page embedded of 3 andlease-lost. The stall case showstimed-outat 15 minutes of fake time, then a next build that completes.Tests
Local readings
knowledge-build-fence.test.ts(new, 8 cases):findcalled once,completeBuild0,lease-lost, released once;lease-lost;timed-outat the bound, lease released, the next builddone;done;completeBuild:timed-out;OS_EXPECT_LIVE_DIALECT_MATRIX=1): Test Files 8 passed, Tests 83 passed, against 76 before this PR. New:build-fence.live-postgres.test.ts(6 cases) andsearch-switches.test.ts(1). Typecheck exit 0.git restore:fenceBuilddisabled: 2 live cases red;rebuildSourcerace disabled: the hung-completeBuildcase red.Acceptance notes
buildLockIdleMs.AdapterContexthas no abort signal, and adding one would be an ADR-0161 contract member, which this PR does not add. If such a call answers later, its page is written; for pgvector that write is still fenced by the builder lock.readIndexStatereadscurrent, so no build runs and the stale building generation stays until the next build. Retiring it without a build would needindexStatusor a read-time sweep. Not done here.knowledge-service.tsedits stay insidewalkObjectSourceandrebuildSource, plus the import block and a one-parameter pass-through inreindexWiththat threads the fence. None of these touches the regions feat(core): requires knowledge mounts the knowledge service and one vector store #37442 edits; overlap-check reports a clean merge.Verification
VERDICT clean exit 0against origin/main and feat(core): requires knowledge mounts the knowledge service and one vector store #37442.--repo objectstack-ai/objectstack:PREREQUISITE NOT MET(exit 3), so NOT MEASURED:check-plugin-teardown-shape --self-test(shallow clone), speccheck:skill-examples(client-react not built) andcheck:dual-build-cjs-loads(needs a full build).check:objectql-double-limitflagged the new live test's engine double as unjudged. The double now filters and bounds like afind, and the re-run exits 0.Generated by Claude Code