Skip to content

service-knowledge: check the build fence before beginBuild and on each purge deletion #37644

Description

@objectstack-fleet

repo:objectstack#5 · os-bill · session_01Utp6Cb4BAjgQ43tqy1DvVJ

Filing gate: ② follow-up out of #37465 (PR #37570, seat delta record 7198334769 nits N6 + N7, ACCEPT 7198343717), filed by the owning zone ai-37000 under #37465 at the seat's direction, per the maintainer's standing permission for areas to file their own follow-up cards.
Grading: area:ai · domain:server · Task · p3 (seat-directed) · reach: knowledge source rebuild in a cluster · evidence: read, not run.

维护者速读

  • 做什么:知识源重建的“围栏”检查再提前两处:排队中已取消的构建不再开始;清理阶段丢了租约能马上停下,而不是等清理结束。
  • 谁受益:多节点部署少占一会儿 pgvector 构建锁,少做一段无用清理。
  • 不做会怎样:最坏多占锁到空闲超时、多做一段清理;结果正确性不受影响。
  • 需要你做的:无。

What

  • N6: a build cancelled while queued behind another walk still calls beginBuild once the earlier walk ends. On pgvector that takes the builder lock, which is then held until it goes idle.
  • N7: a lease lost during the purge is noticed only at the end of the purge (the S1 check in the private completeBuild helper), not at the next deletion.

Acceptance

Activity

  1. added
    area:ai
    domain:server
    on Nov 26, 2026
  2. objectstack-fleet commented on Nov 26, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

    Triage: lands in area:ai · domain:server · Task · priority:p3 · pm:queue · size XS; rationale: check the build fence before beginBuild and on each purge deletion, so that rebuilds on a cluster stay single-writer. Read, seat-directed p3.

  3. added
    pm:queue
    on Nov 26, 2026
  4. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

    Claim: PM loop round 1 · area o1-C (epic #37000 follow-ups, handed over by repo:objectstack#5 in mailbox #37561 knock 7206533010, ledger #37000 comment 7206523866) · 2026-11-27T00:44Z
    Session: session_016WV4cwPhGV4g9p1BGQaZbP
    Account: os-elon-musk
    Branch: claude/area-o1C-37644
    Worktree: objectstack-issue-37644
    Domain: domain:server
    Area: o1-C
    Seat: repo:objectstack#1
    File surface: packages/services/service-knowledge/src/knowledge-service.ts (the beginBuild call in the complete-walk path and the per-deletion serialize hook of the purge), packages/services/service-knowledge/src/knowledge-build.ts only if the fence helper needs a reader, a new test file under packages/services/service-knowledge/src/__tests__/, a changeset. ⛔ No adapter-contract change (stop on breach; explain in the report)
    Container & model: S, mode:subagent, model: default tier (dispatch-gates --tier: "no path-derived mandate"), effort: high (reason: build-fence ordering under concurrency, each pin ablated red)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack's own code, packages/services/service-knowledge/src/knowledge-service.ts | the fence is checked after writes (:676, :766, :873) and races calls through fencedCall, but not before beginBuild (:604) nor per purge deletion | clustered deployments rebuilding a source (pgvector holds its builder lock until idle); correctness unaffected
    Thread-read: 7198803930
    Premise: holds, read not yet measured — on origin/main 94843b8 beginBuild is called at knowledge-service.ts:604-606 with no fence?.stop() read before it; the purge's serialize hook (:815) does not read the fence.
    Serial constraints cleared: #37676 (seat 5, #37304) rewrites knowledge-service.ts (~900 lines); a probe edit at :604 merges cleanly with it; the dev re-runs overlap-check before every push and queues behind #37676 with Notify: serial on exit 1
    Pre-claim lane: packages/services/service-knowledge/** ⇒ domain:server (file ownership only), built and L1-read in o1-C / L1-a.
    Pre-claim deps: none on the card (source #37465 closed, PR #37570 merged).
    Prior rulings read: check-prior-rulings.mjs --card 37644 --paths packages/services/service-knowledge/src/knowledge-service.ts: zero ruling hits on the surface (no ruling); ADR-0161 K7 (builds and the builder lock) is the governing text; epic #37000 "Rulings that bound every child" apply (no new adapter-contract members).
    Fold-or-serial: not folded — #37597 is another package and mechanism.

  5. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 27, 2026
  6. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP
    os-dev-report

    {
     "issue": 37644,
     "status": "done",
     "branch": "claude/area-o1C-37644",
     "pr": "https://github.com/objectstack-ai/objectstack/pull/37750",
     "session": "session_016WV4cwPhGV4g9p1BGQaZbP",
     "premise_still_valid": true,
     "summary": "Premise measured red on origin/main ce4d8c7d74: 4 new pins failed and the 14 existing ones passed. Cancelled-while-queued and lease-lost-while-queued builds each called beginBuild once. A lease lost mid-purge deleted all 3 candidates. A build cancelled mid-purge kept deleting in the background. walkObjectSource now asks fence?.stop() before beginBuild and returns ok:false ('stopped before its build began, and nothing was written: STOP') carrying the fence's own stop message. The purge's serialize hook asks fence?.stop() inside the chained task before each re-read and delete, so the purge stops at the next candidate, nothing is completed, and the walk answers 'stopped during its purge after N deletion(s): STOP'. The record ends timed-out or lease-lost as before. There is no adapter-contract, purgeDocuments-input or fence-API change.",
     "tests": "Premise (main + new pins): Tests 4 failed | 14 passed (18). Fix d88a72abd4: pnpm --filter @objectstack/service-knowledge test gave Test Files 15 passed (15), Tests 470 passed (470), then typecheck (tsc --noEmit + check:test-typecheck) exit 0, VERDICT command-exit 0. Ablations ran via scripts/ablation-replace.mjs (anchor x1->x0, restored blob == HEAD b33bdec30b90, git diff HEAD empty). The tests import src, so no dist rebuild was needed. A1: pre-begin check disabled gave 2 failed, both queued pins. A2: serialize check removed gave 2 failed, both purge pins. A3: purge-halt message branch disabled gave 1 failed (lease-lost mid-purge).",
     "gates": "Local: dispatch-gates --commands (3 paths vs merge base ce4d8c7d7) derived 70 families. 69 exited 0. pnpm check:dual-build-cjs-loads exited 3, PREREQUISITE NOT MET (it needs every package's dist/), so it is NOT MEASURED locally and left to CI. dispatch-gates --ran gave '70 derived, 69 run, 1 NOT-MEASURED (DERIVED from recorded exit 3)'. check-nul-bytes exit 0. overlap-check gave VERDICT clean exit 0 before both pushes (#37676 merges cleanly). CI on PR head d88a72abd4 at report time: Check Changeset, Check PR Size, Governed Surface Queue Guard, Lint (ESLint, PM dispatch-gates, docs & code guards, repo & tooling gates, CI/release/engine gates, scoped x3), PR-body guards and Type Check (workspace, source gates, consumer gates, debt ledger) were all in_progress. Opt-in and queue-only runs were skipped. Test Core, Build Core and the UI jobs had not yet been listed.",
     "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
     "mcp_calls": "0",
     "api_writes": "3 relay strokes. (1) pr_create, run 45922172341: POST /repos/objectstack-ai/objectstack/pulls answered HTTP 502 and nothing landed; a read confirmed no PR on the head. (2) pr_create retry, run 45922254752: POST /pulls, then POST /issues/37750/assignees (os-elon-musk); read-back says the 6965 bytes are identical. (3) the os-dev-report comment via post-stamped.mjs: POST /issues/37644/comments. git push x3 (not REST).",
     "open_questions": [],
     "security_findings": "none",
     "out_of_scope_findings": [],
     "deviations": "(1) The dispatch named a NEW test file. The pins went instead into the existing fence harness knowledge-build-fence.test.ts as a top-level describe, per AGENTS.md (ruling record 6583487846: a new pin for a component with a shared harness file goes into that file). (2) The dispatch's commit trailer 'Co-Authored-By: Claude Opus 5.5' was refused by the pre-push hook. The unpushed commit was reworded to the AGENTS.md model-free pair 'Co-authored-by: Claude' + Claude-Session; no pushed history was rewritten. (3) The PR body starts with the dispatch's two lines (attribution comment, Requested-by), and 'Fixes #37644' is the third line, not the line right after the comment. (4) The first pr_create got GitHub 502 and was retried once.",
     "files_changed": [
      "packages/services/service-knowledge/src/knowledge-service.ts",
      "packages/services/service-knowledge/src/__tests__/knowledge-build-fence.test.ts",
      ".changeset/37644-knowledge-build-fence-before-begin.md"
     ],
     "line_budget": "197 changed lines (+194 / -3) over 3 files, under the 3000 threshold. knowledge-service.ts +37/-3."
    }
  7. objectstack-fleet commented on Nov 27, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-elon-musk · session_016WV4cwPhGV4g9p1BGQaZbP

    Close-out · area o1-C · 2026-11-27T03:00Z

    Delivered by PR #37750 (merged): the build fence is checked before beginBuild (a build cancelled or lease-lost while queued writes nothing and takes no pgvector builder lock) and before each purge deletion (nothing is completed after a mid-purge stop); pinned in knowledge-build-fence.test.ts, each ablated red; content/docs/ai/knowledge-rag.mdx updated. Nothing remains on this card; pm:dispatched removed with this comment.

  8. removed
    pm:dispatched
    on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:aidomain:serverpriority:p3

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions