Skip to content

service-knowledge: a record sync still in flight when a build starts can be completed as covered, guarded only by a 5 s clock-skew margin #38556

Description

@objectstack-fleet

repo:objectstack#5 · os-project-manager · session_01FEkQ5mC8eA4qtKSweeF7wd

Filing gate: ② seat split. Source: contract review 7253810720 (round 2, PASS) on PR #38509 (#38413), finding N5 (nit, escalated in ③ for a follow-up card): "covered has no guard against a sync still in flight, other than the 5 s margin, whose docblock names clock skew only (knowledge-record-sync-queue.ts:217)." The finding was already in the round-1 head; the PR adds one way in, since a backlog reconcile queued behind another source's walk now starts while batches run. Child of epic #37000.
Grading: area:ai · Bug (index correctness, self-healing) · p3 (needs one sync to stay in flight more than 5 s plus a coincident write and build; the next build that purges repairs it, which is where ADR-0161 K1 puts an index's correctness) · reach: deployments with a slow embedding provider that bulk-write into a record-sourced knowledge source while a build runs · evidence: reasoning in the review record; not reproduced.

维护者速读

What

  1. The case, from the review: a sync re-reads a record; the record is written again; a build of the source starts more than 5 s after that second write while the first sync is still waiting on its store write; that write lands after the walk wrote the record (or after the listing, for a record created and then deleted). The older document, or a deleted record's document, stays in the index, and the second write's message completes as covered.
  2. Pick one of the two answers the review names and say which in the report: widen RECORD_SYNC_COVER_MARGIN_MS to the queue lease (30 s; the only cost is a normal sync for the messages inside the margin), or keep 5 s and make the docblock say the margin is also this guard and what it does not cover. A guard tied to the sync's own completion is welcome if it is no larger.
  3. If widened, a test pins that a message published inside the margin of a build's start is synced, not covered.

Acceptance

  • The margin's docblock names both things it guards (clock skew, a sync in flight), and its value is the one the report argues for.
  • If the value changes, the test in step 3 fails on the old value.
  • No change to IQueueService, to the build's purge, or to the per-message path's behaviour outside covered.

Blocked-by: #38509
Not in scope: N6 to N8 of the same record (nits, no card); the batch claim writes (#38548); the stored source counter (#38489).
Dedupe: covered margin knowledge sync 6 (none on this) · coveredByBuild 1 (#38413 only) · knowledge sync in flight build covered 53 (none on this; #38413 tops the list).

Activity

  1. added
    pm:blocked
    area:ai
    on Nov 29, 2026
  2. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    Unblocked: 2026-11-29T10:16Z · prerequisite #38509 merged into main (a5fe764); pm:blocked → pm:queue on the seat's word. Claimable by area o5-ai37000 when a slot frees.

  3. added
    pm:queue
    and removed
    pm:blocked
    on Nov 29, 2026
  4. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    triage#1 · zhuangjianguo · session_01QsR2jRH2X4frz9bBiZHNk4

    Triage: lands in packages/services/service-knowledge/src/knowledge-record-sync-queue.ts (the covered judgement's margin, ~L217) with a pin · area:ai · domain:server · Bug · p3 · pm:queue · size XS. Grading line: area:ai · Bug · Impeded (a stale document self-heals on the next purging build) · rare configuration (a slow embedder, a coincident write and a build) · evidence read (contract review 7253810720 N5), not reproduced. Rationale: Blocked-by: #38509 merged at a5fe764, so it is dispatchable now. Type set to Bug at this touch.

  5. added
    domain:server
    on Nov 29, 2026
  6. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    Claim: PM loop round 1 · 2026-11-29T10:26Z
    Session: session_01FEkQ5oQLfL8thb6wtUHnTb
    Account: os-project-manager
    Branch: claude/issue-38556-sync-cover-margin
    Worktree: objectstack-issue-38556
    Domain: domain:server
    Seat: repo:objectstack#5
    Area: o5-ai37000
    File surface: packages/services/service-knowledge/src/knowledge-record-sync-queue.ts (RECORD_SYNC_COVER_MARGIN_MS, its docblock and the covered judgement only), a new packages/services/service-knowledge/src/__tests__/record-sync-cover-margin-38556.test.ts, one changeset .changeset/38556-sync-cover-margin.md (stop on breach; explain in the report).
    Container & model: XS, mode:subagent, model: default (no path-derived mandate), effort: medium (XS)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: introduced by PR #38509 (#38413): the batch path starts a backlog reconcile while batches run (contract review 7253810720, N5).
    Thread-read: none
    Premise: holds at main per the card body (reasoned in the review, not reproduced); the dev reads knowledge-record-sync-queue.ts ~L217 first.
    Serial constraints cleared: check-handover --inflight at main: clear; overlap-check before every push
    Pre-claim lane: packages/services/service-knowledge/** ⇒ domain:server; filed by the seat as #38413's follow-up under #37000.
    Pre-claim deps: #38509 merged (a5fe764).
    Prior rulings read: ruling 7250307515 on #38413 (per-message queues' behaviour and pacing untouched).

  7. added
    pm:dispatched
    and removed
    pm:queue
    on Nov 29, 2026
  8. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    Release: claim 7254444945 on this card · 2026-11-29T10:27Z
    Reason: its new test path sat under packages/services/service-knowledge/src/__tests__/, which #38537's in-flight claim 7253127987 holds as a directory (check-handover OVERLAP). No work started; the claim is re-stated in the next comment with the test beside the source. The card stays dispatched to this area.

  9. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    Claim: PM loop round 1 (re-stated: replaces claim 7254444945, released above, whose test path met #38537's src/__tests__/) · 2026-11-29T10:29Z
    Session: session_01FEkQ5oQLfL8thb6wtUHnTb
    Account: os-project-manager
    Branch: claude/issue-38556-sync-cover-margin
    Worktree: objectstack-issue-38556
    Domain: domain:server
    Seat: repo:objectstack#5
    Area: o5-ai37000
    File surface: packages/services/service-knowledge/src/knowledge-record-sync-queue.ts (RECORD_SYNC_COVER_MARGIN_MS, its docblock and the covered judgement only), a new packages/services/service-knowledge/src/knowledge-record-sync-cover-margin.test.ts (beside the source, not under src/__tests__/, which #38537's claim 7253127987 holds), one changeset .changeset/38556-sync-cover-margin.md (stop on breach; explain in the report).
    Container & model: XS, mode:subagent, model: default (no path-derived mandate), effort: medium (XS)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: introduced by PR #38509 (#38413): the batch path starts a backlog reconcile while batches run (contract review 7253810720, N5).
    Thread-read: none
    Premise: holds at main per the card body (reasoned in the review, not reproduced); the dev reads knowledge-record-sync-queue.ts ~L217 first.
    Serial constraints cleared: check-handover --inflight at main: clear; overlap-check before every push
    Pre-claim lane: packages/services/service-knowledge/** ⇒ domain:server; filed by the seat as #38413's follow-up under #37000.
    Pre-claim deps: #38509 merged (a5fe764).
    Prior rulings read: ruling 7250307515 on #38413 (per-message queues' behaviour and pacing untouched).

  10. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#5 · os-project-manager · session_01FEkQ5oQLfL8thb6wtUHnTb
    os-dev-report

    {
      "issue": 38556,
      "status": "done",
      "branch": "claude/issue-38556-sync-cover-margin",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/38577",
      "session": "session_01FEkQ5oQLfL8thb6wtUHnTb",
      "premise_still_valid": true,
      "summary": "Premise holds at main d08d2ae972: coveredByBuild answers covered when publishedAt < build.startedAt - RECORD_SYNC_COVER_MARGIN_MS (was 5_000, docblock naming clock skew only), and nothing there asks whether a sync of the record is still in flight. Chose to widen: RECORD_SYNC_COVER_MARGIN_MS = 30_000, the queue adapter's default message lease; the only cost is a normal sync for messages published in the 25 s that move out of covered, while the backlog messages covered exists for stay covered. A completion-tied guard was rejected: an in-process tracker cannot see a sync on another node, so it is not smaller and leaves the cross-node case open. The docblock names both guards, the cost, what stays uncovered (a sync in flight longer than the margin, since a live handler renews its lease; skew beyond what the sync leaves of the margin) and the repair (next purging build, ADR-0161 K1). The lease is no exported constant (inline default `o.leaseMs ?? 30_000` in service-queue, a devDependency here), so the value is written in service-knowledge and a test pins it equal to DbQueueAdapter's real default. No change to IQueueService, the purge, or either sync path outside covered; knowledge-service.ts untouched. File surface held exactly (3 files).",
      "tests": "At ee44d4985c: `pnpm --filter @objectstack/service-knowledge test` Test Files 23 passed (23), Tests 784 passed (784); `pnpm --filter @objectstack/service-knowledge typecheck` exit 0 (tsc --listFiles reaches the new test: 1 hit; check:test-typecheck OK, 0 debt). New file src/knowledge-record-sync-cover-margin.test.ts, 3 tests: margin == DbQueueAdapter default leaseMs; after a purging build a message published 10 s before the start is synced on per-message and batch paths and repairs a late-written stale doc; a message published margin+1 ms before is covered with no re-read. Ablation (scripts/ablation-replace.mjs, test imports src so no dist leg): `= 30_000;` -> `= 5_000;` landed (anchor 1->0, blob 5cd06940 -> 3b09510b), run under the lock VERDICT command-exit 1: 2 failed | 1 passed, `expected 5000 to be 30000` and `expected 'covered' to be 'synced'`; restore verified blob == HEAD 5cd06940, git diff HEAD empty.",
      "gates": "Local: dispatch-gates --commands --repo objectstack-ai/objectstack at ee44d4985c derived 67; each run with exit captured before any pipe: 66 exit 0, `pnpm check:dual-build-cjs-loads` exit 3 PREREQUISITE NOT MET (needs whole-repo dist) = NOT MEASURED, CI runs it. --ran with `cmd :: exit N` lines: 67 accounted, 66 run, 1 NOT-MEASURED (derived from recorded exit 3). check-platform-checklist --changed-from origin/main: 0 anchored files, nothing judged. check-nul-bytes OK. overlap-check before each push: VERDICT clean exit 0 (origin/main merges cleanly). CI check-runs on PR #38577: NOT MEASURED, reason: report delivered at end of local verification, CI not awaited per dispatch contract.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "4 — git push x2 to claude/issue-38556-sync-cover-margin (plus the dev-worktree --probe empty-branch push); relay pr_create (POST /repos/objectstack-ai/objectstack/pulls draft + POST /issues/38577/assignees os-project-manager, run 46256296610); post-stamped comment on issue 38556 (this report)",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed — the queue's default lease is an inline literal in service-queue (DbQueueAdapter constructor) with no exported constant, so a consumer that sizes against it (here the covered margin) can only pin it by test; exporting one sat outside this card's surface",
        "carrier: none · noted, not filed — AGENTS.md rule (ruling record 6583487846) puts a new pin into the component's shared harness file; the claim placed the test beside the source because src/__tests__/ is held by #38537's claim, so a small harness copy lives in the new file; folding it into knowledge-build.test.ts is for whoever next holds that directory"
      ]
    }
  11. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

    2026-11-29T12:04Z · Takeover · seat repo:objectstack#5's account os-project-manager is out of tokens; seat 1 continues its claim.

    Release: claim 7254472588 (session session_01FEkQ5oQLfL8thb6wtUHnTb, account os-project-manager, seat repo:objectstack#5) — taken over, not abandoned. Provenance: who = the maintainer (Jianguo); words, verbatim: 「hotlong 和 5号座位os-project-manager没token了,他的任务你都继续处理完」; where = seat 1's project chat, 2026-11-29T11:57:54Z.
    Handover: branch claude/issue-38556-sync-cover-margin last pushed ee44d4985c; PR #38577. Picked-up work is UNVERIFIED until seat 1 re-reads it at that head.
    Assignee: os-project-manager → zhuangjianguo in this stroke.

    Claim: PM loop round 3 (takeover of 7254472588)
    Session: session_01QsR2jTsdScTh3o2fSjbxSz
    Account: zhuangjianguo
    Branch: claude/issue-38556-sync-cover-margin
    Worktree: objectstack-issue-38556
    Domain: domain:server
    Seat: repo:objectstack#1
    Area: o1-know
    File surface: packages/services/service-knowledge/src/knowledge-record-sync-queue.ts (RECORD_SYNC_COVER_MARGIN_MS, its docblock and the covered judgement only), a new packages/services/service-knowledge/src/knowledge-record-sync-cover-margin.test.ts (beside the source, not under src/__tests__/, which #38537's claim 7253127987 holds), one changeset .changeset/38556-sync-cover-margin.md (stop on breach; explain in the report).
    Container & model: XS, mode:subagent, model: default (no path-derived mandate), effort: medium (XS)
    Clause-②: no
    Metadata-protocol: none
    Responsibility: introduced by PR #38509 (#38413): the batch path starts a backlog reconcile while batches run (contract review 7253810720, N5).
    Thread-read: 7254997547
    Premise: holds at main per the card body (reasoned in the review, not reproduced); the dev reads knowledge-record-sync-queue.ts ~L217 first.
    Serial constraints cleared: check-handover --inflight at main: clear; overlap-check before every push
    Pre-claim lane: packages/services/service-knowledge/** ⇒ domain:server; filed by the seat as #38413's follow-up under #37000.
    Pre-claim deps: #38509 merged (a5fe764).
    Prior rulings read: ruling 7250307515 on #38413 (per-message queues' behaviour and pacing untouched).

  12. objectstack-fleet commented on Nov 29, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · zhuangjianguo · session_01QsR2jTsdScTh3o2fSjbxSz

    2026-11-29T12:16Z · Landed: PR #38577 merged (seat 5 queued it; seat 1 took the claim over in 7255550781); the card is closed. pm:dispatched removed with this note.

  13. removed
    pm:dispatched
    on Nov 29, 2026
  14. added 2 commits that reference this issue on Dec 1, 2026
    3014176
    95a49ad
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