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

Two Chiefs

~12 min · roles, delegation, architecture, coop

Level 0Visitor
0 XP0/33 lessons0/11 achievements
0/100 XP to next level100 XP to go0% complete

Two Conversations Called Chief

Read cwkPippa's code for long enough and you meet the word chief in two places that have almost nothing to do with each other. One is Master Chief, the subject of this quest. The other is the Coop chief, a back-office reviewer that cwkCoop wakes when work owes an outcome. Both are Pippa. Both are owned by Dad. Both are called chief of staff somewhere in their own text. If you conflate them you will misread every lesson in this track, so this lesson puts them side by side.

Master Chief: the Room

Master Chief is Dad's human-facing room. It is one conversation, found by its external id master-chief:dad:pippa, and every doorway resolves to it: the WebUI, the Pippa app, the watch, Telegram, the panels inside family apps. Dad speaks there; any of the seven brains may answer the next turn, replaying the stored conversation (live rows plus the summary that replaced the oldest). She delegates from there, through the coop tool, and only on Dad's direct request. Reports come back there: Coop's lines, follow-up results, scheduled tasks' outcomes. It never ends, so it never rotates. It compacts between turns instead, keeping up to the newest 40 rows verbatim (Track 4), because its continuity is the point.

The Coop Chief: the Back Office

The Coop chief is an ordinary Pippa conversation filed under Coop's own binder, with the context key coop:chief:main. Dad sees it in the Coop workspace's Sidekick, but he does not drive it. The engine does. Coop's ChiefRunner wakes it with a list of obligations, outcomes that some piece of work owes (at most 50 per wake), and the wake is a scoped backend turn: This is a backend wake from the cwkCoop engine, not a new message or permission from Dad. Its tools are three read-only ones, sidekick_host_read, sidekick_host_status and sidekick_host_search, with the shell off. It reads each record whole and answers with a [COOP_DECISIONS] JSON envelope that the engine validates against its current authority before anything happens.

That authority is wide on purpose. Since 2026-09-30 the Coop chief is Dad's proxy over Coop work, bound by default with every disposition Dad could record: defer, escalate, park, close (with self-contained evidence), release, abandon, adopt a legacy take, assign open work to an enrolled session, retire an idle enrollment, resend an envelope that provably never arrived. It is also on a short leash: no more than 12 new reviews may start in an hour, an obligation the answer forgot is looked at again after 15 minutes, and it never closes work from idle status, elapsed time or silence.

Side by Side

Master ChiefCoop chief
Found byexternal id master-chief:dad:pippacontext key coop:chief:main under the coop binder
Who speaks to itDad, from every doorwaythe Coop engine, in scoped backend wakes
What wakes itDad sending a messageowed obligations, at most 50 per wake
Its power over Coop workthe coop tool: read, add, run, reply, cancel; mutations only on Dad's direct requestdispositions as Dad's proxy: defer, escalate, park, close, release, abandon, adopt, assign, retire, resend
How it answersin conversation, to Dada [COOP_DECISIONS] envelope; reasons in English, for_dad lines in Korean
Toolsthe family tools of a Dad turnthree read-only host tools; shell off
Rateone turn at a time, in orderat most 12 new reviews per hour
Growthendless; compacts, keeps up to the newest 40 rows verbatimrotates to a fresh conversation once it has 40 wakes and a tick has no review to run
Reportsreceives themsends escalations and parks to Dad, which land in Master Chief

Same Pippa, Same Guard

Both conversations belong to soul pippa and owner dad; the Coop wake door refuses any conversation that is not exactly its own (Coop wake requires its own active Pippa chief conversation). And both run their turns through the same serialization guard, app.streaming.chief_turn, which waits while that conversation is streaming, has a scheduled job's turn active, or is already inside another chief turn. Master Chief's FIFO lock enters it; so does every Coop wake. The guard is per conversation, so the two chiefs never block each other. What it prevents is a backend turn interleaving with a live one in the same room.

Why One Rotates and One Compacts

Both face the same arithmetic: Pippa replays the stored conversation on every turn (its live rows, plus a summary once compaction has replaced the oldest), so a conversation that only grows costs more each time. The Coop chief's answer is rotation. Once the conversation has 40 wakes, the runner binds a fresh one under the same context key at its first tick with no review to run, so the Sidekick opens the new one. In a busy stretch, one review after another, the old conversation can take a few more wakes before that quiet tick comes. Its docstring gives the measurement that forced it: 152 messages after three days. Rotation is safe there because the Coop chief's memory is not the conversation. It is Coop's ledger: every wake reads the obligations, reports and worker notes fresh. Master Chief cannot rotate, because Dad's thread with her is the memory. So she compacts, and Track 4 shows what that took.

Where They Meet

The two chiefs never talk directly. When the Coop chief escalates or parks an obligation, its decision may carry for_dad: two or three plain lines in Korean saying what is blocked, the proposal, and the one decision it needs from Dad. Coop turns that into a notification, 📣 chief escalation or 🅿️ parked for Dad, and it travels the road from Lesson 2: notify door, Master Chief line, Telegram once. Dad is asked once; a repeat of the same question with no new evidence is recorded but not sent. The Coop Quest's Track 6, Obligations and the Coop Chief, is where its decisions are taught in depth.

Same identity, different roles, different authority. Master Chief is where Dad speaks and where the news arrives. The Coop chief is where owed work is disposed of. Keep the room and the back office separate, and neither one's growth or authority leaks into the other.

Code

How each chief is recognized (services/master_chief.py and services/coop_wake.py, verbatim excerpts)·python
# Master Chief: one row, by external id
def is_chief(conversation: ConversationRow | None) -> bool:
    # getattr: the payload builders take duck-typed rows (tests hand them a
    # namespace), and a row without the column is simply not the Chief.
    return bool(conversation and getattr(conversation, "external_conversation_id", None) == EXTERNAL_ID)

# The Coop chief: an ordinary conversation under the coop binder
async def require_conversation(cid):
    from routes import sibling_binder
    await sibling_binder.store.init_db()
    conv=await sibling_binder.store.get_conversation(cid)
    if (conv is None or conv.trashed_at or conv.origin_surface!='coop' or conv.context_key!='coop:chief:main'
            or conv.soul_id!='pippa' or conv.owner_user_id!='dad'):
        raise HTTPException(403,'Coop wake requires its own active Pippa chief conversation')
    return conv
The Coop chief's limits and its rotation (cwkCoop chief.py, trimmed excerpt)·python
UNMENTIONED_SECONDS=900
HOURLY_BUDGET=12
ROTATE_AFTER=40

class ChiefRunner:
    async def rotate(self,role):
        """Start a fresh chief conversation after ROTATE_AFTER wakes.

        Pippa replays a conversation in full on every turn, so a chief
        conversation that only ever grows makes each wake cost more than the
        last (152 messages after three days). The binder keeps the same
        context key, so Dad's Sidekick opens the new conversation.
        """
        ...

# Chief.prepare, paraphrased: no new review once HOURLY_BUDGET runs started in the last hour,
# and at most 50 due obligations per wake:
#   SELECT count(*) FROM engine_chief_runs WHERE created > now - 3600      (>= 12: wait)
#   SELECT id FROM engine_obligations WHERE status='pending' AND due <= now ORDER BY due, id LIMIT 50

External links

Exercise

Find a place in your own system where one name covers two jobs: a user account that both a person and a cron job log in as, a bot that both answers people and runs maintenance, a service account with every permission. Write a two-column table like the one in this lesson for it: who speaks to it, what wakes it, what it may change, how it answers, how its history grows. Then decide which column should become its own identity.
Hint
The tell is usually the growth row or the authority row. If one job needs its history kept forever and the other only needs the current state, or one job needs to change things and the other only to read, they want different identities even if the same code serves both.

Progress

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

Comments 0

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

No comments yet — be the first.