fix(formula): resolve refinery agent bead ID dynamically#3301
Merged
steveyegge merged 1 commit intogastownhall:mainfrom Mar 27, 2026
Merged
fix(formula): resolve refinery agent bead ID dynamically#3301steveyegge merged 1 commit intogastownhall:mainfrom
steveyegge merged 1 commit intogastownhall:mainfrom
Conversation
The refinery patrol formula hardcoded `gt-<rig>-refinery` as the agent bead ID in the burn-or-loop step. This breaks when prefix == rig because AgentBeadIDWithPrefix collapses the ID (e.g. `cp-refinery` not `gt-cp-refinery`), causing the refinery to loop with "no issue found". Replace with dynamic resolution via `bd list --type=agent`, matching the pattern already used by the witness formula. Add regression test to prevent re-hardcoding. Fixes: hq-9xs Co-Authored-By: Claude
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
The refinery patrol formula hardcodes the wrong agent bead ID, causing it to loop with "no issue found" errors after any DB reset/recovery.
This PR updates the refinery patrol formula with dynamic resolution matching the witness pattern for finding the agent bead.
Note: I'm fairly new to Gas Town - the Claude-based reasoning on why the correct fix is to update the formula seems plausible to me but I'm happy to be corrected on this.
Details
After a Gas Town restart I noticed the Refinery looping with:
The root cause according to Claude is that the
burn-or-loopstep inmol-refinery-patrol.formula.tomlhardcodesgt-<rig>-refineryas the agent bead ID.Two bugs compound:
gtas the prefix, but non-gastown rigs use their own prefix (e.g.foofor Foobar)AgentBeadIDWithPrefix()inagent_ids.gocollapses the ID when prefix == rig — so for rigfoowith prefixfoo, the actual bead ID isfoo-refinery, notgt-foo-refineryThe witness formula already handles this correctly by resolving its agent bead ID dynamically at runtime via
bd list --type=agent.The fix was to replace the hardcoded ID with the same
bd listdynamic resolution pattern used by the witness. Also added a regression test (TestPatrolFormulasUseDynamicBeadResolution) to prevent re-hardcoding.Verification
After restarting Gas Town with this fix the Refinery was able to find its agent bead and enter normal patrol on non-
gt-prefixed rigs.