Commit graph

165 commits

Author SHA1 Message Date
dan 09b76605c2 refactor: implement consistent error handling strategy
Error handling helpers in utils.nim:
- logError/logWarn: consistent stderr format
- wrapError template: catch and re-raise with context

db.nim:
- openBusDb: wrap with DbError and path context
- poll: handle malformed JSON gracefully with warning
- tryClaim: log failures instead of silently swallowing

git.nim:
- createWorktree/rebaseOnIntegration: warn on fetch failure
- removeWorktree/removeBranch: log cleanup failures
- getBranchStatus: log parseInt failures

context.nim:
- readContext/findContext: add path context to parse errors
- writeContext: wrap IOError with path

types.nim:
- Extract ContextDateFormat constant
- Add context to date parse errors

Closes: skills-05ah, skills-xcl, skills-266, skills-8xv, skills-8vdo,
        skills-tdfm, skills-koes, skills-8bi, skills-2wjp, skills-3uv9, skills-xgh0

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:37:47 -08:00
dan 5121bbb008 bd sync: 2026-01-10 20:37:34 2026-01-10 20:37:34 -08:00
dan d3d22a91e5 refactor: extract common utilities to utils.nim
- Add branchName() and worktreePath() helpers for consistent path generation
- Add msToTime() for epoch ms to Time conversion (8 occurrences consolidated)
- Add validateTaskId() for CLI input validation (prevents path traversal)
- Add optString/optInt64 helpers for nullable DB values
- Add withTransaction template for automatic rollback on error

Closes: skills-lzh2, skills-3d9o, skills-5x2o, skills-qiq0, skills-73yu, skills-vuj2

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:32:47 -08:00
dan 5550421ae9 bd sync: 2026-01-10 20:32:36 2026-01-10 20:32:36 -08:00
dan 200c040d3a fix: P1 security bugs - cryptographic IDs and GC-managed heartbeat
- genOid: use std/sysrand for cryptographic randomness instead of rand()
- HeartbeatThread: change from ptr with manual alloc/dealloc to ref object
- Add error handling for DB open in heartbeat thread
- Remove unused globalChannel and times import

Closes: skills-0wk, skills-bk7x, skills-69sz, skills-ib9u, skills-kvdl, skills-n6zf

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 20:26:38 -08:00
dan 02b7054709 bd sync: 2026-01-10 20:26:28 2026-01-10 20:26:28 -08:00
dan 1c66d019bd feat: add worker CLI scaffold in Nim
Multi-agent coordination CLI with SQLite message bus:
- State machine: ASSIGNED -> WORKING -> IN_REVIEW -> APPROVED -> COMPLETED
- Commands: spawn, start, done, approve, merge, cancel, fail, heartbeat
- SQLite WAL mode, dedicated heartbeat thread, channel-based IPC
- cligen for CLI, tiny_sqlite for DB, ORC memory management

Design docs for branch-per-worker, state machine, message passing,
and human observability patterns.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 18:47:47 -08:00
dan 555dbb8ccd bd sync: 2026-01-10 18:04:40 2026-01-10 18:04:40 -08:00
dan 6dfd373637 bd sync: 2026-01-10 16:08:27 2026-01-10 16:08:27 -08:00
dan 91f324949c bd sync: 2026-01-10 15:56:52 2026-01-10 15:56:53 -08:00
dan f2a5199337 bd sync: 2026-01-10 15:44:21 2026-01-10 15:44:21 -08:00
dan 713a627185 bd sync: 2026-01-10 15:41:05 2026-01-10 15:41:05 -08:00
dan 0fcfbe0624 bd sync: 2026-01-10 15:34:24 2026-01-10 15:34:24 -08:00
dan 1888db7ec0 bd sync: 2026-01-10 15:27:39 2026-01-10 15:27:39 -08:00
dan bc4f2e85cf bd sync: 2026-01-10 15:08:58 2026-01-10 15:08:58 -08:00
dan 83b126719d bd sync: 2026-01-10 15:00:45 2026-01-10 15:00:45 -08:00
dan ed12600df1 bd sync: 2026-01-10 14:37:59 2026-01-10 14:37:59 -08:00
dan 7c6ff10be7 bd sync: 2026-01-10 14:01:28 2026-01-10 14:01:28 -08:00
dan a34da926c2 bd sync: 2026-01-10 13:55:44 2026-01-10 13:55:44 -08:00
dan d6c47c26f5 docs: worklog for multi-agent Lego architecture design session
Covers: review-gate Stop hook fixes, circuit breaker, research on
OpenHands/Gastown/JWZ patterns, epic creation, phased approach

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 13:35:58 -08:00
dan cc2a727644 bd sync: 2026-01-10 13:34:04 2026-01-10 13:34:04 -08:00
dan 71d8445be4 bd sync: 2026-01-10 13:24:42 2026-01-10 13:24:43 -08:00
dan 7426c1f303 bd sync: 2026-01-10 12:24:11 2026-01-10 12:24:11 -08:00
dan c474b81f51 bd sync: 2026-01-10 12:15:46 2026-01-10 12:15:46 -08:00
dan 0356ed237c feat: add circuit breaker to prevent Stop hook infinite loop
- Track block attempts per session in .attempts file
- After 3 attempts (configurable via REVIEW_MAX_ATTEMPTS), trip breaker
- Circuit breaker allows exit with warning instead of crashing
- Clear attempts on approve or when breaker trips
- Add 3 new tests for circuit breaker behavior (46 total)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 10:33:24 -08:00
dan 9df3aedc2f fix: prevent Stop hook infinite loop via stop_hook_active check
When Claude continues after a Stop hook block, the next Stop hook
invocation has stop_hook_active: true. Detect this and allow exit
to break the loop and prevent stack overflow crash.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 09:34:15 -08:00
dan 020458c9b8 fix: review-gate Stop hook output format and test harness
- Change exit code to 2 (Claude Code blocking signal)
- Output JSON to stderr with decision: block and reason fields
- Add integration test harness for live Claude testing
- Update unit tests for new JSON output format
- Add hooks.json example for Stop hook

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-10 08:23:46 -08:00
dan 4130dd4614 test: add review-gate unit tests (43 tests)
Tests cover:
- All CLI commands (check, enable, approve, reject, status, list, clean)
- Exit codes (0 for allow, 1 for block)
- State file creation and JSON structure
- Session ID auto-detection from env vars
- Multiple issues in reject
- Workflow reset (re-enable after approve)
- Error handling

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 23:09:33 -08:00
dan 061556e003 bd sync: 2026-01-09 20:39:37 2026-01-09 20:39:37 -08:00
dan 91b6c842a2 feat: add review-gate skill for cross-agent quality enforcement
- CLI tool with check/enable/approve/reject/status commands
- Stop hook integration for Claude Code blocking
- Adversarial reviewer prompt template
- Dual-publish structure (SKILL.md + .claude-plugin)
- Session ID auto-detection from env vars or git state

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 20:39:34 -08:00
dan 4d298c1e22 bd sync: 2026-01-09 19:59:51 2026-01-09 19:59:51 -08:00
dan beace9046d bd sync: 2026-01-09 19:51:10 2026-01-09 19:51:10 -08:00
dan 75c5edb86c docs: cross-agent enforcement architecture design
Comprehensive design covering:
- Abstract layers (message passing, memory, enforcement)
- Four enforcement strategies:
  - Hook-based (Claude/Gemini)
  - Orchestrator-enforced (OpenCode/Codex)
  - Validator sidecar (universal)
  - Proxy-based (API interception)
- Circuit breakers (semantic drift, three-strike, budget)
- Adversarial reviewer pattern
- State flow diagram
- Implementation phases

Based on web research via orch (gemini --websearch).

Addresses: skills-8sj

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 19:51:09 -08:00
dan 8c033eedd1 docs: add Gemini path fix (includeDirectories setting)
Gemini CLI can access ~/.claude/skills/ via:
  settings.json: { "context": { "includeDirectories": ["~/.claude/skills"] } }
  or CLI: gemini --include-directories ~/.claude/skills

Closes: skills-8nl, skills-bo8

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 19:35:28 -08:00
dan f7483edcf3 bd sync: 2026-01-09 19:33:03 2026-01-09 19:33:03 -08:00
dan 52fe241734 bd sync: 2026-01-09 19:01:55 2026-01-09 19:01:55 -08:00
dan c14075ae7e docs: web research on cross-agent patterns (via orch)
Key findings from gemini --websearch:
- Manager-Worker orchestration (Maestro pattern)
- alice/idle adversarial review gates (emes)
- Git-as-state for agent coordination
- tissue for machine-first issue tracking
- Circuit breakers: semantic drift, three-strike, budget limits
- Sandboxing: Wasm and Docker playgrounds

Validates our direction: beads, orch, file-based coordination.
Gaps: orchestrator-enforced gates, agent messaging, sandboxing.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 17:50:37 -08:00
dan e367be6cb6 bd sync: 2026-01-09 17:32:23 2026-01-09 17:32:23 -08:00
dan ec2d856c05 docs: add agent capability matrix for cross-agent design
Comprehensive comparison of Claude Code, Gemini CLI, OpenCode, and Codex:
- Hooks/lifecycle events (Claude/Gemini best, OpenCode most comprehensive)
- Subagent spawning (MCP is universal bridge)
- File access (Gemini has path restrictions - skills-bo8)
- Sandboxing (Codex has OS-level, others approval-based)
- State persistence (need external store for cross-agent)

Key finding: Orchestrator pattern works across all agents.
Stop hooks only in Claude/Gemini - others need protocol-based gates.

Closes: skills-fqu

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 17:32:17 -08:00
dan c94def1c61 bd sync: 2026-01-09 17:14:41 2026-01-09 17:14:41 -08:00
dan a87f2f4950 bd sync: 2026-01-09 16:57:16 2026-01-09 16:57:16 -08:00
dan 4773abe56f docs: correct alice framing - adversarial agent review for automation
alice is for reviewing AGENT work in unattended/autonomous contexts,
not code review. Key use cases:
- Autonomous runs on ops-jrz1
- CI/CD pipelines with agents
- High-stakes changes without human oversight

Added hybrid approach recommendation: use alice concepts (Stop hook,
adversarial methodology) with our infrastructure (beads, orch).

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:45:49 -08:00
dan 144bafd2b5 bd sync: 2026-01-09 16:43:51 2026-01-09 16:43:51 -08:00
dan 239c758dc7 docs: research idle/alice quality gate mechanism
Comprehensive analysis of emes idle/alice plugin:
- Hook chain (6 hooks, Stop is key blocker)
- State management via jwz (topic-based messaging)
- alice agent (read-only Opus reviewer)
- Circuit breakers against infinite loops

Conclusion: alice pattern is overkill for code-review (we ARE the
reviewer). More useful: "review reminder" hook that checks if
code-review was run before exit on significant changes.

Closes: skills-9jk

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:43:46 -08:00
dan 1b943742bd bd sync: 2026-01-09 16:19:14 2026-01-09 16:19:14 -08:00
dan 5a7891656a feat: convert all skills to dual-publish pattern
Add Claude plugin structure (.claude-plugin/plugin.json) and auto-discovery
(skills/<name>.md) to 15 skills. orch was already converted.

Skills converted:
- ai-tools-doctor, bd-issue-tracking, code-review, doc-review
- niri-window-capture, ops-review, playwright-visit, screenshot-latest
- spec-review, tufte-press, update-opencode, update-spec-kit
- web-research, web-search, worklog

Marketplace now lists all 16 skills for /plugin install.

Closes: skills-1ks

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:19:09 -08:00
dan f6ec653a83 bd sync: 2026-01-09 16:06:50 2026-01-09 16:06:50 -08:00
dan a198b31add docs: clarify deployment strategy (beads local, tissue remote)
Local (skills, dotfiles): beads + our dual-publish
Remote (ops-jrz1 VPS): tissue + emes ecosystem

They coexist by environment, not replacing each other.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 16:06:45 -08:00
dan 8a76f4e9cb docs: add plugin systems comparison (ours vs claude vs emes)
Compares three approaches:
- Our system: cross-agent, Nix, lenses
- Claude plugins: official, hooks, marketplace
- emes: mechanical enforcement, tissue, idle, jwz

Living document for iterating on architecture.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 15:39:19 -08:00
dan a84066c1dd docs: add ADR-005 for dual-publish plugin architecture
Captures the decision to maintain both:
- Nix deployment (cross-agent: Gemini, OpenCode)
- Claude plugin system (hooks, marketplace)

Documents trade-offs, consequences, and mitigations.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-09 11:44:15 -08:00