The Hive: Collaboration Without Shared-File Chaos

Once Munder Difflin can show several terminal processes, a harder question appears: how can those processes exchange work without corrupting one another's state or losing the history of a decision? This chapter examines the local hive as that shared substrate. By tracing ownership, message delivery, and recovery, we can see why collaboration in Munder Difflin is built from small durable artifacts and routing rules rather than from agents freely editing one another's workspaces.

Ownership comes before communication

The hive is a local Git repository, but calling it a repository is not enough to explain its role. It is simultaneously a roster, a memory store, a mailbox system, a planning surface, a task ledger, and an activity record. Each agent has a private directory containing identity and memory information, an inbox for messages addressed to it, an outbox for messages it wants to send, and a cursor that records what it has processed. The hive also contains shared planning and logging state.

The crucial rule is ownership. An agent writes inside its own directory. It does not reach into another agent's inbox, change another worker's memory, or run Git commits concurrently with its peers. The main process watches outboxes, moves messages into recipient inboxes, appends structured events, and acts as the single committer. The board has an even stricter social rule: Michael is the scribe for the shared plan, so several agents do not simultaneously rewrite a document whose meaning depends on a coherent whole.

This is a deliberately conservative design for concurrent software. A shared database could offer transactions, queries, and a central delivery queue. The file-backed hive instead makes state inspectable with ordinary tools and gives each write a clear owner. A worker can leave a durable note without needing a database connection. An operator can inspect the board or event history on disk. A message can be archived rather than disappearing after it is consumed. The price is that polling, file operations, Git locks, malformed artifacts, and repository growth become part of the system's operational life.

The design also avoids a common category error: a shared workspace is not the same as shared state. Workers may operate on the same project or related worktrees, but coordination data still has an owner. Separating the two reduces the chance that two agents will race over a mailbox or that a Git index will be damaged by simultaneous commits. It does not prevent two agents from making incompatible changes to a project; that remains a task and integration problem for Michael and the human to resolve.

What the hive remembers

The different artifacts answer different questions, and combining them into one vague “shared context” would make the system harder to reason about.

The registry says who is on the floor, what role or provider they have, whether they are the orchestrator, and whether a terminal is still active. It is about identity and presence. An agent's memory is for durable facts, decisions, and context that should survive a turn. It is not a complete transcript, and the system deliberately keeps raw operational files out of semantic memory when indexing is enabled.

The board is the shared, human-readable plan. The task ledger is structured work state: assignment, dependencies, status, priority, and outcomes. A task can carry a question and answer from the human, keeping a decision trail attached to the work it unblocked. The append-only log records events such as spawns, routing, or failures in a form the floor and later diagnosis can use. Git history supplies a persistence and audit layer across these changes, but it does not decide whether a task is correct or whether an agent's implementation should be merged.

The distinction matters in practice. If a worker says “the build fails because the configuration expects a missing variable,” that fact belongs in its memory or in a message to Michael. If Michael assigns the worker to investigate, the task ledger records ownership and status. If the operator changes the scope, the board or task's human-feedback trail records the decision. If a message is delivered, the log can record the actual recipient rather than merely the sender's intention. Each artifact narrows a different kind of uncertainty.

How a message moves

A hive message is more structured than a line of chat. It carries a sender and recipient, a conversation identity, a speech-act-like type such as request, query, inform, or done, a subject and body, whether a reply is required, a hop count, a human-escalation flag, and a creation time. Those fields let the router distinguish a request that needs a response from an informational update that can terminate a thread. They also make the activity visible without requiring the operator to read every message body immediately.

The sender writes one message file into its own outbox. The main-process router reads that file, normalizes missing defaults, and treats the owning directory as the authoritative sender. It resolves special recipients such as the human proxy through Michael, selects active broadcast targets, and attempts delivery. For a provider that can safely participate in inbox delivery, the router writes an individual JSON file into the recipient's inbox using a temporary file and an atomic rename. It then records what happened and archives the sender's original file so the same message is not processed again.

Atomic delivery is a small but important guarantee. A recipient should see either a complete message file or no message file, not half of a JSON document while another process is reading it. The single-committer rule then serializes the corresponding Git history. The resulting record does not make delivery instantaneous, but it makes the boundary inspectable: there is a message, a target, an outcome, and an archived trail.

The message's arrival is not the same as the worker's receipt of its meaning. The recipient's process must reach a safe point, inspect the inbox, act on the message, and move handled files into an archive folder. The cursor prevents an already processed identifier from being treated as new. In this design, the inbox is durable coordination state, while the later terminal write is a separate controlled action. That separation becomes essential when a worker is busy or when a person is typing into the same terminal.

Delivery has explicit failure branches

flowchart LR A[Worker outbox] --> B[Main-process router] B --> C{Safe inbox capability?} C -->|yes| D[Atomic recipient inbox write] C -->|no| E[Terminal work-order handoff] D --> F[Delivery log and single Git commit] F --> G[Cursor, inbox archive, guarded wakeup] E --> H{Handoff succeeds?} H -->|yes| G H -->|no| I[Bounce to Michael and log failure] B --> J{Missing inbox or hop limit?} J --> I

The “safe inbox capability” decision is provider-aware. A provider with lifecycle hooks or a supported bridge can receive a durable inbox message that the guarded delivery path will later drain. A hookless provider cannot safely promise that an inbox file will be noticed at an idle prompt, so the renderer can queue a terminal work order instead. If that handoff cannot be made, the message is bounced to Michael rather than silently discarded. Proxy-tier providers may also use a terminal path because a synthesized event can observe a turn without injecting a safe stop reason into the provider's interface.

This is why a routed message should not be described simply as “sent.” The router logs actual recipients, not only intended targets. An unknown recipient or missing inbox is a failure path. A provider can be present in the roster but unable to receive this kind of mail. A message may be safely waiting for a worker's terminal to become idle. These states are different, and Munder Difflin's value depends on not presenting them as one green check mark.

The same principle applies to broadcast. Fan-out is selected from active agents, while archived workers and send-only helper roles are excluded. The router avoids delivering a message back to its sender. A message aimed at an assistant that cannot drain an inbox is bounced to Michael. These rules are not ornamental edge cases; they protect liveness by refusing to create a durable message with no legitimate consumer.

Liveness and idempotence are separate problems

A collaboration system can fail in at least two opposite ways. It can do the same work repeatedly, or it can do no work because a message is waiting in a place no process checks. The hive addresses these with different mechanisms.

The hop cap limits ping-pong. Only certain message types obligate a reply, and every reply advances a hop count. If two agents keep asking each other for clarification, the message cannot circulate indefinitely; the orchestrator becomes the point where the loop is stopped or escalated. This is a semantic guard on conversation behavior.

The cursor limits reprocessing. If a process restarts after reading a message, its last processed identifier tells it where it stopped. Moving handled files into an inbox archive preserves history without leaving them in the unread path. This is an idempotence aid for file consumption, not a solution to agents disagreeing about the work itself.

The wake path addresses the opposite failure: a valid message is waiting, but the worker has reached an idle prompt and no event causes it to look again. Munder Difflin keeps the message durable and uses guarded idle delivery plus a main-process watchdog to re-engage an eligible worker. The watchdog rechecks the inbox before nudging, so a stale observation does not cause a needless duplicate prompt. It also respects controls such as pause and halt. A Stop event alone is not treated as permission to force mail into a human-controlled or still-unsafe turn.

Together, these mechanisms define a more careful notion of autonomy. The hive does not assume that an agent is available merely because its registry entry exists, or that a file has been acted on merely because it was written. It tracks identity, delivery, consumption, and wakeup as separate transitions. That extra bookkeeping is the cost of making parallel work recoverable.

What single-committer Git gives up

The file-backed design is attractive because it is legible. Plain files are easy for agents to read and append to, easy for an operator to inspect, and easy to preserve in a local history. A single committer avoids concurrent index-lock corruption and gives the system one place to retry or recover from a stale lock. Atomic renames protect individual message writes. Archived files preserve an audit trail instead of forcing a database administrator to reconstruct what happened.

But inspectability is not the same as transactional coordination. A local Git repository can become a bottleneck when many changes arrive, and a poll-based router introduces delay and repeated scanning. Malformed outbox files need quarantine. High-churn or sensitive files must be ignored or kept out of history, because committing everything would turn private provider state or raw output into permanent repository data. The design documents these risks rather than claiming that Git is a universal message bus.

There is also a social bottleneck. Making Michael the board's sole scribe avoids conflicting plan edits, but it concentrates interpretation in the orchestrator. If Michael misunderstands a worker's report or records an incomplete task state, the single-writer rule prevents competing edits but does not make the judgment correct. The human can inspect the evidence and intervene; the architecture does not eliminate the need for that oversight.

This balance is central to Munder Difflin's operating model. It chooses a slower, more visible set of local transitions over an opaque shared service. The choice works when the operator values inspectability, recoverable history, and clear state ownership, and when the team size and message volume remain compatible with file-backed coordination. It becomes less comfortable as high-frequency state, many providers, or large histories push the repository toward the limits the design itself acknowledges.

The hive therefore solves one problem while exposing the next. It can place a complete request in the right durable location and tell Michael when delivery failed, but it still must decide when that request may safely enter a live terminal. The following chapter moves from the mailbox to the prompt boundary, where automatic coordination meets human typing, provider lifecycle, and operator control.

References