Repository navigation
fix(cli): stage os skills writes and swap them in by rename, recording last - #35495
Conversation
Claude-Session: https://claude.ai/code/session_01L6bhgTyMahdAdhXSzgy2nt Co-authored-by: Claude <noreply@anthropic.com>
…g last Claude-Session: https://claude.ai/code/session_01L6bhgTyMahdAdhXSzgy2nt Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift Check6 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
Coarse fallback — 40 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin d6a1d3a8d5fa1f1da7de3dbc2c9a9649867bf827 && git checkout d6a1d3a8d5fa1f1da7de3dbc2c9a9649867bf827
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 819c0679a8917fddd8dba7314c8de2c27d03e46b df049c49b17e366f903f0423b849201055b97dc6 && git checkout -B drift-repro 819c0679a8917fddd8dba7314c8de2c27d03e46b && git merge --no-ff df049c49b17e366f903f0423b849201055b97dc6
node scripts/docs-audit/affected-docs.mjs --json 819c0679a8917fddd8dba7314c8de2c27d03e46b |
|
repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt Final green head for L1:
|
|
repo:objectstack#1 · os-sales · session_01L6bhgTcFanGhTvqS1V2Q4U 维护者速读
席位核对 — ACCEPT (L1-a) · repo:objectstack#1 · head
|
…ills-write-staged-swap
|
repo:objectstack#1 · os-sales · session_01L6bhgTcFanGhTvqS1V2Q4U Correction to ACCEPT 7008910233 · 2026-11-19T12:21Z: the "Before landing — dedupe two bullets of 维护者速读" item is withdrawn. The PR body has each bullet once; the repetition was an artefact of my own read (a Generated by Claude Code |
|
repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt Landing · 2026-11-19T12:45Z · area b1-B, after L1-a ACCEPT 7008910233 (head
State: ready + auto-merge now; #35079 closes on merge. Follow-up of the residual kill window: #35502. |
…ding last (#35495) This reverts commit 578d3b1. Why: that commit added a staging directory, mkdtempSync(join(dir, SKILLS_STAGING_PREFIX)) in applySkillsWrite, whose base is the caller's cwd-relative skills directory. The dispatch-gates scratch-dir scan reads one file at a time and treats such a base as unreadable, so the self-test case "no mkdtempSync site in this tree takes a base the scan cannot read" fails on it. That is the one red case keeping main's scheduled full Lint & Type Check run red (#35588). No honest spelling inside the CLI file lets the scan read that base, and the gate is not narrowed. Consequence: the defect #35079 addressed comes back. An os skills update that fails partway can again leave the catalog and its record out of step, and #35079 reopens. Re-landing the staged swap waits on a gate-side ruling about how the scan judges a directory-creating call whose base is a caller's argument. The deleted changeset (.changeset/35079-skills-write-staged-swap.md) was never released, so this revert ships nothing. Claude-Session: https://claude.ai/code/session_01L6bhgTyMahdAdhXSzgy2nt Co-authored-by: Claude <noreply@anthropic.com>
…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>
…ipped package source (objectstack-ai#36368) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCxiFE11rsKwyNffJZKYqJs)_ Fixes objectstack-ai#35611 Clause-②: no Metadata-protocol: none Ruling-ref: 7075362923 ## 维护者速读 - 用户能看到什么变化:用户无感;车队门禁的「临时目录扫描」不再因为发布代码里由用户运行时决定位置的暂存目录而判红,测试和仓库脚本照旧判红。 - 为什么做:执行你选的「扫描只管仓内运行的代码」裁决,解开技能安装「失败可回滚」修复被撤回的卡点。 - 出错会怎样:最坏是发布代码里一个真会落进仓库的暂存目录只被报告、不被拦下;今天这一类为零,撤回本改动即可恢复原判法。 - 要你做什么:本改动碰到门禁本身,需要你批准后才能合入。 ## What changes The `mkdtempSync` completeness rule of the directory-creating sweep in `scripts/pm/dispatch-gates.mjs` now judges an UNRESOLVED site by its **file population**, as ruling record 7075362923 orders. The maintainer's choice, verbatim: 「扫描只管仓内运行的代码」; the option's stated consequence, verbatim: 「完整性规则只管测试与仓库脚本,发布代码同类调用只报告不判红;门禁小幅收窄,技能安装修复原样重新合入。」 - **Test files and repo tooling: still FAIL** on an unresolved `mkdtempSync` base, exactly as before. - **Shipped package source: REPORTED, not failed.** The live case names each such site on its own line and stays green. - **The boundary is one predicate, `isShippedPackageSource(rel, members)`:** a non-test source under the own `src/` of a workspace member whose manifest is not `private: true` (members come from `workspacePackages`' `{dir, manifest}` pairs; a private member, or one whose manifest does not parse, stays on the failing side). "Non-test" reuses the runner-env gate's `isProductSource` (a test by file name or by directory, `.d.ts` excluded). That is the stricter of the tree's test predicates, so a helper under `src/__tests__/` is still held. "Workspace package" means a workspace-enumerator member that holds a published (non-`private`) manifest. The predicate keeps no list of its own. The filter is the file, never "in-tree", because an unresolved site is exactly the one whose location is unknown. It is also not `isTestFilePath` alone, which would drop the 344 tooling sites. - `mkdtempCompleteness(unresolved, { members })` (default: `workspacePackages(ROOT)`) returns `{ failing, reported }`. The live slow case and the new fast pins call the same function. - The in-tree/uncovered rule (`exposedScratchDirs`) is unchanged for every population. No new gate, derivation row, ratchet or constant (`instrument-discipline.md`). - Header: the stale "359 sites, 4 in the tree" is replaced with a dated reading taken through the scan's own exports, plus the boundary in one sentence. - Riders, per the ruling record's seat reading: the objectstack-ai#30467 site stays as landed. Spellings 7 and 8 stay as they are for test fixtures, and this diff does not touch either. After this merges, objectstack-ai#35079's lane re-lands the objectstack-ai#35495 staged swap as written. This PR does not re-land it. Files to read first (risk order): 1. `scripts/pm/dispatch-gates.mjs`, `isShippedPackageSource` / `mkdtempCompleteness` (just above `isTrackedIgnoreSource`). This is the narrowing hunk: the predicate decides which unresolved sites stop failing. 2. `scripts/pm/dispatch-gates.self-test.mjs`, the live case "no mkdtempSync site in a test file or repo tooling takes a base the scan cannot read" (slow section). 3. `scripts/pm/dispatch-gates.self-test.mjs`, the new fast-tier block "Which UNRESOLVED mkdtempSync site fails completeness". Two-minute check: `node scripts/pm/dispatch-gates.mjs --self-test --fast 2>&1 | grep -A11 "REPORTED, not failed"` should print twelve `✓` lines: the shipped arm reported, plus the private-member, non-own-`src/`, test, `__tests__` and tooling arms failing, each next to its control. ## Tests New fast-tier pins (the tier a pull request's lane runs), on the exact spelling that turned main red (`mkdtempSync(join(dir, SKILLS_STAGING_PREFIX))`): | Arm | Verdict | Control one step away | |:--|:--|:--| | `packages/cli/src/utils/skills-install-state.ts` | reported, not failed | same file, `packages/cli` not a workspace package: FAILS; same package, outside `src/`: FAILS | | the same site in a `private: true` member's `src/` | FAILS | the published member: reported | | `packages/cli/scripts/src/staging.ts` (a `src/` that is not the member's own) | FAILS | the member's own `src/`: reported | | `…/skills-install-state.test.ts` (by name), `src/__tests__/…` (by directory) | FAILS | the test file on a `tmpdir()` base: in neither list | | `scripts/pm/stage-skills.mjs` (repo tooling) | FAILS | the tooling file on a `tmpdir()` base: in neither list | | unresolved `mkdirSync` | in neither list | (that half was never held to completeness) | | this tree's own workspace (default `members`) | shipped arm reported, tooling arm FAILS | n/a | Runs at `f7e942e8` (before the rework; this branch merged with `origin/main` `d8599c2c`). At the rework head `3ec2a452` the dev reran both tiers, exit 0: fast 2264 case(s) · slow 315 case(s), 2579 cases pass, including the 12 boundary pins (os-dev-report 7077315476). <details><summary>Both tiers, the slow section that holds the live case included: <code>node scripts/pm/dispatch-gates.mjs --self-test</code>, exit 0</summary> ```text ✓ a caller's-directory mkdtempSync base in shipped package source is REPORTED, not failed ✓ CONTROL: the same file in a directory that holds no workspace package still FAILS ✓ CONTROL: and in the package but outside its own src/ (one directory up), it still FAILS ✓ the same site in a test file FAILS — beside the shipped file, by name ✓ and in a test helper under src/__tests__/, by directory — the stricter test predicate holds it ✓ CONTROL: the test file with a base the scan CAN read (the system temp directory) is in neither list ✓ the same site in repo tooling FAILS — the tooling population is not dropped with the test predicate ✓ CONTROL: the tooling file with a base the scan CAN read is in neither list ✓ and an unresolved mkdirSync site is in neither list — that half was never held to completeness ✓ on this tree's own workspace, the shipped arm is REPORTED and the tooling arm FAILS ... ✓ the sweep really read this tree (3145 directory-creating site(s) across 23403 tracked source(s)) ✓ and it really found in-tree fixture roots (93), so the coverage case below judges something ✓ no mkdtempSync site in a test file or repo tooling takes a base the scan cannot read ... dispatch-gates self-test tiers: fast 2262 case(s) in 1009.1s · slow 315 case(s) in 1825.0s. ✓ dispatch-gates self-test: 2577 cases pass. ``` </details> <details><summary>Fast tier as CI runs it: <code>pnpm check:pm-dispatch-gates</code>, exit 0</summary> ```text ✓ dispatch-gates self-test (fast tier): 2262 cases pass; 9 slow section(s) deferred. check:pm-dispatch-gates: the battery (the fast tier) took 562.7s on this box. ``` </details> ## Acceptance notes - **The objectstack-ai#35495 spelling passes the slow case now (scratch copy, not re-landed here).** I checked out a scratch worktree at this branch's head and applied objectstack-ai#35495's merge diff (`578d3b1d66`: the skills-install-state source, its test, its changeset). I then ran the slow case's own logic on that tree through the scan's exports (`exposedScratchDirs` + `mkdtempCompleteness`). Result: origin/main's rule FAILS, `UNRESOLVED: packages/cli/src/utils/skills-install-state.ts:246 (dir is not bound in this file)`; this branch's rule has failing 0 and reported 1 (the same site), so the case passes. Exposed: 0. - **Boundary reading, resolved by the seat (reading B, rework 3ec2a45).** The maintainer's words 「扫描只管仓内运行的代码」 and 「发布代码同类调用只报告不判红」: a `private: true` member (`examples/*`, `apps/docs`, QA harnesses, the eslint plugin…) is not published code, so its `src/` keeps failing. L2 7076625985 graded the literal-rider reading M1; L1-d had preferred the literal reading (7076590966) and accepted the seat's ruling. Pins: a private member's `src/` site FAILS with the published arm as control, and `packages/cli/scripts/src/staging.ts` FAILS as the control for "the member's own `src/`" (L2 S1). The header's measurement is dated by base tree `d8599c2c`: 1823 sites, 1465 test (47 in-tree), 344 other, 14 shipped (tmpdir), 0 unresolved. - **Ablation not run.** The diff is a repo script, and the dispatch contract does not ablate scripts. The fast pins carry their own controls, and each control flips the verdict. - The live case's title changed from "no mkdtempSync site in this tree…" to "no mkdtempSync site in a test file or repo tooling…". No other file names the old text (`git grep` 0 hits). ## Verification <details><summary>Derived gate families: 63 derived, 62 run, 1 NOT MEASURED, 0 unrun (at f7e942e)</summary> - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 63 families. Each was run with its exit code captured before any pipe, then reconciled: `node scripts/pm/dispatch-gates.mjs --ran ran.list --repo objectstack-ai/objectstack` → `✓ dispatch-gates --ran: 63 derived famil(ies) accounted for — 62 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit 3).` - 62 exit 0, including `pnpm check:pm-dispatch-gates`, `pnpm check:nul-bytes`, `pnpm check:pm-governed-prose`, `pnpm check:pm-governed-merges`, `node scripts/pm/check-governed-queue-guard.mjs --self-test`, `node scripts/check-closing-keyword-parity.mjs` (+ `--self-test`) and `node scripts/check-self-test-wired.mjs` (+ `--self-test`). - NOT MEASURED: `pnpm check:i18n-coverage`, exit 3 (PREREQUISITE NOT MET: the package `dist/` builds it lints against are not built in this worktree, and this diff touches no package). CI runs it. - `node scripts/check-self-test-workflow-commands.mjs` first refused with `spawnSync node ETIMEDOUT` (load average 11 on a shared box, so no verdict). It was rerun at load 7.4 on the same head: exit 0. - `node scripts/pm/overlap-check.mjs --branch=claude/issue-35611-mkdtemp-shipped-report` → `VERDICT clean exit 0` before each push. - Body gate: `node scripts/check-closing-keyword-parity.mjs --body` binds exactly one declaration, this card's, on the line under the header. </details> Tier H: `scripts/pm/dispatch-gates.mjs` is a governed guard instrument, so this lands only on the maintainer's approval. `skip-changeset`: `scripts/pm/**` publishes nothing. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…g last (re-land) (objectstack-ai#36465) <!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} --> _Requested by **Steedos** · [project thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbCxiFE11rsKwyNffJZKYqJs)_ Fixes objectstack-ai#35079 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户能看到什么变化:命令行用户运行「安装技能」或「更新技能」时,若中途写盘失败(磁盘满、无权限、被中断),原有技能和安装记录保持原样,下次直接再运行更新即可,不再需要加强制参数。 - 为什么做:这是技能安装可靠性修复的重新合入;上次合入后因车队门禁读不懂暂存目录而被撤回,门禁那一侧已按你「扫描只管仓内运行的代码」的裁决改好。 - 出错会怎样:最坏是安装或更新在失败时留下一个隐藏的暂存目录,它不会被当成技能读取,下次写入时自动删除;可直接撤回本改动。 - 要你做什么:无。 ## What changes This re-lands the staged swap of PR objectstack-ai#35495 (merge commit `578d3b1d66`), byte for byte. PR objectstack-ai#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 objectstack-ai#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`: objectstack-ai#35495's patch changeset for `@objectstack/cli`, unchanged. Proof of identity with objectstack-ai#35495: `git diff --cached` after `git cherry-pick -n 578d3b1` equals `git diff 578d3b1~1 578d3b1` (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 eb1f85d 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. <details><summary>The live slow case, from the full self-test log</summary> ```text ✓ 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. ``` </details> ## Acceptance notes - Gate-side unblock: the slow case's own logic also passed when called through the scan's exports at head `009ca680a2f` (`exposedScratchDirs({})` + `mkdtempCompleteness`): 3154 sites across 23442 tracked sources, 93 in-tree, exposed 0, unresolved 508, failing 0, reported 1 (`packages/cli/src/utils/skills-install-state.ts:246 (dir is not bound in this file)`). No `scripts/pm/**` file is touched. - Residual, unchanged from objectstack-ai#35495: a hard kill (SIGKILL, power loss, an unhandled SIGINT) inside the rename-only swap window can still leave mixed state. The failure path the card names, a throw the process survives, is handled. The hard-kill window is tracked as objectstack-ai#35502. - Ablation not re-run: the source and test are byte-identical to objectstack-ai#35495, whose red-before and ablation runs are on record in its os-dev-report (7008338749): 4 failed / 30 passed on the old source, 34 / 34 on the fix. ## Verification <details><summary>Derived gate families: 64 derived, 61 run, 3 NOT MEASURED, 0 unrun (head 009ca68)</summary> - `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. </details> `@objectstack/cli` publishes, so the patch changeset from objectstack-ai#35495 comes along unchanged. No `skip-changeset`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- signed: repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC --> Co-authored-by: Claude <noreply@anthropic.com>
Fixes #35079
Clause-②: no
Metadata-protocol: none
维护者速读
os skills install/update的写盘改为「先写进隐藏的暂存目录 → 逐个改名换入 → 最后改名落记录」,任何一步失败都按倒序撤回已做的改名。update必须加--force才能恢复。applySkillsWrite一处写路径;残留风险是进程被强杀(SIGKILL/断电)恰好落在纯改名的换入阶段,见 Acceptance notes。回滚即还原本 PR。packages/cli/src/utils/skills-install-state.ts的applySkillsWritetry/catch 与undoSwap;其次packages/cli/test/skills-commands.test.ts末尾的新 describe 与顶部的node:fs故障注入。pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2 test/skills-commands.test.ts,预期 34/34 通过(新增 4 例在修复前全红)。What changes
applySkillsWrite(packages/cli/src/utils/skills-install-state.ts) now writes in three phases, and the module header documents them:new/inside one staging directory created in the skills directory itself (SKILLS_STAGING_PREFIX=.objectstack-skills-staging-, viamkdtempSync). Same filesystem as the targets, so every later step is a rename.old/; each catalog skill's existing directory (recorded, or a conflictinstall --forceadopted) is renamed aside, then its staged copy renamed into place. Rename-aside rather than rename-over, because a directory cannot be renamed over a non-empty one (POSIXENOTEMPTY, Windows refuses outright)..objectstack-skills.json: a file rename over a file is atomic on POSIX and replaces on Windows.Any throw in 1–3 undoes the renames already done, newest first, removes the staging directory and rethrows; the command prints the failure and exits 1 as before. If an undo itself fails, the error says which steps could not be undone and where the previous copies are, and the staging directory is kept.
What "the old skills and the record stay usable" means here: all or nothing across the skills. A failure partway restores every skill, not only the one that failed, so the record never names a directory the failure removed nor one at a version it does not record. Per-skill would leave a mixed catalog under a record of one version, which
updatethen refuses as changed locally: the defect this card files.Leftovers. The staging directory is hidden.
skillDirectoriesalready skips names starting with a dot, andSKILL_NAMErequires a first letter or digit, so the plan,statusandinspectSkillsDirnever read it as a skill and no catalog skill can collide with it. Its contents sit one level deeper (new/NAME,old/NAME), so an agent loadingDIR/NAME/SKILL.mddoes not load them either. The next write removes any.objectstack-skills-staging-*directory a killed run left (removeStagingLeftovers). Removing the staging directory after a successful write is best effort: a failure there is left for the next write and never masks the write's outcome.All path judgments (
underRoot) still happen before the first write, unchanged, and the record is computed before the first write too.Tests
The pin is a new top-level
describein the existing shared harnesspackages/cli/test/skills-commands.test.ts(the shared-harness rule). Failure injection: a hoistedvi.mock('node:fs')that passes everything through except the onewriteFileSync/renameSynccallfault.whenmatches, which throwsENOSPConce and disarms. Unarmed in every other test.it.eachover three failure points duringupdateV1 → V2: a file of the second skill is written; the second skill is moved into place; the record is written after every skill is in place. Each asserts exit 1, the fault fired exactly once, andENOSPCreaches the output. It then asserts V1 is intact (every file's bytes, record version,status --version V1 --check --jsonexit 0 with nothing missing, modified or extra, nothing hidden beside the record), and that a plainupdate --version V2with no--forcelands V2 with no leftovers.statusand is removed by the next plainupdate.Red before the fix: the new test commit 060bd8f, run against the unmodified source. Ablation after the fix: source restored to the base 6d833b5 with the fix committed, then put back with
git checkout HEAD, the blob hash checked against HEAD,git diff HEADempty.Red before (060bd8f, unmodified source) and ablation (b555879, source restored to 6d833b5): 4 failed | 30 passed (34), both runs
In the first and third cases the old code had already rewritten
objectstack-dataat V2 under the V1 record, which is exactly the stateupdaterefuses without--force. The fourth case's red on the old source comes from the missingSKILLS_STAGING_PREFIXexport, which makes the leftover's name visible: it shows that the export is needed, not that the old code mishandled a hidden leftover.Ablation restore proof:
git checkout HEAD -- packages/cli/src/utils/skills-install-state.ts, thengit hash-object= 36b9524f2415589b0e054b61ae8ebe514ef4869e = the HEAD blob,git diff HEAD0 lines,git status --porcelainempty.Acceptance notes
updaterefuses those as changed locally. Closing it needs a journal that is read and replayed before the plan is computed, inrunSkillsWrite(packages/cli/src/utils/skills-command.ts). That is outside this card's file surface, so it is noted, not built. A kill during the staging phase, which is where nearly all the time goes, leaves the old catalog untouched, and the next write removes the leftover. carrier: none.vi.mock('node:fs')in the shared harness, a pure pass-through while unarmed. No production seam was added for it.Verification
All readings are on head b555879. The base is 6d833b5, and the 91 files
origin/mainhas moved since then touch no skills file.Tests: the pin file 34/34; the cli unit tier 430 files / 6150 tests, all green
The
integrationtier was not run locally. CI runs it: this diff touches no integration-tier file and no spawn entry.Gates: 64 derived by dispatch-gates.mjs; 61 exit 0, 3 NOT MEASURED (exit 3, prerequisite not met)
CI covers all three, in Lint and Repo Gates.
Generated by Claude Code