# Connection availability

The relocation fix passes the local fake CLI flow and the production no-turn
preflight. Deployment and instance receipt of the new heartbeat are pending the
controller. No deployment, push, merge or message as Paul was performed.

## Root cause

The read-only instance query returned both unavailable reports from transaction
5152, written 2026-11-06 12:32:22 UTC. The unit was active on release 8989033.
`claude-a` reported `f415d19a3841596750d28113f2217f380e0955b4fb8fd4dc9a9ef1052f66fac4`.
`claude-b` reported `9b5b1e544a1fd642682a8911ec3d1fe696b6356c438c012e5d3706874340199f`.
These were constructed implement-policy hashes, not the fallback binding hashes.
All five installed binary digests passed `VerifyInstalled`.

`discoverNamespaces` constructed only the implement policy. It required both
installed binary verification and an exact implement certificate before running
the CLI preflight. A failed certificate comparison left the default
`capability_unverified` reason. The account/version probe and dependency probe
therefore never ran. There is no missing startup registration or additional
model capability trial to perform.

`policyTemplate` retains runtime binary source paths as well as their digests.
The live gate used these two source paths:

- `/home/paulca/.local/share/equipo/try/bin/claude`
- `/home/paulca/.local/share/equipo/try/bin/equipo-tool-proxy`

The enrolled service used the same bytes at these paths:

- `/home/paulca/.local/share/claude/versions/2.1.312`
- `/home/paulca/.local/share/equipo-runner/releases/8989033/equipo-tool-proxy`

A temporary diagnostic called the production policy constructor on only the
`paul@tito.io` binding. With the service paths it reproduced the reported hash.
Changing just those two executable paths to the gate paths reproduced all three
existing certificates exactly:

| Action | Certified hash |
|---|---|
| implement | `07f4d97e1629d285c30411766ba75135ad7adb599fd8e50321d781e5b88c7e54` |
| review | `19832014cb5aa65fb42d2cd29661d336752b7ad58efef7a8fc4a4e42ee6ed269` |
| coordinate | `3ba26b99cbfb29041600d32d0eb4c2fa53174ff8bb8d79ad4d65180c654b53cf` |

The second binding belongs to `paul@keymail.dev`. These certificates bind the
first account and home. Relocation does not make the second account certified.

## Change

The release manifest records the two live-gate paths as `policy_source` metadata
on the existing binary entries. Certificate comparison can substitute those
source paths for read-only executable mounts. Digests, mount targets, access
modes, account identity, home, model, settings, denied paths, tools and versions
remain in the comparison. The original concrete manifest and policy hash remain
unchanged and continue to protect launch attestation and source validation.
Neither evidence artifacts nor certified hashes were rewritten.

Discovery now tries certified actions, preferring coordinate, instead of
requiring implement. Only a matching certificate followed by a successful
preflight makes a connection available. It reports the matching certified tuple
so the instance can verify isolation. Specialist and coordinator launch guards
use the same relocation-aware comparison and still require installed pins and
confined selection. Every launch still checks its own action; availability does
not certify an uncertified action.

The CLI preflight checks the account/version and dependency startup without a
model turn. Its successful result is cached by binding, credential-generation
fingerprint and actual policy hash. Construction and certificate checks still
run on each discovery. Changed credentials require another preflight.

The report-selection code lives in the existing certified package. New discovery
tests have their own package to stay inside source and test budgets. The existing
fake coordinator launcher was moved unchanged into a reusable fixture file. No
budget was raised. No application copy or README changed. The controller report
is an agent handoff; no copy-review server was started.

Future certificates must record the binary source paths used by their own live
gate if their binaries will move. These optional paths describe the original
certificate; they are not installation paths or a mechanism to certify new
accounts. Other changes to the exact policy still require certification.

## Verification

Go commands use `CGO_ENABLED=0`; the full gate pins Go 1.26.10. Go caches stayed
at their defaults. Scratch was under the existing on-disk `$TMPDIR`.

1. Before the relocation implementation, `go test ./internal/runner/provider
   -run '^TestPolicyBinaryRelocation$' -count=1` failed with
   `identical relocated binary lost certification`.
2. The final targeted run covers `TestPolicyBinaryRelocation`,
   `TestConnectionAvailableGuards`, `TestConnectionAvailableCoordinatorFakeCLI`,
   `TestDirectClaimRevalidates`, `TestRuntimeMountsStandaloneToolProxy` and
   `TestCoordinatorSessionProductionWiring`. All passed.
3. `TestConnectionAvailableCoordinatorFakeCLI` uses a synthetic certificate and
   actual local CLI subprocesses. It exercises account preflight, relocated
   policy comparison, HTTP heartbeat, instance isolation verification, automatic
   binding, admitted coordinator claim, runner journal, tool proxy, reply and
   delivered turn. The adapter and namespace containment are simulated; this is
   not live isolation evidence.
4. The discovery guards cover coordinator-only and review-only certificates,
   absent certificates, wrong actions, another binding, changed binary bytes,
   failed installed verification, failed account preflight, sign-in maintenance
   and failed cleanup. Provider tests also cover settings, denied paths, targets,
   writable mounts, manifest integrity, policy-hash integrity and invalid paths.
5. Mutation checks removed relocation, concrete manifest validation, policy hash
   validation, installed verification, preflight, exact action/hash matching and
   support for coordinator-only discovery. Each targeted test failed at its
   assertion. All mutations were restored. The first cleanup mutation contained
   a substitution typo and failed compilation; a corrected cleanup mutation is
   recorded in the final results below.

The mutation commands were `go test ./internal/runner/provider -run
'^TestPolicyBinaryRelocation$' -count=1`, its `manifest` and `hash` subtests,
and the `uninstalled`, `preflight`, `cleanup`, `wrong-action` discovery subtests
plus `TestConnectionAvailableCoordinatorFakeCLI`. Discovery tests initially lived
in `internal/plan3test`; their final location is
`internal/runner/certified/discoverytest`.

### Production preflight

The unit was stopped briefly and restarted in a `finally` block. An initial
test-binary diagnostic was refused because containment requires its runner path
to identify the current executable. No provider was launched by that attempt.
A scratch build of the real command then ran `preflight` with the service's
configuration and exited 0. It reported:

```json
{
  "LocalID": "claude-a",
  "Available": true,
  "ReadIsolation": true,
  "UnavailableReason": "",
  "IsolationConfigHash": "3ba26b99cbfb29041600d32d0eb4c2fa53174ff8bb8d79ad4d65180c654b53cf",
  "ObservedAccountID": "paul@tito.io"
}
```

`claude-b` remained unavailable with `capability_unverified`; its CLI was not
launched. No model turns were used, against the authorized ceiling of 15. No
credential file contents were inspected or printed by the diagnostic harness;
the production account code performed its normal staging and validation.

This foreground preflight does not send a heartbeat. It proves that the updated
runner can produce the report, not that the deployed instance has received it.
The original unit was active again on release 8989033 after the check.

## Controller deployment and receipt check

Run these steps only after the controller has reviewed, pushed and integrated
the commit. This agent has not run them. Keep the existing enrollment and account
bindings. Re-enrollment is unnecessary.

1. In the clean integrated checkout, load the existing service configuration and
   build the versioned release:

   ```sh
   set -a
   . "$HOME/.local/share/equipo-runner/service.env"
   set +a
   make release
   connection_version=$(git rev-parse --short HEAD)
   carlos deploy --app equipo --account oficina --channel edge --timeout 5m \
     "releases/equipo-linux-arm64-$connection_version"
   ```

2. Update the local runner to the same version. The following script preserves
   the existing environment and unit except for their executable paths:

   ```sh
   export connection_version
   python3 - <<'PY'
   import os, pathlib, shutil, subprocess
   version = os.environ['connection_version']
   home = pathlib.Path.home()
   root = home / '.local/share/equipo-runner'
   source = pathlib.Path('releases') / ('equipo-runner-linux-amd64-' + version)
   destination = root / 'releases' / version
   unit = home / '.config/systemd/user/equipo-runner.service'
   env = root / 'service.env'
   old_unit, old_env = unit.read_text(), env.read_text()
   assert sum(x.startswith('ExecStart=') for x in old_unit.splitlines()) == 1
   assert sum(x.startswith('EQUIPO_TOOL_PROXY_PATH=') for x in old_env.splitlines()) == 1
   subprocess.run(['systemctl', '--user', 'stop', 'equipo-runner.service'], check=True)
   try:
       destination.mkdir(mode=0o700, exist_ok=False)
       for name in ('equipo-runner', 'equipo-tool-proxy', 'install-manifest.json'):
           shutil.copy2(source / name, destination / name)
       unit.write_text('\n'.join(
           'ExecStart=' + str(destination / 'equipo-runner') + ' run'
           if x.startswith('ExecStart=') else x for x in old_unit.splitlines()) + '\n')
       env.write_text('\n'.join(
           'EQUIPO_TOOL_PROXY_PATH="' + str(destination / 'equipo-tool-proxy') + '"'
           if x.startswith('EQUIPO_TOOL_PROXY_PATH=') else x for x in old_env.splitlines()) + '\n')
       subprocess.run(['systemctl', '--user', 'daemon-reload'], check=True)
   except BaseException:
       unit.write_text(old_unit)
       env.write_text(old_env)
       subprocess.run(['systemctl', '--user', 'daemon-reload'], check=True)
       raise
   finally:
       subprocess.run(['systemctl', '--user', 'start', 'equipo-runner.service'], check=True)
   PY
   systemctl --user is-active equipo-runner.service
   ```

3. After the next heartbeat, query the read-only replica. Confirm its snapshot
   and `last_seen` are newer than the runner update. Repeat if the replica lags.

   ```sh
   carlos db query --app equipo --account oficina --sql "
   SELECT local_id, last_seen,
     json_extract(reports_json, '\$[0].Available') AS available,
     json_extract(reports_json, '\$[0].ReadIsolation') AS read_isolation,
     json_extract(reports_json, '\$[0].UnavailableReason') AS reason,
     json_extract(reports_json, '\$[0].IsolationConfigHash') AS policy_hash
   FROM connections ORDER BY local_id"
   ```

   For `claude-a`, require `available=1`, `read_isolation=1`, an empty reason and
   the coordinator hash printed above. `claude-b` must remain unavailable.
   Save this output as the missing deployed receipt evidence.

4. Paul sends a new message himself. Do not send or retry one as Paul. Verify
   the coordinator binds to `claude-a` and its new turn reaches `delivered`:

   ```sh
   carlos db query --app equipo --account oficina --sql "
   SELECT b.id, b.person, c.local_id, b.generation
   FROM coordinator_bindings b JOIN connections c ON c.id=b.connection_id"
   carlos db query --app equipo --account oficina --sql "
   SELECT id, message_id, state FROM coordinator_turns ORDER BY rowid DESC LIMIT 5"
   ```

   An existing finished setup note is not a queued request. The fresh message
   supplies the request for this check. Record the turn ID and final state.

## Final gate and handoff

The first `make -k ci` exited 2. It found six unclassified references: five
already in the controller brief and one in the new regression test. The same
inventory failure caused `TestDirectDeadReferencesRepository` to fail. Staticcheck
also required `http.StatusConflict` instead of literal 409 in the new fixture.
Both issues were corrected. All other test assertions passed: 34 packages ran,
one failed on that inventory check. Adapter, namespace and migration checks
passed. Performance passed, including a cold boot median of 116ms against 500ms.

Local timing warnings were runner 352.369s/330s, provider 21.388s/15s, Claude
adapter 46.973s/45s and Codex adapter 39.399s/35s. These would fail their budgets
in CI mode. No timing allowance was changed.

The corrected cleanup mutation failed at `cleanup failure hidden <nil>`.
Restoring the guard made the final targeted tests pass: provider 0.309s,
discovery 6.027s and the existing coordinator HTTP acceptance test 4.225s.
`make copy-release-check direct-release-check` also passed with the installed
binary paths. The existing evidence remains byte-identical.

The first permitted full `make -k ci` rerun exited 0. All 35 test packages
passed, with no cached packages and eight packages without tests. The test phase
took 362.191s. Build, vet, formatting, staticcheck, vulnerability scanning,
secret scanning, reference inventory, size budgets, adapter, namespace,
migration and performance checks passed. Cold boot median was 121ms against
500ms. Total full gate runs: two; no second rerun was needed.

The rerun retained local timing warnings: runner 360.185s/330s, provider
21.488s/15s, Claude adapter 47.208s/45s and Codex adapter 39.783s/35s. Exit 0
establishes the local gate result, not CI-mode timing compliance.

A second read-only instance query, transaction 5291 written at
2026-11-06 12:52:12 UTC, returned no coordinator bindings. The controller can
therefore test initial automatic binding with Paul's next message after the
update. Receipt of an available heartbeat and a delivered production turn
remain pending deployment; neither is claimed here.

Task scratch and diagnostic sources were removed. No task server or background
process remains. The existing unit is active on release 8989033, as requested.
The changes and this report are committed on `connection-available`; the
controller owns push, integration and deployment. The workspace is safe to close.
