# Enable execution: controller report

The installer accepts the starter set's certified policies alongside its 15
uncertified policies. `make release` now builds the linux/amd64 runner first,
checks its bundled downloads, then embeds them in the linux/arm64 app. An unset
`EQUIPO_RUNNER_RELEASE_DIR` selects that bundle. A configured directory still
wins and fails closed if invalid. Uncertified dispatch remains denied.

No provider was launched, deployed configuration changed, runner enrolled, or
application deployed during this task. No copy-review server was started. This
is the controller's requested operational report, not new app copy; README and
runtime strings are unchanged.

## Implementation and checks

- The bootstrap keeps its version, target, copy, certification and digest
  assertions. It requires a direct policy with a matching certificate that is
  not also listed as uncertified. The downloaded runner still validates the
  complete installation manifest before installation.
- `scripts/build-instance-release.sh` stages only the installation manifest,
  runner, tool proxy and bootstrap script. It refuses an existing staging
  directory and removes its own staging directory on success or failure.
  `runnerassets` is a release-only build tag: normal app and runner builds do
  not contain the bundle, preventing recursive runner embedding.
- Before building the app, `TestBundledInstallAssets` checks the version,
  namespace policy, release-manifest equality, runner SHA-256 and tool-proxy
  SHA-256 through `InstallAssets`. It serves and compares all four HTTP bodies.
  The bootstrap script has no separate digest field in the existing manifest;
  its bytes are copied from the same clean commit. Runner and tool-proxy
  digests retain their existing manifest locations.
- Embedded assets reuse the directory handler's validation, path allowlist,
  range support and cache headers. Immutable embedded files are hashed once.
  Directory files retain their metadata and replacement checks.
- No startup behavior needed changing. The new CARLOS layout test opens and
  reopens execution with a private witness subdirectory, no release-directory
  override and `AlwaysOn=false`. Enrolment remains available. The existing
  authenticated runner HTTP tests also pass with `AlwaysOn=false`.

Initial red tests:

```sh
CGO_ENABLED=0 go test ./internal/release \
  -run 'TestBootstrapPartialRelease|TestEmbeddedInstallAssets' -count=1
CGO_ENABLED=0 go test ./internal/equipotest \
  -run '^TestDirectReleaseRequiresCertification/release/clean$' -count=1
```

The first command rejected the partial manifest and could not serve the
embedded fixture. The second failed because the app build had no staged runner
manifest. Both pass after implementation. The first compile attempt also
failed because the bundle interface did not yet exist.

Targeted verification passed:

```sh
CGO_ENABLED=0 go test ./internal/release ./internal/equipotest \
  -run 'TestBootstrapPartialRelease|TestEmbeddedInstallAssets|TestOnboardingInstallPackaging|TestExecutionCarlosMarkerLayout|TestExecutionStartupClosed|TestExecutionHibernateWitness|TestRunnerAppCSRF|TestReleaseStampContract|TestRunnerReleaseContractPackaging|TestDirectReleaseRequiresCertification' \
  -count=1
```

Mutation checks used disposable Go overlays under on-disk `$TMPDIR`; the
bootstrap mutation was restored in a `finally` block. Each command exited 1
with the named assertion failing; the restored targeted command above passed.

| Behavior deliberately broken | Command after `CGO_ENABLED=0` | Observed failure |
| --- | --- | --- |
| Ignore binary digest differences | `go test -overlay=<scratch>/digest.json ./internal/release -run '^TestEmbeddedInstallAssets$' -count=1` | Tampered runner and proxy accepted |
| Ignore release-manifest equality | `go test -overlay=<scratch>/manifest.json ./internal/release -run '^TestEmbeddedInstallAssets$' -count=1` | Mismatched instance target accepted |
| Prefer embedded files over an explicit directory | `go test -overlay=<scratch>/override.json ./internal/release -run '^TestEmbeddedInstallAssets$' -count=1` | Invalid explicit override accepted |
| Ignore execution-enabled environment value | `go test -overlay=<scratch>/execution-env.json ./internal/equipotest -run '^TestExecutionCarlosMarkerLayout$' -count=1` | Execution configuration stayed disabled |
| Remove disabled-execution guard | `go test -overlay=<scratch>/execution-off.json ./internal/equipotest -run '^TestExecutionStartupClosed$' -count=1` | Disabled execution opened |
| Remove database-directory separation | `go test -overlay=<scratch>/marker-separation.json ./internal/equipotest -run '^TestExecutionStartupClosed$' -count=1` | Witness shared database directory |
| Remove the app build's `runnerassets` tag | `go test ./internal/equipotest -run '^TestReleaseStampContract/defaults$' -count=1` | Release missing embedded assets |
| Skip bootstrap certificate matching | `go test ./internal/release -run '^TestBootstrapPartialRelease$' -count=1` | Unmatched and explicitly uncertified policies accepted |

The initial manifest mutation survived because its fixture changed the Claude
version, which failed certification before reaching the equality check. The
fixture now changes the instance target, and the equality mutation fails.
The override mutation must change both opening and cache selection to model an
unsafe fallback; changing opening alone still failed closed at file identity.

One full `make -k ci` ran and exited 2. Build, vet, formatting, staticcheck,
govulncheck, gitleaks, size budgets, adapter tests, namespace tests, migration
checks and performance passed. Cold boot median was 116 ms against 500 ms.
The reference scan and test target failed for these reasons:

1. The brief and new runner asset references needed exact inventory entries.
   Added those entries, including this report; the scanner now passes.
2. `TestOnboardingInstallShell/Linux/x86_64` supplied empty certificate objects.
   Added the fixture's matching provider, action and policy hash. The full
   `internal/release` package now passes.
3. `TestReviewExpiredAccountSignsIn/claude` returned `provider_account_busy`.
   Its isolated rerun passed without account-code changes. The same failure
   and passing isolated rerun are recorded in
   `CONTROLLER-REPORT-fewer-prompts.md`; this change does not alter that path.

The full test run executed 27 packages, with no cached results. Local advisory
time overruns were runner 370.872/330 seconds, provider 21.891/15, Claude
58.215/45 and Codex 46.821/35. No budgets were raised. These timings would fail
when CI timing enforcement is enabled.

The affected checks passed on this focused rerun:

```sh
CGO_ENABLED=0 go test ./internal/release ./internal/equipotest ./internal/tryequipo \
  -run '^TestOnboardingInstallShell$|^TestDirectDeadReferencesRepository$|^TestReviewExpiredAccountSignsIn$|^TestReleaseStampContract$' \
  -count=1
CGO_ENABLED=0 go test ./internal/release -count=1
CGO_ENABLED=0 go test ./internal/equipotest \
  -run '^TestReleaseStampContract$|^TestDirectDeadReferencesRepository$' -count=1
```

No second full CI run was used. The full run remains recorded as failed;
the focused fixes and reruns do not turn it into a claimed full green run.

A dry `make release` passed in a clean disposable snapshot under on-disk
`$TMPDIR`, stamped `4d1cb1f`. It used only the five executable-path variables
read from the existing `runner.env`, with `EQUIPO_CLAUDE_PATH` overridden to
`/home/paulca/.local/share/claude/versions/2.1.312`. No provider process was
launched. This scratch commit is evidence of the build, not a version to deploy.

The release ran these checks before compiling the ARM64 instance:

```sh
EQUIPO_BUNDLE_VERSION=4d1cb1f CGO_ENABLED=0 go test -tags runnerassets \
  ./internal/release -run '^TestBundledInstallAssets$' -count=1
```

All four embedded downloads were served through the HTTP handler and matched
the staged bytes. Both executable digests matched the installation manifest.
The built AMD64 runner also passed `verify-install-manifest` on that manifest,
and its `version` command reported `4d1cb1f`. No app server was started.

| Artifact | Bytes | MiB |
| --- | ---: | ---: |
| ARM64 app including runner bundle | 41,484,450 | 39.56 |
| AMD64 runner | 18,116,770 | 17.28 |
| AMD64 tool proxy | 2,646,178 | 2.52 |

`file` confirmed a stripped, statically linked ARM64 app and stripped,
statically linked AMD64 runner and helper. The generated bundle directory was
removed by the build script, and the scratch checkout remained clean. Final
`make runner-dead-references fmt-check` and `git diff --check` passed.

## CARLOS configuration for the controller

Choose this absolute marker path:

```text
/data/instances/equipo.bds.oncarlos.com/execution/witness
```

The platform's `internal/provision/provision.go` defines the persistent nested
instance directory and database path. For this hostname, the database is
`/data/instances/equipo.bds.oncarlos.com/equipo.bds.oncarlos.com.db` in the
nested layout. The older flat layout uses `/data/equipo.bds.oncarlos.com.db`.
The chosen witness directory is separate in either layout. The isolated
instance unit binds and permits writes to its own `/data/instances/<host>`
directory. `OpenExecution` creates `execution` with mode 0700.

Sources read locally under `~/amadan.net/carlos/platform`:
`internal/provision/provision.go` (`InstanceDir`, `NestedDBPath`, `DefaultDBPath`),
`internal/host/units/carlos-instance@.service` (`BindPaths`, `ReadWritePaths`),
`internal/activator/backend_exec.go` (`agentOwnedVars`, `childEnv`, replication),
`docs/site/cli.md` (configuration bundles), and `carlos help` / `carlos env set -h`.
`CARLOS_DATA_DIR` configures the platform process; it is not an injected app
storage variable. App launch supplies `--db`; injected platform variables such
as `CARLOS_CONTROL_SOCKET` and `CARLOS_REGION` do not identify persistent app
storage. This selection comes from the checked-in platform contract; no live
instance filesystem was inspected.

Preserve this witness independently when restoring the SQLite database.
Database replication does not replicate this extra file. Hibernation on the
same disk can reopen it. If a host move, disk loss or restore loses or rolls
back the witness, execution must quarantine until a person follows recovery.
Do not copy an old witness together with an old database to bypass that check.

Leave `EQUIPO_ALWAYS_ON` unset. It enables browser live updates and related
in-process scheduling in `internal/equipo/app.go`; it does not control CARLOS
hibernation or register runner routes. Runners use outbound authenticated HTTP,
25-second long polls and heartbeats. Requests wake the app through CARLOS, and
execution resumes from its database and witness. No always-on platform change
is needed for connectivity.

After review and human merge, build from a clean checkout of the commit to be
deployed. Export the executable paths from the existing local runner setup and
pin Claude to the certified version before running the release gate. These
commands are for the controller to run later; none were run against CARLOS:

```sh
set -a
. "$HOME/.local/share/equipo-runner/runner.env"
set +a
export EQUIPO_CLAUDE_PATH="$HOME/.local/share/claude/versions/2.1.312"
make release
EQUIPO_RELEASE_VERSION=$(git rev-parse --short HEAD)
read -r -p 'Paste the flagship console address linked below: ' EQUIPO_CONSOLE
carlos deploy --console "$EQUIPO_CONSOLE" --app equipo --account oficina \
  --channel edge --timeout 5m \
  "./releases/equipo-linux-arm64-$EQUIPO_RELEASE_VERSION"
carlos env set --console "$EQUIPO_CONSOLE" --app equipo --account oficina \
  --no-prompt EQUIPO_EXECUTION_ENABLED=1 \
  EQUIPO_EXECUTION_MARKER_PATH=/data/instances/equipo.bds.oncarlos.com/execution/witness
```

Flagship console:
[https://console.carloku.com](https://console.carloku.com).
The command uses the repository's `edge` deployment target. Confirm the route's channel before promotion if
it has changed since this brief. The stated current env has no named bundle;
the command writes the default bundle. If the controller discovers a named
bundle overriding these values, apply them to that bundle with `--environment`.
Do not set `EQUIPO_RUNNER_RELEASE_DIR`; the app serves its matching bundle.

## Install and enrol docs-t1 as paulca

Open [https://equipo.bds.oncarlos.com](https://equipo.bds.oncarlos.com), sign in,
and open [https://equipo.bds.oncarlos.com/onboarding](https://equipo.bds.oncarlos.com/onboarding).
The page's installer command supplies the deployed version and instance ID.
Check its instance argument against `EQUIPO_INSTANCE_ID` in the saved
`runner.env`. If using the navigation instead, choose **Connections**, then
**Enrol a runner** to reach the machine enrolment page.

For a fresh installation, the page's bootstrap command runs the installer,
asks for the machine label and asks you to type `yes`. It then prints a
one-time device code and the approval URL. The code is generated at enrolment;
there is no reusable code to put in this report.

On this machine, use the manual installation below. The existing
`~/.local/share/equipo-runner/runner.env` is mode 0600 and has no installer
ownership attribute. `SaveServiceEnvironment` refuses to overwrite it. Even
an installer-owned replacement would select `accounts.json` and new work and
scratch defaults instead of the live gate's `bindings.json` and existing
paths. Passing the existing variables to the bootstrap does not fix those
hardcoded defaults. The commands below preserve the saved configuration and
bindings, changing only Claude's executable pin and the installed tool-proxy
path. They do not repeat provider sign-in or copy credentials.

The user service manager is available and `loginctl` reported `Linger=yes`.
All five installed executable hashes match the manifest when Claude is pinned
to 2.1.312. No executable was launched to check those hashes.
At inspection, there was no runner user service, `state/credentials.json`, or
`state/enrolment.json`. The two bindings both use Claude and existing dedicated
homes under `~/.local/share/equipo/accounts/`. Keep those homes and binding
records intact. The commands deliberately stop if a service or target release
has appeared since this inspection; reconcile that newer installation first.

Run this in Bash on docs-t1 as `paulca`, after the new app is deployed:

```bash
set -euo pipefail
umask 077
EQUIPO_INSTALL_ROOT="$HOME/.local/share/equipo-runner"
test "$(id -un)" = paulca
test ! -e "$HOME/.config/systemd/user/equipo-runner.service"
test ! -L "$HOME/.config/systemd/user/equipo-runner.service"
test ! -e "$EQUIPO_INSTALL_ROOT/equipo-runner.service"
test ! -L "$EQUIPO_INSTALL_ROOT/equipo-runner.service"
systemctl --user show-environment >/dev/null
loginctl show-user "$(id -u)" --property=Linger --value
set -a
. "$EQUIPO_INSTALL_ROOT/runner.env"
set +a
export EQUIPO_CLAUDE_PATH="$HOME/.local/share/claude/versions/2.1.312"
test -x "$EQUIPO_CLAUDE_PATH"
test "$EQUIPO_ACCOUNT_BINDINGS_PATH" = "$EQUIPO_INSTALL_ROOT/bindings.json"
mkdir -p "$HOME/.cache/equipo-install"
export TMPDIR="$HOME/.cache/equipo-install"
EQUIPO_DOWNLOAD=$(mktemp -d "$TMPDIR/download-XXXXXXXX")
trap 'rm -rf "$EQUIPO_DOWNLOAD"' EXIT
EQUIPO_INSTALL_VERSION=$(curl --fail --silent --show-error \
  --proto '=https' --tlsv1.2 "$EQUIPO_ORIGIN/api/version")
export EQUIPO_INSTALL_VERSION EQUIPO_DOWNLOAD
python3 - <<'PY'
import os, re
v = os.environ['EQUIPO_INSTALL_VERSION']
assert re.fullmatch(r'[a-zA-Z0-9][a-zA-Z0-9._-]{0,79}', v)
assert v not in ('dev', 'latest')
PY
for asset in install-manifest.json equipo-runner equipo-tool-proxy; do
  curl --fail --silent --show-error --proto '=https' --tlsv1.2 \
    "$EQUIPO_ORIGIN/releases/$EQUIPO_INSTALL_VERSION/$asset" \
    -o "$EQUIPO_DOWNLOAD/$asset"
done
python3 - <<'PY'
import hashlib, json, os, pathlib
root = pathlib.Path(os.environ['EQUIPO_DOWNLOAD'])
m = json.loads((root / 'install-manifest.json').read_text())
assert m['version'] == os.environ['EQUIPO_INSTALL_VERSION']
assert m['target'] == 'linux/amd64'
def digest(path):
    with pathlib.Path(path).open('rb') as f:
        return hashlib.file_digest(f, 'sha256').hexdigest()
assert digest(root / 'equipo-runner') == m['runner_sha256']
paths = {'claude': os.environ['EQUIPO_CLAUDE_PATH'],
         'codex': os.environ['EQUIPO_CODEX_PATH'],
         'codex-code-mode-host': os.environ['EQUIPO_CODEX_CODE_MODE_HOST_PATH'],
         'bwrap': os.environ['EQUIPO_BWRAP_PATH'],
         'equipo-tool-proxy': root / 'equipo-tool-proxy'}
assert len(m['release']['binaries']) == len(paths)
for b in m['release']['binaries']:
    assert digest(paths[b['name']]) == b['sha256'], b['name']
PY
chmod 700 "$EQUIPO_DOWNLOAD/equipo-runner"
"$EQUIPO_DOWNLOAD/equipo-runner" verify-install-manifest \
  "$EQUIPO_DOWNLOAD/install-manifest.json" >/dev/null
EQUIPO_INSTALL_RELEASE="$EQUIPO_INSTALL_ROOT/releases/$EQUIPO_INSTALL_VERSION"
mkdir -p "$EQUIPO_INSTALL_ROOT/releases"
mkdir "$EQUIPO_INSTALL_RELEASE"
install -m 700 "$EQUIPO_DOWNLOAD/equipo-runner" "$EQUIPO_INSTALL_RELEASE/"
install -m 700 "$EQUIPO_DOWNLOAD/equipo-tool-proxy" "$EQUIPO_INSTALL_RELEASE/"
install -m 600 "$EQUIPO_DOWNLOAD/install-manifest.json" "$EQUIPO_INSTALL_RELEASE/"
export EQUIPO_TOOL_PROXY_PATH="$EQUIPO_INSTALL_RELEASE/equipo-tool-proxy"
export EQUIPO_INSTALL_ROOT
python3 - <<'PY'
import json, os, pathlib
root = pathlib.Path(os.environ['EQUIPO_INSTALL_ROOT'])
p = root / 'runner.env'
original = p.read_bytes()
with (root / 'runner.env.before-enable-execution').open('xb') as backup:
    backup.write(original)
updates = {k: os.environ[k] for k in ('EQUIPO_CLAUDE_PATH', 'EQUIPO_TOOL_PROXY_PATH')}
lines = original.decode().splitlines()
assert all(sum(line.startswith(k + '=') for line in lines) == 1 for k in updates)
p.write_text('\n'.join(k + '=' + json.dumps(updates[k]) if k in updates else line
                       for line in lines for k in [line.partition('=')[0]]) + '\n')
p.chmod(0o600)
PY
export EQUIPO_MACHINE_LABEL=docs-t1
"$EQUIPO_INSTALL_RELEASE/equipo-runner" enrol
```

While `enrol` waits, open
[https://equipo.bds.oncarlos.com/runners/enrol](https://equipo.bds.oncarlos.com/runners/enrol).
Enter the terminal's one-time code in **Code from your machine**, click
**Check machine**, check the `docs-t1` label, key fingerprint and request time,
compare the fingerprint before clicking **Approve machine**. Run this in a
second terminal while enrolment waits; it prints only the hash of the public key:

```bash
python3 - <<'PYCODE'
import base64, hashlib, json, pathlib
p = pathlib.Path.home() / '.local/share/equipo-runner/state/machine-key.json'
s = json.loads(p.read_text())
key = base64.urlsafe_b64decode(s + '=' * (-len(s) % 4))
assert len(key) == 64
print(hashlib.sha256(key[32:]).hexdigest())
PYCODE
```

Click **Approve machine** once those details match. The code expires after ten
minutes. Wait for `enrol` to exit successfully. A retry
reuses a still-valid pending code; an already enrolled matching state returns
success without another code. Never delete existing state to force enrolment.

Then install and start the user service, still in the same shell:

```bash
mkdir -p "$HOME/.config/systemd/user"
cat > "$EQUIPO_INSTALL_ROOT/equipo-runner.service" <<UNIT
[Unit]
Description=equipo-runner
[Service]
Type=simple
EnvironmentFile=$EQUIPO_INSTALL_ROOT/runner.env
ExecStart=$EQUIPO_INSTALL_RELEASE/equipo-runner run
Restart=on-failure
RestartSec=5
TimeoutStopSec=45
KillMode=control-group
UMask=0077
NoNewPrivileges=yes
[Install]
WantedBy=default.target
UNIT
chmod 600 "$EQUIPO_INSTALL_ROOT/equipo-runner.service"
systemctl --user link "$EQUIPO_INSTALL_ROOT/equipo-runner.service"
systemctl --user daemon-reload
systemctl --user enable --now equipo-runner.service
systemctl --user status equipo-runner.service --no-pager
rm -rf "$EQUIPO_DOWNLOAD"
trap - EXIT
```

If the earlier `Linger` result was `no`, the user service stops after logout.
Keep the user session open; no root or lingering change is part of this task.
Starting the service is the point at which real work can begin. The manual
route uses the same certified binaries and existing live-gate containment
setup, but does not run the installer's containment probe; do not use it on a
machine whose bubblewrap/user-namespace prerequisites have changed. The runner
still enforces its runtime checks. In **Connections**, confirm that the
existing accounts are reported before requesting a task. The runner will
continue to refuse any route without a matching policy certificate.

## Handoff

Implementation and controller instructions are ready on `enable-execution`.
Human review, merge and versioned deployment remain with the controller; Paul
then approves docs-t1's device code. The local full CI result and focused
reruns are recorded above, including the pre-existing intermittent account test
and advisory timing overruns. Task scratch, release binaries and logs were
removed. No server or background process from this task remains.
