Commit Graph

2854 Commits

Author SHA1 Message Date
Julian Knutsen
043a6abc59 fix(beads): prevent routes.jsonl corruption and add doctor check for rig-level routes.jsonl (#377)
* fix(beads): prevent routes.jsonl corruption from bd auto-export

When issues.jsonl doesn't exist, bd's auto-export mechanism writes
issue data to routes.jsonl, corrupting the routing configuration.

Changes:
- install.go: Create issues.jsonl before routes.jsonl at town level
- manager.go: Create issues.jsonl in rig beads; don't create routes.jsonl
  (rig-level routes.jsonl breaks bd's walk-up routing to town routes)
- Add integration tests for routes.jsonl corruption prevention

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(doctor): add check to detect and fix rig-level routes.jsonl

Add RigRoutesJSONLCheck to detect routes.jsonl files in rig .beads
directories. These files break bd's walk-up routing to town-level
routes.jsonl, causing cross-rig routing failures.

The fix unconditionally deletes rig-level routes.jsonl files since
bd will auto-export to issues.jsonl on next run.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(rig): add verification that routes.jsonl does NOT exist in rig .beads

Add explicit test assertion and detailed comment explaining why rig-level
routes.jsonl files must not exist (breaks bd walk-up routing to town routes).

Also verify that issues.jsonl DOES exist (prevents bd auto-export corruption).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(doctor): ensure town root route exists in routes.jsonl

The RoutesCheck now detects and fixes missing town root routes (hq- -> .).
This can happen when routes.jsonl is corrupted or was created without the
town route during initialization.

Changes:
- Detect missing hq- route in Run()
- Add hq- route in Fix() when missing
- Handle case where routes.jsonl is corrupted (regenerate with town route)
- Add comprehensive unit tests for route detection and fixing

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* test(beads): fix routing integration test for routes.jsonl corruption

The TestBeadsRoutingFromTownRoot test was failing because bd's auto-export
mechanism writes issue data to routes.jsonl when issues.jsonl doesn't exist.
This corrupts the routing configuration.

Fix: Create empty issues.jsonl after bd init to prevent corruption.
This mirrors what gt install does to prevent the same bug.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: julianknutsen <julianknutsen@users.noreply.github>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 01:45:26 -08:00
Julian Knutsen
a1008f6f58 fix(sling): pass both feature and issue vars in formula-on-bead mode (#382)
When using `gt sling <formula> --on <bead>`, the code was only passing
the `feature` variable (set to bead title). This broke formulas that
expect `issue` (set to bead ID), like mol-polecat-work.

Now passes both common variables:
- feature: bead title (for shiny-style formulas)
- issue: bead ID (for mol-polecat-work-style formulas)

This allows either formula type to work with --on without requiring
the user to manually specify variables.

Fixes #355

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 01:45:25 -08:00
Julian Knutsen
995476a9c0 fix(install): add gt:role label to role beads during creation (#383)
Role beads created by gt install were missing the gt:role label required
by GetRoleConfig(), causing witness startup to fail with:
"bead hq-witness-role is not a role bead (missing gt:role label)"

This regression was introduced in 96970071 which migrated from type-based
to label-based bead classification. The install code used raw exec.Command
instead of the beads API, so it wasn't updated to add labels.

Changes:
- Use bd.CreateWithID() API which auto-converts Type:"role" to gt:role label
- Add RoleLabelCheck doctor migration to fix existing installations
- Add comprehensive unit tests with mocked dependencies

Co-authored-by: julianknutsen <julianknutsen@users.noreply.github>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 01:45:21 -08:00
Julian Knutsen
7b35398ebc fix(git): fetch origin after configuring refspec for bare clones (#384)
Bare clones don't have refs/remotes/origin/* populated by default.
The configureRefspec fix (a91e6cd6) set up the fetch config but didn't
actually run a fetch, leaving origin/main unavailable.

This caused polecat worktree creation to fail with:
  fatal: invalid reference: origin/main

Fixes:
1. Add git fetch after configureRefspec in bare clone setup
2. Add fetch before polecat worktree creation (ensures latest code)

The second fix matches RepairWorktreeWithOptions which already had a fetch.

Related: #286

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 01:45:09 -08:00
mayor
0d0d2763a8 feat: Implement unified escalation system (gt-i9r20)
Add severity-based routing for escalations with config-driven targets.

Changes:
- EscalationConfig type with severity routes and external channels
- beads/beads_escalation.go: Escalation bead operations (create/ack/close/list)
- Refactored gt escalate command with subcommands:
  - list: Show open escalations
  - ack: Acknowledge an escalation
  - close: Resolve with reason
  - stale: Find unacknowledged escalations past threshold
  - show: Display escalation details
- Added TypeEscalationAcked and TypeEscalationClosed event types

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 00:47:11 -08:00
beads/crew/emma
ea5d72a07b feat(crew): add --debug flag to crew at command
Add --debug flag for troubleshooting crew attach issues. Shows:
- Current working directory
- Detected rig and crew name
- Computed session ID
- Whether inside tmux
- Which session we are attaching to

Also adds Attaching to session message before attach.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-12 00:35:40 -08:00
mayor
cdea53e221 fix(done): make gt done resilient to missing agent beads
If the agent bead doesn't exist when gt done tries to clear the hook,
return early instead of failing. This happens for polecats created
before identity beads existed.

gt done must be resilient and forgiving - the important thing is work
gets submitted to merge queue, not that cleanup succeeds.

Fixes: hq-i26n2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 23:10:47 -08:00
chrispyfryz
b0f377f973 Add gt mail show alias (#340)
* Use rig prefix for agent bead IDs

* Add gt mail show alias

---------

Co-authored-by: Chris Fry <chris@hyperspect.ai>
2026-01-11 23:09:11 -08:00
Bo
28c55bd451 fix(prime): add boot role detection for proper context injection (#370)
Boot sessions run in `deacon/dogs/boot/` but were incorrectly detected
as deacon role because the deacon check matched first. This caused Boot
to receive Deacon's context instead of Boot-specific context.

Changes:
- Add RoleBoot constant
- Add boot path detection before deacon check in detectRole()
- Add boot case in buildRoleAnnouncement()
- Add boot case in getAgentIdentity() (returns "boot")
- Add boot case in getAgentBeadID() (uses deacon's bead as subprocess)

The boot.md.tmpl template already exists and will now be used.

Fixes #318
2026-01-11 23:08:37 -08:00
Bo
2a0a8c760b fix(refinery): delete remote polecat branches after merge (#369)
Since the self-cleaning model (Jan 10), polecats push branches to origin
before `gt done`. The refinery was only deleting local branches after
merge, causing stale `polecat/*` branches to accumulate on the remote.

Now deletes both local and remote branches after successful merge.
Uses existing `git.DeleteRemoteBranch()` function. Remote deletion is
non-fatal if the branch doesn't exist.

Fixes #359
2026-01-11 23:08:29 -08:00
Bo
1f272ffc53 test: comprehensive test coverage for 5 packages (#351)
* test(util): add comprehensive tests for atomic write functions

Add tests for:
- File permissions
- Empty data handling
- Various JSON types (string, int, float, bool, null, array, nested)
- Unmarshallable types error handling
- Read-only directory permission errors
- Concurrent writes
- Original content preservation on failure
- Struct serialization/deserialization
- Large data (1MB)

* test(connection): add edge case tests for address parsing

Add comprehensive test coverage for ParseAddress edge cases:
- Empty/whitespace/slash-only inputs
- Leading/trailing slash handling
- Machine prefix edge cases (colons, empty machine)
- Multiple slashes in polecat name (SplitN behavior)
- Unicode and emoji support
- Very long addresses
- Special characters (hyphens, underscores, dots)
- Whitespace in components

Also adds tests for MustParseAddress panic behavior and RigPath method.

Closes: gt-xgjyp

* test(checkpoint): add comprehensive test coverage for checkpoint package

Tests all public functions: Read, Write, Remove, Capture, WithMolecule,
WithHookedBead, WithNotes, Age, IsStale, Summary, Path.

Edge cases covered: missing file, corrupted JSON, stale detection.

Closes: gt-09yn1

* test(lock): add comprehensive tests for lock package

Add lock_test.go with tests covering:
- LockInfo.IsStale() with valid/invalid PIDs
- Lock.Acquire/Release lifecycle
- Re-acquiring own lock (session refresh)
- Stale lock cleanup during Acquire
- Lock.Read() for missing/invalid/valid files
- Lock.Check() for unlocked/owned/stale scenarios
- Lock.Status() string formatting
- Lock.ForceRelease()
- processExists() helper
- FindAllLocks() directory scanning
- CleanStaleLocks() with mocked tmux
- getActiveTmuxSessions() parsing
- splitOnColon() and splitLines() helpers
- DetectCollisions() for stale/orphaned locks

Coverage: 84.4%

* test(keepalive): add example tests demonstrating usage patterns

Add ExampleTouchInWorkspace, ExampleRead, and ExampleState_Age to
serve as documentation for how to use the keepalive package.

* fix(test): correct boundary test timing race in checkpoint_test.go

The 'exactly threshold' test case was flaky due to timing: by the time
time.Since() runs after setting Timestamp, microseconds have passed,
making age > threshold. Changed expectation to true since at-threshold
is effectively stale.

---------

Co-authored-by: slit <gt@gastown.local>
2026-01-11 23:04:03 -08:00
Julian Knutsen
4bbf97ab82 fix(costs): query all beads locations for session events (#374)
* test(costs): add failing test for multi-location session event query

Add integration test that verifies querySessionEvents finds session.ended
events from both town-level and rig-level beads databases.

The test demonstrates the bug: events created by rig-level agents (polecats,
witness, etc.) are stored in the rig's .beads database, but querySessionEvents
only queries the town-level beads, missing rig-level events.

Test setup:
- Creates town with gt install
- Adds rig with gt rig add (separate beads DB)
- Creates session.ended event in town beads (simulating mayor)
- Creates session.ended event in rig beads (simulating polecat)
- Verifies querySessionEvents finds both events

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

* fix(costs): query all beads locations for session events

querySessionEvents previously only queried the town-level beads database,
missing session.ended events created by rig-level agents (polecats, witness,
refinery, crew) which are stored in each rig's own .beads database.

The fix:
- Load rigs from mayor/rigs.json
- Query each rig's beads location in addition to town-level beads
- Merge and deduplicate results by session ID + timestamp

This ensures `gt costs` finds all session cost events regardless of which
agent's beads database they were recorded in.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

---------

Co-authored-by: julianknutsen <julianknutsen@users.noreply.github>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 23:03:50 -08:00
Julian Knutsen
add77eea84 fix(beads): init db for tracked beads after clone (#376)
When a repo with tracked .beads/ is added as a rig, the beads.db file
doesn't exist because it's gitignored. Previously, bd init was only run
if prefix detection succeeded. If there were no issues in issues.jsonl,
detection failed and bd init was never run, causing "Error: no beads
database found" when running bd commands.

Changes:
- Always run bd init when tracked beads exist but db is missing
- Detect prefix from existing issues in issues.jsonl
- Only error on prefix mismatch if user explicitly passed --prefix
- If no issues exist, use the derived/provided prefix

Fixes #72

Co-authored-by: julianknutsen <julianknutsen@users.noreply.github>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 23:03:47 -08:00
gastown/crew/george
a144c99f46 docs(identity): fix stale polecat identity description
Update identity.md to reflect the implemented polecat identity model.
The previous text incorrectly stated "Polecats are ephemeral... no
persistent polecat CV" which contradicted the polecat-lifecycle.md
docs and the gt polecat identity implementation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 22:56:02 -08:00
Tanwa Arpornthip
956f8cc5f0 fix(handoff): recognize polecat session pattern gt-<rig>-<name> (#373)
sessionWorkDir had cases for mayor, deacon, crew, witness, and refinery
but not polecats. When gt handoff was run from a polecat session like
gt-tanwa_info-slit, it failed with "unknown session type".

Fix uses session.ParseSessionName to parse the session name and extract
rig/name for polecat sessions, mapping to <townRoot>/<rig>/polecats/<name>.

Fixes: gm-lie6

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 22:36:14 -08:00
gastown/crew/jack
30a6f27404 fix(sling): remove obsolete --naked flag
The --naked flag (skip tmux session creation) was a vestige of an earlier
design requiring manual session management. With the current polecat
architecture where polecats are witness-managed, ephemeral, and self-deleting
after task completion, manual session management is no longer needed.

The flag also created invalid states (e.g., slinging to crew --naked left
them unreachable since crew require tmux sessions for communication).

Closes gt-xhn5s

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 22:23:21 -08:00
gastown/crew/george
f5832188a6 docs: add plugin and escalation system designs
Plugin System (gt-n08ix):
- Deacon-dispatched periodic automation
- Dog execution model (non-blocking)
- Wisps for state tracking (no state.json)
- Gate types: cooldown, cron, condition, event
- First plugin: rebuild-gt for stale binary detection

Escalation System (gt-i9r20):
- Unified gt escalate command with severity routing
- Config-driven: settings/escalation.json
- Escalation beads for tracking
- Stale escalation re-escalation
- Actions: bead, mail, email, sms

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:24:58 -08:00
furiosa
a106796a0e feat(polecat): add identity subcommand group for agent bead management
Add new `gt polecat identity` (alias: `id`) subcommand group with commands:
- add <rig> [name]: Create identity bead (auto-generates name if omitted)
- list <rig>: List polecat identity beads with session/worktree status
- show <rig> <name>: Show identity details and CV (work history)
- rename <rig> <old> <new>: Rename identity, preserving CV chain
- remove <rig> <name>: Remove identity with safety checks

Each command manipulates agent beads with role_type=polecat. Safety checks
prevent removal of identities with active sessions or work on hook.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:24:30 -08:00
gastown/crew/gus
88f784a9aa docs: reorganize documentation into concepts, design, and examples
Move documentation files into a clearer structure:
- concepts/: core ideas (convoy, identity, molecules, polecat-lifecycle, propulsion)
- design/: architecture and protocols (architecture, escalation, federation, mail, etc.)
- examples/: demos and tutorials (hanoi-demo)
- overview.md: renamed from understanding-gas-town.md

Remove outdated/superseded docs and update reference.md.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:22:17 -08:00
furiosa
8ed31e9634 deprecate(polecat): add migration warning to gt polecat add
Add deprecation warning pointing users to 'gt polecat identity add':
- Cobra Deprecated field emits automatic warning on command use
- Custom warning in runPolecatAdd for prominent stderr output
- Updated help text with deprecation notice and new command example

The command still functions but will be removed in v1.0.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 21:17:58 -08:00
abhijit
833724a7ed new changes 2026-01-11 19:03:06 -08:00
Joshua Vial
c7e1b207df Improve tmux statusline: sort rigs by activity and add visual grouping (#337)
* Improve tmux statusline: sort rigs by activity and add visual grouping

- Sort rigs by running state, then polecat count, then operational state
- Add visual grouping with | separators between state groups
- Show process state with icons (🟢 both running, 🟡 one running, 🅿️ parked, 🛑 docked,  idle)
- Display polecat counts for active rigs
- Improve icon spacing: 2 spaces after Park emoji, 1 space for others

* Fix golangci-lint warnings

- Check error return from os.Setenv
- Check error return from lock.Unlock
- Mark intentionally unused parameters with _

---------

Co-authored-by: joshuavial <git@codewithjv.com>
2026-01-11 18:50:04 -08:00
Bo
d22b5b6ab5 refactor(suggest): extract magic numbers to named constants (#353)
Extract 9 hardcoded scoring weights from similarity() into documented
package-level constants:

- ScoreExactMatch (1000) - identical string match
- ScorePrefixWeight (20) - per-char prefix bonus
- ScoreContainsFullWeight (15) - search term in candidate
- ScoreSuffixWeight (10) - per-char suffix bonus
- ScoreContainsPartialWeight (10) - candidate in search term
- ScoreDistanceWeight (5) - Levenshtein close match
- ScoreCommonCharsWeight (2) - shared character bonus
- LengthDiffThreshold (5) - penalty trigger threshold
- LengthDiffPenalty (2) - per-char length difference penalty

No behavior change - same scores, now with godoc documentation.

Closes: gt-kf7fw

Co-authored-by: furiosa <gt@gastown.local>
2026-01-11 18:49:01 -08:00
Steve Brown
91641b01a0 fix(done): auto-detect cleanup status to prevent premature nuke (#361)
When polecats run 'gt done' without --cleanup-status, the witness may
prematurely nuke the worktree before the refinery can merge.

This fix auto-detects git state:
- uncommitted: has uncommitted changes
- stash: has stashed changes
- unpushed: branch not pushed or has unpushed commits
- clean: everything pushed

Uses BranchPushedToRemote() which properly handles polecat branches
that don't have upstream tracking (compares against origin/main).
On error, defaults to 'unpushed' to prevent accidental data loss.

Fixes: #342

Co-authored-by: mayor <mayor@gastown.local>
2026-01-11 18:47:49 -08:00
Erik LaBianca
7ef4ddab6c fix(install): allow --wrappers in existing town without recreating HQ (#366)
When running `gt install --wrappers` in an existing Gas Town HQ,
the command now installs wrappers directly without requiring --force
or recreating the entire HQ structure.

Previously, `gt install --wrappers` would fail with "directory is
already a Gas Town HQ" unless --force was used, which would then
unnecessarily reinitialize the entire workspace.

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 18:45:24 -08:00
mayor
5aa218fc96 docs(formula): add comprehensive package documentation
Add documentation to make the formula package more discoverable and
demonstrate its value as a reusable workflow definition library.

The formula package provides TOML-based workflow definitions with:
- Type inference (convoy, workflow, expansion, aspect)
- Comprehensive validation
- Cycle detection in dependency graphs
- Topological sorting (Kahn's algorithm)
- Ready-step computation for parallel execution

New files:
- doc.go: Package-level godoc with examples and API overview
- README.md: User guide with installation, quick start, and API reference
- example_test.go: Runnable examples for godoc and testing

The package has 130% test coverage (1,200 LOC tests for 925 LOC code)
and only depends on github.com/BurntSushi/toml.
2026-01-11 21:45:14 -05:00
mayor
e16d5840c6 docs: clarify gt prime is context recovery, not session start (GH #308)
gt prime recovers context inside an existing session (after compaction,
clear, or new session). It's not an alternative to 'gt mayor attach'
which starts a new Mayor session.
2026-01-11 21:44:30 -05:00
slit
947111f6d8 docs(mq): add parameter godoc for GenerateMRIDWithTime
Add detailed parameter documentation for GenerateMRIDWithTime function
including prefix, branch, and timestamp parameters with examples.
2026-01-11 21:44:30 -05:00
rictus
66f6e37844 docs: add godoc for isAutonomousRole explaining autonomous roles
Explains that autonomous roles (polecat, witness, refinery, deacon)
get automatic mail injection on startup since they operate without
human prompting. Non-autonomous roles (mayor, crew) skip this.

Closes: gt-pawy3
2026-01-11 21:44:30 -05:00
dementus
96632fe4ba docs: add godoc for formatInt in activity package
Explains the integer-to-string conversion behavior:
- Direct rune conversion for single digits (efficiency)
- Iterative digit extraction for larger numbers
- Avoids strconv import for simple formatting
2026-01-11 21:44:30 -05:00
nux
54be24ab5b docs(keepalive): document nil sentinel pattern
Add comprehensive godoc comments explaining how the sentinel pattern
enables graceful degradation when keepalive files are missing or stale.
2026-01-11 21:44:30 -05:00
furiosa
ce9cd72c37 docs: clarify Beads issue ID format in README (gt-uzx2c)
Added "Issue IDs" section to Core Concepts explaining that Gas Town
uses Beads' auto-generated short IDs (e.g., gt-x7k2m) rather than
sequential numbers like GitHub issues.

Updated all example issue IDs throughout the README to use realistic
Beads-style IDs instead of confusing "issue-123" format.

Fixes: GitHub #309
2026-01-11 21:44:30 -05:00
gastown/crew/joe
d126c967a0 fix: handle bd --no-daemon exit code 0 bug on not-found (#339)
When bd --no-daemon show <id> does not find an issue, it incorrectly exits
with code 0 (success) but writes the error to stderr and leaves stdout empty.
This causes JSON parse failures throughout gt when code tries to unmarshal
the empty stdout.

This PR handles the bug defensively in all affected code paths:
- beads.go run(): Detect empty stdout + non-empty stderr as error
- beads.go wrapError(): Add 'no issue found' to ErrNotFound patterns
- sling.go: Check len(out) == 0 in multiple functions
- convoy.go getIssueDetails(): Check stdout.Len() == 0
- prime_molecule.go: Check stdout.Len() == 0

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 18:37:01 -08:00
gastown/crew/joe
b9025379b7 test: fix sling test for bd empty output handling
The verifyFormulaExists function now checks for non-empty output,
so the test stub must output something for formula show commands.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 18:36:22 -08:00
gastown/crew/joe
598a39e708 fix: prevent inherited BEADS_DIR from causing prefix mismatch (#321)
- Fix beads.run() to always explicitly set BEADS_DIR based on the working
  directory or explicit override
- This prevents inherited environment variables (e.g., from mayor session
  with BEADS_DIR=/home/erik/gt/.beads) from causing prefix mismatch errors
  when creating agent beads for rigs
- Update polecat manager to use NewWithBeadsDir for explicitness
- Add comprehensive test coverage for BEADS_DIR routing and validation
- Add SessionLister interface for deterministic orphan session testing

Root cause: When BEADS_DIR was set in the parent environment, all bd
commands used the town database (hq- prefix) instead of the rig database
(gt- prefix), causing "prefix mismatch: database uses 'hq' but you
specified 'gt'" errors during polecat spawn.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 18:33:34 -08:00
Steve Yegge
ea84079f8b Merge pull request #334 from julianknutsen/fix/beads-path
Merging: fix is correct, tests comprehensive, lint failures are pre-existing issues unrelated to this PR.
2026-01-11 18:30:51 -08:00
gastown/crew/dennis
b9e8be4352 fix(lint): resolve errcheck and unparam violations
Fixes CI lint failures by handling unchecked error returns and marking
unused parameters with blank identifiers.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 18:06:09 -08:00
mayor
89aec8e19e fix(mail): use NudgeSession for all agent notifications
Simplified notification delivery to always use NudgeSession, since all
sessions are Claude Code (or similar AI sessions), never plain terminals.

This removes unnecessary complexity and the IsClaudeRunning check.
2026-01-11 17:06:47 +01:00
gastown/crew/max
5d554a616a chore: Bump version to 0.2.5
Some checks failed
Release / goreleaser (push) Failing after 5m4s
Release / publish-npm (push) Has been skipped
Release / update-homebrew (push) Has been skipped
v0.2.5
2026-01-11 00:20:09 -08:00
gastown/crew/max
dceabab8db docs: update CHANGELOG for v0.2.5 2026-01-11 00:19:48 -08:00
beads/crew/fang
1418b1123a feat: add gt mail mark-read command for desire path (bd-rjuu6)
Adds mark-read and mark-unread commands that allow marking messages
as read without archiving them. Uses a "read" label to track status.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:03:40 -08:00
mayor
2c73cf35f1 crew.md.tmpl: policy-aware PR guidance (check remote origin)
Makes PR rules conditional on repo ownership instead of absolute ban.
Non-maintainer repos may require PRs for external contributors.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-11 00:01:17 -08:00
mayor
0b90837a18 Make shiny formula and crew template policy-neutral for merge workflow
- shiny.formula.toml: defers to role's git workflow instead of hardcoding PR
- crew.md.tmpl: checks remote origin ownership instead of absolute PR ban
- tmux.go: minor comment fix

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:55:52 -08:00
beads/crew/emma
566bdfbcd8 fix(templates): strengthen No PRs rule to ABSOLUTELY FORBIDDEN
The previous NEVER create GitHub PRs language was too weak. Strengthened to:
- ABSOLUTELY FORBIDDEN header
- This is not negotiable
- Explicit STOP if about to run gh pr create
- Clarified PR Sheriff reviews incoming PRs, does not create them

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:54:12 -08:00
gastown/crew/jack
1ece29e1fd fix(tmux): send Escape before Enter for vim mode compatibility
NudgeSession and NudgePane now send Escape key before Enter to exit
vim INSERT mode if enabled. Harmless in normal mode.

Fixes #307

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:27:50 -08:00
mayor
7f4c3201cf docs(witness): update help text to reflect self-cleaning polecat model
Remove references to idle state. Polecats self-nuke after work - there is
no idle state. The Witness handles crash recovery and orphan cleanup.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:18:39 -08:00
gastown/crew/max
8deb5ed1bd refactor(cmd): remove gt stop command entirely
Too early to deprecate - just remove it. Use `gt down --polecats` instead.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:08:53 -08:00
gastown/crew/max
dab619b3d0 feat(down): add --polecats flag and deprecate gt stop command
Issue #336: Consolidate down/shutdown/stop commands

Changes:
- Add `gt down --polecats` flag to stop all polecat sessions
- Deprecate `gt stop` command (prints warning, directs to `gt down --polecats`)
- Update help text to clarify down vs shutdown distinction:
  - down = pause (reversible, keeps worktrees)
  - shutdown = done (permanent cleanup)
- Integrate --polecats with new --dry-run mode from recent PR

Note: The issue proposed renaming --nuke to --tmux, but PR #330 just
landed with --nuke having better safety (GT_NUKE_ACKNOWLEDGED env var),
so keeping --nuke as-is. The new --polecats flag absorbs gt stop
functionality as proposed.

Closes #336

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 23:04:37 -08:00
Steve Brown
3246c7c6b7 fix(beads): add CreateOrReopenAgentBead for polecat re-spawn (#333)
When a polecat is nuked and re-spawned with the same name, CreateAgentBead
fails with a UNIQUE constraint error because the old agent bead exists as
a tombstone.

This adds CreateOrReopenAgentBead that:
1. First tries to create the agent bead normally
2. If UNIQUE constraint fails, reopens the existing bead and updates fields

Updated both spawn paths in polecat manager to use the new function.

Fixes #332

Co-authored-by: Claude <noreply@anthropic.com>
2026-01-10 22:56:37 -08:00
Subhrajit Makur
6a705f6210 Feat/gt down tests (#15) (#18) (#330)
* fix(down): add refinery shutdown to gt down

Refineries were not being stopped by gt down, causing them to continue
running after shutdown. This adds a refinery shutdown loop before
witnesses, fixing problem P3 from the v2.4 proposal.

Changes:
- Add Phase 1: Stop refineries (gt-<rig>-refinery sessions)
- Renumber existing phases (witnesses now Phase 2, etc.)
- Include refineries in halt event logging

* feat(beads): add StopAllBdProcesses for shutdown

Add functions to stop bd daemon and bd activity processes:
- StopAllBdProcesses(dryRun, force) - main entry point
- CountBdDaemons() - count running bd daemons
- CountBdActivityProcesses() - count running bd activity processes
- stopBdDaemons() - uses bd daemon killall
- stopBdActivityProcesses() - SIGTERM->wait->SIGKILL pattern

This solves problems P1 (bd daemon respawns sessions) and P2 (bd activity
causes instant wakeups) from the v2.4 proposal.

* feat(down): rename --all to --nuke, add new --all and --dry-run flags

BREAKING CHANGE: --all now stops bd processes instead of killing tmux server.
Use --nuke for the old --all behavior (killing the entire tmux server).

New flags:
- --all: Stop bd daemons/activity processes and verify shutdown
- --nuke: Kill entire tmux server (DESTRUCTIVE, with warning)
- --dry-run: Preview what would be stopped without taking action

This solves problem P4 (old --all was too destructive) from the v2.4 proposal.

The --nuke flag now requires GT_NUKE_ACKNOWLEDGED=1 environment variable
to suppress the warning about destroying all tmux sessions.

* feat(down): add shutdown lock to prevent concurrent runs

Add Phase 0 that acquires a file lock before shutdown to prevent race
conditions when multiple gt down commands are run concurrently.

- Uses gofrs/flock for cross-platform file locking
- Lock file stored at ~/gt/daemon/shutdown.lock
- 5 second timeout with 100ms retry interval
- Lock released via defer on successful acquisition
- Dry-run mode skips lock acquisition

This solves problem P6 (concurrent shutdown race) from the v2.4 proposal.

* feat(down): add verification phase for respawn detection

Add Phase 5 that verifies shutdown was complete after stopping all services:
- Waits 500ms for processes to fully terminate
- Checks for respawned bd daemons
- Checks for respawned bd activity processes
- Checks for remaining gt-*/hq-* tmux sessions
- Checks if daemon PID is still running

If anything respawned, warns user and suggests checking systemd/launchd.

This solves problem P5 (no verification) from the v2.4 proposal.

* test(down): add unit tests for shutdown functionality

Add tests for:
- parseBdDaemonCount() - array, object with count, object with daemons, empty, invalid
- CountBdActivityProcesses() - integration test
- CountBdDaemons() - integration test (skipped if bd not installed)
- StopAllBdProcesses() - dry-run mode test
- isProcessRunning() - current process, invalid PID, max PID

These tests cover the core parsing and process detection logic added
in the v2.4 shutdown enhancement.

* fix(review): add tmux check and pkill fallback for bd shutdown

Address review gaps against proposal v2.4 AC:

- AC1: Add tmux availability check BEFORE acquiring shutdown lock
- AC2: Add pkill fallback for bd daemon when killall incomplete
- AC2: Return remaining count from stop functions for error reporting
- Style: interface{} → any (Go 1.18+)



* fix(prime): add validation for --state flag combination

The --state flag should be standalone and not combined with other flags.
Add validation at start of runPrime to enforce this.

Fixes TestPrimeFlagCombinations test failures.

* fix(review): address bot review critical issues

- isProcessRunning: handle pid<=0 as invalid (return false)
- isProcessRunning: handle EPERM as process exists (return true)
- stopBdDaemons: prevent negative killed count from race conditions
- stopBdActivityProcesses: prevent negative killed count from race conditions



* fix(review): critical fixes from deep review

Platform fixes:
- CountBdActivityProcesses: use sh -c "pgrep | wc -l" for macOS compatibility
  (pgrep -c flag not available on BSD/macOS)

Correctness fixes:
- stopSession: return (wasRunning, error) to distinguish "stopped" vs "not running"
- daemon.IsRunning: handle error instead of ignoring with blank identifier
- stopBdDaemons/stopBdActivityProcesses: guard against negative killed counts

Safety fixes:
- --nuke: require GT_NUKE_ACKNOWLEDGED=1, don't just warn and proceed
- pkill patterns: document limitation about broad matching

Code cleanup:
- EnsureBdDaemonHealth: remove unused issues variable



---------

Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 22:56:33 -08:00