fix(hook): make cross-level hooks visible to mayor/deacon

The gt hook command wasn't finding hooked beads for town-level roles
(mayor, deacon) because of an identity format mismatch:

- When hooking a bead, resolveSelfTarget() sets assignee with trailing
  slash (e.g., "mayor/")
- When querying, buildAgentIdentity() returned without slash ("mayor")

This caused the assignee filter to miss the hooked bead since bd does
exact matching on the assignee field.

Fix:
- Update buildAgentIdentity() to return "mayor/" and "deacon/" with
  trailing slash, matching the format used when setting assignee
- Update isTownLevelRole() to accept both formats for compatibility

Fixes: gt-g6ng2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
slit
2026-01-09 21:37:54 -08:00
committed by beads/crew/giles
parent c4fcdd88c8
commit aeb4c0d26f

View File

@@ -451,13 +451,14 @@ func runMoleculeStatus(cmd *cobra.Command, args []string) error {
}
// buildAgentIdentity constructs the agent identity string from role context.
// Format matches session.AgentIdentity.Address() for consistency.
// Town-level agents (mayor, deacon) use trailing slash to match the format
// used when setting assignee on hooked beads (see resolveSelfTarget in sling.go).
func buildAgentIdentity(ctx RoleContext) string {
switch ctx.Role {
case RoleMayor:
return "mayor"
return "mayor/"
case RoleDeacon:
return "deacon"
return "deacon/"
case RoleWitness:
return ctx.Rig + "/witness"
case RoleRefinery:
@@ -876,8 +877,10 @@ func getGitRootForMolStatus() (string, error) {
// isTownLevelRole returns true if the agent ID is a town-level role.
// Town-level roles (Mayor, Deacon) operate from the town root and may have
// pinned beads in any rig's beads directory.
// Accepts both "mayor" and "mayor/" formats for compatibility.
func isTownLevelRole(agentID string) bool {
return agentID == "mayor" || agentID == "deacon"
return agentID == "mayor" || agentID == "mayor/" ||
agentID == "deacon" || agentID == "deacon/"
}
// extractMailSender extracts the sender from mail bead labels.