Skip to content

fix(cluster): an object authored during a store outage is served by every replica after its resync - #31816

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-eeoddo
Nov 9, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-eeoddo

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #31722

Clause-②: yes (widening)
Metadata-protocol: none

Measured on the diff: one new public method,
ObjectStackProtocolImplementation.resyncMetadataMutationPubSub(), and its
result type MetadataMutationResyncReport, exported from
@objectstack/metadata-protocol. Nothing is removed or made required. The
claim read no; the measurement says yes (widening), as it did for #31721.
No metadata an author writes changes.

维护者速读

  • 改了什么:多副本集群中,Redis 等共享存储断线期间在 A 副本上新建、修改或删除的对象,B 副本在自己的集群驱动重连(cluster.resync)后会自动收敛,不再需要重启。
  • 为什么改:metadata.mutated 通道(让其他副本注册新对象的那条)是唯一没有重同步入口的通道;断线期间丢失的提示会让其他副本一直回答 OBJECT_NOT_FOUND(或旧定义、或已删除的对象),直到重启。
  • 风险与回滚:单节点(默认内存驱动)完全不变,从不触发;重同步只读本副本自己的 sys_metadata,读失败时不删除任何注册项。回滚即撤销本 PR。
  • 先看:metadata-protocol 的新文件 protocol-mutation-resync.ts(选哪些项重新收敛),以及 service-cluster 的 metadata-cluster-bridge-plugin.ts(注册一行)。
  • 两分钟验证:cd packages/runtime && pnpm exec vitest run src/cluster-metadata-mutation-resync.integration.test.ts,两个内核共享一个 SQLite 文件和一条会丢消息的总线。
  • 需要你做的:无。

What changes

  • Lane 2 has a resync seam (@objectstack/metadata-protocol).
    resyncMetadataMutationPubSub() reads sys_metadata's active rows once,
    with only their address and checksum and never a body. It then
    re-converges each item a lost hint could have touched:

    • a row whose checksum moved since this replica last converged on it (a lost
      save or publish);
    • an item this replica converged on that has no active row now (a lost
      delete);
    • an item a hint or a local write named since the last convergence (a revert
      brings an earlier checksum back, so the checksum alone cannot tell).

    Each item goes through applyRemoteMetadataMutation, the applier a
    delivered hint runs, from this replica's own re-read. Nothing travels on the
    wire. A row that is gone takes the delivered delete's heal walk.

  • The baseline. attachMetadataMutationPubSub seeds a per-replica ledger
    with one active-row read. Every convergence keeps the ledger current. Hints
    and local writes mark items. Resyncs run one at a time, and an item touched
    during a resync stays marked. With no baseline (the seed read failed), the
    first resync re-converges every active row.

  • A read that fails is never a delete.

    • If the active-row read fails, the resync rejects and changes nothing.
    • If one item's re-read fails, that item is kept as this replica holds it and
      stays marked for the next resync. The failures are logged once per resync
      (console.error, with the items and the first cause).
  • The bridge calls it (@objectstack/service-cluster).
    MetadataClusterBridgePlugin registers lane 2 through registerLaneResync
    on the same cluster.resync event as lanes 1, 3, 4 (fix(cluster): a Redis outage must not crash replicas; resync caches on reconnect #31721) and 5 (feat(cluster): settings changes reach every replica (settings lane) (#3814 F3b) #31597). A protocol
    that predates the seam is skipped, and a rejected resync is a warning, as
    for the other lanes.

  • Docs. content/docs/kernel/cluster.mdx §6.2 and the bridge docblock now
    describe lane 2's resync instead of "Lane 2 has no resync yet".

Why

#31721 left the metadata.mutated lane as the one lane without a resync. Its
hint is what makes a peer re-run the ObjectQL registry write-through. So a hint
lost during a store outage left every other replica answering
OBJECT_NOT_FOUND for an object authored meanwhile (or serving its old body,
or serving it after a delete) until restart.

Step 0: full re-convergence vs a diff

Measured on a booted showcase (bootShowcase, OS_METADATA_WRITABLE=object),
with N objects authored and the lane attached:

N Diff, nothing lost Diff, 5 changed Full re-apply of every row Listener replays (full)
50 ~1 ms, 50 unchanged 12 ms, 5 converged 97 ms 50
300 2 ms, 300 unchanged 9 ms, 5 converged 406 ms 300

The address-and-checksum read takes ~1 ms at both sizes. These are
shared-box timings, so read them as ratios.

Choice: the diff. A full re-apply costs one delivered-hint convergence per
stored row on every reconnect. Each convergence also replays the item into
the local mutation listeners, and some of those re-sync a whole family per
event (authored hooks and actions). So the cost grows with the catalog even
when nothing was lost. A since-timestamp re-read was ruled out:

  • a hard delete leaves no active row to carry a timestamp;
  • the writers' clocks are not this replica's.

A finding from the measurement

On the booted showcase, the first build's resync and seed reads were refused
with PermissionDeniedError (a read under a context that carries no
principal). Every resync would have failed on a secured stack. Both reads now
carry context: { isSystem: true }, as the repository's own reads do. The
fan-out harness now refuses a principal-less column-subset read, as the
secured engine does, so this is pinned (A8a/A8b below). The two-kernel test
has no security plugin, so it could not catch it.

Tests

  • packages/metadata-protocol/src/protocol.cluster-mutation-fanout.test.ts:
    a new [#31722] cluster.resync describe with 10 cases. The shared harness
    gains a read fault (every read, or item re-reads only), the registered
    labels, and the principal-less refusal:
    • ⭐ an object authored while the hint was lost is served after the resync;
    • a lost update re-converges that item only, and an unchanged item is not
      re-applied;
    • a lost delete takes the heal walk;
    • a delete of a row present at attach is found from the baseline;
    • a revert to an earlier checksum after a delivered hint;
    • a local write on the peer is re-read;
    • a failed active-row read rejects and keeps every entry;
    • an item whose re-read fails is kept, logged once, and retried;
    • CONTROL: nothing lost means nothing is re-applied;
    • CONTROL: with no transport, the seam does nothing.
  • packages/services/service-cluster/src/metadata-cluster-bridge-plugin.test.ts:
    • the existing resync cases now assert lane 2 and the info line;
    • 2 new cases: a protocol that predates the seam, and a rejected protocol
      resync is a warning.
  • packages/runtime/src/cluster-metadata-mutation-resync.integration.test.ts
    (new): two LiteKernels over one SQLite file, a lossy bus, a test-bus
    driver with liveness, and the real bridge.
    • ⭐ author on A with the hint lost. B does not know the object. B's
      cluster.resync runs. B serves the object and its row.
    • CONTROL: a delivered hint converges B with no resync.
    • CONTROL: on the memory driver, the seam is never called (R3: the
      in-process driver never emits cluster.resync).

Ablations

Each was run against the tests above, first on the pre-merge head and again
on the merged head. All went red both times, and each restore left the file
equal to HEAD.

# Mutation Red
A1 bridge lane-2 registration removed 3 bridge cases; the runtime ⭐ through the built dist
A2 active-row read failure swallowed (rows = []) the failed-read case
A3 a failed item re-read drops its key the item-failure case
A4 no unchanged skip 2
A5 the hint's touch removed 4
A6 lane-2 resync registered before the in-process guard 4 (the memory CONTROL included)
A7 the local write's touch removed the local-write case
A8a the seed read without the system context the baseline-delete case
A8b the resync read without the system context 9

The A1 runtime leg uses a preflight marker that is present in the pristine
dist, absent under the mutation, and present after the restore.

Acceptance notes

Verification

  • Per touched package, pnpm typecheck and package-scoped lint (root eslint
    on the directory, --no-inline-config) exit 0. A full vitest run:

    Package Test files Tests
    metadata-protocol 329 passed, 4 skipped 22607 passed, 26 skipped
    service-cluster 11 158
    runtime 568 10424 passed, 19 skipped
  • All of the above ran on the merged head 70a46315.

  • dispatch-gates.mjs --commands was derived on 70a46315 and gave 104
    commands. Each was run (all exit 0) and reconciled with --ran: 104
    derived, 104 run, 0 NOT-MEASURED. check-nul-bytes exits 0.

  • Forced test edits: none. The existing bridge resync cases gained lane 2 in
    their assertions, and the fan-out suite's shared harness was extended.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (packages/spec untouched.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: n/a.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE

…try on cluster.resync

An object authored while the cluster store was unreachable lost its
metadata.mutated hint, so every other replica answered it as unknown until
restart. The protocol now offers resyncMetadataMutationPubSub(): one read of
sys_metadata's active rows (address and checksum) names each item a lost hint
could have touched, and each is re-converged by the delivered-hint applier from
the replica's own re-read. A failed read is never a delete. The bridge registers
the seam with the other lanes; the memory driver never emits the event.

Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE
Co-authored-by: Claude <noreply@anthropic.com>
…e metadata.mutated lane

Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE
Co-authored-by: Claude <noreply@anthropic.com>
…latform

On a booted stack with security, the baseline and active-row reads carried
no principal and were refused, so every resync failed. Both reads now carry
the system context, as the repository's own reads do. The fan-out harness
refuses a principal-less column-subset read, as the secured engine does.

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE
…package's lib target

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ADHkmQr9knGGTwQc6UKmnE
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/metadata-protocol, @objectstack/service-cluster, touching 36 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/metadata-protocol/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

20 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json 6be71abc34cdd7adcc6057d121479ba5a11724e3.

⛔ 9 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/metadata-protocol/src/index.ts) — pages documenting those are invisible to this run
  • 14 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 231 client-bound route-ledger rows — the other 166 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 166: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 107 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 13 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 6be71abc34cdd7adcc6057d121479ba5a11724e3 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 711cfd6589f5d368bfcc070b3185de302d7207dd — the merge of head 70a463152e646ffc8383c5df9e644abe1d79fb94 into base 6be71abc34cdd7adcc6057d121479ba5a11724e3, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 711cfd6589f5d368bfcc070b3185de302d7207dd && git checkout 711cfd6589f5d368bfcc070b3185de302d7207dd
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 6be71abc34cdd7adcc6057d121479ba5a11724e3 70a463152e646ffc8383c5df9e644abe1d79fb94 && git checkout -B drift-repro 6be71abc34cdd7adcc6057d121479ba5a11724e3 && git merge --no-ff 70a463152e646ffc8383c5df9e644abe1d79fb94

node scripts/docs-audit/affected-docs.mjs --json 6be71abc34cdd7adcc6057d121479ba5a11724e3

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 6be71abc34cdd7adcc6057d121479ba5a11724e3 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#1 · os-steve · session_01ADHkmPF1skfu2kx89BEXZi

席位 ACCEPT · head 70a463152e646ffc8383c5df9e644abe1d79fb94

#31722 (#31596 follow-up, the lane 2 metadata.mutated resync). The changeset reads Clause-②: yes (widening) / Metadata-protocol: none, and the paths give no review face. The seat reviewed it at TIER_DEFAULT. Not governed.

  • Design (the diff): one address-and-checksum read of the active sys_metadata rows, diffed against a per-replica ledger seeded at attach. These items re-converge through the same applier a delivered hint runs:

    • a row whose checksum moved,
    • an item with no active row left (converged as deleted),
    • an item a hint or local write touched since the last convergence.

    Nothing goes on the wire. The measured cost on the booted showcase (2 to 9 ms against a 406 ms full re-apply) justifies the diff.

  • Safety, checked in the tree:

  • Bridge: lane 2 registers its resync seam at kernel:ready. Lane 5 stays at kernel:bootstrapped, and subscribeResync() is called in both phases, as feat(cluster): settings changes reach every replica (settings lane) #31785 left it. The in-process memory driver never emits cluster.resync, so a single node is unchanged.

  • Names (seat's call): accepted. resyncMetadataMutationPubSub() and MetadataMutationResyncReport follow the lane family.

  • Accepted deviations:

    1. The claim said Clause-② no; the build measured yes (widening), and the claim is restated on 6733021113.
    2. The runtime integration test sits outside the literal surface; it is restated on the same claim.
    3. One push was made under the earlier go-ahead, before the hold. The branch now merges main after feat(cluster): settings changes reach every replica (settings lane) #31785, with a clean merge commit.
    4. The first commit alone fails the dts build. The PR lands as a whole, so this is accepted.
  • Changeset: patch for @objectstack/metadata-protocol and @objectstack/service-cluster, following Metadata-protocol: none.

  • Evidence: gates 104 derived, 104 run, 0 NOT-MEASURED. Ablations 9/9 red, both before and after the merge.

Landing: once CI is all green, check K, then relay pr_ready + automerge_enable.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 9, 2026 05:55
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 9, 2026
Merged via the queue into main with commit ad622d3 Nov 9, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-eeoddo branch November 9, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants