Skip to content

[coordination] Ticket 2 — make coding work visible to a supervisor (domain writes) #206

Closed

Description

@serge-ivo

Follow-on to #205. That ticket gives the supervisor a reader over generic platform records. This one makes the coding domain write enough into those records for the reader to see it — the other half of "the domain writes into a generic record; the supervisor reads platform records."

No supervision-side change is needed for any of this, which is the evidence the boundary is right.

A. A human-driven coding session is invisible

Starting a session from the Coding tab writes only coding_sessions. It creates no board card and no loop run, so a Lead cannot answer "is anyone working in the API repo right now" — the most common case, and half of what the hardcoded Overseer assembles per repo (routes/coding.ts:1122-1131).

Fix: lib/coding-board.ts (new, pure, mirroring lib/delegation.ts) emits a generic record —
codingSessionTaskRecord({sessionId, repoName, engine, status, now}) → id csess-${sessionId}, type coding.session, title Coding: ${repoName}. Precedent three lines away: routes/coding.ts:760 already writes an engine.signin card via mirrorRuntimeTask.

No column declaration needed — coder-repo declares no boardColumns, so defaultBoardColumns(["coding"]) already maps running→"Running" and completed→"Done".

The trap, and the reason this ticket exists separately. A session leaves active in four places, and only one is the end route:

  1. routes/coding.ts:1336 — endSession
  2. lib/coding-store.ts:403 — inside reconcileOrphanedSessions, the reaper
  3. suspendSessionsFromOtherNodes (routes/instances.ts:328) — suspends rather than ends
  4. CodingSessionWorkflow's finally — raw UPDATE coding_sessions, not via endSession

Writing the card at create and clearing it only at (1) strands a permanently "running" card on three paths — the exact failure mode this whole feature exists to remove, and the same shape as the two stranded-row bugs already memorialised in coding-session.ts:122 and :158.

Recommended: make endSession the single choke point (have the workflow call it instead of raw SQL) and mirror the card from createSession + endSession. mirrorRuntimeTask upserts on id, so re-writes are idempotent.

Note this also puts a live session on the Repo Coder's own board for the human. Confirmed wanted — a live session is exactly what belongs on a work board.

B. The Pilot never reports mid-run progress

AgentLoopWorkflow calls recordIteration per iteration (workflows/agent-loop.ts:144). CodingSessionWorkflow does not, so check_delegation and subordinate_status both report iteration: 0 for a run that has taken a dozen steps — the supervisor's only progress signal, permanently reading zero.

Fix: hoist let pilotSteps = 0 above closeDelegation, increment on the "action" branch of the existing onEvent dep, and call recordIteration when loopRunId is set. runCodingLoop already emits exactly one "action" per step (lib/coding-loop.ts:118), so no extra durable steps.

Compute the increment outside step.do — a retried step re-runs its body, and ++ inside would double-count.

A second bug rides on this. CodingSessionWorkflow runs runCodingLoop in up to 12 rounds, and runCodingLoop restarts its step counter at 0 each round. So today's terminal recordIteration(env, runId, outcome.steps) records the last round's count, not the cumulative one — it understates even at the end. Fix with Math.max(pilotSteps, outcome.steps ?? 0).

Activity

  1. serge-ivo commented on Aug 5, 2026

    @serge-ivo
    ContributorAuthor

    Shipped in 75e2d51 (deployed).

    Verified live, both halves of the acceptance criterion:

    1. Started a coding session by hand on the FWS Repo Coder (no delegation). A Coding: fws/platform card appeared in Running on its board.
    2. Asked the Coder Lead "is anyone working in the FWS repo right now?" — it answered from **one subordinate_status call and zero delegate_goal calls** (tool log in instance_messages`), correctly reporting FWS as having a live coding session and FAS/FGS as idle. Before this it had no way to see a human-driven session at all.
    3. Ended the session — the same card moved to Done. No duplicate, no stranded running.

    Supervision still reads only platform records; the coding domain writes the generic one. Also fixed en route: the Pilot workflow's raw UPDATE … WHERE status = 'active' silently skipped suspended, so a Pilot finishing after a --force takeover elsewhere left its session suspended forever with nothing to close it — it now goes through endSession. And recordIteration now fires mid-run, so a supervisor no longer reads "iteration 0 of 10" for a run a dozen steps deep.

  2. serge-ivo commented on Aug 5, 2026

    @serge-ivo
    ContributorAuthor

    Correction: the commit is 14828f3, not the hash in my previous comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions