# Coordinator end-to-end report

Branch: `e2e-coordinator`, based on `0fa1a48`. No production writes, service
changes, push or deployment. New interface strings are individually marked
`// COPY REVIEW PENDING`; no copy-review server was started.

## Diagnosis

There is an HTTP bridge. The service calls task poll, then coordinator poll;
task poll can hold the loop for 25 seconds. The coordinator endpoints are
`POST /api/runner/v2/coordinator/{poll,claim,renew,tool,event,containment}`.
Heartbeat is `POST /api/runner/v2/heartbeat`. Coordinator requests carry
version 2 and capability `coordinator.v1`. The instance returns a fenced claim
with the selected account, context, admission ticket and deadlines. The runner
launches the provider, posts structured tool results and delivery events, then
reports containment.

Read-only evidence came from `carlos db query --app equipo --account oficina`.
The replica had advanced beyond the brief's four queued rows:

| Snapshot, UTC on 2026-11-06 | Evidence |
| --- | --- |
| 14:33:55, transaction 6000 | Binding generation 2 selects `claude-b`. Binding and runner both belong to `paul@tito.io`. Member is active at revision 1; binding member revision is 1. Connection and binding connection revisions are both 4. Neither connection nor runner is revoked. |
| 14:34:25, transaction 6004 | Generation 1 turns are superseded. The first generation 2 turn is `waiting_connection`; later turns remain queued. Every job ID is zero and every claim is empty. This proves coordinator polling reaches the instance. |
| 14:37:25, transaction 6025 | `claude-a` is available and confined, account `paul@tito.io`, policy `3ba26b99cbfb29041600d32d0eb4c2fa53174ff8bb8d79ad4d65180c654b53cf`. `claude-b` is unavailable and unconfined, account `paul@keymail.dev`, policy `8d121c4a565bf378c0eedaa256072a9f9e674c82b0506c5c8a88649f6cca9475`. Its report says `capability_unverified`. |
| 14:53:48, transaction 6139 | `SELECT person,revision,limits FROM coordinator_limits` returns no rows. |
| 14:54:58, transaction 6147 | `SELECT team_id,revision,config FROM budget_records` returns no rows. |
| 15:17:38, transaction 6306 | Final recheck still selects unavailable `claude-b`; team-budget and coordinator-limit row counts are both zero. |

The current binding cannot be claimed because its selected account is not
certified. Switching to `claude-a` alone is insufficient: the team and personal
coordinator budgets are both unset. Budget admission must continue to deny that
state. The provider account's email is distinct from the authenticated runner's
person; server ownership checks use the latter. No account substitution is
appropriate without the person's choice.

The instance also requires current roster and connection revisions, a fresh
heartbeat, pinned identity and routing, a verified isolation tuple, a current
binding generation, no earlier blocked turn or uncontained attempt, no task
holding the account, and budget capacity. Claim repeats authority checks inside
the write transaction. The production launcher separately verifies executable
digests and the exact coordinator policy. None of these checks was removed.

## Changes

- Binding changes now verify selection eligibility inside the transaction before
  cancelling or superseding existing work. An unavailable choice leaves the old
  binding and generation intact. Settings disable unavailable choices.
- Blocked conversation cards link to coordinator settings. Missing coordinator
  limits link the owner to team limits, which must be set first.
- Chat appends a pending bubble synchronously on submit, waits 500 ms before
  showing Sending, and keeps Retry on failure. Retries reuse the original
  idempotency key. Server HTML echoes only the viewing person's send keys;
  reconciliation handles live feed replacement and identical message bodies.
  Native form submission still works without JavaScript. Vendored scripts are
  unchanged.
- `make e2e-live` builds the actual instance and runner binaries, uses loopback
  HTTP and a new database, signs in through the real email flow, and enrols a
  scratch runner using the existing test-side approval helper. No test endpoint
  or authentication bypass was added to either production binary.
- The harness selects only dedicated `claude-a`, `paul@tito.io`, Claude 2.1.312.
  It verifies installed binaries against the release manifest. Scratch paths
  require an exact harness-only policy certificate; a Go build overlay embeds
  it only in scratch binaries. The checked-in manifest and evidence are intact.
- The final harness starts with both budgets absent, proves `budget_needed`,
  then uses the owner team-budget and coordinator-limit forms to authorize six
  calls. It sends two small messages through `/conversation`, waits for delivered
  turns and checks the rendered reply and project-setup card. The unconfigured
  repository is advertised with an empty fixture credential; no forge access
  occurs. Each failure names its stage.
- Five recorded request/response fixtures cover heartbeat, coordinator poll,
  claim, post_message reply and delivery. Both the instance handler and runner
  transport tests consume them. Recording excludes all headers and enrollment
  traffic; the provider email, admission identifier and credential-home hash
  are replaced with fixed fixture values.

The harness reads installed tool paths and the dedicated account binding from
`~/.local/share/equipo-runner/service.env`; `EQUIPO_E2E_ENV` can name another
configuration. It copies only the selected binding metadata into scratch, not
credentials. The existing dedicated home is leased through the production
account lock. All test processes and scratch files are removed after each run.

## Verification

Initial failing tests and observed failures:

- `CGO_ENABLED=0 go test ./internal/chatsend -count=1`
- `EQUIPO_BROWSER_NO_JS=1 CGO_ENABLED=0 go test -tags browser ./internal/equipotest -run '^TestChatBrowser$' -count=1`
- `CGO_ENABLED=0 go test ./internal/plan3test -run '^TestCoordinatorRejectsUnavailableBinding$' -count=1`:
  failed because an unavailable binding was accepted with no error. Passed after
  transactional selection validation; the original binding remains intact.
- `CGO_ENABLED=0 go test -tags browser ./internal/equipotest -run '^TestOptimisticChat$' -count=1`:
  failed because there was no pending bubble before the POST completed.
- Renaming the wire `turn_id` field to `turn_key` made both recorded-contract
  tests fail. Restored it.
- Removing the coordinator capability check made the instance contract test
  fail. Restored it.
- Changing the Sending timer from 500 ms to zero made the strengthened browser
  test fail at its 250 ms assertion. Restored it. The first timing assertion was
  too weak; it was strengthened after a mutation unexpectedly passed.
- Replacing the server send key with a wrong key made reconciliation fail.
  Restored it.
- Removing viewer scoping made `TestRequestsStayWithViewer` expose the other
  person's key and fail. Restored it; a database lookup error also fails closed.
- Replacing the feed with a response captured before the POST made the browser
  test lose the confirmed message. It now retains the last 50 confirmed sends
  across stale live responses and passes.

Passing targeted commands:

- `CGO_ENABLED=0 go test ./internal/plan3test -run '^TestCoordinator' -count=1`
- `CGO_ENABLED=0 go test ./internal/runner/transporttest ./internal/runnerproto -run '^TestCoordinatorRecorded' -count=1`
- `CGO_ENABLED=0 go test -tags browser ./internal/equipotest -run '^(TestOptimisticChat|TestChatBrowser)$' -count=1`

The browser tests cover Enter, Shift+Enter, immediate display, delayed Sending,
network failure, retry, a response lost after the write commits, identical text
sent twice, live feed replacement, escaping, focus and scrolling.

The final `make e2e-live` passed twice consecutively in **115.35 s and 115.18 s**.
Both runs started without budgets, recovered through the owner forms, and
checked the coordinator message element and the proposal's setup form in the
rendered feed. Earlier runs caught scratch setup errors: missing budgets, an
uncertified scratch policy and an unadvertised repository. The final HTML checks
also prevent the person's own prompt from satisfying a reply assertion.

Across eleven invocations, two failed before model dispatch, one dispatched one
turn, and eight dispatched two each: **17 admitted coordinator turns**, below
the authorized total of 30. Each run admitted at most two, below its six-call
cap. No live model use occurred outside the harness.

CI: the first full `make -k ci` found the brief's missing reference allowance,
a numeric HTTP status in a contract test, and the three missing pending-copy
inventory entries. It also hit `TestNamespaceStartingThreadExit`: `unix.Poll`
returned `EINTR`, which the test mistook for process exit. The test helper now
retries interrupted polling without accepting a dead process. Production
containment code is unchanged. Build, vet, vulnerability scanning, secret
scanning, size budgets, adapter tests, migration checks and performance passed.
Timing notices under concurrent load included runner 358.194 s (330 s budget),
provider 22.522 s (15 s), Claude adapter 49.642 s (45 s) and Codex adapter 41.092 s
(35 s). No budget was raised.

The one full rerun of `make -k ci` exited **0**: 36 tested packages, none failed;
all remaining gates passed. It still reported timing overruns for runner
355.421 s, provider 21.600 s, Claude adapter 47.512 s and Codex adapter 39.940 s.
These are warnings locally and failures when CI enforces timing budgets. The
controller should retain this timing caveat when assessing the branch; this
session did not relax those limits or claim a hosted-CI pass.

The post-commit secret scan identified four high-entropy fixture identifiers.
They were replaced with fixed values, the shared contract tests were rerun,
and the unpushed commit was amended. The final browser checks passed, including the stale-feed race and scriptless
submission. Scratch instances, runners and browsers stopped through test
cleanup. Task logs were removed after recording these results. The production
service remained running; no merge, push or deployment was performed.

## Controller action

After reviewing and releasing this commit, Paul must explicitly choose
`claude-a`, set the team budget in `/settings#budgets`, then set coordinator
limits in `/settings/coordinator`. Choose real operating limits, not the
harness's test values. Existing queued messages can then resume through normal
polling. This session did not change those production settings or Paul's
conversation. Copy approval remains a release step for the three marked strings.
