| 1 | # Agent setup controller report |
| 2 | |
| 3 | Round 2 adds automatic coordinator binding, setup and failure notes, and chat |
| 4 | focus/transition fixes. The round 2 evidence and handoff follow the original |
| 5 | R1–R5 report below. |
| 6 | |
| 7 | The coordinator can propose a repository project in the conversation. The |
| 8 | project is created only when its person taps **Set up**. **Not now** closes |
| 9 | the card without creating a project. This branch was rebased onto `main` |
| 10 | `96920a2` after the chat UI merge. Commit only; the controller pushes. |
| 11 | |
| 12 | ## Delivered |
| 13 | |
| 14 | - R1: each normal heartbeat sends the sorted repository keys from the dedicated |
| 15 | forge credential file. Legacy string values and separate API/Git values both |
| 16 | work. No credential values enter the report. The instance replaces the list |
| 17 | per authenticated runner and resolves the person through the current runner |
| 18 | and roster. Failed local discovery withdraws old names. Revoked runners are |
| 19 | excluded immediately. Rotation-only heartbeats leave discovery unchanged. |
| 20 | - R2: `propose_project({repository, why})` is in the coordinator-only tool list. |
| 21 | Repository names must match a current report from this person's runners. |
| 22 | Proposals are private, audited, replayable and deduplicated while pending. |
| 23 | Confirmation checks the person, binding generation, current owner role, |
| 24 | repository report and card revision inside the write transaction. It uses the |
| 25 | existing project validator. Account, project, decision owners, audit, card |
| 26 | update and follow-up message commit together. Replay creates nothing twice. |
| 27 | - R3: the prompt tells the coordinator to propose setup for a new repository or |
| 28 | app and to recommend a repository when the team has no projects. Context |
| 29 | contains reported names and eligible existing project metadata. Existing |
| 30 | project restrictions still apply to the selected model connection. Empty |
| 31 | conversations explain that people can say what they want fixed. |
| 32 | - R4: the optional new-project form requires only a repository. A datalist offers |
| 33 | reported names and still accepts typed names. More options is collapsed. |
| 34 | Existing project edits keep the previous validation path. |
| 35 | - R5: only coordinator policy inventories changed. Its obsolete live certificate |
| 36 | was removed from the active manifest. Both specialist certificates, their |
| 37 | isolation tuples and all specialist inventory hashes are unchanged. Historical |
| 38 | evidence files are unchanged. The coordinator remains uncertified. |
| 39 | |
| 40 | Defaults: the last repository segment supplies the name; its namespace supplies |
| 41 | an account label, created if needed; kind is Repository; branch is `main`; the |
| 42 | confirming person owns work and merge decisions. No project playbook or approval |
| 43 | override is written. The existing team/kind playbook resolution and approval |
| 44 | default apply. Tests verify an installed team playbook is inherited. Model |
| 45 | connection consent and execution gates retain their existing behavior. |
| 46 | |
| 47 | Migration `0034_agent_setup.sql` adds `runner_repositories` and |
| 48 | `project_proposals`; Models and the schema snapshot match. Form parsing lives in |
| 49 | `setup`, and the new integration tests have their own package. Size budgets were |
| 50 | not raised. The historical reference inventory received only the changed model |
| 51 | line's hash. |
| 52 | |
| 53 | ## Policy identities |
| 54 | |
| 55 | These are portable constructor inventory hashes, not new live certificates. |
| 56 | |
| 57 | | Provider/action | Before | After | |
| 58 | |---|---|---| |
| 59 | | Claude/coordinate | `a671f7b2fe5b2d9864684d2260400f278041f35f0b33afbe7e2569551aba9e7f` | `ed4d28bda3454a731a0265a46f25d7b567ad05606ef288751100eb4b31e7f6f2` | |
| 60 | | Codex/coordinate | `d6815e9d94c8c96ae63e40505011be6c7ec226db1e2479454eee83ca6b8f4c6e` | `26a6d7dbb36a6787f651a22ae9785ac827e02bb8de8b89f93a0b403108577a86` | |
| 61 | |
| 62 | The retired Claude coordinator live policy hash is |
| 63 | `7390776107a4ae309ed3182e2c6079dd08e7f4fdcaee0cb64287eb2bf0671529`. |
| 64 | The controller must rerun the starter gate for the new coordinator policies. |
| 65 | Offline tests grant no production certification. |
| 66 | |
| 67 | ## Verification |
| 68 | |
| 69 | Before implementation: |
| 70 | |
| 71 | - `CGO_ENABLED=0 go test ./internal/coordinator -run '^TestProposeProjectSchema' -count=1` |
| 72 | failed with `runner.invalid` for the new tool. |
| 73 | - `CGO_ENABLED=0 go test ./internal/plan3test -run '^TestAgentSetup' -count=1` |
| 74 | failed to compile because the reporting and proposal-answer APIs did not exist. |
| 75 | These tests were later moved to `internal/agentsetuptest` to keep the existing |
| 76 | package within its size budget. |
| 77 | - `CGO_ENABLED=0 go test ./internal/agentsetuptest -run '^TestAgentSetupContextScope$' -count=1` |
| 78 | failed with `setup context disclosed a project denied to this connection`. |
| 79 | Applying the existing project-access check restored it. |
| 80 | |
| 81 | Passing targeted commands: |
| 82 | |
| 83 | ```sh |
| 84 | CGO_ENABLED=0 go test ./internal/agentsetuptest -count=1 |
| 85 | CGO_ENABLED=0 go test ./internal/coordinator ./internal/equipo ./internal/release ./internal/runner/transporttest -run 'TestProposeProjectSchema|TestCoordinatorToolAllowlist|TestMigrationModels|TestConversationMigrationSnapshot|TestPlanWorkflowReleasePolicyInventory|TestRunnerHeartbeatWireReports' -count=1 |
| 86 | CGO_ENABLED=0 go test ./internal/runner/forge ./internal/runner/heartbeat -run 'TestRepositoryNames|TestForgeCredential' -count=1 |
| 87 | CGO_ENABLED=0 go test ./internal/plan3test ./internal/runner/provider/claude ./internal/runner/provider/codex -run 'TestCoordinatorAuthorityProjectContext|TestCoordinatorContext|TestCoordinatorSessionContinuity' -count=1 |
| 88 | ``` |
| 89 | |
| 90 | The fake CLI is a local Python subprocess that reads the actual coordinator |
| 91 | prompt and emits `propose_project`. Its call crosses the real tool broker, |
| 92 | runner journal, loopback HTTP protocol and instance transaction. Repository |
| 93 | URL, app name and no-project cases each reach a card, then an authenticated |
| 94 | HTML form tap, then one persisted project. Provider event transport and |
| 95 | containment are simulated; no live provider account is used. |
| 96 | |
| 97 | ### Guard mutations |
| 98 | |
| 99 | Each mutation was applied alone and restored. Each command below exited 1 |
| 100 | with an assertion failure, rather than a compilation failure. The restored |
| 101 | suite passes. The card-state test removes a queue replay record to check the |
| 102 | state guard independently of queue idempotency. An initial weaker test was |
| 103 | strengthened after that separate guard concealed the mutation. |
| 104 | |
| 105 | Use `CGO_ENABLED=0 go test <package> -run '<filter>' -count=1`: |
| 106 | |
| 107 | | Guard deliberately broken | Package | Filter | Observed failure | |
| 108 | |---|---|---|---| |
| 109 | | repository allowlist | `./internal/agentsetuptest` | `^TestAgentSetupGuards/unreported$` | unreachable repository accepted | |
| 110 | | tap rechecks discovery | `./internal/agentsetuptest` | `^TestAgentSetupGuards/withdrawn$` | guard accepted withdrawn | |
| 111 | | current owner | `./internal/agentsetuptest` | `^TestAgentSetupGuards/role$` | guard accepted role | |
| 112 | | binding generation | `./internal/agentsetuptest` | `^TestAgentSetupGuards/generation$` | guard accepted generation | |
| 113 | | card revision | `./internal/agentsetuptest` | `^TestAgentSetupGuards/stale$` | guard accepted stale | |
| 114 | | card terminal state | `./internal/agentsetuptest` | `^TestAgentSetupDuplicateAndDecline$` | declined card reused | |
| 115 | | person isolation | `./internal/agentsetuptest` | `^TestAgentSetupTap$` | another person accepted | |
| 116 | | pending deduplication | `./internal/agentsetuptest` | `^TestAgentSetupDuplicateAndDecline$` | duplicate pending card | |
| 117 | | existing project | `./internal/agentsetuptest` | `^TestAgentSetupDuplicateAndDecline$` | existing project proposed | |
| 118 | | audit atomicity | `./internal/agentsetuptest` | `^TestAgentSetupGuards/audit$` | guard accepted audit | |
| 119 | | decline consent | `./internal/agentsetuptest` | `^TestAgentSetupGuards/decline$` | refused proposal created a project | |
| 120 | | coordinator instructions | `./internal/agentsetuptest` | `^TestAgentSetupFakeCLI/Fix_new-app$` | Fake CLI instruction assertion failed | |
| 121 | | heartbeat names | `./internal/runner/heartbeat` | `^TestRepositoryNames$` | names missing from serialized heartbeat | |
| 122 | | runner revocation | `./internal/agentsetuptest` | `^TestAgentSetupHeartbeat$` | revoked runner repository retained | |
| 123 | |
| 124 | ### Full gate |
| 125 | |
| 126 | Two complete `make -k ci` runs were made. The first exited 2. It exposed |
| 127 | context visibility regressions, expected certification-count changes, the |
| 128 | missing copy-inventory rows, one stale reference hash and one lint finding. |
| 129 | Targeted reruns of every failing group passed after correction. |
| 130 | |
| 131 | The single full rerun exited 0: 34 test packages ran uncached with zero |
| 132 | failures. Build, vet, formatting, static analysis, vulnerability and secret |
| 133 | scans, reference inventory, size budgets, adapter checks, namespace checks, |
| 134 | migration comparison and performance checks passed. The conversation's median |
| 135 | response was 20.587 ms against 150 ms; cold boot was 111 ms against 500 ms. |
| 136 | |
| 137 | The local run printed timing warnings for existing packages. These are |
| 138 | informational locally but are enforced in CI; no time limits were raised: |
| 139 | |
| 140 | | Package | Measured | Limit | |
| 141 | |---|---:|---:| |
| 142 | | `internal/runner` | 5m56.061s | 5m30s | |
| 143 | | `internal/runner/provider` | 21.532s | 15s | |
| 144 | | `internal/runner/provider/claude` | 47.184s | 45s | |
| 145 | | `internal/runner/provider/codex` | 39.056s | 35s | |
| 146 | |
| 147 | The new integration package passed within its unchanged 10-second default. |
| 148 | Its independent guard and fake-CLI cases run in parallel. |
| 149 | |
| 150 | ### Browser evidence |
| 151 | |
| 152 | Both widths passed browser checks for one confirmation card, live creation and |
| 153 | completion, no horizontal overflow, a repository datalist and one required |
| 154 | field. The scriptless variant also submitted the real confirmation form. |
| 155 | |
| 156 | ```sh |
| 157 | EQUIPO_BROWSER_ARTIFACTS="$PWD/docs/mockups/built/2026-11-06" CGO_ENABLED=0 go test -tags browser ./internal/agentsetuptest -run '^TestAgentSetupBrowser' -count=1 |
| 158 | EQUIPO_BROWSER_NO_JS=1 CGO_ENABLED=0 go test -tags browser ./internal/agentsetuptest -run '^TestAgentSetupBrowser' -count=1 |
| 159 | ``` |
| 160 | |
| 161 | Screenshots are in `docs/mockups/built/2026-11-06/`: |
| 162 | `agent-setup-card-1280.png`, `agent-setup-card-390.png`, |
| 163 | `agent-setup-empty-1280.png`, `agent-setup-empty-390.png`. |
| 164 | |
| 165 | ## Copy and handoff |
| 166 | |
| 167 | No copy-review server was started. Eleven new strings and the revised |
| 168 | `conversation.empty` are individually marked `COPY REVIEW PENDING` in |
| 169 | `internal/equipo/copy.go`. The existing complete copy inventory in |
| 170 | `CONTROLLER-REPORT-plan-3.md` contains the same text and marks it for review. |
| 171 | README prose was left unchanged. |
| 172 | |
| 173 | The controller's remaining work is to review copy, rerun the live starter gate, |
| 174 | and push this commit. No merge, push or deployment was performed here. |
| 175 | All servers and browser processes started for the checks have stopped. Scratch |
| 176 | files created for this task were removed; default Go caches were retained. |
| 177 | The supplied worktree remains in place for the controller. |
| 178 | |
| 179 | ## Round 2: automatic coordinator binding (2026-11-06) |
| 180 | |
| 181 | Merged local `main` first as `449715a`. The only conflict was in `copy.go`: |
| 182 | kept the previous agent-setup empty state pending and retained main's approvals |
| 183 | for unchanged chat strings. No fetch or push was attempted. |
| 184 | |
| 185 | A1: sending a main-conversation message now binds an unconfigured coordinator |
| 186 | to the first eligible connection by ID. Candidates belong to the current |
| 187 | person and an active runner in this instance. The release must certify the |
| 188 | provider's coordinate action; reported provider, launcher, bubblewrap and |
| 189 | policy versions must match. Existing freshness, availability, routing and |
| 190 | isolation checks apply. The binding records current member and connection |
| 191 | revisions. Message, binding, human-attributed audit, queued turn and system |
| 192 | note commit together. A replay adds no note, binding or turn. Existing bindings |
| 193 | are retained, including explicit project selection and the existing poll path. |
| 194 | |
| 195 | A2: missing runners, connections, certification or usable online connections |
| 196 | produce a plain system note with the next action. Existing offline or changed |
| 197 | bindings also explain the problem when sending. Interrupted, fenced, waiting |
| 198 | connection and budget states are visible in the conversation. Lease and attempt |
| 199 | deadlines produce a timeout note, with live refresh scheduled for both. Retry |
| 200 | controls for uncertain turns remain hidden until containment is confirmed. |
| 201 | Reads do not rewrite turn state or authorize a new attempt. |
| 202 | |
| 203 | A3: an app-owned script skips cross-document transitions when the source and |
| 204 | destination have the same origin, path and query. Composer and answer forms |
| 205 | restore focus to the composer after POST + 303; ordinary page navigation keeps |
| 206 | its transition. Browser tests exercise actual composer and project-answer |
| 207 | submissions at 1280 and 390. Vendored Rastrillo files remain byte-identical. |
| 208 | |
| 209 | Selection logic moved into the conversation package to stay within the existing |
| 210 | source budget. No budget, migration, schema, policy constructor, policy inventory |
| 211 | or certification file changed in round 2. The prior coordinator hashes above |
| 212 | still apply. Its live certification is still required; the fake release injected |
| 213 | by tests cannot authorize a real runner's policy or executable checks. |
| 214 | |
| 215 | ### Round 2 verification |
| 216 | |
| 217 | Initial failing tests: |
| 218 | |
| 219 | - `CGO_ENABLED=0 go test ./internal/agentsetuptest -run 'TestCoordinatorMissingSetupNote|TestCoordinatorFailureVisible' -count=1` |
| 220 | failed with a missing setup note and silent uncertain, fenced, waiting |
| 221 | connection and budget states. |
| 222 | - `CGO_ENABLED=0 go test ./internal/agentsetuptest -run '^TestCoordinatorExistingOfflineNote$' -count=1` |
| 223 | failed because an existing offline binding produced no note. |
| 224 | |
| 225 | The fake Python CLI now receives an authenticated first HTML message with no |
| 226 | binding, runs through automatic binding and the real runner protocol, posts a |
| 227 | reply with `post_message`, and reaches delivered state. A separate subprocess |
| 228 | failure reaches an uncertain turn with a visible recovery action after |
| 229 | containment. Existing project-proposal flows still pass. No live provider is |
| 230 | used; containment and provider event transport are simulated. |
| 231 | |
| 232 | Eleven guard mutations each exited 1 with a test assertion, then were restored. |
| 233 | Commands use `CGO_ENABLED=0 go test ./internal/agentsetuptest -run '<filter>' -count=1`: |
| 234 | |
| 235 | | Broken guard | Filter | Observed failure | |
| 236 | |---|---|---| |
| 237 | | coordinate certification | `^TestCoordinatorAutoBind/uncertified$` | ineligible binding accepted | |
| 238 | | online freshness | `^TestCoordinatorAutoBind/offline$` | offline binding accepted | |
| 239 | | certified provider version | `^TestCoordinatorAutoBind/wrong-version$` | wrong version accepted | |
| 240 | | candidate person filter | `^TestCoordinatorAutoBind/eligible$` | eligible binding missing | |
| 241 | | connection revocation | `^TestCoordinatorAutoBind/connection-revoked$` | revoked connection bound | |
| 242 | | deterministic order | `^TestCoordinatorAutoBind/deterministic$` | wrong binding selected | |
| 243 | | audit atomicity | `^TestCoordinatorAutoBind/audit$` | audit failure ignored | |
| 244 | | setup replay | `^TestCoordinatorMissingSetupNote$` | replay attempted duplicate setup write | |
| 245 | | failure visibility | `^TestCoordinatorFailureVisible/uncertain$` | silent turn | |
| 246 | | timeout visibility | `^TestCoordinatorTimeoutVisible$` | timeout note missing | |
| 247 | | same-page transition skip | `^TestAgentSetupBrowser/390$` with `-tags browser` | transition was not skipped | |
| 248 | |
| 249 | The certification and version fixtures were strengthened after independent |
| 250 | version and isolation checks initially concealed those mutations. Restored |
| 251 | checks cover current membership, foreign ownership, revoked runners and |
| 252 | connections, unavailable reports, lookup/decode errors and audit rollback. |
| 253 | Timeout tests also verify that live refresh is scheduled. Historical conversation |
| 254 | and migration assertions now include the setup note beside the person's message. |
| 255 | |
| 256 | Eight new copy entries and the revised `coordinator.uncertain` and |
| 257 | `coordinator.waiting_connection` are individually marked `COPY REVIEW PENDING`. |
| 258 | The consolidated Plan 3 copy inventory contains their exact text. The controller |
| 259 | applies Paul's acceptance before release. No copy-review server was started; |
| 260 | README prose is unchanged. |
| 261 | |
| 262 | Targeted checks passed: |
| 263 | |
| 264 | ```sh |
| 265 | CGO_ENABLED=0 go test ./internal/agentsetuptest -count=1 |
| 266 | CGO_ENABLED=0 go test -tags browser ./internal/agentsetuptest -run '^TestAgentSetupBrowser' -count=1 |
| 267 | CGO_ENABLED=0 go test ./internal/agentsetuptest ./internal/plan3test -run 'TestCoordinatorAutoBind|TestCoordinatorExistingOfflineNote|TestPlan3ReleaseBoundaries/inventory' -count=1 |
| 268 | ``` |
| 269 | |
| 270 | The first full `make -k ci` exited 2 with one failing package: |
| 271 | `internal/tryequipo`, test `TestAutomaticAnswerProcessChain`. Its captured |
| 272 | terminal output showed the provider check passing and the shell printing |
| 273 | `exit`; the Python driver then failed its one-shot, nonblocking child-exit |
| 274 | check. A process-reaping race is the likely cause, not a proven diagnosis. |
| 275 | `CGO_ENABLED=0 go test ./internal/tryequipo -run '^TestAutomaticAnswerProcessChain$' -count=3 -v` |
| 276 | passed all three isolated runs. That unrelated fixture is unchanged. |
| 277 | |
| 278 | Every other gate passed on the first full run. Conversation median response was |
| 279 | 19.594 ms against 150 ms; cold boot was 110 ms against 500 ms. Existing local-only |
| 280 | timing warnings: runner 5m54.874s/5m30s, provider 22.456s/15s, Claude |
| 281 | 53.751s/45s, Codex 43.872s/35s. No time limits were raised. |
| 282 | |
| 283 | The single full rerun exited 0. All 34 test packages ran uncached with zero |
| 284 | failures. Reference scan, build, vet, formatting, static analysis, vulnerability |
| 285 | and secret scans, size budgets, adapter and namespace checks, migration |
| 286 | comparison and performance passed. Conversation median response was 20.991 ms; |
| 287 | cold boot was 115 ms. The four local timing warnings remained: runner |
| 288 | 5m54.195s/5m30s, provider 21.528s/15s, Claude 47.469s/45s and Codex 39.94s/35s. |
| 289 | Timing limits are enforced in CI environments; these existing warnings were not |
| 290 | waived or changed. Two full runs total, one rerun; no third run. |
| 291 | |
| 292 | Controller: apply copy acceptance, rerun live coordinator certification and push |
| 293 | the local commits. No push or deployment was performed. Test servers and browser |
| 294 | processes have stopped, and task scratch was removed. Default Go caches and the |
| 295 | controller-provided worktree remain in place. |
| 296 | |