FACTUAL ACTIVITY RECORD · An activity record based on work that took place
Creating a safe cleanup path for cancelled work
Confirming external cancellation first, then exclusively cleaning only the fixed local target
Purpose
When a workstream is cancelled without adoption, discarding local changes first can erase its rationale and candidate result if closing the external records then fails.
A fail-closed cleanup path was needed that fixed the target and cancellation reason, confirmed external closure, and only then cleaned the explicitly approved local scope.
Implementation
The cancellation helper runs only when one approval fixes the work area, work record, change proposal, work scope, baseline state, and cancellation reason. Preflight cross-checks a single worktree, the relationship between targets, and the current reference position; ambiguity or mismatch stops without mutation.
The order was fixed so the external change proposal ends as not adopted, the work record receives an exact cancellation record with a reason digest, and both closed states are retrieved and verified before local cleanup begins. A retry of an already closed target succeeds only when the same target and exact reason record are present.
Immediately before local cleanup, the helper reacquires the target, current position, HEAD, work reference, and worktree layout and compares them with the preflight snapshot. If external processing coincided with a switch to other work, a changed reference, or use by another worktree, it stops without altering local files.
- Every canonical Git writer and cleanup operation atomically acquires the same scope-local lock and holds it through completion.
- Recheck that the index and working tree remain clean after external closure, after retrieval updates, and immediately before restoring the default state.
- Limit untracked cleanup to paths enumerated by Git, without deleting remote work references, forcing changes, or performing broad recursive cleanup.
- Do not fall back to raw commands or another helper; return a reasoned blocker on failure.
A test-only execution path that returned expected strings was replaced with a fixture backend running through the production control flow. Tests reproduce target races, missing or different reasons, mid-operation work switches, linked worktrees, a default state becoming dirty, and lock contention with writers, confirming that destructive cleanup is not reached.
15. CEOがmergeしない作業系統の打ち切りを現スレッドで明示承認した場合だけ、Makoがapproved cancellation helperでrepository / Issue / PR / Story branch / `main` / 中止理由を固定し、外部close成功確認後に限定local cleanupを行う。role agentは実行せず、raw Git / `gh`や別helperへfallbackしないRendering diagram…
What was confirmed
Verification results
The applied order prevented local discard before external closure was confirmed and required an exact matching cancellation record for retries.
Changes to the target during external processing, a dirty default state, another worktree, or a concurrent writer stopped while preserving changes outside the approved scope.
The production-flow fixtures, existing safe dry run, command and path policies, configuration and hook parsing, Skill validation, and diff check passed.
At the cutoff, the cancellation helper and shared exclusion protocol had been applied to the target. Processing a real cancellation with this helper and deleting remote work references were outside this Activity.
Basis for completion
The work was complete when target and reason fixation, external-first ordering, local revalidation, the shared lock, bounded cleanup, and no-fallback behavior passed production-flow fixtures, and the helper and related operating contract were applied to the target.