fix: add RouteForBead to bdCmd builder for consistent subprocess routing#3526
Draft
mk-imagine wants to merge 6 commits intogastownhall:mainfrom
Draft
fix: add RouteForBead to bdCmd builder for consistent subprocess routing#3526mk-imagine wants to merge 6 commits intogastownhall:mainfrom
mk-imagine wants to merge 6 commits intogastownhall:mainfrom
Conversation
…WIP) Placeholder for draft PR. Adds 5 routed bd command wrappers under gt bead.
…x6o) Replace repeated Dir(resolveBeadDir(id)).StripBeadsDir() pattern with a single RouteForBead(id) builder method on bdCmd. This prepares for adding 5 new gt bead subcommands that reuse the same routing logic. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…hq-x6o) Add 5 new gt bead subcommands that proxy bd commands with automatic prefix-based routing to the correct rig database: - create: routes by --rig flag to target rig - update: routes by bead ID prefix - dep: routes by first bead ID prefix - list: routes by --rig flag to target rig - search: routes by --rig flag to target rig Also adds RouteForPrefix() builder method on bdCmd for commands that accept a prefix rather than a bead ID. Fixes variable shadowing in cat.go and close.go from the RouteForBead refactoring, and adds missing io import to convoy_stage.go. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
feat: add gt bead subcommands with prefix routing
…ing (WIP) Placeholder for draft PR. Adds RouteForBead() method and migrates 11 call sites.
Add RouteForBead(beadID) method to the bdCmd builder that encapsulates the Dir(resolveBeadDir(id)).StripBeadsDir() pattern into a single call. Also adds RouteForPrefix(prefix) for commands that take a prefix. Migrated call sites: - sling_helpers.go: verifyBeadExists, getBeadInfo, storeFieldsInBead (x2) - bead.go: moveBead source lookup - hook.go: hookBead retry loop - cat.go: bd show passthrough (converted from raw exec.Command) - close.go: bd close passthrough, closeChildren query + close (converted) - convoy_stage.go: bdShow, bdDepList helpers (converted) Also fixes pre-existing compact_report_test.go build failure.
f562074 to
75e96f7
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
Add a
RouteForBead(beadID string) *bdCmdmethod to the existingbdCmdbuilder ininternal/cmd/bd_helpers.go. This encapsulates the three-step routing pattern (resolve prefix viaroutes.jsonl, setcmd.Dir, stripBEADS_DIR) into a single chainable builder call, then migrates 11 call sites that currently lack routing.Why: ~160 out of ~199 internal
bdsubprocess calls lack prefix routing. When Go code callsbd show <[rig]-bead>from the town root, it queries the wrong database (hqinstead of[rig]). This causes silent failures: beads created by polecats are invisible to the Mayor, convoy completion checks miss rig-level beads, and the merge queue loses MR beads.Root cause found: The Mayor couldn't see
[rig]-*beads created by polecats during a parallel pipeline test run. Investigation traced it tobdsubprocess calls inconvoy.goandprime.gothat setcmd.Dirto the town root instead of routing to the rig database.Implementation Plan
Phase 1: Implement
RouteForBead()method + testsPhase 2: Migrate 11 call sites across 3 files:
prime.goexec.Command, no Dirdeacon.gotownRootas Dirconvoy.gotownBeadsas Dir with convoy IDsPhase 3: Validation sweep
Key Design Decisions
bdCmdbuilder (not a standalone function)BEADS_DIR(defensive — inherited value is never correct for cross-rig)hq-*IDs too (zero-cost when prefix resolves to town-level, future-proofs for rig-level convoys)Key Files
internal/cmd/bd_helpers.go— newRouteForBead()methodinternal/cmd/bd_helpers_test.go— tests for routing behaviorinternal/cmd/prime.go— 1 call siteinternal/cmd/deacon.go— 1 call siteinternal/cmd/convoy.go— 9 call sitesTest plan
go build ./...passesgo test -race ./internal/cmd/...passesgolangci-lint runcleanbd_helpers_test.gotests still passRouteForBeadtests verify Dir and env stripping behavior