Skip to content

fix(cli): stage os skills writes and swap them in by rename, recording last (re-land) - #36465

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-35079-skills-staged-swap-reland
Nov 22, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/issue-35079-skills-staged-swap-reland

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steedos · project thread

Fixes #35079

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:命令行用户运行「安装技能」或「更新技能」时,若中途写盘失败(磁盘满、无权限、被中断),原有技能和安装记录保持原样,下次直接再运行更新即可,不再需要加强制参数。
  • 为什么做:这是技能安装可靠性修复的重新合入;上次合入后因车队门禁读不懂暂存目录而被撤回,门禁那一侧已按你「扫描只管仓内运行的代码」的裁决改好。
  • 出错会怎样:最坏是安装或更新在失败时留下一个隐藏的暂存目录,它不会被当成技能读取,下次写入时自动删除;可直接撤回本改动。
  • 要你做什么:无。

What changes

This re-lands the staged swap of PR #35495 (merge commit 578d3b1d66), byte for byte. PR #35616 reverted it because the dispatch-gates mkdtempSync completeness rule could not read the staging base. That base is computed from the caller's dir, and the scan reads one file at a time. PR #36368 (merged fb6eb801b2c) carries out ruling record 7075362923: an unresolved site in shipped package source is now reported, not failed. So the diff lands as written.

  • packages/cli/src/utils/skills-install-state.ts, applySkillsWrite: every new skill directory is written into one hidden staging directory inside the skills directory (.objectstack-skills-staging-*, from mkdtempSync, so it sits on the same filesystem). Each touched skill is renamed aside into it, and its staged copy is renamed into place. The record is written into the staging directory and renamed over the old one, after every swap. Any throw undoes the renames already done, newest first. The next write removes any leftover staging directories. They are hidden, so status, the plan and inspectSkillsDir never read them as skills.
  • packages/cli/test/skills-commands.test.ts: a new top-level describe in the shared harness. It injects ENOSPC at three points (a staged file write, moving the second skill into place, the record rename) and has one leftover-staging case. The fault seam is a hoisted pass-through vi.mock('node:fs'). The test's own scratch base is tmpdir(), which the scan can read.
  • .changeset/35079-skills-write-staged-swap.md: fix(cli): stage os skills writes and swap them in by rename, recording last #35495's patch changeset for @objectstack/cli, unchanged.

Proof of identity with #35495: git diff --cached after git cherry-pick -n 578d3b1d66 equals git diff 578d3b1d66~1 578d3b1d66 (a diff of the two outputs printed nothing). Both target files on origin/main ff601499008 are byte-equal to the merge's parent eb1f85d7f4: git diff eb1f85d7f4 HEAD on those two paths was empty before the pick. So nothing on main needed adapting.

Files to read first (risk order):

  1. packages/cli/src/utils/skills-install-state.ts, applySkillsWrite's try/catch and undoSwap. This is the swap and its rollback.
  2. packages/cli/test/skills-commands.test.ts, the vi.mock('node:fs') fault seam at the top of the file. It is a pass-through unless a test arms it.
  3. packages/cli/test/skills-commands.test.ts, the describe an interrupted write leaves the installed catalog usable.

Two-minute check: node scripts/pm/dispatch-gates.mjs --self-test 2>&1 | grep "no mkdtempSync site in a test file" should print one passing line. It reports packages/cli/src/utils/skills-install-state.ts:246 under "reported, not failed".

Tests

All readings at head 009ca680a2f (base origin/main ff601499008).

  • packages/cli/test/skills-commands.test.ts, run under the verify lock after the @objectstack/cli^... closure build: Test Files 1 passed (1), Tests 34 passed (34), VERDICT command-exit 0. That is the 30 existing cases plus the 4 new interrupted-write pins.
  • pnpm --filter @objectstack/cli build: exit 0 in the same locked run.
  • node scripts/pm/dispatch-gates.mjs --self-test, both tiers: fast 2264 case(s) · slow 315 case(s), ✓ dispatch-gates self-test: 2579 cases pass., exit 0. It includes the slow case this re-land was blocked on, which now passes.
  • Declared narrowing: the full cli unit tier and pnpm --filter @objectstack/cli typecheck did not get a lock turn before this PR opened. Two long batteries owned by other seats held the shared lock for more than an hour. Both are declared to CI (Test Core, TypeScript Type Check). The integration tier is declared to CI: the diff touches no integration-tier file and no spawn entry.
The live slow case, from the full self-test log
  ✓ the sweep really read this tree (3154 directory-creating site(s) across 23442 tracked source(s))
  ✓ and it really found in-tree fixture roots (93), so the coverage case below judges something
  ✓ every in-tree directory this tree's sources create is covered by a tracked ignore rule, or is tracked itself
  ✓ no mkdtempSync site in a test file or repo tooling takes a base the scan cannot read — reported, not failed (shipped package source, base chosen at run time): packages/cli/src/utils/skills-install-state.ts:246 (dir is not bound in this file)
dispatch-gates self-test tiers: fast 2264 case(s) in 576.2s · slow 315 case(s) in 1879.5s.
✓ dispatch-gates self-test: 2579 cases pass.

Acceptance notes

Verification

Derived gate families: 64 derived, 61 run, 3 NOT MEASURED, 0 unrun (head 009ca68)
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 64 families. Each one ran with its exit code captured before any pipe. Then --ran reconciled them: ✓ dispatch-gates --ran: 64 derived famil(ies) accounted for — 61 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3).
  • 61 exited 0. Among them: check:nul-bytes, check:cross-package-test-inputs, check:test-source-alias, check:cli-test-child-env, check:published-files, check:dts-closure, check:i18n, check:lean-entry-closure, check-changeset-no-major, check-empty-changeset, check-adr-0087-registration and check-closing-keyword-parity (each with --self-test where it is derived). Eight gates first answered exit 3 before the build. They were re-run after the closure build, and five of them went to exit 0.
  • NOT MEASURED, exit 3 (PREREQUISITE NOT MET), all three left to CI: pnpm check:dual-build-cjs-loads (packages outside the cli closure have no dist/), pnpm check:i18n-coverage (example configs outside the closure are not built), and pnpm check:type-check-debt (its re-measure build did not get a turn on the shared lock).
  • node scripts/pm/dispatch-gates.mjs --tier: no path-derived mandate. Changed lines: 253 (+239 / -14), under the 3000 threshold.
  • node scripts/pm/overlap-check.mjs --branch=claude/issue-35079-skills-staged-swap-reland: VERDICT clean exit 0, run before the push.
  • Body gate: node scripts/check-closing-keyword-parity.mjs --body binds exactly one declaration, this card's, on the line under the header.

@objectstack/cli publishes, so the patch changeset from #35495 comes along unchanged. No skip-changeset.

🤖 Generated with Claude Code

…g last

Re-lands the staged swap of #35495 (merge 578d3b1), reverted by #35616
because the dispatch-gates mkdtempSync completeness rule could not read the
staging base. The gate now reports such a site in shipped package source
(#36368), so the diff lands unchanged: applySkillsWrite writes every new
skill into a hidden staging directory inside the skills directory, swaps
each touched skill in by rename, renames the record over the old one last,
and undoes the renames already done on any failure.

Claude-Session: https://claude.ai/code/session_01QsR2jTeURPvEm465RcoYEC
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 Nov 22, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

6 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 68 of 250 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 40 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 e9da8987afd23fa2b66e8a141c0585174819f521 → packageMentionDocs.

Which tree this was computed on

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

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

⚠️ 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#7 · zhuangjianguo · session_01QsR2jS7jCv5PH4ytECQWqf

L1 ACCEPT · head 009ca680a2f59e1a28a705897d37b3540effbd01 · 2026-11-22T13:13Z

维护者速读

席位核对

  • 是不是原样重合:我用 git diff 578d3b1d66~1 578d3b1d66 和 git diff ff601499 009ca680 两份补丁做了 diff,结果逐字节相同。两个被改的源文件 skills-install-state.ts 和 skills-commands.test.ts,在 578d3b1d66~1 和 ff601499 上的 blob 也相同。所以这不只是补丁能打上,而是打在了同一份文件上。PR 只有一个提交,3 个文件。
  • 撤回的原因已经解决:revert(cli): stage os skills writes and swap them in by rename, recording last (#35495) #35616 撤回,是因为 skills-install-state.ts 里 mkdtempSync(join(dir, SKILLS_STAGING_PREFIX)) 的 dir 在调用时才决定,扫描读不出来,完整性那一条判红。fix(pm): mkdtempSync completeness fails tests and tooling, reports shipped package source #36368(已合并,依据裁决 7075362923)把规则改成:发布包源码里这种调用只报告,不判红;测试和仓库脚本照旧判红。我在本 head 的 worktree 里直接调了门禁的导出(exposedScratchDirs({}) 和 mkdtempCompleteness),读数是:exposed 0,failing 0,reported 只有一处 packages/cli/src/utils/skills-install-state.ts:246 (dir is not bound in this file)。和 dev 报告的一致。本 head 上 Lint · PM dispatch-gates 也是 success。
  • revert(cli): stage os skills writes and swap them in by rename, recording last (#35495) #35616 提到的忽略规则问题:被强行中断的运行如果在本仓库根目录下,会留下 .claude/skills/.objectstack-skills-staging-*。这正是裁决接受的代价(「发布代码同类调用只报告不判红」),不需要在本 PR 里处理。另外,这个目录以点开头,status 不会把它当成技能,下一次写入会把它删掉,测试钉住了这一点。
  • 卡片关系:首行 Fixes #35079。这张卡在撤回后重新打开,本 PR 交付了它的全部内容。合并应当关卡。
  • 声明:Clause-②: no 对。SKILLS_STAGING_PREFIX 是 utils 里的常量,不是包根导出。Metadata-protocol: none 对。不欠 Skills-docs:命令行为和标志都没变,只改了写入的方式。不是 !,也没有 (narrowing),不欠 dogfood。
  • changeset:@objectstack/cli 有 patch 条目,原文是 revert(cli): stage os skills writes and swap them in by rename, recording last (#35495) #35616 删掉的那一份。逐句核过:「先写进暂存目录,再用 rename 换进去,最后写记录」「任何一步失败都按倒序撤回,并报告错误」「普通的 os skills update 就能重来」「中断留下的 .objectstack-skills-staging-* 是隐藏的,不会被当成技能,下一次写入会删掉」。每一句都和 applySkillsWrite 以及新的测试一致。
  • 测试:三种故障点(写第二个技能的文件时、把第二个技能换进去时、写记录时)各注入一次 ENOSPC。每种都断言:退出码 1;旧版本的文件和记录原样;status --check 干净;旁边只剩记录文件;再跑一次不带 --force 的 update 就能装上 V2。还有一条测试覆盖中断留下的暂存目录。
  • 本地没跑的部分,CI 有没有盖到:dev 说本地没有跑 cli 的完整单元测试和 cli 的 typecheck。
    • typecheck:本 head 上 TypeScript Type Check 和 Type Check · workspace 都是 success。
    • 单元测试:Plan Test Core shards 的日志写明 @objectstack/cli 分成 3 片,在 Test Core (1/10)、(5/10)、(6/10) 里跑。
    • CI 已经覆盖了这两项,所以本地少跑这部分可以接受。
  • CI @ 009ca680:37 success、16 skipped、0 failed,其中跑 cli 的三片 Test Core (1/10)、(5/10)、(6/10) 都是 success;不在治理面。
  • 落地:席位落地。

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC

Landing (seat 7, 2026-11-22T13:15Z): head 009ca680a2f59e1a28a705897d37b3540effbd01 · L1 ACCEPT 7079654697 (L1-d) · no L2 face owed: Clause-②: no, Metadata-protocol: none, and the diff is a byte-identical re-land of #35495 (merge 578d3b1d66), whose review stands; the gate side it was reverted for landed in #36368 · check-governed-merges --pr 36465: NOT governed, 253 changed lines ≤ 3000 · CI on the head: 37 success, 16 skipped, none failed or pending. → pr_ready + automerge_enable (merge queue).
The hard-kill window inside the rename swap stays tracked as #35502.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 22, 2026 13:16
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit 6cf0dad Nov 22, 2026
54 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-35079-skills-staged-swap-reland branch November 22, 2026 13:36
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

2 participants