Repository navigation
feat: add Jev-powered Discord thread auto-renaming - #329
Merged
Merged
Conversation
- thread_title.py is the only writer of a thread's title: it computes the desired title from its inputs (open decisions from the decision ledger, the latest verdict with its transcript cutoff, a new base, the captain's own words) and writes only when it differs. - Marker precedence is question > blocked > running > done; a decision button's question mark skips our 10-minute pace, nothing skips Discord's rate-limit headers or 429 retry_after. - thread_autoname.py judges each post off the delivery path with Jev and the naming model, and runs the one-time, resumable catch-up over the ten newest threads; delivery, the decision sweep, and catch-up only update inputs. - Shared Jev client and key check in bin/fm-jev-lib.sh; gateway subprocesses no longer receive the key except the judge. - fm-ext-decision.sh threads reports the newest closure time from the decision post ledger.
- The reconciler now logs the retry_after it waits, so a held title is visible in the gateway journal.
- Each pass recomputes the title from durable state: the decision ledger, accepted-chunk progress with each reply's own state and retitle, the thread's Jev verdict log, and Discord waits in state/ext-autoname/cooldowns.json. - Compare-and-write re-reads the live title, newest accepted message, and ledger right before PATCH; a write that still raced newer state is corrected on the next pass without the 10-minute pace. - Only the newest unjudged Firstmate message per thread is judged; catch-up fixes its ten threads and a horizon before the first model call. - Events plus a 10-minute safety sweep (also at start) schedule passes. - fm-ext-thread-judge.sh --check prints on/off/unknown/inactive; unknown decision state, unreadable inputs, or an unclear check mean no title work. - fm-ext-decision.sh settles closed decision posts without buttons too, so each closed post keeps one closure time.
dnth
force-pushed
the
fm/fm-thread-autorename-v2
branch
from
November 24, 2026 05:31
d840f15 to
00e925a
Compare
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
One reconciler per Discord topic thread is now the only code that writes its title (issue 324 rebuild).
Each pass works out the title from saved state alone, then compares and writes:
Choices where the spec is silent:
bin/fm-ext-topic.sh --retitle-fileis removed: nothing calls it.Evidence
After:
tests/fm-ext-thread-autoname.test.sh13/13 at 2176be0 on a fake clock and a local Discord, among them:Other suites at 2176be0 (local runs): topic-threads 41, decision 23, bridge all (with
FM_TASK_IDunset), dispatch-resolve, thread-context, ask, needs-you-buttons, plugin-dest.After the pipeline's review fixes (09c9838) its test step reran thread-autoname, topic-threads, dispatch-resolve, bridge 51-52, and a local-gateway drive of 8 scenarios: all passed.
ubuntu-latestmove to 26.04) are fixed on main by the runner pin in ci: pin Linux jobs to ubuntu-24.04 #330; this PR is rebased onto it. The one failure this PR caused (serial 4, bot-identity test using the old title transport) was fixed in the pipeline's CI round.❓at 01:14:17❓at once (01:14:29), stayed through the reminder,✅at 01:24:50 right after settled closure❓ Captain words · rename checkat 01:24:43Merge Danger
Door: two-way
Revert restores the previous rename path; the new state (
state/ext-autoname/catch-up.json,cooldowns.json,titlefields in thread records) is ignored by older code.Blast Radius: Discord-titles
Only topic-thread titles in the dedicated channel change; replies, decision buttons, and routing are untouched, and every title-path failure leaves the title as it is.
Settled free-text decision posts now get a settle record and an empty
.finalizedmarker.Deferred review findings (follow-up issue)
The last review round was capped by decision; these are listed for a follow-up, not fixed here.
Two came from the last fix round itself and should go first:
request-slot-wait-invalidates-title-compare: a PATCH that waits for the shared request slot can overwrite a captain rename made during the wait.retention-fix-expires-actively-renamed-threads: real title writes no longer refresh the thread record's age, so a thread still active under newer requests can age out with its first request.Also deferred:
decision-chronology-loses-opening-and-closing-order,unreadable-ledger-becomes-authoritative-state,kept-status-jumps-unjudged-substantive-post,repeated-manual-edits-reuse-stale-observation,catch-up-freezes-before-legacy-ownership-proof,judge-scan-starts-superseded-cutoffs,permanent-refusal-retries-before-next-reply,key-read-failure-still-enables-explicit-fallback,paced-decision-marker-becomes-held-status,identity-route-cooldown-is-thread-local,forced-safety-sweeps-mask-missing-deadline-wakeups,unused-last-pass-timestamp.The review on the rebase onto main raised 7 more, also listed, not fixed. One is a public-safety gap to decide before merge:
model-retitle-publishes-forbidden-branch-name: when the topic drifts, the naming model can propose a public title containing a branch name mentioned in the thread, and the title screen does not reject it.Also from that review:
retitle-base-can-set-marker-without-verdict,closed-decision-question-can-regain-marker-on-first-delivery,outbox-expiry-rewinds-title-inputs,background-title-scans-block-delivery-progress,opened-thread-lookup-oracle-reuses-receipt,redundant-env-change-test-selector.The review on the test-step rerun raised 4 more, also listed, not fixed:
unrelated-reply-bypasses-title-pace(a reply with no title input that lands during a write can later let another reply skip the 10-minute pace),closure-test-accepts-observation-time,redundant-existing-thread-name-branch,redundant-judging-state-alias.Declined:
superseded-fixed-retry-path(the documented 30-second retry stays).No-Mistakes review outcomes
No GitHub reviews or review threads exist on this PR; these are the pipeline review findings.
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
contrib/hermes-gateway-firstmate-comms/thread_title.py:495- The approved rule says “at most 1 judged title change per thread per 10 minutes,” with an exception for correcting a raced write. If a state-less follow-up lands during a PATCH to ✅, line 495 treats its newer message ID as evidence of a race even though it leaves the desired title unchanged. The next pass exits at line 660 without clearing that evidence. A later explicitnonereply can then take the correction branch at lines 674–675 and remove ✅ inside the ten-minute window. The same path exists with judging on if the intervening post has no verdict and the later post supplies one. At the shared correction check, require the input that made the previous title wrong to have arrived before that write landed.tests/fm-ext-thread-autoname.test.sh:684- The closure test accepts any positivelast_closed_at. A ledger that reports the time of the summary read would pass, even though the contract requires the settled timestamp. Use the fake clock at settlement on lines 675–678 as the expected value, then advance the clock before reading the summary and assert that bothlast_closed_atand the post'sclosed_atretain the settlement time.contrib/hermes-gateway-firstmate-comms/outbox_poster.py:1043- The new title-flag suppression branch inthread_name_forhas no required production caller. The request creation path returns an existing thread at line 1341, and the opened-thread path does the same at lines 1420–1424. Remove the extra record lookup and pass the creating title directly.contrib/hermes-gateway-firstmate-comms/thread_title.py:759- The reconciler adds a secondjudging_stateentry point that only forwards tothread_autoname.judging_state. No intent requirement needs the alias. Remove it and call the shared check from the reconciler entry points at lines 617 and 812.✅ **Test** - passed
✅ No issues found.
env -u FM_TASK_ID PYTHONDONTWRITEBYTECODE=1 TMPDIR="$PWD/.gate-title-test/tmp" bash tests/fm-ext-thread-autoname.test.shenv -u FM_TASK_ID PYTHONDONTWRITEBYTECODE=1 TMPDIR="$PWD/.gate-title-test/tmp" bash tests/fm-ext-bot-identity.test.shenv -u FM_TASK_ID PYTHONDONTWRITEBYTECODE=1 TMPDIR="$PWD/.gate-title-test/tmp" bash tests/fm-ext-topic-threads.test.shbin/fm-hermes-sandbox.sh --root "$PWD/.gate-title-test/run/sandbox" -- hermes gateway runwith a workspace-local Discord runtimepython3 -B .gate-title-test/emulator.pyandpython3 -B .gate-title-test/drive.pyfor live gateway, REST, WebSocket, persisted state, and restart checkspython3 -B .gate-title-test/drive.py stale_delivery discord_response_headers discord_failures_and_unknown raced_writefollowed bypython3 -B .gate-title-test/drive.py stale_deliveryfor corrected fixture checksCaptured protocol events, persisted ledger and title results, and gateway lifecycle logs, then verified that all disposable processes exited.⏭️ **Document** - skipped
Step was skipped.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.