Commit Graph

36 Commits

Author SHA1 Message Date
Levi Neely bb29ec6de7 Extract Assist to anvillm-acme, move logging to pkg/ 2026-03-20 15:29:06 +01:00
Levi Neely 46da046fb3 tmux: remove FIFO plumbing, fix per-window metadata
- Remove dead streaming code: reader(), waitForReady(), StartupHandler, pipe-pane
- Switch recovery metadata from session-scoped set-environment to window-scoped set-option -w @key
- Sessions now start in idle state immediately (no startup wait)
2026-03-12 11:47:37 +01:00
Levi Neely e4ea258c6a session: remove wakeup channel, use ticker-only mail processing
The wakeup channel caused duplicate message delivery: inbox delivery
and idle state transitions both signaled an immediate wakeup with
bypassIdleCheck=true, prompting bots before they were ready.

Replace with a simple 5-second ticker. The idle threshold is always
applied, eliminating the race condition. Worst-case delivery latency
is 10 seconds (one tick to drain outboxes, next tick to prompt).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 22:38:21 +01:00
Levi Neely 29f7b45adc session: wake mail processor immediately on inbox delivery or idle transition
Add wakeupCh (buffered 1) to session.Manager. The mail processing loop
now selects on both the 5s ticker and the wakeup channel. Two events
signal the wakeup: a message delivered to any bot inbox (via onRecv
callback), and a session transitioning to idle with pending messages
(via OnStateChange). When woken, processMailboxes bypasses the
idleDuration threshold check. This covers all delivery paths including
direct DeliverToInbox calls from the supervisor.

Also flatten p9/roles to match p9/skills: remove focus-area directory
layer, expose roles as a flat <name>.md listing.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-06 19:35:41 +01:00
Levi Neely ebc162ac4f crash recovery: reset initialPromptSent and send inbox message
On crash restart:
- Reset initialPromptSent flag so context gets re-injected
- Send 'Continue working.' inbox message from user to session
- Add OnCrashRestart callback to Session struct
2026-03-06 17:27:50 +01:00
Levi Neely ec880544df fix skill prompt commands 2026-03-05 22:31:21 +01:00
Levi Neely bde53a7389 perf: reduce mail idle guard from 15s to 5s
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-01 16:51:34 +01:00
Levi Neely cbace3407c Update changes 2026-02-27 12:12:08 +01:00
Levi Neely 2111f19e9f Add zap logging to ~/.config/anvillm/logs with panic recovery
- Created internal/logging package with zap logger
- Added panic recovery to anvilsrv main loop, monitor goroutine, and mail processing
- Replaced log.Printf/Fatal with zap in debug, p9, tmux packages
- Fixed beads race condition: clear assignee before closing issue
- All errors and crashes now logged to ~/.config/anvillm/logs
2026-02-27 11:46:49 +01:00
Levi Neely addcf0a978 Fix crash bugs: remove impossible nil checks, add bounds check for strings.Fields
- mailManager guaranteed non-nil by constructor, removed defensive checks
- Added bounds check for strings.Fields()[0] in slash command validation
- Removed impossible nil check in processMailboxes()
2026-02-26 22:28:16 +01:00
Levi Neely 49dee87384
Merge pull request #2 from lneely/better-subjects
Make bot prompt send_message instruction dynamic and compact
2026-02-22 09:42:18 +01:00
Levi Neely 407b3732af Replace event queue with in-memory pub-sub event bus
Replaces the TTL-based event queue (internal/events) with a proper
in-memory pub-sub bus (internal/eventbus) backed by simonfxr/pubsub.

The agent/events 9P endpoint is now a streaming subscriber: clients
block on reads and receive one JSON-encoded event per read until they
disconnect. Each open(2) creates a per-connection subscription; clunk
and connection teardown cancel it automatically.

- internal/eventbus/bus.go: new package wrapping simonfxr/pubsub;
  provides Publish(agent, type, data) and Subscribe() -> (chan, cancel)
- internal/events/events.go: deleted
- internal/session/manager.go: SetEventQueue -> SetEventBus; all
  publish sites updated to use eventbus constants
- internal/p9/server.go: fid gains eventCh/eventUnsub fields; Topen
  subscribes, Tread blocks on channel, Tclunk/serve-defer cancel
- cmd/anvilsrv/main.go: wired to SetEventBus

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 09:38:14 +01:00
Levi Neely 2d31b40037 Stop auto-archiving PROMPT_RESPONSE messages
Remove the inbox processing loop that auto-completed PROMPT_RESPONSE
messages, so they now stay in the user's inbox like all other types.
Update message.go grouping and SKILL.md docs accordingly.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-02-22 09:15:10 +01:00
Levi Neely 536b358006 Sort session list by creation time (newest first)
Backend changes:
- Add CreatedAt() to Session interface
- Implement CreatedAt() in tmux.Session (field already existed)
- Sort Manager.List() by creation time descending

Benefits:
- Deterministic ordering (no more random map iteration)
- Newest sessions appear first (most useful)
- All clients benefit immediately
- head -1 now reliably gets most recent session

README:
- Update example to use head -1 for newest session
- Document that list is sorted newest first
2026-02-19 23:51:10 +01:00
Levi Neely e1fc56f213 Improve event system: add initial state event and rename exited to killed
- Emit initial state change event (stopped -> starting) when session is created
- Rename 'exited' state to 'killed' for clarity
- Remove duplicate killed event emission (Close() already emits via transitionToLocked)
- Set OnStateChange callback in NewManager to emit state change events
- All state changes now properly emit events via callbacks
2026-02-19 20:29:43 +01:00
Levi Neely 65be761262 Fix event system: wire state changes to OnStateChange and fix /events 9p read
- Wire all state changes in tmux session to use transitionToLocked (triggers OnStateChange)
  - Close() exited state
  - Refresh() stopped states (intentional stop, restart spam prevention, auto-restart failure, PID=0)
- Add event callbacks to mailbox manager for send/receive events
  - Callbacks fire when message removed from outbox (send) and delivered to inbox (receive)
  - Consistent with state change callback pattern
- Fix /events 9p read handler to respect offset/count
  - Prevents infinite read loop by properly signaling EOF
  - Uses readFile() pattern like /list for consistency
2026-02-19 20:18:55 +01:00
Levi Neely 4c79fc796c Add 9P event queue infrastructure
- internal/events: new package with Queue supporting Push/Read/Ack and 2-min TTL
- internal/p9: expose /events file (read returns JSON lines, write accepts ack)
- internal/backend/tmux: add OnStateChange callback to Session
- internal/session: add OnStateChange callback to Manager

No events are emitted yet - infrastructure only.
2026-02-19 18:56:24 +01:00
Levi Neely 7089aa96fb Make inbox notification more action-oriented
- Change from 'check inbox' to 'You have a new message'
- Add 'respond appropriately' to emphasize action needed
2026-02-18 22:10:43 +01:00
Levi Neely 3515f51151 Replace all 9p command references with MCP tools
- Updated anvillm-communication skill to use MCP tools
- Changed session.go to instruct agents to use send_message
- Updated manager.go to tell agents to use read_inbox
- Updated Claude hook to mention read_inbox tool
- Cleaner, more consistent interface across all documentation
2026-02-18 21:49:35 +01:00
Levi Neely 937ad83e97 Remove deprecated endpoints and fix mailbox auto-completion
- Fix PROMPT_RESPONSE messages not auto-completing
- Remove deprecated message types (LogInfo, LogError, StatusUpdate)
- Remove entire chat log system (replaced by audit log)
- Migrate user prompts to mailbox system in main.go
- Remove {id}/in and {id}/out 9P endpoints
- Only mail processor uses sess.Send() directly
- Fix file index constants after removing in/out files
- Remove unused SendCtl function
2026-02-17 23:06:07 +01:00
Levi Neely 67c3133ff8 dead letter 2026-02-17 22:14:55 +01:00
Levi Neely 314d347e76 Add centralized audit log system
- Created internal/audit package for centralized logging
- Replaced per-session log files with single agent/audit file
- Updated all UIs (TUI, web, Emacs) to use centralized audit log
- Modified mailbox manager to log all message deliveries with aliases
- Updated Alog script to stream centralized audit log
- Removed session-specific log streaming in favor of global audit log
2026-02-17 22:07:39 +01:00
Levi Neely 45356673ec Update mailbox message types and validation 2026-02-17 16:32:20 +01:00
Levi Neely e227aee097 Add persistent message types to communication system 2026-02-17 16:11:34 +01:00
Levi Neely fa127f1d44 Reduce idle window from 30 to 15 seconds before prompting agents 2026-02-17 14:40:21 +01:00
Levi Neely 35b3ff338e Fix 9p-read-inbox to strip .json extension when marking messages complete 2026-02-17 14:37:46 +01:00
Levi Neely 50f8cde2ee Remove reserved flag and fix state transitions
- Remove reserved flag and all reservation logic (unnecessary for kiro-cli)
- Fix session ID file creation: detect kiro-cli runs directly in pane
- Add retry loop for FindBackendPID with kiro-cli detection
- Update hooks to use PPID's parent (kiro-cli PID) instead of 15569
- Remove 5-second delay from running->idle transition
- Clean up workflow scripts: remove explicit skill references and communication protocol sections
- Update researcher roles to use knowledge base, web, and codebase
2026-02-16 23:07:35 +01:00
Levi Neely 825ce1e415 Implement state machine improvements with reservation system and condition variables 2026-02-16 20:26:50 +01:00
Levi Neely 9d58f8a9fc fix(session): synchronous message delivery with proper retry handling
- Drain all outbox messages in batch instead of one per tick
- Process inbound messages synchronously to ensure delivery before completion
- Keep failed messages in inbox for retry instead of re-delivering
- Simplify control flow with early continue pattern
2026-02-16 17:12:44 +01:00
Levi Neely e95c9ad8cd Simplify idle transition via mailbox
Message to user now triggers idle state automatically.
Removed separate idle signal instruction from prompts.
Single action (send to user) replaces two-step process.
2026-02-16 15:11:39 +01:00
Levi Neely 7b950c4eef Add user mailbox for unified communication
- Add agent/user/ directory with inbox/outbox/completed
- User is first-class participant (not a session)
- Bot->user: bot writes to outbox with to="user"
- User->bot: user writes to user/outbox with to="{session-id}"
- User inbox messages written to sender's log file
2026-02-16 15:05:51 +01:00
Levi Neely 51679e5661 Implement mailbox system for bot-to-bot communication
- Add mailbox manager with inbox/outbox/completed structure
- Expose mailboxes via 9P filesystem (agent/{id}/inbox, outbox, completed)
- Mail processor runs every 5s to deliver messages from outbox to inbox
- Messages delivered when recipient is idle, formatted and sent via in file
- Retry logic: 3 attempts max, then discard with notification to sender
- Race condition fixes: messages moved to completed before sending
- Auto-generate message ID and timestamp if missing from bot's JSON
- Update peer-bot skill to use mailbox system with JSON format
- Update all workflows (DevReview, DevReviewQA, Planning) with:
  - Explicit shell command examples for sending messages
  - plan9 task for all agents
  - Mailbox instructions without markdown code blocks
- Fix idle signaling: bots must write summary to out BEFORE signaling idle
- All messages archived in completed/ with proper metadata
2026-02-15 21:16:00 +01:00
Levi Neely 873f839278 Implement layered sandbox configuration system
- Add global.yaml base config (renamed from sandbox.yaml)
- Add backend-specific configs (claude.yaml, kiro-cli.yaml)
- Add role configs (developer, reviewer, tester, architect, etc.)
- Add task configs (git, docker, go, rust, python, nodejs, etc.)
- Implement config merging: global + backend + role + tasks
- Update workflows to use roles and tasks
- Create tester role with read-only source, execute-only bins
- Fix reviewer role to use rox for bin directories
- Auto-create RW directories that don't exist
- Make backend configs required (fail if missing)
- Update mkfile to install cfg files to ~/.config/anvillm
- Remove Role-Based Sessions from IDEAS.md (now implemented)
2026-02-15 18:57:55 +01:00
Levi Neely 460a6fd75f support multiple backends per Assist instance 2026-02-10 22:02:15 +01:00
Levi Neely 6cb61a7a32 debug mode, don't print to main window, rename go module and main window 2026-02-10 21:45:27 +01:00
Levi Neely 7ca987e6eb refactor in progress 2026-02-09 19:45:42 +01:00