Commit Graph

7 Commits

Author SHA1 Message Date
slit
9caf5302d4 fix(tmux): use KillSessionWithProcesses to prevent zombie bash processes
When Claude sessions were terminated using KillSession(), bash subprocesses
spawned by Claude's Bash tool could survive because they ignore SIGHUP.
This caused zombie processes to accumulate over time.

Changed all critical session termination paths to use KillSessionWithProcesses()
which explicitly kills all descendant processes before terminating the session.

Fixes: gt-ew3tk

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-20 20:45:58 -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
max
1b69576573 fix: Address golangci-lint errors (errcheck, gosec) (#76)
Apply PR #76 from dannomayernotabot:

- Add golangci exclusions for internal package false positives
- Tighten file permissions (0644 -> 0600) for sensitive files
- Add ReadHeaderTimeout to HTTP server (slowloris prevention)
- Explicit error ignoring with _ = for intentional cases
- Add //nolint comments with justifications
- Spelling: cancelled -> canceled (US locale)

Co-Authored-By: dannomayernotabot <noreply@github.com>

🤖 Generated with Claude Code
2026-01-03 16:11:55 -08:00
rictus
478dc60db1 feat(connection): Add extended address parser (gt-f9x.10)
Implement address parsing for cross-machine operations:

Format: [machine:]rig[/polecat]

Examples:
- gastown/rictus -> local, gastown rig, rictus polecat
- vm:gastown/rictus -> vm machine, gastown rig, rictus
- gastown/ -> broadcast to gastown rig

Address struct with:
- ParseAddress() parser with validation
- String() canonical form
- IsLocal(), IsBroadcast() predicates
- Equal() comparison (normalizes local machine)
- Validate() against MachineRegistry
- RigPath() for rig/polecat without machine prefix

Includes comprehensive test coverage.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 19:24:51 -08:00
rictus
0013cc0f19 feat(connection): Add MachineRegistry for federation support (gt-f9x.9)
Implement MachineRegistry that manages machine configurations and
provides Connection instances for local and remote operations:

- Machine struct with name, type, host, key path, and town path
- Registry with JSON persistence (federation.json)
- CRUD operations: Get, Add, Remove, List
- Connection factory that returns appropriate Connection type
- Built-in "local" machine that cannot be removed

SSH connections return an error until SSHConnection is implemented.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 19:24:51 -08:00
rictus
b4ff6781b3 feat(connection): Add LocalConnection implementation (gt-f9x.8)
Implement LocalConnection that provides local file operations, command
execution, and tmux integration:

- File ops: ReadFile, WriteFile, MkdirAll, Remove, RemoveAll, Stat, Glob, Exists
- Command exec: Exec, ExecDir, ExecEnv
- Tmux: NewSession, KillSession, SendKeys, CapturePane, HasSession, ListSessions

Uses proper error wrapping with NotFoundError and PermissionError types.
Integrates with existing internal/tmux package for session management.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 19:20:32 -08:00
rictus
ca3c6da8ec feat(connection): Add Connection interface for local/remote ops (gt-f9x.7)
Define the Connection interface that abstracts file operations, command
execution, and tmux management for both local and remote (SSH) contexts.

Includes:
- Connection interface with file, exec, and tmux operations
- FileInfo interface for remote stat results
- BasicFileInfo implementation with JSON serialization
- Error types for connection failures

This enables Gas Town to manage rigs on remote machines using the
same interface as local operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-01 19:20:32 -08:00