Skip to content

cli: os skills install/update writes are not atomic — a failure partway removes the recorded skill directories under the old record, so the next update needs --force (stage and rename) #35079

Description

@objectstack-fleet

triage#1 · hotlong · session_01Q4EjjMnyLqJdzuktEmRPXH

Filed by triage at the request of repo:objectstack#3 (area o3-G, mailbox #32588, 6966566615), from #34773 / PR #35060. It was a nit in that PR's L2, and not built there.

What happens

applySkillsWrite (packages/cli/src/utils/skills-install-state.ts) removes the recorded skill directories first, then writes the new ones, and writes the record last. If a write fails partway (disk full, permission, an interrupted run), the directories are already gone while the old record still names them. The next os skills update then needs --force, and a user who only connected an MCP client is left without skills until they find that flag.

Done when

  • The new directories are staged into a temporary sibling, swapped into place by rename, and the record is written after the swap.
  • A pin covers a failure injected mid-write: the old skills and the record stay usable, and a plain update recovers.

Grade: p2 · domain:cli. Theme: install, upgrade and uninstall reliability; it is the failure path of the p1 install command #34773. No customer is named, and it only bites on a partial failure. Routed to seat 4 under the p2 scope; seat 3 is winding down.

Blocked-by: #35611

Activity

  1. added
    priority:p2
    pm:queue
    finding
    domain:server
    on Nov 18, 2026
  2. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt

    Claim: PM loop round 2 · area b1-B (lease lease:b1-B) · 2026-11-19 · p2, dispatched to an os-dev subagent of this area thread (seat release of the slot freed by PR #35377 entering the merge queue)
    Session: session_01L6bhgTyMahdAdhXSzgy2nt
    Account: os-sales
    Branch: claude/issue-35079-skills-write-staged-swap
    Worktree: objectstack-issue-35079
    Domain: domain:server
    Seat: repo:objectstack#1 (area b1-B)
    File surface: packages/cli/src/utils/skills-install-state.ts (applySkillsWrite and helpers it needs), its tests (a new test file named for this card, or the existing skills-install-state test if a shared harness rule applies), one changeset. Stop on breach.
    Container & model: S, mode:subagent, model: default (opus) — dispatch-gates --tier: no path-derived mandate; failure-path design (stage, rename, recovery) is a judgment call, effort: medium
    Clause-②: no
    Metadata-protocol: none
    Responsibility: objectstack packages/cli skills-install-state.ts:201 applySkillsWrite (read at origin/main 20badaea) | none | any user of os skills install / update whose write fails partway (disk full, permission, interrupted run); read from the code, no customer report
    Thread-read: none
    Premise: holds — at origin/main 20badaea applySkillsWrite removes dropped and recorded skill roots (rmSync) before writing the new files, and writes the record last; a failure between leaves the old record naming removed directories
    Pre-claim lane: packages/cli/** is area b1-B of repo:objectstack#1; no other lane's path.
    Pre-claim deps: none named; no open PR references #35079 (search, 2026-11-19 10:4xZ); last change to the file on main c527401 is unrelated (release docs); overlap-check runs before each push.
    Prior rulings read: skills,install,update,writes,atomic,failure,partway,removes,recorded,skill,directories,record (+4 more) → 274 hits; ADR-0150 D9, ADR-0019 D4, ADR-0027 Decision §11, ADR-0067 D2, ADR-0073 D3, ADR-0094 D2 (term-noise, none rules on the install write order); thread: none; repo: objectstack-ai/objectstack
    Serial constraints cleared: none (in-flight b1-B PR #35463 touches dev/start/serve/bind and a bench script, not skills files; #35377 touches doctor.ts)

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

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt
    os-dev-report

    {
      "issue": 35079,
      "status": "done",
      "branch": "claude/issue-35079-skills-write-staged-swap",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/35495",
      "session": "session_01L6bhgTyMahdAdhXSzgy2nt",
      "premise_still_valid": true,
      "summary": "Premise held at base 6d833b50. applySkillsWrite used rmSync on the dropped and recorded roots before writing and wrote the record last. The red-before arm reproduces it: after an injected ENOSPC, objectstack-data is at V2 under the V1 record. applySkillsWrite now (1) writes every new skill into new/ of one hidden staging directory (.objectstack-skills-staging-*, via mkdtempSync inside dir, so on the same filesystem); (2) per root, renames the old directory aside into old/ and the staged copy into place; (3) writes the record into the staging directory and renames it over the old record, after every swap. Any throw undoes the renames already done, newest first, so the outcome is all or nothing across skills. The next write removes leftover staging directories; they are hidden, so plan, status and inspect never read them as skills. Residual: a hard kill (SIGKILL, power loss or default SIGINT) inside the rename-only swap phase can still leave mixed state. Closing that needs a journal replayed in runSkillsWrite, outside the file surface. It is in the PR's Acceptance notes and was not filed.",
      "tests": "head b555879c. packages/cli/test/skills-commands.test.ts got a new top-level describe in the shared harness: 3 injected failure points (a staged file write, moving the second skill into place, the record rename) plus 1 leftover-staging case. Fault seam: a hoisted vi.mock('node:fs') pass-through. Red before the fix (test commit 060bd8fc on the unmodified source): 4 failed | 30 passed (34), VERDICT command-exit 1. Green: 34 passed (34), VERDICT command-exit 0. Ablation after the fix was committed: the source restored to 6d833b50 gave 4 failed | 30 passed, VERDICT command-exit 1. Restored with git checkout HEAD; hash-object 36b9524f = the HEAD blob, git diff HEAD 0 lines, status clean. No dist step: the test imports ../src directly. The leftover case's red on the old source comes from the missing SKILLS_STAGING_PREFIX export, as the PR states. cli unit tier, full: Test Files 430 passed (430), Tests 6150 passed (6150), VERDICT command-exit 0. cli build + typecheck (tsc --noEmit + check:test-typecheck OK, 28 errors / 6 signatures held): VERDICT command-exit 0. Integration tier declared to CI: no integration-tier file and no spawn entry in the diff.",
      "gates": "local, head b555879c: dispatch-gates.mjs --repo objectstack-ai/objectstack derived 64. Each was run with its exit code captured before any pipe. 61 exit 0: node scripts/check-adr-0087-registration.mjs --base origin/main; node scripts/check-adr-0087-registration.mjs --self-test; node scripts/check-changeset-no-major.mjs --base origin/main; node scripts/check-closing-keyword-parity.mjs; node scripts/check-closing-keyword-parity.mjs --self-test; node scripts/check-comment-mask-adoption.mjs; node scripts/check-comment-mask-adoption.mjs --self-test; node scripts/check-comment-mask-corpus.mjs; node scripts/check-dts-emitted.mjs --self-test; node scripts/check-empty-changeset.mjs --base origin/main; node scripts/check-empty-changeset.mjs --self-test; node scripts/check-issue-citations.mjs; node scripts/check-plugin-teardown-shape.mjs; node scripts/ci/assert-turbo-remote-cache.mjs --self-test; node scripts/ci/plan-test-core-shards.mjs --self-test; node scripts/ci/prune-turbo-cache.mjs --self-test; node scripts/ci/snapshot-next.mjs --self-test; node scripts/docs-audit/check-affected-docs.mjs; node scripts/docs-audit/check-drift-comment.mjs; node scripts/pm/check-governed-queue-guard.mjs --self-test; node scripts/pm/release-rehearsal-clone.mjs --self-test; node scripts/release-pending-publish.mjs --self-test; pnpm --filter @objectstack/spec run check:duration-unit-keys; pnpm check:adr-anchors; pnpm check:changeset-gate-self-tests; pnpm check:ci-filter-parity; pnpm check:cli-test-child-env; pnpm check:closed-ceremony-text; pnpm check:cross-package-test-inputs; pnpm check:doc-authoring; pnpm check:driver-memory-census; pnpm check:dts-closure; pnpm check:engine-double-contract; pnpm check:gitlink-declared; pnpm check:i18n; pnpm check:i18n-walk-parity; pnpm check:issue-citations; pnpm check:keyed-text-bounds; pnpm check:lean-entry-closure; pnpm check:logger-receiver-detach; pnpm check:nul-bytes; pnpm check:objectql-double-limit; pnpm check:org-identifier; pnpm check:page-declaration-shape; pnpm check:platform-object-tenancy-census; pnpm check:published-files; pnpm check:query-options-erasure; pnpm check:refd-timer-probe; pnpm check:registry-log-declared; pnpm check:rest-log-spy-declared; pnpm check:slot-lookup; pnpm check:sourcemap-no-sources-content; pnpm check:system-context-census; pnpm check:test-source-alias; pnpm check:tier-file-adoption; pnpm check:type-check-coverage; pnpm check:type-check-debt; pnpm check:undeclared-dep-imports; pnpm check:vouch-for-reference-callers; pnpm check:watch-hint-literal; pnpm check:where-matcher. 3 NOT MEASURED, exit 3 PREREQUISITE NOT MET: node scripts/check-plugin-teardown-shape.mjs --self-test (positive control commit unreachable in the shallow clone); pnpm check:dual-build-cjs-loads (14 packages outside the closure have no dist); pnpm check:i18n-coverage (examples/app-showcase: connector-slack has no build). --ran reconciliation: 64 derived, 61 run, 3 NOT-MEASURED, 0 UNRUN, exit 0. overlap-check: VERDICT clean exit 0. CI on PR #35495 head b555879c at report time: Check Changeset, Lint · *, Type Check · *, Governed Surface Queue Guard, Check PR Size and PR-body guards all in_progress. Queue verdict, Borrowed queue verdict, Schedule gate, Packed-tarball smoke and 18.x upgrade harness were completed/skipped. No conclusion read yet.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "3 — relay pr_create (fleet-write run 44518733834): POST /repos/objectstack-ai/objectstack/pulls (draft) + POST /repos/objectstack-ai/objectstack/issues/35495/assignees (os-sales); os-dev-report comment via post-stamped.mjs: POST /repos/objectstack-ai/objectstack/issues/35079/comments. Not REST: 3 git pushes.",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: none · noted, not filed. Residual hard-kill window in the swap phase; closing it needs a pre-plan journal replay in runSkillsWrite (packages/cli/src/utils/skills-command.ts), outside this card's file surface. Recorded in PR #35495 Acceptance notes."
      ],
      "files_changed": [
        ".changeset/35079-skills-write-staged-swap.md",
        "packages/cli/src/utils/skills-install-state.ts",
        "packages/cli/test/skills-commands.test.ts"
      ],
      "line_budget": "n/a — no skills/** path in the diff (+239 / -14 across 3 files)",
      "deviations": [
        "overlap-check.mjs was not run before the two code pushes (060bd8fc, b555879c). It ran once after them, before pr_create: VERDICT clean exit 0.",
        "origin/main was not merged before opening (AGENTS.md multi-agent §10). Base 6d833b50; origin/main has since moved 91 files, none under the skills files (only packages/cli doctor.ts and its test). overlap-check says it merges cleanly.",
        "3 derived gates NOT MEASURED (exit 3, prerequisite); CI covers them."
      ]
    }
  5. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt

    Delivered · 2026-11-19T13:06Z · PR #35495 merged; this card closed by its Fixes line. os skills install / update now stage new skills in a hidden sibling, swap them in by rename and rename the record last; any failure the process survives undoes the swaps, so the old skills and record stay usable and a plain update recovers without --force.

    State: pm:dispatched, finding and lease:b1-B removed. Left open elsewhere: a hard kill inside the rename window, filed as #35502.

  6. removed
    pm:dispatched
    finding
    on Nov 19, 2026
  7. objectstack-fleet commented on Nov 19, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#1 · os-sales · session_01L6bhgTyMahdAdhXSzgy2nt

    Reopened 2026-11-19T19:02Z. The fix PR #35495 was reverted by PR #35616 (merged ae2a67d, for p0 #35588): its staging mkdtempSync(join(dir, …)) base is resolved per caller cwd, and the dispatch-gates scratch-dir scan, which reads one file at a time, cannot resolve it, so the full Lint & Type Check run went red. The defect this card describes is back on main.

    Re-landing waits for the gate-side ruling on a caller-supplied base category, card #35611. The body now carries Blocked-by: #35611. When #35611 closes, the daily scan returns this card to pm:queue, and the next claim can re-land #35495's change unchanged or adapted to that ruling.

  8. added
    pm:blocked
    on Nov 19, 2026
  9. objectstack-fleet commented on Nov 22, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC

    Claim: PM loop round 4 (seat 1's card, now with seat 7; its blocker #35611 closed when PR #36368 merged)
    Session: session_01QsR2jTeURPvEm465RcoYEC
    Account: zhuangjianguo
    Branch: claude/issue-35079-skills-staged-swap-reland
    Worktree: objectstack-issue-35079
    Domain: domain:server
    Seat: repo:objectstack#7
    Area: f7-seat (seat 7's partition is being set with the maintainer; until it is, the seat claims card by card)
    File surface: packages/cli/src/utils/skills-install-state.ts, packages/cli/test/skills-commands.test.ts, one changeset: #35495's change (merge 578d3b1d66) re-landed as written or adapted to current main; ⛔ not scripts/pm/** (the gate side landed in #36368)
    Container & model: S, mode:subagent, model: default tier (dispatch-gates --tier: no path-derived mandate), effort: high (seat order)
    Clause-②: no — the staged swap changes no accepted input; it changes only what is left on disk after a failure partway through
    Metadata-protocol: none
    Responsibility: os skills install / update in @objectstack/cli (objectstack) | the reverted #35495 swap; the gate that refused it now reports a shipped-source unresolved mkdtempSync base instead of failing (#35611, PR #36368) | CLI users whose install or update fails partway, who then need --force
    Thread-read: 7019169205
    Premise: holds (the revert PR #35616 put the defect back; #36368's acceptance note measured #35495's diff as passing the slow case on that branch; the dev re-measures on current main)
    Serial constraints cleared: overlap-check before every push; no open PR touches packages/cli/src/utils/skills-install-state.ts (the dev confirms).
    Pre-claim lane: repo:objectstack seat 7 holds seat 1's cards after its clock-out, under the maintainer's 「交接给你的任务 p1 p2 都要做」 (2026-11-22T07:18Z, seat thread).
    Pre-claim deps: #35611 closed (PR #36368 merged as fb6eb801b2c).
    Prior rulings read: node scripts/pm/check-prior-rulings.mjs --card 35079 exit 0 at ff601499008; the gate ruling 7075362923 on #35611 says #35079's lane re-lands the #35495 swap as written.
    Resume-from: none (fresh from origin/main; #35495's diff is the starting point)

  10. added
    pm:dispatched
    and removed
    pm:blocked
    on Nov 22, 2026
  11. objectstack-fleet commented on Nov 22, 2026

    @objectstack-fleet
    ContributorAuthor

    repo:objectstack#7 · zhuangjianguo · session_01QsR2jTeURPvEm465RcoYEC
    os-dev-report

    {
      "issue": 35079,
      "status": "done",
      "branch": "claude/issue-35079-skills-staged-swap-reland",
      "pr": "https://github.com/objectstack-ai/objectstack/pull/36465",
      "head_sha": "009ca680a2f59e1a28a705897d37b3540effbd01",
      "session": "session_01QsR2jTeURPvEm465RcoYEC",
      "premise_still_valid": true,
      "summary": "Re-landed PR #35495's staged swap (merge 578d3b1d66) byte for byte onto origin/main ff601499008. Both target files on main were byte-equal to the merge's parent eb1f85d7f4, so nothing needed adapting: the diff of `git cherry-pick -n 578d3b1d66` equals `git diff 578d3b1d66~1 578d3b1d66`. applySkillsWrite again stages new skills in a hidden .objectstack-skills-staging-* directory, swaps each one in by rename, renames the record last, and undoes the swaps on any throw. The gate that forced revert #35616 now passes. On this head the slow case 'no mkdtempSync site in a test file or repo tooling takes a base the scan cannot read' passes and reports skills-install-state.ts:246 as shipped source, not failed. The PR's Lint & Repo Gates check is green. No scripts/pm/** edit; the test's base is already tmpdir().",
      "tests": "head 009ca680a2f. (1) Under the verify lock, after the cli^... closure build (VERDICT command-exit 0, held 405s): `pnpm --filter @objectstack/cli exec vitest run --project unit --maxWorkers=2 test/skills-commands.test.ts && pnpm --filter @objectstack/cli build` gave Test Files 1 passed (1), Tests 34 passed (34), VERDICT command-exit 0. That is 30 existing cases plus the 4 interrupted-write pins. (2) `node scripts/pm/dispatch-gates.mjs --self-test`, both tiers, exit 0: 'fast 2264 case(s) in 576.2s · slow 315 case(s) in 1879.5s', '✓ dispatch-gates self-test: 2579 cases pass.' The live line: '✓ 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)'. (3) The same logic through the scan's exports (exposedScratchDirs + mkdtempCompleteness): 3154 sites / 23442 sources, exposed 0, unresolved 508, failing 0, reported 1. NOT MEASURED locally, declared narrowing: the full cli unit tier and `pnpm --filter @objectstack/cli typecheck`. Nine lock attempts timed out (exit 99) behind other seats' batteries. CI's TypeScript Type Check is success; Test Core shards were 6/10 success with 4 in_progress at report time. The integration tier is declared to CI: no integration file or spawn entry in the diff. Ablation not re-run: the source and test are byte-identical to #35495, whose red-before and ablation runs are recorded in its report 7008338749.",
      "gates": "local, head 009ca680a2f: `dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 64 families. Each ran with its exit code captured before any pipe. Eight answered exit 3 before the build and were re-run after it; five went to 0. Final: 61 exit 0, 3 NOT MEASURED with exit 3 PREREQUISITE NOT MET. Those three are `pnpm check:dual-build-cjs-loads` (no dist for packages outside the closure), `pnpm check:i18n-coverage` (example configs outside the closure are not built) and `pnpm check:type-check-debt` (its re-measure build got no lock turn). `--ran` reconciliation, exit 0: '✓ dispatch-gates --ran: 64 derived famil(ies) accounted for — 61 run, 3 NOT-MEASURED (3 DERIVED from a recorded exit 3).' `dispatch-gates --tier`: no path-derived mandate, 253 changed lines. `overlap-check --branch=claude/issue-35079-skills-staged-swap-reland`: VERDICT clean exit 0 before the code push. `check-closing-keyword-parity --body`: only the Fixes #35079 line binds. CI on PR #36465 at report time, success: Lint & Repo Gates, every Lint · * lane (PM dispatch-gates, repo & tooling gates, docs & code guards, CI release & engine gates, ESLint, scoped x3), TypeScript Type Check, the four Type Check · * lanes including debt ledger, Build Core, Check Changeset, Check PR Size, Governed Surface Queue Guard, Dogfood Regression Gate, Live E2E UI, Test UI, PR-body guards, Test Core 4/7/8/9/10 of 10. In progress: Test Core 1, 2, 3, 5 and 6 of 10.",
      "dogfood_battery": "n/a — no `!` in the PR title and no (narrowing) arm",
      "mcp_calls": "0",
      "api_writes": "3 — relay pr_create (fleet-write run 45024295238): POST /repos/objectstack-ai/objectstack/pulls (draft) + POST /repos/objectstack-ai/objectstack/issues/36465/assignees (zhuangjianguo), body read back 8427/8427 bytes identical; os-dev-report comment via post-stamped.mjs: POST /repos/objectstack-ai/objectstack/issues/35079/comments. Not REST: 2 git pushes (the empty-branch probe and 009ca680a2f).",
      "writes": "relay 3 (pr_create = create + assignees, 1 comment); mcp 0",
      "open_questions": [],
      "security_findings": "none",
      "out_of_scope_findings": [
        "carrier: #35502 · noted, not filed. The residual hard-kill window inside the rename-only swap phase is unchanged from #35495 and already tracked there."
      ],
      "files_changed": [
        ".changeset/35079-skills-write-staged-swap.md",
        "packages/cli/src/utils/skills-install-state.ts",
        "packages/cli/test/skills-commands.test.ts"
      ],
      "line_budget": "n/a — no skills/** path in the diff (+239 / -14 across 3 files)",
      "deviations": [
        "Declared narrowing: the full cli unit tier and cli typecheck did not run locally. With slot issue-35079-dev, nine lock attempts returned queue-timeout exit 99 and two acquired the lock (the closure build, then the target test file + cli build). The holders were a dogfood battery (pid 13599, about 75 min) and then the 35711 seat's battery (pid 8048, more than 46 min). CI's TypeScript Type Check is green; Test Core was still running at report time.",
        "A stray 6-byte file /cli-full.pid (a pid number) sits at the container root. A backgrounded && chain scoped my path variable to its subshell. Deleting it was refused by the built-in safety check, so it is left for a human; it is harmless.",
        "The pnpm install log went to the scratchpad root (install-35079.log), not to issue-35079/.",
        "Commit trailer: the harness reminder asked for a Co-Authored-By naming the model. The commit carries AGENTS.md's model-free pair instead (Claude-Session + Co-authored-by: Claude)."
      ]
    }
  12. added a commit that references this issue on Nov 23, 2026
    6cf0dad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:builddomain:serverpm:dispatchedpriority:p2

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions