Skip to content

fix: retire former owners' records for reassigned worktree slots - #5502

Open
yasuhito wants to merge 3 commits into
kunchenguid:mainfrom
yasuhito:fm/firstmate-reassigned-slot-record-retirement-v1
Open

yasuhito wants to merge 3 commits into
kunchenguid:mainfrom
yasuhito:fm/firstmate-reassigned-slot-record-retirement-v1

Conversation

@yasuhito

Copy link
Copy Markdown
Contributor

Intent

firstmate の確認処理を修正とは、firstmate 自体にプルリクを出すという意味?
それは PR を出したほうがよさげ?
ok

ここでいう確認処理は、完了した Jev の3件の作業記録が同じローカルコピーを指しているため、Firstmate が後片付けを拒否している問題を指す。現在の所有者を確実に確認できるときに限り、以前の2件の記録だけをコピーに触れずに安全に閉じる限定修正を、テスト付きの Firstmate プルリクエストとして出す。マージと強制的な整理は含まない。

What Changed

  • Read the pool slot owner claim before checking for duplicate records. A task proven to be a former owner can retire its own endpoint and record without touching the shared worktree; the current owner must still have an exclusive record before returning the slot.
  • Treat conflicting repeated fields in a slot owner claim as unsafe and preserve the duplicate slot refusal during forced secondmate teardown.
  • Add regression coverage for three records sharing a slot and for claims that cannot prove ownership, and document the teardown rule.

Risk Assessment

✅ Low: The change is confined to claim-proven retirement of non-owner records, preserves duplicate-record refusal for the slot owner and forced secondmate teardown, and adds behavioral regression coverage.

Testing

Both targeted test files passed. A real named Herdr lab confirmed retirement of the two older records, preservation of the current owner's slot, refusal of overlapping and malformed ownership claims, and eventual clean owner teardown. The lab was torn down and no working-tree artifacts remained.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
An operator tears down two older records sharing the current owner's slot; each older pane and record closes while the owner's pane, claim, and copy remain intact ✅ pass live Real Herdr teardown transcript: RETIRED first-task and second-task
The current owner attempts teardown while other records still name its slot; teardown refuses without changing the owner's record or copy ✅ pass live Real Herdr teardown transcript: OWNER REFUSED
An operator attempts teardown with conflicting repeated task or home claim lines; teardown refuses and preserves the copy ✅ pass live Real Herdr teardown transcript: MALFORMED CLAIM REFUSED and MALFORMED HOME CLAIM REFUSED
After the older records close, the owner's dirty copy is protected; once clean, its exclusive record and slot claim retire ✅ pass live Real Herdr teardown transcript: DIRTY OWNER REFUSED and OWNER RETIRED
Evidence: Real Herdr teardown transcript

Source: Real Herdr teardown transcript

SPAWN first-task window=fm-lab-slot-retire-3634154-29210:w1:p2 worktree=~/.treehouse/project-88997c/1/project
SPAWN second-task window=fm-lab-slot-retire-3634154-29210:w1:p3 worktree=~/.treehouse/project-88997c/2/project
SPAWN owner-task window=fm-lab-slot-retire-3634154-29210:w1:p4 worktree=~/.treehouse/project-88997c/3/project
owner claim: task=owner-task
home=~/.no-mistakes/worktrees/38526edaf053/01M396JYGJ7H48NY4XYTA4A3PB/.slot-live.XJCXRj/home
OWNER REFUSED: REFUSED: task owner-task's recorded worktree ~/.treehouse/project-88997c/3/project is also task first-task's recorded worktree.
RETIRED first-task pane w1:p2; owner pane w1:p4 and copy intact; warning: task first-task's recorded worktree ~/.treehouse/project-88997c/3/project was reassigned to task owner-task (home ~/.no-mistakes/worktrees/38526edaf053/01M396JYGJ7H48NY4XYTA4A3PB/.slot-live.XJCXRj/home), which claimed that pool slot after this record was written; that slot is no longer first-task's, so its processes, copy, and claim are left untouched and only first-task's own cleanup runs.
RETIRED second-task pane w1:p3; owner pane w1:p4 and copy intact; warning: task second-task's recorded worktree ~/.treehouse/project-88997c/3/project was reassigned to task owner-task (home ~/.no-mistakes/worktrees/38526edaf053/01M396JYGJ7H48NY4XYTA4A3PB/.slot-live.XJCXRj/home), which claimed that pool slot after this record was written; that slot is no longer second-task's, so its processes, copy, and claim are left untouched and only second-task's own cleanup runs.
DIRTY OWNER REFUSED: REFUSED: worktree ~/.treehouse/project-88997c/3/project has uncommitted changes.
MALFORMED CLAIM REFUSED: REFUSED: task owner-task's recorded worktree ~/.treehouse/project-88997c/3/project carries a slot-owner claim that cannot be read, so the slot cannot be proved to still be this task's; nothing was changed - not even with --force.
MALFORMED HOME CLAIM REFUSED: REFUSED: task owner-task's recorded worktree ~/.treehouse/project-88997c/3/project carries a slot-owner claim that cannot be read, so the slot cannot be proved to still be this task's; nothing was changed - not even with --force.
OWNER RETIRED after exclusive clean slot

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • 🚨 bin/fm-wake-lib.sh:1343 - A claim containing task= followed by task=owner-task is accepted because an empty value also means “not seen.” For a shared slot, teardown of an earlier record then treats that malformed claim as proof of reassignment and retires the record. Track whether task= has appeared separately from its value and refuse inconsistent repeats. The same empty-value guard affects home= at bin/fm-wake-lib.sh:1347.
  • ⚠️ bin/fm-teardown.sh:2894 - The intent says “マージと強制的な整理は含まない” (forced cleanup is excluded). This changed branch also lets forced secondmate teardown proceed past duplicate descendant slot records when a claim names another owner. Normal teardown of the two earlier records does not need that extension. Remove the forced-path change unless its behavior is separately authorized.

🔧 Fix applied.
✅ Re-checked - no issues remain.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
An operator tears down two older records sharing the current owner's slot; each older pane and record closes while the owner's pane, claim, and copy remain intact ✅ pass live Real Herdr teardown transcript: RETIRED first-task and second-task
The current owner attempts teardown while other records still name its slot; teardown refuses without changing the owner's record or copy ✅ pass live Real Herdr teardown transcript: OWNER REFUSED
An operator attempts teardown with conflicting repeated task or home claim lines; teardown refuses and preserves the copy ✅ pass live Real Herdr teardown transcript: MALFORMED CLAIM REFUSED and MALFORMED HOME CLAIM REFUSED
After the older records close, the owner's dirty copy is protected; once clean, its exclusive record and slot claim retire ✅ pass live Real Herdr teardown transcript: DIRTY OWNER REFUSED and OWNER RETIRED
  • bash tests/fm-teardown-endpoint-safety.test.sh
  • bash tests/fm-secondmate-safety.test.sh
  • live-slot-check.sh against a named Herdr lab through bin/fm-herdr-lab.sh, with real spawn and teardown commands
  • git status --short and a transient-artifact check after lab teardown
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

…e owner

Teardown ran its record-exclusivity scan before reading the slot's owner
claim, so when a pool slot was handed on while earlier records stayed open,
every record refused - including the ones the claim already proved were not
the owner, whose teardown takes no step on the slot at all. Read the claim
first and run the scan only for a teardown the claim does not prove
reassigned; the owner's destructive return still needs an exclusive record.
A claim whose repeated task= or home= lines disagree now reads as unsafe and
refuses instead of letting the last line decide.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant