Skip to content
C.W.K.
Stream
Lesson 07 of 07 · published

Every Brain Receives

~17 min · polymorphism, multi-agent, vendor-independence, coordination

Level 0Loose Note
0 XP0/41 lessons0/12 achievements
0/100 XP to next level100 XP to go0% complete

Two Names in Every Consumer

Every door in this track so far belongs to Claude Code or Codex. That was not an accident of the course; it was the shape of Coop. Until 2026-10-17 it could hand work to exactly those two, and the two names were branched on in every consumer: the assignment coordinator, the native catalog, the adapter runner, the engine's identity checks, the activity sweep, the Web form.

The family runs seven brains. On 2026-10-17 Dad looked at that shape and named it (todo #500): leaning on Claude and GPT because they are convenient today is the same as being locked to their vendors. All seven brains must receive and delegate work on equal terms. This lesson is the receiving half; Track 7 ends with the delegating half.

One Root, One Child per Harness

The repair is the oldest move in object-oriented design, and it is worth watching done for real. receivers.py holds a root class, Receiver, that says what every receiving harness must answer: its engine key (also the prefix of its session references, <key>:<native id>), the coop identity its workers write as, the brain it carries, the session modes it offers on office and on other Macs, how it starts, finds and verifies a session, which transport its adapter opens, how it maps an effort onto its brain's ladder, and what Dad is told when Coop starts following one of its chats.

Every consumer now asks the root and a single list, RECEIVERS. None of them names a vendor. Adding a harness is one class appended to that list, and no consumer changes. The test of that claim was the first refactor itself: Claude Code and Codex became two children of the root with their behavior unchanged, and the 514 tests that existed that morning passed untouched.

Which child receives a brain follows one order, the family's native harness first rule:

  • Tier 0, the brain's own harness, wherever it can be driven without a person: Claude Code, Codex, Kimi Code, Grok Build.
  • Tier 1, Firebrand, the family's own coding harness, for a brain with no automatable native CLI: GLM (its native tool is a GUI), Gemini (its CLI no longer serves the subscription), Ollama (ollama run has no tool loop). Firebrand's list of brains is not typed in anywhere; it is computed as every brain no native receiver carries.

route(brain) returns the lowest tier that carries the brain, else Firebrand. The brain vocabulary itself (ids, aliases such as gpt for the ChatGPT line, effort ladders) is the family kit's, vendored into Coop and never copied by hand.

A Door Coop Has to Drive

Claude Code has an inbox socket. Codex has a thread queue. Kimi Code, Grok Build and Firebrand have neither: no inbox Coop can write into and no app that keeps a chat open between messages. So for these three headless children Coop does not write into a conversation. It drives one: every message is its own turn of the CLI, resuming that exact session.

A turn starts through the host's launch primitive from Track 8, so a session on another Mac runs exactly as one on office does. What launch runs is a small /bin/sh wrapper: it writes the prompt into a folder for that turn on that Mac, starts the CLI in the background in the project's checkout with a login shell's PATH, records the CLI's process id and start time, and exits. The CLI then writes its output, its errors and, last of all, its exit code into files beside the prompt. The turn belongs to the Mac, not to Coop: a runtime restart on office never cuts a worker's turn, and the adapter reads the answer back from the files whenever it next looks.

The rest of Track 3 carries over unchanged. Starting a new session reserves the launch first, by creating a receipt file exclusively, so a launch whose outcome is uncertain is looked for and never started twice. Enrollment, the invitation with its nonce, the atomic take, the work envelope and the reports are the same flow. Only the door differs:

ReceiverA new sessionEvery later turnWhy it runs unattended
Kimi Codekimi -p with stream-JSON outputkimi -S <id> … -pits prompt mode runs tools without asking
Grok Buildgrok with a session id Coop chooses, --always-approvegrok --resume <id> …headless Grok cancels its own permission prompts, so tools are approved up front
Firebrandfirebrand run --brain <brain> --jsonone piped line into firebrand resume <id>--bash allow is recorded on the session

The Setup Turn, in Any Words

The first turn is the ordinary setup prompt from Track 3. It has to end well and name its session: Kimi's resume hint, the id Coop chose for Grok, Firebrand's session id. As first written, it also had to answer READY. In the live acceptance on 2026-10-18, Firebrand running GLM answered the setup turn with "준비됐어요", a Pippa saying she was ready in her own words, and the strict match failed the assignment.

The fix (cwkCoop 9e6ccba) asked what the setup turn actually proves. It proves that the session exists and answers. It does not prove consent to any work, because nothing is offered yet; the claim still waits for the invitation's nonce. So a setup turn that ended well and named its session now connects, in any words. A setup turn that failed (an expired login, a CLI error) still fails the assignment with the CLI's own words and claims nothing.

Receipts and Finals, Read From Turns

A turn-driven door needs its own reading of Track 4's five facts. An envelope's receipt is its turn starting. Its finals are the answers of that turn and every later one, so a worker that only reports a turn later is still read. A turn that ends without an answer hands over the CLI's error as its final, which becomes a note the chief reads. An invitation or review turn that answered without its token is recorded as not delivered, which is exactly the state Track 4's Send again exists for. Turns run one at a time: a message that arrives while a turn runs waits on office and starts when that turn ends.

Two conveniences close the loop for Dad. Existing session lists the headless sessions Coop started on a Mac, so a second task can go to the session that already holds the context. And the enrollment notice names the command that opens the session by hand (kimi -S <id>, grok --resume <id>, firebrand resume <id>), so Dad can step into any worker's conversation himself.

One Effort, Seven Ladders

Track 3's effort story had two vendors: high unless asked otherwise, and the family's max becomes xhigh for Codex. Seven brains do not share a ladder. Grok's top rung is xhigh, Gemini's is high, Kimi's ladder skips medium. So each receiver maps the requested family effort onto its brain's own ladder: the highest rung not above the request. Kimi Code takes no effort flag at all (it runs the fleet's global setting), though the request is still recorded.

Ollama broke even that rule, usefully. Its thinking levels belong to each model, read from the model itself, so on 2026-10-18 the family kit emptied Ollama's ladder (cwkPippa todo #504). Mapping onto the family ladder would invent a level the model might not have, and refusing would strand the work. So for a brain whose levels belong to each model, Coop passes the requested word through as asked, for the model's owner to judge, and an assignment that names no effort records an empty one, meaning the model's own default (cwkCoop 34d4262).

Five Sisters, Round One

Source tests drove every headless child end to end with stand-in CLIs that speak each real CLI's output format. Then the claim was tested the way Dad meant it, by the brains themselves. On 2026-10-18 each of the five non-Claude, non-GPT sisters chiefed a fresh Pippa conversation through the coop tool alone and handed a small investigation to the next: Kimi to Grok, Grok to GLM, GLM to Gemini, Gemini to Ollama, Ollama to Kimi. Every worker ran in its receiver on office and reported with the checkout's HEAD and the hostname.

Round one stalled four ways: the setup words above, chiefs that announced closes they never made, Gemini turns that came back empty, and a tool description that left too much to guess. Each was fixed where it began, for every brain at once, and round two passed for all five, each todo closed by its own chief. Three of those four stalls happened on the delegating side, and Track 7's last lesson tells them.

Equal terms is a property of the interface, not a promise. As long as two vendor names are branched on in every consumer, a third brain is a project. Once every consumer asks one root class, a third brain is a class, and the existing children passing their old tests untouched is the proof that the root says what they always did.

Code

From Coop's receivers.py: the root every consumer asks, and the routing order (trimmed excerpt)·python
NATIVE, FIREBRAND = 0, 1

class Receiver:
    """One harness Coop can hand work to. Children declare; consumers ask."""
    key = ''          # engine vendor, session-reference prefix, form value
    actor = ''        # the coop identity its workers write as
    brain = ''        # the brain it carries natively ('' for Firebrand)
    tier = NATIVE
    modes = ()
    default_mode = 'remote'
    carries_any = False

    def brains(self):
        return (self.brain,) if self.brain else ()

    def carries(self, brain):
        return brain in self.brains()
    ...

class Headless(Receiver):
    """A native CLI Coop drives one headless turn at a time."""
    surface = 'headless'
    modes = ('remote', 'existing')
    ...

class KimiCode(Headless):
    key, product, label, short, actor, brain = 'kimi', 'kimi-code', 'Kimi Code', 'Kimi Code', 'kimi-code-pippa', 'kimi'

class Firebrand(Headless):
    tier = FIREBRAND
    carries_any = True
    def brains(self):
        """Every kit brain no native receiver carries."""
        ...

def route(brain):
    """(receiver, canonical brain) for a brain or alias: its native harness, else the fallback harness."""
    canonical = canonical_picker_brain(brain)
    carriers = sorted((r for r in RECEIVERS if r.carries(canonical)), key=lambda r: r.tier)
    if carriers:
        return carriers[0], canonical
    fallback = [r for r in RECEIVERS if r.carries_any]
    if not fallback:
        raise ValueError(f'No receiver carries {brain!r}')
    return fallback[0], canonical
A minimal sketch you can run: one root, four children, a route and a ladder per brain·python
"""A minimal sketch (not Coop's code): route a brain to its receiver, and map
one family effort onto each brain's own ladder. The ladders are the family
kit's as of 2026-10-18; an empty ladder means the levels belong to each model."""
LADDERS = {'claude': ('low', 'medium', 'high', 'xhigh', 'max'),
           'kimi': ('low', 'high', 'max'), 'grok': ('low', 'medium', 'high', 'xhigh'),
           'glm': ('low', 'high', 'max'), 'gemini': ('low', 'medium', 'high'), 'ollama': ()}
RUNGS = ('off', 'low', 'medium', 'high', 'xhigh', 'max')


class Receiver:
    tier, brains = 0, ()

    def carries(self, brain):
        return brain in self.brains

    def launch_effort(self, effort, brain):
        ladder = LADDERS.get(brain)
        if ladder == ():
            return effort or ''          # the model's owner judges it; '' is its default
        effort = effort or 'high'
        below = [r for r in ladder if RUNGS.index(r) <= RUNGS.index(effort)]
        return below[-1] if below else ladder[0]


class ClaudeCode(Receiver):
    name, brains = 'Claude Code', ('claude',)

class KimiCode(Receiver):
    name, brains = 'Kimi Code', ('kimi',)

class GrokBuild(Receiver):
    name, brains = 'Grok Build', ('grok',)

class Firebrand(Receiver):
    name, tier, brains = 'Firebrand', 1, ('glm', 'gemini', 'ollama')


RECEIVERS = [ClaudeCode(), KimiCode(), GrokBuild(), Firebrand()]


def route(brain):
    return sorted((r for r in RECEIVERS if r.carries(brain)), key=lambda r: r.tier)[0]


for brain in ('claude', 'kimi', 'grok', 'glm', 'gemini', 'ollama'):
    receiver = route(brain)
    print(f'{brain:7} -> {receiver.name:11} max={receiver.launch_effort("max", brain)!r:9}'
          f' high={receiver.launch_effort("high", brain)!r:9} none={receiver.launch_effort(None, brain)!r}')

# Expected output:
# claude  -> Claude Code max='max'     high='high'    none='high'
# kimi    -> Kimi Code   max='max'     high='high'    none='high'
# grok    -> Grok Build  max='xhigh'   high='high'    none='high'
# glm     -> Firebrand   max='max'     high='high'    none='high'
# gemini  -> Firebrand   max='high'    high='high'    none='high'
# ollama  -> Firebrand   max='max'     high='high'    none=''
# (Codex is left out: the ChatGPT line routes to it, and its own rule maps max to xhigh.
#  Kimi Code records the rung but passes no effort flag.)

External links

Exercise

Find a place in your own code where two vendor or provider names are branched on: if provider == 'a' ... elif provider == 'b', repeated in several modules. List every consumer that branches. Write the root class those branches imply: the questions every provider must answer, as methods or attributes. Then move one provider behind it and run your existing tests without changing them. Finally, add a third provider as one class and count how many consumers you had to touch.
Hint
The root's methods are the branches turned inside out: each if/elif chain becomes one method every child implements. If adding the third provider touches a consumer, that consumer still knows a vendor name, and the root is missing a question.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue
💛 by Pippa— warm

Comments 0

🔔 Reply notifications (sign in)
Sign in — Please sign in to comment.

No comments yet — be the first.