Skip to content

fix(runtime): get_metadata_item without state answers the version a following save takes - #39022

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-38982-read-version
Dec 2, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/issue-38982-read-version

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #38982

Clause-②: no (the tool answer gains the version it already carries on a read with state; no input parameter added, no package export moved)
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:助手通过连接读取一个已有配置时,即使没说读哪个状态,返回里也带上版本号,紧接着保存修改不再因为猜错版本号被拒。
  • 为什么做:属于「助手直接在环境里搭应用」这条主线第二阶段,替改现有对象、视图的助手省掉一轮失败重来。
  • 出错会怎样:最坏是读的过程中配置恰好被别人改了,这时不给版本号或给旧版本号,保存会被拒并提示重读,不会覆盖别人的改动;可直接撤回本改动。
  • 要你做什么:无。

What changes

get_metadata_item read without state serves the pending draft where one exists and the published item otherwise, through the protocol's previewDrafts read, which answers no version on purpose (no single lifecycle's token describes it; it is the render path). The door therefore answered no token, and an agent that saved after such a read guessed ifMatch and was refused.

The door now reads each lifecycle's token by the strict read a state read makes (state: 'draft' first; on NO_DRAFT, the plain read), BEFORE the served read, and answers the token of the lifecycle the served item came from: the draft's when the answer says draft: true, the published item's otherwise. A read with state is unchanged, and so is the protocol (packages/metadata-protocol/** untouched; the previewDrafts read keeps omitting version).

Why before and not after: a change landing between the token read and the served read leaves the token OLDER than what was served, and a save pinned to it is refused (409, naming the current version). Read after, the token could be NEWER than what was served and would pin a save to content the caller never saw. A draft published, discarded or first saved in between leaves no token of the served lifecycle, and the answer carries no version then (PM mechanism assumption 3: no version rather than a wrong one).

The tool description's sentence "a read without state answers none" now says what the answer carries, and that version: null means save without ifMatch (the save refuses ifMatch: null with VALIDATION_ERROR; a read with state: 'active' of an item with no stored row already answered null). Seat rulings D1 to D4 and ruling 5856774816 quoted in the file are untouched.

Read first, by risk:

  1. packages/runtime/src/domains/mcp-authoring.ts, the get_metadata_item branch: the token reads ahead of the previewDrafts read, and the version selection after the gate.
  2. packages/runtime/src/domains/mcp-authoring-38982-read-version.test.ts, the second describe (a writer landing between the token reads and the served read).
  3. packages/runtime/src/domains/mcp-authoring.test.ts, the one pin whose recorded protocol calls gain the leading state: 'draft' read.

Tests

New file, real metadata protocol over a SQLite file; every token is one a read answered and every save is the protocol's own judgement, no token built by hand:

  • no pending draft: the stateless read answers the published item's version, equal to a state: 'active' read's; a save pinned to it is written;
  • a pending draft: it answers the draft's version, equal to a state: 'draft' read's and different from the published one; the published version is refused 409 METADATA_CONFLICT (the card's case) and the answered one is written;
  • a never-published item: the first draft's version, and a save pinned to it is written;
  • the draft saved again between the token read and the served read: the answered token is the older draft's, and a save pinned to it is refused, leaving the newer draft in place;
  • the draft discarded in between: the published item is served with no version;
  • a first draft saved in between: the draft is served with no version.
Runs at head 8d6f9b4 (the merge of origin/main; 4ab29f3 after it is an empty trailer-carrying commit, same tree)
  • pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 over the four files that import the authoring registry plus src/domains/mcp*: Test Files 15 passed (15), Tests 451 passed (451), lock verdict command-exit 0.
  • pnpm --filter @objectstack/runtime typecheck: exit 0, check:test-typecheck: OK — @objectstack/runtime's test layer compiles under packages/runtime/tsconfig.test.json.
  • The full @objectstack/runtime suite did not finish inside the container's foreground cap: NOT MEASURED locally, left to CI's Test Core.
Ablations (on-disk mutation through scripts/ablation-replace.mjs, restored to the HEAD blob, git diff HEAD empty after each)
  • A: the stateless read answers only the protocol's own version (the old behaviour): 4 of 6 new cases red (the three version cases and the re-saved-draft race); the two no-version race cases stay green, as they should.
  • B: the lifecycle match dropped (servedTokens.draft ?? servedTokens.active): the two no-version race cases red, the other four green.

Acceptance notes

  • Cost: a stateless read now makes two protocol reads where a draft is pending (the strict draft read, which also folds the draft's publish verdict, then the served read), and three where none is (the draft read's 404, the plain read, the served read). A read with state still makes one.
  • Boundary, not filed: the preview read considers a declared override's pending draft (servedOverride), the strict draft read does not. Where both an override draft and another draft of the name exist, the token answered is the one a state: 'draft' read answers, which may describe a different row from the one served. That is the existing state: 'draft' read's address, unchanged here.
  • AGENTS.md says a new pin for a component with a shared harness file goes into that file as a top-level describe (ruling record 6583487846). The dispatch's file surface names a new file and limits mcp-authoring.test.ts to pins reading a changed node, so the new pins are in their own file; raised in the report.
  • The card's other half (a skill line stating the read that does answer the token) is in skills/**, outside this card's surface.

Verification

pnpm --filter @objectstack/runtime exec vitest run --maxWorkers=2 src/domains/mcp-authoring-38982-read-version.test.ts (after building the runtime package's dependencies) prints Tests 6 passed (6).


Generated by Claude Code

…'s description; pin it on the real protocol

Claude-Session: https://claude.ai/code/session_01WGufzivFXq32jQSCUnECPj
Co-authored-by: Claude <noreply@anthropic.com>
The merge commit 8d6f9b4 was written without the trailer pair; this
empty commit carries it, and the tree is unchanged.

Claude-Session: https://claude.ai/code/session_01WGufzivFXq32jQSCUnECPj
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m 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 Dec 2, 2026
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

2 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 71 of 254 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 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; 124 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 — 30 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 c748e7dfd647ca9b4e679d59425f358c9ff84b04 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 12e9134fe1fb4463aa794ed1573727eae88c098e — the merge of head 070143a23f511df9d37dd101995f5d8fa888b12f into base c748e7dfd647ca9b4e679d59425f358c9ff84b04, 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 12e9134fe1fb4463aa794ed1573727eae88c098e && git checkout 12e9134fe1fb4463aa794ed1573727eae88c098e
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin c748e7dfd647ca9b4e679d59425f358c9ff84b04 070143a23f511df9d37dd101995f5d8fa888b12f && git checkout -B drift-repro c748e7dfd647ca9b4e679d59425f358c9ff84b04 && git merge --no-ff 070143a23f511df9d37dd101995f5d8fa888b12f

node scripts/docs-audit/affected-docs.mjs --json c748e7dfd647ca9b4e679d59425f358c9ff84b04

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzivFXq32jQSCUnECPj

Final green head for L1 · 2026-12-02T03:26Z · zone osa-build

  • Head: 4ab29f33ade667d7198ae2e2add949dcfc7dea37 — 39 check runs success, 18 skipped (opt-in jobs), 0 other; mergeable, clean.
  • Size: +306/−3 across 4 files; no governed path.
  • Fixes #38982: the card's acceptance names two alternatives; this PR delivers the first (the read without state answers the served lifecycle's version). The skill-line alternative is not needed and not in this surface.
  • Pin placement: the new pins stay in their own file, per the claim's file surface (the dev's open question, answered A by the zone).
  • Dev report: 读配置不带状态时不返回版本号,助手保存时只好猜版本号 #38982 comment 7333515079.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 review · PR #39022 (#38982) · head 4ab29f3 · 2026-12-02T03:28Z

ACCEPT, on head 4ab29f33ade667d7198ae2e2add949dcfc7dea37.

  • Face: l1-face CLEAN. Checks 39 success, 18 expected skips, 0 failed, 0 pending; mergeable_state clean. Not governed; +306/−3. Clause-②: no and Metadata-protocol: none hold, because the answer gains a version the tool already returned on state reads and no exported type or schema moves. patch on runtime.
  • Fixes #38982 is right. The card's acceptance is an either/or ("answers the version … or the skill states the read"), and this delivers the first alternative with pins.
  • Head shape: 4ab29f33 is an empty trailer-only commit (no diff from 8d6f9b47). 8d6f9b47 is a pure merge of main: its tree f2899ddf equals merge-tree of its parents.
  • (1) Token order, read in mcp-authoring.ts. With no state, the strict state: 'draft' read runs first and swallows only NO_DRAFT, then the published read runs, then the served previewDrafts read. The answer takes the token of the lifecycle the served item came from (_draft) and none when that lifecycle had no token at read time. I walked every race: draft re-saved in between gives an older token and a 409; draft discarded gives active served with no token; first draft saved gives draft served with no token; draft published gives active served with no token. None can pin a save to content the caller did not see. Each of the six cases is pinned on a real engine in the new test file. The missing-item path is unchanged: the published read answers no item and notFound follows, and the existing missing pin still passes. The gate runs on the served item as before, so no token is answered for a refused item.
  • (2) Declared override's pending draft. If the preview read serves an override's draft that the strict draft read does not see, the answer is draft: true with tokens from the active lifecycle only. So it carries no version, which fails safe because nothing gets pinned to the wrong row. Nit: in that state, "read it again" in the tool description repeats the same answer. A caller then needs a state read. Recorded in the PR's acceptance notes; a follow-up card is fine if it ever reproduces.
  • (3) Pins in their own file, per the claim's surface: fine.
  • The existing call-order pin in mcp-authoring.test.ts gains the leading strict draft read, matching the code.
  • Changeset and tool description read sentence by sentence: both match the tree.

Next: zone landing. The merge closes #38982.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzivFXq32jQSCUnECPj

Landing · 2026-12-02T03:29Z · zone osa-build

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review December 2, 2026 03:30
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 2, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Dec 2, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzivFXq32jQSCUnECPj

Dequeued, not this PR's defect · 2026-12-02T03:46Z · zone osa-build

@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 46803014842 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Test Core (7/12) — 失败步骤: Run this shard's tests

    @objectstack/plugin-auth:test:  FAIL  src/objectql-adapter.test.ts > a single-use auth value is redeemed at most once, even across processes sharing a database > of two concurrent redemptions on two e
      ↳ 失败原因: @objectstack/plugin-auth:test: Error: Test timed out in 10000ms.
    @objectstack/plugin-auth:test:  FAIL  src/objectql-adapter.test.ts > a single-use auth value is redeemed at most once, even across processes sharing a database > a redemption of a value already redeem
      ↳ 失败原因: @objectstack/plugin-auth:test: Error: Hook timed out in 10000ms.
    @objectstack/plugin-auth:test:  FAIL  src/objectql-adapter.test.ts > a single-use auth value is redeemed at most once, even across processes sharing a database > a single redemption receives the value
      ↳ 失败原因: @objectstack/plugin-auth:test: Error: Test timed out in 10000ms.
    

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • src/objectql-adapter.test.ts — 24h 窗口内只有本 PR 撞到过,暂不汇总(再有一个不同 PR 撞到就会自动开汇总 issue)。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 1 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

Picks up the gate fix for the closed-ceremony-text listing buffer (#39025), which the merge queue failed this PR on.

Claude-Session: https://claude.ai/code/session_01WGufzivFXq32jQSCUnECPj
Co-authored-by: Claude <noreply@anthropic.com>
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzivFXq32jQSCUnECPj

Final green head for L1 delta · 2026-12-02T05:19Z · zone osa-build

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzhGA3zoCFquQgku4pm

L1 delta · PR #39022 (#38982) · head 070143a · 2026-12-02T05:20Z

ACCEPT, on head 070143a23f511df9d37dd101995f5d8fa888b12f.

Next: re-arm.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack@os-support-ai · os-support-ai · session_01WGufzivFXq32jQSCUnECPj

Re-arm (once) · 2026-12-02T05:20Z · zone osa-build

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Dec 2, 2026
Merged via the queue into main with commit 4a3b532 Dec 2, 2026
57 checks passed
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/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

读配置不带状态时不返回版本号,助手保存时只好猜版本号

2 participants