Skip to content

🤖 fix: fence removal of legacy id-less workspace rows across backends - #4919

Merged
ThomasK33 merged 1 commit into
mainfrom
fix/legacy-row-removal-fence
Sep 27, 2026
Merged

ThomasK33 merged 1 commit into
mainfrom
fix/legacy-row-removal-fence

Conversation

@ThomasK33

Copy link
Copy Markdown
Member

Summary

The cross-process removal fence (#4776/#4908) now covers upgraded workspaces whose config row has no id yet. A removal persists the legacy row's id before it claims its pendingRemoval marker. A task creation whose parent resolved only through session metadata finds that row again by its stable identity (config project key + workspace path) inside its config commit. If the row is gone or marked, the commit refuses.

Fixes #4914

Background

Every step of the fence found the row by id: claimPendingRemoval wrote no marker when findWorkspaceEntry missed, Config.removeWorkspace did not deregister the row, and assertParentAdmitsChild could not see a marker or the row's absence (#4908 exempted id-less parents so that creation under them kept working). So another backend could create a child under such a workspace while it was being removed, or after it was removed.

Implementation

  • Removal (WorkspaceService.removeUnlocked, after the mutation gate and before the marker claim): if the row is not found by id but Config.findWorkspace resolves it (a legacy row), it calls Config.getWorkspaceMetadataById, which persists the read-time id migration that workspace listing already persists. Then the claim, the release and the deregistration find the row by id as usual. If the row still has no id (the best-effort migration write failed), the removal refuses before any effect: it could not be fenced. This is the fail-closed choice.
  • Task creation (createMany plans and both create commits): when the parent row has no id in the preparation snapshot, the plan records LegacyParentRow from Config.findWorkspace. assertParentAdmitsChild falls back to the id-less row at that path and requires a row by id or by path, so a removed legacy parent refuses the child the same way a removed parent with an id does. A parent that resolves nowhere (e.g. the existing "no config row by id" test that fakes a parent id) keeps today's behavior.

Scope stayed small (3 files); no new persisted fields: LegacyParentRow is an in-memory plan field.

Validation

New tests in workspaceService.pendingRemoval.test.ts (two backends, real service stacks, a real id-less row with its id in sessions/<basename>/metadata.json) fail on origin/main and pass with this change:

(fail) workspace removal across two backends on one root > a removal marks a legacy id-less row, so the other backend refuses a child under it
(fail) workspace removal across two backends on one root > a batch creation under a legacy id-less parent refuses once the other backend removed it
Expected to contain: "removed"
Received: "created"

Each production hunk has its own red test: without the removal change the first test fails (no marker on the row), and without the task-creation change the second fails (the batch commits under the removed parent). A third test checks that a batch creation under a live legacy parent still commits.

Risks

Low. The new paths run only for rows without an id, which the read-time migration normally fixes at the first workspace listing. The removal of such a row now performs that migration write first, and refuses if the write fails.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-27T22:15:38.111966Z 27c7d5e PR opened
🔒 Security Review ✅ Completed 2026-09-27T22:16:16.005532Z 27c7d5e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 27c7d5e654

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/node/services/workspaceService.ts Resolved
Comment thread src/node/services/taskService.ts Resolved
@ThomasK33

Copy link
Copy Markdown
Member Author

Readiness (final head 27c7d5e654bd55f04cdd5cbac303322e8eedee3e):

  • Merge rule (accepted by the coordinator): the latest security review on the head is clean; every normal-review finding is fixed, rejected with a reason, or deferred to a tracking issue; all threads are resolved; and the final check says ready.
  • Security review on this head: clean.
  • Normal review on this head: 2 findings, both rejected with reasons in the threads (the legacy alias loss happens on main at the first workspace listing, which persists the same migration; path reuse needs an older build on the same root, which is unsupported, 🤖 tests: finish cross-process lock hardening (holder in fileLock errors, macOS/Windows qualification, mixed versions) #4480). Both threads resolved.
  • Assessments used: 2 of 6 (the automatic runs on open).
  • Local: make static-check passed; workspaceService and taskService tests 1864 pass, 0 fail. The two new red tests failed on origin/main, and each production hunk has its own red test.
  • CI: required checks green on this head (Codex Comments re-run after the threads were resolved).
  • Final independent check (fresh clean-context sub-agent): ready with tracked follow-ups.

Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high • Cost: $8.57

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant