Skip to content

refactor(fleet): replace dropbox protocol with universal inbox#637

Merged
Wirasm merged 2 commits intomainfrom
feature/universal-fleet-inbox
Mar 19, 2026
Merged

refactor(fleet): replace dropbox protocol with universal inbox#637
Wirasm merged 2 commits intomainfrom
feature/universal-fleet-inbox

Conversation

@Wirasm
Copy link
Copy Markdown
Owner

@Wirasm Wirasm commented Mar 18, 2026

Summary

Replace the complex dropbox messaging system (2,100 lines with task IDs, history.jsonl, flock locking, ack files) with a simpler file-based inbox protocol at ~/.kild/inbox/<project_id>/<branch>/. Net deletion of ~2,100 lines.

Changes

  • Delete dropbox.rs and its CLI commands (check-queue, report)
  • Add inbox.rs with streamlined read_inbox_state() and generate_prime_context()
  • Extract fleet instruction generation into fleet_instructions.rs
  • Simplify Claude hooks: remove Stop prompt hook, SessionStart auto-prime, check-queue from TeammateIdle, report from TaskCompleted
  • Rewrite inbox/inject/prime CLI commands for the new protocol
  • Add inbox path helpers to kild-paths

Files Changed

30 files changed

File list
  • .claude/agents/kild-brain.md
  • .claude/skills/kild/SKILL.md
  • CLAUDE.md
  • crates/kild-core/src/agents/mod.rs
  • crates/kild-core/src/agents/registry.rs
  • crates/kild-core/src/agents/types.rs
  • crates/kild-core/src/sessions/create.rs
  • crates/kild-core/src/sessions/daemon_request.rs
  • crates/kild-core/src/sessions/daemon_spawn.rs
  • crates/kild-core/src/sessions/destroy.rs
  • crates/kild-core/src/sessions/dropbox.rs (deleted)
  • crates/kild-core/src/sessions/fleet.rs
  • crates/kild-core/src/sessions/inbox.rs (new)
  • crates/kild-core/src/sessions/integrations/claude.rs
  • crates/kild-core/src/sessions/integrations/fleet_instructions.rs (new)
  • crates/kild-core/src/sessions/integrations/mod.rs
  • crates/kild-core/src/sessions/mod.rs
  • crates/kild-core/src/sessions/open.rs
  • crates/kild-daemon/src/hooks/mod.rs
  • crates/kild-paths/src/lib.rs
  • crates/kild/src/app/daemon.rs
  • crates/kild/src/app/misc.rs
  • crates/kild/src/app/mod.rs
  • crates/kild/src/app/tests.rs
  • crates/kild/src/commands/check_queue.rs (deleted)
  • crates/kild/src/commands/inbox.rs
  • crates/kild/src/commands/inject.rs
  • crates/kild/src/commands/mod.rs
  • crates/kild/src/commands/prime.rs
  • crates/kild/src/commands/report.rs (deleted)

Testing

  • cargo fmt --check passes
  • cargo clippy --all -- -D warnings passes
  • cargo test --all passes
  • cargo build --all passes

Remove the complex dropbox messaging system (task IDs, history.jsonl,
flock locking, ack files) in favor of a simpler file-based inbox
protocol at ~/.kild/inbox/<project_id>/<branch>/.

Key changes:
- Delete dropbox.rs (2,100 lines) and its CLI commands (check-queue, report)
- Add inbox.rs with streamlined read_inbox_state() and generate_prime_context()
- Extract fleet instruction generation into fleet_instructions.rs
- Simplify Claude hooks: remove Stop prompt hook, SessionStart auto-prime,
  check-queue from TeammateIdle, and report from TaskCompleted
- Rewrite inbox/inject/prime CLI commands for the new protocol
- Add inbox path helpers to kild-paths
@Wirasm
Copy link
Copy Markdown
Owner Author

Wirasm commented Mar 18, 2026

PR Review Summary — 5 Specialized Agents

Critical Issues (3 found)

Agent Issue Location
code-reviewer forward_to_brain overwrites brain's task.md — every worker Stop event clobbers the brain's current task assignment via write_task("honryu", ...). The Claude Code inbox delivery (line 329) already delivers the message; this file write is a data corruption bug. kild-daemon/src/hooks/mod.rs:314-325
code-reviewer kild prime --json always outputs fleet: [] — hardcoded empty vec where old code populated from context. Silent data regression for scripted consumers. kild/src/commands/prime.rs:81-87
silent-failure-hunter handle_all_prime collects errors but always returns Ok(()) with zero exit code. Brain running kild prime --all gets truncated output with no indication of failures. Should mirror handle_all_inbox error pattern. kild/src/commands/prime.rs:195-202

Important Issues (5 found)

Agent Issue Location
silent-failure-hunter read_inbox_state silently converts ALL I/O errors (permission denied, hardware) into "unknown" status. Should only swallow NotFound, warn on other errors. kild-core/src/sessions/inbox.rs:134-137
silent-failure-hunter forward_to_brain spawn_blocking JoinHandle dropped — panics in brain forwarding are completely silent. Should await and log. kild-daemon/src/hooks/mod.rs:303-353
silent-failure-hunter ensure_inbox status file write failure only emits warn! (needs -v), no eprintln! like the directory creation failure above it. kild-core/src/sessions/inbox.rs:77-84
code-reviewer write_task returns Result<Option<()>, String> — breaks project error contract requiring thiserror types with KildError trait. Should use SessionError. kild-core/src/sessions/inbox.rs:98
code-reviewer _is_brain parameter accepted but ignored in ensure_inbox — dead API surface violating YAGNI. kild-core/src/sessions/inbox.rs:48

Suggestions (6 found)

Agent Suggestion Location
type-design Introduce WorkerStatus enum (Idle, Working, Done, Blocked, Unknown) instead of free String for InboxState::status. Prevents misspelling/casing issues. inbox.rs:24
simplifier Extract build_fleet_entries() and render_fleet_table() helpers — identical construction loop appears verbatim in both generate_prime_context and generate_status_table. inbox.rs:222-236, 294-308
simplifier Flatten write_task return type from Result<Option<()>, String> to Result<bool, String>Option<()> carries no info, bool expresses "wrote or not" directly. inbox.rs:98-117
simplifier Remove _resolved wrapper functions — merge path resolution into primary read_inbox_state and generate_prime_context functions. Every caller resolves paths just to call these. inbox.rs:334-351
simplifier Three write_*_fleet_instructions functions are structurally identical (only file path and log label differ) — extract a shared helper. fleet_instructions.rs:89-133
silent-failure-hunter upsert_fleet_section silently appends when begin marker exists but end marker is missing (corrupted file). Should warn about corrupt markers to prevent snowballing duplicate sections. fleet_instructions.rs:189-191

Documentation Issues

File Issue Fix
README.md:296-309 Section still says "dropbox" — "Inspect fleet dropbox state" Change to "Inspect fleet inbox state"
README.md:304-307 Lists removed --task, --report, --status flags for kild inbox — users will get clap errors Remove; only --json and --all remain
README.md:313 kild prime note references removed "protocol" section Change to "Output current task + fleet status as a markdown blob"
.claude/skills/kild-wave-planner/SKILL.md:86 Maps core.fleet label to deleted dropbox.rs Change to inbox.rs

Strengths

  • Massive net deletion (-2,105 lines) — the new inbox protocol is dramatically simpler
  • inbox.rs:61-71 — directory creation failure correctly handled with both warn! + eprintln!
  • inject.rs:57-67 — inbox write failure treated as warning allowing Claude inbox fast-path fallback
  • inject.rs:104-110 — missing daemon_session_id produces specific, actionable error message
  • fleet_instructions.rs:75-86 — all instruction write failures emit both warn! + eprintln!
  • Clean separation of fleet instructions into dedicated fleet_instructions.rs module

Type Design Scores

Type Overall Notes
InboxState 6/10 status is unvalidated String; all fields pub with no constructor
FleetEntry 6/10 Construction duplicated; untyped status strings
AgentType (modified) 9/10 Clean simplification removing unused supports_inbox()
KildPaths inbox methods 8/10 Well-encapsulated path construction

Verdict

NEEDS FIXES — 3 critical issues (brain task clobber, empty fleet JSON, silent prime errors) must be addressed before merge. The 5 important issues should also be fixed. The refactoring direction is excellent and the simplification is well-motivated.

Recommended Actions

  1. Remove or redirect write_task("honryu", ...) in forward_to_brain — it silently corrupts the brain's active task
  2. Populate fleet field in PrimeOutput for --json path
  3. Mirror handle_all_inbox error pattern in handle_all_prime
  4. Narrow unwrap_or_else in read_inbox_state to only catch NotFound
  5. Address remaining important issues and consider type/simplification suggestions

Critical fixes:
- Remove write_task("honryu",...) from forward_to_brain that clobbered
  the brain's task.md on every worker Stop event
- Populate fleet entries in kild prime --json (was always empty vec)
- Surface errors in handle_all_prime (was silently returning Ok)

Error handling fixes:
- Narrow status file read to only swallow NotFound, warn on other I/O errors
- Await spawn_blocking JoinHandle in forward_to_brain to catch panics
- Add eprintln for inbox status init failure (was warn-only)

Simplification:
- Remove unused _is_brain parameter from ensure_inbox
- Flatten write_task return from Result<Option<()>> to Result<bool>
- Extract build_fleet_entries() and render_fleet_table() helpers
- Merge _resolved wrappers into primary read_inbox_state/generate_prime_context
- Extract write_fleet_instructions_to() shared helper
- Warn on corrupt fleet instruction markers (begin without end)

Docs:
- Fix README.md stale dropbox references and removed --task/--report/--status flags
- Fix wave planner skill referencing deleted dropbox.rs
@Wirasm Wirasm merged commit c408649 into main Mar 19, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant