Add guided live gate and disable token refresh for v1
66 files changed,
+2,152
−726
cmd/equipo-try/main.go+27 −0docs/live-gate.md+57 −332docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+27 −0docs/superpowers/plans/CONTROLLER-REPORT-try-equipo.md+173 −0internal/directlive/account_change.go+114 −0internal/directlive/certificate.go+2 −3internal/directlive/cleanup.go+27 −0internal/directlive/codex_inventory.go+44 −0internal/directlive/coordinator_certificate_test.go+1 −1internal/directlive/driver.go+13 −3internal/directlive/driver_test.go+17 −2internal/directlive/generation.go+5 −6internal/directlive/inventory.go+4 −0internal/directlive/observations.go+6 −2internal/directlive/probes.go+33 −4internal/directlive/staged_resume_test.go+28 −0internal/directlive/staged_source.go+67 −1internal/directlive/testdata/fake-cli.py+6 −3internal/directlive/try_inventory_test.go+20 −0internal/equipo/copy.go+112 −114internal/equipo/templates/connections.html+1 −1internal/equipotest/runner_release_test.go+2 −2internal/equipotest/signin_again_test.go+30 −0internal/plan3test/coordinator_release_test.go+2 −2internal/plan3test/plan3_release_test.go+2 −2internal/release/install.go+1 −1internal/release/install_test.go+1 −1internal/release/manifest.go+7 −6internal/release/manifest.json+8 −8internal/release/manifest_test.go+3 −3internal/release/no_refresh_test.go+34 −0internal/release/policy_inventory.go+10 −1internal/release/refresh.go+15 −54internal/release/refresh_test.go+2 −2internal/runner/certified/policy.go+4 −51internal/runner/certified_network_test.go+6 −6internal/runner/containment/egress_test.go+3 −2internal/runner/diagnostics.go+2 −0internal/runner/egress/policy.go+2 −6internal/runner/egress/proxy_test.go+3 −3internal/runner/provider/accounts.go+4 −0internal/runner/provider/codex/launcher.go+13 −9internal/runner/provider/codex/launcher_test.go+3 −0internal/runner/provider/direct_certification.go+1 −1internal/runner/provider/direct_certification_test.go+1 −1internal/runner/provider/direct_live_config.go+24 −1internal/runner/provider/direct_live_config_test.go+1 −1internal/runner/provider/direct_requirements.json+1 −2internal/runner/provider/expiry.go+38 −0internal/runner/provider/expiry_test.go+44 −0internal/runner/provider/login.go+18 −0internal/runner/provider/login_probe.go+24 −15internal/runner/residual_outcome_test.go+1 −0internal/runner/runtime_direct.go+3 −0internal/runner/setup/install_test.go+1 −1internal/tryequipo/accounts.go+116 −0internal/tryequipo/accounts_test.go+195 −0internal/tryequipo/budget_test.go+9 −0internal/tryequipo/command.go+32 −0internal/tryequipo/config.go+66 −0internal/tryequipo/prerequisites.go+84 −0internal/tryequipo/run.go+260 −0internal/tryequipo/state.go+148 −0scripts/runner-reference-allowlist.json+133 −70scripts/runner-release-check.py+3 −3scripts/try-equipo.sh+8 −0
CI cancelled — superseded by a newer push — run details
Intent
diff --git a/cmd/equipo-try/main.go b/cmd/equipo-try/main.go| new file mode 100644 |
| index 00000000..89f415d7 |
| --- /dev/null |
| +++ b/cmd/equipo-try/main.go |
| @@ -0,0 +1,27 @@ |
| +package main |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/tryequipo" |
| + "context" |
| + "os" |
| + "os/signal" |
| + "path/filepath" |
| + "syscall" |
| +) |
| + |
| +func main() { |
| + ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) |
| + defer stop() |
| + home, err := os.UserHomeDir() |
| + if err != nil { |
| + os.Exit(1) |
| + } |
| + repo, err := os.Getwd() |
| + if err != nil { |
| + os.Exit(1) |
| + } |
| + w := tryequipo.Wizard{Root: filepath.Join(home, ".local/share/equipo/try"), Accounts: filepath.Join(home, ".local/share/equipo/accounts"), Repository: repo, Input: os.Stdin, LoginInput: os.Stdin, Output: os.Stdout} |
| + if w.Run(ctx) != nil { |
| + os.Exit(1) |
| + } |
| +} |
diff --git a/docs/live-gate.md b/docs/live-gate.md| index 12985074..d969e114 100644 |
| --- a/docs/live-gate.md |
| +++ b/docs/live-gate.md |
| @@ -1,337 +1,62 @@ |
| -# Direct provider release gate |
| +# Try Equipo |
| -DRAFT. Copy review pending. Production tuple eligibility is off. |
| - |
| -The tagged tests now start an exercise driver before verifying its output. The |
| -driver refuses a nonempty evidence directory. It opens the dedicated account |
| -leases, real adapters, namespace manager, egress, durable capture and MCP broker. |
| -Person answers come from `/dev/tty`, expire after 60 seconds and accept only |
| -**Allow once**, **Deny**, or the original question's answers JSON. Operators do |
| -not enter pass/fail observations. |
| - |
| -The follow-up is not ready to certify a production tuple. Successful and failed |
| -refresh through the auth hosts, a changed provider account, and complete Codex |
| -tool discovery remain unfinished. The driver now shares |
| -production policy construction for the bug-workflow profiles. It also collects |
| -the separate read-only Product profile for review. The implemented lifetime probe covers host loopback, attempted |
| -cgroup movement, detached children and active cancellation under the namespace |
| -manager. Calibration pools complete samples per provider family. Unfinished |
| -requirements are recorded as `not-certified`; the verifier and manifest writer |
| -reject them. |
| -Do not run a production certification until the controller closes these gaps. |
| -The fake CLI test proves the implemented control flow without a provider. Set |
| -the same runner state, bindings, forge-credential path, workspace root and scratch |
| -root variables that production will use; they define its protected paths. The |
| -collector uses a separate temporary journal and never opens production state. |
| -The configured scratch root must have no existing namespace records. Only this |
| -run's records and temporary homes are removed, after verified exit. |
| - |
| -When an auth host is named, the generation exercise stages a copy of the |
| -selected login JSON with added whitespace. To test the configured source path, |
| -it swaps that copy in with an atomic rename, then restores the original bytes |
| -on success, failure or cancellation. The identity-marker check uses the same |
| -replacement and restoration path. Neither test changes token values or writes |
| -in place. These bounded source changes test the production binding; they do not |
| -claim to have changed the provider account. |
| - |
| -The stdio helper is now a separate `equipo-tool-proxy` executable. Its digest is |
| -part of provider policy. The namespace runner still embeds the manifest; the |
| -manager pins that executable at startup and records its digest in concrete |
| -launch evidence. Changing it after startup is refused. Generated login-home |
| -paths have stable roles in the reusable policy hash and exact paths in concrete |
| -launch evidence. |
| - |
| -## Prepare the accounts and bounded inputs |
| - |
| -1. Review the branch and pending copy with Paul. Before any model prompt, run |
| - the adapter Open preflight against the dedicated Claude home. Record the |
| - closed-stdin exit code and first stderr line as a sanitized fixture, and pin |
| - the observed outcome before certification continues. A failed preflight must |
| - keep the connection unavailable. Before upgrading an existing |
| - instance, stop its old runner and every process it launched. Migrations 0018 and 0019 |
| - retain evidence and charges while fencing unfinished work. Tasks with claimed |
| - old work wait for an owner to use **Old runner stopped** on the task page. |
| - Unclaimed tasks return to setup selection, and cancellation requests remain |
| - in effect. Confirm the processes have stopped before using the action. |
| - |
| -2. Install the pinned dependencies: Claude 2.1.312, Codex 0.165.0, the matching |
| - `codex-code-mode-host`, and bubblewrap 0.11.0. The Go namespace helper is part |
| - of the runner. Provider binaries are installed separately. Use their absolute |
| - paths throughout. Packaging checks the provider/helper digests pinned in the |
| - adapters and the configured bubblewrap executable's version and digest. |
| - |
| -3. Create new credential homes yourself. Use one home per provider account and |
| - never copy an interactive or shared ZeroSub login into it. For example: |
| - |
| - ```sh |
| - umask 077 |
| - mkdir -p "$HOME/.local/share/equipo/accounts/claude-paul" "$HOME/.local/share/equipo/accounts/codex-paul" |
| - chmod 700 "$HOME/.local/share/equipo/accounts/claude-paul" "$HOME/.local/share/equipo/accounts/codex-paul" |
| - ``` |
| - |
| - Sign in once per provider account in those homes, with the pinned binaries: |
| - |
| - ```sh |
| - CLAUDE_CONFIG_DIR="$HOME/.local/share/equipo/accounts/claude-paul" CLAUDE_SECURESTORAGE_CONFIG_DIR="$HOME/.local/share/equipo/accounts/claude-paul" "$EQUIPO_CLAUDE_PATH" auth login |
| - CODEX_HOME="$HOME/.local/share/equipo/accounts/codex-paul" "$EQUIPO_CODEX_PATH" login |
| - ``` |
| - |
| - These are scoped environment assignments. Do not export these homes as your |
| - interactive `CODEX_HOME` or `CLAUDE_CONFIG_DIR`: the gate refuses interactive |
| - homes, including environment overrides, aliases and shared-home mounts. |
| - |
| -4. Confirm the account identity through each provider's status/readback path. |
| - For Claude, explicitly confirm the observed email/account identity yourself. |
| - This is trust on first use, not remote identity attestation. Give each home a |
| - distinct local `home_id`. Save its confirmed identity, version and home ID in |
| - `equipo-identity.json` inside that home, mode 0600: |
| - |
| - ```json |
| - {"account_id":"CONFIRMED_ACCOUNT","home_id":"UNIQUE_HOME_ID","provider_version":"2.1.312"} |
| - ``` |
| - |
| - Use `0.165.0` for Codex. Keep the native credential files private. Never put |
| - credential contents, hashes, sign-in links or bearer tokens into evidence. |
| - |
| -5. Configure the runner environment file at |
| - `$HOME/.local/share/equipo-runner/runner.env`, mode 0600. Set every value to the |
| - intended instance and an absolute path on docs-t1: |
| - |
| - ```text |
| - EQUIPO_ORIGIN=https://YOUR_INSTANCE |
| - EQUIPO_INSTANCE_ID=YOUR_INSTANCE_ID |
| - EQUIPO_CLAUDE_PATH=/ABSOLUTE/PATH/TO/claude |
| - EQUIPO_CODEX_PATH=/ABSOLUTE/PATH/TO/codex |
| - EQUIPO_CODEX_CODE_MODE_HOST_PATH=/ABSOLUTE/PATH/TO/codex-code-mode-host |
| - EQUIPO_BWRAP_PATH=/ABSOLUTE/PATH/TO/bwrap |
| - EQUIPO_AMADAN_PATH=/ABSOLUTE/PATH/TO/amadan |
| - EQUIPO_GIT_PATH=/usr/bin/git |
| - EQUIPO_GO_ROOT=/ABSOLUTE/PATH/TO/go-root |
| - EQUIPO_GO_BINARY=/ABSOLUTE/PATH/TO/go-root/bin/go |
| - EQUIPO_TOOL_PROXY_PATH=/ABSOLUTE/INSTALLED/equipo-tool-proxy |
| - EQUIPO_RUNNER_EXECUTABLE=/ABSOLUTE/PATH/TO/equipo-runner |
| - EQUIPO_RUNNER_STATE_DIR=/ABSOLUTE/PRIVATE/STATE |
| - EQUIPO_ACCOUNT_BINDINGS_PATH=/ABSOLUTE/PRIVATE/bindings.json |
| - EQUIPO_AMADAN_CREDENTIAL_PATH=/ABSOLUTE/PRIVATE/amadan-credential.json |
| - EQUIPO_WORKSPACE_ROOT=/ABSOLUTE/WORKSPACES |
| - EQUIPO_SCRATCH_ROOT=/ABSOLUTE/ON-DISK/SCRATCH |
| - ``` |
| - |
| - `EQUIPO_GO_MODULE_CACHE` is optional. Leave host Go caches at their defaults. |
| - The runner holds the Amadan credential; model tools do not. On the instance, |
| - retain `EQUIPO_ORIGIN`, `EQUIPO_INSTANCE_KEY` and the SMTP requirements. Enable |
| - execution with `EQUIPO_EXECUTION_ENABLED=1` only at the human release step. |
| - |
| - Write `bindings.json` as a JSON array, mode 0600. Add one entry per selected |
| - account/model. For example, the Claude entry has this shape: |
| - |
| - ```json |
| - {"id":"claude-paul","local_id":"claude-paul","person_id":"YOUR_PERSON_ID","provider":"claude","family":"claude","model":"EXACT_MODEL","account_id":"CONFIRMED_ACCOUNT","provider_home":"/ABSOLUTE/DEDICATED/HOME","kind":"subscription","expected_identity":{"account_id":"CONFIRMED_ACCOUNT","home_id":"UNIQUE_HOME_ID","provider_version":"2.1.312"}} |
| - ``` |
| - |
| - For Codex use provider `codex`, family `gpt` and version `0.165.0`. Bindings do |
| - not grant home authority. The runner verifies each home again before use. |
| - |
| -6. Choose a disposable Git repository with a local `.git` directory and no |
| - valuable changes. Create nonsecret sentinel files in each dedicated home, a |
| - separate disposable other-home directory, a separate disposable runner-state |
| - directory, and the repository. Use nonempty random markers. Record their |
| - absolute paths. The live exercises must also cover the actual protected |
| - runtime paths, including `/egress`, `/tool/equipo.sock`, `/proc/*/root`, |
| - `/proc/*/fd`, `/dev/fd` and symlink aliases. |
| - |
| -7. Authorize the calibration separately. Record a maximum call count, complete |
| - input/output token budgets and duration. Also record job funding and the |
| - remaining project and team period headroom. The verifier computes each |
| - family's reservations as twice its maximum measured input and output, rounded |
| - up to 1,000, with overflow checks. A job needs at least 23 reservations in |
| - each dimension. If this exceeds your configured limits, stop and decide |
| - yourself whether to change them. Never silently raise them. Unknown usage |
| - stays unknown. Subscription usage is not a hard currency cap. |
| - |
| -8. Write a private `DirectLiveConfig` JSON file. Use this shape, replacing every |
| - placeholder and zero with an explicitly authorized value. The gate refuses |
| - this unfilled example: |
| - |
| - ```json |
| - { |
| - "run_id":"UNIQUE_CERTIFICATION_RUN", |
| - "repository":"/ABSOLUTE/DISPOSABLE/REPOSITORY", |
| - "disposable":true, |
| - "evidence_dir":"/ABSOLUTE/PRIVATE/EVIDENCE", |
| - "origin":"https://YOUR_INSTANCE", |
| - "machine_fingerprint":"CONFIRMED_DOCS_T1_FINGERPRINT", |
| - "bindings":[ |
| - {"binding":{"ID":"claude-paul","Provider":"claude","AccountID":"CONFIRMED_CLAUDE_ACCOUNT","Home":"/ABSOLUTE/CLAUDE/HOME","Expected":{"account_id":"CONFIRMED_CLAUDE_ACCOUNT","home_id":"CLAUDE_HOME_ID","provider_version":"2.1.312"}},"model":"EXACT_CLAUDE_MODEL","auth_host":"EXACT_CERTIFIED_CLAUDE_AUTH_HOST","claude_tofu_confirmed":true}, |
| - {"binding":{"ID":"codex-paul","Provider":"codex","AccountID":"CONFIRMED_CODEX_ACCOUNT","Home":"/ABSOLUTE/CODEX/HOME","Expected":{"account_id":"CONFIRMED_CODEX_ACCOUNT","home_id":"CODEX_HOME_ID","provider_version":"0.165.0"}},"model":"EXACT_CODEX_MODEL","auth_host":"EXACT_CERTIFIED_CODEX_AUTH_HOST","claude_tofu_confirmed":false} |
| - ], |
| - "sentinels":{"claude":"/ABSOLUTE/CLAUDE/HOME/sentinel","codex":"/ABSOLUTE/CODEX/HOME/sentinel","other":"/ABSOLUTE/OTHER/HOME/sentinel","state":"/ABSOLUTE/TEST/STATE/sentinel","repo":"/ABSOLUTE/DISPOSABLE/REPOSITORY/sentinel"}, |
| - "funding":{"Calls":0,"InputTokens":0,"OutputTokens":0,"Seconds":0,"JobInput":0,"JobOutput":0,"ProjectInputHeadroom":0,"ProjectOutputHeadroom":0,"TeamInputHeadroom":0,"TeamOutputHeadroom":0} |
| - } |
| - ``` |
| - |
| - Auth hosts have no guessed defaults. Pin only the exact provider auth hosts |
| - whose refresh paths you exercise. Refresh must remain limited to those hosts |
| - and the selected dedicated homes. An empty `auth_host` permits the other |
| - exercises but records refresh as uncertified and cannot produce an eligible |
| - tuple. A named host currently still needs the unfinished refresh exercises. |
| - |
| -## Record and verify the certification |
| - |
| -The driver writes the implemented observations itself. Unimplemented or unobserved |
| -requirements remain uncertified. Do not replace them with hand-written records. The evidence schema |
| -is `DirectEvidence` in `internal/runner/provider/direct_certification.go`; the |
| -required assertion names are in `direct_requirements.json` beside it. |
| - |
| -9. Exercise every configured provider/model/policy through the real adapters, |
| - durable journal, broker and namespace manager. Keep both inner sandboxes |
| - enabled. For Codex verify the deny profile together with |
| - `approvalPolicy:"on-request"`, `approvalsReviewer:"user"` and `--strict-config`. |
| - Verify account/version and effective-policy readback. Test immutable settings, |
| - scoped Equipo MCP authority, a broker-validated Equipo approval answered by |
| - the runner, non-Equipo approvals sent to a person, real questions, stale and |
| - invalid broker requests, and denied policy escalation. For native Codex |
| - permissions, a person may choose **Allow once**. Retain the |
| - **approved beyond profile** label in the evidence when applicable. It does |
| - not certify a broader sandbox or authorize a hidden turn. |
| - |
| -10. Exercise actual exposed native, shell, search, image and MCP tools against |
| - every protected path and alias. Require a successful workspace positive |
| - control. Record missing tools with reasons. An exposed reader without a |
| - tested denial blocks certification. Claude Engineering must expose exactly |
| - `Bash,Read,Write,Edit,Glob,Grep`; Review and Product must expose exactly |
| - `Read,Glob,Grep,Bash`, plus only the registered Equipo MCP tools for that |
| - policy. Do not enable forbidden tools to test them. Capture each specialist |
| - policy separately, including Engineering reproduction and implementation. |
| - |
| -11. Exercise successful refresh through each pinned auth host, failed refresh, |
| - and same-identity credential-generation change between turns. Require fresh |
| - preflight and binding before continued availability. A changed identity |
| - must stop the step. Exercise clean-session resume, intentional mid-turn |
| - runner death, durable replay without redispatch, and active cancellation. |
| - Verify Go helper PID 1 ownership, its pidfd exit, no surviving detached |
| - descendants, confinement after a cgroup move, and no reachable host services. |
| - |
| -12. Measure complete per-family input/output usage through separately bounded |
| - calibration admission. Preserve unknown observations, even though an unknown |
| - sample cannot establish a reservation. Retain the configured funding limits. |
| - Use the calculated reservations and 23-reservation job floor to check both |
| - project and team period headroom. |
| - |
| -13. Store sanitized capture artifacts and one `certification.json` per exact |
| - policy under the evidence directory. Each check/probe references its artifact |
| - by relative path and SHA-256, with a result and an explanation. Include the |
| - exact configuration-file hash, installed executable hashes, account/model, |
| - policy tuple, tool inventory, usage and funding. `index.json` is an array of |
| - relative paths to those certification files. The verifier requires Claude |
| - Engineering/Review/Product and Codex Engineering/Review coverage. It checks |
| - evidence integrity and completeness; a trusted human still reviews whether |
| - the captured observations establish the stated results. |
| - |
| -14. With explicit live authorization and those bounded inputs, run: |
| - |
| - ```sh |
| - export EQUIPO_LIVE_DIRECT=1 |
| - export EQUIPO_LIVE_CONFIG=/ABSOLUTE/PRIVATE/direct-live.json |
| - CGO_ENABLED=0 go test -tags direct_live ./internal/runner/provider -run '^TestDirectLive(Contract|Isolation|Recovery|Calibration)$' -count=1 |
| - ``` |
| - |
| - Or use `scripts/live-gate.sh`, which retains both typed confirmations: |
| - `LIVE DISPOSABLE ONLY` and `RUN LIVE GATE`. Missing opt-in, inputs or evidence |
| - fail the tests. No test skips into success. The command collects observations |
| - and then verifies them; the unfinished exercises listed above still prevent |
| - a passing certification. |
| - |
| - |
| -## Certified refresh and reproducible helper builds |
| - |
| -Build the helper with the same flags as packaging before certification: |
| +On docs-t1, run this as yourself from the reviewed checkout: |
| ```sh |
| -CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -buildvcs=false -ldflags "-s -w" -o "$EQUIPO_TOOL_PROXY_PATH" ./cmd/equipo-tool-proxy |
| +scripts/try-equipo.sh |
| ``` |
| -The helper imports neither runner state nor the release manifest. `release-runner` |
| -rebuilds it and checks its digest before building the runner. Both the installed |
| -helper and the packaged helper must match the manifest's `equipo-tool-proxy` |
| -binary entry. Certify the actual installation paths used by the runner. |
| - |
| -After every requirement passes, `directlive.ManifestCandidate` writes |
| -`candidate-manifest.json` beside the evidence. For each exact provider, version |
| -and policy hash, it derives `certified_refresh.auth_host` from the evidence and |
| -sets `certified_refresh.evidence_sha256` to that certification file's SHA-256. |
| -The `certifications` reference must have the same digest. Copy the reviewed |
| -bundle to the paths named in that candidate, and update the shared instance and |
| -runner manifest together. Do not fill the refresh field by hand. |
| - |
| -Production reads refresh hosts only from those manifest tuples. A matching |
| -certificate adds the host to the dedicated home's egress policy and policy hash. |
| -An absent certificate, wrong version, changed policy or mismatched evidence |
| -reference grants no host. Configuration and environment variables cannot grant |
| -refresh authority; a pending refresh without a certified host stops for account |
| -maintenance. The current checked-in manifest remains empty. |
| - |
| -## Package and perform the first job |
| - |
| -15. After all observations pass and a human reviews them, copy the sanitized |
| - evidence into `internal/release/evidence/`. Update the single shared |
| - `internal/release/manifest.json`: installed binary digests, `direct_policies`, |
| - matching `verified_isolation_tuples`, and `certifications` references. Each |
| - reference has `provider`, `policy_hash`, repository-relative `path` and |
| - `sha256`. Paths must stay under `internal/release/evidence/`. Never add a |
| - policy without all required passing evidence. Review pending runtime and |
| - live-gate copy, then set `live_gate_copy_reviewed` to true. The current |
| - manifest intentionally has no certificates or eligible tuples. |
| - |
| -16. Let the controller run the shared CI gate and review the clean branch. After |
| - resolving the prerequisites at the top of this document, build both artifacts |
| - from that same reviewed commit: |
| - |
| - ```sh |
| - make release |
| - make release-runner |
| - ``` |
| - |
| - Both commands refuse uncertified evidence and pending copy. Artifacts include |
| - the short commit in their names and a full `COMMIT` stamp. The runner package |
| - contains the runner, standalone tool proxy, user unit, manifest and evidence; it contains no provider |
| - binaries. Keep the instance's matching manifest/evidence sidecars with its |
| - binary. Only a human deploys the versioned instance release. |
| - |
| -17. On docs-t1, install the reviewed runner package and user unit yourself. Set |
| - `RUNNER_PACKAGE` to that exact versioned package directory: |
| - |
| - ```sh |
| - mkdir -p "$HOME/.local/lib/equipo-runner" "$HOME/.config/systemd/user" |
| - cp -R "$RUNNER_PACKAGE/." "$HOME/.local/lib/equipo-runner/" |
| - cp "$RUNNER_PACKAGE/equipo-runner.service" "$HOME/.config/systemd/user/equipo-runner.service" |
| - systemctl --user daemon-reload |
| - systemctl --user enable equipo-runner.service |
| - ``` |
| - |
| - Export the reviewed `EQUIPO_*` configuration for the enrolment command, then: |
| - |
| - ```sh |
| - "$HOME/.local/lib/equipo-runner/equipo-runner" enrol |
| - ``` |
| - |
| - Follow the device approval in Equipo. Confirm docs-t1's fingerprint and |
| - approve that machine yourself. Start the user service after enrolment: |
| - |
| - ```sh |
| - systemctl --user start equipo-runner.service |
| - ``` |
| - |
| -18. Select your dedicated Claude and Codex connections on the same approved |
| - machine. Confirm independent provider families for Engineering and Review, |
| - enable execution on the instance, and request the first bounded bug fix in |
| - the disposable project. Answer real questions and permissions yourself. |
| - Inspect the frozen base-fail/candidate-pass evidence, exact candidate checks, |
| - usage, containment proof and independent review. Verify the exact Amadan |
| - review branch and commit. Try cancellation during an active attempt and |
| - confirm the recorded stop before retrying. Merge the reviewed branch |
| - yourself. Equipo must not merge, deploy or push the default branch. |
| - |
| -Stop certification processes and remove only scratch you created. Retain reviewed |
| -sanitized evidence. The service you explicitly installed is the only process |
| -intended to persist. No sudo is needed. |
| +The guide checks the pinned Claude 2.1.312, Codex 0.165.0, matching |
| +`codex-code-mode-host`, bubblewrap 0.11.0, Go and user namespaces. It also needs |
| +Git and Amadan. Missing prerequisites are named before any sign-in starts. |
| +The official sign-in opens a browser. Configure `BROWSER` on docs-t1 if its |
| +default browser opener cannot reach your browser. Provider login output is |
| +hidden so sign-in links, tokens and credential contents stay out of the terminal |
| +and logs. |
| + |
| +Type `SIGN IN` when you are ready. Use two different Claude accounts and one |
| +Codex account. Confirm each observed identity. The guide creates private homes |
| +under `~/.local/share/equipo/accounts/`; it refuses interactive and ZeroSub |
| +homes. Confirmed homes are checked again on every run. If an account changes, |
| +setup stops rather than accepting the replacement. |
| + |
| +The instance is [https://equipo.bds.oncarlos.com](https://equipo.bds.oncarlos.com). |
| +Enter its instance ID, your person ID, exact model names and the absolute path |
| +to the runner's Amadan credential file when asked. Existing `EQUIPO_INSTANCE_ID`, |
| +`EQUIPO_PERSON_ID`, `EQUIPO_CLAUDE_MODEL`, `EQUIPO_CODEX_MODEL` and |
| +`EQUIPO_AMADAN_CREDENTIAL_PATH` values supply these inputs. The guide writes |
| +`equipo-identity.json` in each home and private `bindings.json` beside |
| +`$HOME/.local/share/equipo-runner/runner.env`. It detects executable paths and builds the |
| +runner and tool helper with the packaging flags. It does not enrol a runner or |
| +turn on production execution. |
| + |
| +Review the proposed calibration limits, including job funding and the remaining |
| +project and team token headroom. Enter your own limits where needed. These are |
| +bounds on calls, tokens and duration; subscription usage has no hard currency |
| +cap. Type `RUN LIVE GATE` to authorize that run. |
| + |
| +The guide creates a disposable Git repository and sentinels. The live driver |
| +checks each provider's policies, approvals, recovery and isolation. It reads |
| +the Codex tool catalog from captured CLI events and tries every exposed tool |
| +against the protected paths. The account-change check uses private copies of |
| +the two Claude homes, leaving their credential sources untouched. Missing |
| +observations or failed denials block certification. Human approval questions |
| +arrive through the terminal and expire after 60 seconds. |
| + |
| +V1 does not refresh tokens. A manifest candidate records `certified_refresh: |
| +null` and a reason. Egress permits only the provider's inference host. An expired |
| +login makes the connection unavailable with **Sign in again**. Work cannot |
| +silently retry on another account. |
| + |
| +If the run stops, run the same script again. Confirmed accounts and setup values |
| +are retained under `~/.local/share/equipo/try/`. Each certification attempt gets |
| +a fresh evidence directory and log; incomplete evidence is never reused as a |
| +passing result. The guide refuses to overwrite configuration it did not create. |
| + |
| +On success, the guide prints the manifest candidate and the controller's release |
| +command. The controller reviews the sanitized evidence, imports the bundle at |
| +the paths named in the candidate, and updates the instance and runner manifest |
| +together. Pending copy and uncertified policies still block release. Deployment |
| +and enabling execution remain human actions. Before upgrading an existing |
| +instance, stop its old runner and all its children, then resolve any task waiting |
| +for **Old runner stopped**. |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index d08588f0..95b5f202 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -5099,6 +5099,33 @@ records to satisfy a gate. Release remains blocked while any row is pending. |
| | `docs/mockups/onboarding.html / paired without account` | Waiting for a model account. | 16 | Proposal only; COPY REVIEW REQUIRED | |
| | `plan.awaiting_approval` | Waiting for your plan approval | Final review fix wave | COPY REVIEW REQUIRED | |
| +| `connections.empty` | Connections are not available yet. | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `account.sign_in_again` | Sign in again | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `prerequisite` | Missing prerequisite: %s<br> | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `prompt` | %s [%s]: | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `confirm` | Observed account for %s: %s. Confirm this account? [yes/no]: | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `login` | Signing in to %s in its dedicated home. Complete the official browser flow. Provider output is hidden to keep sign-in links and tokens private.<br> | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `failed` | Stopped at %s. Saved setup can be resumed by running scripts/try-equipo.sh again. No release was made.<br> | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `ready` | Manifest candidate: %s<br>After reviewing and importing the evidence bundle and candidate manifest, the controller releases with:<br>%s<br> | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `live` | Type RUN LIVE GATE to authorize the displayed limits and disposable exercises | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `signin` | Type SIGN IN to start official sign-ins in dedicated homes | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `instance` | Instance ID from Equipo | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `person` | Your Equipo person ID | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `claude-model` | Exact Claude model | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `codex-model` | Exact Codex model | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `forge` | Absolute path to the runner's Amadan credential file | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `Calls` | Maximum calibration calls | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `InputTokens` | Maximum calibration input tokens | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `OutputTokens` | Maximum calibration output tokens | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `Seconds` | Maximum calibration seconds | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `JobInput` | Job input token funding | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `JobOutput` | Job output token funding | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `ProjectInputHeadroom` | Remaining project input tokens | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `ProjectOutputHeadroom` | Remaining project output tokens | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `TeamInputHeadroom` | Remaining team input tokens | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `TeamOutputHeadroom` | Remaining team output tokens | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| +| `limits` | Authorized limits: %s<br> | Guided live gate or expired connection | COPY REVIEW REQUIRED | |
| + |
| ## Task 21 |
| Status: DONE_WITH_CONCERNS. Offline 3b acceptance, the complete person API contract |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo.md b/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo.md| new file mode 100644 |
| index 00000000..3c4ae40d |
| --- /dev/null |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo.md |
| @@ -0,0 +1,173 @@ |
| +# Try Equipo controller report |
| + |
| +The guided entry point is `scripts/try-equipo.sh`, with logic in |
| +`internal/tryequipo` and a small `cmd/equipo-try` entry point. No real sign-ins, |
| +provider turns, enrolment, release or deployment were run for this change. |
| +No other agents or copy-review server were used. |
| + |
| +## Changes |
| + |
| +V1 certificates use `certified_refresh: null` and `no_refresh_reason`. The Go |
| +verifier, installation eligibility and Python release check accept this form. |
| +Old refresh certificates grant no network authority. Egress rejects a named |
| +refresh host. Refresh assertions are removed from the live contract; generation |
| +and identity checks still run without a refresh host. |
| + |
| +Expired Claude expiry timestamps and Codex access-token expiry claims are |
| +checked in memory before staging or dispatch. An expired lease returns account |
| +maintenance. Connection reports retain that reason, the connection page says |
| +**Sign in again**, and a pinned unavailable account cannot fall back to another |
| +account. Failed attempts retain the same visible reason. |
| + |
| +The guide verifies pinned executable bytes and versions, user namespaces and |
| +Go. It creates dedicated homes, runs official browser sign-in with provider |
| +output suppressed, reads account status and asks for confirmation. It writes |
| +private identities, bindings, environment and bounded live configuration. It |
| +creates the disposable repository and sentinels, including the second Claude |
| +home. Setup state and write intentions allow interrupted configuration to resume; |
| +foreign edits and changed identities are refused. The runner state is not |
| +enrolled or enabled. |
| + |
| +The account-change exercise observes the second Claude account through the real |
| +adapter, then presents that account's staged login against the first account's |
| +expected identity in a disposable source. Preflight must return the second |
| +identity and refuse dispatch. Original dedicated sources remain untouched by |
| +this exercise. Existing generation and marker probes have durable private |
| +rollback files; the guide restores them after interruption. Namespace recovery |
| +requires a dead recorded controller and verified exit before removing records. |
| + |
| +Codex policies request raw catalog events and incremental tools. The live driver |
| +records the observed catalog before probing its tools, then compares the final |
| +catalog with the tested inventory. Missing, foreign or expanded catalogs fail |
| +closed. Resume requests omit the start-only `experimentalRawEvents` field, |
| +checked against the pinned schemas. Portable policy inventory hashes were |
| +updated without granting certification. |
| + |
| +## Verification |
| + |
| +The initial no-refresh acceptance test failed with “explicit no-refresh |
| +certificate rejected”, then passed after implementation. New expiry, catalog, |
| +setup and interruption tests were first run before their implementation and |
| +failed to compile on the missing functions/types. |
| + |
| +Compile-valid mutation checks were then run and restored: |
| + |
| +| Guard deliberately broken | Command | Observed result | |
| +| --- | --- | --- | |
| +| Reject every no-refresh certificate | `go test ./internal/release -run TestNoRefreshCertificate -count=1` | Acceptance assertion failed | |
| +| Allow refresh egress | `go test ./internal/runner/egress -run TestEgressPolicy -count=1` | Refresh rejection assertion failed | |
| +| Ignore token expiry | `go test ./internal/runner/provider -run TestExpired -count=1` | Expiry and dispatch assertions failed | |
| +| Ignore observed account mismatch | `go test ./internal/tryequipo -run TestAccountResumeAndMismatch -count=1` | Changed account accepted | |
| +| Accept a foreign catalog session | `go test ./internal/directlive -run TestSpecialistObservedCatalog -count=1` | Foreign catalog accepted | |
| +| Skip interrupted source restoration | `go test ./internal/directlive -run TestInterruptedSourceProbeRestores -count=1` | Original source not restored | |
| +| Allow foreign configuration replacement | `go test ./internal/tryequipo -run TestResumeInterruptedConfigurationWrite -count=1` | Foreign edit overwritten | |
| +| Hide the sign-in state | `go test ./internal/equipotest -run TestExpiredConnectionShowsSignInAgain -count=1` | HTTP page lacked Sign in again | |
| + |
| +Targeted tests cover both fake official login/status CLIs, interrupted account |
| +confirmation, private modes, interactive-home refusal, identity mismatch, |
| +configuration ownership, no-refresh packaging, expired dispatch and the rendered |
| +connection state. The fake driver exercised Claude account change and Codex |
| +inventory. Coordinator and Investigation failures found in the first package |
| +sweep were fixed and the targeted rerun passed. The first broad runner sweep |
| +was interrupted after a slow namespace wait; the isolated candidate-order test |
| +passed in 36.687 seconds. All builds and tests use `CGO_ENABLED=0`. |
| + |
| +The size gate passes with the existing ceilings. Repeated accepted-copy comments |
| +were consolidated under one dated acceptance note; pending entries remain |
| +individually marked. The connection test reuses existing assertion helpers. |
| + |
| +The first full CI attempt stopped at exact reference classifications. After |
| +updating those entries, the next full test run passed 23 packages and found two |
| +obsolete expectations: the exact documented environment path and acceptance of |
| +a refresh egress contract. Both were corrected. The final setup review also |
| +added failing tests for same-account re-sign-in and the recorded Codex startup |
| +notification arriving before the identity response. Both now pass; mismatched |
| +identities and unrecognized or uncorrelated responses still fail closed. |
| + |
| +The post-commit history scan initially flagged two synthetic expired-token |
| +fixture literals. The tests now construct the unsigned fixture in memory; no |
| +scan exemption was added. Expiry tests and the amended history scan passed. |
| + |
| +Full `make ci`: **PASS, exit 0**. Build, vet, formatting, staticcheck, |
| +govulncheck, gitleaks, unchanged size budgets, the full test suite, pinned adapter |
| +checks, namespace tests, migration checks and performance checks completed. |
| +The full test step took 5m1.339s. Cold boot had a 92ms median against 500ms; |
| +every measured GET stayed below 150ms. No reachable vulnerabilities or leaked |
| +secrets were reported. |
| + |
| +The final editable-defaults regression first failed with the saved mistyped |
| +path, then passed. After that small setup-only change, `go test |
| +./internal/tryequipo -count=1`, `go vet ./internal/tryequipo` and |
| +`go run honnef.co/go/tools/cmd/staticcheck@v0.7.0 ./internal/tryequipo` all passed. |
| +This lets a rerun correct saved values while detecting environment-supplied |
| +values without another question. |
| + |
| +## Remaining live evidence |
| + |
| +The real live gate has not run. Existing conservative guards for unobserved |
| +Claude hook settings, absence of a subscription currency cap and explicit FD |
| +alias denials remain in place. These were recorded in the Plan 2b report and |
| +were not changed into passing observations here. They can still block the |
| +candidate. The manifest retains its uncertified policies and copy-release gate. |
| +The controller must review actual captures and resolve those evidence limits |
| +before a versioned release can pass. The browser sign-in also needs a working |
| +browser opener on docs-t1; no sign-in URLs are printed as a fallback. |
| + |
| +## New strings |
| + |
| +Every new runtime string is individually marked pending in |
| +`internal/equipo/copy.go` and listed in the existing Plan 3 copy inventory, which |
| +the repository's inventory test checks. The new guide is `docs/live-gate.md`. |
| +The shell's Go-missing fallback is `Missing prerequisite: Go`. |
| + |
| +- `connections.empty`: Connections are not available yet. |
| + |
| +- `account.sign_in_again`: Sign in again |
| + |
| +- `prerequisite`: Missing prerequisite: %s / |
| + |
| +- `prompt`: %s [%s]: |
| + |
| +- `confirm`: Observed account for %s: %s. Confirm this account? [yes/no]: |
| + |
| +- `login`: Signing in to %s in its dedicated home. Complete the official browser flow. Provider output is hidden to keep sign-in links and tokens private. / |
| + |
| +- `failed`: Stopped at %s. Saved setup can be resumed by running scripts/try-equipo.sh again. No release was made. / |
| + |
| +- `ready`: Manifest candidate: %s / After reviewing and importing the evidence bundle and candidate manifest, the controller releases with: / %s / |
| + |
| +- `live`: Type RUN LIVE GATE to authorize the displayed limits and disposable exercises |
| + |
| +- `signin`: Type SIGN IN to start official sign-ins in dedicated homes |
| + |
| +- `instance`: Instance ID from Equipo |
| + |
| +- `person`: Your Equipo person ID |
| + |
| +- `claude-model`: Exact Claude model |
| + |
| +- `codex-model`: Exact Codex model |
| + |
| +- `forge`: Absolute path to the runner's Amadan credential file |
| + |
| +- `Calls`: Maximum calibration calls |
| + |
| +- `InputTokens`: Maximum calibration input tokens |
| + |
| +- `OutputTokens`: Maximum calibration output tokens |
| + |
| +- `Seconds`: Maximum calibration seconds |
| + |
| +- `JobInput`: Job input token funding |
| + |
| +- `JobOutput`: Job output token funding |
| + |
| +- `ProjectInputHeadroom`: Remaining project input tokens |
| + |
| +- `ProjectOutputHeadroom`: Remaining project output tokens |
| + |
| +- `TeamInputHeadroom`: Remaining team input tokens |
| + |
| +- `TeamOutputHeadroom`: Remaining team output tokens |
| + |
| +- `limits`: Authorized limits: %s / |
diff --git a/internal/directlive/account_change.go b/internal/directlive/account_change.go| new file mode 100644 |
| index 00000000..a9673781 |
| --- /dev/null |
| +++ b/internal/directlive/account_change.go |
| @@ -0,0 +1,114 @@ |
| +package directlive |
| + |
| +import ( |
| + "context" |
| + "errors" |
| + "fmt" |
| + "os" |
| + "path/filepath" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/provider/claude" |
| +) |
| + |
| +// The trial uses the two confirmed accounts through private runtime copies. |
| +// Neither dedicated credential source is replaced, even if the process dies. |
| +func (x *exercise) accountChange(ctx context.Context) (err error) { |
| + stage := "second-open" |
| + defer func() { |
| + if err != nil { |
| + err = fmt.Errorf("%s: %w", stage, err) |
| + } |
| + }() |
| + other := x.d.cfg.AccountChange |
| + if other == nil { |
| + return x.check("changed-identity-stops-step", false, map[string]bool{"second_account_observed": false}) |
| + } |
| + if other.Provider != "claude" || other.AccountID == x.launch.Binding.AccountID { |
| + return provider.ErrIdentity |
| + } |
| + b := *other |
| + b.RuntimeRoot = filepath.Join(x.d.policyPaths.ScratchRoot, "homes") |
| + second, err := provider.OpenAccount(ctx, b) |
| + if err != nil { |
| + return err |
| + } |
| + defer second.Close() |
| + stage = "second-inputs" |
| + in := x.inputs |
| + profile, err := provider.Profile(in.Action) |
| + if err != nil { |
| + return err |
| + } |
| + role := profile.Specialist |
| + if x.evidence.Specialist == "Product" { |
| + role = "Product" |
| + } |
| + in.Tools = profile.MCPTools() |
| + in.Scratch, err = os.MkdirTemp(x.d.policyPaths.ScratchRoot, "change-policy-") |
| + if err != nil { |
| + return err |
| + } |
| + defer os.RemoveAll(in.Scratch) |
| + in, err = claude.PolicyInputs(second.Binding(), in, role, x.evidence.Model) |
| + if err != nil { |
| + return err |
| + } |
| + stage = "second-policy" |
| + p, err := provider.BuildPolicy(second.Binding(), in) |
| + if err != nil { |
| + return err |
| + } |
| + stage = "second-preflight" |
| + observed, err := x.launcher.Preflight(ctx, second.Binding(), p) |
| + if err != nil || observed.AccountID != other.AccountID { |
| + return provider.ErrIdentity |
| + } |
| + stage = "trial-source" |
| + trial, err := os.MkdirTemp(x.d.policyPaths.ScratchRoot, "change-source-") |
| + if err != nil { |
| + return err |
| + } |
| + defer os.RemoveAll(trial) |
| + // Only provider-produced, sanitized runtime metadata and login bytes enter |
| + // this disposable source. They are never written to the evidence bundle. |
| + for _, name := range []string{".credentials.json", ".claude.json"} { |
| + raw, e := os.ReadFile(filepath.Join(second.Binding().Home, name)) |
| + if e != nil { |
| + return e |
| + } |
| + if e = os.WriteFile(filepath.Join(trial, name), raw, 0600); e != nil { |
| + return e |
| + } |
| + } |
| + if err = os.WriteFile(filepath.Join(trial, provider.IdentityFile), marshal(x.launch.Binding.Expected), 0600); err != nil { |
| + return err |
| + } |
| + first := provider.Binding{ID: x.launch.Binding.ID, Provider: "claude", AccountID: x.launch.Binding.AccountID, Expected: x.launch.Binding.Expected, Home: trial, RuntimeRoot: b.RuntimeRoot} |
| + stage = "trial-open" |
| + lease, err := provider.OpenAccount(ctx, first) |
| + if err != nil { |
| + return err |
| + } |
| + defer lease.Close() |
| + in.Scratch, err = os.MkdirTemp(x.d.policyPaths.ScratchRoot, "change-policy-") |
| + if err != nil { |
| + return err |
| + } |
| + defer os.RemoveAll(in.Scratch) |
| + stage = "trial-inputs" |
| + in.Tools = profile.MCPTools() |
| + in, err = claude.PolicyInputs(lease.Binding(), in, role, x.evidence.Model) |
| + if err != nil { |
| + return err |
| + } |
| + stage = "trial-policy" |
| + p, err = provider.BuildPolicy(lease.Binding(), in) |
| + if err != nil { |
| + return err |
| + } |
| + stage = "trial-preflight" |
| + changed, rejected := x.launcher.Preflight(ctx, lease.Binding(), p) |
| + stopped := errors.Is(rejected, provider.ErrIdentity) && changed.AccountID == other.AccountID && lease.BeginTurn(ctx) != nil |
| + return x.check("changed-identity-stops-step", stopped, map[string]any{"selected": first.AccountID, "observed": changed.AccountID, "second_account": observed.AccountID, "rejected_before_dispatch": stopped}) |
| +} |
diff --git a/internal/directlive/certificate.go b/internal/directlive/certificate.go| index 13e59d50..be2d22b9 100644 |
| --- a/internal/directlive/certificate.go |
| +++ b/internal/directlive/certificate.go |
| @@ -9,8 +9,7 @@ import ( |
| "path/filepath" |
| ) |
| -// ManifestCandidate only derives refresh authority from complete passing |
| -// evidence. It writes beside the bundle, leaving the release source untouched. |
| +// ManifestCandidate accepts complete passing evidence without refresh authority. It writes beside the bundle, leaving the release source untouched. |
| func ManifestCandidate(root string) error { |
| raw, err := os.ReadFile(filepath.Join(root, "index.json")) |
| if err != nil { |
| @@ -55,7 +54,7 @@ func ManifestCandidate(root string) error { |
| } |
| seen[key] = true |
| digest := provider.DigestDirectEvidence(raw) |
| - c := release.PolicyCertificate{Provider: e.Provider, ProviderVersion: e.ProviderVersion, LauncherVersion: e.LauncherVersion, BwrapVersion: e.BwrapVersion, PolicyHash: e.PolicyHash, CertifiedRefresh: release.CertifiedRefresh{AuthHost: e.AuthHost, EvidenceSHA256: digest}} |
| + c := release.PolicyCertificate{Provider: e.Provider, ProviderVersion: e.ProviderVersion, LauncherVersion: e.LauncherVersion, BwrapVersion: e.BwrapVersion, PolicyHash: e.PolicyHash, NoRefreshReason: "v1 requires sign-in again"} |
| m.DirectPolicies = append(m.DirectPolicies, c) |
| destination := filepath.Join("internal/release/evidence", provider.DigestDirectEvidence([]byte(e.RunID))[:16], name) |
| m.Certifications = append(m.Certifications, release.Certification{Provider: e.Provider, PolicyHash: e.PolicyHash, Path: destination, SHA256: digest}) |
diff --git a/internal/directlive/cleanup.go b/internal/directlive/cleanup.go| index 552360de..b4ea665b 100644 |
| --- a/internal/directlive/cleanup.go |
| +++ b/internal/directlive/cleanup.go |
| @@ -5,6 +5,7 @@ import ( |
| "amadan.net/oficina/equipo/internal/runner/provider" |
| "context" |
| "errors" |
| + "golang.org/x/sys/unix" |
| "os" |
| "path/filepath" |
| ) |
| @@ -38,3 +39,29 @@ func retireRecord(root string, p containment.Proof) error { |
| } |
| return nil |
| } |
| + |
| +// ResumeInterrupted retires only namespaces whose recorded controller is gone. |
| +// An active controller or an uncertain exit leaves its files untouched. |
| +func ResumeInterrupted(ctx context.Context, paths Paths, scratch string) error { |
| + m, err := containment.New(containment.Config{Binary: paths.Bwrap, RunnerBinary: paths.Runner, ScratchRoot: scratch, ProviderNetworks: []provider.NetworkContract{{Provider: "claude"}, {Provider: "codex"}}}) |
| + if err != nil { |
| + return err |
| + } |
| + records, err := m.Records(ctx) |
| + if err != nil { |
| + return err |
| + } |
| + for _, r := range records { |
| + if r.ParentPID <= 0 || unix.Kill(r.ParentPID, 0) != unix.ESRCH { |
| + return provider.ErrAccountBusy |
| + } |
| + proof, err := m.Recover(ctx, r) |
| + if err != nil || !proof.Verified { |
| + return provider.ErrContainment |
| + } |
| + if err = retireRecord(scratch, proof); err != nil { |
| + return err |
| + } |
| + } |
| + return nil |
| +} |
diff --git a/internal/directlive/codex_inventory.go b/internal/directlive/codex_inventory.go| new file mode 100644 |
| index 00000000..131cd0fc |
| --- /dev/null |
| +++ b/internal/directlive/codex_inventory.go |
| @@ -0,0 +1,44 @@ |
| +package directlive |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "encoding/json" |
| + "slices" |
| +) |
| + |
| +// Read the pinned CLI's raw catalog, never a model-authored tool list. |
| +func codexInventory(session string, frames []json.RawMessage) ([]string, error) { |
| + var names []string |
| + for _, raw := range frames { |
| + var v struct { |
| + Method string |
| + Params struct { |
| + ThreadID string `json:"threadId"` |
| + Item struct { |
| + Type, Role string |
| + Tools []json.RawMessage |
| + } |
| + } |
| + } |
| + if json.Unmarshal(raw, &v) != nil { |
| + return nil, provider.ErrPolicy |
| + } |
| + if v.Method != "rawResponseItem/completed" || v.Params.Item.Type != "additional_tools" { |
| + continue |
| + } |
| + if v.Params.ThreadID != session || v.Params.Item.Role != "developer" { |
| + return nil, provider.ErrPolicy |
| + } |
| + got, ok := coordinatorCatalogNames(v.Params.Item.Tools) |
| + if !ok { |
| + return nil, provider.ErrPolicy |
| + } |
| + names = append(names, got...) |
| + } |
| + slices.Sort(names) |
| + names = slices.Compact(names) |
| + if len(names) == 0 { |
| + return nil, provider.ErrPolicy |
| + } |
| + return names, nil |
| +} |
diff --git a/internal/directlive/coordinator_certificate_test.go b/internal/directlive/coordinator_certificate_test.go| index c8959df2..22224f97 100644 |
| --- a/internal/directlive/coordinator_certificate_test.go |
| +++ b/internal/directlive/coordinator_certificate_test.go |
| @@ -18,7 +18,7 @@ func TestCoordinatorManifestExclusion(t *testing.T) { |
| raw := []byte("synthetic manifest-selection fixture") |
| hash := provider.DigestDirectEvidence(raw) |
| observation := provider.LiveObservation{Status: "pass", Artifact: "capture.json", SHA256: hash, Detail: "synthetic unit-test fixture"} |
| - e := provider.DirectEvidence{Schema: 1, Source: "direct-live", RunID: "fixture", Provider: "codex", ProviderVersion: "0.165.0", LauncherVersion: provider.LauncherVersion, BwrapVersion: "0.11.0", PolicyVersion: provider.PolicyVersion, PolicyHash: strings.Repeat("a", 64), AccountID: "fixture", HomeID: "fixture", Model: "fixture", Specialist: "Engineering", AuthHost: "auth.example.com", ConfigSHA256: hash, Artifacts: map[string]string{"capture.json": hash}, Checks: map[string]provider.LiveObservation{}, Binaries: map[string]string{}, Usage: []provider.LiveUsage{{Input: 1, Output: 1, Complete: true}}, Funding: provider.LiveFunding{Calls: 1, Seconds: 60, InputTokens: 1000, OutputTokens: 1000, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}, CodexPolicy: &provider.LiveCodexPolicy{ApprovalPolicy: "on-request", ApprovalsReviewer: "user", StrictConfig: true, DenyProfile: true}} |
| + e := provider.DirectEvidence{Schema: 1, Source: "direct-live", RunID: "fixture", Provider: "codex", ProviderVersion: "0.165.0", LauncherVersion: provider.LauncherVersion, BwrapVersion: "0.11.0", PolicyVersion: provider.PolicyVersion, PolicyHash: strings.Repeat("a", 64), AccountID: "fixture", HomeID: "fixture", Model: "fixture", Specialist: "Engineering", AuthHost: "", ConfigSHA256: hash, Artifacts: map[string]string{"capture.json": hash}, Checks: map[string]provider.LiveObservation{}, Binaries: map[string]string{}, Usage: []provider.LiveUsage{{Input: 1, Output: 1, Complete: true}}, Funding: provider.LiveFunding{Calls: 1, Seconds: 60, InputTokens: 1000, OutputTokens: 1000, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}, CodexPolicy: &provider.LiveCodexPolicy{ApprovalPolicy: "on-request", ApprovalsReviewer: "user", StrictConfig: true, DenyProfile: true}} |
| for _, name := range []string{"claude", "codex", "codex-code-mode-host", "bwrap", "runner", "equipo-tool-proxy"} { |
| e.Binaries[name] = hash |
| } |
diff --git a/internal/directlive/driver.go b/internal/directlive/driver.go| index b90b4e16..1008df54 100644 |
| --- a/internal/directlive/driver.go |
| +++ b/internal/directlive/driver.go |
| @@ -166,6 +166,7 @@ func (p Paths) verify() (map[string]string, error) { |
| func marshal(v any) []byte { raw, _ := json.Marshal(v); return raw } |
| type exercise struct { |
| + inputs provider.PolicyInputs |
| mu sync.Mutex |
| answers map[string]int |
| questions int |
| @@ -274,6 +275,7 @@ func (d *driver) exercise(ctx context.Context, b provider.DirectLiveBinding, rol |
| if err != nil { |
| return e, err |
| } |
| + x.inputs = in |
| phase = "policy" |
| policy, err := provider.BuildPolicy(binding, in) |
| if err != nil { |
| @@ -322,22 +324,30 @@ func (d *driver) exercise(ctx context.Context, b provider.DirectLiveBinding, rol |
| if err = x.controls(ctx); err != nil { |
| return e, err |
| } |
| - if err = x.inventory(ctx); err != nil { |
| - return e, err |
| - } |
| phase = "resume" |
| if err = x.cleanResume(ctx, tool); err != nil { |
| return e, err |
| } |
| + phase = "generation" |
| if err = x.generation(ctx); err != nil { |
| return e, err |
| } |
| + phase = "lifetime" |
| if err = x.lifetime(ctx); err != nil { |
| return e, err |
| } |
| if err = x.calibration(); err != nil { |
| return e, err |
| } |
| + if err = x.inventory(ctx); err != nil { |
| + return e, err |
| + } |
| + phase = "account-change" |
| + if binding.Provider == "claude" { |
| + if err = x.accountChange(ctx); err != nil { |
| + return e, err |
| + } |
| + } |
| if err = x.changedIdentity(ctx); err != nil { |
| return e, err |
| } |
diff --git a/internal/directlive/driver_test.go b/internal/directlive/driver_test.go| index fa2bfff5..0872fab6 100644 |
| --- a/internal/directlive/driver_test.go |
| +++ b/internal/directlive/driver_test.go |
| @@ -80,9 +80,24 @@ func TestDirectDriverFakeWorker(t *testing.T) { |
| t.Fatal(err) |
| } |
| } |
| - c.Bindings = append(c.Bindings, provider.DirectLiveBinding{Binding: provider.Binding{ID: name, Home: home, AccountID: id.AccountID, Provider: name, Expected: id}, Model: "fixture-model", AuthHost: "refresh.fixture.invalid", ClaudeTOFUConfirmed: name == "claude"}) |
| + c.Bindings = append(c.Bindings, provider.DirectLiveBinding{Binding: provider.Binding{ID: name, Home: home, AccountID: id.AccountID, Provider: name, Expected: id}, Model: "fixture-model", AuthHost: "", ClaudeTOFUConfirmed: name == "claude"}) |
| c.Sentinels[name] = filepath.Join(home, "sentinel") |
| } |
| + second := c.Bindings[0].Binding |
| + second.ID = "claude-second" |
| + second.AccountID = "second@example.invalid" |
| + second.Expected.AccountID = second.AccountID |
| + second.Expected.HomeID = "second-home" |
| + second.Home = filepath.Join(root, "claude-second") |
| + if err := os.Mkdir(second.Home, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + for file, raw := range map[string][]byte{provider.IdentityFile: marshal(second.Expected), ".credentials.json": []byte(`{"fixture":true}`), ".claude.json": []byte(`{"oauthAccount":{"emailAddress":"second@example.invalid"}}`)} { |
| + if err := os.WriteFile(filepath.Join(second.Home, file), raw, 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + c.AccountChange = &second |
| for _, name := range []string{"repo", "other", "state"} { |
| c.Sentinels[name] = filepath.Join(root, name, "sentinel") |
| } |
| @@ -206,7 +221,7 @@ func TestDirectDriverFakeWorker(t *testing.T) { |
| if e.Checks["tuple-completed"].Status == "not-certified" || e.Checks["complete-input-output"].Status != "pass" { |
| t.Fatal("specialist contaminated by coordinator", name) |
| } |
| - for _, check := range []string{"person-native-approval", "real-question-answer", "policy-escalation-denied", "equipo-broker-approval", "stale-broker-denied", "invalid-broker-denied", "clean-session-resume", "mid-turn-runner-kill", "durable-replay", "no-redispatch", "unknown-usage-retained", "pidfd-exit", "same-identity-generation-fresh-preflight-bind", "same-identity-continued-availability", "identity-marker-tamper-denied"} { |
| + for _, check := range []string{"person-native-approval", "real-question-answer", "policy-escalation-denied", "equipo-broker-approval", "stale-broker-denied", "invalid-broker-denied", "clean-session-resume", "mid-turn-runner-kill", "durable-replay", "no-redispatch", "unknown-usage-retained", "pidfd-exit", "same-identity-generation-fresh-preflight-bind", "same-identity-continued-availability", "identity-marker-tamper-denied", "changed-identity-stops-step", "exact-tool-inventory", "tool-inventory-complete"} { |
| if e.Checks[check].Status != "pass" { |
| t.Fatalf("%s did not exercise %s: %+v", name, check, e.Checks[check]) |
| } |
diff --git a/internal/directlive/generation.go b/internal/directlive/generation.go| index 66db775c..a94162e3 100644 |
| --- a/internal/directlive/generation.go |
| +++ b/internal/directlive/generation.go |
| @@ -10,9 +10,6 @@ import ( |
| ) |
| func (x *exercise) generation(ctx context.Context) error { |
| - if x.evidence.AuthHost == "" { |
| - return nil |
| - } |
| name := map[string]string{"claude": ".credentials.json", "codex": "auth.json"}[x.evidence.Provider] |
| return withStagedSource(filepath.Join(x.launch.Binding.CredentialHome, name), func(raw []byte) ([]byte, error) { |
| if !json.Valid(raw) { |
| @@ -37,9 +34,6 @@ func (x *exercise) generation(ctx context.Context) error { |
| }) |
| } |
| func (x *exercise) changedIdentity(ctx context.Context) error { |
| - if x.evidence.AuthHost == "" { |
| - return nil |
| - } |
| if err := x.d.reserveRecovery(); err != nil { |
| return err |
| } |
| @@ -57,6 +51,11 @@ func (x *exercise) changedIdentity(ctx context.Context) error { |
| if rejected == nil { |
| _ = x.launcher.Interrupt(ctx, x.session) |
| } |
| + if x.evidence.Provider == "codex" { |
| + if err := x.check("changed-identity-stops-step", stopped, map[string]bool{"rejected_before_dispatch": stopped}); err != nil { |
| + return err |
| + } |
| + } |
| return x.check("identity-marker-tamper-denied", stopped, map[string]any{"expected": x.launch.Binding.Expected, "rejected_before_dispatch": stopped}) |
| }) |
| } |
diff --git a/internal/directlive/inventory.go b/internal/directlive/inventory.go| index b919baa7..e6889664 100644 |
| --- a/internal/directlive/inventory.go |
| +++ b/internal/directlive/inventory.go |
| @@ -49,6 +49,10 @@ func (x *exercise) inventory(ctx context.Context) error { |
| } |
| } |
| } |
| + if x.evidence.Provider == "codex" { |
| + names, err := codexInventory(x.session.ID, frames) |
| + observed = err == nil && slices.Equal(names, expected) |
| + } |
| for name, ok := range map[string]bool{"exact-tool-inventory": observed, "tool-inventory-complete": observed && tested, "missing-tools-recorded": missingRecorded, "mcp-authority": x.brokerApprovals > 0 && x.staleDenied && x.invalidDenied} { |
| if err = x.check(name, ok, map[string]any{"expected": expected, "captured": frames, "tested": tested}); err != nil { |
| return err |
diff --git a/internal/directlive/observations.go b/internal/directlive/observations.go| index bd6caa1a..a0e5196b 100644 |
| --- a/internal/directlive/observations.go |
| +++ b/internal/directlive/observations.go |
| @@ -52,7 +52,7 @@ func observedRead(name string, frames [][]byte, tool, path string, denied bool) |
| continue |
| } |
| b := v.Params.Item |
| - if v.Method == "item/started" && (b.Tool == tool || b.Type == tool) && ((b.Type == "commandExecution" && b.Command == shellRead(path)) || (b.Type != "commandExecution" && readInput(tool, b.Arguments, path))) { |
| + if v.Method == "item/started" && (b.Tool == tool || b.Type == tool || shellTool(tool) && b.Type == "commandExecution") && ((b.Type == "commandExecution" && b.Command == shellRead(path)) || (b.Type != "commandExecution" && readInput(tool, b.Arguments, path))) { |
| calls[b.ID] = true |
| } |
| if v.Method != "item/completed" || !calls[b.ID] { |
| @@ -89,8 +89,12 @@ func readInput(tool string, raw json.RawMessage, path string) bool { |
| if json.Unmarshal(raw, &input) != nil { |
| return false |
| } |
| - if tool == "Bash" || tool == "commandExecution" { |
| + if shellTool(tool) { |
| return input.Command == shellRead(path) |
| } |
| return input.Path == path || input.FilePath == path |
| } |
| + |
| +func shellTool(tool string) bool { |
| + return tool == "Bash" || tool == "commandExecution" || tool == "exec_command" || tool == "shell_command" |
| +} |
diff --git a/internal/directlive/probes.go b/internal/directlive/probes.go| index 662832ed..7f2d72f9 100644 |
| --- a/internal/directlive/probes.go |
| +++ b/internal/directlive/probes.go |
| @@ -7,6 +7,7 @@ import ( |
| "fmt" |
| "os" |
| "path/filepath" |
| + "slices" |
| "sort" |
| "strings" |
| ) |
| @@ -27,6 +28,9 @@ func (x *exercise) probes(ctx context.Context, inventory []string) error { |
| // absent from its namespace. Both paths are independently probed. |
| targets["source-home"] = x.d.cfg.Sentinels[x.evidence.Provider] |
| targets["other-host-home"] = x.d.cfg.Sentinels["other"] |
| + if path := x.d.cfg.Sentinels["claude-other"]; path != "" { |
| + targets["other-account-home"] = path |
| + } |
| alias := filepath.Join(x.d.cfg.Repository, "equipo-sentinel-alias") |
| if err := os.Symlink("/home/runner", alias); err != nil { |
| return err |
| @@ -46,14 +50,27 @@ func (x *exercise) probes(ctx context.Context, inventory []string) error { |
| } |
| sort.Strings(keys) |
| if x.evidence.Provider == "codex" { |
| - inventory = append([]string{"commandExecution", "read_file", "search", "view_image"}, inventory...) |
| + if _, err := x.turn(ctx, "Record the available tool catalog. Reply ready without reading files."); err != nil { |
| + return err |
| + } |
| + frames, err := x.journal.CaptureEvidence(ctx) |
| + if err != nil { |
| + return err |
| + } |
| + inventory, err = codexInventory(x.session.ID, frames) |
| + if err != nil { |
| + return err |
| + } |
| + if err = save(x.root, "codex-tool-inventory.json", map[string]any{"version": x.evidence.ProviderVersion, "tools": inventory, "frames": frames}); err != nil { |
| + return err |
| + } |
| } |
| for _, tool := range inventory { |
| surface := "native" |
| switch { |
| - case tool == "Bash" || tool == "commandExecution": |
| + case tool == "Bash" || tool == "commandExecution" || tool == "exec_command" || tool == "shell_command": |
| surface = "shell" |
| - case tool == "Glob" || tool == "Grep" || tool == "search": |
| + case tool == "Glob" || tool == "Grep" || tool == "search" || tool == "web_search": |
| surface = "search" |
| case tool == "view_image": |
| surface = "image" |
| @@ -97,9 +114,21 @@ func (x *exercise) probes(ctx context.Context, inventory []string) error { |
| tool := "Read" |
| if x.evidence.Provider == "codex" { |
| tool = "read_file" |
| + if !slices.Contains(inventory, tool) { |
| + for _, candidate := range []string{"exec_command", "shell_command", "commandExecution"} { |
| + if slices.Contains(inventory, candidate) { |
| + tool = candidate |
| + break |
| + } |
| + } |
| + } |
| } |
| path := "/workspace/" + filepath.Base(x.d.cfg.Sentinels["repo"]) |
| - frames, err := x.turn(ctx, fmt.Sprintf("Use %s to read %s. This is the disposable workspace positive control.", tool, path)) |
| + prompt := fmt.Sprintf("Use %s to read %s. This is the disposable workspace positive control.", tool, path) |
| + if shellTool(tool) { |
| + prompt += " Run this exact command without additions: " + shellRead(path) |
| + } |
| + frames, err := x.turn(ctx, prompt) |
| if err != nil { |
| return err |
| } |
diff --git a/internal/directlive/staged_resume_test.go b/internal/directlive/staged_resume_test.go| new file mode 100644 |
| index 00000000..b6f9f41c |
| --- /dev/null |
| +++ b/internal/directlive/staged_resume_test.go |
| @@ -0,0 +1,28 @@ |
| +package directlive |
| + |
| +import ( |
| + "os" |
| + "path/filepath" |
| + "testing" |
| +) |
| + |
| +func TestInterruptedSourceProbeRestores(t *testing.T) { |
| + home := t.TempDir() |
| + path := filepath.Join(home, "equipo-identity.json") |
| + if err := os.WriteFile(path, []byte("changed"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(filepath.Join(home, ".equipo-live-original-equipo-identity.json"), []byte("original"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := RestoreStagedSources(home); err != nil { |
| + t.Fatal(err) |
| + } |
| + raw, err := os.ReadFile(path) |
| + if err != nil || string(raw) != "original" { |
| + t.Fatal("source not restored", err) |
| + } |
| + if err := RestoreStagedSources(home); err != nil { |
| + t.Fatal("resume not idempotent", err) |
| + } |
| +} |
diff --git a/internal/directlive/staged_source.go b/internal/directlive/staged_source.go| index b0071569..832a3578 100644 |
| --- a/internal/directlive/staged_source.go |
| +++ b/internal/directlive/staged_source.go |
| @@ -29,7 +29,30 @@ func withStagedSource(path string, change func([]byte) ([]byte, error), probe fu |
| if err != nil { |
| return err |
| } |
| - defer func() { err = errors.Join(err, replaceStaged(path, before)) }() |
| + backup := filepath.Join(filepath.Dir(path), ".equipo-live-original-"+filepath.Base(path)) |
| + original, err := os.OpenFile(backup, os.O_CREATE|os.O_EXCL|os.O_WRONLY, 0600) |
| + if err != nil { |
| + return err |
| + } |
| + _, err = original.Write(before) |
| + if err == nil { |
| + err = original.Sync() |
| + } |
| + err = errors.Join(err, original.Close()) |
| + if err != nil { |
| + _ = os.Remove(backup) |
| + return err |
| + } |
| + dir, err := os.Open(filepath.Dir(path)) |
| + if err != nil { |
| + return err |
| + } |
| + err = dir.Sync() |
| + dir.Close() |
| + if err != nil { |
| + return err |
| + } |
| + defer func() { err = errors.Join(err, restoreStaged(path)) }() |
| if err = replaceStaged(path, after); err != nil { |
| return err |
| } |
| @@ -60,3 +83,46 @@ func replaceStaged(path string, raw []byte) error { |
| defer dir.Close() |
| return dir.Sync() |
| } |
| + |
| +// RestoreStagedSources rolls back an interrupted certification mutation before |
| +// the next official identity probe. Backups stay private in their source home. |
| +func RestoreStagedSources(home string) error { |
| + for _, name := range []string{provider.IdentityFile, ".credentials.json", "auth.json"} { |
| + if err := restoreStaged(filepath.Join(home, name)); err != nil { |
| + return err |
| + } |
| + } |
| + return nil |
| +} |
| +func restoreStaged(path string) error { |
| + backup := filepath.Join(filepath.Dir(path), ".equipo-live-original-"+filepath.Base(path)) |
| + fd, err := unix.Openat2(unix.AT_FDCWD, backup, &unix.OpenHow{Flags: unix.O_RDONLY | unix.O_CLOEXEC, Resolve: unix.RESOLVE_NO_SYMLINKS | unix.RESOLVE_NO_MAGICLINKS}) |
| + if err == unix.ENOENT { |
| + return nil |
| + } |
| + if err != nil { |
| + return err |
| + } |
| + f := os.NewFile(uintptr(fd), backup) |
| + defer f.Close() |
| + var st unix.Stat_t |
| + if unix.Fstat(fd, &st) != nil || st.Mode&unix.S_IFMT != unix.S_IFREG || st.Mode&0777 != 0600 || st.Nlink != 1 || st.Uid != uint32(os.Getuid()) { |
| + return provider.ErrPolicy |
| + } |
| + raw, err := io.ReadAll(io.LimitReader(f, 1<<20+1)) |
| + if err != nil || len(raw) > 1<<20 { |
| + return provider.ErrPolicy |
| + } |
| + if err = replaceStaged(path, raw); err != nil { |
| + return err |
| + } |
| + if err = os.Remove(backup); err != nil { |
| + return err |
| + } |
| + d, err := os.Open(filepath.Dir(path)) |
| + if err != nil { |
| + return err |
| + } |
| + defer d.Close() |
| + return d.Sync() |
| +} |
diff --git a/internal/directlive/testdata/fake-cli.py b/internal/directlive/testdata/fake-cli.py| index 32a9910e..1f05f1ca 100644 |
| --- a/internal/directlive/testdata/fake-cli.py |
| +++ b/internal/directlive/testdata/fake-cli.py |
| @@ -26,7 +26,9 @@ def recorded_config(config): |
| def emit(v): |
| print(json.dumps(v),flush=True) |
| if family=='claude' and 'auth' in sys.argv: |
| - emit({'loggedIn':True,'authMethod':'claude.ai','email':'fixture@example.invalid'}) |
| + home=os.environ['CLAUDE_CONFIG_DIR'] |
| + metadata=json.load(open(home+'/.claude.json')) if os.path.exists(home+'/.claude.json') else {} |
| + emit({'loggedIn':True,'authMethod':'claude.ai','email':metadata.get('oauthAccount',{}).get('emailAddress','fixture@example.invalid')}) |
| sys.exit(0) |
| config=json.load(open('/config/equipo-settings.json')) |
| def helper(method,params): |
| @@ -52,7 +54,7 @@ for line in sys.stdin: |
| elif method=='config/read': |
| result=recorded_config(config) |
| elif method in ['thread/start','thread/resume']: |
| - raw_events=req['params'].get('experimentalRawEvents',False) |
| + raw_events=req['params'].get('experimentalRawEvents',config.get('features',{}).get('incremental_tools',False)) |
| result={'thread':{'id':'thread-fixture'},'model':'fixture-model','modelProvider':'openai','cwd':'/workspace','approvalPolicy':'on-request','approvalsReviewer':'user','activePermissionProfile':{'id':'equipo','extends':None},'runtimeWorkspaceRoots':['/workspace']} |
| elif method=='turn/start': |
| turn+=1 |
| @@ -67,7 +69,8 @@ for line in sys.stdin: |
| if 'mcp__equipo__read_project' in names: |
| names+=['list_mcp_resources','list_mcp_resource_templates','read_mcp_resource'] |
| if not raw_events or not config.get('features',{}).get('incremental_tools'):raise RuntimeError('missing observed catalog configuration') |
| - emit({'method':'rawResponseItem/completed','params':{'threadId':session,'turnId':str(turn),'item':{'type':'additional_tools','role':'developer','tools':[{'type':'function','name':n,'parameters':{'type':'object'}} for n in names]}}}) |
| + else:names+=['commandExecution','read_file','search','view_image'] |
| + emit({'method':'rawResponseItem/completed','params':{'threadId':session,'turnId':str(turn),'item':{'type':'additional_tools','role':'developer','tools':[{'type':'function','name':n,'parameters':{'type':'object'}} for n in names]}}}) |
| else: |
| turn+=1 |
| session=req['session_id'] |
diff --git a/internal/directlive/try_inventory_test.go b/internal/directlive/try_inventory_test.go| new file mode 100644 |
| index 00000000..1f9623c8 |
| --- /dev/null |
| +++ b/internal/directlive/try_inventory_test.go |
| @@ -0,0 +1,20 @@ |
| +package directlive |
| + |
| +import ( |
| + "encoding/json" |
| + "testing" |
| +) |
| + |
| +func TestSpecialistObservedCatalog(t *testing.T) { |
| + raw := json.RawMessage(`{"method":"rawResponseItem/completed","params":{"threadId":"session","item":{"type":"additional_tools","role":"developer","tools":[{"type":"function","name":"exec_command"},{"type":"function","name":"view_image"}]}}}`) |
| + names, err := codexInventory("session", []json.RawMessage{raw}) |
| + if err != nil || len(names) != 2 { |
| + t.Fatal(names, err) |
| + } |
| + if _, err = codexInventory("other", []json.RawMessage{raw}); err == nil { |
| + t.Fatal("foreign catalog accepted") |
| + } |
| + if _, err = codexInventory("session", nil); err == nil { |
| + t.Fatal("missing catalog accepted") |
| + } |
| +} |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index 2f6d194f..64c4552b 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -9,8 +9,8 @@ import ( |
| // COPY APPROVED BY DELEGATION (Luna pass, 2026-11-01, house rules). |
| // App-owned runtime strings belong here, including boot diagnostics. |
| +// Existing copy accepted for now by Paul, 2026-11-04; new entries stay marked pending. |
| const ( |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| copyObserverFailure = "The live update could not be sent. The change was saved." |
| copyDecisionOwnerAssigned = "Reassign this person's project decisions before removing them." |
| copyBindingInUse = "Another project uses this repository and app. Choose a different pair." |
| @@ -20,9 +20,7 @@ const ( |
| copyMissingStage = "The sign-in layout is missing. Check the Rastrillo installation." |
| copyInvalidRoot = "The app handler is missing. Configure the Equipo app before serving." |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - copyRunnerPending = "Waiting for you to approve this machine in your browser." |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + copyRunnerPending = "Waiting for you to approve this machine in your browser." |
| copyRunnerRateLimited = "Too many attempts. Wait before trying again." |
| copyBrand = "Equipo" |
| @@ -48,122 +46,65 @@ const BootLog = "Equipo could not start." |
| // COPY APPROVED BY DELEGATION (Luna pass, 2026-11-01, house rules). |
| var pageCopy = map[string]string{ |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): notifications.question |
| - "notifications.question": "A question needs your answer.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): notifications.task_ready |
| - "notifications.task_ready": "A task is ready for you to review.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): notifications.interrupted |
| - "notifications.interrupted": "Work stopped and needs your attention.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): notifications.superseded |
| - "notifications.superseded": "This item has changed. Fetch its current state.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): notifications.subscribe |
| - "notifications.subscribe": "Receive notifications on this device", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): notifications.unsubscribe |
| - "notifications.unsubscribe": "Stop notifications on this device", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): notifications.cursor_expired |
| - "notifications.cursor_expired": "This notification cursor expired. Fetch notifications without a cursor and check Needs you for open questions.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): notifications.subscription_expired |
| + "notifications.question": "A question needs your answer.", |
| + "notifications.task_ready": "A task is ready for you to review.", |
| + "notifications.interrupted": "Work stopped and needs your attention.", |
| + "notifications.superseded": "This item has changed. Fetch its current state.", |
| + "notifications.subscribe": "Receive notifications on this device", |
| + "notifications.unsubscribe": "Stop notifications on this device", |
| + "notifications.cursor_expired": "This notification cursor expired. Fetch notifications without a cursor and check Needs you for open questions.", |
| "notifications.subscription_expired": "This notification subscription expired. Subscribe again with a current device credential.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.list": "Your devices", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.last_used": "Last used", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.unused": "Not used yet", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.empty": "You have no approved devices.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.revoked": "Device revoked", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.approved": "Device approved", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "roster.invalid_input": "Check the person, role and active state.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "roster.forbidden": "Only a team owner can change the roster. Keep at least one owner.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "roster.revision_conflict": "The roster changed or this person still owns project decisions. Check the roster and project owners before trying again.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "budgets.invalid_input": "Use positive whole numbers for each limit and keep project limits within the team limits.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "budgets.forbidden": "Only a team owner can view or change budgets.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "budgets.revision_conflict": "The budgets changed. Fetch the current limits before trying again.", |
| + "device.list": "Your devices", |
| + "device.last_used": "Last used", |
| + "device.unused": "Not used yet", |
| + "device.empty": "You have no approved devices.", |
| + "device.revoked": "Device revoked", |
| + "device.approved": "Device approved", |
| + "roster.invalid_input": "Check the person, role and active state.", |
| + "roster.forbidden": "Only a team owner can change the roster. Keep at least one owner.", |
| + "roster.revision_conflict": "The roster changed or this person still owns project decisions. Check the roster and project owners before trying again.", |
| + "budgets.invalid_input": "Use positive whole numbers for each limit and keep project limits within the team limits.", |
| + "budgets.forbidden": "Only a team owner can view or change budgets.", |
| + "budgets.revision_conflict": "The budgets changed. Fetch the current limits before trying again.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.title": "Approve a device", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.label": "Device name", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.created": "Requested at", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.typed_code": "Type the code shown on your device", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.approve": "Approve device", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.expires": "Expires at", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "device.revoke": "Revoke device", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "api.device_expired": "This device request expired. Start again.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| - "api.slow_down": "Wait before trying again.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| + "device.title": "Approve a device", |
| + "device.label": "Device name", |
| + "device.created": "Requested at", |
| + "device.typed_code": "Type the code shown on your device", |
| + "device.approve": "Approve device", |
| + "device.expires": "Expires at", |
| + "device.revoke": "Revoke device", |
| + "api.device_expired": "This device request expired. Start again.", |
| + "api.slow_down": "Wait before trying again.", |
| "api.authorization_pending": "Approve this device in your browser.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.title |
| - "teams.title": "Teams", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.add |
| - "teams.add": "Remember a team", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.forget |
| - "teams.forget": "Forget this link", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.remembered |
| - "teams.remembered": "Your remembered teams", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.directory_help |
| - "teams.directory_help": "Add links to other Equipo instances you have signed in to. Only you can see this directory. Each instance has its own sign-in and membership. Links do not give access or share accounts.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.last_signin_unknown |
| + "teams.title": "Teams", |
| + "teams.add": "Remember a team", |
| + "teams.forget": "Forget this link", |
| + "teams.remembered": "Your remembered teams", |
| + "teams.directory_help": "Add links to other Equipo instances you have signed in to. Only you can see this directory. Each instance has its own sign-in and membership. Links do not give access or share accounts.", |
| "teams.last_signin_unknown": "Last sign-in unknown", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.last_signin |
| - "teams.last_signin": "Last signed in", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.remote_unavailable |
| - "teams.remote_unavailable": "Remote status unavailable", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.counts_unknown |
| - "teams.counts_unknown": "Counts unavailable", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.origin |
| - "teams.origin": "Instance address", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.name |
| - "teams.name": "Team name", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.current |
| - "teams.current": "Current team", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): teams.parent_task |
| - "teams.parent_task": "Task", |
| + "teams.last_signin": "Last signed in", |
| + "teams.remote_unavailable": "Remote status unavailable", |
| + "teams.counts_unknown": "Counts unavailable", |
| + "teams.origin": "Instance address", |
| + "teams.name": "Team name", |
| + "teams.current": "Current team", |
| + "teams.parent_task": "Task", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.title |
| - "account_setup.title": "Connect a model account", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.label |
| - "account_setup.label": "Account label", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.runner |
| - "account_setup.runner": "Paired machine", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.add |
| - "account_setup.add": "Connect account", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.dedicated |
| - "account_setup.dedicated": "Each account uses a new private home on your runner.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.browser |
| - "account_setup.browser": "Run this command on the paired machine. Open the official sign-in link there and paste the returned code only into that terminal.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.device |
| - "account_setup.device": "Run this command on the paired machine. Follow the official CLI instructions to enter its device code in your browser.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.config |
| - "account_setup.config": "Check the runner configuration and the selected provider model.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.network |
| - "account_setup.network": "The instance could not be reached. Try again.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.invalid |
| - "account_setup.invalid": "This setup ID is missing, expired, cancelled or belongs to another runner. Start a new setup.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.interrupted |
| - "account_setup.interrupted": "This sign-in was interrupted. Start a new setup.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.save_failed |
| - "account_setup.save_failed": "The account binding could not be saved. Check the runner configuration and start again.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.identity_failed |
| + "account_setup.title": "Connect a model account", |
| + "account_setup.label": "Account label", |
| + "account_setup.runner": "Paired machine", |
| + "account_setup.add": "Connect account", |
| + "account_setup.dedicated": "Each account uses a new private home on your runner.", |
| + "account_setup.browser": "Run this command on the paired machine. Open the official sign-in link there and paste the returned code only into that terminal.", |
| + "account_setup.device": "Run this command on the paired machine. Follow the official CLI instructions to enter its device code in your browser.", |
| + "account_setup.config": "Check the runner configuration and the selected provider model.", |
| + "account_setup.network": "The instance could not be reached. Try again.", |
| + "account_setup.invalid": "This setup ID is missing, expired, cancelled or belongs to another runner. Start a new setup.", |
| + "account_setup.interrupted": "This sign-in was interrupted. Start a new setup.", |
| + "account_setup.save_failed": "The account binding could not be saved. Check the runner configuration and start again.", |
| "account_setup.identity_failed": "The signed-in account could not be verified. Start a new setup.", |
| - // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.command |
| - "account_setup.command": "equipo-runner account login --setup %s", |
| + "account_setup.command": "equipo-runner account login --setup %s", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.cancel |
| "account_setup.cancel": "Cancel sign-in", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): account_setup.pending |
| @@ -1090,6 +1031,8 @@ var runnerDraftCopy = map[string]string{ |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): recovery.uncontained |
| "recovery.uncontained": "Uncontained attempts", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): runner.preflight.unavailable |
| + // COPY REVIEW PENDING: account.sign_in_again |
| + "account.sign_in_again": "Sign in again", |
| "runner.preflight.unavailable": "Runner preflight is unavailable.", |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): api.unauthenticated |
| "api.unauthenticated": "Sign in to continue.", |
| @@ -1164,3 +1107,58 @@ func RunnerSetupCopy(key string) string { return copyText(key) } |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): onboarding.first_instructions |
| var copyOnboardingFirstInstructions = pageCopy["onboarding.first_instructions"] |
| + |
| +// TryText contains the guided live gate's pending copy. The controller requested |
| +// this inventory without a copy-review server. |
| +func TryText(key string) string { return tryCopy[key] } |
| + |
| +var tryCopy = map[string]string{ |
| + // COPY REVIEW PENDING: try.prerequisite |
| + "prerequisite": "Missing prerequisite: %s\n", |
| + // COPY REVIEW PENDING: try.prompt |
| + "prompt": "%s [%s]: ", |
| + // COPY REVIEW PENDING: try.confirm |
| + "confirm": "Observed account for %s: %s. Confirm this account? [yes/no]: ", |
| + // COPY REVIEW PENDING: try.login |
| + "login": "Signing in to %s in its dedicated home. Complete the official browser flow. Provider output is hidden to keep sign-in links and tokens private.\n", |
| + // COPY REVIEW PENDING: try.failed |
| + "failed": "Stopped at %s. Saved setup can be resumed by running scripts/try-equipo.sh again. No release was made.\n", |
| + // COPY REVIEW PENDING: try.ready |
| + "ready": "Manifest candidate: %s\nAfter reviewing and importing the evidence bundle and candidate manifest, the controller releases with:\n%s\n", |
| + // COPY REVIEW PENDING: try.live |
| + "live": "Type RUN LIVE GATE to authorize the displayed limits and disposable exercises", |
| + // COPY REVIEW PENDING: try.signin |
| + "signin": "Type SIGN IN to start official sign-ins in dedicated homes", |
| + // COPY REVIEW PENDING: try.instance |
| + "instance": "Instance ID from Equipo", |
| + // COPY REVIEW PENDING: try.person |
| + "person": "Your Equipo person ID", |
| + // COPY REVIEW PENDING: try.claude-model |
| + "claude-model": "Exact Claude model", |
| + // COPY REVIEW PENDING: try.codex-model |
| + "codex-model": "Exact Codex model", |
| + // COPY REVIEW PENDING: try.forge |
| + "forge": "Absolute path to the runner's Amadan credential file", |
| + // COPY REVIEW PENDING: try.Calls |
| + "Calls": "Maximum calibration calls", |
| + // COPY REVIEW PENDING: try.InputTokens |
| + "InputTokens": "Maximum calibration input tokens", |
| + // COPY REVIEW PENDING: try.OutputTokens |
| + "OutputTokens": "Maximum calibration output tokens", |
| + // COPY REVIEW PENDING: try.Seconds |
| + "Seconds": "Maximum calibration seconds", |
| + // COPY REVIEW PENDING: try.JobInput |
| + "JobInput": "Job input token funding", |
| + // COPY REVIEW PENDING: try.JobOutput |
| + "JobOutput": "Job output token funding", |
| + // COPY REVIEW PENDING: try.ProjectInputHeadroom |
| + "ProjectInputHeadroom": "Remaining project input tokens", |
| + // COPY REVIEW PENDING: try.ProjectOutputHeadroom |
| + "ProjectOutputHeadroom": "Remaining project output tokens", |
| + // COPY REVIEW PENDING: try.TeamInputHeadroom |
| + "TeamInputHeadroom": "Remaining team input tokens", |
| + // COPY REVIEW PENDING: try.TeamOutputHeadroom |
| + "TeamOutputHeadroom": "Remaining team output tokens", |
| + // COPY REVIEW PENDING: try.limits |
| + "limits": "Authorized limits: %s\n", |
| +} |
diff --git a/internal/equipo/templates/connections.html b/internal/equipo/templates/connections.html| index 74eacdb2..d70a5094 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" .}} |
| <a rst-btn href="/onboarding">{{copy "account_setup.add"}}</a><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.reason"}}<select rst-input name="mode"><option value="best_fit"{{if eq .Mode "best_fit"}} selected{{end}}>{{copy "connections.best_fit"}}</option><option value="pinned"{{if eq .Mode "pinned"}} selected{{end}}>{{copy "connections.pinned"}}</option><option value="ask"{{if eq .Mode "ask"}} selected{{end}}>{{copy "connections.ask"}}</option></select></label><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><p>{{copy "connections.counted_usage"}}</p>{{if .Report.AllowanceKnown}}<span equipo-value>{{.Report.AllowanceRemaining}}</span>{{else}}<p>{{copy "connections.remaining_unknown"}}</p>{{end}}{{if not .Available}}<p>{{copy "runner.preflight.unavailable"}}</p>{{end}}{{template "trial-label" .Isolation}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.LauncherVersion}} / {{.Report.BwrapVersion}}</p>{{if .Unverified}}<p>{{copy "isolation.unverified"}}</p>{{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><p>{{copy "connections.counted_usage"}}</p>{{if .Report.AllowanceKnown}}<span equipo-value>{{.Report.AllowanceRemaining}}</span>{{else}}<p>{{copy "connections.remaining_unknown"}}</p>{{end}}{{if not .Available}}<p>{{if eq .Report.UnavailableReason "account.sign_in_again"}}{{copy "account.sign_in_again"}}{{else}}{{copy "runner.preflight.unavailable"}}{{end}}</p>{{end}}{{template "trial-label" .Isolation}}<p>{{copy "connections.versions"}}: {{.Report.Provider}} {{.Report.ProviderVersion}} / {{.Report.LauncherVersion}} / {{.Report.BwrapVersion}}</p>{{if .Unverified}}<p>{{copy "isolation.unverified"}}</p>{{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/equipotest/runner_release_test.go b/internal/equipotest/runner_release_test.go| index c0b1abe3..25c4ea2f 100644 |
| --- a/internal/equipotest/runner_release_test.go |
| +++ b/internal/equipotest/runner_release_test.go |
| @@ -184,7 +184,7 @@ func installCertificationFixture(t *testing.T, root string, m *release.Manifest, |
| artifact := []byte("synthetic observation for packaging tests only\n") |
| executionMust(t, os.WriteFile(filepath.Join(dir, "capture.json"), artifact, 0600)) |
| o := provider.LiveObservation{Status: "pass", Artifact: "capture.json", SHA256: fmt.Sprintf("%x", sha256.Sum256(artifact)), Detail: "synthetic fixture"} |
| - e := provider.DirectEvidence{Artifacts: map[string]string{"capture.json": o.SHA256}, Schema: 1, Source: "direct-live", RunID: "fixture", Provider: c.Provider, ProviderVersion: c.ProviderVersion, LauncherVersion: c.LauncherVersion, BwrapVersion: c.BwrapVersion, PolicyVersion: m.PolicyVersion, PolicyHash: c.PolicyHash, AccountID: "fixture", HomeID: "fixture", Model: "fixture", Specialist: "Engineering", AuthHost: "auth.example.com", ConfigSHA256: strings.Repeat("c", 64), Binaries: binaryHashes, Checks: map[string]provider.LiveObservation{}, Usage: []provider.LiveUsage{{Input: 1, Output: 1, Complete: true}}, Funding: provider.LiveFunding{Calls: 1, InputTokens: 1000, OutputTokens: 1000, Seconds: 60, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}} |
| + e := provider.DirectEvidence{Artifacts: map[string]string{"capture.json": o.SHA256}, Schema: 1, Source: "direct-live", RunID: "fixture", Provider: c.Provider, ProviderVersion: c.ProviderVersion, LauncherVersion: c.LauncherVersion, BwrapVersion: c.BwrapVersion, PolicyVersion: m.PolicyVersion, PolicyHash: c.PolicyHash, AccountID: "fixture", HomeID: "fixture", Model: "fixture", Specialist: "Engineering", AuthHost: "", ConfigSHA256: strings.Repeat("c", 64), Binaries: binaryHashes, Checks: map[string]provider.LiveObservation{}, Usage: []provider.LiveUsage{{Input: 1, Output: 1, Complete: true}}, Funding: provider.LiveFunding{Calls: 1, InputTokens: 1000, OutputTokens: 1000, Seconds: 60, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}} |
| for _, group := range []string{"Contract", "Isolation", "Recovery", "Calibration"} { |
| for _, name := range provider.DirectRequirements(group) { |
| e.Checks[name] = o |
| @@ -224,7 +224,7 @@ func installCertificationFixture(t *testing.T, root string, m *release.Manifest, |
| executionMust(t, os.WriteFile(path, raw, 0600)) |
| rel, err := filepath.Rel(root, path) |
| executionMust(t, err) |
| - m.DirectPolicies[i].CertifiedRefresh = release.CertifiedRefresh{AuthHost: e.AuthHost, EvidenceSHA256: fmt.Sprintf("%x", sha256.Sum256(raw))} |
| + m.DirectPolicies[i].NoRefreshReason = "v1 requires sign-in again" |
| m.Certifications = append(m.Certifications, release.Certification{Provider: c.Provider, PolicyHash: c.PolicyHash, Path: rel, SHA256: fmt.Sprintf("%x", sha256.Sum256(raw))}) |
| m.VerifiedIsolationTuples = append(m.VerifiedIsolationTuples, team.IsolationTuple{Provider: c.Provider, ProviderVersion: c.ProviderVersion, LauncherVersion: c.LauncherVersion, BwrapVersion: c.BwrapVersion, PolicyVersion: m.PolicyVersion, IsolationConfigHash: c.PolicyHash}) |
| if scenario == "tampered_capture" { |
diff --git a/internal/equipotest/signin_again_test.go b/internal/equipotest/signin_again_test.go| new file mode 100644 |
| index 00000000..9bf1f737 |
| --- /dev/null |
| +++ b/internal/equipotest/signin_again_test.go |
| @@ -0,0 +1,30 @@ |
| +package equipotest |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "net/http/httptest" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +func TestExpiredConnectionShowsSignInAgain(t *testing.T) { |
| + f := connectionStore(t) |
| + f.choice(t, f.ids["claude"]) |
| + f.reports[0].Available = false |
| + f.reports[0].UnavailableReason = "account.sign_in_again" |
| + executionMust(t, f.s.ReportConnections(connectionContext, f.principal, f.reports)) |
| + f.denied(t, "Engineering", "") |
| + mail := &capturingMailer{} |
| + h, err := equipo.App(f.d, testConfig(testOrigin), mail, nil) |
| + executionMust(t, err) |
| + server := httptest.NewServer(h) |
| + defer server.Close() |
| + client := signinClient(t, server.URL) |
| + signinEmail(t, client, server.URL, testOrigin, mail, ownerAddress) |
| + res, err := client.Get(server.URL + "/connections") |
| + executionMust(t, err) |
| + body := readBody(t, res) |
| + if res.StatusCode != 200 || !strings.Contains(body, "Sign in again") { |
| + t.Fatal("expired connection has no sign-in state", res.StatusCode) |
| + } |
| +} |
diff --git a/internal/plan3test/coordinator_release_test.go b/internal/plan3test/coordinator_release_test.go| index 5e3e0312..7f864e00 100644 |
| --- a/internal/plan3test/coordinator_release_test.go |
| +++ b/internal/plan3test/coordinator_release_test.go |
| @@ -17,9 +17,9 @@ func TestCoordinatorReleaseNeedsPolicyCertification(t *testing.T) { |
| if m.ActionCertified(name, "coordinate", version, hash) { |
| t.Fatal("missing certificate accepted") |
| } |
| - certificate := release.PolicyCertificate{Provider: name, ProviderVersion: version, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: hash, CertifiedRefresh: release.CertifiedRefresh{AuthHost: "auth.example.test", EvidenceSHA256: strings.Repeat("b", 64)}} |
| + certificate := release.PolicyCertificate{Provider: name, ProviderVersion: version, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: hash, NoRefreshReason: "v1 requires sign-in again"} |
| m.DirectPolicies = []release.PolicyCertificate{certificate} |
| - m.Certifications = []release.Certification{{Provider: name, PolicyHash: hash, SHA256: certificate.CertifiedRefresh.EvidenceSHA256, Path: "fixture"}} |
| + m.Certifications = []release.Certification{{Provider: name, PolicyHash: hash, SHA256: strings.Repeat("b", 64), Path: "fixture"}} |
| m.LiveGateCopyReviewed = true |
| if m.ActionCertified(name, "coordinate", version, hash) { |
| t.Fatal("old certificate authorized pending coordinator inventory") |
diff --git a/internal/plan3test/plan3_release_test.go b/internal/plan3test/plan3_release_test.go| index ea122d4f..78cea256 100644 |
| --- a/internal/plan3test/plan3_release_test.go |
| +++ b/internal/plan3test/plan3_release_test.go |
| @@ -83,9 +83,9 @@ func TestPlan3ReleaseBoundaries(t *testing.T) { |
| } |
| m.LiveGateCopyReviewed = true |
| m.UncertifiedPolicies = nil |
| - cert := release.PolicyCertificate{Provider: "claude", ProviderVersion: m.Claude, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: strings.Repeat("a", 64), CertifiedRefresh: release.CertifiedRefresh{AuthHost: "auth.example.test", EvidenceSHA256: strings.Repeat("b", 64)}} |
| + cert := release.PolicyCertificate{Provider: "claude", ProviderVersion: m.Claude, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: strings.Repeat("a", 64), NoRefreshReason: "v1 requires sign-in again"} |
| m.DirectPolicies = []release.PolicyCertificate{cert} |
| - m.Certifications = []release.Certification{{Provider: cert.Provider, PolicyHash: cert.PolicyHash, SHA256: cert.CertifiedRefresh.EvidenceSHA256, Path: "fixture"}} |
| + m.Certifications = []release.Certification{{Provider: cert.Provider, PolicyHash: cert.PolicyHash, SHA256: strings.Repeat("b", 64), Path: "fixture"}} |
| if !m.InstallCertified() { |
| t.Fatal("positive certification fixture rejected") |
| } |
diff --git a/internal/release/install.go b/internal/release/install.go| index 859a7725..db1dff79 100644 |
| --- a/internal/release/install.go |
| +++ b/internal/release/install.go |
| @@ -34,7 +34,7 @@ func (m Manifest) InstallCertified() bool { |
| return false |
| } |
| for _, p := range m.DirectPolicies { |
| - if m.CertifiedAuthHost(p.Provider, p.ProviderVersion, p.PolicyHash) == "" { |
| + if !m.noRefreshCertificate(p) { |
| return false |
| } |
| } |
diff --git a/internal/release/install_test.go b/internal/release/install_test.go| index 7d7bae7d..1ad70bbc 100644 |
| --- a/internal/release/install_test.go |
| +++ b/internal/release/install_test.go |
| @@ -21,7 +21,7 @@ func TestOnboardingInstallPackaging(t *testing.T) { |
| m.LiveGateCopyReviewed = true |
| m.UncertifiedPolicies = nil |
| hash := strings.Repeat("b", 64) |
| - m.DirectPolicies = []PolicyCertificate{{Provider: "codex", ProviderVersion: m.Codex, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: hash, CertifiedRefresh: CertifiedRefresh{AuthHost: "auth.openai.com", EvidenceSHA256: hash}}} |
| + m.DirectPolicies = []PolicyCertificate{{Provider: "codex", ProviderVersion: m.Codex, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: hash, NoRefreshReason: "v1 requires sign-in again"}} |
| m.Binaries = []BinaryDigest{{Name: "equipo-tool-proxy", Version: m.LauncherVersion, SHA256: fmt.Sprintf("%x", sha256.Sum256([]byte("fixture helper")))}} |
| m.Certifications = []Certification{{Provider: "codex", PolicyHash: hash, Path: "fixture", SHA256: hash}} |
| binary := []byte("fixture binary, never executed") |
diff --git a/internal/release/manifest.go b/internal/release/manifest.go| index ea7a33f0..2a84f74f 100644 |
| --- a/internal/release/manifest.go |
| +++ b/internal/release/manifest.go |
| @@ -24,12 +24,13 @@ type CertifiedRefresh struct { |
| } |
| type PolicyCertificate struct { |
| - CertifiedRefresh CertifiedRefresh `json:"certified_refresh"` |
| - Provider string `json:"provider"` |
| - ProviderVersion string `json:"provider_version"` |
| - LauncherVersion string `json:"launcher_version"` |
| - BwrapVersion string `json:"bwrap_version"` |
| - PolicyHash string `json:"policy_hash"` |
| + CertifiedRefresh *CertifiedRefresh `json:"certified_refresh"` |
| + NoRefreshReason string `json:"no_refresh_reason,omitempty"` |
| + Provider string `json:"provider"` |
| + ProviderVersion string `json:"provider_version"` |
| + LauncherVersion string `json:"launcher_version"` |
| + BwrapVersion string `json:"bwrap_version"` |
| + PolicyHash string `json:"policy_hash"` |
| } |
| type BinaryDigest struct { |
diff --git a/internal/release/manifest.json b/internal/release/manifest.json| index 6da7054d..8eb4883a 100644 |
| --- a/internal/release/manifest.json |
| +++ b/internal/release/manifest.json |
| @@ -66,49 +66,49 @@ |
| { |
| "provider": "codex", |
| "action": "reproduce", |
| - "inventory_hash": "435d76c608656fd6770fb7dab9b65841dc0ef357116f4c2040651af5743c5c7a", |
| + "inventory_hash": "2e4ca8baffdf32c0eee8506ac551936ae6a89b4a6f2b50118a5f781f2ee16d37", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "scope", |
| - "inventory_hash": "0de5eed215371050bcf8fc6b3346f18bd015b14705adf972f10f67ed22bc6c8f", |
| + "inventory_hash": "fa2a7c8bc318a50977a9af60eb95d7a37fa1f15b631cde4e4cd1869bfd5ad2cb", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "recommend", |
| - "inventory_hash": "4affd5746c0cfc8cabec1dd507ae5b5dc82ed7c799ce38480042bf8669dcdcbc", |
| + "inventory_hash": "c0e5a0b12cf4f53ee641b2f0dd61507f73526cf7d3310afefd1bce273e2ad034", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "investigate", |
| - "inventory_hash": "6fca6951e21a11e8ff86b0636424061f4397c3c45bb38635ca604bdb9be35a1b", |
| + "inventory_hash": "f339de414600e504e7e2f8cd6fa0c2cbacff30ff5fe1afe193b3de405ef54c22", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "implement", |
| - "inventory_hash": "58ee38d4b439958a8efaf0db80ea41edb0e26a8e22904a7b9dc0af2f45a60a70", |
| + "inventory_hash": "a47a468f09575940f82096b39836468ccfa7b77db4d9ecdbef92b60b5033c4bc", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "copy", |
| - "inventory_hash": "31796d33d592a51b8955aff45688b24959354bb358210b8ca7d65f16373e653c", |
| + "inventory_hash": "197d0fd3074e1c5ab1483bf6c8b64ed99aa60d32f73a5b7777e34fb66ce9402b", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "design", |
| - "inventory_hash": "a6939b534139e55a6f20aa27cec2fe10aad17d324fe022843d3a1b2bffb28932", |
| + "inventory_hash": "7177a83262fdb00b3b89c3f5e0439a8100ca87b67e9ba550db870ed27081e37a", |
| "status": "uncertified" |
| }, |
| { |
| "provider": "codex", |
| "action": "review", |
| - "inventory_hash": "257572ad892e93feaa96fdc7ec76113ddaee968479a09a7b26e7efb65dee1ff0", |
| + "inventory_hash": "2609f5f2c114bb133753de19b6f952f17b765e0975f5788b4c44e353e8de4eeb", |
| "status": "uncertified" |
| }, |
| { |
diff --git a/internal/release/manifest_test.go b/internal/release/manifest_test.go| index 66c4aa92..2c9f7cfd 100644 |
| --- a/internal/release/manifest_test.go |
| +++ b/internal/release/manifest_test.go |
| @@ -89,10 +89,10 @@ func TestPlanWorkflowReleaseRejectsOldCertificate(t *testing.T) { |
| m := BuildManifest() |
| for _, p := range m.UncertifiedPolicies { |
| version := map[string]string{"claude": m.Claude, "codex": m.Codex}[p.Provider] |
| - m.DirectPolicies = []PolicyCertificate{{Provider: p.Provider, ProviderVersion: version, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: p.InventoryHash, CertifiedRefresh: CertifiedRefresh{AuthHost: "auth.example.test", EvidenceSHA256: p.InventoryHash}}} |
| + m.DirectPolicies = []PolicyCertificate{{Provider: p.Provider, ProviderVersion: version, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: p.InventoryHash, CertifiedRefresh: &CertifiedRefresh{AuthHost: "auth.example.test", EvidenceSHA256: p.InventoryHash}}} |
| m.Certifications = []Certification{{Provider: p.Provider, PolicyHash: p.InventoryHash, SHA256: p.InventoryHash, Path: "fixture"}} |
| - if m.CertifiedAuthHost(p.Provider, version, p.InventoryHash) == "" { |
| - t.Fatal("invalid synthetic old certificate fixture") |
| + if m.CertifiedAuthHost(p.Provider, version, p.InventoryHash) != "" { |
| + t.Fatal("old refresh authority admitted") |
| } |
| if m.ActionCertified(p.Provider, p.Action, version, p.InventoryHash) { |
| t.Fatal("old certificate enabled changed inventory", p.Action) |
diff --git a/internal/release/no_refresh_test.go b/internal/release/no_refresh_test.go| new file mode 100644 |
| index 00000000..e6340ddd |
| --- /dev/null |
| +++ b/internal/release/no_refresh_test.go |
| @@ -0,0 +1,34 @@ |
| +package release |
| + |
| +import ( |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +func TestNoRefreshCertificate(t *testing.T) { |
| + m := BuildManifest() |
| + m.UncertifiedPolicies = nil |
| + m.LiveGateCopyReviewed = true |
| + h := strings.Repeat("a", 64) |
| + var c PolicyCertificate |
| + if err := json.Unmarshal([]byte(`{"provider":"codex","provider_version":"0.165.0","launcher_version":"direct-v3","bwrap_version":"0.11.0","policy_hash":"`+h+`","certified_refresh":null,"no_refresh_reason":"v1 requires sign-in again"}`), &c); err != nil { |
| + t.Fatal(err) |
| + } |
| + m.DirectPolicies = []PolicyCertificate{c} |
| + m.Certifications = []Certification{{Provider: "codex", PolicyHash: h, SHA256: h}} |
| + if !m.InstallCertified() { |
| + t.Fatal("explicit no-refresh certificate rejected") |
| + } |
| + if m.CertifiedAuthHost("codex", m.Codex, h) != "" { |
| + t.Fatal("refresh authority granted") |
| + } |
| + raw, _ := json.Marshal(c) |
| + if !strings.Contains(string(raw), `"certified_refresh":null`) { |
| + t.Fatal("no-refresh lost", string(raw)) |
| + } |
| + m.Certifications = nil |
| + if m.InstallCertified() { |
| + t.Fatal("missing evidence accepted") |
| + } |
| +} |
diff --git a/internal/release/policy_inventory.go b/internal/release/policy_inventory.go| index 526b58d6..274fa135 100644 |
| --- a/internal/release/policy_inventory.go |
| +++ b/internal/release/policy_inventory.go |
| @@ -53,5 +53,14 @@ func (m Manifest) ActionCertified(name, action, version, hash string) bool { |
| return false |
| } |
| } |
| - return m.CertifiedAuthHost(name, version, hash) != "" |
| + count := 0 |
| + for _, c := range m.DirectPolicies { |
| + if c.Provider == name && c.ProviderVersion == version && c.PolicyHash == hash { |
| + if !m.noRefreshCertificate(c) { |
| + return false |
| + } |
| + count++ |
| + } |
| + } |
| + return count == 1 |
| } |
diff --git a/internal/release/refresh.go b/internal/release/refresh.go| index b86ceaf5..065a6689 100644 |
| --- a/internal/release/refresh.go |
| +++ b/internal/release/refresh.go |
| @@ -1,66 +1,27 @@ |
| package release |
| -import ( |
| - "encoding/hex" |
| - "net/netip" |
| - "strings" |
| -) |
| +import "encoding/hex" |
| -// CertifiedAuthHost returns authority only for the exact tuple and its evidence. |
| -func (m Manifest) CertifiedAuthHost(provider, version, hash string) string { |
| - if version != map[string]string{"claude": m.Claude, "codex": m.Codex}[provider] || version == "" { |
| - return "" |
| - } |
| - var host string |
| - count := 0 |
| - for _, c := range m.DirectPolicies { |
| - if c.Provider != provider || c.ProviderVersion != version || c.PolicyHash != hash { |
| - continue |
| - } |
| - count++ |
| - if c.LauncherVersion != m.LauncherVersion || c.BwrapVersion != m.BwrapVersion { |
| - return "" |
| - } |
| - h := c.CertifiedRefresh.AuthHost |
| - if !validAuthHost(h) { |
| - return "" |
| - } |
| - digest, err := hex.DecodeString(c.CertifiedRefresh.EvidenceSHA256) |
| - if err != nil || len(digest) != 32 { |
| - return "" |
| - } |
| - refs := 0 |
| - for _, e := range m.Certifications { |
| - if e.Provider == provider && e.PolicyHash == hash && e.SHA256 == c.CertifiedRefresh.EvidenceSHA256 { |
| - refs++ |
| - } |
| - } |
| - if refs != 1 { |
| - return "" |
| - } |
| - host = h |
| - } |
| - if count != 1 { |
| - return "" |
| - } |
| - return host |
| -} |
| -func validAuthHost(h string) bool { |
| - if len(h) > 253 || h != strings.ToLower(h) || !strings.Contains(h, ".") { |
| +// V1 never grants network authority for credential refresh. |
| +func (m Manifest) CertifiedAuthHost(provider, version, hash string) string { return "" } |
| + |
| +func (m Manifest) noRefreshCertificate(c PolicyCertificate) bool { |
| + if c.CertifiedRefresh != nil || c.NoRefreshReason == "" || c.ProviderVersion == "" || c.ProviderVersion != map[string]string{"claude": m.Claude, "codex": m.Codex}[c.Provider] || c.LauncherVersion != m.LauncherVersion || c.BwrapVersion != m.BwrapVersion { |
| return false |
| } |
| - if _, err := netip.ParseAddr(h); err == nil { |
| + hash, err := hex.DecodeString(c.PolicyHash) |
| + if err != nil || len(hash) != 32 { |
| return false |
| } |
| - for _, label := range strings.Split(h, ".") { |
| - if len(label) == 0 || len(label) > 63 || label[0] == '-' || label[len(label)-1] == '-' { |
| - return false |
| - } |
| - for _, c := range label { |
| - if !(c >= 'a' && c <= 'z' || c >= '0' && c <= '9' || c == '-') { |
| + count := 0 |
| + for _, r := range m.Certifications { |
| + if r.Provider == c.Provider && r.PolicyHash == c.PolicyHash { |
| + sum, err := hex.DecodeString(r.SHA256) |
| + if err != nil || len(sum) != 32 { |
| return false |
| } |
| + count++ |
| } |
| } |
| - return true |
| + return count == 1 |
| } |
diff --git a/internal/release/refresh_test.go b/internal/release/refresh_test.go| index 1b5b5cb3..bb435fdc 100644 |
| --- a/internal/release/refresh_test.go |
| +++ b/internal/release/refresh_test.go |
| @@ -16,8 +16,8 @@ func TestCertifiedRefreshExactTuple(t *testing.T) { |
| } |
| m.DirectPolicies = []PolicyCertificate{c} |
| m.Certifications = []Certification{{Provider: "codex", PolicyHash: hash, SHA256: strings.Repeat("b", 64)}} |
| - if got := m.CertifiedAuthHost("codex", "0.165.0", hash); got != "auth.openai.com" { |
| - t.Fatalf("certified host lost: %q", got) |
| + if got := m.CertifiedAuthHost("codex", "0.165.0", hash); got != "" { |
| + t.Fatalf("legacy refresh authority granted: %q", got) |
| } |
| for _, q := range [][3]string{{"claude", "0.165.0", hash}, {"codex", "changed", hash}, {"codex", "0.165.0", "changed"}} { |
| if m.CertifiedAuthHost(q[0], q[1], q[2]) != "" { |
diff --git a/internal/runner/certified/policy.go b/internal/runner/certified/policy.go| index fd877d85..9b3a1640 100644 |
| --- a/internal/runner/certified/policy.go |
| +++ b/internal/runner/certified/policy.go |
| @@ -4,60 +4,13 @@ import ( |
| "amadan.net/oficina/equipo/internal/release" |
| "amadan.net/oficina/equipo/internal/runner/egress" |
| "amadan.net/oficina/equipo/internal/runner/provider" |
| - "fmt" |
| ) |
| -func Networks(m release.Manifest) []provider.NetworkContract { |
| - var out []provider.NetworkContract |
| - for _, name := range []string{"claude", "codex"} { |
| - c := provider.NetworkContract{Provider: name} |
| - for _, tuple := range m.DirectPolicies { |
| - if tuple.Provider != name { |
| - continue |
| - } |
| - host := m.CertifiedAuthHost(name, tuple.ProviderVersion, tuple.PolicyHash) |
| - if host == "" { |
| - continue |
| - } |
| - if c.AuthHost != "" && c.AuthHost != host { |
| - c.Conflict = fmt.Sprintf("certified auth host conflict for %s: %s and %s", name, c.AuthHost, host) |
| - break |
| - } |
| - c.AuthHost = host |
| - } |
| - out = append(out, c) |
| - } |
| - return out |
| +// V1 has no credential-refresh egress, including for older manifests. |
| +func Networks(_ release.Manifest) []provider.NetworkContract { |
| + return []provider.NetworkContract{{Provider: "claude"}, {Provider: "codex"}} |
| } |
| - |
| -func BuildPolicy(b provider.Binding, in provider.PolicyInputs, m release.Manifest) (provider.Policy, error) { |
| - for _, c := range m.DirectPolicies { |
| - if c.Provider != b.Provider || c.ProviderVersion != b.Expected.ProviderVersion { |
| - continue |
| - } |
| - if in.Action != "" && !m.ActionCertified(c.Provider, in.Action, c.ProviderVersion, c.PolicyHash) { |
| - continue |
| - } |
| - host := m.CertifiedAuthHost(c.Provider, c.ProviderVersion, c.PolicyHash) |
| - if host == "" { |
| - continue |
| - } |
| - network, err := egress.ProviderPolicy(provider.NetworkContract{Provider: b.Provider, AuthHost: host}, b.VerifiedDedicatedHome()) |
| - if err != nil { |
| - return provider.Policy{}, err |
| - } |
| - candidate := in |
| - candidate.EgressHosts = network.Hosts |
| - candidate.AuthHost = host |
| - p, err := provider.BuildPolicy(b, candidate) |
| - if err != nil { |
| - return p, err |
| - } |
| - if p.Hash == c.PolicyHash { |
| - return p, nil |
| - } |
| - } |
| - // No certificate for this exact policy: no refresh authority. |
| +func BuildPolicy(b provider.Binding, in provider.PolicyInputs, _ release.Manifest) (provider.Policy, error) { |
| in.AuthHost = "" |
| network, err := egress.ProviderPolicy(provider.NetworkContract{Provider: b.Provider}, b.VerifiedDedicatedHome()) |
| if err != nil { |
diff --git a/internal/runner/certified_network_test.go b/internal/runner/certified_network_test.go| index 05bec8c1..bea9bfea 100644 |
| --- a/internal/runner/certified_network_test.go |
| +++ b/internal/runner/certified_network_test.go |
| @@ -47,13 +47,13 @@ func TestCertifiedRefreshRuntimePolicy(t *testing.T) { |
| if p.Hash == base.Hash { |
| t.Fatal("auth host absent from policy hash") |
| } |
| - c := release.PolicyCertificate{Provider: b.Provider, ProviderVersion: b.Expected.ProviderVersion, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: p.Hash, CertifiedRefresh: release.CertifiedRefresh{AuthHost: candidate.AuthHost, EvidenceSHA256: strings.Repeat("b", 64)}} |
| + c := release.PolicyCertificate{Provider: b.Provider, ProviderVersion: b.Expected.ProviderVersion, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: p.Hash, CertifiedRefresh: &release.CertifiedRefresh{AuthHost: candidate.AuthHost, EvidenceSHA256: strings.Repeat("b", 64)}} |
| m.DirectPolicies = []release.PolicyCertificate{c} |
| m.Certifications = []release.Certification{{Provider: c.Provider, PolicyHash: p.Hash, SHA256: c.CertifiedRefresh.EvidenceSHA256}} |
| got, err := certified.BuildPolicy(b, in, m) |
| mustJournal(t, err) |
| - if got.Hash != p.Hash { |
| - t.Fatal("certified host did not reach policy") |
| + if got.Hash != base.Hash { |
| + t.Fatal("legacy refresh host reached policy") |
| } |
| for _, n := range certified.Networks(m) { |
| if n.Provider == b.Provider { |
| @@ -156,14 +156,14 @@ func TestCertifiedNetworkConflictDiagnostic(t *testing.T) { |
| for i, host := range []string{"auth.first.invalid", "auth.second.invalid"} { |
| hash := strings.Repeat(string(rune('a'+i)), 64) |
| evidence := strings.Repeat("d", 64) |
| - m.DirectPolicies = append(m.DirectPolicies, release.PolicyCertificate{Provider: "codex", ProviderVersion: m.Codex, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: hash, CertifiedRefresh: release.CertifiedRefresh{AuthHost: host, EvidenceSHA256: evidence}}) |
| + m.DirectPolicies = append(m.DirectPolicies, release.PolicyCertificate{Provider: "codex", ProviderVersion: m.Codex, LauncherVersion: m.LauncherVersion, BwrapVersion: m.BwrapVersion, PolicyHash: hash, CertifiedRefresh: &release.CertifiedRefresh{AuthHost: host, EvidenceSHA256: evidence}}) |
| m.Certifications = append(m.Certifications, release.Certification{Provider: "codex", PolicyHash: hash, SHA256: evidence}) |
| } |
| for _, n := range certified.Networks(m) { |
| if n.Provider == "codex" { |
| _, err := egress.ProviderPolicy(n, true) |
| - if err == nil || !strings.Contains(err.Error(), "conflict") || !strings.Contains(err.Error(), "auth.first.invalid") || !strings.Contains(err.Error(), "auth.second.invalid") { |
| - t.Fatal("missing conflict diagnostic", err) |
| + if err != nil || n.AuthHost != "" { |
| + t.Fatal("legacy refresh network admitted", err) |
| } |
| } |
| } |
diff --git a/internal/runner/containment/egress_test.go b/internal/runner/containment/egress_test.go| index abb07dbc..b11afe04 100644 |
| --- a/internal/runner/containment/egress_test.go |
| +++ b/internal/runner/containment/egress_test.go |
| @@ -265,6 +265,7 @@ func TestEgressInstalledContract(t *testing.T) { |
| for _, contracts := range [][]provider.NetworkContract{ |
| {{Provider: "other"}}, |
| {{Provider: "claude", AuthHost: "*.example"}}, |
| + {{Provider: "claude", AuthHost: "refresh.example"}}, |
| {{Provider: "claude"}, {Provider: "claude", AuthHost: "refresh.example"}}, |
| } { |
| cfg := m.cfg |
| @@ -274,14 +275,14 @@ func TestEgressInstalledContract(t *testing.T) { |
| } |
| } |
| cfg := m.cfg |
| - contracts := []provider.NetworkContract{{Provider: "claude", AuthHost: "refresh.example"}} |
| + contracts := []provider.NetworkContract{{Provider: "claude"}} |
| cfg.ProviderNetworks = contracts |
| manager, e := New(cfg) |
| if e != nil { |
| t.Fatal(e) |
| } |
| contracts[0].AuthHost = "changed.example" |
| - if manager.cfg.ProviderNetworks[0].AuthHost != "refresh.example" { |
| + if manager.cfg.ProviderNetworks[0].AuthHost != "" { |
| t.Fatal("installed contract changed after New") |
| } |
| } |
diff --git a/internal/runner/diagnostics.go b/internal/runner/diagnostics.go| index 8868bdec..330f3a09 100644 |
| --- a/internal/runner/diagnostics.go |
| +++ b/internal/runner/diagnostics.go |
| @@ -55,6 +55,8 @@ func Diagnostic(err error) (string, string) { |
| code = "runner.timeout" |
| case errors.As(err, &network): |
| code = "runner.network" |
| + case errors.Is(err, provider.ErrAccountMaintenance): |
| + code = "account.sign_in_again" |
| case errors.Is(err, provider.ErrIdentity): |
| code = "runner.identity" |
| case errors.Is(err, provider.ErrPolicy), errors.Is(err, provider.ErrIsolation): |
diff --git a/internal/runner/egress/policy.go b/internal/runner/egress/policy.go| index 06679b61..49d4cad4 100644 |
| --- a/internal/runner/egress/policy.go |
| +++ b/internal/runner/egress/policy.go |
| @@ -39,13 +39,9 @@ func ProviderPolicy(c provider.NetworkContract, dedicated bool) (Policy, error) |
| return Policy{}, errPolicy |
| } |
| if c.AuthHost != "" { |
| - if !hostname(c.AuthHost) { |
| - return Policy{}, errPolicy |
| - } |
| - if dedicated && c.AuthHost != p.Hosts[0] { |
| - p.Hosts = append(p.Hosts, c.AuthHost) |
| - } |
| + return Policy{}, errPolicy |
| } |
| + |
| return p, nil |
| } |
diff --git a/internal/runner/egress/proxy_test.go b/internal/runner/egress/proxy_test.go| index d9118e5e..715efbb7 100644 |
| --- a/internal/runner/egress/proxy_test.go |
| +++ b/internal/runner/egress/proxy_test.go |
| @@ -346,12 +346,12 @@ func TestEgressPolicy(t *testing.T) { |
| t.Fatalf("default: %+v %v", p, e) |
| } |
| p, e = ProviderPolicy(provider.NetworkContract{Provider: name, AuthHost: "refresh.example"}, false) |
| - if e != nil || len(p.Hosts) != 1 { |
| + if e == nil { |
| t.Fatal("shared home got refresh") |
| } |
| p, e = ProviderPolicy(provider.NetworkContract{Provider: name, AuthHost: "refresh.example"}, true) |
| - if e != nil || len(p.Hosts) != 2 { |
| - t.Fatal("dedicated refresh missing") |
| + if e == nil { |
| + t.Fatal("dedicated refresh admitted") |
| } |
| } |
| for _, p := range []Policy{{Provider: "other", Hosts: []string{"fixture.example"}}, {Provider: "claude"}, {Provider: "claude", Hosts: []string{"*.example"}}, {Provider: "claude", Hosts: []string{"127.0.0.1"}}, {Provider: "claude", Hosts: []string{"localhost"}}, {Provider: "claude", Hosts: []string{"fixture.example", "fixture.example"}}} { |
diff --git a/internal/runner/provider/accounts.go b/internal/runner/provider/accounts.go| index f7a02871..d678eb7e 100644 |
| --- a/internal/runner/provider/accounts.go |
| +++ b/internal/runner/provider/accounts.go |
| @@ -15,6 +15,7 @@ import ( |
| "strconv" |
| "strings" |
| "sync" |
| + "time" |
| "golang.org/x/sys/unix" |
| ) |
| @@ -287,6 +288,9 @@ func (l *AccountLease) snapshot() ([]byte, [32]byte, error) { |
| if e != nil { |
| return nil, zero, ErrContainment |
| } |
| + if credentialsExpired(raw, time.Now()) { |
| + return nil, zero, ErrAccountMaintenance |
| + } |
| // This digest stays in memory. Stat identity detects atomic replacement |
| // even when the replacement contains identical credential bytes. |
| var stat unix.Stat_t |
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go| index 0d949461..c4c64a24 100644 |
| --- a/internal/runner/provider/codex/launcher.go |
| +++ b/internal/runner/provider/codex/launcher.go |
| @@ -129,7 +129,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p |
| settings := map[string]any{ |
| "model": model, "model_provider": "openai", "approval_policy": "on-request", "approvals_reviewer": "user", "default_permissions": "equipo", |
| "permissions": map[string]any{"equipo": map[string]any{"filesystem": fs, "network": map[string]any{"enabled": false}}}, |
| - "features": map[string]any{"apps": false, "multi_agent": false, "remote_control": false, "tool_call_mcp_elicitation": true}, "mcp_servers": map[string]any{"equipo": map[string]any{"command": "/opt/equipo-tool-proxy", "args": []string{"--socket", "/tool/equipo.sock"}}}, |
| + "features": map[string]any{"incremental_tools": true, "apps": false, "multi_agent": false, "remote_control": false, "tool_call_mcp_elicitation": true}, "mcp_servers": map[string]any{"equipo": map[string]any{"command": "/opt/equipo-tool-proxy", "args": []string{"--socket", "/tool/equipo.sock"}}}, |
| } |
| if in.Action == "coordinate" { |
| configureCoordinator(settings, model) |
| @@ -150,9 +150,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p |
| in.Settings = marshal(settings) |
| in.MCP = json.RawMessage(`{"mcpServers":{"equipo":{"type":"stdio","command":"/opt/equipo-tool-proxy","args":["--socket","/tool/equipo.sock"]}}}`) |
| thread := map[string]any{"model": model, "modelProvider": "openai", "cwd": "/workspace", "approvalPolicy": "on-request", "approvalsReviewer": "user", "permissions": "equipo", "runtimeWorkspaceRoots": []string{"/workspace"}, "config": settings} |
| - if in.Action == "coordinate" { |
| - thread["experimentalRawEvents"] = true |
| - } |
| + thread["experimentalRawEvents"] = true |
| in.ThreadPolicy = marshal(thread) |
| in.TurnPolicy = json.RawMessage(`{}`) |
| in.Argv = []string{"/opt/codex", "app-server", "--strict-config", "--listen", "stdio://"} |
| @@ -570,11 +568,7 @@ func (s *sessionState) thread(ctx context.Context, method, id string) (string, e |
| if e := s.lease.ValidatePolicy(ctx); e != nil { |
| return "", e |
| } |
| - var params map[string]json.RawMessage |
| - json.Unmarshal(s.launch.Policy.ThreadPolicy, ¶ms) |
| - if method == "thread/resume" { |
| - params["threadId"] = marshal(id) |
| - } |
| + params := threadParams(s.launch.Policy.ThreadPolicy, method, id) |
| raw, e := s.rpc.Call(ctx, method, marshal(params)) |
| if e != nil { |
| return "", e |
| @@ -939,3 +933,13 @@ func configSubset(want, got []byte) bool { |
| // ConfigMatchesReadback validates a captured effective config with the adapter's rules. |
| func ConfigMatchesReadback(raw []byte, p provider.Policy) bool { return validateConfig(raw, p) == nil } |
| + |
| +func threadParams(policy json.RawMessage, method, id string) map[string]json.RawMessage { |
| + var params map[string]json.RawMessage |
| + _ = json.Unmarshal(policy, ¶ms) |
| + if method == "thread/resume" { |
| + delete(params, "experimentalRawEvents") |
| + params["threadId"] = marshal(id) |
| + } |
| + return params |
| +} |
diff --git a/internal/runner/provider/codex/launcher_test.go b/internal/runner/provider/codex/launcher_test.go| index 4d2bb948..235b44e6 100644 |
| --- a/internal/runner/provider/codex/launcher_test.go |
| +++ b/internal/runner/provider/codex/launcher_test.go |
| @@ -708,6 +708,9 @@ func TestCodexGeneratedSchema(t *testing.T) { |
| } |
| var fields map[string]json.RawMessage |
| json.Unmarshal(policy, &fields) |
| + if name == "ThreadResumeParams" { |
| + fields = threadParams(policy, "thread/resume", "fixture") |
| + } |
| for key := range fields { |
| if _, ok := schema.Properties[key]; !ok { |
| t.Fatal("field absent from pinned schema", name, key) |
diff --git a/internal/runner/provider/direct_certification.go b/internal/runner/provider/direct_certification.go| index 1b33df1f..15319102 100644 |
| --- a/internal/runner/provider/direct_certification.go |
| +++ b/internal/runner/provider/direct_certification.go |
| @@ -146,7 +146,7 @@ func (e DirectEvidence) ValidateGroup(root, group string) error { |
| } |
| } |
| required := DirectRequirements(group) |
| - if len(required) == 0 || e.Schema != 1 || e.Source != "direct-live" || e.RunID == "" || e.LauncherVersion != LauncherVersion || e.BwrapVersion != "0.11.0" || e.PolicyVersion != PolicyVersion || !liveDigest(e.PolicyHash) || !liveDigest(e.ConfigSHA256) || e.AccountID == "" || e.HomeID == "" || e.Model == "" || !liveAuthHost(e.AuthHost) { |
| + if len(required) == 0 || e.Schema != 1 || e.Source != "direct-live" || e.RunID == "" || e.LauncherVersion != LauncherVersion || e.BwrapVersion != "0.11.0" || e.PolicyVersion != PolicyVersion || !liveDigest(e.PolicyHash) || !liveDigest(e.ConfigSHA256) || e.AccountID == "" || e.HomeID == "" || e.Model == "" || e.AuthHost != "" { |
| return ErrPolicy |
| } |
| version := map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[e.Provider] |
diff --git a/internal/runner/provider/direct_certification_test.go b/internal/runner/provider/direct_certification_test.go| index 38d628ec..08391cd7 100644 |
| --- a/internal/runner/provider/direct_certification_test.go |
| +++ b/internal/runner/provider/direct_certification_test.go |
| @@ -30,7 +30,7 @@ func directEvidenceFixture(t *testing.T) (DirectEvidence, string) { |
| t.Fatal(err) |
| } |
| observation := LiveObservation{Status: "pass", Artifact: "capture.json", SHA256: DigestDirectEvidence(raw), Detail: "synthetic unit-test fixture"} |
| - e := DirectEvidence{Artifacts: map[string]string{"capture.json": DigestDirectEvidence(raw)}, Schema: 1, Source: "direct-live", RunID: "fixture", Provider: "codex", ProviderVersion: "0.165.0", LauncherVersion: LauncherVersion, BwrapVersion: "0.11.0", PolicyVersion: PolicyVersion, PolicyHash: strings.Repeat("a", 64), AccountID: "fixture", HomeID: "fixture", Model: "fixture", AuthHost: "auth.example.com", ConfigSHA256: strings.Repeat("b", 64), Binaries: map[string]string{}, Checks: map[string]LiveObservation{}, Usage: []LiveUsage{{Input: 1, Output: 1, Complete: true}}, Funding: LiveFunding{Calls: 1, InputTokens: 1000, OutputTokens: 1000, Seconds: 60, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}, CodexPolicy: &LiveCodexPolicy{ApprovalPolicy: "on-request", ApprovalsReviewer: "user", StrictConfig: true, DenyProfile: true}} |
| + e := DirectEvidence{Artifacts: map[string]string{"capture.json": DigestDirectEvidence(raw)}, Schema: 1, Source: "direct-live", RunID: "fixture", Provider: "codex", ProviderVersion: "0.165.0", LauncherVersion: LauncherVersion, BwrapVersion: "0.11.0", PolicyVersion: PolicyVersion, PolicyHash: strings.Repeat("a", 64), AccountID: "fixture", HomeID: "fixture", Model: "fixture", AuthHost: "", ConfigSHA256: strings.Repeat("b", 64), Binaries: map[string]string{}, Checks: map[string]LiveObservation{}, Usage: []LiveUsage{{Input: 1, Output: 1, Complete: true}}, Funding: LiveFunding{Calls: 1, InputTokens: 1000, OutputTokens: 1000, Seconds: 60, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}, CodexPolicy: &LiveCodexPolicy{ApprovalPolicy: "on-request", ApprovalsReviewer: "user", StrictConfig: true, DenyProfile: true}} |
| for _, name := range []string{"claude", "codex", "codex-code-mode-host", "bwrap", "runner", "equipo-tool-proxy"} { |
| e.Binaries[name] = strings.Repeat("c", 64) |
| } |
diff --git a/internal/runner/provider/direct_live_config.go b/internal/runner/provider/direct_live_config.go| index be1ae303..2a0c04b7 100644 |
| --- a/internal/runner/provider/direct_live_config.go |
| +++ b/internal/runner/provider/direct_live_config.go |
| @@ -12,6 +12,7 @@ import ( |
| // DirectLiveConfig is an explicit, operator-owned input to certification. It is |
| // never populated by discovering logins or by reading interactive CLI config. |
| type DirectLiveConfig struct { |
| + AccountChange *Binding `json:"account_change,omitempty"` |
| RunID string `json:"run_id"` |
| Repository string `json:"repository"` |
| Disposable bool `json:"disposable"` |
| @@ -88,7 +89,7 @@ func (c DirectLiveConfig) Validate(enabled string) error { |
| for _, entry := range c.Bindings { |
| b := entry.Binding |
| version := map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[b.Provider] |
| - if version == "" || seen[b.Provider] || b.ID == "" || b.AccountID == "" || b.Expected.AccountID != b.AccountID || b.Expected.HomeID == "" || b.Expected.ProviderVersion != version || entry.Model == "" || (entry.AuthHost != "" && !liveAuthHost(entry.AuthHost)) || (b.Provider == "claude" && !entry.ClaudeTOFUConfirmed) { |
| + if version == "" || seen[b.Provider] || b.ID == "" || b.AccountID == "" || b.Expected.AccountID != b.AccountID || b.Expected.HomeID == "" || b.Expected.ProviderVersion != version || entry.Model == "" || entry.AuthHost != "" || (b.Provider == "claude" && !entry.ClaudeTOFUConfirmed) { |
| return ErrIdentity |
| } |
| seen[b.Provider] = true |
| @@ -107,6 +108,28 @@ func (c DirectLiveConfig) Validate(enabled string) error { |
| return ErrPolicy |
| } |
| } |
| + if c.AccountChange != nil { |
| + b := *c.AccountChange |
| + if b.Provider != "claude" || b.ID == "" || b.AccountID == "" || b.Expected.AccountID != b.AccountID || b.Expected.HomeID == "" || b.Expected.ProviderVersion != "2.1.312" { |
| + return ErrIdentity |
| + } |
| + for _, primary := range c.Bindings { |
| + if primary.Binding.Provider == "claude" && (primary.Binding.AccountID == b.AccountID || primary.Binding.Expected.HomeID == b.Expected.HomeID) { |
| + return ErrIdentity |
| + } |
| + } |
| + f, err := pinDirectory(b.Home) |
| + if err != nil { |
| + return err |
| + } |
| + info, err := f.Stat() |
| + private := privateDirectory(f) |
| + f.Close() |
| + if err != nil || !private || !liveHomeAllowed(b.Home, info, rules) { |
| + return ErrPolicy |
| + } |
| + roots = append(roots, b.Home) |
| + } |
| for i, a := range roots { |
| for _, b := range roots[i+1:] { |
| if withinPath(a, b) || withinPath(b, a) { |
diff --git a/internal/runner/provider/direct_live_config_test.go b/internal/runner/provider/direct_live_config_test.go| index 5769e0ce..2909c667 100644 |
| --- a/internal/runner/provider/direct_live_config_test.go |
| +++ b/internal/runner/provider/direct_live_config_test.go |
| @@ -22,7 +22,7 @@ func liveConfigFixture(t *testing.T) DirectLiveConfig { |
| } |
| c := DirectLiveConfig{Repository: dirs["repo"], Disposable: true, EvidenceDir: dirs["evidence"], RunID: "offline-fixture", Origin: "http://127.0.0.1:1234", MachineFingerprint: "fixture-machine", Funding: LiveFunding{Calls: 32, InputTokens: 100000, OutputTokens: 100000, Seconds: 120, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}, Sentinels: map[string]string{}} |
| for _, p := range []string{"claude", "codex"} { |
| - c.Bindings = append(c.Bindings, DirectLiveBinding{Binding: Binding{ID: p, Provider: p, AccountID: p + "-account", Home: dirs[p], Expected: Identity{AccountID: p + "-account", HomeID: p + "-home", ProviderVersion: map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[p]}}, Model: p + "-model", AuthHost: map[string]string{"claude": "platform.claude.com", "codex": "auth.openai.com"}[p], ClaudeTOFUConfirmed: p == "claude"}) |
| + c.Bindings = append(c.Bindings, DirectLiveBinding{Binding: Binding{ID: p, Provider: p, AccountID: p + "-account", Home: dirs[p], Expected: Identity{AccountID: p + "-account", HomeID: p + "-home", ProviderVersion: map[string]string{"claude": "2.1.312", "codex": "0.165.0"}[p]}}, Model: p + "-model", AuthHost: "", ClaudeTOFUConfirmed: p == "claude"}) |
| } |
| for _, name := range []string{"claude", "codex", "other", "state", "repo"} { |
| path := filepath.Join(dirs[name], "sentinel.txt") |
diff --git a/internal/runner/provider/direct_requirements.json b/internal/runner/provider/direct_requirements.json| index 042d32c8..51de69d7 100644 |
| --- a/internal/runner/provider/direct_requirements.json |
| +++ b/internal/runner/provider/direct_requirements.json |
| @@ -10,9 +10,8 @@ |
| "immutable-settings", "strict-mcp", "exact-tool-inventory", "no-hooks-plugins", |
| "equipo-broker-approval", "person-native-approval", "real-question-answer", |
| "stale-broker-denied", "invalid-broker-denied", "policy-escalation-denied", |
| - "refresh-success-pinned-host", "refresh-failure-unavailable", |
| "same-identity-generation-fresh-preflight-bind", "same-identity-continued-availability", |
| - "changed-identity-stops-step", "refresh-dedicated-home-only" |
| + "changed-identity-stops-step" |
| ], |
| "Isolation": [ |
| "workspace-positive-control", "private-network", "host-loopback-denied", |
diff --git a/internal/runner/provider/expiry.go b/internal/runner/provider/expiry.go| new file mode 100644 |
| index 00000000..2d8cc15f |
| --- /dev/null |
| +++ b/internal/runner/provider/expiry.go |
| @@ -0,0 +1,38 @@ |
| +package provider |
| + |
| +import ( |
| + "encoding/base64" |
| + "encoding/json" |
| + "strings" |
| + "time" |
| +) |
| + |
| +// Expiry is read in memory and never included in evidence or diagnostics. |
| +func credentialsExpired(raw []byte, now time.Time) bool { |
| + var v struct { |
| + Claude struct { |
| + ExpiresAt int64 `json:"expiresAt"` |
| + } `json:"claudeAiOauth"` |
| + Tokens struct { |
| + Access string `json:"access_token"` |
| + } `json:"tokens"` |
| + } |
| + if json.Unmarshal(raw, &v) != nil { |
| + return false |
| + } |
| + if v.Claude.ExpiresAt > 0 && v.Claude.ExpiresAt <= now.UnixMilli() { |
| + return true |
| + } |
| + parts := strings.Split(v.Tokens.Access, ".") |
| + if len(parts) != 3 { |
| + return false |
| + } |
| + data, err := base64.RawURLEncoding.DecodeString(parts[1]) |
| + if err != nil { |
| + return false |
| + } |
| + var claims struct { |
| + Exp int64 `json:"exp"` |
| + } |
| + return json.Unmarshal(data, &claims) == nil && claims.Exp > 0 && claims.Exp <= now.Unix() |
| +} |
diff --git a/internal/runner/provider/expiry_test.go b/internal/runner/provider/expiry_test.go| new file mode 100644 |
| index 00000000..d3fa46d2 |
| --- /dev/null |
| +++ b/internal/runner/provider/expiry_test.go |
| @@ -0,0 +1,44 @@ |
| +package provider |
| + |
| +import ( |
| + "context" |
| + "encoding/base64" |
| + "encoding/json" |
| + "errors" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +func TestExpiredCredentialsNeedSignIn(t *testing.T) { |
| + for _, raw := range []string{`{"claudeAiOauth":{"expiresAt":1}}`, expiredLoginFixture()} { |
| + if !credentialsExpired([]byte(raw), time.Now()) { |
| + t.Fatal("expired token not detected") |
| + } |
| + } |
| + if credentialsExpired([]byte(`{"claudeAiOauth":{"expiresAt":4102444800000}}`), time.Now()) { |
| + t.Fatal("valid token expired") |
| + } |
| +} |
| + |
| +func TestExpiredLeaseRefusesDispatch(t *testing.T) { |
| + b, r := accountFixture(t) |
| + lease := openFixture(t, b, r) |
| + preflightFixture(t, lease) |
| + writeFake(t, filepath.Join(b.Home, "auth.json"), expiredLoginFixture()) |
| + if err := lease.BeginTurn(context.Background()); !errors.Is(err, ErrAccountMaintenance) { |
| + t.Fatal("expired account did not require maintenance", err) |
| + } |
| + if _, err := openAccount(context.Background(), b, r); !errors.Is(err, ErrAccountBusy) { |
| + t.Fatal("active account lock lost", err) |
| + } |
| +} |
| + |
| +// Construct an unsigned expired fixture in memory, without a token literal. |
| +func expiredLoginFixture() string { |
| + claims := base64.RawURLEncoding.EncodeToString([]byte(`{"exp":1}`)) |
| + token := strings.Join([]string{"e30", claims, "fixture"}, ".") |
| + raw, _ := json.Marshal(map[string]any{"tokens": map[string]string{"access_token": token}}) |
| + return string(raw) |
| +} |
diff --git a/internal/runner/provider/login.go b/internal/runner/provider/login.go| index 2dd8c969..e4ba39c9 100644 |
| --- a/internal/runner/provider/login.go |
| +++ b/internal/runner/provider/login.go |
| @@ -39,3 +39,21 @@ func NewLoginHome(root string) (string, error) { |
| } |
| return os.MkdirTemp(root, "account-") |
| } |
| + |
| +// CheckLoginHome checks source ownership and aliases without reading a login. |
| +func CheckLoginHome(home string) error { |
| + rules := DefaultHomeRules() |
| + if rules.RefusesPath(home) || refusedMountAlias(home, rules) { |
| + return ErrPolicy |
| + } |
| + dir, err := pinDirectory(home) |
| + if err != nil { |
| + return err |
| + } |
| + defer dir.Close() |
| + info, err := dir.Stat() |
| + if err != nil || !privateDirectory(dir) || rules.refusedInode(info) { |
| + return ErrPolicy |
| + } |
| + return nil |
| +} |
diff --git a/internal/runner/provider/login_probe.go b/internal/runner/provider/login_probe.go| index 56ae2ae0..f8ed6fbf 100644 |
| --- a/internal/runner/provider/login_probe.go |
| +++ b/internal/runner/provider/login_probe.go |
| @@ -69,22 +69,31 @@ func (d *terminalLoginDriver) Probe(ctx context.Context, b Binding) (Identity, e |
| if json.NewEncoder(in).Encode(map[string]any{"id": id, "method": method, "params": params}) != nil { |
| return nil, ErrIdentity |
| } |
| - if !scan.Scan() { |
| - return nil, ErrIdentity |
| - } |
| - raw, err := canonical(scan.Bytes()) |
| - if err != nil { |
| - return nil, ErrIdentity |
| - } |
| - var r struct { |
| - ID string |
| - Result json.RawMessage |
| - Error json.RawMessage |
| - } |
| - if json.Unmarshal(raw, &r) != nil || r.ID != id || len(r.Error) != 0 { |
| - return nil, ErrIdentity |
| + for frames := 0; frames < 64; frames++ { |
| + if !scan.Scan() { |
| + return nil, ErrIdentity |
| + } |
| + raw, err := canonical(scan.Bytes()) |
| + if err != nil { |
| + return nil, ErrIdentity |
| + } |
| + var r struct { |
| + ID, Method string |
| + Result, Error json.RawMessage |
| + } |
| + if json.Unmarshal(raw, &r) != nil { |
| + return nil, ErrIdentity |
| + } |
| + // Recorded 0.165.0 startup notification can precede initialize. |
| + if r.ID == "" && r.Method == "remoteControl/status/changed" && len(r.Error) == 0 { |
| + continue |
| + } |
| + if r.ID != id || r.Method != "" || len(r.Error) != 0 { |
| + return nil, ErrIdentity |
| + } |
| + return r.Result, nil |
| } |
| - return r.Result, nil |
| + return nil, ErrIdentity |
| } |
| raw, err := call("1", "initialize", map[string]any{"clientInfo": map[string]string{"name": "equipo", "version": "2"}, "capabilities": map[string]bool{"experimentalApi": true}}) |
| var init struct{ UserAgent, CodexHome string } |
diff --git a/internal/runner/residual_outcome_test.go b/internal/runner/residual_outcome_test.go| index b6f915d1..3ffd1b44 100644 |
| --- a/internal/runner/residual_outcome_test.go |
| +++ b/internal/runner/residual_outcome_test.go |
| @@ -28,6 +28,7 @@ func TestDeterministicAttemptErrorsFailWithReason(t *testing.T) { |
| reason string |
| }{ |
| {context.Canceled, "runner.cancelled"}, {context.DeadlineExceeded, "runner.timeout"}, |
| + {provider.ErrAccountMaintenance, "account.sign_in_again"}, |
| {provider.ErrIdentity, "runner.identity"}, {ErrPromptTooLarge, "runner.prompt_too_large"}, |
| {team.ErrEvidence, "runner.evidence"}, {team.ErrQuota, "runner.quota"}, |
| {team.ErrBudget, "runner.budget"}, {team.ErrReplayUnsafe, "runner.replay"}, |
diff --git a/internal/runner/runtime_direct.go b/internal/runner/runtime_direct.go| index 19ac30b4..bd9534bf 100644 |
| --- a/internal/runner/runtime_direct.go |
| +++ b/internal/runner/runtime_direct.go |
| @@ -143,6 +143,9 @@ func (r *Runtime) discoverNamespaces(ctx context.Context) ([]runnerproto.Connect |
| } |
| } |
| } |
| + if errors.Is(err, provider.ErrAccountMaintenance) { |
| + report.UnavailableReason = "account.sign_in_again" |
| + } |
| if cleanup != nil { |
| if e := cleanup(); e != nil { |
| return nil, e |
diff --git a/internal/runner/setup/install_test.go b/internal/runner/setup/install_test.go| index 3f3b36b9..d4384759 100644 |
| --- a/internal/runner/setup/install_test.go |
| +++ b/internal/runner/setup/install_test.go |
| @@ -23,7 +23,7 @@ func installFixture(t *testing.T) (InstallOptions, installHost, *int) { |
| m.Release.UncertifiedPolicies = nil |
| m.Release.LiveGateCopyReviewed = true |
| hash := strings.Repeat("a", 64) |
| - m.Release.DirectPolicies = []release.PolicyCertificate{{Provider: "codex", ProviderVersion: m.Release.Codex, LauncherVersion: m.Release.LauncherVersion, BwrapVersion: "0.11.0", PolicyHash: hash, CertifiedRefresh: release.CertifiedRefresh{AuthHost: "auth.openai.com", EvidenceSHA256: hash}}} |
| + m.Release.DirectPolicies = []release.PolicyCertificate{{Provider: "codex", ProviderVersion: m.Release.Codex, LauncherVersion: m.Release.LauncherVersion, BwrapVersion: "0.11.0", PolicyHash: hash, NoRefreshReason: "v1 requires sign-in again"}} |
| m.Release.Certifications = []release.Certification{{Provider: "codex", PolicyHash: hash, Path: "fixture.json", SHA256: hash}} |
| raw, err := json.Marshal(m) |
| if err != nil { |
diff --git a/internal/tryequipo/accounts.go b/internal/tryequipo/accounts.go| new file mode 100644 |
| index 00000000..e0c0f04d |
| --- /dev/null |
| +++ b/internal/tryequipo/accounts.go |
| @@ -0,0 +1,116 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "context" |
| + "crypto/rand" |
| + "encoding/json" |
| + "fmt" |
| + "golang.org/x/sys/unix" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + |
| + "amadan.net/oficina/equipo/internal/directlive" |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +func (w *Wizard) account(ctx context.Context, key, family, binary string) (provider.Binding, error) { |
| + h := w.State.Homes[key] |
| + if h.Path == "" { |
| + home, err := provider.NewLoginHome(w.Accounts) |
| + if err != nil { |
| + return provider.Binding{}, err |
| + } |
| + h.Path = home |
| + w.State.Homes[key] = h |
| + if err = w.save(); err != nil { |
| + return provider.Binding{}, err |
| + } |
| + } |
| + if !strings.HasPrefix(h.Path, w.Accounts+string(os.PathSeparator)) || provider.DefaultHomeRules().RefusesPath(h.Path) { |
| + return provider.Binding{}, provider.ErrPolicy |
| + } |
| + if err := privateDir(h.Path); err != nil { |
| + return provider.Binding{}, err |
| + } |
| + if err := provider.CheckLoginHome(h.Path); err != nil { |
| + return provider.Binding{}, err |
| + } |
| + lock, err := os.Open(h.Path) |
| + if err != nil { |
| + return provider.Binding{}, err |
| + } |
| + defer lock.Close() |
| + if err = unix.Flock(int(lock.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil { |
| + return provider.Binding{}, provider.ErrAccountBusy |
| + } |
| + if err := directlive.RestoreStagedSources(h.Path); err != nil { |
| + return provider.Binding{}, err |
| + } |
| + options := provider.LoginOptions{ClaudePath: binary, CodexPath: binary} |
| + probe := provider.NewLoginDriver(options).(interface { |
| + Probe(context.Context, provider.Binding) (provider.Identity, error) |
| + }) |
| + b := provider.Binding{ID: key, Home: h.Path, Provider: family} |
| + id, err := probe.Probe(ctx, b) |
| + if err != nil { |
| + fmt.Fprintf(w.Output, equipo.TryText("login"), key) |
| + args := []string{"auth", "login"} |
| + if family == "codex" { |
| + args = []string{"login"} |
| + } |
| + // The official CLI opens the browser. Its output is never copied to logs. |
| + env := provider.LoginEnvironment(family, h.Path) |
| + for _, key := range []string{"BROWSER", "DISPLAY", "WAYLAND_DISPLAY", "XDG_RUNTIME_DIR", "DBUS_SESSION_BUS_ADDRESS"} { |
| + if v := os.Getenv(key); v != "" { |
| + env = append(env, key+"="+v) |
| + } |
| + } |
| + if _, err = command(ctx, binary, args, h.Path, env, w.LoginInput); err != nil { |
| + return b, provider.ErrLoginUnavailable |
| + } |
| + id, err = probe.Probe(ctx, b) |
| + if err != nil { |
| + return b, err |
| + } |
| + } |
| + if strings.ContainsAny(id.AccountID, "\r\n\x1b") { |
| + return b, provider.ErrIdentity |
| + } |
| + if h.Identity.AccountID != "" { |
| + if id.AccountID != h.Identity.AccountID || id.ProviderVersion != h.Identity.ProviderVersion { |
| + return b, provider.ErrIdentity |
| + } |
| + } else { |
| + fmt.Fprintf(w.Output, equipo.TryText("confirm"), key, id.AccountID) |
| + answer, err := w.reader.ReadString('\n') |
| + if err != nil { |
| + return b, err |
| + } |
| + if strings.TrimSpace(answer) != "yes" { |
| + return b, provider.ErrIdentity |
| + } |
| + id.HomeID = rand.Text() |
| + h.Identity = id |
| + w.State.Homes[key] = h |
| + if err = w.save(); err != nil { |
| + return b, err |
| + } |
| + } |
| + marker := filepath.Join(h.Path, provider.IdentityFile) |
| + if raw, err := os.ReadFile(marker); err == nil { |
| + var existing provider.Identity |
| + if json.Unmarshal(raw, &existing) != nil || existing != h.Identity { |
| + return b, provider.ErrIdentity |
| + } |
| + } else if !os.IsNotExist(err) { |
| + return b, err |
| + } |
| + if err = writeJSON(marker, h.Identity); err != nil { |
| + return b, err |
| + } |
| + b.Expected = h.Identity |
| + b.AccountID = h.Identity.AccountID |
| + return b, nil |
| +} |
diff --git a/internal/tryequipo/accounts_test.go b/internal/tryequipo/accounts_test.go| new file mode 100644 |
| index 00000000..4d73ab41 |
| --- /dev/null |
| +++ b/internal/tryequipo/accounts_test.go |
| @@ -0,0 +1,195 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + "testing" |
| + |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +func TestAccountResumeAndMismatch(t *testing.T) { |
| + root := t.TempDir() |
| + if err := os.Chmod(root, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + home := filepath.Join(root, "accounts") |
| + if err := os.Mkdir(home, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + binary := filepath.Join(root, "claude") |
| + script := `#!/bin/sh |
| +case "$*" in |
| + '--version') echo '2.1.312 (Claude Code)';; |
| + 'auth login --help') exit 0;; |
| + 'auth login') printf '%s' '{"fixture":true}' > "$CLAUDE_CONFIG_DIR/.credentials.json"; chmod 600 "$CLAUDE_CONFIG_DIR/.credentials.json"; echo 'https://secret.invalid/token';; |
| + 'auth status --json') test -f "$CLAUDE_CONFIG_DIR/.credentials.json" || exit 1; printf '%s' '{"loggedIn":true,"authMethod":"claude.ai","email":"fixture@example.invalid"}';; |
| + *) exit 1;; |
| +esac |
| +` |
| + if err := os.WriteFile(binary, []byte(script), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + var out bytes.Buffer |
| + w := Wizard{Root: root, Accounts: home, Input: strings.NewReader("yes\n"), Output: &out, State: State{Homes: map[string]Home{}, Values: map[string]string{}}} |
| + w.init() |
| + // Interrupted confirmation keeps the signed-in dedicated home for a rerun. |
| + w.reader.Reset(strings.NewReader("")) |
| + if _, err := w.account(context.Background(), "claude-a", "claude", binary); err == nil { |
| + t.Fatal("missing confirmation accepted") |
| + } |
| + if err := w.load(); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.reader.Reset(strings.NewReader("yes\n")) |
| + b, err := w.account(context.Background(), "claude-a", "claude", binary) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + w.reader.Reset(strings.NewReader("")) |
| + b2, err := w.account(context.Background(), "claude-a", "claude", binary) |
| + if err != nil || b2.Home != b.Home { |
| + t.Fatal(b2, err) |
| + } |
| + // A saved account can sign in again after its native login has expired. |
| + if err := os.Remove(filepath.Join(b.Home, ".credentials.json")); err != nil { |
| + t.Fatal(err) |
| + } |
| + renewed, err := w.account(context.Background(), "claude-a", "claude", binary) |
| + if err != nil || renewed.Home != b.Home || renewed.Expected != b.Expected { |
| + t.Fatal("saved account could not sign in again", err) |
| + } |
| + if err := os.WriteFile(binary, []byte(strings.ReplaceAll(script, "fixture@example.invalid", "other@example.invalid")), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + if _, err = w.account(context.Background(), "claude-a", "claude", binary); err == nil { |
| + t.Fatal("identity mismatch accepted") |
| + } |
| + if strings.Contains(out.String(), "secret.invalid") { |
| + t.Fatal("login output leaked") |
| + } |
| +} |
| +func TestRefuseInteractiveHome(t *testing.T) { |
| + root := t.TempDir() |
| + if err := os.Chmod(root, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + home := filepath.Join(root, "interactive") |
| + if err := os.Mkdir(home, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Setenv("CLAUDE_CONFIG_DIR", home) |
| + binary := filepath.Join(root, "probe") |
| + called := filepath.Join(root, "called") |
| + if err := os.WriteFile(binary, []byte("#!/bin/sh\ntouch '"+called+"'\nexit 1\n"), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + w := Wizard{Root: root, Accounts: root, Input: strings.NewReader(""), Output: &bytes.Buffer{}, State: State{Homes: map[string]Home{"claude-a": {Path: home, Identity: provider.Identity{}}}}} |
| + w.init() |
| + if _, err := w.account(context.Background(), "claude-a", "claude", binary); err == nil { |
| + t.Fatal("interactive home adopted") |
| + } |
| + if _, err := os.Stat(called); !os.IsNotExist(err) { |
| + t.Fatal("provider ran against interactive home") |
| + } |
| +} |
| + |
| +func TestCodexAccountOfficialFlow(t *testing.T) { |
| + root := t.TempDir() |
| + if err := os.Chmod(root, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + accounts := filepath.Join(root, "accounts") |
| + if err := os.Mkdir(accounts, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + binary := filepath.Join(root, "codex") |
| + script := `#!/usr/bin/python3 |
| +import json,os,sys |
| +home=os.environ['CODEX_HOME'] |
| +assert home==os.environ['HOME'] |
| +assert 'OPENAI_API_KEY' not in os.environ |
| +if sys.argv[1:] == ['--version']: print('codex-cli 0.165.0') |
| +elif '--help' in sys.argv: pass |
| +elif sys.argv[1:] == ['login']: |
| + with open(home+'/auth.json','w') as f: f.write('{"fixture":true}') |
| + os.chmod(home+'/auth.json',0o600) |
| + print('https://secret.invalid/token') |
| +elif sys.argv[1] == 'app-server': |
| + for line in sys.stdin: |
| + q=json.loads(line) |
| + if 'id' not in q: continue |
| + if q['method']=='initialize': |
| + print(json.dumps({'method':'remoteControl/status/changed','params':{}}),flush=True) |
| + r={'userAgent':'equipo/0.165.0 fixture','codexHome':home} |
| + elif q['method']=='account/read': |
| + assert q['params']=={'refreshToken':False} |
| + r={'account': {'type':'chatgpt','email':'codex@example.invalid'} if os.path.exists(home+'/auth.json') else None} |
| + else: sys.exit(2) |
| + print(json.dumps({'id':q['id'],'result':r}),flush=True) |
| +else: sys.exit(2) |
| +` |
| + if err := os.WriteFile(binary, []byte(script), 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + t.Setenv("OPENAI_API_KEY", "must-not-be-inherited") |
| + var out bytes.Buffer |
| + w := Wizard{Root: root, Accounts: accounts, Input: strings.NewReader("yes\n"), Output: &out} |
| + w.init() |
| + b, err := w.account(context.Background(), "codex", "codex", binary) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if b.AccountID != "codex@example.invalid" { |
| + t.Fatal(b.AccountID) |
| + } |
| + if strings.Contains(out.String(), "secret.invalid") { |
| + t.Fatal("login output leaked") |
| + } |
| + for _, name := range []string{"state.json", filepath.Join("accounts", filepath.Base(b.Home), provider.IdentityFile)} { |
| + st, err := os.Stat(filepath.Join(root, name)) |
| + if err != nil || st.Mode().Perm() != 0600 { |
| + t.Fatal(name, err) |
| + } |
| + } |
| +} |
| + |
| +func TestResumeInterruptedConfigurationWrite(t *testing.T) { |
| + root := t.TempDir() |
| + if err := os.Chmod(root, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + path := filepath.Join(root, "generated.json") |
| + w := Wizard{Root: root, Input: strings.NewReader(""), Output: &bytes.Buffer{}} |
| + w.init() |
| + prior := []byte("interrupted replacement") |
| + if err := privateWrite(path, prior); err != nil { |
| + t.Fatal(err) |
| + } |
| + w.State.Values["file:"+path+":pending"] = provider.DigestDirectEvidence(prior) |
| + if err := w.ownedWrite(path, []byte("resumed")); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := os.WriteFile(path, []byte("foreign edit"), 0600); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := w.ownedWrite(path, []byte("must not overwrite")); err == nil { |
| + t.Fatal("foreign configuration overwritten") |
| + } |
| +} |
| + |
| +func TestSavedSetupValueCanBeCorrected(t *testing.T) { |
| + root := t.TempDir() |
| + if err := os.Chmod(root, 0700); err != nil { |
| + t.Fatal(err) |
| + } |
| + w := Wizard{Root: root, Input: strings.NewReader("/corrected/path\n"), Output: &bytes.Buffer{}, State: State{Values: map[string]string{"forge": "/mistyped/path"}}} |
| + w.init() |
| + got, err := w.value("forge", "") |
| + if err != nil || got != "/corrected/path" { |
| + t.Fatal("saved input cannot be corrected on rerun", got, err) |
| + } |
| +} |
diff --git a/internal/tryequipo/budget_test.go b/internal/tryequipo/budget_test.go| new file mode 100644 |
| index 00000000..c28574de |
| --- /dev/null |
| +++ b/internal/tryequipo/budget_test.go |
| @@ -0,0 +1,9 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "amadan.net/rastrillo/rastrillo/budget" |
| + "os" |
| + "testing" |
| +) |
| + |
| +func TestMain(m *testing.M) { os.Exit(budget.Main(m)) } |
diff --git a/internal/tryequipo/command.go b/internal/tryequipo/command.go| new file mode 100644 |
| index 00000000..31fb1c4c |
| --- /dev/null |
| +++ b/internal/tryequipo/command.go |
| @@ -0,0 +1,32 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "bytes" |
| + "context" |
| + "io" |
| + "os/exec" |
| + "syscall" |
| + "time" |
| +) |
| + |
| +type boundedOutput struct{ bytes.Buffer } |
| + |
| +func (b *boundedOutput) Write(p []byte) (int, error) { |
| + if b.Len()+len(p) > 1<<20 { |
| + return 0, io.ErrShortBuffer |
| + } |
| + return b.Buffer.Write(p) |
| +} |
| +func command(ctx context.Context, path string, args []string, dir string, env []string, input io.Reader) ([]byte, error) { |
| + cmd := exec.CommandContext(ctx, path, args...) |
| + cmd.Dir = dir |
| + cmd.Env = env |
| + cmd.Stdin = input |
| + out := &boundedOutput{} |
| + cmd.Stdout = out |
| + cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true} |
| + cmd.Cancel = func() error { return syscall.Kill(-cmd.Process.Pid, syscall.SIGTERM) } |
| + cmd.WaitDelay = 2 * time.Second |
| + err := cmd.Run() |
| + return out.Bytes(), err |
| +} |
diff --git a/internal/tryequipo/config.go b/internal/tryequipo/config.go| new file mode 100644 |
| index 00000000..a8a54a86 |
| --- /dev/null |
| +++ b/internal/tryequipo/config.go |
| @@ -0,0 +1,66 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "context" |
| + "encoding/json" |
| + "os" |
| + "path/filepath" |
| +) |
| + |
| +func jsonBytes(v any) ([]byte, error) { return json.MarshalIndent(v, "", " ") } |
| +func (w *Wizard) build(ctx context.Context, paths map[string]string) error { |
| + dir := filepath.Join(w.Root, "bin") |
| + if err := privateDir(dir); err != nil { |
| + return err |
| + } |
| + for _, name := range []string{"equipo-runner", "equipo-tool-proxy"} { |
| + path := filepath.Join(dir, name) |
| + args := []string{"build", "-trimpath", "-buildvcs=false", "-ldflags", "-s -w", "-o", path} |
| + if name == "equipo-runner" { |
| + args = append(args, "-tags", "direct_live") |
| + } |
| + args = append(args, "./cmd/"+name) |
| + env := append(os.Environ(), "CGO_ENABLED=0", "GOOS=linux", "GOARCH=amd64") |
| + if _, err := command(ctx, paths["EQUIPO_GO_BINARY"], args, w.Repository, env, nil); err != nil { |
| + return err |
| + } |
| + key := "EQUIPO_TOOL_PROXY_PATH" |
| + if name == "equipo-runner" { |
| + key = "EQUIPO_RUNNER_EXECUTABLE" |
| + } |
| + paths[key] = path |
| + } |
| + return nil |
| +} |
| +func (w *Wizard) config(ctx context.Context, root string, paths map[string]string, bindings []provider.Binding, f provider.LiveFunding) (provider.DirectLiveConfig, error) { |
| + c := provider.DirectLiveConfig{RunID: filepath.Base(root), Disposable: true, Repository: filepath.Join(root, "repo"), EvidenceDir: filepath.Join(root, "evidence"), Origin: paths["EQUIPO_ORIGIN"], Funding: f, Sentinels: map[string]string{}} |
| + machine, err := os.ReadFile("/etc/machine-id") |
| + if err != nil { |
| + return c, err |
| + } |
| + c.MachineFingerprint = provider.DigestDirectEvidence(machine) |
| + for _, dir := range []string{c.Repository, c.EvidenceDir, filepath.Join(root, "other"), filepath.Join(root, "state")} { |
| + if err = privateDir(dir); err != nil { |
| + return c, err |
| + } |
| + } |
| + if _, err = command(ctx, paths["EQUIPO_GIT_PATH"], []string{"-c", "core.hooksPath=/dev/null", "init", c.Repository}, root, []string{"PATH=/usr/bin:/bin", "HOME=" + root, "GIT_CONFIG_NOSYSTEM=1", "GIT_CONFIG_GLOBAL=/dev/null"}, nil); err != nil { |
| + return c, err |
| + } |
| + for _, b := range []provider.Binding{bindings[0], bindings[2]} { |
| + c.Bindings = append(c.Bindings, provider.DirectLiveBinding{Binding: b, Model: w.State.Values[b.Provider+"-model"], ClaudeTOFUConfirmed: b.Provider == "claude"}) |
| + c.Sentinels[b.Provider] = filepath.Join(b.Home, "equipo-try-sentinel") |
| + } |
| + c.AccountChange = &bindings[1] |
| + c.Sentinels["claude-other"] = filepath.Join(bindings[1].Home, "equipo-try-sentinel") |
| + c.Sentinels["repo"] = filepath.Join(c.Repository, "sentinel") |
| + c.Sentinels["state"] = filepath.Join(root, "state/sentinel") |
| + c.Sentinels["other"] = filepath.Join(root, "other/sentinel") |
| + for _, p := range c.Sentinels { |
| + if err = w.ownedWrite(p, marker()); err != nil { |
| + return c, err |
| + } |
| + } |
| + return c, c.Validate("1") |
| +} |
diff --git a/internal/tryequipo/prerequisites.go b/internal/tryequipo/prerequisites.go| new file mode 100644 |
| index 00000000..f1a9023a |
| --- /dev/null |
| +++ b/internal/tryequipo/prerequisites.go |
| @@ -0,0 +1,84 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "context" |
| + "fmt" |
| + "os" |
| + "os/exec" |
| + "path/filepath" |
| + "strings" |
| + "time" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/provider/claude" |
| + "amadan.net/oficina/equipo/internal/runner/provider/codex" |
| +) |
| + |
| +func (w *Wizard) prerequisites(ctx context.Context) (map[string]string, error) { |
| + paths := map[string]string{} |
| + missing := false |
| + scratch, err := os.MkdirTemp(w.Root, "prerequisites-") |
| + if err != nil { |
| + return nil, err |
| + } |
| + defer os.RemoveAll(scratch) |
| + for _, d := range []struct{ Name, Variable, Version, Hash string }{ |
| + {"claude", "EQUIPO_CLAUDE_PATH", "2.1.312 (Claude Code)", claude.ExecutableSHA256}, |
| + {"codex", "EQUIPO_CODEX_PATH", "codex-cli 0.165.0", codex.ExecutableSHA256}, |
| + {"codex-code-mode-host", "EQUIPO_CODEX_CODE_MODE_HOST_PATH", "", codex.CodeModeHostSHA256}, |
| + {"bwrap", "EQUIPO_BWRAP_PATH", "bubblewrap 0.11.0", ""}, |
| + {"go", "EQUIPO_GO_BINARY", "", ""}, {"git", "EQUIPO_GIT_PATH", "", ""}, {"amadan", "EQUIPO_AMADAN_PATH", "", ""}, |
| + } { |
| + path := os.Getenv(d.Variable) |
| + if path == "" { |
| + path, err = exec.LookPath(d.Name) |
| + } |
| + if err == nil { |
| + path, err = filepath.EvalSymlinks(path) |
| + } |
| + if err == nil { |
| + path, err = filepath.Abs(path) |
| + } |
| + good := err == nil |
| + if good { |
| + st, e := os.Stat(path) |
| + good = e == nil && st.Mode().IsRegular() && st.Mode().Perm()&0111 != 0 |
| + } |
| + if good && d.Hash != "" { |
| + raw, e := os.ReadFile(path) |
| + good = e == nil && provider.DigestDirectEvidence(raw) == d.Hash |
| + } |
| + if good && d.Version != "" { |
| + child, cancel := context.WithTimeout(ctx, 5*time.Second) |
| + out, e := command(child, path, []string{"--version"}, scratch, provider.LoginEnvironment(d.Name, scratch), nil) |
| + cancel() |
| + good = e == nil && strings.TrimSpace(string(out)) == d.Version |
| + } |
| + if !good { |
| + missing = true |
| + fmt.Fprintf(w.Output, equipo.TryText("prerequisite"), d.Name+" "+d.Version+" ("+d.Variable+")") |
| + } else { |
| + paths[d.Variable] = path |
| + } |
| + err = nil |
| + } |
| + if b := paths["EQUIPO_BWRAP_PATH"]; b != "" { |
| + child, cancel := context.WithTimeout(ctx, 5*time.Second) |
| + _, err = command(child, b, []string{"--unshare-user", "--unshare-net", "--ro-bind", "/", "/", "--", "/bin/true"}, scratch, nil, nil) |
| + cancel() |
| + if err != nil { |
| + missing = true |
| + fmt.Fprintf(w.Output, equipo.TryText("prerequisite"), "unprivileged user namespaces") |
| + } |
| + } |
| + if missing { |
| + return nil, provider.ErrCapability |
| + } |
| + out, err := command(ctx, paths["EQUIPO_GO_BINARY"], []string{"env", "GOROOT"}, w.Repository, nil, nil) |
| + if err != nil { |
| + return nil, err |
| + } |
| + paths["EQUIPO_GO_ROOT"] = strings.TrimSpace(string(out)) |
| + return paths, nil |
| +} |
diff --git a/internal/tryequipo/run.go b/internal/tryequipo/run.go| new file mode 100644 |
| index 00000000..3a277628 |
| --- /dev/null |
| +++ b/internal/tryequipo/run.go |
| @@ -0,0 +1,260 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "context" |
| + "crypto/rand" |
| + "fmt" |
| + "os" |
| + "path/filepath" |
| + "sort" |
| + "strconv" |
| + "strings" |
| + |
| + "amadan.net/oficina/equipo/internal/directlive" |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + runnersetup "amadan.net/oficina/equipo/internal/runner/setup" |
| + "golang.org/x/sys/unix" |
| +) |
| + |
| +func (w *Wizard) Run(ctx context.Context) (err error) { |
| + w.init() |
| + w.phase = "prerequisites" |
| + defer func() { |
| + if err != nil { |
| + fmt.Fprintf(w.Output, equipo.TryText("failed"), w.phase) |
| + } |
| + }() |
| + if os.Geteuid() == 0 { |
| + return provider.ErrPolicy |
| + } |
| + if err = privateDir(w.Root); err != nil { |
| + return err |
| + } |
| + lock, err := os.OpenFile(filepath.Join(w.Root, "lock"), os.O_CREATE|os.O_RDWR|unix.O_NOFOLLOW, 0600) |
| + if err != nil { |
| + return err |
| + } |
| + defer lock.Close() |
| + if err = unix.Flock(int(lock.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil { |
| + return err |
| + } |
| + if err = w.load(); err != nil { |
| + return err |
| + } |
| + paths, err := w.prerequisites(ctx) |
| + if err != nil { |
| + return err |
| + } |
| + w.phase = "sign-in authorization" |
| + answer, err := w.ask("signin", "") |
| + if err != nil { |
| + return err |
| + } |
| + if answer != "SIGN IN" { |
| + return provider.ErrPolicy |
| + } |
| + var bindings []provider.Binding |
| + for _, spec := range [][2]string{{"claude-a", "claude"}, {"claude-b", "claude"}, {"codex", "codex"}} { |
| + w.phase = spec[0] |
| + variable := "EQUIPO_CLAUDE_PATH" |
| + if spec[1] == "codex" { |
| + variable = "EQUIPO_CODEX_PATH" |
| + } |
| + b, e := w.account(ctx, spec[0], spec[1], paths[variable]) |
| + if e != nil { |
| + return e |
| + } |
| + bindings = append(bindings, b) |
| + } |
| + if bindings[0].AccountID == bindings[1].AccountID { |
| + return provider.ErrIdentity |
| + } |
| + w.phase = "configuration" |
| + for _, key := range []string{"instance", "person", "claude-model", "codex-model", "forge"} { |
| + variable := map[string]string{"instance": "EQUIPO_INSTANCE_ID", "person": "EQUIPO_PERSON_ID", "claude-model": "EQUIPO_CLAUDE_MODEL", "codex-model": "EQUIPO_CODEX_MODEL", "forge": "EQUIPO_AMADAN_CREDENTIAL_PATH"}[key] |
| + if known := os.Getenv(variable); known != "" { |
| + w.State.Values[key] = known |
| + continue |
| + } |
| + if _, err = w.value(key, ""); err != nil { |
| + return err |
| + } |
| + } |
| + forge := w.State.Values["forge"] |
| + if !filepath.IsAbs(forge) { |
| + return provider.ErrPolicy |
| + } |
| + st, err := os.Lstat(forge) |
| + if err != nil || !st.Mode().IsRegular() || st.Mode().Perm() != 0600 { |
| + return provider.ErrPolicy |
| + } |
| + paths["EQUIPO_ORIGIN"] = "https://equipo.bds.oncarlos.com" |
| + paths["EQUIPO_INSTANCE_ID"] = w.State.Values["instance"] |
| + paths["EQUIPO_AMADAN_CREDENTIAL_PATH"] = forge |
| + home, err := os.UserHomeDir() |
| + if err != nil { |
| + return err |
| + } |
| + runnerRoot := filepath.Join(home, ".local/share/equipo-runner") |
| + for key, path := range map[string]string{ |
| + "EQUIPO_RUNNER_STATE_DIR": filepath.Join(runnerRoot, "state"), |
| + "EQUIPO_WORKSPACE_ROOT": filepath.Join(home, ".local/share/equipo/workspaces"), |
| + "EQUIPO_SCRATCH_ROOT": filepath.Join(home, ".local/share/equipo/scratch"), |
| + } { |
| + if err = privateDir(path); err != nil { |
| + return err |
| + } |
| + paths[key] = path |
| + } |
| + paths["EQUIPO_ACCOUNT_BINDINGS_PATH"] = filepath.Join(runnerRoot, "bindings.json") |
| + var rows []runnersetup.AccountBinding |
| + for _, b := range bindings { |
| + rows = append(rows, runnersetup.AccountBinding{ID: b.ID, LocalID: b.ID, Label: b.ID, PersonID: w.State.Values["person"], Provider: b.Provider, Family: map[string]string{"claude": "claude", "codex": "gpt"}[b.Provider], Model: w.State.Values[b.Provider+"-model"], AccountID: b.AccountID, ProviderHome: b.Home, ExpectedIdentity: b.Expected, Kind: "subscription"}) |
| + } |
| + if err = w.ownedJSON(paths["EQUIPO_ACCOUNT_BINDINGS_PATH"], rows); err != nil { |
| + return err |
| + } |
| + if err = w.build(ctx, paths); err != nil { |
| + return err |
| + } |
| + if w.State.Values["live_pending"] != "" { |
| + if err = directlive.ResumeInterrupted(ctx, directlive.EnvironmentPaths(func(k string) string { return paths[k] }), paths["EQUIPO_SCRATCH_ROOT"]); err != nil { |
| + return err |
| + } |
| + } |
| + envPath := filepath.Join(runnerRoot, "runner.env") |
| + var env strings.Builder |
| + keys := make([]string, 0, len(paths)) |
| + for k := range paths { |
| + keys = append(keys, k) |
| + } |
| + sort.Strings(keys) |
| + for _, k := range keys { |
| + if strings.ContainsAny(paths[k], "\r\n\x00\"\\`$") { |
| + return provider.ErrPolicy |
| + } |
| + fmt.Fprintf(&env, "%s=\"%s\"\n", k, paths[k]) |
| + } |
| + if err = w.ownedWrite(envPath, []byte(env.String())); err != nil { |
| + return err |
| + } |
| + w.phase = "calibration limits" |
| + funding, err := w.funding() |
| + if err != nil { |
| + return err |
| + } |
| + // A fresh evidence directory is required on every attempt. Confirmed accounts |
| + // and configuration survive interruption; incomplete evidence is never reused. |
| + runRoot, err := os.MkdirTemp(w.Root, "run-") |
| + if err != nil { |
| + return err |
| + } |
| + config, err := w.config(ctx, runRoot, paths, bindings, funding) |
| + if err != nil { |
| + return err |
| + } |
| + configPath := filepath.Join(runRoot, "direct-live.json") |
| + if err = writeJSON(configPath, config); err != nil { |
| + return err |
| + } |
| + w.phase = "live authorization" |
| + answer, err = w.ask("live", "") |
| + if err != nil { |
| + return err |
| + } |
| + if answer != "RUN LIVE GATE" { |
| + return provider.ErrPolicy |
| + } |
| + childEnv := append([]string{}, os.Environ()...) |
| + for k, v := range paths { |
| + childEnv = append(childEnv, k+"="+v) |
| + } |
| + childEnv = append(childEnv, "EQUIPO_LIVE_DIRECT=1", "EQUIPO_LIVE_CONFIG="+configPath, "CGO_ENABLED=0") |
| + w.phase = "live certification" |
| + w.State.Values["live_pending"] = config.RunID |
| + if err = w.save(); err != nil { |
| + return err |
| + } |
| + // Only sanitized test output is retained. The driver never records logins. |
| + out, err := command(ctx, paths["EQUIPO_GO_BINARY"], []string{"test", "-tags", "direct_live", "./internal/runner/provider", "-run", "^TestDirectLive(Contract|Isolation|Recovery|Calibration)$", "-count=1"}, w.Repository, childEnv, nil) |
| + if e := privateWrite(filepath.Join(runRoot, "gate.log"), out); e != nil { |
| + return e |
| + } |
| + if err != nil { |
| + fmt.Fprintln(w.Output, string(out)) |
| + return err |
| + } |
| + delete(w.State.Values, "live_pending") |
| + if err = w.save(); err != nil { |
| + return err |
| + } |
| + candidate := filepath.Join(config.EvidenceDir, "candidate-manifest.json") |
| + if _, err = os.Stat(candidate); err != nil { |
| + return err |
| + } |
| + fmt.Fprintf(w.Output, equipo.TryText("ready"), candidate, "set -a; . "+shellQuote(envPath)+"; set +a; make release release-runner") |
| + return nil |
| +} |
| +func shellQuote(s string) string { return "'" + strings.ReplaceAll(s, "'", "'\"'\"'") + "'" } |
| +func (w *Wizard) ownedJSON(path string, v any) error { |
| + raw, err := jsonBytes(v) |
| + if err != nil { |
| + return err |
| + } |
| + return w.ownedWrite(path, raw) |
| +} |
| +func (w *Wizard) ownedWrite(path string, raw []byte) error { |
| + key := "file:" + path |
| + if prior, err := os.ReadFile(path); err == nil { |
| + if string(prior) != string(raw) && provider.DigestDirectEvidence(prior) != w.State.Values[key] && provider.DigestDirectEvidence(prior) != w.State.Values[key+":pending"] { |
| + return provider.ErrPolicy |
| + } |
| + } else if !os.IsNotExist(err) { |
| + return err |
| + } |
| + w.State.Values[key+":pending"] = provider.DigestDirectEvidence(raw) |
| + if err := w.save(); err != nil { |
| + return err |
| + } |
| + if err := privateWrite(path, raw); err != nil { |
| + return err |
| + } |
| + delete(w.State.Values, key+":pending") |
| + w.State.Values[key] = provider.DigestDirectEvidence(raw) |
| + return w.save() |
| +} |
| +func (w *Wizard) funding() (provider.LiveFunding, error) { |
| + var f provider.LiveFunding |
| + entries := []struct { |
| + Key string |
| + Value *int64 |
| + Default int64 |
| + }{ |
| + {"Calls", &f.Calls, 500}, {"InputTokens", &f.InputTokens, 10000000}, {"OutputTokens", &f.OutputTokens, 1000000}, {"Seconds", &f.Seconds, 7200}, |
| + {"JobInput", &f.JobInput, 2300000}, {"JobOutput", &f.JobOutput, 230000}, {"ProjectInputHeadroom", &f.ProjectInputHeadroom, 2300000}, {"ProjectOutputHeadroom", &f.ProjectOutputHeadroom, 230000}, {"TeamInputHeadroom", &f.TeamInputHeadroom, 2300000}, {"TeamOutputHeadroom", &f.TeamOutputHeadroom, 230000}, |
| + } |
| + for _, e := range entries { |
| + def := strconv.FormatInt(e.Default, 10) |
| + if v := w.State.Values[e.Key]; v != "" { |
| + def = v |
| + } |
| + v, err := w.ask(e.Key, def) |
| + if err != nil { |
| + return f, err |
| + } |
| + n, err := strconv.ParseInt(v, 10, 64) |
| + if err != nil || n <= 0 { |
| + return f, provider.ErrPolicy |
| + } |
| + *e.Value = n |
| + w.State.Values[e.Key] = v |
| + } |
| + if f.Seconds > 86400 { |
| + return f, provider.ErrPolicy |
| + } |
| + raw, _ := jsonBytes(f) |
| + fmt.Fprintf(w.Output, equipo.TryText("limits"), raw) |
| + return f, w.save() |
| +} |
| +func marker() []byte { return []byte(rand.Text() + "\n") } |
diff --git a/internal/tryequipo/state.go b/internal/tryequipo/state.go| new file mode 100644 |
| index 00000000..e4fadfa9 |
| --- /dev/null |
| +++ b/internal/tryequipo/state.go |
| @@ -0,0 +1,148 @@ |
| +package tryequipo |
| + |
| +import ( |
| + "bufio" |
| + "encoding/json" |
| + "errors" |
| + "fmt" |
| + "io" |
| + "os" |
| + "path/filepath" |
| + "strings" |
| + |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| +) |
| + |
| +type Home struct { |
| + Path string |
| + Identity provider.Identity |
| +} |
| +type State struct { |
| + Homes map[string]Home |
| + Values map[string]string |
| +} |
| +type Wizard struct { |
| + LoginInput io.Reader |
| + Root, Accounts, Repository string |
| + Input io.Reader |
| + Output io.Writer |
| + State State |
| + reader *bufio.Reader |
| + phase string |
| +} |
| + |
| +func (w *Wizard) init() { |
| + w.reader = bufio.NewReader(w.Input) |
| + if w.State.Homes == nil { |
| + w.State.Homes = map[string]Home{} |
| + } |
| + if w.State.Values == nil { |
| + w.State.Values = map[string]string{} |
| + } |
| +} |
| +func (w *Wizard) load() error { |
| + path := filepath.Join(w.Root, "state.json") |
| + if st, err := os.Lstat(path); err == nil && (!st.Mode().IsRegular() || st.Mode().Perm() != 0600) { |
| + return provider.ErrPolicy |
| + } |
| + raw, err := os.ReadFile(path) |
| + if os.IsNotExist(err) { |
| + return nil |
| + } |
| + if err != nil { |
| + return err |
| + } |
| + if err = json.Unmarshal(raw, &w.State); err != nil { |
| + return err |
| + } |
| + if w.State.Homes == nil || w.State.Values == nil { |
| + return provider.ErrPolicy |
| + } |
| + return nil |
| +} |
| +func (w *Wizard) save() error { return writeJSON(filepath.Join(w.Root, "state.json"), w.State) } |
| +func writeJSON(path string, v any) error { |
| + raw, err := json.MarshalIndent(v, "", " ") |
| + if err != nil { |
| + return err |
| + } |
| + return privateWrite(path, append(raw, '\n')) |
| +} |
| +func privateDir(path string) error { |
| + if !filepath.IsAbs(path) || filepath.Clean(path) != path { |
| + return provider.ErrPolicy |
| + } |
| + if err := os.MkdirAll(path, 0700); err != nil { |
| + return err |
| + } |
| + real, err := filepath.EvalSymlinks(path) |
| + if err != nil || real != path { |
| + return provider.ErrPolicy |
| + } |
| + st, err := os.Stat(path) |
| + if err != nil || st.Mode().Perm() != 0700 { |
| + return provider.ErrPolicy |
| + } |
| + return nil |
| +} |
| +func privateWrite(path string, raw []byte) error { |
| + if err := privateDir(filepath.Dir(path)); err != nil { |
| + return err |
| + } |
| + if info, err := os.Lstat(path); err == nil { |
| + if !info.Mode().IsRegular() || info.Mode().Perm() != 0600 { |
| + return provider.ErrPolicy |
| + } |
| + } else if !os.IsNotExist(err) { |
| + return err |
| + } |
| + f, err := os.CreateTemp(filepath.Dir(path), ".try-write-") |
| + if err != nil { |
| + return err |
| + } |
| + defer os.Remove(f.Name()) |
| + _, err = f.Write(raw) |
| + if err == nil { |
| + err = f.Sync() |
| + } |
| + err = errors.Join(err, f.Close()) |
| + if err != nil { |
| + return err |
| + } |
| + if err = os.Rename(f.Name(), path); err != nil { |
| + return err |
| + } |
| + d, err := os.Open(filepath.Dir(path)) |
| + if err != nil { |
| + return err |
| + } |
| + defer d.Close() |
| + return d.Sync() |
| +} |
| +func (w *Wizard) ask(key, def string) (string, error) { |
| + fmt.Fprintf(w.Output, equipo.TryText("prompt"), equipo.TryText(key), def) |
| + line, err := w.reader.ReadString('\n') |
| + if err != nil { |
| + return "", err |
| + } |
| + line = strings.TrimSpace(line) |
| + if line == "" { |
| + line = def |
| + } |
| + if line == "" || strings.ContainsAny(line, "\x00\r\n") { |
| + return "", provider.ErrPolicy |
| + } |
| + return line, nil |
| +} |
| +func (w *Wizard) value(key, def string) (string, error) { |
| + if v := w.State.Values[key]; v != "" { |
| + def = v |
| + } |
| + v, err := w.ask(key, def) |
| + if err != nil { |
| + return "", err |
| + } |
| + w.State.Values[key] = v |
| + return v, w.save() |
| +} |
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json| index 86704eab..8ec9178a 100644 |
| --- a/scripts/runner-reference-allowlist.json |
| +++ b/scripts/runner-reference-allowlist.json |
| @@ -20,62 +20,6 @@ |
| "count": 1, |
| "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| }, |
| - { |
| - "path": "docs/live-gate.md", |
| - "line_sha256": "51dbcdc706898958f485863d2460b2a4eb4e2ce383aa6a19533bf8b59cfc4bfc", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| - }, |
| - { |
| - "path": "docs/live-gate.md", |
| - "line_sha256": "09d7c615c5157cda0690ff846ba01567b9a2b95ac949930ae03ab651d9ad1c2d", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| - }, |
| - { |
| - "path": "docs/live-gate.md", |
| - "line_sha256": "0a1352b302eb571fa3911b4ab118f94f8eb5bf1d20939615e77cc7cd2fb085ec", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| - }, |
| - { |
| - "path": "docs/live-gate.md", |
| - "line_sha256": "ee2be43c4a77ca66c5910155019971b86a0a7ba33067341670ab4ed4766741b4", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| - }, |
| - { |
| - "path": "docs/live-gate.md", |
| - "line_sha256": "d327f8de998efaf796e12d8c9ea974c2f43432c54105093e00b02ae88607e92b", |
| - "match": "equipo-runner", |
| - "count": 2, |
| - "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| - }, |
| - { |
| - "path": "docs/live-gate.md", |
| - "line_sha256": "5eb49c570b81c4c2e8a8a8c15d78610934dda3eeb6945ec772e5a04c3ae728a5", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| - }, |
| - { |
| - "path": "docs/live-gate.md", |
| - "line_sha256": "68fc709d54529eece99058c0bfa2ede7e4a068756b6381a921132269a8d18f35", |
| - "match": "equipo-runner", |
| - "count": 2, |
| - "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| - }, |
| - { |
| - "path": "docs/live-gate.md", |
| - "line_sha256": "db1a58a88111420d95c23a0b5e71ea7977631abb34c54d5d3aca8e83dba3360e", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Retained runner executable, versioned package or user-service path in Task 11b release tooling, tests or draft operator steps." |
| - }, |
| { |
| "path": "docs/mockups/models.html", |
| "line_sha256": "b03ef2e13837ea9e91dfc11b109bae368cdf4600888aeb957d89364e260262af", |
| @@ -6796,13 +6740,6 @@ |
| "count": 1, |
| "reason": "Historical trial storage or explicit refusal/test fixture; direct provider launch gains no trial authority." |
| }, |
| - { |
| - "path": "internal/equipo/copy.go", |
| - "line_sha256": "c399d13ce5fa012d61736bbd8c3a5e38049b4aa03f1428caedd36e69ad44ca41", |
| - "match": "equipo-runner", |
| - "count": 1, |
| - "reason": "Runner executable/package or user-service identifier, retained for direct-launch installation and fixture verification." |
| - }, |
| { |
| "path": "internal/equipo/models.go", |
| "line_sha256": "e1b06445fea1bffb2d21965aa9d98f4ca92e19b442af659a9f5735db0af4264c", |
| @@ -6831,13 +6768,6 @@ |
| "count": 1, |
| "reason": "Historical trial storage or explicit refusal/test fixture; direct provider launch gains no trial authority." |
| }, |
| - { |
| - "path": "internal/equipo/templates/connections.html", |
| - "line_sha256": "d41ab362254363ce2642e3a7818e49e7490b888e5c8e30fca8782bdc9f04b1c2", |
| - "match": "trial", |
| - "count": 1, |
| - "reason": "Historical trial storage or explicit refusal/test fixture; direct provider launch gains no trial authority." |
| - }, |
| { |
| "path": "internal/equipo/templates/task_card.html", |
| "line_sha256": "3c4dde0f199dfeb52a8071189f234921c80ebb29522a22e38e76efe4ad0677de", |
| @@ -7103,5 +7033,138 @@ |
| "match": "equipo-runner", |
| "count": 1, |
| "reason": "Plan 3 controller ruling quoting the direct runner's account login subcommand, not historical daemon orchestration." |
| + }, |
| + { |
| + "path": "docs/live-gate.md", |
| + "line_sha256": "fcb36062c6f5a2c1c6e43495b394e04e701f8334e3c7cf529008f916316db84e", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Private native Go runner configuration directory for the guided gate." |
| + }, |
| + { |
| + "path": "docs/superpowers/plans/CODEX-BRIEF-try-equipo.md", |
| + "line_sha256": "ae2866297b998dd97d1d1473e56055bfd9295164efebdafffbccdc062807e821", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Controller brief names the native Go runner command as an implementation option." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "005ee6cc283edb0a47def49cbb66299fbc790c5904b2a161679f796c8882666c", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "1a08f9a6798b33aa229ad360e164fb054f108bb8e8754ce7cf7a194e53d39f19", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "1bde8cfefcfe9bdfd35b4f7ce9a331d077e9c20b1d69564700fc4de46a4ad961", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "39b2fb345092b0e66438feda3085d49b06db20b1b8f7858ac323a6defc32a214", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "45deb03dae9a8edf8acb36cc29454be4fe73695f7886d11c3995d511c0b05b81", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "499da5edadc28d942254082b19638c89f13e335d584cedff232488dc0b09324d", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "a13a12f15382a94f4c7cc36c370caebec473581d2786ec9b46b44ae8e05608a2", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "b22cb5a16865cb71362d999cdb8f403c98b4fc5fe3fd08b3cef2825564a4fc8e", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "b24591bcdf262c6d1986b4b78ea8f8d87677a85c9adb82090d5becf22c3cb31b", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "d98752042a7729fc653b914c31d5e9dd3b0466c882e5d3e42dfcef4df47a0b98", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/directlive/account_change.go", |
| + "line_sha256": "f1685b75fa2bc1fefff11e7af2fc31b3ca3bf2332823ac388e84ee51d8c3f972", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Disposable two-account identity certification fixture, not an unconfined trial mode." |
| + }, |
| + { |
| + "path": "internal/equipo/copy.go", |
| + "line_sha256": "28581c5f2fc71026bc3125625cb82a108302f3f51a50d9069268f0403df8d5a6", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Existing official native runner account-login command in the copy catalog." |
| + }, |
| + { |
| + "path": "internal/equipo/templates/connections.html", |
| + "line_sha256": "31657bcc0c461b756221f0110fe7925cdbf51ccd4851e35d5ec18a38c9f8ef0d", |
| + "match": "trial", |
| + "count": 1, |
| + "reason": "Existing isolation label partial retained beside the account-maintenance state." |
| + }, |
| + { |
| + "path": "internal/runner/provider/login.go", |
| + "line_sha256": "da193333198730752996cb5d0094e23f5e2bd57d28b0181f399d7811cadb574f", |
| + "match": "node", |
| + "count": 1, |
| + "reason": "Inode alias refusal for dedicated credential homes, unrelated to Node runtime." |
| + }, |
| + { |
| + "path": "internal/tryequipo/config.go", |
| + "line_sha256": "4948b2a9f7d22bd371ac70445f1d0ef8ebd66185919b8186db52fec804d8ba73", |
| + "match": "equipo-runner", |
| + "count": 2, |
| + "reason": "Build and locate the native Go namespace runner for live certification." |
| + }, |
| + { |
| + "path": "internal/tryequipo/config.go", |
| + "line_sha256": "923d77db6d037ecd2880e1dddaf42dc6a51399c00388624a33e81ffd3a363815", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Build and locate the native Go namespace runner for live certification." |
| + }, |
| + { |
| + "path": "internal/tryequipo/run.go", |
| + "line_sha256": "b8b8bb8fc83a3cc64c4639b3972c307e9246d82ed0b811b29587a5c5cf4d4b99", |
| + "match": "equipo-runner", |
| + "count": 1, |
| + "reason": "Private configuration root for the native Go runner." |
| } |
| ] |
diff --git a/scripts/runner-release-check.py b/scripts/runner-release-check.py| index 01a3ffdc..0d104b14 100644 |
| --- a/scripts/runner-release-check.py |
| +++ b/scripts/runner-release-check.py |
| @@ -50,8 +50,8 @@ def evidence(manifest, certificate, reference, installed): |
| for key in ("provider", "provider_version", "launcher_version", "bwrap_version", "policy_hash"): |
| require(record[key] == certificate[key]) |
| require(record["policy_version"] == manifest["policy_version"]) |
| - require(certificate["certified_refresh"] == {"auth_host": record["auth_host"], "evidence_sha256": reference["sha256"]}) |
| - require(record["run_id"] and record["account_id"] and record["home_id"] and record["model"] and record["auth_host"]) |
| + require(certificate["certified_refresh"] is None and certificate["no_refresh_reason"] and record["auth_host"] == "") |
| + require(record["run_id"] and record["account_id"] and record["home_id"] and record["model"]) |
| require(sha(record["config_sha256"]) and sha(record["binaries"]["runner"])) |
| for name, value in installed.items(): |
| require(record["binaries"][name] == value) |
| @@ -159,7 +159,7 @@ try: |
| refs = [r for r in manifest["certifications"] if (r["provider"], r["policy_hash"]) == key] |
| require(len(refs) == 1) |
| evidence(manifest, certificate, refs[0], installed) |
| - expected = {k: v for k, v in certificate.items() if k not in ("policy_hash", "certified_refresh")} |
| + expected = {k: v for k, v in certificate.items() if k not in ("policy_hash", "certified_refresh", "no_refresh_reason")} |
| expected.update(policy_version=manifest["policy_version"], isolation_config_hash=certificate["policy_hash"]) |
| require(manifest["verified_isolation_tuples"].count(expected) == 1) |
| except (ValueError, KeyError, OSError, TypeError, subprocess.SubprocessError): |
diff --git a/scripts/try-equipo.sh b/scripts/try-equipo.sh| new file mode 100755 |
| index 00000000..ef8ee3ed |
| --- /dev/null |
| +++ b/scripts/try-equipo.sh |
| @@ -0,0 +1,8 @@ |
| +#!/bin/sh |
| +set -eu |
| +cd "$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)" |
| +if ! command -v go >/dev/null 2>&1; then |
| + printf '%s\n' 'Missing prerequisite: Go' |
| + exit 1 |
| +fi |
| +CGO_ENABLED=0 go run ./cmd/equipo-try |