oficina / equipo Public

feat: add supervised runner trials and dedicated-user setup

Add owner consent, version lapse, trial provenance and charged reconnect waiting. Keep containment, Codex acknowledgement and Amadan publication gates intact. Document the dedicated OS user setup as draft copy.
codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev ad32cda9033675d1cef5ef9e2112d2d46b818df6 parent 96aaefd
47 files changed, +1,524 −85
  • docs/live-gate.md +199 −34
  • docs/superpowers/plans/CONTROLLER-REPORT-supervised-trial.md +131 −0
  • internal/equipo/app.go +1 −0
  • internal/equipo/connection_isolation.go +5 −1
  • internal/equipo/connection_selection.go +27 −1
  • internal/equipo/connection_views.go +8 −2
  • internal/equipo/connections.go +25 −1
  • internal/equipo/copy.go +24 −0
  • internal/equipo/live_changes.go +1 −0
  • internal/equipo/migrations/0017_supervised_trials.sql +10 −0
  • internal/equipo/models.go +1 −1
  • internal/equipo/runner_execution.go +5 −0
  • internal/equipo/runner_models.go +5 −2
  • internal/equipo/runners.go +9 −0
  • internal/equipo/supervised_trial.go +152 −0
  • internal/equipo/task_views.go +9 −0
  • internal/equipo/team/git_evidence.go +10 −2
  • internal/equipo/team/trial.go +72 −0
  • internal/equipo/team/trial_test.go +41 −0
  • internal/equipo/templates/connections.html +1 −1
  • internal/equipo/templates/runners.html +2 −0
  • internal/equipo/templates/task.html +1 −1
  • internal/equipo/templates/task_card.html +4 −2
  • internal/equipo/trial_handlers.go +23 −0
  • internal/equipotest/live_gate_test.go +31 −1
  • internal/equipotest/trial_test.go +157 −0
  • internal/runner/config.go +2 −1
  • internal/runner/connections.go +1 −1
  • internal/runner/forge/description.go +76 −0
  • internal/runner/forge/description_test.go +30 −0
  • internal/runner/paseo/client.go +62 −12
  • internal/runner/paseo/client_test.go +18 −1
  • internal/runner/paseo/trial.go +38 −0
  • internal/runner/paseo/trial_test.go +79 −0
  • internal/runner/paseo/types.go +17 −11
  • internal/runner/runtime.go +10 −1
  • internal/runner/runtime_workflow.go +2 −2
  • internal/runner/supervisor.go +5 −1
  • internal/runner/trial.go +87 −0
  • internal/runner/trial_reconnect.go +34 −0
  • internal/runner/trial_test.go +54 −0
  • internal/runner/workflow_turn.go +12 −1
  • internal/runner/workspace/workspace.go +3 −0
  • internal/runnerproto/types.go +2 −0
  • runner/paseo/bridge.mjs +6 −3
  • runner/paseo/bridge.test.mjs +23 −0
  • scripts/live-gate.sh +9 −2

CI passed — run details

diff --git a/docs/live-gate.md b/docs/live-gate.md
index 41425c6c..fca11242 100644
--- a/docs/live-gate.md
+++ b/docs/live-gate.md
@@ -2,20 +2,186 @@ DRAFT: copy review required
# Paul's runner live gate
-The current build cannot pass this gate. Paseo 0.14.0 lacks per-agent account
-binding and no-failover guarantees, provider version reporting, effective
-isolation configuration, and recoverable completion. These are discussion 3,
-items 1 through 4. Amadan lacks branch description readback, item 5.
-Containment on docs-t1 needs a dedicated runner OS user or Paseo cgroup
-ownership, item 6. The runner service's own cgroup does not cover agents
-started by a separate shared Paseo daemon.
-
-The three tagged tests currently probe the shipped adapter and fail on those
-missing capabilities. They also fail if preflight becomes green without the
-remaining live observations being implemented. They do not yet dispatch the
-sentinel or calibration turns. Resolve the owning-product contracts, implement
-the probes below against those supported contracts, and review them before
-attempting acceptance. A failed or skipped test supplies no verified tuple.
+Paul can enable supervised trial per enrolled runner in Machines. The consent
+records the owner, time and observed Paseo and provider versions. It lapses on
+version changes, owner removal or demotion, or when an owner turns it off.
+Codex still needs its separate unconfined acknowledgement in Connections.
+Without current consent, the four missing Paseo capabilities still block work.
+
+Trial dispatch requests the chosen connection's credential home. An observed
+account mismatch stops the step. Otherwise the account remains unverified;
+Equipo never tries another account. Provider versions come from the local CLI
+and are recorded as observed locally. Effective isolation remains unknown, so
+all trial work is unconfined. After a reconnect gap, the task waits for a person
+with its reservation charged. Steps, evidence and branch descriptions retain
+both labels and the list of unverified checks after consent ends.
+
+Containment, the trusted check executor, independent-family review, budgets,
+cancel and Amadan description readback remain required. The planned readback
+uses `GET /api/v1/repos/{ns}/{repo}/branches/{name}/description`, also exposed by
+`amadan branch show <ns>/<repo> <name> -json`. The production publication
+transport still refuses pending verification of the deployed API and ordering.
+
+The tagged live probes still require the full upstream contracts and currently
+fail. They do not dispatch sentinel or calibration turns. Trial consent is not
+sentinel evidence and must never add a verified isolation tuple. Complete and
+review those probes before claiming the live gate passed.
+
+## Create the dedicated runner user on docs-t1
+
+These are Paul's commands. The coding agent never runs `sudo`, enrols a machine,
+starts real Paseo agents or deploys a release. Run this preparation yourself after
+copy review. The runner user owns both its Paseo daemon and its provider logins.
+Keep ordinary interactive work under your existing user.
+
+From your own shell on docs-t1, create a user with a locked password and enable
+its user services at boot. Do not give it SSH keys or add it to the sudo group.
+
+```sh
+sudo useradd --create-home --shell /bin/bash equipo-runner
+sudo passwd --lock equipo-runner
+sudo chmod 0700 /home/equipo-runner
+sudo loginctl enable-linger equipo-runner
+sudo -iu equipo-runner
+```
+
+The remaining commands in this section run in that new shell. Install the pinned
+Node release and the provider CLIs in this user's home. The archive is checked
+against Node's published checksum. Downloads and Go scratch stay on disk.
+
+```sh
+umask 077
+mkdir -p "$HOME/.local" "$HOME/.local/bin" "$HOME/.cache/equipo-install" "$HOME/.cache/tmp"
+export TMPDIR="$HOME/.cache/tmp"
+export PATH="$HOME/.local/bin:$PATH"
+cd "$HOME/.cache/equipo-install"
+curl --fail --show-error --location --remote-name https://nodejs.org/dist/v24.19.0/node-v24.19.0-linux-x64.tar.xz
+curl --fail --show-error --location --remote-name https://nodejs.org/dist/v24.19.0/SHASUMS256.txt
+awk '$2 == "node-v24.19.0-linux-x64.tar.xz"' SHASUMS256.txt | sha256sum --check --strict
+tar -xJf node-v24.19.0-linux-x64.tar.xz --strip-components=1 -C "$HOME/.local"
+npm config set prefix "$HOME/.local"
+npm install --global @getpaseo/cli@0.14.0 @anthropic-ai/claude-code@2.1.312 @openai/codex@0.165.0
+node --version
+claude --version
+codex --version
+claude auth login --claudeai
+codex login --device-auth
+cd "$HOME"
+rm "$HOME/.cache/equipo-install/node-v24.19.0-linux-x64.tar.xz" "$HOME/.cache/equipo-install/SHASUMS256.txt"
+rmdir "$HOME/.cache/equipo-install"
+```
+
+Complete both browser sign-ins as yourself. These credentials belong under
+`/home/equipo-runner/.claude` and `/home/equipo-runner/.codex`. Do not copy your
+existing credentials or expose those directories to a repository. Disable
+Claude auto-updates with `DISABLE_AUTOUPDATER=1` in both service environments; an observed update
+requires fresh consent and adapter support for that version.
+
+Install the pinned Go toolchain as equipo-runner. Its download is checked
+against the checksum published in Go's release list. Leave Go caches at their
+defaults.
+
+```sh
+mkdir -p "$HOME/.cache/equipo-install"
+cd "$HOME/.cache/equipo-install"
+curl --fail --show-error --location --output go.tar.gz https://go.dev/dl/go1.26.10.linux-amd64.tar.gz
+curl --fail --show-error --location --output go-releases.json 'https://go.dev/dl/?mode=json&include=all'
+python3 - <<'CHECK'
+import hashlib, json
+releases = json.load(open('go-releases.json'))
+match = next(f for r in releases for f in r['files'] if f['filename'] == 'go1.26.10.linux-amd64.tar.gz')
+with open('go.tar.gz', 'rb') as archive:
+ assert hashlib.file_digest(archive, 'sha256').hexdigest() == match['sha256']
+CHECK
+test ! -e "$HOME/.local/go-dist"
+tar -xzf go.tar.gz -C "$HOME/.cache/equipo-install"
+mv go "$HOME/.local/go-dist"
+cd "$HOME"
+rm "$HOME/.cache/equipo-install/go.tar.gz" "$HOME/.cache/equipo-install/go-releases.json"
+rmdir "$HOME/.cache/equipo-install"
+```
+
+After the reviewed release has been built, Paul runs these commands from his
+original user shell. Change `RUNNER_BUNDLE` to that versioned bundle's absolute
+path. Do not change ownership of the source checkout.
+
+```sh
+RUNNER_BUNDLE=/absolute/path/to/reviewed/equipo-runner-linux-amd64
+sudo install -d -o equipo-runner -g equipo-runner -m 0700 /home/equipo-runner/.local/lib/equipo-runner
+sudo cp -a "$RUNNER_BUNDLE/." /home/equipo-runner/.local/lib/equipo-runner/
+sudo chown -R equipo-runner:equipo-runner /home/equipo-runner/.local/lib/equipo-runner
+```
+
+Continue in the equipo-runner shell.
+
+Start a separate loopback Paseo service. Check `ss -ltn` first; if port 6773 is
+occupied, choose a free loopback port and use it in both units and runner.env.
+
+```sh
+export XDG_RUNTIME_DIR="/run/user/$(id -u)"
+export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
+mkdir -p "$HOME/.config/systemd/user" "$HOME/.config/equipo-runner" "$HOME/.paseo"
+cat > "$HOME/.config/systemd/user/equipo-paseo.service" <<'UNIT'
+[Unit]
+Description=Equipo Paseo daemon
+[Service]
+Type=simple
+Environment=PATH=/home/equipo-runner/.local/bin:/usr/local/bin:/usr/bin:/bin
+Environment=PASEO_HOME=/home/equipo-runner/.paseo
+Environment=PASEO_LISTEN=127.0.0.1:6773
+Environment=TMPDIR=/home/equipo-runner/.cache/tmp
+Environment=DISABLE_AUTOUPDATER=1
+ExecStart=/home/equipo-runner/.local/bin/paseo daemon run --home /home/equipo-runner/.paseo
+Restart=on-failure
+RestartSec=5
+UMask=0077
+[Install]
+WantedBy=default.target
+UNIT
+systemctl --user daemon-reload
+systemctl --user enable --now equipo-paseo.service
+paseo daemon status --home "$HOME/.paseo" --json
+```
+
+Record the daemon's server ID and observed version from that status. This daemon
+must be version 0.14.0. Do not point the runner at Paul's existing daemon.
+
+The runner normally fetches its own clones using a disclosed Amadan agent
+credential. Provision that credential privately in
+`/home/equipo-runner/.config/equipo-runner/forge.json`, mode 0600, with an `agent`
+identity and a `repositories` map from the exact `amadan.net/namespace/repository`
+to its credential. Give it only the disposable repositories needed for the gate.
+This avoids granting access to Paul's home or existing clones. Any manually
+copied clone must be owned by the runner user and contain no saved credentials.
+
+Create `bindings.json`, mode 0600, in the same directory. Each selected connection
+needs `id`, `local_id`, `provider`, `family`, `model`, `account_id`, `credential_home`
+and `kind`. Claude uses family `claude`, Codex uses `gpt`; `kind` is `subscription`.
+Use the actual provider account identities and exact installed model IDs. The
+credential homes are the two paths above. Account IDs select the requested
+connection; they do not prove which account the provider opened.
+
+Create `runner.env` using the table below, plus `PATH`, `TMPDIR` and `DISABLE_AUTOUPDATER=1` from this
+section. Keep it mode 0600 and use plain `KEY=value` entries. Supply the real
+instance origin, instance ID and observed Paseo server ID. Then, as equipo-runner:
+
+```sh
+mkdir -p "$HOME/.local/state/equipo" "$HOME/equipo-work" "$HOME/.cache/equipo-scratch"
+chmod 0700 "$HOME/.local/state/equipo"
+set -a
+. "$HOME/.config/equipo-runner/runner.env"
+set +a
+"$HOME/.local/lib/equipo-runner/equipo-runner" enrol
+cp "$HOME/.local/lib/equipo-runner/equipo-runner.service" "$HOME/.config/systemd/user/"
+systemctl --user daemon-reload
+systemctl --user enable --now equipo-runner.service
+```
+
+Open the displayed approval page and check the origin and machine fingerprint.
+In Machines, enable supervised trial after fresh connection reports arrive.
+Then acknowledge the exact Codex connection in Connections and enable the chosen
+connections for the disposable project. Enabling trial alone grants no project
+access. Both services were installed by you and may stay running for your trial.
## Prepare the machine and instance
@@ -23,8 +189,7 @@ attempting acceptance. A failed or skipped test supplies no verified tuple.
instance origin, machine fingerprint, repository, base commit, review ref,
connection IDs, provider accounts and chosen models. Leave other projects,
agents and the shared daemon unchanged. Do not enrol tito-studio.
-2. Resolve process ownership first. Arrange a dedicated runner OS user or
- supported Paseo cgroup ownership. The runner must account for every owned
+2. Resolve process ownership first. Use the dedicated runner OS user and its own Paseo daemon above. The runner must account for every owned
agent, terminal and background process across reconnect and restart.
Unknown coverage blocks work and cannot be called stopped.
3. Review pending copy and the clean commit. From that commit run `make release`
@@ -51,7 +216,7 @@ attempting acceptance. A failed or skipped test supplies no verified tuple.
sign-in link into gate evidence. Enrol the second member separately.
7. Run `systemctl --user daemon-reload`, then
`systemctl --user enable --now equipo-runner.service`. Inspect its status.
- Only this human-installed service may remain running after acceptance.
+ Only the runner and Paseo services you installed may remain running after acceptance.
8. In Connections, enable each person's own accounts for the disposable
project and choose the pins. A current team owner must acknowledge the
exact Codex connection after checking its observed provider version,
@@ -120,8 +285,8 @@ runs exactly:
EQUIPO_LIVE_PASEO=1 go test -tags paseo_live ./internal/runner/paseo -run 'TestPaseoLiveContract|TestPaseoLiveReadIsolation|TestPaseoLiveTurnCalibration' -count=1
```
-Keep the exit status and full nonsecret output. Today this command fails on
-the blockers above. Do not turn that result into a pass or use an offline
+Keep the exit status and full nonsecret output. Today these full-contract probes
+still fail; the trial behaviours are covered by the targeted offline tests. Do not turn that result into a pass or use an offline
fixture as live proof.
After every required assertion passes, record each exact provider, provider
@@ -168,9 +333,8 @@ fresh authority and timeline recovery.
## Runner environment
-All these settings are required for run, enrol, preflight and reset. Examples use
-an operator account named runner. Replace its paths and the observed identities
-with your own values. Diagnostics print a reason code and variable name, never its
+All these settings are required for run, enrol, preflight and reset. Examples use the dedicated equipo-runner user. Replace the instance values and
+observed identities with your own. Diagnostics print a reason code and variable name, never its
value. `runner.config.path` means the path must be absolute and canonical;
`runner.config.overlap` means it overlaps the private state directory.
@@ -178,21 +342,22 @@ value. `runner.config.path` means the path must be absolute and canonical;
| --- | --- | --- |
| EQUIPO_ORIGIN | Instance origin, HTTPS except local loopback fixtures | https://equipo.example |
| EQUIPO_INSTANCE_ID | Enrolled instance identity | equipo-team |
-| EQUIPO_RUNNER_STATE_DIR | Private journal, keys and credentials directory, mode 0700 | /home/runner/.local/state/equipo |
-| EQUIPO_PASEO_HOME | Existing Paseo daemon home | /home/runner/.paseo |
+| EQUIPO_RUNNER_STATE_DIR | Private journal, keys and credentials directory, mode 0700 | /home/equipo-runner/.local/state/equipo |
+| EQUIPO_PASEO_HOME | Existing Paseo daemon home | /home/equipo-runner/.paseo |
| EQUIPO_PASEO_ENDPOINT | Loopback daemon host and port | 127.0.0.1:6773 |
| EQUIPO_PASEO_SERVER_ID | Observed daemon identity | observed-server-id |
-| EQUIPO_NODE_PATH | Pinned Node executable | /home/runner/.local/bin/node |
-| EQUIPO_BRIDGE_PATH | Bridge from the versioned runner bundle | /home/runner/.local/lib/equipo-runner/paseo/bridge.mjs |
-| EQUIPO_ACCOUNT_BINDINGS_PATH | Private JSON account binding file, mode 0600 | /home/runner/.config/equipo-runner/bindings.json |
-| EQUIPO_AMADAN_CREDENTIAL_PATH | Private forge credential file, mode 0600 | /home/runner/.config/equipo-runner/forge.json |
-| EQUIPO_CODEX_PATH | Pinned Codex command sandbox executable | /home/runner/.local/bin/codex |
-| EQUIPO_GO_ROOT | Pinned Go installation | /home/runner/.local/go-dist |
-| EQUIPO_GO_BINARY | Go executable inside that installation | /home/runner/.local/go-dist/bin/go |
-| EQUIPO_WORKSPACE_ROOT | Disposable checkout directory outside private state | /home/runner/equipo-work |
-| EQUIPO_SCRATCH_ROOT | On-disk scratch directory outside private state | /home/runner/.cache/equipo-scratch |
+| EQUIPO_NODE_PATH | Pinned Node executable | /home/equipo-runner/.local/bin/node |
+| EQUIPO_BRIDGE_PATH | Bridge from the versioned runner bundle | /home/equipo-runner/.local/lib/equipo-runner/paseo/bridge.mjs |
+| EQUIPO_ACCOUNT_BINDINGS_PATH | Private JSON account binding file, mode 0600 | /home/equipo-runner/.config/equipo-runner/bindings.json |
+| EQUIPO_AMADAN_CREDENTIAL_PATH | Private forge credential file, mode 0600 | /home/equipo-runner/.config/equipo-runner/forge.json |
+| EQUIPO_CLAUDE_PATH | Claude executable used for local version observation in trial | /home/equipo-runner/.local/bin/claude |
+| EQUIPO_CODEX_PATH | Pinned Codex command sandbox executable | /home/equipo-runner/.local/bin/codex |
+| EQUIPO_GO_ROOT | Pinned Go installation | /home/equipo-runner/.local/go-dist |
+| EQUIPO_GO_BINARY | Go executable inside that installation | /home/equipo-runner/.local/go-dist/bin/go |
+| EQUIPO_WORKSPACE_ROOT | Disposable checkout directory outside private state | /home/equipo-runner/equipo-work |
+| EQUIPO_SCRATCH_ROOT | On-disk scratch directory outside private state | /home/equipo-runner/.cache/equipo-scratch |
| EQUIPO_GIT_PATH | Git executable | /usr/bin/git |
-| EQUIPO_RUNNER_EXECUTABLE | Runner from the versioned bundle | /home/runner/.local/lib/equipo-runner/equipo-runner |
+| EQUIPO_RUNNER_EXECUTABLE | Runner from the versioned bundle | /home/equipo-runner/.local/lib/equipo-runner/equipo-runner |
The runner supplies the following variables to its children. Do not set them in
runner.env or reuse values from a previous attempt.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-supervised-trial.md b/docs/superpowers/plans/CONTROLLER-REPORT-supervised-trial.md
new file mode 100644
index 00000000..d64dbfcb
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-supervised-trial.md
@@ -0,0 +1,131 @@
+DRAFT: copy review required
+
+# Supervised trial controller report
+
+Implemented the 2026-11-03 trial brief on `runner`, starting at `96aaefd`.
+The trial brief supersedes plan 2's refusal for the four named Paseo gaps.
+The design, plan 2 rulings and dispositions, live-gate instructions and Equipo
+discussion 3 were read. No other agents or model reviewers were used.
+
+## Behaviour
+
+A current team owner can enable or turn off supervised trial for an enrolled
+runner from Machines. The additive `supervised_trials` table records the owner,
+owner revision, runner, time and reported provider/server versions. Each write
+checks the roster inside its transaction and records an audit event. A version
+change revokes consent durably, including a change followed by a downgrade.
+Owner removal or demotion makes the saved owner revision unusable. Reports must
+be fresh; missing connections cannot remain eligible through trial metadata.
+
+Discovery can report trial eligibility while preflight still refuses dispatch.
+The runner needs an authenticated, current assignment carrying consent before
+trial preflight succeeds. Codex's separate acknowledgement remains required.
+The requested credential home travels through Paseo's supported per-agent
+environment. An observed account mismatch refuses the session. Missing account
+observation remains labelled, with no retry against another account.
+
+The runner executes the configured provider's `--version` under its own OS user.
+Trial records distinguish this local observation from Paseo reporting. The
+requested policy hash identifies the tuple; it is never evidence that the
+policy took effect. Every trial connection is unconfined. Historical trial
+consent, local version provenance and unverified checks survive in step,
+artifact, event, executor and publication isolation records and in the views.
+
+A trial subscription cannot be resumed or replaced after a gap. The runner
+persists the admitted action before sending, reports an interrupted action as
+lost, and preserves the full reservation. The task waits visibly for a person.
+Restart recovery reports saved in-flight trial actions before containment.
+Containment and credential rotation continue through the existing supervisor.
+
+Production publication remains disabled. `forge.ReadBranchDescription` prepares
+the announced GET request with escaped branch names, authenticated readback,
+redirect refusal, bounded response size, author checks and content-hash checks.
+Its request and response match the Amadan branch-description-read worktree.
+The deployed contract and ordering still require verification before enabling it.
+
+The live-gate draft describes Paul's commands for a dedicated `equipo-runner`
+user, locked password, lingering, pinned installations, separate loopback Paseo
+service, provider logins, private credentials, runner-owned clones and enrolment.
+The script requires that OS user and its daemon home. New runtime strings are
+individually marked pending in `internal/equipo/copy.go`; release copy checking
+continues to refuse pending copy. README prose and vendored static files are
+unchanged.
+
+## Verification
+
+Initial failing tests:
+
+- `CGO_ENABLED=0 go test ./internal/runner/paseo ./internal/equipotest -run TestSupervisedTrial -count=1`
+ failed because the trial types and methods did not exist.
+- `node --test --test-name-pattern='trial routes' runner/paseo/bridge.test.mjs`
+ failed with `invalid_request` before credential-home routing was implemented.
+- `CGO_ENABLED=0 go test ./internal/runner/forge -run TestPlannedAmadanDescriptionReadback -count=1`
+ failed because the planned client did not exist.
+
+Restored targeted gate:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/paseo ./internal/equipotest ./internal/equipo/team ./internal/runner ./internal/runner/forge -run 'TestSupervisedTrial|TestTrial|TestPlannedAmadan' -count=1
+node --test runner/paseo/bridge.test.mjs
+sh -n scripts/live-gate.sh
+git diff --check
+```
+
+All passed. The Go gate covers trial off/on, missing consent, all four gap
+behaviours, owner and version lapse, downgrade after lapse, missing profiles,
+account mismatch, local version reads, unconfined labels on the task surfaces,
+evidence and descriptions, charged reconnect waiting and refusal of readmission.
+The bridge suite passes all 31 tests. Existing unsupported-capability,
+unconfined-label and migration parity tests also passed in targeted runs.
+
+Each mutation below was applied alone, observed failing its named test, then
+restored. Commands used `CGO_ENABLED=0 go test <package> -run '^<test>$' -count=1`.
+
+| Broken guard | Package | Failing test |
+| --- | --- | --- |
+| Authorize trial without consent | `./internal/runner/paseo` | `TestSupervisedTrialDispatchAccount/off` |
+| Accept a different observed account | `./internal/runner/paseo` | `TestSupervisedTrialPreflight/mismatch` |
+| Accept unknown process coverage | `./internal/runner/paseo` | `TestSupervisedTrialPreflight/containment` |
+| Ignore the approving owner's role | `./internal/equipotest` | `TestSupervisedTrialConsent/demote` |
+| Stop recording permanent version lapse | `./internal/equipotest` | `TestSupervisedTrialConsent/provider` |
+| Strip trial from selection provenance | `./internal/equipotest` | `TestSupervisedTrialConsent/on` |
+| Complete an uncertain trial as failed | `./internal/runner` | `TestTrialReconnectWaitsWithoutRetry` |
+| Use the wrong description endpoint | `./internal/runner/forge` | `TestPlannedAmadanDescriptionReadback` |
+
+The first owner-guard mutation caused an unused-variable build failure. It was
+restored and replaced with a compiling mutation; the named assertion then failed.
+The full bridge suite also exposed shared fixture state in the new routing test;
+the assertion now checks the provider selected by that fixture. Both targeted
+and complete bridge runs pass.
+
+`make ci` ran once in the background with network access and default Go caches.
+Build, vet, formatting, staticcheck, govulncheck, gitleaks and size budgets passed.
+The full Go suite had one failure: `TestLiveGateConfirmation` used the old shared
+user fixture. All other packages and tests passed. The runner package took
+199.588 seconds; the integration package took 203.007 seconds, within their
+existing budgets.
+
+The confirmation fixture now supplies a fake dedicated user and the required
+loopback daemon configuration. The real live gate is never invoked by the test.
+`CGO_ENABLED=0 go test ./internal/equipotest -run 'TestLiveGateConfirmation|TestLiveGateRequiresDedicatedUser' -count=1`
+passes. Removing each of the script's user, daemon-home and loopback checks
+individually failed `TestLiveGateRequiresDedicatedUser/user`, `/home` and
+`/endpoint`; the script was restored and both tests passed again.
+
+`make runner-adapter-test migration-check perf` then completed the remaining CI
+targets successfully. The complete bridge suite passed 31 tests, migration parity
+passed, all screen medians were below 150 ms, and cold boot was 59 ms against
+500 ms. `make vet fmt-check staticcheck budget` also passed after the test fixture
+change. There was no second full-suite or `make ci` run.
+
+## Remaining human work
+
+Review pending copy before a release. Verify Amadan's deployed readback and
+ordering before enabling the production transport. Complete the live probes and
+calibration before claiming live acceptance. Trial never enters the verified
+isolation tuple list.
+
+No machine was enrolled, no real Paseo agent or service was started, and no sudo,
+merge or deployment command was executed. Only test fixtures and local inspection
+were used. The final handback records the commit, push and CI result. Task scratch
+and test processes are removed before handback.
diff --git a/internal/equipo/app.go b/internal/equipo/app.go
index 261301ca..cf8844b9 100644
--- a/internal/equipo/app.go
+++ b/internal/equipo/app.go
@@ -187,6 +187,7 @@ func RouterWithStore(d *db.DB, cfg Config, mailer mail.Sender, logger *slog.Logg
r.Post("/tasks/{id}/questions/{question}/answer", a.answerQuestion)
r.Post("/runners/enrol", a.approveEnrolment)
r.Post("/runners/{id}/revoke", a.revokeRunner)
+ r.Post("/runners/{id}/supervised-trial", a.supervisedTrial)
r.Post("/projects/{id}/connections", a.saveConnectionChoice)
r.Post("/connections/{id}/acknowledge", a.acknowledgeConnection)
r.Post("/connections/{id}/revoke-acknowledgement", a.revokeConnectionAcknowledgement)
diff --git a/internal/equipo/connection_isolation.go b/internal/equipo/connection_isolation.go
index 896c01bb..54425b40 100644
--- a/internal/equipo/connection_isolation.go
+++ b/internal/equipo/connection_isolation.go
@@ -61,7 +61,11 @@ func (s *Store) AcknowledgeUnconfined(ctx context.Context, actor Actor, id strin
}
r := c.Reports[0]
now := s.runnerClock.Now().UTC()
- if s.confined(r) || !unconfinedException(r) || !routingValid(r) || !r.Available || !freshConnection(c, now) {
+ trial, err := s.trialSnapshot(tx, c)
+ if err != nil {
+ return err
+ }
+ if s.confined(r) || !unconfinedException(r) || (!(routingValid(r) && r.Available) && !(trial != nil && trialRouting(r))) || !freshConnection(c, now) {
return ErrForbidden
}
if _, err := currentRunnerMember(tx, c.Person); err != nil {
diff --git a/internal/equipo/connection_selection.go b/internal/equipo/connection_selection.go
index 6a704115..8304bb74 100644
--- a/internal/equipo/connection_selection.go
+++ b/internal/equipo/connection_selection.go
@@ -15,7 +15,7 @@ func freshConnection(c connectionRecord, now time.Time) bool {
return !c.LastSeen.After(now) && now.Sub(c.LastSeen) < 90*time.Second
}
func (s *Store) eligible(tx *gorm.DB, c connectionRecord, r ConnectionReport, now time.Time) (bool, IsolationAcknowledgement, error) {
- if !r.Available || !freshConnection(c, now) || !routingValid(r) {
+ if !freshConnection(c, now) || (!(r.Available && routingValid(r)) && !trialRouting(r)) {
return false, IsolationAcknowledgement{}, nil
}
instance, err := runnerInstance(tx)
@@ -29,6 +29,23 @@ func (s *Store) eligible(tx *gorm.DB, c connectionRecord, r ConnectionReport, no
if err != nil {
return false, IsolationAcknowledgement{}, err
}
+ trial, err := s.trialSnapshot(tx, c)
+ if err != nil {
+ return false, IsolationAcknowledgement{}, err
+ }
+ if trial != nil && trialRouting(r) {
+ if r.Provider != "codex" {
+ return true, IsolationAcknowledgement{}, nil
+ }
+ ack, err := s.acknowledgementAt(tx, c, r)
+ if errors.Is(err, ErrForbidden) {
+ return false, ack, nil
+ }
+ return err == nil, ack, err
+ }
+ if !r.Available || !routingValid(r) {
+ return false, IsolationAcknowledgement{}, nil
+ }
if s.confined(r) {
return true, IsolationAcknowledgement{}, nil
}
@@ -202,6 +219,15 @@ func (s *Store) isolationSnapshot(tx *gorm.DB, c connectionRecord, r ConnectionR
if !s.confined(r) {
snapshot.Status = "unconfined"
}
+ trial, err := s.trialSnapshot(tx, c)
+ if err != nil {
+ return snapshot, err
+ }
+ if trial != nil {
+ snapshot.Trial = trial
+ snapshot.Status = "unconfined"
+ snapshot.RunnerTainted = true
+ }
var choices []connectionChoiceRecord
if err := tx.Where("person = ?", c.Person).Find(&choices).Error; err != nil {
return snapshot, storeError(err)
diff --git a/internal/equipo/connection_views.go b/internal/equipo/connection_views.go
index 9c44b567..3b9b1a32 100644
--- a/internal/equipo/connection_views.go
+++ b/internal/equipo/connection_views.go
@@ -1,6 +1,7 @@
package equipo
import (
+ "amadan.net/oficina/equipo/internal/equipo/team"
"encoding/json"
"errors"
"net/http"
@@ -10,6 +11,7 @@ import (
)
type ConnectionView struct {
+ Isolation team.IsolationSnapshot
Connection
Report ConnectionReport
Unconfined, Unverified, Acknowledged, Available bool
@@ -48,8 +50,12 @@ func (a *application) connectionsPage(w http.ResponseWriter, r *http.Request, da
if err != nil {
return err
}
- unverified := !a.store.confined(report) && !unconfinedException(report)
- data.Connections = append(data.Connections, ConnectionView{Connection: row.Connection, Report: report, Unverified: unverified, Unconfined: !a.store.confined(report) && !unverified, Acknowledged: ack.ID != "", Available: available})
+ iso, err := a.store.isolationSnapshot(tx, row, report)
+ if err != nil {
+ return err
+ }
+ unverified := iso.Trial == nil && !a.store.confined(report) && !unconfinedException(report)
+ data.Connections = append(data.Connections, ConnectionView{Isolation: iso, Connection: row.Connection, Report: report, Unverified: unverified, Unconfined: (iso.Trial != nil || !a.store.confined(report)) && !unverified, Acknowledged: ack.ID != "", Available: available})
}
}
var projects []Project
diff --git a/internal/equipo/connections.go b/internal/equipo/connections.go
index 991ce8c7..2ab86a47 100644
--- a/internal/equipo/connections.go
+++ b/internal/equipo/connections.go
@@ -21,7 +21,7 @@ func reportTuple(r ConnectionReport) team.IsolationTuple {
return team.IsolationTuple{Provider: r.Provider, ProviderVersion: r.ProviderVersion, PaseoVersion: r.PaseoVersion, IsolationConfigHash: r.IsolationConfigHash}
}
func (s *Store) confined(r ConnectionReport) bool {
- return r.ReadIsolation && slices.Contains(s.verifiedIsolation, reportTuple(r))
+ return !r.TrialReady && r.ReadIsolation && slices.Contains(s.verifiedIsolation, reportTuple(r))
}
func hexHash(s string) bool {
b, err := hex.DecodeString(s)
@@ -139,10 +139,14 @@ func (s *Store) ReportConnections(ctx context.Context, principal RunnerPrincipal
}
}
if invalid {
+ if err := tx.Model(&supervisedTrialRecord{}).Where("runner_id=? AND revoked_at IS NULL", runner.ID).Select("RevokedAt").Updates(&supervisedTrialRecord{RevokedAt: &now}).Error; err != nil {
+ return storeError(err)
+ }
for _, c := range byLocal {
c.Revision++
for i := range c.Reports {
c.Reports[i].Available = false
+ c.Reports[i].TrialReady = false
}
data, _ := json.Marshal(c.Reports)
c.ReportsJSON = string(data)
@@ -218,6 +222,7 @@ func (s *Store) ReportConnections(ctx context.Context, principal RunnerPrincipal
changed = true
}
c.Reports[i].Available = false
+ c.Reports[i].TrialReady = false
}
if changed {
if err := invalidateConnection(tx, c, "profile_missing", now); err != nil {
@@ -230,6 +235,25 @@ func (s *Store) ReportConnections(ctx context.Context, principal RunnerPrincipal
return storeError(err)
}
}
+ var trials []supervisedTrialRecord
+ if err := tx.Where("runner_id=? AND revoked_at IS NULL", runner.ID).Find(&trials).Error; err != nil {
+ return storeError(err)
+ }
+ var current []connectionRecord
+ if err := tx.Where("runner_id=?", runner.ID).Find(&current).Error; err != nil {
+ return storeError(err)
+ }
+ versions, versionErr := trialVersions(current)
+ for _, a := range trials {
+ if versionErr != nil || versions != a.Versions {
+ if err := tx.Model(&supervisedTrialRecord{}).Where("id=?", a.ID).Select("RevokedAt").Updates(&supervisedTrialRecord{RevokedAt: &now}).Error; err != nil {
+ return storeError(err)
+ }
+ if err := appendAudit(tx, Actor{Address: runner.Person}, "runner.trial.lapsed", a.ID); err != nil {
+ return err
+ }
+ }
+ }
return appendAudit(tx, Actor{Address: runner.Person}, "connection.report", runner.ID)
})
if err != nil {
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index eb24b822..181d9219 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -201,6 +201,30 @@ func RunnerToolCopy() runner.ToolCopy {
// runnerDraftCopy is the Task 16 runtime inventory. Each entry needs review.
var runnerDraftCopy = map[string]string{
+ // COPY REVIEW REQUIRED: trial.label
+ "trial.label": "supervised trial",
+ // COPY REVIEW REQUIRED: trial.off
+ "trial.off": "Supervised trial is off or has lapsed.",
+ // COPY REVIEW REQUIRED: trial.enable
+ "trial.enable": "Enable supervised trial",
+ // COPY REVIEW REQUIRED: trial.disable
+ "trial.disable": "Turn off supervised trial",
+ // COPY REVIEW REQUIRED: trial.meaning
+ "trial.meaning": "Every step on this runner is unconfined. Account binding, automatic account changes, effective isolation and completion after reconnect remain unverified. Provider versions are observed locally. Consent lapses on version changes or when its owner loses their role.",
+ // COPY REVIEW REQUIRED: trial.reconnect
+ "trial.reconnect": "outcome uncertain after reconnect",
+ // COPY REVIEW REQUIRED: trial.observed_locally
+ "trial.observed_locally": "Provider version observed locally",
+ // COPY REVIEW REQUIRED: trial.check.account_unverified
+ "trial.check.account_unverified": "account unverified",
+ // COPY REVIEW REQUIRED: trial.check.no_failover
+ "trial.check.no_failover": "account failover unverified",
+ // COPY REVIEW REQUIRED: trial.check.provider_version
+ "trial.check.provider_version": "provider version not reported by Paseo",
+ // COPY REVIEW REQUIRED: trial.check.effective_isolation
+ "trial.check.effective_isolation": "effective isolation unverified",
+ // COPY REVIEW REQUIRED: trial.check.recoverable_completion
+ "trial.check.recoverable_completion": "completion recovery unverified",
// COPY REVIEW REQUIRED: connections.empty
"connections.empty": "No connections reported.",
// COPY REVIEW REQUIRED: task.provenance
diff --git a/internal/equipo/live_changes.go b/internal/equipo/live_changes.go
index c0b9d9b5..7b69e0a2 100644
--- a/internal/equipo/live_changes.go
+++ b/internal/equipo/live_changes.go
@@ -35,6 +35,7 @@ func installLiveChanges(ctx context.Context, tx *sql.Tx) (err error) {
return err
}
tables := map[string]string{
+ "supervised_trials": "SELECT team_id,job_id FROM runner_assignments WHERE runner_id=$runner_id AND state!='contained' UNION SELECT instance_id,0 FROM runners WHERE id=$runner_id",
"tasks": "SELECT $team_id,$job_id",
"task_outboxes": "SELECT team_id,job_id FROM tasks WHERE id=$task_id",
"questions": "SELECT team_id,job_id FROM tasks WHERE id=$task_id",
diff --git a/internal/equipo/migrations/0017_supervised_trials.sql b/internal/equipo/migrations/0017_supervised_trials.sql
new file mode 100644
index 00000000..f2a4ff18
--- /dev/null
+++ b/internal/equipo/migrations/0017_supervised_trials.sql
@@ -0,0 +1,10 @@
+CREATE TABLE supervised_trials (
+ id text PRIMARY KEY,
+ runner_id text,
+ owner text,
+ owner_revision integer,
+ acknowledged_at datetime,
+ versions text,
+ revoked_at datetime
+);
+CREATE INDEX trial_runner ON supervised_trials(runner_id);
diff --git a/internal/equipo/models.go b/internal/equipo/models.go
index 16d63199..8cbd63ab 100644
--- a/internal/equipo/models.go
+++ b/internal/equipo/models.go
@@ -2,7 +2,7 @@ package equipo
import "time"
-var Models = append([]any{&questionRecord{}, &runnerEvent{}, &runnerEventID{}, &runnerTimeline{}, &runnerArtifactRequest{}, &artifactBlob{}, &artifactBlobUpload{}, &runnerAssignment{}, &runnerCleanup{}, &runnerObservation{}, &runnerRotation{}, &executionAdmissionTicket{}, &Task{}, &taskOutbox{}, &Team{}, &Member{}, &AuditEvent{}, &Account{}, &Project{}, &DecisionOwner{}, &projectRequest{}, &budgetRecord{}, &Specialist{}, &runnerRecord{}, &runnerEnrolment{}, &runnerCredentialRecord{}, &runnerRate{}, &connectionRecord{}, &connectionChoiceRecord{}, &isolationAcknowledgementRecord{}, &ConnectionInvalidation{}}, executionModels...)
+var Models = append([]any{&supervisedTrialRecord{}, &questionRecord{}, &runnerEvent{}, &runnerEventID{}, &runnerTimeline{}, &runnerArtifactRequest{}, &artifactBlob{}, &artifactBlobUpload{}, &runnerAssignment{}, &runnerCleanup{}, &runnerObservation{}, &runnerRotation{}, &executionAdmissionTicket{}, &Task{}, &taskOutbox{}, &Team{}, &Member{}, &AuditEvent{}, &Account{}, &Project{}, &DecisionOwner{}, &projectRequest{}, &budgetRecord{}, &Specialist{}, &runnerRecord{}, &runnerEnrolment{}, &runnerCredentialRecord{}, &runnerRate{}, &connectionRecord{}, &connectionChoiceRecord{}, &isolationAcknowledgementRecord{}, &ConnectionInvalidation{}}, executionModels...)
type Role string
diff --git a/internal/equipo/runner_execution.go b/internal/equipo/runner_execution.go
index 301bb0b4..d4cd9039 100644
--- a/internal/equipo/runner_execution.go
+++ b/internal/equipo/runner_execution.go
@@ -52,6 +52,11 @@ func specialistFor(step string) string {
}
}
func mergeIsolation(a, b team.IsolationSnapshot) team.IsolationSnapshot {
+ a.Trial = team.MergeTrial(a.Trial, b.Trial)
+ if a.Trial != nil {
+ a.Status = "unconfined"
+ a.RunnerTainted = true
+ }
if b.Status == "unconfined" {
a.Status = "unconfined"
}
diff --git a/internal/equipo/runner_models.go b/internal/equipo/runner_models.go
index df1cb9b3..9f5b85e0 100644
--- a/internal/equipo/runner_models.go
+++ b/internal/equipo/runner_models.go
@@ -3,8 +3,11 @@ package equipo
import "time"
type Runner struct {
- ID string `gorm:"primaryKey"`
- Person string `gorm:"index:runner_person"`
+ TrialOwner string `gorm:"-"`
+ TrialAt time.Time `gorm:"-"`
+ TrialVersions string `gorm:"-"`
+ ID string `gorm:"primaryKey"`
+ Person string `gorm:"index:runner_person"`
MachineKeyHash string
Label string
Revision int64
diff --git a/internal/equipo/runners.go b/internal/equipo/runners.go
index 50f60c18..96d46a0a 100644
--- a/internal/equipo/runners.go
+++ b/internal/equipo/runners.go
@@ -194,6 +194,15 @@ func (s *Store) runnersFor(ctx context.Context, actor Actor) ([]Runner, error) {
return storeError(err)
}
for _, record := range records {
+ trial, err := s.trialAt(tx, record.ID)
+ if err != nil && !errors.Is(err, ErrForbidden) {
+ return err
+ }
+ if err == nil {
+ record.TrialOwner = trial.Owner
+ record.TrialAt = trial.AcknowledgedAt
+ record.TrialVersions = trial.Versions
+ }
result = append(result, record.Runner)
}
return nil
diff --git a/internal/equipo/supervised_trial.go b/internal/equipo/supervised_trial.go
new file mode 100644
index 00000000..8027fe21
--- /dev/null
+++ b/internal/equipo/supervised_trial.go
@@ -0,0 +1,152 @@
+package equipo
+
+import (
+ "context"
+ "crypto/rand"
+ "encoding/json"
+ "errors"
+ "sort"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo/team"
+ "gorm.io/gorm"
+)
+
+type supervisedTrialRecord struct {
+ ID string `gorm:"primaryKey"`
+ RunnerID string `gorm:"index:trial_runner"`
+ Owner string
+ OwnerRevision int64
+ AcknowledgedAt time.Time
+ Versions string
+ RevokedAt *time.Time
+}
+
+func (supervisedTrialRecord) TableName() string { return "supervised_trials" }
+
+func trialRouting(r ConnectionReport) bool {
+ v := r.Routing
+ return r.TrialReady && r.ProviderVersionSource == "observed_locally" && r.ProviderVersion != "" && r.PaseoVersion != "" && v.BindingID != "" && v.AccountID != "" && hexHash(v.CredentialHomeHash) && v.ProcessOwnership && (v.ObservedAccountID == "" || v.ObservedAccountID == v.AccountID)
+}
+func trialVersions(rows []connectionRecord) (string, error) {
+ versions := []string{}
+ for _, c := range rows {
+ if err := decodeConnection(&c); err != nil {
+ return "", err
+ }
+ for _, r := range c.Reports {
+ if r.ProviderVersion == "" || r.PaseoVersion == "" {
+ return "", ErrUnavailable
+ }
+ raw, _ := json.Marshal([]string{r.LocalID, r.Provider, r.ProviderVersion, r.PaseoVersion})
+ versions = append(versions, string(raw))
+ }
+ }
+ if len(versions) == 0 {
+ return "", ErrUnavailable
+ }
+ sort.Strings(versions)
+ raw, _ := json.Marshal(versions)
+ return string(raw), nil
+}
+func (s *Store) trialAt(tx *gorm.DB, runner string) (supervisedTrialRecord, error) {
+ var a supervisedTrialRecord
+ if err := tx.Where("runner_id=? AND revoked_at IS NULL", runner).Order("acknowledged_at DESC").First(&a).Error; err != nil {
+ if errors.Is(err, gorm.ErrRecordNotFound) {
+ return a, ErrForbidden
+ }
+ return a, storeError(err)
+ }
+ m, err := memberAt(tx, a.Owner)
+ if errors.Is(err, ErrNotFound) {
+ return a, ErrForbidden
+ }
+ if err != nil {
+ return a, err
+ }
+ if !m.Active || m.Role != RoleOwner || m.Revision != a.OwnerRevision {
+ return a, ErrForbidden
+ }
+ var rows []connectionRecord
+ if err := tx.Where("runner_id=?", runner).Find(&rows).Error; err != nil {
+ return a, storeError(err)
+ }
+ versions, err := trialVersions(rows)
+ if err != nil {
+ return a, err
+ }
+ if versions != a.Versions {
+ return a, ErrForbidden
+ }
+ return a, nil
+}
+func (s *Store) SetSupervisedTrial(ctx context.Context, actor Actor, runner string, revision int64, enabled bool) error {
+ return s.write(ctx, func(tx *gorm.DB) error {
+ if err := requireOwner(tx, actor); err != nil {
+ return err
+ }
+ owner, err := memberAt(tx, actor.Address)
+ if err != nil {
+ return err
+ }
+ instance, err := runnerInstance(tx)
+ if err != nil {
+ return err
+ }
+ machine, err := runnerAt(tx, instance, runner)
+ if err != nil {
+ return err
+ }
+ if machine.Revision != revision {
+ return ErrConflict
+ }
+ if _, err := currentRunnerMember(tx, machine.Person); err != nil {
+ return err
+ }
+ var rows []connectionRecord
+ if err := tx.Where("runner_id=?", runner).Find(&rows).Error; err != nil {
+ return storeError(err)
+ }
+ now := s.runnerClock.Now().UTC()
+ versions := ""
+ if enabled {
+ versions, err = trialVersions(rows)
+ if err != nil {
+ return err
+ }
+ for _, c := range rows {
+ if !freshConnection(c, now) {
+ return ErrUnavailable
+ }
+ }
+ }
+ if err := tx.Model(&supervisedTrialRecord{}).Where("runner_id=? AND revoked_at IS NULL", runner).Select("RevokedAt").Updates(&supervisedTrialRecord{RevokedAt: &now}).Error; err != nil {
+ return storeError(err)
+ }
+ a := supervisedTrialRecord{ID: rand.Text(), RunnerID: runner, Owner: owner.Address, OwnerRevision: owner.Revision, AcknowledgedAt: now, Versions: versions}
+ kind := "runner.trial.disabled"
+ if enabled {
+ kind = "runner.trial.enabled"
+ if err := tx.Create(&a).Error; err != nil {
+ return storeError(err)
+ }
+ }
+ for _, c := range rows {
+ if err := invalidateConnection(tx, c, kind, now); err != nil {
+ return err
+ }
+ }
+ raw, _ := json.Marshal(a)
+ return appendAudit(tx, actor, kind, string(raw))
+ })
+}
+func (s *Store) trialSnapshot(tx *gorm.DB, c connectionRecord) (*team.TrialSnapshot, error) {
+ a, err := s.trialAt(tx, c.RunnerID)
+ if errors.Is(err, ErrForbidden) {
+ return nil, nil
+ }
+ if err != nil {
+ return nil, err
+ }
+ return &team.TrialSnapshot{Label: "supervised trial", AcknowledgementIDs: []string{a.ID}, UnverifiedChecks: team.TrialChecks(), ProviderVersionSource: "observed_locally"}, nil
+}
diff --git a/internal/equipo/task_views.go b/internal/equipo/task_views.go
index 878201c7..df932baf 100644
--- a/internal/equipo/task_views.go
+++ b/internal/equipo/task_views.go
@@ -39,6 +39,7 @@ type TaskEvidence struct {
Unconfined bool
}
type TaskViewData struct {
+ Isolation team.IsolationSnapshot
Task Task
Project Project
Steps []StepCard
@@ -268,7 +269,12 @@ func (s *Store) taskViewAt(tx *gorm.DB, actor Actor, task Task) (TaskViewData, e
}
historical = mergeIsolation(historical, iso)
}
+ v.Isolation = historical
v.Unconfined = exposed(historical)
+ if historical.Trial != nil && job.Wait == string(team.WaitUncertainOutcome) {
+ v.StateKey = "trial.reconnect"
+ v.NeedsYou = true
+ }
for _, plan := range BugPlan(task) {
card := StepCard{Key: plan.Key, Category: plan.Specialist, Person: plan.Person, State: "pending", UsageKnown: task.JobID != 0}
if plan.RunnerOnly {
@@ -295,6 +301,9 @@ func (s *Store) taskViewAt(tx *gorm.DB, actor Actor, task Task) (TaskViewData, e
for _, step := range steps {
if step.Key == plan.Key {
card.State = step.State
+ if historical.Trial != nil && job.Wait == string(team.WaitUncertainOutcome) && (step.State == "running" || step.State == "pending") {
+ card.State = "waiting"
+ }
for _, u := range usage {
if u.StepID == step.ID && !readTime(u.CreatedAt).Before(weekStart(s.runnerClock.Now())) {
card.CountedTurns += u.SCalls
diff --git a/internal/equipo/team/git_evidence.go b/internal/equipo/team/git_evidence.go
index 2c335f79..71536fef 100644
--- a/internal/equipo/team/git_evidence.go
+++ b/internal/equipo/team/git_evidence.go
@@ -47,6 +47,7 @@ type IsolationTuple struct {
}
type IsolationSnapshot struct {
+ Trial *TrialSnapshot `json:"trial,omitempty"`
Status string `json:"status"`
RunnerTainted bool `json:"runner_tainted"`
AcknowledgementIDs []string `json:"acknowledgement_ids"`
@@ -87,13 +88,16 @@ func gitCandidate(a *Artifact, j jobRow) (GitCandidate, error) {
func (p IsolationSnapshot) Valid() bool { return p.valid() }
func (p IsolationSnapshot) valid() bool {
+ if !p.Trial.valid() || (p.Trial != nil && (p.Status != "unconfined" || !p.RunnerTainted)) {
+ return false
+ }
if p.Status != "confined" && p.Status != "unconfined" {
return false
}
if len(p.ObservedTuples) == 0 {
return false
}
- if (p.Status == "unconfined" || p.RunnerTainted) && len(p.AcknowledgementIDs) == 0 {
+ if (p.Status == "unconfined" || p.RunnerTainted) && len(p.AcknowledgementIDs) == 0 && p.Trial == nil {
return false
}
if p.Status == "unconfined" && !p.RunnerTainted {
@@ -112,6 +116,10 @@ func (p IsolationSnapshot) valid() bool {
return true
}
func mergeIsolation(a, b IsolationSnapshot) IsolationSnapshot {
+ a.Trial = MergeTrial(a.Trial, b.Trial)
+ if a.Trial != nil {
+ a.Status = "unconfined"
+ }
// Status belongs to this connection; historical runner exposure is separate.
a.RunnerTainted = a.RunnerTainted || b.RunnerTainted || b.Status == "unconfined"
a.AcknowledgementIDs = slices.Clone(a.AcknowledgementIDs)
@@ -234,7 +242,7 @@ func publicationMatches(p publication, cand *Artifact, j jobRow) bool {
}
func isolationContains(have, need IsolationSnapshot) bool {
- if !have.valid() || !need.valid() || need.RunnerTainted && !have.RunnerTainted {
+ if !trialContains(have.Trial, need.Trial) || !have.valid() || !need.valid() || need.RunnerTainted && !have.RunnerTainted {
return false
}
for _, id := range need.AcknowledgementIDs {
diff --git a/internal/equipo/team/trial.go b/internal/equipo/team/trial.go
new file mode 100644
index 00000000..712d6b4b
--- /dev/null
+++ b/internal/equipo/team/trial.go
@@ -0,0 +1,72 @@
+package team
+
+import "slices"
+
+// TrialSnapshot is historical consent and the checks a release cannot verify.
+// Copy review is required for its display labels in equipo/copy.go.
+type TrialSnapshot struct {
+ Label string `json:"label"`
+ AcknowledgementIDs []string `json:"acknowledgement_ids"`
+ UnverifiedChecks []string `json:"unverified_checks"`
+ ProviderVersionSource string `json:"provider_version_source"`
+}
+
+func TrialChecks() []string {
+ return []string{"account_unverified", "no_failover", "provider_version", "effective_isolation", "recoverable_completion"}
+}
+func MergeTrial(a, b *TrialSnapshot) *TrialSnapshot {
+ if a == nil && b == nil {
+ return nil
+ }
+ out := &TrialSnapshot{Label: "supervised trial", ProviderVersionSource: "observed_locally"}
+ for _, v := range []*TrialSnapshot{a, b} {
+ if v == nil {
+ continue
+ }
+ out.AcknowledgementIDs = append(out.AcknowledgementIDs, v.AcknowledgementIDs...)
+ out.UnverifiedChecks = append(out.UnverifiedChecks, v.UnverifiedChecks...)
+ }
+ slices.Sort(out.AcknowledgementIDs)
+ out.AcknowledgementIDs = slices.Compact(out.AcknowledgementIDs)
+ slices.Sort(out.UnverifiedChecks)
+ out.UnverifiedChecks = slices.Compact(out.UnverifiedChecks)
+ return out
+}
+func trialContains(have, need *TrialSnapshot) bool {
+ if need == nil {
+ return true
+ }
+ if have == nil {
+ return false
+ }
+ for _, v := range need.AcknowledgementIDs {
+ if !slices.Contains(have.AcknowledgementIDs, v) {
+ return false
+ }
+ }
+ for _, v := range need.UnverifiedChecks {
+ if !slices.Contains(have.UnverifiedChecks, v) {
+ return false
+ }
+ }
+ return true
+}
+func (p *TrialSnapshot) valid() bool {
+ if p == nil {
+ return true
+ }
+ if p.Label != "supervised trial" || p.ProviderVersionSource != "observed_locally" || len(p.AcknowledgementIDs) == 0 || len(p.UnverifiedChecks) == 0 {
+ return false
+ }
+ for _, id := range p.AcknowledgementIDs {
+ if id == "" {
+ return false
+ }
+ }
+ for _, check := range p.UnverifiedChecks {
+ if !slices.Contains(TrialChecks(), check) {
+ return false
+ }
+ }
+ return true
+}
diff --git a/internal/equipo/team/trial_test.go b/internal/equipo/team/trial_test.go
new file mode 100644
index 00000000..4e3035b0
--- /dev/null
+++ b/internal/equipo/team/trial_test.go
@@ -0,0 +1,41 @@
+package team
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestTrialEvidenceAndPublication(t *testing.T) {
+ g := newGitEnv(t)
+ g.observed.Isolation.Trial = &TrialSnapshot{Label: "supervised trial", AcknowledgementIDs: []string{"trial-1"}, UnverifiedChecks: TrialChecks(), ProviderVersionSource: "observed_locally"}
+ g.build()
+ g.review()
+ g.verify(true)
+ if g.artifact.Provenance.Isolation.Trial == nil {
+ t.Fatal("candidate missing trial")
+ }
+ h := g.claimStep("publish")
+ p, err := g.store.Publication(g.ctx, g.scope, h)
+ must(t, err)
+ var d PublicationDescription
+ must(t, json.Unmarshal([]byte(p.Description), &d))
+ if d.Isolation.Trial == nil || d.Isolation.Trial.Label != "supervised trial" || d.Label != "unconfined" {
+ t.Fatal("publication missing labels")
+ }
+ for _, e := range d.Evidence {
+ if e.Provenance.Isolation.Trial == nil || e.Label != "unconfined" {
+ t.Fatal("evidence missing labels", e.Role)
+ }
+ }
+ stripped := d
+ stripped.Isolation.Trial = nil
+ if publicationDescriptionContains(string(mustJSON(stripped)), p.Description) {
+ t.Fatal("description accepted stripped trial")
+ }
+ stripped = d
+ stripped.Evidence = append([]PublicationEvidence(nil), d.Evidence...)
+ stripped.Evidence[0].Provenance.Isolation.Trial = nil
+ if publicationDescriptionContains(string(mustJSON(stripped)), p.Description) {
+ t.Fatal("evidence accepted stripped trial")
+ }
+}
diff --git a/internal/equipo/templates/connections.html b/internal/equipo/templates/connections.html
index bfa3d1c2..d117b2fa 100644
--- a/internal/equipo/templates/connections.html
+++ b/internal/equipo/templates/connections.html
@@ -1,3 +1,3 @@
{{define "content"}}<h1>{{copy "nav.connections"}}</h1><a rst-btn href="/runners/enrol">{{copy "connections.enrol"}}</a>{{template "region:activity" .}}
<h2>{{copy "connections.personal"}}</h2>{{range .Choices}}<form equipo-form method="post" action="/projects/{{.Project.ID}}/connections"><h3>{{.Project.Name}}</h3><input type="hidden" name="revision" value="{{.Revision}}">{{range .Options}}<label><input type="checkbox" name="connection_id" value="{{.ID}}"{{if .Enabled}} checked{{end}}>{{copy "connections.enable"}}: {{.Label}}</label>{{end}}<label>{{copy "connections.pin"}}<select rst-input name="pinned_id"><option value="">{{copy "value.none"}}</option>{{$pinned:=.PinnedID}}{{range .Options}}<option value="{{.ID}}"{{if eq .ID $pinned}} selected{{end}}>{{.Label}}</option>{{end}}</select></label><button rst-btn>{{copy "form.save"}}</button></form>{{end}}{{end}}
-{{define "region:activity"}}<div id="activity" {{.Live.Attrs .Topic}}>{{range .Connections}}<section equipo-card><h2>{{.Report.AccountLabel}}</h2><p>{{.Person}}</p>{{if not .Available}}<p>{{copy "runner.preflight.unavailable"}}</p>{{end}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.PaseoVersion}}</p>{{if .Unverified}}<p>{{copy "isolation.unverified"}}</p>{{else if .Unconfined}}<p>{{copy "isolation.unconfined"}}</p><p>{{copy "isolation.meaning"}}</p><p>{{if .Acknowledged}}{{copy "isolation.acknowledged"}}{{else}}{{copy "isolation.expired"}}{{end}}</p>{{if $.Owner}}<form method="post" action="/connections/{{.ID}}/acknowledge-unconfined"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="acknowledge" value="unconfined"><button rst-btn>{{copy "isolation.acknowledge"}}</button></form><form method="post" action="/connections/{{.ID}}/revoke-isolation-acknowledgement"><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn>{{copy "isolation.revoke"}}</button></form>{{end}}{{else}}<p>{{copy "isolation.confined"}}</p>{{end}}</section>{{else}}<p data-empty-state="connections.empty">{{copy "connections.empty"}}</p>{{end}}</div>{{end}}
+{{define "region:activity"}}<div id="activity" {{.Live.Attrs .Topic}}>{{range .Connections}}<section equipo-card><h2>{{.Report.AccountLabel}}</h2><p>{{.Person}}</p>{{if not .Available}}<p>{{copy "runner.preflight.unavailable"}}</p>{{end}}{{template "trial-label" .Isolation}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.PaseoVersion}}</p>{{if .Unverified}}<p>{{copy "isolation.unverified"}}</p>{{else if .Unconfined}}<p>{{copy "isolation.unconfined"}}</p><p>{{copy "isolation.meaning"}}</p>{{if eq .Report.Provider "codex"}}<p>{{if .Acknowledged}}{{copy "isolation.acknowledged"}}{{else}}{{copy "isolation.expired"}}{{end}}</p>{{if $.Owner}}<form method="post" action="/connections/{{.ID}}/acknowledge-unconfined"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="acknowledge" value="unconfined"><button rst-btn>{{copy "isolation.acknowledge"}}</button></form><form method="post" action="/connections/{{.ID}}/revoke-isolation-acknowledgement"><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn>{{copy "isolation.revoke"}}</button></form>{{end}}{{end}}{{else}}<p>{{copy "isolation.confined"}}</p>{{end}}</section>{{else}}<p data-empty-state="connections.empty">{{copy "connections.empty"}}</p>{{end}}</div>{{end}}
diff --git a/internal/equipo/templates/runners.html b/internal/equipo/templates/runners.html
index 761bed13..cf94419d 100644
--- a/internal/equipo/templates/runners.html
+++ b/internal/equipo/templates/runners.html
@@ -29,6 +29,8 @@
<dt>{{copy "runner.person"}}</dt><dd>{{.Person}}</dd>
<dt>{{copy "runner.fingerprint"}}</dt><dd>{{.MachineKeyHash}}</dd>
</dl>
+{{if .TrialOwner}}<p>{{copy "trial.label"}}: {{.TrialOwner}} / {{.TrialAt}}</p><pre>{{.TrialVersions}}</pre>{{else}}<p>{{copy "trial.off"}}</p>{{end}}
+{{if $.Owner}}<p>{{copy "trial.meaning"}}</p><form method="post" action="/runners/{{.ID}}/supervised-trial" equipo-form><input type="hidden" name="revision" value="{{.Revision}}"><button rst-btn name="enabled" value="true">{{copy "trial.enable"}}</button><button rst-btn name="enabled" value="false">{{copy "trial.disable"}}</button></form>{{end}}
<form method="post" action="/runners/{{.ID}}/revoke" equipo-form>
<input type="hidden" name="revision" value="{{.Revision}}">
<button rst-btn type="submit">{{copy "runner.revoke"}}</button>
diff --git a/internal/equipo/templates/task.html b/internal/equipo/templates/task.html
index f538e079..f7e7cf23 100644
--- a/internal/equipo/templates/task.html
+++ b/internal/equipo/templates/task.html
@@ -11,4 +11,4 @@
{{range .Logs}}<section equipo-card>{{if .Unconfined}}<p>{{copy "isolation.unconfined"}}</p>{{end}}<p>{{.Actual}}</p>{{template "isolation-history" .Isolation}}<pre>{{.Detail}}</pre></section>{{end}}
{{end}}</div>{{end}}
-{{define "isolation-history"}}{{if .ObservedTuples}}<details><summary>{{copy "task.provenance"}}</summary>{{range .ObservedTuples}}<p>{{.Provider}} {{.ProviderVersion}} / {{.PaseoVersion}} / {{.IsolationConfigHash}}</p>{{end}}<p>{{copy "isolation.acknowledgements"}}: {{range .AcknowledgementIDs}}{{.}} {{end}}</p></details>{{end}}{{end}}
+{{define "isolation-history"}}{{template "trial-label" .}}{{if .ObservedTuples}}<details><summary>{{copy "task.provenance"}}</summary>{{range .ObservedTuples}}<p>{{.Provider}} {{.ProviderVersion}} / {{.PaseoVersion}} / {{.IsolationConfigHash}}</p>{{end}}<p>{{copy "isolation.acknowledgements"}}: {{range .AcknowledgementIDs}}{{.}} {{end}}</p></details>{{end}}{{end}}
diff --git a/internal/equipo/templates/task_card.html b/internal/equipo/templates/task_card.html
index 93a35d13..2de10a02 100644
--- a/internal/equipo/templates/task_card.html
+++ b/internal/equipo/templates/task_card.html
@@ -1,7 +1,9 @@
{{define "task-card"}}
<article equipo-task data-task="{{.Task.ID}}">
-<div equipo-card><h3><a href="/tasks/{{.Task.ID}}">{{.Task.Description}}</a></h3><p>{{.Project.Name}}</p><p>{{copy .StateKey}}</p>{{if .Unconfined}}<p equipo-isolation>{{copy "isolation.unconfined"}}</p>{{end}}</div>
-<ol equipo-steps>{{range .Steps}}<li equipo-step data-step="{{.Key}}"><strong>{{copy (printf "nav.%s" .Category)}}</strong><span>{{copy (printf "step.%s" .Key)}}</span><span>{{.Model}} {{.Account}}{{.Person}}</span><span>{{copy (printf "step.%s" .State)}}</span>{{if .Unconfined}}<span equipo-isolation>{{copy "isolation.unconfined"}}</span>{{end}}</li>{{end}}</ol>
+<div equipo-card><h3><a href="/tasks/{{.Task.ID}}">{{.Task.Description}}</a></h3><p>{{.Project.Name}}</p><p>{{copy .StateKey}}</p>{{if .Unconfined}}<p equipo-isolation>{{copy "isolation.unconfined"}}</p>{{end}}{{template "trial-label" .Isolation}}</div>
+<ol equipo-steps>{{range .Steps}}<li equipo-step data-step="{{.Key}}"><strong>{{copy (printf "nav.%s" .Category)}}</strong><span>{{copy (printf "step.%s" .Key)}}</span><span>{{.Model}} {{.Account}}{{.Person}}</span><span>{{copy (printf "step.%s" .State)}}</span>{{if .Unconfined}}<span equipo-isolation>{{copy "isolation.unconfined"}}</span>{{end}}{{template "trial-label" .Isolation}}</li>{{end}}</ol>
</article>
{{end}}
{{define "task-groups"}}{{range $group := taskGroups}}<section><h2>{{copy (printf "task.group.%s" $group)}}</h2>{{range $.Tasks}}{{if eq .Group $group}}{{template "task-card" .}}{{end}}{{end}}</section>{{end}}{{if not .Tasks}}<p data-empty-state="{{.Key}}.empty">{{copy "task.empty"}}</p>{{end}}{{end}}
+
+{{define "trial-label"}}{{with .Trial}}<span equipo-isolation>{{copy "trial.label"}}: {{range .UnverifiedChecks}}<span>{{copy (printf "trial.check.%s" .)}}</span> {{end}}<span>{{copy "trial.observed_locally"}}</span></span>{{end}}{{end}}
diff --git a/internal/equipo/trial_handlers.go b/internal/equipo/trial_handlers.go
new file mode 100644
index 00000000..3406b8f8
--- /dev/null
+++ b/internal/equipo/trial_handlers.go
@@ -0,0 +1,23 @@
+package equipo
+
+import (
+ "github.com/go-chi/chi/v5"
+ "net/http"
+)
+
+func (a *application) supervisedTrial(w http.ResponseWriter, r *http.Request) {
+ actor, revision, ok := a.connectionForm(w, r)
+ if !ok {
+ return
+ }
+ value := r.PostForm.Get("enabled")
+ if value != "true" && value != "false" {
+ a.failure(w, r, ErrInvalid)
+ return
+ }
+ if err := a.store.SetSupervisedTrial(r.Context(), actor, chi.URLParam(r, "id"), revision, value == "true"); err != nil {
+ a.failure(w, r, err)
+ return
+ }
+ http.Redirect(w, r, "/runners/enrol", http.StatusSeeOther)
+}
diff --git a/internal/equipotest/live_gate_test.go b/internal/equipotest/live_gate_test.go
index dc795366..9b87d06e 100644
--- a/internal/equipotest/live_gate_test.go
+++ b/internal/equipotest/live_gate_test.go
@@ -14,8 +14,9 @@ func TestLiveGateConfirmation(t *testing.T) {
root := t.TempDir()
capture := filepath.Join(root, "capture")
executionMust(t, os.WriteFile(filepath.Join(root, "go"), []byte("#!/bin/sh\nprintf '%s\\n' \"$EQUIPO_LIVE_PASEO\" \"$@\" > \"$CAPTURE\"\nexit 23\n"), 0700))
+ executionMust(t, os.WriteFile(filepath.Join(root, "id"), []byte("#!/bin/sh\nprintf 'equipo-runner\\n'\n"), 0700))
cmd := exec.Command("/bin/sh", "../../scripts/live-gate.sh")
- cmd.Env = []string{"PATH=" + root + ":/usr/bin:/bin", "CAPTURE=" + capture}
+ cmd.Env = []string{"PATH=" + root + ":/usr/bin:/bin", "CAPTURE=" + capture, "EQUIPO_PASEO_HOME=/home/equipo-runner/.paseo", "EQUIPO_PASEO_ENDPOINT=127.0.0.1:6773"}
cmd.Stdin = strings.NewReader(input)
_, err := cmd.CombinedOutput()
if err == nil {
@@ -39,3 +40,32 @@ func TestLiveGateConfirmation(t *testing.T) {
})
}
}
+
+func TestLiveGateRequiresDedicatedUser(t *testing.T) {
+ for _, mode := range []string{"user", "home", "endpoint"} {
+ t.Run(mode, func(t *testing.T) {
+ root := t.TempDir()
+ capture := filepath.Join(root, "capture")
+ user, home, endpoint := "equipo-runner", "/home/equipo-runner/.paseo", "127.0.0.1:6773"
+ switch mode {
+ case "user":
+ user = "shared"
+ case "home":
+ home = "/home/shared/.paseo"
+ case "endpoint":
+ endpoint = "0.0.0.0:6773"
+ }
+ executionMust(t, os.WriteFile(filepath.Join(root, "id"), []byte("#!/bin/sh\nprintf '%s\\n' '"+user+"'\n"), 0700))
+ executionMust(t, os.WriteFile(filepath.Join(root, "go"), []byte("#!/bin/sh\ntouch \"$CAPTURE\"\n"), 0700))
+ cmd := exec.Command("/bin/sh", "../../scripts/live-gate.sh")
+ cmd.Env = []string{"PATH=" + root + ":/usr/bin:/bin", "CAPTURE=" + capture, "EQUIPO_PASEO_HOME=" + home, "EQUIPO_PASEO_ENDPOINT=" + endpoint}
+ cmd.Stdin = strings.NewReader("LIVE DISPOSABLE ONLY\nRUN LIVE GATE\n")
+ if output, err := cmd.CombinedOutput(); err == nil {
+ t.Fatalf("unsafe gate accepted: %s", output)
+ }
+ if _, err := os.Stat(capture); !os.IsNotExist(err) {
+ t.Fatal("ran live gate")
+ }
+ })
+ }
+}
diff --git a/internal/equipotest/trial_test.go b/internal/equipotest/trial_test.go
new file mode 100644
index 00000000..fe8c6f20
--- /dev/null
+++ b/internal/equipotest/trial_test.go
@@ -0,0 +1,157 @@
+package equipotest
+
+import (
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/equipo/team"
+ "strings"
+ "testing"
+)
+
+func trialFixture(t *testing.T) connectionFixture {
+ t.Helper()
+ f := connectionStore(t)
+ for i := range f.reports {
+ r := &f.reports[i]
+ r.Available = false
+ r.ReadIsolation = false
+ r.TrialReady = true
+ r.ProviderVersionSource = "observed_locally"
+ r.UnavailableReason = "account_binding_unsupported"
+ r.Routing.AccountPinned = false
+ r.Routing.NoFailover = false
+ r.Routing.TimelineRecovery = false
+ r.Routing.ObservedAccountID = ""
+ }
+ if err := f.s.ReportConnections(connectionContext, f.principal, f.reports); err != nil {
+ t.Fatal(err)
+ }
+ f.choice(t, f.ids["claude"])
+ return f
+}
+func TestSupervisedTrialConsent(t *testing.T) {
+ for _, change := range []string{"off", "on", "revoke", "provider", "server", "demote", "remove", "mismatch", "containment"} {
+ t.Run(change, func(t *testing.T) {
+ f := trialFixture(t)
+ setMember(t, f.s, "trial@example.com", equipo.RoleOwner, true)
+ actor := equipo.Actor{Address: "trial@example.com"}
+ if change != "off" {
+ if err := f.s.SetSupervisedTrial(connectionContext, actor, f.principal.RunnerID, 1, true); err != nil {
+ t.Fatal(err)
+ }
+ }
+ switch change {
+ case "revoke":
+ if err := f.s.SetSupervisedTrial(connectionContext, actor, f.principal.RunnerID, 1, false); err != nil {
+ t.Fatal(err)
+ }
+ case "provider":
+ f.reports[0].ProviderVersion = "2.1.313"
+ case "server":
+ f.reports[0].PaseoVersion = "0.15.0"
+ case "demote":
+ setMember(t, f.s, actor.Address, equipo.RoleMember, true)
+ case "remove":
+ setMember(t, f.s, actor.Address, equipo.RoleOwner, false)
+ case "mismatch":
+ f.reports[0].Routing.ObservedAccountID = "different"
+ case "containment":
+ f.reports[0].Routing.ProcessOwnership = false
+ }
+ if change == "provider" || change == "server" || change == "mismatch" || change == "containment" {
+ if err := f.s.ReportConnections(connectionContext, f.principal, f.reports); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if change == "on" {
+ sel := f.selectOK(t, "product", "")
+ if sel.Isolation.Trial == nil || !sel.Isolation.RunnerTainted || sel.Isolation.Status != "unconfined" || !sel.Isolation.Valid() {
+ t.Fatalf("missing provenance: %+v", sel)
+ }
+ } else {
+ f.denied(t, "product", "")
+ }
+ if change == "provider" || change == "server" {
+ f.reports[0] = trialFixtureReport(f.reports[0])
+ if err := f.s.ReportConnections(connectionContext, f.principal, f.reports); err != nil {
+ t.Fatal(err)
+ }
+ f.denied(t, "product", "")
+ }
+ })
+ }
+}
+func trialFixtureReport(r equipo.ConnectionReport) equipo.ConnectionReport {
+ r.ProviderVersion = "2.1.312"
+ r.PaseoVersion = "0.14.0"
+ return r
+}
+
+func TestSupervisedTrialLabelEverySurface(t *testing.T) {
+ f := bugFixture(t)
+ if err := f.s.SetSupervisedTrial(connectionContext, ownerActor, f.principal.RunnerID, 1, true); err != nil {
+ t.Fatal(err)
+ }
+ task := bugTask(t, f)
+ server, c := taskPageServer(t, f, false)
+ for _, path := range []string{"/journey", "/tasks/" + task.ID, "/specialists/engineering", "/specialists/review"} {
+ body := taskGet(t, c, server.URL, path, 200)
+
+ if strings.Count(body, "supervised trial") < 6 || strings.Count(body, "account unverified") < 6 || strings.Count(body, ">unconfined<") < 6 {
+ t.Fatal("labels missing", path)
+ }
+ }
+ if err := f.s.SetSupervisedTrial(connectionContext, ownerActor, f.principal.RunnerID, 1, false); err != nil {
+ t.Fatal(err)
+ }
+ v, err := f.s.TaskView(connectionContext, ownerActor, task.ID)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if v.Isolation.Trial == nil {
+ t.Fatal("revocation erased history")
+ }
+}
+
+func TestTrialReconnectReservationAndWaitingView(t *testing.T) {
+ f := runnerFixtureNew(t, true)
+ executionMust(t, f.s.SetSupervisedTrial(connectionContext, ownerActor, f.principal.RunnerID, 1, true))
+ id := eventTurn(t, f)
+ q := f.request()
+ q.ActionID = id
+ q.RequestID = "trial-gap"
+ _, err := f.x.Mutate(connectionContext, f.principal, "lost", q)
+ executionMust(t, err)
+ action, err := f.x.Core.GetAction(connectionContext, f.a.Scope, id)
+ executionMust(t, err)
+ if action.State != team.ActionUncertain {
+ t.Fatal("action not uncertain", action.State)
+ }
+ reservations, err := f.x.Core.Reservations(connectionContext, f.a.Scope)
+ executionMust(t, err)
+ if len(reservations) != 1 || reservations[0].Settled != reservations[0].Reserved {
+ t.Fatalf("reservation not charged: %+v", reservations)
+ }
+ view, err := f.s.TaskView(connectionContext, ownerActor, f.a.TaskID)
+ executionMust(t, err)
+ if view.StateKey != "trial.reconnect" || !view.NeedsYou {
+ t.Fatalf("not a visible human wait: %+v", view)
+ }
+ q.RequestID = "retry"
+ if _, err := f.x.Mutate(connectionContext, f.principal, "admit", q); err == nil {
+ t.Fatal("uncertain turn redispatched")
+ }
+}
+func TestTrialOwnerAndFreshReports(t *testing.T) {
+ f := trialFixture(t)
+ if err := f.s.SetSupervisedTrial(connectionContext, equipo.Actor{Address: "member@example.com"}, f.principal.RunnerID, 1, true); err == nil {
+ t.Fatal("member enabled trial")
+ }
+ if err := f.s.SetSupervisedTrial(connectionContext, ownerActor, f.principal.RunnerID, 99, true); err == nil {
+ t.Fatal("stale runner revision accepted")
+ }
+ executionMust(t, f.s.SetSupervisedTrial(connectionContext, ownerActor, f.principal.RunnerID, 1, true))
+ if err := f.s.ReportConnections(connectionContext, f.principal, f.reports[1:]); err != nil {
+ t.Fatal(err)
+ }
+ f.denied(t, "product", "")
+}
diff --git a/internal/runner/config.go b/internal/runner/config.go
index 8153444c..551bda6b 100644
--- a/internal/runner/config.go
+++ b/internal/runner/config.go
@@ -16,6 +16,7 @@ import (
)
type Config struct {
+ ClaudePath string
Report func(string)
Origin, StateDir, PaseoHome, NodePath, BridgePath, AmadanCredentialPath, AccountBindingsPath, CodexPath string
GoRoot, GoBinary, WorkspaceRoot, ScratchRoot, GitPath, Executable string
@@ -24,7 +25,7 @@ type Config struct {
}
func LoadConfig(getenv func(string) string) (Config, error) {
- c := Config{Origin: getenv("EQUIPO_ORIGIN"), StateDir: getenv("EQUIPO_RUNNER_STATE_DIR"), PaseoHome: getenv("EQUIPO_PASEO_HOME"), NodePath: getenv("EQUIPO_NODE_PATH"), BridgePath: getenv("EQUIPO_BRIDGE_PATH"), AmadanCredentialPath: getenv("EQUIPO_AMADAN_CREDENTIAL_PATH"), AccountBindingsPath: getenv("EQUIPO_ACCOUNT_BINDINGS_PATH"), CodexPath: getenv("EQUIPO_CODEX_PATH"), GoRoot: getenv("EQUIPO_GO_ROOT"), GoBinary: getenv("EQUIPO_GO_BINARY"), WorkspaceRoot: getenv("EQUIPO_WORKSPACE_ROOT"), ScratchRoot: getenv("EQUIPO_SCRATCH_ROOT"), GitPath: getenv("EQUIPO_GIT_PATH"), Executable: getenv("EQUIPO_RUNNER_EXECUTABLE"), PaseoEndpoint: getenv("EQUIPO_PASEO_ENDPOINT"), PaseoServerID: getenv("EQUIPO_PASEO_SERVER_ID"), InstanceID: getenv("EQUIPO_INSTANCE_ID")}
+ c := Config{ClaudePath: getenv("EQUIPO_CLAUDE_PATH"), Origin: getenv("EQUIPO_ORIGIN"), StateDir: getenv("EQUIPO_RUNNER_STATE_DIR"), PaseoHome: getenv("EQUIPO_PASEO_HOME"), NodePath: getenv("EQUIPO_NODE_PATH"), BridgePath: getenv("EQUIPO_BRIDGE_PATH"), AmadanCredentialPath: getenv("EQUIPO_AMADAN_CREDENTIAL_PATH"), AccountBindingsPath: getenv("EQUIPO_ACCOUNT_BINDINGS_PATH"), CodexPath: getenv("EQUIPO_CODEX_PATH"), GoRoot: getenv("EQUIPO_GO_ROOT"), GoBinary: getenv("EQUIPO_GO_BINARY"), WorkspaceRoot: getenv("EQUIPO_WORKSPACE_ROOT"), ScratchRoot: getenv("EQUIPO_SCRATCH_ROOT"), GitPath: getenv("EQUIPO_GIT_PATH"), Executable: getenv("EQUIPO_RUNNER_EXECUTABLE"), PaseoEndpoint: getenv("EQUIPO_PASEO_ENDPOINT"), PaseoServerID: getenv("EQUIPO_PASEO_SERVER_ID"), InstanceID: getenv("EQUIPO_INSTANCE_ID")}
return c, c.validate()
}
func validOrigin(origin string) bool {
diff --git a/internal/runner/connections.go b/internal/runner/connections.go
index b6206794..dda969bd 100644
--- a/internal/runner/connections.go
+++ b/internal/runner/connections.go
@@ -113,7 +113,7 @@ func connectionReport(b AccountBinding, p paseo.ReadPolicy, c paseo.Capabilities
if !ready && reason == "" {
reason = "capability_unverified"
}
- return runnerproto.ConnectionReport{LocalID: b.LocalID, Provider: b.Provider, Family: b.Family, Model: b.Model, Kind: b.Kind, ProviderVersion: c.ProviderVersion, PaseoVersion: c.PaseoVersion, IsolationConfigHash: p.ConfigHash, Available: ready, ReadIsolation: confined, UnavailableReason: reason, Routing: runnerproto.ConnectionRouting{BindingID: b.ID, AccountID: b.AccountID, ObservedAccountID: c.ObservedAccount, CredentialHomeHash: hex.EncodeToString(hash[:]), AccountPinned: c.AccountPinning && routingObserved, NoFailover: c.NoFailover, TimelineRecovery: c.RecoverableTimeline, ProcessOwnership: c.ProcessOwnership}}
+ return runnerproto.ConnectionReport{TrialReady: c.TrialReady && (err == nil || err == paseo.ErrCapability || err == paseo.ErrIsolation || err == paseo.ErrPolicy), ProviderVersionSource: c.ProviderVersionSource, LocalID: b.LocalID, Provider: b.Provider, Family: b.Family, Model: b.Model, Kind: b.Kind, ProviderVersion: c.ProviderVersion, PaseoVersion: c.PaseoVersion, IsolationConfigHash: p.ConfigHash, Available: ready, ReadIsolation: confined, UnavailableReason: reason, Routing: runnerproto.ConnectionRouting{BindingID: b.ID, AccountID: b.AccountID, ObservedAccountID: c.ObservedAccount, CredentialHomeHash: hex.EncodeToString(hash[:]), AccountPinned: c.AccountPinning && routingObserved, NoFailover: c.NoFailover, TimelineRecovery: c.RecoverableTimeline, ProcessOwnership: c.ProcessOwnership}}
}
func discover(ctx context.Context, c Config, client *paseo.Client) ([]runnerproto.ConnectionReport, error) {
bs, err := loadBindings(c.AccountBindingsPath)
diff --git a/internal/runner/forge/description.go b/internal/runner/forge/description.go
new file mode 100644
index 00000000..a5ca2c13
--- /dev/null
+++ b/internal/runner/forge/description.go
@@ -0,0 +1,76 @@
+package forge
+
+import (
+ "context"
+ "encoding/json"
+ "io"
+ "net/http"
+ "net/url"
+ "strings"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/equipo/team"
+)
+
+type descriptionText struct {
+ Description string `json:"description"`
+ Human string `json:"human"`
+ Summary string `json:"summary"`
+ Notes string `json:"notes"`
+}
+
+// ReadBranchDescription implements the announced Amadan GET contract, also used
+// by `amadan branch show <ns>/<repo> <name> -json`. Production publication stays
+// disabled until the deployed contract and pre-push ordering are verified.
+func ReadBranchDescription(ctx context.Context, client *http.Client, cred Credential, repo, ref string) (Description, error) {
+ if !repoName.MatchString(repo) || cred.Remote != "https://"+repo || !team.ValidPublicationAgent(cred.Agent) || cred.Bearer == "" || !strings.HasPrefix(ref, "refs/heads/") {
+ return Description{}, team.ErrInvalid
+ }
+ branch := strings.TrimPrefix(ref, "refs/heads/")
+ if branch == "" || strings.ContainsAny(branch, "\x00\r\n") {
+ return Description{}, team.ErrInvalid
+ }
+ parts := strings.Split(repo, "/")
+ endpoint := "https://amadan.net/api/v1/repos/" + url.PathEscape(parts[1]) + "/" + url.PathEscape(parts[2]) + "/branches/" + url.PathEscape(branch) + "/description"
+ ctx, cancel := context.WithTimeout(ctx, 15*time.Second)
+ defer cancel()
+ req, err := http.NewRequestWithContext(ctx, http.MethodGet, endpoint, nil)
+ if err != nil {
+ return Description{}, team.ErrInvalid
+ }
+ req.Header.Set("Authorization", "Bearer "+cred.Bearer)
+ req.Header.Set("Accept", "application/json")
+ if client == nil {
+ client = http.DefaultClient
+ }
+ local := *client
+ local.CheckRedirect = func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }
+ response, err := local.Do(req)
+ if err != nil {
+ return Description{}, team.ErrUncertain
+ }
+ defer response.Body.Close()
+ if response.StatusCode != http.StatusOK {
+ return Description{}, team.ErrUncertain
+ }
+ data, err := io.ReadAll(io.LimitReader(response.Body, 1<<20+1))
+ if err != nil || len(data) > 1<<20 {
+ return Description{}, team.ErrUncertain
+ }
+ var result struct {
+ descriptionText
+ By string `json:"by"`
+ At int64 `json:"at"`
+ Agent json.RawMessage `json:"agent"`
+ Empty bool `json:"empty"`
+ ContentHash string `json:"content_hash"`
+ }
+ if json.Unmarshal(data, &result) != nil || result.Empty || result.By != cred.Agent || result.Description == "" {
+ return Description{}, team.ErrEvidence
+ }
+ content, _ := json.Marshal(result.descriptionText)
+ if result.ContentHash != "sha256:"+team.ContentDigest(content) {
+ return Description{}, team.ErrEvidence
+ }
+ return Description{Repository: repo, Ref: ref, Agent: result.By, Body: result.Description, Digest: team.ContentDigest([]byte(result.Description))}, nil
+}
diff --git a/internal/runner/forge/description_test.go b/internal/runner/forge/description_test.go
new file mode 100644
index 00000000..6a295f2a
--- /dev/null
+++ b/internal/runner/forge/description_test.go
@@ -0,0 +1,30 @@
+package forge
+
+import (
+ "amadan.net/oficina/equipo/internal/equipo/team"
+ "context"
+ "encoding/json"
+ "io"
+ "net/http"
+ "strings"
+ "testing"
+)
+
+type descriptionRoundTrip func(*http.Request) (*http.Response, error)
+
+func (f descriptionRoundTrip) RoundTrip(r *http.Request) (*http.Response, error) { return f(r) }
+func TestPlannedAmadanDescriptionReadback(t *testing.T) {
+ client := &http.Client{Transport: descriptionRoundTrip(func(r *http.Request) (*http.Response, error) {
+ if r.Method != "GET" || r.URL.EscapedPath() != "/api/v1/repos/oficina/equipo/branches/review%2Ftrial/description" || r.Header.Get("Authorization") != "Bearer test-token" {
+ t.Fatal("wrong request", r.Method, r.URL.EscapedPath())
+ }
+ fields := descriptionText{Description: "supervised trial; unconfined"}
+ content, _ := json.Marshal(fields)
+ body, _ := json.Marshal(map[string]any{"description": fields.Description, "human": "", "summary": "", "notes": "", "by": "codex~owner@example.com", "at": 123, "agent": nil, "empty": false, "content_hash": "sha256:" + team.ContentDigest(content)})
+ return &http.Response{StatusCode: 200, Body: io.NopCloser(strings.NewReader(string(body)))}, nil
+ })}
+ got, err := ReadBranchDescription(context.Background(), client, Credential{Remote: "https://amadan.net/oficina/equipo", Bearer: "test-token", Agent: "codex~owner@example.com"}, "amadan.net/oficina/equipo", "refs/heads/review/trial")
+ if err != nil || got.Body != "supervised trial; unconfined" || got.Digest != team.ContentDigest([]byte(got.Body)) {
+ t.Fatalf("%+v %v", got, err)
+ }
+}
diff --git a/internal/runner/paseo/client.go b/internal/runner/paseo/client.go
index d1ca1108..69a4a205 100644
--- a/internal/runner/paseo/client.go
+++ b/internal/runner/paseo/client.go
@@ -33,9 +33,10 @@ type frame struct {
Event *Event `json:"event,omitempty"`
}
type agentState struct {
- agent Agent
- request AgentRequest
- caps Capabilities
+ trialSubscribed bool
+ agent Agent
+ request AgentRequest
+ caps Capabilities
}
type Client struct {
cfg Config
@@ -386,11 +387,6 @@ func (c *Client) Preflight(ctx context.Context, s Selection, p ReadPolicy) (Capa
if caps.ServerID != c.cfg.ServerID {
return caps, ErrIdentity
}
- if c.cfg.VerifyRouting != nil {
- if err := c.cfg.VerifyRouting(ctx, s, caps); err != nil {
- return caps, err
- }
- }
inspected := false
if c.cfg.InspectProcesses != nil {
var err error
@@ -399,6 +395,43 @@ func (c *Client) Preflight(ctx context.Context, s Selection, p ReadPolicy) (Capa
inspected = false
}
}
+ var trial Capabilities
+ if c.cfg.ObserveProviderVersion != nil {
+ version, e := c.cfg.ObserveProviderVersion(ctx, s)
+ if e != nil {
+ return caps, e
+ }
+ if caps.ProviderVersion != "" && caps.ProviderVersion != version {
+ return caps, ErrIdentity
+ }
+ local := caps
+ local.ProviderVersion = version
+ local.ProviderVersionSource = "observed_locally"
+ trial, e = evaluateTrial(s, p, local, inspected)
+ if e == nil {
+ if c.cfg.VerifyRouting != nil {
+ if e = c.cfg.VerifyRouting(ctx, s, trial); e != nil {
+ return trial, e
+ }
+ }
+ if c.cfg.AuthorizeTrial != nil && c.cfg.AuthorizeTrial(ctx, s, trial) == nil {
+ trial.UnavailableReason = ""
+ return trial, nil
+ }
+ }
+ }
+ result, err := c.strictPreflight(ctx, s, p, caps, inspected)
+ if err != nil && trial.TrialReady {
+ return trial, ErrCapability
+ }
+ return result, err
+}
+func (c *Client) strictPreflight(ctx context.Context, s Selection, p ReadPolicy, caps Capabilities, inspected bool) (Capabilities, error) {
+ if c.cfg.VerifyRouting != nil {
+ if err := c.cfg.VerifyRouting(ctx, s, caps); err != nil {
+ return caps, err
+ }
+ }
result, err := evaluate(s, p, caps, c.cfg.VerifiedTuples, inspected, false)
if err == ErrIsolation && s.Provider == "codex" && c.cfg.AuthorizeUnconfined != nil {
if authErr := c.cfg.AuthorizeUnconfined(ctx, s, result); authErr == nil {
@@ -458,6 +491,12 @@ func (c *Client) CreateAgent(ctx context.Context, r AgentRequest) (Agent, error)
if err != nil {
return a, err
}
+ if c.cfg.CredentialHome != nil {
+ r.CredentialHome, err = c.cfg.CredentialHome(r.Selection)
+ if err != nil {
+ return a, err
+ }
+ }
if err := c.intent(ctx, "agent", r.IdempotencyKey, r); err != nil {
return a, err
}
@@ -475,14 +514,14 @@ func (c *Client) CreateAgent(ctx context.Context, r AgentRequest) (Agent, error)
}
return a, err
}
- if (r.ResourceID != "" && a.AgentID != r.ResourceID) || a.ServerID != c.cfg.ServerID || a.WorkspaceID != r.Workspace.WorkspaceID || a.AgentID == "" || a.ProviderSessionID == "" || a.AccountID != caps.ObservedAccount || a.Provider != r.Selection.Provider || a.Model != r.Selection.Model || a.Family != r.Selection.Family {
+ if (r.ResourceID != "" && a.AgentID != r.ResourceID) || a.ServerID != c.cfg.ServerID || a.WorkspaceID != r.Workspace.WorkspaceID || a.AgentID == "" || a.ProviderSessionID == "" || (a.AccountID != r.Selection.AccountID && !(caps.TrialReady && a.AccountID == "")) || a.Provider != r.Selection.Provider || a.Model != r.Selection.Model || a.Family != r.Selection.Family {
return a, ErrUncertain
}
// Retain our own copy so caller mutations cannot change the policy of a turn.
b, _ := json.Marshal(r)
_ = json.Unmarshal(b, &r)
c.mu.Lock()
- c.agents[a.AgentID] = agentState{a, r, caps}
+ c.agents[a.AgentID] = agentState{agent: a, request: r, caps: caps}
c.mu.Unlock()
return a, nil
}
@@ -510,7 +549,8 @@ func (c *Client) revalidate(ctx context.Context, a Agent) error {
return nil
}
func (c *Client) Subscribe(ctx context.Context, a Agent, cursor Cursor) (*Subscription, error) {
- if _, err := c.state(a); err != nil {
+ state, err := c.state(a)
+ if err != nil {
return nil, err
}
if cursor.Sequence < 0 || (cursor.Sequence > 0 && cursor.Epoch == "") {
@@ -530,14 +570,24 @@ func (c *Client) Subscribe(ctx context.Context, a Agent, cursor Cursor) (*Subscr
return nil, ErrContract
}
}
+ if state.caps.TrialReady {
+ latest := c.agents[a.AgentID]
+ if latest.trialSubscribed {
+ c.mu.Unlock()
+ return nil, ErrUncertain
+ }
+ latest.trialSubscribed = true
+ c.agents[a.AgentID] = latest
+ }
c.subs[sub.id] = sub
c.mu.Unlock()
go func() {
err := c.call(ctx, "subscribe", struct {
+ Trial bool `json:"trial,omitempty"`
Agent Agent `json:"agent"`
Cursor Cursor `json:"cursor"`
SubscriptionID string `json:"subscription_id"`
- }{a, cursor, sub.id}, nil)
+ }{state.caps.TrialReady, a, cursor, sub.id}, nil)
c.mu.Lock()
defer c.mu.Unlock()
if _, ok := c.subs[sub.id]; !ok {
diff --git a/internal/runner/paseo/client_test.go b/internal/runner/paseo/client_test.go
index 852122f3..ef625e11 100644
--- a/internal/runner/paseo/client_test.go
+++ b/internal/runner/paseo/client_test.go
@@ -259,6 +259,16 @@ func TestPaseoHelper(t *testing.T) {
if mode == "version" {
caps.PaseoVersion = "0.15.0"
}
+ if strings.HasPrefix(mode, "trial") {
+ caps.AccountPinning = false
+ caps.ObservedAccount = ""
+ caps.NoFailover = false
+ caps.RecoverableTimeline = false
+ caps.ProviderVersion = ""
+ caps.IsolationConfigHash = ""
+ caps.ReadIsolation = false
+ caps.ProcessOwnership = false
+ }
result = caps
case "register_project":
result = Project{ServerID: "server", ProjectID: "project", Path: "/repo"}
@@ -289,7 +299,14 @@ func TestPaseoHelper(t *testing.T) {
if mode == "lost-create" {
os.Exit(0)
}
- result = fixtureAgent()
+ agent := fixtureAgent()
+ if mode == "trial" {
+ agent.AccountID = ""
+ }
+ if mode == "trial-mismatch" {
+ agent.AccountID = "other"
+ }
+ result = agent
case "subscribe":
if mode == "slow" {
time.Sleep(150 * time.Millisecond)
diff --git a/internal/runner/paseo/trial.go b/internal/runner/paseo/trial.go
new file mode 100644
index 00000000..41adf896
--- /dev/null
+++ b/internal/runner/paseo/trial.go
@@ -0,0 +1,38 @@
+package paseo
+
+// evaluateTrial keeps capability claims false. It identifies the observations
+// eligible for owner consent, never granting dispatch authority itself.
+func evaluateTrial(s Selection, p ReadPolicy, c Capabilities, inspected bool) (Capabilities, error) {
+ c.TrialReady = false
+ c.ReadIsolation = false
+ c.IsolationStatus = "unconfined"
+ c.ProcessOwnership = inspected
+ deny := func(reason string, err error) (Capabilities, error) { c.UnavailableReason = reason; return c, err }
+ if c.Version != PinnedVersion || c.PaseoVersion != PinnedVersion {
+ return deny("unsupported_daemon_version", ErrCapability)
+ }
+ if c.ProviderVersionSource != "observed_locally" || !((s.Provider == "claude" && c.ProviderVersion == "2.1.312") || (s.Provider == "codex" && c.ProviderVersion == "0.165.0")) {
+ return deny("unsupported_provider_version", ErrCapability)
+ }
+ if c.ObservedAccount != "" && c.ObservedAccount != s.AccountID {
+ return deny("account_mismatch", ErrIdentity)
+ }
+ if c.ObservedFamily != "" && c.ObservedFamily != s.Family {
+ return deny("family_changed", ErrIdentity)
+ }
+ if !inspected {
+ return deny("process_coverage_unverified", ErrCapability)
+ }
+ if !c.MCPAtCreate {
+ return deny("mcp_at_create_unsupported", ErrCapability)
+ }
+ if !validPolicy(p) {
+ return deny("invalid_policy", ErrPolicy)
+ }
+ // This is the requested policy's hash. Trial never claims it is effective.
+ c.IsolationConfigHash = p.ConfigHash
+ c.ReadIsolationReason = "effective_policy_unobserved"
+ c.TrialReady = true
+ c.UnavailableReason = "supervised_trial_required"
+ return c, nil
+}
diff --git a/internal/runner/paseo/trial_test.go b/internal/runner/paseo/trial_test.go
new file mode 100644
index 00000000..754edb31
--- /dev/null
+++ b/internal/runner/paseo/trial_test.go
@@ -0,0 +1,79 @@
+package paseo
+
+import (
+ "context"
+ "testing"
+)
+
+func TestSupervisedTrialPreflight(t *testing.T) {
+ for _, mode := range []string{"off", "on", "mismatch", "containment", "mcp", "version"} {
+ t.Run(mode, func(t *testing.T) {
+ caps := fixtureCaps()
+ caps.AccountPinning = false
+ caps.NoFailover = false
+ caps.ObservedAccount = ""
+ caps.RecoverableTimeline = false
+ caps.ReadIsolation = false
+ caps.IsolationConfigHash = ""
+ caps.ProviderVersionSource = "observed_locally"
+ if mode == "mismatch" {
+ caps.ObservedAccount = "other"
+ }
+ if mode == "mcp" {
+ caps.MCPAtCreate = false
+ }
+ if mode == "version" {
+ caps.PaseoVersion = "0.15.0"
+ }
+ got, err := evaluateTrial(fixtureSelection(), fixturePolicy(), caps, mode != "containment")
+ if mode == "off" {
+ got, err = evaluate(fixtureSelection(), fixturePolicy(), caps, nil, true, false)
+ }
+ if mode == "on" {
+ if err != nil || got.ReadIsolation || !got.TrialReady || got.ProviderVersionSource != "observed_locally" {
+ t.Fatalf("trial: %+v %v", got, err)
+ }
+ } else if err == nil {
+ t.Fatal("guard accepted", mode)
+ }
+ })
+ }
+}
+
+func TestSupervisedTrialDispatchAccount(t *testing.T) {
+ for _, mode := range []string{"off", "trial", "trial-mismatch"} {
+ t.Run(mode, func(t *testing.T) {
+ helper := mode
+ if mode == "off" {
+ helper = "trial"
+ }
+ c := testClient(t, helper, func(cfg *Config) {
+ cfg.ObserveProviderVersion = func(context.Context, Selection) (string, error) { return "2.1.312", nil }
+ if mode != "off" {
+ cfg.AuthorizeTrial = func(context.Context, Selection, Capabilities) error { return nil }
+ }
+ })
+ caps, err := c.Preflight(context.Background(), fixtureSelection(), fixturePolicy())
+ if mode == "off" {
+ if err == nil || !caps.TrialReady {
+ t.Fatalf("off: %+v %v", caps, err)
+ }
+ return
+ }
+ if err != nil {
+ t.Fatal(err)
+ }
+ agent, err := c.CreateAgent(context.Background(), AgentRequest{Workspace: fixtureWorkspace(), Selection: fixtureSelection(), IdempotencyKey: "trial", ModeID: "default", ReadPolicy: fixturePolicy()})
+ if mode == "trial-mismatch" {
+ if err == nil {
+ t.Fatal("mismatched account accepted")
+ }
+ if _, err := c.state(agent); err == nil {
+ t.Fatal("mismatched account retained")
+ }
+ } else if err != nil || agent.AccountID != "" {
+ t.Fatalf("unverified identity invented: %+v %v", agent, err)
+ }
+ })
+ }
+}
diff --git a/internal/runner/paseo/types.go b/internal/runner/paseo/types.go
index 95a3d0ab..aa86c66f 100644
--- a/internal/runner/paseo/types.go
+++ b/internal/runner/paseo/types.go
@@ -46,6 +46,8 @@ type VerifiedTuple struct {
ConfigHash string
}
type Capabilities struct {
+ TrialReady bool `json:"trial_ready,omitempty"`
+ ProviderVersionSource string `json:"provider_version_source,omitempty"`
ObservedFamily string `json:"observed_family,omitempty"`
ObservedCredentialHome string `json:"observed_credential_home,omitempty"`
ObservedBindingID string `json:"observed_binding_id,omitempty"`
@@ -99,6 +101,7 @@ type MCPServer struct {
Env map[string]string `json:"env"`
}
type AgentRequest struct {
+ CredentialHome string `json:"credential_home,omitempty"`
ResourceID string `json:"resource_id,omitempty"`
Workspace Workspace `json:"workspace"`
Selection Selection `json:"selection"`
@@ -136,17 +139,20 @@ type Intent struct {
Request json.RawMessage
}
type Config struct {
- VerifyRouting func(context.Context, Selection, Capabilities) error
- NodePath string
- BridgePath string
- DaemonHome string
- Endpoint string
- ServerID string
- VerifiedTuples []VerifiedTuple
- RecordIntent func(context.Context, Intent) error
- RecordCreationRefusal func(context.Context, Intent) error
- InspectProcesses func(context.Context, Selection) (bool, error)
- AuthorizeUnconfined func(context.Context, Selection, Capabilities) error
+ CredentialHome func(Selection) (string, error)
+ ObserveProviderVersion func(context.Context, Selection) (string, error)
+ AuthorizeTrial func(context.Context, Selection, Capabilities) error
+ VerifyRouting func(context.Context, Selection, Capabilities) error
+ NodePath string
+ BridgePath string
+ DaemonHome string
+ Endpoint string
+ ServerID string
+ VerifiedTuples []VerifiedTuple
+ RecordIntent func(context.Context, Intent) error
+ RecordCreationRefusal func(context.Context, Intent) error
+ InspectProcesses func(context.Context, Selection) (bool, error)
+ AuthorizeUnconfined func(context.Context, Selection, Capabilities) error
}
type ProjectRequest struct {
diff --git a/internal/runner/runtime.go b/internal/runner/runtime.go
index bb24c273..d5c9dcbc 100644
--- a/internal/runner/runtime.go
+++ b/internal/runner/runtime.go
@@ -84,7 +84,7 @@ func openRuntime(ctx context.Context, c Config) (r *Runtime, err error) {
tuples = append(tuples, paseo.VerifiedTuple{Provider: v.Provider, ProviderVersion: v.ProviderVersion, PaseoVersion: v.PaseoVersion, ConfigHash: v.IsolationConfigHash})
}
variable = "EQUIPO_BRIDGE_PATH"
- r.client, err = paseo.Start(ctx, paseo.Config{VerifyRouting: r.verifyRouting, VerifiedTuples: tuples, NodePath: c.NodePath, BridgePath: c.BridgePath, DaemonHome: c.PaseoHome, Endpoint: c.PaseoEndpoint, ServerID: c.PaseoServerID, RecordIntent: r.journal.RecordIntent, RecordCreationRefusal: r.journal.RecordCreationRefusal, InspectProcesses: r.coverage, AuthorizeUnconfined: r.authorizeUnconfined})
+ r.client, err = paseo.Start(ctx, paseo.Config{CredentialHome: func(s paseo.Selection) (string, error) { b, _, err := r.binding(s); return b.CredentialHome, err }, ObserveProviderVersion: r.providerVersion, AuthorizeTrial: r.authorizeTrial, VerifyRouting: r.verifyRouting, VerifiedTuples: tuples, NodePath: c.NodePath, BridgePath: c.BridgePath, DaemonHome: c.PaseoHome, Endpoint: c.PaseoEndpoint, ServerID: c.PaseoServerID, RecordIntent: r.journal.RecordIntent, RecordCreationRefusal: r.journal.RecordCreationRefusal, InspectProcesses: r.coverage, AuthorizeUnconfined: r.authorizeUnconfined})
if err != nil {
return r, err
}
@@ -172,6 +172,12 @@ func (r *Runtime) verifyRouting(_ context.Context, s paseo.Selection, c paseo.Ca
if err != nil {
return err
}
+ if c.TrialReady {
+ if (c.ObservedBindingID != "" && c.ObservedBindingID != b.ID) || (c.ObservedCredentialHome != "" && c.ObservedCredentialHome != b.CredentialHome) || (c.ObservedFamily != "" && c.ObservedFamily != b.Family) {
+ return paseo.ErrIdentity
+ }
+ return nil
+ }
if c.ObservedBindingID != b.ID || c.ObservedCredentialHome != b.CredentialHome || c.ObservedFamily != b.Family {
return paseo.ErrIdentity
}
@@ -198,6 +204,9 @@ func Run(ctx context.Context, c Config) error {
return r.service.Run(ctx)
}
func (r *Runtime) Poll(ctx context.Context) ([]runnerproto.Assignment, error) {
+ r.mu.Lock()
+ r.current = nil
+ r.mu.Unlock()
reports, err := discover(ctx, r.cfg, r.client)
if err != nil {
return nil, err
diff --git a/internal/runner/runtime_workflow.go b/internal/runner/runtime_workflow.go
index ba7ae45c..b552acc9 100644
--- a/internal/runner/runtime_workflow.go
+++ b/internal/runner/runtime_workflow.go
@@ -37,8 +37,8 @@ func (f forgeCredentials) Resolve(ctx context.Context, repo string) (workspace.R
return workspace.Remote{URL: c.Remote, Bearer: c.Bearer}, err
}
-// The pinned Amadan interface has no authenticated description readback.
-// Keep publication unavailable until that interface exists.
+// Keep publication unavailable until the deployed Amadan readback and ordering
+// are verified. forge.ReadBranchDescription implements the announced GET shape.
type unavailableDescription struct{}
func (unavailableDescription) BeforePush() bool { return true }
diff --git a/internal/runner/supervisor.go b/internal/runner/supervisor.go
index 45d695c2..fc3bb753 100644
--- a/internal/runner/supervisor.go
+++ b/internal/runner/supervisor.go
@@ -29,6 +29,7 @@ type RunClaim struct {
runnerproto.ClaimResponse
}
type attemptState struct {
+ InFlightAction team.ActionID
Claim RunClaim
Owner ProcessOwner
Agent paseo.Agent
@@ -175,7 +176,9 @@ func (s *Supervisor) finishAttempt(cleanupCtx context.Context, r *attemptState,
}
bookkeepingErr := s.journal.finishTools(cleanupCtx, r.Claim, outcome)
if err != nil {
- if infrastructureOnly(err, r) {
+ if errors.Is(err, errTrialReconnect) {
+ // trialLost has already put the job into a charged human wait.
+ } else if infrastructureOnly(err, r) {
q := r.request("release")
q.Reason = team.WaitRunnerUnavailable
err = errors.Join(err, s.api.Call(cleanupCtx, "release", q, nil))
@@ -433,6 +436,7 @@ func (s *Supervisor) Recover(ctx context.Context) error {
failures = errors.Join(failures, restore.RestoreClaim(r.Claim))
}
if r.Phase != "contained" {
+ failures = errors.Join(failures, s.trialLost(ctx, r))
if r.Phase != "completed" && r.Phase != "prepared" && r.Phase != "verified" {
stopErr := s.api.Call(ctx, "stop", r.request("stop"), nil)
if stopErr != nil {
diff --git a/internal/runner/trial.go b/internal/runner/trial.go
new file mode 100644
index 00000000..ae1fe6a8
--- /dev/null
+++ b/internal/runner/trial.go
@@ -0,0 +1,87 @@
+package runner
+
+import (
+ "context"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "strings"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/runner/paseo"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+func (r *Runtime) providerVersion(ctx context.Context, s paseo.Selection) (string, error) {
+ path := r.cfg.ClaudePath
+ if s.Provider == "codex" {
+ path = r.cfg.CodexPath
+ } else if s.Provider != "claude" {
+ return "", paseo.ErrCapability
+ }
+ if !filepath.IsAbs(path) {
+ return "", paseo.ErrCapability
+ }
+ ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
+ defer cancel()
+ // Inherit the runner user's login environment, never an agent's workspace.
+ cmd := exec.CommandContext(ctx, path, "--version")
+ cmd.Dir = filepath.Dir(path)
+ r.mu.Lock()
+ claim := r.current
+ r.mu.Unlock()
+ if claim != nil {
+ marker := attemptKey(claim.Scope, claim.Handle)
+ if claim.Assignment.Kind == "prepare" {
+ marker = claim.Assignment.ID
+ }
+ cmd.Env = append(os.Environ(), "EQUIPO_ATTEMPT_MARKER="+marker)
+ }
+ out, err := cmd.Output()
+ if err != nil || len(out) > 256 {
+ return "", paseo.ErrCapability
+ }
+ fields := strings.Fields(string(out))
+ if len(fields) == 0 {
+ return "", paseo.ErrCapability
+ }
+ if s.Provider == "codex" {
+ if len(fields) != 2 || fields[0] != "codex-cli" {
+ return "", paseo.ErrCapability
+ }
+ return fields[1], nil
+ }
+ if len(fields) != 3 || fields[1] != "(Claude" || fields[2] != "Code)" {
+ return "", paseo.ErrCapability
+ }
+ return fields[0], nil
+}
+func (r *Runtime) authorizeTrial(ctx context.Context, s paseo.Selection, caps paseo.Capabilities) error {
+ r.mu.Lock()
+ claim := r.current
+ r.mu.Unlock()
+ if claim == nil || selection(claim.Assignment) != s {
+ return paseo.ErrCapability
+ }
+ iso := claim.Assignment.Selection.Isolation
+ if iso.Trial == nil || !iso.Valid() {
+ return paseo.ErrCapability
+ }
+ matched := false
+ for _, v := range iso.ObservedTuples {
+ if v.Provider == s.Provider && v.ProviderVersion == caps.ProviderVersion && v.PaseoVersion == caps.PaseoVersion && v.IsolationConfigHash == caps.IsolationConfigHash {
+ matched = true
+ }
+ }
+ if !matched {
+ return paseo.ErrCapability
+ }
+ var current runnerproto.Selection
+ if err := r.api.Call(ctx, "validate", runnerproto.RunnerRequest{Version: 1, AssignmentID: claim.Assignment.ID, Scope: claim.Scope, Handle: claim.Handle, RequestID: "trial-preflight"}, &current); err != nil {
+ return err
+ }
+ if current.Isolation.Trial == nil {
+ return paseo.ErrCapability
+ }
+ return nil
+}
diff --git a/internal/runner/trial_reconnect.go b/internal/runner/trial_reconnect.go
new file mode 100644
index 00000000..6e23bb38
--- /dev/null
+++ b/internal/runner/trial_reconnect.go
@@ -0,0 +1,34 @@
+package runner
+
+import (
+ "context"
+ "errors"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/runner/paseo"
+)
+
+var errTrialReconnect = errors.New("trial_reconnect")
+
+func (s *Supervisor) trialLost(ctx context.Context, r *attemptState) error {
+ if r.Claim.Assignment.Selection.Isolation.Trial == nil || r.InFlightAction == 0 {
+ return nil
+ }
+ q := r.request("trial-reconnect")
+ q.ActionID = r.InFlightAction
+ return s.api.Call(ctx, "lost", q, nil)
+}
+func (s *Supervisor) trialTurnError(ctx context.Context, r *attemptState, err error) error {
+ if err == nil || r.InFlightAction == 0 || r.Claim.Assignment.Selection.Isolation.Trial == nil {
+ return err
+ }
+ // Every interrupted trial turn keeps its reservation, including process
+ // restart. The live completion stream cannot be recovered by this adapter.
+ report, cancel := context.WithTimeout(context.WithoutCancel(ctx), 30*time.Second)
+ defer cancel()
+ lost := s.trialLost(report, r)
+ if errors.Is(err, paseo.ErrUncertain) || errors.Is(err, paseo.ErrClosed) || errors.Is(err, paseo.ErrNotReady) || errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
+ return errors.Join(errTrialReconnect, err, lost)
+ }
+ return errors.Join(err, lost)
+}
diff --git a/internal/runner/trial_test.go b/internal/runner/trial_test.go
new file mode 100644
index 00000000..ffee596f
--- /dev/null
+++ b/internal/runner/trial_test.go
@@ -0,0 +1,54 @@
+package runner
+
+import (
+ "context"
+ "errors"
+ "os"
+ "path/filepath"
+ "slices"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/equipo/team"
+ "amadan.net/oficina/equipo/internal/runner/paseo"
+)
+
+func TestTrialReconnectWaitsWithoutRetry(t *testing.T) {
+ s, r, _, order := cleanupFixture(t)
+ r.Claim.Assignment.Selection.Isolation.Trial = &team.TrialSnapshot{Label: "supervised trial"}
+ r.InFlightAction = 1
+ err := s.trialTurnError(context.Background(), r, paseo.ErrUncertain)
+ if !errors.Is(err, errTrialReconnect) || !slices.Contains(*order, "lost") {
+ t.Fatalf("lost not recorded: %v %v", err, *order)
+ }
+ _ = s.finishAttempt(context.Background(), r, err)
+ if slices.Contains(*order, "release") || slices.Contains(*order, "complete") {
+ t.Fatal("trial outcome retried or failed", *order)
+ }
+}
+func TestTrialProviderVersionObservedLocally(t *testing.T) {
+ for _, provider := range []string{"claude", "codex"} {
+ t.Run(provider, func(t *testing.T) {
+ path := filepath.Join(t.TempDir(), provider)
+ output := "2.1.312 (Claude Code)"
+ expected := "2.1.312"
+ if provider == "codex" {
+ output = "codex-cli 0.165.0"
+ expected = "0.165.0"
+ }
+ if err := os.WriteFile(path, []byte("#!/bin/sh\n[ \"$1\" = --version ] || exit 1\nprintf '%s\\n' '"+output+"'\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ r := Runtime{cfg: Config{ClaudePath: path, CodexPath: path}}
+ got, err := r.providerVersion(context.Background(), paseo.Selection{Provider: provider})
+ if err != nil || got != expected {
+ t.Fatalf("%s %v", got, err)
+ }
+ if err := os.WriteFile(path, []byte("#!/bin/sh\nprintf 'not a version'\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := r.providerVersion(context.Background(), paseo.Selection{Provider: provider}); err == nil {
+ t.Fatal("unobserved version accepted")
+ }
+ })
+ }
+}
diff --git a/internal/runner/workflow_turn.go b/internal/runner/workflow_turn.go
index 87566c59..c23460da 100644
--- a/internal/runner/workflow_turn.go
+++ b/internal/runner/workflow_turn.go
@@ -12,7 +12,8 @@ import (
"amadan.net/oficina/equipo/internal/runnerproto"
)
-func (w *BugWorkflow) modelTurn(ctx context.Context, s *Supervisor, r *attemptState, l *leaseGuard, current func(context.Context) error, socket *AttemptSocket, artifacts []team.Artifact) error {
+func (w *BugWorkflow) modelTurn(ctx context.Context, s *Supervisor, r *attemptState, l *leaseGuard, current func(context.Context) error, socket *AttemptSocket, artifacts []team.Artifact) (turnErr error) {
+ defer func() { turnErr = s.trialTurnError(ctx, r, turnErr) }()
if err := s.journal.BeginReplay(ctx, r.Agent); err != nil {
return err
}
@@ -162,6 +163,10 @@ drained:
if err := retryAuthority(ctx, func() error { return s.api.Call(ctx, "admit", q, &ticket) }); err != nil {
return err
}
+ r.InFlightAction = action
+ if err := s.save(ctx, r); err != nil {
+ return err
+ }
if err := current(ctx); err != nil {
return err
}
@@ -226,6 +231,12 @@ drained:
return err
}
}
+ if e.Kind == "turn_completed" || e.Kind == "turn_failed" {
+ r.InFlightAction = 0
+ if err := s.save(ctx, r); err != nil {
+ return err
+ }
+ }
if e.Kind == "turn_failed" {
return team.ErrEvidence
}
diff --git a/internal/runner/workspace/workspace.go b/internal/runner/workspace/workspace.go
index 919ae384..6860ec3b 100644
--- a/internal/runner/workspace/workspace.go
+++ b/internal/runner/workspace/workspace.go
@@ -346,6 +346,9 @@ func (m *Manager) preflight(ctx context.Context, a runnerproto.Assignment) (pase
found = true
}
}
+ if snap.Trial != nil && snap.Valid() && c.TrialReady && found {
+ return p, nil
+ }
if s.Provider != "codex" || c.ProviderVersion != "0.165.0" || c.PaseoVersion != "0.14.0" || snap.Status != "unconfined" || !snap.RunnerTainted || len(snap.AcknowledgementIDs) == 0 || !found {
return p, paseo.ErrIsolation
}
diff --git a/internal/runnerproto/types.go b/internal/runnerproto/types.go
index 80993025..7095c0fc 100644
--- a/internal/runnerproto/types.go
+++ b/internal/runnerproto/types.go
@@ -117,6 +117,8 @@ type ConnectionRouting struct {
}
type ConnectionReport struct {
+ TrialReady bool
+ ProviderVersionSource string
LocalID, Provider, ProviderVersion, PaseoVersion, Family, Model, AccountLabel, Kind, UnavailableReason, IsolationConfigHash string
Available, ReadIsolation, AllowanceKnown bool
AllowanceRemaining int64
diff --git a/runner/paseo/bridge.mjs b/runner/paseo/bridge.mjs
index 86aec2af..2d336035 100644
--- a/runner/paseo/bridge.mjs
+++ b/runner/paseo/bridge.mjs
@@ -176,12 +176,13 @@ export class Bridge {
async createAgent(r) {
let status;
try {
- keys(r, ['resource_id', 'workspace', 'selection', 'idempotency_key', 'mode_id', 'read_policy', 'env', 'provider_options', 'mcp_servers']);
+ keys(r, ['credential_home', 'resource_id', 'workspace', 'selection', 'idempotency_key', 'mode_id', 'read_policy', 'env', 'provider_options', 'mcp_servers']);
status = await this.status(r.workspace.server_id);
allowedPath(r.workspace.path, r.read_policy);
if (!text(r.workspace.workspace_id) || !text(r.idempotency_key) || r.mode_id !== 'default') fail('invalid_request');
if (!isDeepStrictEqual(r.provider_options, providerPolicy(r.selection.provider, status.version, r.read_policy))) fail('policy_mismatch');
validateEnv(r.env ?? {});
+ if (r.credential_home !== undefined && (!text(r.credential_home) || !isAbsolute(r.credential_home) || resolve(r.credential_home) !== r.credential_home || !r.read_policy.denied_paths.includes(r.credential_home))) fail('policy_mismatch');
if (!record(r.mcp_servers)) fail('invalid_mcp');
for (const server of Object.values(r.mcp_servers)) {
if (!record(server) || server.type !== 'stdio' || !text(server.command) || !isAbsolute(server.command) || !Array.isArray(server.args) || server.args.some(a => typeof a !== 'string')) fail('invalid_mcp');
@@ -189,7 +190,7 @@ export class Bridge {
}
this.creationReceipts();
} catch (error) { error.definitiveCreateFailure = true; throw error; }
- const a = await this.client.createAgent({ agentId: r.resource_id, workspaceId: r.workspace.workspace_id, cwd: r.workspace.path, provider: r.selection.provider, model: r.selection.model, idempotencyKey: r.idempotency_key, modeId: r.mode_id, env: r.env ?? {}, providerOptions: r.provider_options, mcpServers: r.mcp_servers });
+ const a = await this.client.createAgent({ agentId: r.resource_id, workspaceId: r.workspace.workspace_id, cwd: r.workspace.path, provider: r.selection.provider, model: r.selection.model, idempotencyKey: r.idempotency_key, modeId: r.mode_id, env: { ...(r.env ?? {}), ...(r.credential_home ? { [r.selection.provider === 'claude' ? 'CLAUDE_CONFIG_DIR' : 'CODEX_HOME']: r.credential_home } : {}) }, providerOptions: r.provider_options, mcpServers: r.mcp_servers });
if ((r.resource_id && a.id !== r.resource_id) || !text(a.id) || a.workspaceId !== r.workspace.workspace_id || a.cwd !== r.workspace.path || a.provider !== r.selection.provider || a.model !== r.selection.model) fail('identity_mismatch');
return { server_id: status.serverId, agent_id: a.id, provider_session_id: a.runtimeInfo?.sessionId ?? a.persistence?.sessionId ?? '', workspace_id: a.workspaceId, account_id: '', provider: a.provider, model: a.model, family: r.selection.family };
}
@@ -241,7 +242,8 @@ export class Bridge {
if (!sub || !sub.ready || sub.closed) fail('subscription_not_ready');
return sub;
}
- async subscribe({ agent, cursor, subscription_id }) {
+ async subscribe({ agent, cursor, subscription_id, trial = false }) {
+ if (trial && (cursor.epoch || cursor.sequence > 0)) fail('timeline_gap');
if (!text(subscription_id) || this.subscriptions.has(subscription_id) || [...this.subscriptions.values()].some(s => s.agent.agent_id === agent.agent_id)) fail('invalid_request');
// Install controls and live observation before reading history, then deduplicate
// sequenced entries. Controls without cursors retain that uncertainty.
@@ -286,6 +288,7 @@ export class Bridge {
next = history.endCursor;
}
if (sub.closed) fail('timeline_gap');
+ if (trial && sub.sequence <= 0) this.emit({ version: 1, type: 'event', subscription_id, event: { kind: 'trial_timeline_snapshot', server_id: agent.server_id, agent_id: agent.agent_id, provider_session_id: agent.provider_session_id, turn_id: '', permission_id: '', epoch: sub.epoch, sequence: 0, payload: {} } });
sub.ready = true;
for (const event of sub.pending) this.deliver(subscription_id, sub, event);
sub.pending = [];
diff --git a/runner/paseo/bridge.test.mjs b/runner/paseo/bridge.test.mjs
index 25129b34..49c09d9a 100644
--- a/runner/paseo/bridge.test.mjs
+++ b/runner/paseo/bridge.test.mjs
@@ -398,3 +398,26 @@ test('definitive policy failures retain their specific wire codes', async () =>
assert.deepEqual(bridgeFailure(Object.assign(new Error('invalid_request'),{definitiveCreateFailure:true})),{error:'create_refused',definitive_create_failure:true});
assert.deepEqual(bridgeFailure(new Error('policy_mismatch')),{error:'policy_mismatch',definitive_create_failure:false});
});
+
+test('trial routes the chosen credential home using supported agent env', async () => {
+ const f = fake();
+ const input = { ...request(), credential_home: '/protected' };
+ await f.bridge.createAgent(input);
+ const actual = f.calls.find(c => c[0] === 'create')[1];
+ assert.equal(actual.env[selection.provider === 'claude' ? 'CLAUDE_CONFIG_DIR' : 'CODEX_HOME'], '/protected');
+ assert.equal(Object.hasOwn(actual, 'accountId'), false);
+});
+
+test('trial starts an empty live timeline and refuses recovered completion', async () => {
+ const f = fake();
+ const pending = f.bridge.subscribe({ agent, cursor: { sequence: 0 }, subscription_id: 'trial', trial: true });
+ f.ready(); await pending;
+ assert.equal(f.events[0].event.kind, 'trial_timeline_snapshot');
+ assert.equal(f.events[0].event.epoch, 'epoch-fixture');
+ f.disconnect();
+ assert.equal(f.events.at(-1).type, 'subscription_error');
+ await assert.rejects(f.bridge.send({ agent, message: 'again', message_id: 'again' }), /subscription_not_ready/);
+ assert.equal(f.calls.filter(c => c[0] === 'send').length, 0);
+ await assert.rejects(f.bridge.subscribe({ agent, cursor: { epoch: 'epoch-fixture', sequence: 1 }, subscription_id: 'replay', trial: true }), /timeline_gap/);
+ await f.bridge.close();
+});
diff --git a/scripts/live-gate.sh b/scripts/live-gate.sh
index d8e54a7f..e632f2ba 100755
--- a/scripts/live-gate.sh
+++ b/scripts/live-gate.sh
@@ -2,12 +2,19 @@
# DRAFT: copy review required
set -eu
cd "$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
-printf '%s\n' 'Read docs/live-gate.md. The pinned stack has unresolved blockers and cannot pass.'
+if [ "$(id -un)" != equipo-runner ]; then
+ printf '%s\n' 'Run this as equipo-runner after Paul completes docs/live-gate.md. The agent never runs sudo.' >&2
+ exit 1
+fi
+[ "${EQUIPO_PASEO_HOME:-}" = /home/equipo-runner/.paseo ] || exit 1
+case "${EQUIPO_PASEO_ENDPOINT:-}" in 127.0.0.1:*) ;; *) exit 1 ;; esac
+printf '%s\n' 'Read docs/live-gate.md. Full-contract probes still fail; trial consent is not a passed live gate.'
+printf '%s\n' 'Confirm this runner and its own Paseo daemon run as equipo-runner.'
printf '%s\n' 'Confirm the disposable repository, enrolled connections, origin and machine fingerprint.'
printf '%s' 'Type LIVE DISPOSABLE ONLY: '
IFS= read -r answer
[ "$answer" = 'LIVE DISPOSABLE ONLY' ] || exit 1
-printf '%s\n' 'Confirm bounded calibration funding, disposable sentinel locations, owner acknowledgement and process ownership.'
+printf '%s\n' 'Confirm bounded calibration funding, disposable sentinel locations, current runner trial consent, Codex acknowledgement and process ownership.'
printf '%s\n' 'Keep other agents, projects, credentials and the shared daemon unchanged.'
printf '%s' 'Type RUN LIVE GATE: '
IFS= read -r answer