Repository navigation
fix: keep Discord threads marked until open decisions close - #322
Merged
Merged
Conversation
- An open decision post now owns the ❓ marker: a later reply's none or done is held in the thread record and applied when the last decision closes. - The decision sweep re-asserts ❓ on an eligible Firstmate thread with an open decision and no marker, under the existing best-effort and archived-thread rules. - A free-text question records a decision with no options (fm-ext-ask.sh --free-text, or a decision file with none), so the marker clears only when the answer reaches that decision's ledger. - docs/configuration.md Topic threads stays the single owner of the marker contract; the ext-respond skill states when Firstmate marks each state.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
An open decision post now owns the thread marker, and the periodic sweep repairs a missing marker without touching the thread's title.
Evidence
Before: a later
noneordonerenamed a thread that still had an open decision, and a state-less question could leave no marker at all.After: every changed suite passes on the PR head
af63aa0c.bash bin/fm-lint.shpasses on the branch (ShellCheck 0.11.0) andbash bin/fm-doc-audience-check.shreportsok surfaces=104 local_links=548.CI attribution. The PR's CI is red on runner-environment tests that fail identically on main
a037440c. Each candidate was run 3 times locally on both heads:af63aa0ca037440cfm-pi-watch-extension(serial 8 failure)fm-omp-secondmate(serial 9, running at cancel)fm-fleet-snapshot-view(macOS job, 17 assertions)fm-bearings-snapshot(macOS job, 47 assertions)CI logs show serial 8 failing only on this head (
Pi must deliver the actionable wake after bounded hung-successor recovery: expected exit 0, got 1), serial 9 cancelled whilefm-omp-secondmate.test.shwas running with no failing line, and the macOS job cancelled before any log existed. Serial 8 is the same watcher-wake-lock family as serial 2, which fails on main too. macOS Bash 3.2 itself is not reproducible on this Linux host, so that job stays unproven rather than failed.No green No-Mistakes attestation is claimed for this merge: run
01M7T5CB305E5WPR1SG355B847remains parked at its CI gate, so this lands as the captain-approved direct-PR-style merge. The## Pipelinesection below is kept verbatim as that run's status record, not as a green attestation.Reload after merge (AC5): the plugin runs inside the Hermes gateway, so restart its unit once. On this host only
hermes-gateway.serviceexists:A profile with its own unit restarts that unit instead (for example
hermes-gateway-fmcomms.service). Queued outbox payloads retry after the restart; new thread-record fields are optional, so an older plugin keeps working.Merge Danger
Door: two-way.
Thread renames are reversible REST PATCHes, and every new record field defaults to absent.
Blast Radius: dedicated-channel topic threads this home created only.
A captain-made thread, another channel, a DM, or a record without Firstmate provenance is never renamed. A failed rename is recorded and retried by the next reply; the sweep never unarchives a thread. Free-text decisions post plain text with no components, and their marker clears only when the answer reaches that decision's ledger.
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1444- R1 requires that the thread keep ❓ “while any decision post in the thread is open.” The new ledger check runs only for an explicit state. If adonerename fails and a state-less decision is posted before the sweep, that delivery retries the olddoneand can put ✅ on the open question. The retry at outbox_poster.py:1438, retitle-only path at :1465, and sweep retry at :1563 all bypass the check. The stale-sweep repair at :1385 can also restore a cacheddoneafter a concurrent post invalidates the snapshot. The explicit-state path at :1447 treats an unavailable ledger as zero open decisions. Enforce the decision override at the shared marker application boundary before these paths write a name, and distinguish an unavailable ledger from a confirmed empty result.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1538- R2 requires the sweep to reassert ❓ on an eligible thread that “has an open decision but no marker.” The newstate != "needs-you"condition checks the stored target. If the captain manually removes ❓ on Discord while a decision is open, the target still saysneeds-youand every sweep skips the repair. Use the live-name check already available inapply_thread_stateat outbox_poster.py:1346, while retaining the permanent-failure guard at :1562.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1446- R1 says “the requested state applies once the last open decision closes.” Post an open decision, send adonereply, then send aneeds-youreminder while the decision is still open. The newdeferred = ""assignment clears the pendingdonethrough outbox_poster.py:1378 and :976, so the sweep at :1554 makes the thread bare when the captain answers. Preserve the pending terminal state across a reminder that belongs to the same open decision. Test 35 at tests/fm-ext-topic-threads.test.sh:2247 stops after thedonereply and misses this sequence..agents/skills/ext-respond/SKILL.md:113- The intent requires updating the Topic threads contract “rather than restating it elsewhere.” The new open-decision rule in this skill duplicates the override and deferred-state contract in docs/configuration.md:1145–1151. The new text at .agents/skills/ext-respond/SKILL.md:69 and docs/configuration.md:1236 also repeats marker lifetime outside that owner section. Remove the duplicate marker rules and link to Topic threads. Keep the skill’s required guidance on when Firstmate marks each state and the Decision buttons section’s guidance on using free text.bin/fm-ext-ask.sh:269- The new zero-option guard can reject an ask after it has already created or refreshed a captain hold. For example,--free-textwith a pasted numbered choice and “Reply with the number” passes the wrapper’s validation, runsholdat bin/fm-ext-ask.sh:269, then fails at bin/fm-ext-emit.sh:391. That leaves a held call without a Discord question. Run the existing choice check on the assembled free-text body before creating the hold, and retain the emit check for direct decision-file callers.tests/fm-ext-topic-threads.test.sh:2372- The free-text test cannot verify the required absence of Discord buttons. Its sender stub at tests/fm-ext-topic-threads.test.sh:164 bypassesdiscord_sendand always omits the button receipt. The assertion here also queriesposts --settled-onlywhile the decision is open, so it can pass even if Discord received a Discuss button. Exercise the real sender with click routing available and a mocked Discord HTTP transport, then assert that the outbound message has no interactive components. R3 supplies the expected result, and removing the options check in outbox_poster.py:1829 should make the test fail.🔧 Fix applied.
8 issues (6 errors, 2 warnings) still open:
contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1444- R1 requires that the thread keep ❓ “while any decision post in the thread is open.” The new ledger check runs only for an explicit state. If adonerename fails and a state-less decision is posted before the sweep, that delivery retries the olddoneand can put ✅ on the open question. The retry at outbox_poster.py:1438, retitle-only path at :1465, and sweep retry at :1563 all bypass the check. The stale-sweep repair at :1385 can also restore a cacheddoneafter a concurrent post invalidates the snapshot. The explicit-state path at :1447 treats an unavailable ledger as zero open decisions. Enforce the decision override at the shared marker application boundary before these paths write a name, and distinguish an unavailable ledger from a confirmed empty result.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1538- R2 requires the sweep to reassert ❓ on an eligible thread that “has an open decision but no marker.” The newstate != "needs-you"condition checks the stored target. If the captain manually removes ❓ on Discord while a decision is open, the target still saysneeds-youand every sweep skips the repair. Use the live-name check already available inapply_thread_stateat outbox_poster.py:1346, while retaining the permanent-failure guard at :1562.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1446- R1 says “the requested state applies once the last open decision closes.” Post an open decision, send adonereply, then send aneeds-youreminder while the decision is still open. The newdeferred = ""assignment clears the pendingdonethrough outbox_poster.py:1378 and :976, so the sweep at :1554 makes the thread bare when the captain answers. Preserve the pending terminal state across a reminder that belongs to the same open decision. Test 35 at tests/fm-ext-topic-threads.test.sh:2247 stops after thedonereply and misses this sequence.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1352- R1 says “the requested state applies once the last open decision closes.” Round 1 addedif state != "needs-you": return "skipped"when the decision ledger is unavailable. With ❓ showing anddonealready deferred, a newernonesent during an outage is receipted and discarded. After the captain answers, the sweep applies the older ✅. The same guard drops an explicit retitle routed through outbox_poster.py:1479–1498. The receipt at outbox_poster.py:2491 prevents the reply from replaying, and tests/fm-ext-topic-threads.test.sh:2389–2396 expects the wrong ✅. Preserve the requested operation at the shared marker boundary while leaving the visible marker intact until the ledger is readable.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1367- R2 calls for reasserting ❓ on a thread that “has an open decision but no marker,” and the intent excludes retitle automation. Round 1 sends every eligible open thread through a full-name comparison. If the captain changes❓ Aceh · long chatsto❓ Aceh · compaction recap, the next sweep restores the old title even though ❓ is already present. The scheduling branch is at outbox_poster.py:1569–1582, and tests/fm-ext-topic-threads.test.sh:2337–2341 covers only the identical title and a removed marker. Narrow periodic reassertion to correcting the live marker, preserving the title and the existing explicit retitle retry.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1571- The intent requires keeping existing retitle behavior. Round 1 moved thestate == "needs-you"check inside one arm of the auto-clear condition, so stalemarked_opencan now clear a recorded ✅. With an open decision marked ❓, manually mark the thread ✅, answer the decision, and send a retitle-only reply before the sweep. The retitle reads and preserves ✅ at outbox_poster.py:1484–1498, retainsmarked_openthrough outbox_poster.py:1355–1357 and :974–975, then the sweep makes the thread bare. Keep auto-clear scoped to the decision-owned question marker. The same broadened condition breaks the newer-donecase in tests/fm-ext-bridge.test.sh:3649–3664. That test's one-argument ledger doubles at :3654 and :3755 also need to handle the new targeted calls at outbox_poster.py:1338.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1338- Round 1 puts a full retained-outbox read between routine replies in the serial delivery loop. Queue two ordinarynoneordonereplies. The first gets a receipt, then its targeted query builds the entire post table before filtering by thread at bin/fm-ext-decision.sh:852–858. The second waits at outbox_poster.py:2505–2520. Commit f680d28 documents the production delay that motivated separating delivery from reconciliation. The same path also scans all progress files under the shared lock at outbox_poster.py:1313, :1381, and :1403, so unrelated progress can invalidate a sweep or repeat the work. Bound the synchronous lookup and freshness checks to records that can affect the target thread, including newer replacements for its decision keys.bin/fm-ext-emit.sh:398- Round 1 moved the choice-text check before the hold, but the new buttonless path still has two late refusals that can leave a captain call held without a Discord question. An otherwise valid 90-character task ID produces a 101-byte Discuss ID and fails the unconditional button limit here, even though no Discuss button is sent. A task namedanswercan pass the wrapper's text check at bin/fm-ext-ask.sh:218, then its generated cue at :228 triggers the task-ID check in bin/fm-ext-emit.sh:402–404 after the hold at bin/fm-ext-ask.sh:271. Apply the component limit only to option posts and check the complete public body before creating or refreshing the hold.🔧 Fix applied.
16 issues (10 errors, 6 warnings) still open:
contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1444- R1 requires that the thread keep ❓ “while any decision post in the thread is open.” The new ledger check runs only for an explicit state. If adonerename fails and a state-less decision is posted before the sweep, that delivery retries the olddoneand can put ✅ on the open question. The retry at outbox_poster.py:1438, retitle-only path at :1465, and sweep retry at :1563 all bypass the check. The stale-sweep repair at :1385 can also restore a cacheddoneafter a concurrent post invalidates the snapshot. The explicit-state path at :1447 treats an unavailable ledger as zero open decisions. Enforce the decision override at the shared marker application boundary before these paths write a name, and distinguish an unavailable ledger from a confirmed empty result.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1538- R2 requires the sweep to reassert ❓ on an eligible thread that “has an open decision but no marker.” The newstate != "needs-you"condition checks the stored target. If the captain manually removes ❓ on Discord while a decision is open, the target still saysneeds-youand every sweep skips the repair. Use the live-name check already available inapply_thread_stateat outbox_poster.py:1346, while retaining the permanent-failure guard at :1562.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1446- R1 says “the requested state applies once the last open decision closes.” Post an open decision, send adonereply, then send aneeds-youreminder while the decision is still open. The newdeferred = ""assignment clears the pendingdonethrough outbox_poster.py:1378 and :976, so the sweep at :1554 makes the thread bare when the captain answers. Preserve the pending terminal state across a reminder that belongs to the same open decision. Test 35 at tests/fm-ext-topic-threads.test.sh:2247 stops after thedonereply and misses this sequence.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1352- R1 says “the requested state applies once the last open decision closes.” Round 1 addedif state != "needs-you": return "skipped"when the decision ledger is unavailable. With ❓ showing anddonealready deferred, a newernonesent during an outage is receipted and discarded. After the captain answers, the sweep applies the older ✅. The same guard drops an explicit retitle routed through outbox_poster.py:1479–1498. The receipt at outbox_poster.py:2491 prevents the reply from replaying, and tests/fm-ext-topic-threads.test.sh:2389–2396 expects the wrong ✅. Preserve the requested operation at the shared marker boundary while leaving the visible marker intact until the ledger is readable.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1367- R2 calls for reasserting ❓ on a thread that “has an open decision but no marker,” and the intent excludes retitle automation. Round 1 sends every eligible open thread through a full-name comparison. If the captain changes❓ Aceh · long chatsto❓ Aceh · compaction recap, the next sweep restores the old title even though ❓ is already present. The scheduling branch is at outbox_poster.py:1569–1582, and tests/fm-ext-topic-threads.test.sh:2337–2341 covers only the identical title and a removed marker. Narrow periodic reassertion to correcting the live marker, preserving the title and the existing explicit retitle retry.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1571- The intent requires keeping existing retitle behavior. Round 1 moved thestate == "needs-you"check inside one arm of the auto-clear condition, so stalemarked_opencan now clear a recorded ✅. With an open decision marked ❓, manually mark the thread ✅, answer the decision, and send a retitle-only reply before the sweep. The retitle reads and preserves ✅ at outbox_poster.py:1484–1498, retainsmarked_openthrough outbox_poster.py:1355–1357 and :974–975, then the sweep makes the thread bare. Keep auto-clear scoped to the decision-owned question marker. The same broadened condition breaks the newer-donecase in tests/fm-ext-bridge.test.sh:3649–3664. That test's one-argument ledger doubles at :3654 and :3755 also need to handle the new targeted calls at outbox_poster.py:1338.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1338- Round 1 puts a full retained-outbox read between routine replies in the serial delivery loop. Queue two ordinarynoneordonereplies. The first gets a receipt, then its targeted query builds the entire post table before filtering by thread at bin/fm-ext-decision.sh:852–858. The second waits at outbox_poster.py:2505–2520. Commit f680d28 documents the production delay that motivated separating delivery from reconciliation. The same path also scans all progress files under the shared lock at outbox_poster.py:1313, :1381, and :1403, so unrelated progress can invalidate a sweep or repeat the work. Bound the synchronous lookup and freshness checks to records that can affect the target thread, including newer replacements for its decision keys.bin/fm-ext-emit.sh:398- Round 1 moved the choice-text check before the hold, but the new buttonless path still has two late refusals that can leave a captain call held without a Discord question. An otherwise valid 90-character task ID produces a 101-byte Discuss ID and fails the unconditional button limit here, even though no Discuss button is sent. A task namedanswercan pass the wrapper's text check at bin/fm-ext-ask.sh:218, then its generated cue at :228 triggers the task-ID check in bin/fm-ext-emit.sh:402–404 after the hold at bin/fm-ext-ask.sh:271. Apply the component limit only to option posts and check the complete public body before creating or refreshing the hold.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1592- Round 2 can erase a newer ✅. The sweep reads a decision as open, the captain answers, and an ordinarydonereply applies and records ✅ before the sweep reads the thread record. The sweep still uses its old open count, overwrites ✅ with ❓, and the next sweep clears to bare because no deferreddonesurvived. The before- and after-PATCH guards at outbox_poster.py:1419 and :1439 track decision publications, so they miss this ledger closure and already-completed reply. The repair branch at :1453 also reuses the live title at :1381–1398, so a delayed sweep PATCH can overwrite a concurrent explicit retitle and then adopt the old title it just wrote. Recheck the target thread’s decision and rename intent together before applying a sweep result, and repair a stale PATCH from the newer recorded intent.bin/fm-ext-decision.sh:870- The round-2 outage fix leaves a real ledger failure classified as a verified open question. After a buttonless worker decision is answered and ✅ is applied, an unreadable retained worker status file yieldsunknownat bin/fm-ext-lib.sh:737–755. This branch counts it as open, so outbox_poster.py:1371 and :1592 replace ✅ with ❓. When the ledger recovers, :1594 clears it to bare. Buttonless posts reach this path because bin/fm-ext-decision.sh:784 skips their settlement. Carry the indeterminate result through the thread summary at bin/fm-ext-decision.sh:878–886 and the parser at outbox_poster.py:1540–1544, then preserve the current marker and pending intent when the result is indeterminate. The regression at tests/fm-ext-topic-threads.test.sh:2398 only simulates a missing CLI.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1368- Round 2 still loses a deferred terminal state if a decision closes before ledger lookup recovers. Publish a decision without a marker, then deliverdoneand aneeds-youreminder during the outage. The reminder replaces the replay state withneeds-youwhile leavingmarked_openunset. If the captain answers before recovery, the replay installs ❓ with the reminder’s later timestamp, erases the deferreddoneat outbox_poster.py:1392–1394, and evades subsequent auto-clear at :1590–1599. Preserve the queued terminal state across the reminder and resolve it against the recovered decision summary before replay. The case at tests/fm-ext-topic-threads.test.sh:2409–2419 starts with a successful question marker and recovers before the decision closes.bin/fm-ext-emit.sh:301- R3 says to “keep --no-buttons for genuinely informational status that asks nothing,” but the changed needs-you gate accepts any--no-buttonsreason.Pick a routewith numbered choices andReply with the numberskips the detector at bin/fm-ext-emit.sh:279 and publishes with no decision, so a laterdonecan hide the unanswered choice. The same emitter handles answer, followup, final, and the opening reply via bin/fm-ext-open.sh:97. Narrow the exemption for actual questions while preserving the deliberate informational list covered at tests/fm-ext-ask.test.sh:254–267. The skill’s example at .agents/skills/ext-respond/SKILL.md:83 and the contract at docs/configuration.md:1236 should reflect the same boundary.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1397- Round 2’s live-title reuse can stack markers and leave ❓ after closure. If a captain manually renames an open thread to✅ ❓ Compaction recap, the formatter at outbox_poster.py:1157–1162 strips one prefix, so reassertion writes❓ ❓ Compaction recap. Auto-clear then writes❓ Compaction recapand recordsnone, leaving the false question marker in place. Normalize the full leading marker sequence at the shared formatter used by the open, clear, and retry branches at :1590–1604.bin/fm-ext-emit.sh:391- The added zero-option guard is broader than R3’s written-answer decision needs.How many jobs failed? Reply with the number.offers no choices, but the standalone reply cue causes both bin/fm-ext-ask.sh:225 and bin/fm-ext-emit.sh:391 to refuse it. Remove the broad guard from the empty-option path. If actual offered choices must still use the button path, use a narrower match that requires offered alternatives. Update the rule at docs/configuration.md:1240 and the corresponding assertions at tests/fm-ext-ask.test.sh:554 and tests/fm-ext-topic-threads.test.sh:2503.bin/fm-ext-ask.sh:223- The generatedReply here with your answer.cue is unnecessary for recording a question in words. It makes a valid task namedanswerimpossible to ask about through--free-texteven when the caller’s public text contains no task identifier. Round 2’s regression at tests/fm-ext-ask.test.sh:568–589 pins that refusal. Remove the generated sentence and keep the complete public-body check at bin/fm-ext-ask.sh:236 and bin/fm-ext-emit.sh:404.bin/fm-ext-decision.sh:191- Round 2 narrows JSON parsing but leaves two retained-outbox body scans for a marker reply in a thread with a decision. Both selectors at bin/fm-ext-decision.sh:230 and :238 call the same grep at :191–192, which opens every retained progress file, including ordinary replies containing rendered chunks. The synchronous lookup at outbox_poster.py:1349 runs between replies in the sequential drain at :2527–2539. A lookup genuinely bounded to the target thread and its replacement keys needs an index or equivalent maintained lookup. That remedy requires scope approval.✅ **Test** - passed
✅ No issues found.
bash tests/fm-ext-topic-threads.test.shbash tests/fm-ext-ask.test.shtest_51_delivery_survives_a_long_sweepandtest_52_thread_record_writes_are_serializedfromtests/fm-ext-bridge.test.shin an isolated test homepython3 -B .marker-live/drive.pyin a loopback-only network namespace, launchingbin/fm-hermes-sandbox.sh --root <isolated-root> -- hermes gateway runand recording Discord REST, WebSocket, and Firstmate CLI behaviorReviewed the marker guidance in.agents/skills/ext-respond/SKILL.mdand the Topic threads contract indocs/configuration.md.Retained the Discord transcript and gateway shutdown records, verified process exit, and removed the disposable test environment.✅ **Document** - passed
✅ No issues found.
🔧 **Lint** - 1 issue found → auto-fixed ✅
🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Push** - passed
✅ No issues found.