Repository navigation
fix(bin): preserve hold reasons and reject invalid completion inventories - #6331
kunchenguid merged 7 commits into
Conversation
…mplete hold now stores a reason with parentheses, line breaks, or percent signs through a reversible percent encoding that every reader decodes, instead of refusing it. hold --origin records the origin on the held task, and complete refuses the origin as its own inventory entry and an entry held for a different origin; holds with no recorded origin are accepted and flagged.
|
| sub decode_reason { | ||
| my ($value) = @_; | ||
| return $value unless defined($value) && $value =~ s/^fm-hold-v1://; | ||
| return decode("UTF-8", decode_base64($value), FB_CROAK); |
There was a problem hiding this comment.
Historical reasons can break reads
An older, literal hold reason beginning with fm-hold-v1: is treated as encoded data even if this encoder never wrote it. For example, fm-hold-v1:bm9ydGg= displays as north; if the suffix decodes to invalid UTF-8, public task reads fail and the fleet snapshot can fail to load.
…us origin, and invalid base64/UTF-8 reasons remain verbatim. Added regressions and documented valid-literal ambiguity. Both failures were reproduced before fixes. Verification: 54 lifecycle tests and 9 wrapper tests passed; 7 Beads-specific cases skipped because tasks-axi is markdown-only. Focused lint and diff checks passed. No pipeline or publication actions performed
|
Speaking as Kun's firstmate: Verdict: Tip vs main 8f756bb reviewed. Body links #5712 but has no Closes #5712 / no GitHub closing reference — does NOT close an issue (add a closing keyword if that is the intent). Tip encodes hold reasons, records Captain hold origin, refuses self-inventory/wrong-origin on complete, restores previous origin on failed backend re-hold — restore matching ready-for-pr #5712. |
|
Reply to the review comment "Historical reasons can break reads" on A stored reason that starts with The remaining case, an older literal reason that happens to be a valid encoding such as |
|
Speaking as Kun's firstmate: Verdict: Tip vs main VISION.md (each rule): all align — authority via recorded origin; scripts own hold/complete mechanics; no new default-on captain surface. Greptile: P1 failed-re-hold thread resolved on tip. Historical-reason thread outdated; tip returns invalid base64/UTF-8 payloads verbatim (covered by tests); documented residual for hand-typed valid Attestation: MATCH. CI/NM: SUCCESS CLEAN. mergeable: MERGEABLE. Merging squash now. Firstmate flag: no. Security tip: none. |
|
Speaking as Kun's firstmate: this is merged. Thank you @mremond — really appreciate you taking the time on this. |
Intent
Launch upstream ready-for-pr issue #5712 as its own ship from current origin/main, through the usual upstream contribution path; the maintainer merges. Keep it scoped to its issue.
Substance of the issue and the maintainer's triage (contract-class restore):
bin/fm-captain-hold.sh hold --reasonrefuses any reason containing parentheses with "reason must not contain parentheses (tasks-axi hold contract)" and names no remedy, although parentheses are ordinary prose in a decision reason. Separately,bin/fm-captain-hold.sh complete <origin> <origin>accepts the origin task as its own captain-call inventory whenever the origin row looks durable, so a refused hold immediately before it (for example in a chain with pipefail off) goes unnoticed and the completion gate looks satisfied with no hold recorded. The maintainer left the issue open for a PR along the issue author's refined fix:holdstores the origin it was recorded for on the held task;completerefuses an inventory entry equal to the origin, and refuses an entry whose stored origin differs from the origin being completed, with older records that carry no stored origin falling back to the current check and flagged in the output; reason text is encoded where tasks-axi stores it instead of banning characters, so a reason containing parentheses, semicolons, quotes and a newline is stored and read back unchanged. Tests: a failed hold followed bycomplete <o> <o>exits non-zero; an entry held for a different origin is refused; a reason containing ( ) ; " and a newline round-trips unchanged. An optionalhold --completethat records hold and completion in one locked step is welcome but not required.What Changed
--originbefore applying a hold; makecompleteandverifyreject self-references and mismatched origins using backend identities, while completion flags legacy entries without recorded origins.Risk Assessment
✅ Low: The changes are bounded and follow the latest recorded decisions; the full static review identified no additional material defects.
Testing
Baseline defects reproduced; all targeted live Markdown CLI scenarios passed with tasks-axi 0.2.6. Corrected driver setup errors were re-tested. CLI transcripts and persisted output were captured; labs were removed. No full suite, linters, publication or CI phases were run.
Evidence: Live CLI transcripts
Source: Live CLI transcripts
Evidence: Fleet output with decoded reasons
Source: Fleet output with decoded reasons
Evidence: Validation results and cleanup record
Source: Validation results and cleanup record
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 5 issues found → auto-fixed (4) ✅
bin/fm-captain-hold.sh:956- A failed re-hold can certify the wrong origin. Hold task h for A, release it with a recorded answer, then re-hold h for B. This writes B before the backend hold succeeds; if that operation fails, complete B h accepts A's old answer with B's new association. Publish the association only with a successfully established hold. Related sites: bin/fm-captain-hold.sh:831 (origin write), :959 and :962 (fallible hold operations), :862 (durability/origin check), :1727 and :1794 (complete/verify consumers).bin/fm-captain-hold.sh:894- The required reason text must be “stored and read back unchanged,” but the diff passes --reason "$stored_reason" to tasks-axi while the routine public reader, bin/fm-tasks-axi.sh:140, still directly executes tasks-axi. Holding with reason '(north)\nNext' therefore exposes '%28north%29%0ANext' through show/list. Restore decoding at the shared public read boundary. Related changed sites: bin/fm-captain-hold.sh:959 and :962 (both writers), docs/captain-hold-lifecycle.md:67 (decoding promise), tests/fm-captain-hold-lifecycle.test.sh:4252 (round-trip assertion covers only fleet JSON).bin/fm-hold-reason-lib.sh:47- The blanket decoder changes text that this encoder never wrote. A task titled 'Investigate literal %28' becomes 'Investigate literal (' in startup output; an older hold containing a URL with %28 likewise changes in fleet JSON. No intent requirement calls for interpreting unrelated fields or legacy plain text as encoded reasons. Remove that blanket acceptance and restrict decoding to identifiable encoded reason fields. Related sites: bin/fm-session-start.sh:555 (entire listing), bin/fm-afk-return.sh:597 (entire rows), bin/fm-fleet-snapshot.sh:432 (all historical reasons), bin/fm-hold-reason-lib.sh:35 (parallel decoder).bin/fm-captain-hold.sh:849- The advertised recovery does not work for existing self-inventories. Before this change, complete o o persisted decision_keys=o. After upgrading, creating separate task c and following this message with complete o c still unions o into the inventory and refuses forever; --none also retains it. Distinguish this historical-record case and provide workable repair instructions while preserving self-inventory rejection. Related sites: bin/fm-captain-hold.sh:859 (resolved identity check), :1727 (verification of the union), :1794 (verify also blocks cleanup).bin/fm-hold-reason-lib.sh:33- Simplification: fm_hold_reason_decode has no callers. Production readers independently implement decoding in the stream filter and fleet jq expression, so this adds an unused parallel definition without satisfying an additional intent requirement. Remove the unused function from the final implementation.🔧 Fix applied.
5 issues (3 errors, 2 warnings) still open:
bin/fm-captain-hold.sh:956- A failed re-hold can certify the wrong origin. Hold task h for A, release it with a recorded answer, then re-hold h for B. This writes B before the backend hold succeeds; if that operation fails, complete B h accepts A's old answer with B's new association. Publish the association only with a successfully established hold. Related sites: bin/fm-captain-hold.sh:831 (origin write), :959 and :962 (fallible hold operations), :862 (durability/origin check), :1727 and :1794 (complete/verify consumers).bin/fm-captain-hold.sh:894- The required reason text must be “stored and read back unchanged,” but the diff passes --reason "$stored_reason" to tasks-axi while the routine public reader, bin/fm-tasks-axi.sh:140, still directly executes tasks-axi. Holding with reason '(north)\nNext' therefore exposes '%28north%29%0ANext' through show/list. Restore decoding at the shared public read boundary. Related changed sites: bin/fm-captain-hold.sh:959 and :962 (both writers), docs/captain-hold-lifecycle.md:67 (decoding promise), tests/fm-captain-hold-lifecycle.test.sh:4252 (round-trip assertion covers only fleet JSON).bin/fm-captain-hold.sh:849- The advertised recovery does not work for existing self-inventories. Before this change, complete o o persisted decision_keys=o. After upgrading, creating separate task c and following this message with complete o c still unions o into the inventory and refuses forever; --none also retains it. Distinguish this historical-record case and provide workable repair instructions while preserving self-inventory rejection. Related sites: bin/fm-captain-hold.sh:859 (resolved identity check), :1727 (verification of the union), :1794 (verify also blocks cleanup).bin/fm-captain-hold.sh:859- Self-inventory remains reachable through supported Beads aliases. With captain-held origin fm-o and no recorded origin,complete fm-o osucceeds: resolve_entry returns the requested spellingoeven when tasks-axi resolves it to fm-o. Both comparisons miss the identical row, and verify also accepts it. Compare backend-returned identities at verify_entry_durable. Related sites: bin/fm-captain-hold.sh:848 (initial comparison), :857 (requested identity), :865 (stored-origin comparison can also falsely reject equivalent spellings), :956 (origin storage), :1727 (complete), and :1794 (verify).tests/fm-captain-hold-lifecycle.test.sh:4361- Simplification: the Round 1 fixer introduced FM_TEST_ONLY, a new command-dispatch and early-exit mode. Neither issue fm-captain-hold: parentheses in --reason are refused without a remedy, and complete accepts the origin as its own inventory #5712 nor the approved R2/R3/R5 fixes require another test-selection option; the normal suite already invokes the regressions. Remove this added dispatch block to keep the fix round within the requested scope.🔧 Fix applied.
3 issues (2 errors, 1 warning) still open:
bin/fm-captain-hold.sh:956- A failed re-hold can certify the wrong origin. Hold task h for A, release it with a recorded answer, then re-hold h for B. This writes B before the backend hold succeeds; if that operation fails, complete B h accepts A's old answer with B's new association. Publish the association only with a successfully established hold. Related sites: bin/fm-captain-hold.sh:831 (origin write), :959 and :962 (fallible hold operations), :862 (durability/origin check), :1727 and :1794 (complete/verify consumers).bin/fm-captain-hold.sh:849- The advertised recovery does not work for existing self-inventories. Before this change, complete o o persisted decision_keys=o. After upgrading, creating separate task c and following this message with complete o c still unions o into the inventory and refuses forever; --none also retains it. Distinguish this historical-record case and provide workable repair instructions while preserving self-inventory rejection. Related sites: bin/fm-captain-hold.sh:859 (resolved identity check), :1727 (verification of the union), :1794 (verify also blocks cleanup).bin/fm-captain-hold.sh:859- Self-inventory remains reachable through supported Beads aliases. With captain-held origin fm-o and no recorded origin,complete fm-o osucceeds: resolve_entry returns the requested spellingoeven when tasks-axi resolves it to fm-o. Both comparisons miss the identical row, and verify also accepts it. Compare backend-returned identities at verify_entry_durable. Related sites: bin/fm-captain-hold.sh:848 (initial comparison), :857 (requested identity), :865 (stored-origin comparison can also falsely reject equivalent spellings), :956 (origin storage), :1727 (complete), and :1794 (verify).🔧 Fix applied.
4 issues (3 errors, 1 warning) still open:
bin/fm-captain-hold.sh:956- A failed re-hold can certify the wrong origin. Hold task h for A, release it with a recorded answer, then re-hold h for B. This writes B before the backend hold succeeds; if that operation fails, complete B h accepts A's old answer with B's new association. Publish the association only with a successfully established hold. Related sites: bin/fm-captain-hold.sh:831 (origin write), :959 and :962 (fallible hold operations), :862 (durability/origin check), :1727 and :1794 (complete/verify consumers).bin/fm-captain-hold.sh:849- The advertised recovery does not work for existing self-inventories. Before this change, complete o o persisted decision_keys=o. After upgrading, creating separate task c and following this message with complete o c still unions o into the inventory and refuses forever; --none also retains it. Distinguish this historical-record case and provide workable repair instructions while preserving self-inventory rejection. Related sites: bin/fm-captain-hold.sh:859 (resolved identity check), :1727 (verification of the union), :1794 (verify also blocks cleanup).bin/fm-captain-hold.sh:859- Self-inventory remains reachable through supported Beads aliases. With captain-held origin fm-o and no recorded origin,complete fm-o osucceeds: resolve_entry returns the requested spellingoeven when tasks-axi resolves it to fm-o. Both comparisons miss the identical row, and verify also accepts it. Compare backend-returned identities at verify_entry_durable. Related sites: bin/fm-captain-hold.sh:848 (initial comparison), :857 (requested identity), :865 (stored-origin comparison can also falsely reject equivalent spellings), :956 (origin storage), :1727 (complete), and :1794 (verify).bin/fm-captain-hold.sh:997- Round 3 moved R1's partial-write defect. For a newhold h --origin B, the backend hold can succeed and the subsequent origin lookup or body update fail. The remaining captain-held row has no recorded origin, socomplete A haccepts it through the legacy fallback despite A being unrelated. Re-holds can similarly retain a stale association. Related sites: bin/fm-captain-hold.sh:983 and bin/fm-captain-hold.sh:986 (hold writes), bin/fm-captain-hold.sh:825 and bin/fm-captain-hold.sh:843 (subsequent failures), bin/fm-captain-hold.sh:882 and bin/fm-captain-hold.sh:888 (origin checks), bin/fm-captain-hold.sh:1754 and bin/fm-captain-hold.sh:1821 (complete/verify consumers). Make incomplete origin-bearing holds distinguishable and reject them at verify_entry_durable until finalized. The remedy needs approval because reliably distinguishing interrupted writes requires durable transition state or an atomic storage change.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
python3 ~/.no-mistakes/evidence/01M3W33QQYV7FCM041WC2819ZB/live-validation.py, with targeted reruns after correcting driver setup.git archive 8f756bbc287c5bdfacc64a7cc09e8516c64fc919 bin .tasks.toml: executed the baseline commands and reproduced both original defects.Realfm-captain-hold.sh hold,answer,completeandverify, including process-localRLIMIT_FSIZEfailure injection.Realfm-tasks-axi.sh show/view/list,fm-fleet-snapshot.sh --json,fm-session-start.shandfm-afk-return.sh checkagainst disposable Markdown backlogs.git status --porcelainand workspace-local lab cleanup verification.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Closes #5712