oficina / equipo Public

Clone
git clone https://amadan.net/oficina/equipo

Plain git — no account needed to clone.

Download

Download this file

1# Self-healing coordinator
2
3Implemented on `self-heal`, from the dispatched brief commit `cac8b11`
4(main base `80c15d0`). Commit only; no push, merge or deployment.
5New runtime copy is individually marked `COPY REVIEW PENDING` in
6`internal/equipo/copy.go` and listed in the existing copy inventory.
7No copy-review server was started. README prose is unchanged.
8
9## Changes
10
11The runner runs the pinned official CLI in the dedicated source home while
12holding the existing directory lock, before staging any runtime login.
13Claude 2.1.312 uses `auth status --json`; its startup performs and awaits
14native refresh. Codex 0.165.0 uses app-server `account/read` with
15`refreshToken:true`, after initialization. Neither path starts a model turn.
16Equipo consumes account metadata only and does not extract refresh tokens.
17The executable digests are checked before maintenance.
18
19Saved-account setup and generic discovery also probe the locked source home.
20An unconfined native CLI probe rejects a staged binding. This closes the setup
21path as well as the dispatch path.
22
23The source lock stays held throughout the attempt, so maintenance cannot
24run alongside a turn. Runtime copies expire after 25 minutes, which covers
25the existing 20-minute coordinator attempt limit. A production lease cannot
26commit runtime credentials back to its source. Runtime network policy still
27excludes the refresh hosts; Claude refresh uses platform.claude.com and Codex
28uses auth.openai.com. Owner mode uses the same isolation and needs no new
29certification. Certified mode continues to enforce its policy hashes.
30
31Temporary maintenance failures remain retryable. A native missing-login result
32or a recognized terminal refresh rejection produces `account.sign_in_again`.
33That connection gets one conversation note containing its exact command,
34including the dedicated-home environment, pinned executable and directory lock.
35Repeated polls do not repeat that note. No credentials are included in reports.
36
37Coordinator settings now show the current connection and the automatic-selection
38reason. The binding picker and its Save/Reset controls are gone; the obsolete
39binding form action is rejected. Recovery reset actions remain available for
40uncertain work. On each new message and poll, selection prefers a currently
41healthy report, then fewer active tasks, then the latest report. Only the
42person's own enrolled runners qualify. An admitted attempt with pending
43containment cannot be moved or cancelled by automatic selection.
44
45Projects without an explicit budget inherit the team ceiling. Job creation,
46plan admission, reservation headroom, usage reads and bug preparation agree
47on this rule. Explicit project caps and aggregate team caps still apply.
48Temporary connection and admission waits stay in the thinking bubble, name
49the connection and retry on polling. Missing bindings are retried when a
50runner becomes available. Routine fallback no longer adds system notes.
51
52`equipo_status` accepts no caller-supplied scope. The normal claim, handle and
53current-roster checks apply before it returns the person's runners and
54connections, team budgets, coordinator usage and permitted projects. It excludes
55credentials, home paths, machine keys and other people's connections. Stale
56heartbeats are reported as unavailable. A deleted selected connection still
57renders a waiting conversation; database failures remain errors.
58
59## Verification
60
61Behavioral failures observed before implementation:
62
63- `CGO_ENABLED=0 go test ./internal/equipo/team -run TestSelfHeal -count=1`:
64 failed with `job needs configured project`; passed after inheritance.
65- `CGO_ENABLED=0 go test ./internal/runner/provider -run TestSourceRefresh -count=1`:
66 failed because staging retained the old login and failed refresh still staged.
67- `CGO_ENABLED=0 go test ./internal/coordinator -run TestEquipoStatusSchema -count=1`:
68 rejected the new read-only tool before implementation.
69- `CGO_ENABLED=0 go test ./internal/plan3test -run TestSelfHeal -count=1`:
70 failed for the missing live wait bubble and the remaining picker.
71- `CGO_ENABLED=0 go test ./internal/runner/provider -run TestSourceRefreshLease -count=1`:
72 admitted an expired staged lease before the lifetime guard.
73- `CGO_ENABLED=0 go test ./internal/runner/provider -run TestRefreshRevocationCodes -count=1`:
74 failed to distinguish terminal refresh rejections before classification.
75- `CGO_ENABLED=0 go test ./internal/runner/provider -run TestRefreshUsesOfficialCLIWithoutTurn -count=1`:
76 the added staged-home case failed because an unconfined CLI accepted the copy.
77- `CGO_ENABLED=0 go test ./internal/ownermodetest -run TestSelfHealRemovedConnection -count=1`:
78 returned a not-found error for the waiting conversation before correction.
79
80Each mutation below was applied alone, tested with `CGO_ENABLED=0 go test`
81and `-count=1`, and restored immediately. All eleven tests failed at their
82behavior assertion, not at compilation:
83
84| Broken guard | Package and test |
85| --- | --- |
86| Skip source refresh | `./internal/runner/provider -run ^TestSourceRefreshBeforeStageUnderLock$` |
87| Remove source flock | Same test |
88| Ignore changed identity | `./internal/runner/provider -run ^TestSourceRefreshFailureDoesNotStage$` |
89| Ignore staged lifetime | `./internal/runner/provider -run ^TestSourceRefreshLeaseExpiresAndCannotWriteBack$` |
90| Permit runtime writeback | Same test |
91| Send Codex refreshToken:false | `./internal/runner/provider -run ^TestRefreshUsesOfficialCLIWithoutTurn$` |
92| Repeat sign-in note | `./internal/plan3test -run ^TestSelfHealRevokedLoginNotifiedOnce$` (subsequently moved to `./internal/ownermodetest`) |
93| Prefer the busier connection | `./internal/plan3test -run ^TestSelfHealBusyConnectionFailsOver$` |
94| Permit active-turn fallback | `./internal/plan3test -run ^TestSelfHealFailoverDoesNotMoveActiveTurn$`; caught cancellation of the active job |
95| Remove the status runner-person filter | `./internal/ownermodetest -run ^TestSelfHealStatusIsScopedAndRevocationApplies$`; caught another person's runner label |
96| Treat a stale heartbeat as available | `./internal/ownermodetest -run ^TestSelfHealStatusDoesNotCallStaleReportsAvailable$` |
97
98Restored targeted tests cover source refresh and CLI failures, picker removal,
99status scope and roster revocation, one-time login notices, busy failover,
100active-attempt fencing, inherited budgets and project-card-to-work admission.
101Existing tests were updated where they required the removed picker, repeated
102setup notes, or rejection of an unset project budget. Their authority,
103transaction rollback and accounting assertions remain.
104
105## Live proof
106
107Only the authorized paul@tito.io `claude-a` home was used. With the production
108runner briefly stopped and the source directory exclusively locked, pinned
109Claude `auth status --json` exited 0, reported the expected identity, and
110changed the credential file's modification time. The proof inspected metadata
111only; it did not read, print or copy credential contents. The runner was
112restarted immediately. The brief reported this login as expired. The proof used
113it unchanged; no credential was edited to manufacture an expiry. Codex refresh
114is covered by fake CLI tests;
115no live Codex account was used.
116
117`CGO_ENABLED=0 make e2e-live` passed twice, in 91.8 seconds and 95.6 seconds.
118Its fake CLI prerequisites passed too. The final browser run confirmed no
119coordinator picker, proposed a project, clicked Set up, then received a second
120admitted coordinator reply with `Projects:null` still in the budget record.
121The coordinator called `equipo_status` successfully. Each passing run used two
122coordinator turns. No specialist model work ran.
123
124Other live harness attempts consumed five coordinator turns. One stopped on
125a browser-helper error. Two encountered the setup card being replaced by a
126late live update. One two-turn run created the project but its subsequent
127reply became contained and uncertain. That run did not silently redispatch.
128The final test waits for containment, opens the settled conversation, and
129explicitly requires the reply through `post_message`. Metadata-only failure
130diagnostics are now included in the harness. Total live coordinator turns:
131nine, below the authorized twenty. The production runner was left active.
132
133## Final gates and handoff
134
135The first `CGO_ENABLED=0 make -k ci` completed all lanes. It failed the
136reference inventory, size gate and tests that still expected the previous
137setup notes, picker and coordinator inventory. It also caught an onboarding
138probe error regression and a synthetic-policy test that now crossed the new
139executable verification boundary. Targeted checks pass after correction.
140The synthetic test now enters the shared policy builder with its synthetic
141lease; production still verifies executable digests before source maintenance.
142The two changed coordinator inventory hashes remain explicitly uncertified.
143
144Build, vet, staticcheck, govulncheck, gitleaks, adapter checks, namespace checks,
145migration checks and performance passed in that first full run. Local timing
146notes reflect shared-machine load; no budget ceilings were raised. The size
147gate passes after moving diagnostics and test helpers to their feature packages.
148The reference inventory contains three new exact entries, including the
149controller's authorization in the original brief.
150
151Both permitted full reruns passed every gate with exit 0. Exactly three full
152`CGO_ENABLED=0 make -k ci` runs were made. The final run tested 41 packages,
153with zero failures, then passed adapter, namespace, migration and performance
154checks. Cold boot had a 167 ms median against the 500 ms limit. All screen
155performance checks passed.
156
157The final local run reported timing advisories: runner 371.68 s against 330 s,
158discovery tests 10.662 s against 10 s, provider 22.654 s against 15 s, Claude
15949.786 s against 45 s, and Codex 41.921 s against 35 s. These are advisory
160locally but become failures when CI or AMADAN_CI is set. No ceilings were raised.
161The last two status mutations were made after the full gate, restored byte for
162byte, and followed by passing targeted status and refresh tests.
163
164Scratch logs and disposable test environments are removed. No review server
165or test process remains. The pre-existing production runner is active, as
166required. The controller can review and push this local commit; pending copy
167still needs its release review. Nothing was pushed, merged or deployed.
168