oficina / equipo Public

Fix guided Equipo sign-in and live certification review issues

Preserve terminal access, pin private CLI copies, and validate every account.
Recover interrupted scratch using process identity and probe all connected homes.
Run certification through the runner and record pathless tools as not applicable.

Record regression tests, 26 guard mutations, CI results, and pending copy.
codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev a7a507c82fffc42c80d8e184d0dbda329442eb15 parent f8144c3
44 files changed, +1,455 −209
  • cmd/equipo-runner/direct_live.go +29 −2
  • cmd/equipo-runner/direct_live_test.go +22 −0
  • cmd/equipo-runner/main.go +2 −1
  • cmd/equipo-try/main.go +4 −2
  • docs/live-gate.md +25 −12
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +49 −25
  • docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-3.md +187 −0
  • internal/directlive/cleanup.go +20 −2
  • internal/directlive/delegation.go +36 −0
  • internal/directlive/delegation_test.go +76 −0
  • internal/directlive/driver.go +10 −0
  • internal/directlive/driver_test.go +20 −0
  • internal/directlive/inventory.go +5 −1
  • internal/directlive/probes.go +23 −2
  • internal/directlive/review_fixes_test.go +82 −0
  • internal/equipo/copy.go +51 −52
  • internal/runner/containment/recovery.go +31 −0
  • internal/runner/egress/policy.go +1 −1
  • internal/runner/provider/accounts.go +1 −1
  • internal/runner/provider/claude/launcher.go +1 −6
  • internal/runner/provider/claude/launcher_test.go +11 −6
  • internal/runner/provider/codex/launcher.go +1 −6
  • internal/runner/provider/codex/launcher_test.go +9 −9
  • internal/runner/provider/direct_certification.go +5 −1
  • internal/runner/provider/path_tools.go +19 −0
  • internal/runner/provider/review_tools_test.go +24 −0
  • internal/runner/provider/types.go +1 −1
  • internal/runner/setup/account_bindings.go +2 −2
  • internal/tryequipo/account_set.go +49 −9
  • internal/tryequipo/accounts.go +62 −10
  • internal/tryequipo/accounts_test.go +9 −1
  • internal/tryequipo/budget_test.go +8 −1
  • internal/tryequipo/command.go +40 −7
  • internal/tryequipo/config.go +5 −1
  • internal/tryequipo/diagnostics.go +28 −0
  • internal/tryequipo/executable.go +75 −0
  • internal/tryequipo/multiple_accounts_test.go +19 −1
  • internal/tryequipo/prerequisites.go +27 −15
  • internal/tryequipo/review_fixes_test.go +323 −0
  • internal/tryequipo/run.go +15 −13
  • internal/tryequipo/state.go +10 −10
  • scripts/live-gate.sh +1 −1
  • scripts/runner-reference-allowlist.json +35 −7
  • scripts/try-equipo.sh +2 −1

CI failed — run details

diff --git a/cmd/equipo-runner/direct_live.go b/cmd/equipo-runner/direct_live.go
index 9d5c8e60..7b67053d 100644
--- a/cmd/equipo-runner/direct_live.go
+++ b/cmd/equipo-runner/direct_live.go
@@ -6,14 +6,41 @@ import (
"amadan.net/oficina/equipo/internal/directlive"
"amadan.net/oficina/equipo/internal/runner/provider"
"context"
+ "encoding/json"
+ "io"
+ "os"
)
func directLiveWorker(ctx context.Context, args []string, getenv func(string) string) (bool, error) {
- if len(args) != 2 || args[0] != "__direct-live-worker" {
+ if len(args) != 2 {
+ return false, nil
+ }
+ switch args[0] {
+ case "__direct-live-worker", "__direct-live-run", "__direct-live-resume":
+ default:
return false, nil
}
if getenv("EQUIPO_LIVE_DIRECT") != "1" {
return true, provider.ErrPolicy
}
- return true, directlive.RecoveryWorker(ctx, args[1])
+ paths := directlive.EnvironmentPaths(getenv)
+ switch args[0] {
+ case "__direct-live-worker":
+ return true, directlive.RecoveryWorker(ctx, args[1])
+ case "__direct-live-resume":
+ return true, directlive.ResumeInterrupted(ctx, paths, args[1])
+ default:
+ if args[1] != "-" {
+ return true, provider.ErrPolicy
+ }
+ raw, err := io.ReadAll(io.LimitReader(os.Stdin, (1<<20)+1))
+ if err != nil {
+ return true, err
+ }
+ var c provider.DirectLiveConfig
+ if len(raw) > 1<<20 || json.Unmarshal(raw, &c) != nil {
+ return true, provider.ErrPolicy
+ }
+ return true, directlive.Run(ctx, c, raw, paths)
+ }
}
diff --git a/cmd/equipo-runner/direct_live_test.go b/cmd/equipo-runner/direct_live_test.go
new file mode 100644
index 00000000..7d4d35b9
--- /dev/null
+++ b/cmd/equipo-runner/direct_live_test.go
@@ -0,0 +1,22 @@
+//go:build direct_live
+
+package main
+
+import (
+ "bytes"
+ "context"
+ "strings"
+ "testing"
+)
+
+func TestDirectLiveEntryRefusals(t *testing.T) {
+ for _, mode := range []string{"__direct-live-run", "__direct-live-resume", "__direct-live-worker"} {
+ var output bytes.Buffer
+ if code := run(context.Background(), []string{mode, "fixture"}, strings.NewReader(""), &output, &output, func(string) string { return "" }); code != 1 {
+ t.Fatal("missing opt-in accepted", code)
+ }
+ if !strings.Contains(output.String(), "provider_policy_rejected") || !strings.Contains(output.String(), "scripts/try-equipo.sh") {
+ t.Fatal("silent refusal", output.String())
+ }
+ }
+}
diff --git a/cmd/equipo-runner/main.go b/cmd/equipo-runner/main.go
index 3f3b903e..a64b363a 100644
--- a/cmd/equipo-runner/main.go
+++ b/cmd/equipo-runner/main.go
@@ -25,7 +25,8 @@ func run(ctx context.Context, args []string, input io.Reader, output, errorOutpu
}
if handled, err := directLiveWorker(ctx, args, getenv); handled {
if err != nil {
- return fail(err)
+ fmt.Fprintf(errorOutput, equipo.TryText("failed"), args[0], err)
+ return 1
}
return 0
}
diff --git a/cmd/equipo-try/main.go b/cmd/equipo-try/main.go
index 89f415d7..642e6196 100644
--- a/cmd/equipo-try/main.go
+++ b/cmd/equipo-try/main.go
@@ -12,15 +12,17 @@ import (
func main() {
ctx, stop := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)
defer stop()
- home, err := os.UserHomeDir()
+ home, err := tryequipo.SystemHome()
if err != nil {
+ tryequipo.ReportFailure(os.Stderr, "startup", err)
os.Exit(1)
}
repo, err := os.Getwd()
if err != nil {
+ tryequipo.ReportFailure(os.Stderr, "startup", err)
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}
+ w := tryequipo.Wizard{Root: filepath.Join(home, ".local/share/equipo/try"), Accounts: filepath.Join(home, ".local/share/equipo/accounts"), Repository: repo, Input: 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 414cd424..083a4134 100644
--- a/docs/live-gate.md
+++ b/docs/live-gate.md
@@ -1,5 +1,7 @@
# Try Equipo
+Draft changes pending copy review.
+
On docs-t1, run this as yourself from the reviewed checkout:
```sh
@@ -9,10 +11,14 @@ scripts/try-equipo.sh
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.
+The guide copies the pinned provider executables into its private `try/bin`
+folder. The Codex code-mode host comes from beside the resolved Codex executable.
+Executables inside interactive or ZeroSub homes are refused.
+
+Codex signs in with `codex login --device-auth`. Both providers receive
+`SHET_BRIDGE` when set. Their sign-in instructions go directly to the terminal;
+the guide never captures or logs that output. Configure `BROWSER` if Claude's
+browser opener cannot reach your browser.
Type `SIGN IN` when you are ready. Choose the total accounts to connect for
each provider. The defaults are six Claude accounts and two Codex accounts,
@@ -27,10 +33,12 @@ 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.
+`equipo-identity.json` in each home and private `bindings.json` beside `runner.env`.
+The usual environment-file path is `$HOME/.local/share/equipo-runner/runner.env`.
+All guide paths use your operating system account's home, even when `HOME`
+points elsewhere. The guide 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
@@ -40,8 +48,9 @@ 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
-two connected accounts for each provider, leaving their credential sources
+against the protected paths, including every connected home. Tools that cannot
+request a filesystem read are recorded as not applicable. The account-change
+check uses private copies of two connected accounts for each provider, leaving their credential sources
untouched. Missing observations or failed denials block certification. Human approval questions
arrive through the terminal and expire after 60 seconds.
@@ -53,12 +62,16 @@ silently retry on another account.
To add accounts, run the script again and increase the totals. Every connected
account is written to the bindings file. Finished sign-ins are checked and reused;
only new or expired accounts need sign-in. Existing homes and binding IDs stay
-the same, and totals cannot drop existing accounts.
+the same. Totals cannot drop confirmed accounts; lower a total to drop an
+unconfirmed account. Its abandoned home is left on disk.
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.
+passing result. After proving the prior controller has stopped, it removes
+interrupted account-change scratch. The gate log includes test stderr, and the
+calibration duration controls the timeout. 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
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 42c7246d..d9a594e0 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5101,34 +5101,58 @@ records to satisfy a gate. Release remains blocked while any row is pending.
| `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 |
+| `prerequisite` | Missing prerequisite: %s. Install the pinned version outside interactive homes and run the guide again.<br> | Guided live gate | COPY REVIEW REQUIRED |
+| `prompt` | %s [%s]: | Guided live gate | COPY REVIEW REQUIRED |
+| `confirm` | Observed account for %s: %s. Confirm this account? [yes/no]: | Guided live gate | COPY REVIEW REQUIRED |
+| `login` | Signing in to %s in its dedicated home. Follow the official CLI instructions in this terminal.<br> | Guided live gate | COPY REVIEW REQUIRED |
+| `failed` | Stopped at %s: %v. Correct the cause above. Saved setup can be resumed by running scripts/try-equipo.sh again. No release was made.<br> | Guided live gate | 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 | COPY REVIEW REQUIRED |
+| `live` | Type RUN LIVE GATE to authorize the displayed limits and disposable exercises | Guided live gate | COPY REVIEW REQUIRED |
+| `signin` | Type SIGN IN to start official sign-ins in dedicated homes | Guided live gate | COPY REVIEW REQUIRED |
| `claude-accounts` | Total Claude accounts to connect | Guided live gate | COPY REVIEW REQUIRED |
| `codex-accounts` | Total Codex accounts to connect | Guided live gate | COPY REVIEW REQUIRED |
-| `account-minimum` | Enter a whole number of at least %d. Keep all existing accounts connected.<br> | Guided live gate | COPY REVIEW REQUIRED |
+| `account-minimum` | Enter a whole number of at least %d. Keep all confirmed accounts connected. Lower the count to drop an unconfirmed account.<br> | Guided live gate | COPY REVIEW REQUIRED |
| `duplicate-account` | This account is already connected in another home. Run the guide again and sign in to a different account.<br> | Guided live gate | 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&#x27;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 |
+| `instance` | Instance ID from Equipo | Guided live gate | COPY REVIEW REQUIRED |
+| `person` | Your Equipo person ID | Guided live gate | COPY REVIEW REQUIRED |
+| `claude-model` | Exact Claude model | Guided live gate | COPY REVIEW REQUIRED |
+| `codex-model` | Exact Codex model | Guided live gate | COPY REVIEW REQUIRED |
+| `forge` | Absolute path to the runner's Amadan credential file | Guided live gate | COPY REVIEW REQUIRED |
+| `Calls` | Maximum calibration calls | Guided live gate | COPY REVIEW REQUIRED |
+| `InputTokens` | Maximum calibration input tokens | Guided live gate | COPY REVIEW REQUIRED |
+| `OutputTokens` | Maximum calibration output tokens | Guided live gate | COPY REVIEW REQUIRED |
+| `Seconds` | Maximum calibration seconds | Guided live gate | COPY REVIEW REQUIRED |
+| `JobInput` | Job input token funding | Guided live gate | COPY REVIEW REQUIRED |
+| `JobOutput` | Job output token funding | Guided live gate | COPY REVIEW REQUIRED |
+| `ProjectInputHeadroom` | Remaining project input tokens | Guided live gate | COPY REVIEW REQUIRED |
+| `ProjectOutputHeadroom` | Remaining project output tokens | Guided live gate | COPY REVIEW REQUIRED |
+| `TeamInputHeadroom` | Remaining team input tokens | Guided live gate | COPY REVIEW REQUIRED |
+| `TeamOutputHeadroom` | Remaining team output tokens | Guided live gate | COPY REVIEW REQUIRED |
+| `limits` | Authorized limits: %s<br> | Guided live gate | COPY REVIEW REQUIRED |
+
+| `login-failed` | The official sign-in did not finish. Follow its terminal instructions and run the guide again | Guided live gate | COPY REVIEW REQUIRED |
+| `confirmation-required` | The account was not confirmed. Run the guide again to confirm it or lower the account count to drop it | Guided live gate | COPY REVIEW REQUIRED |
+| `identity-mismatch` | The observed account does not match the confirmed identity. Sign in to the confirmed account in this dedicated home and retry | Guided live gate | COPY REVIEW REQUIRED |
+| `account-check` | Account validation failed. Check this dedicated home and sign in again through the guide | Guided live gate | COPY REVIEW REQUIRED |
+| `prerequisite-cause` | Cannot use %s: %v<br> | Guided live gate | COPY REVIEW REQUIRED |
+| `executable-hash` | Executable does not match its pinned hash. Install the pinned version and retry | Guided live gate | COPY REVIEW REQUIRED |
+| `executable-file` | Executable is not a runnable regular file. Correct its EQUIPO path or permissions | Guided live gate | COPY REVIEW REQUIRED |
+| `executable-home` | Executable is inside an interactive or ZeroSub home. Install the pinned CLI outside those homes and set its EQUIPO path | Guided live gate | COPY REVIEW REQUIRED |
+| `funding-invalid` | Funding limits must be positive whole numbers and seconds must be at most 86400. Enter valid limits on the next run | Guided live gate | COPY REVIEW REQUIRED |
+| `forge-path` | The Amadan credential must be an absolute path to a regular file with mode 0600. Correct its path or permissions | Guided live gate | COPY REVIEW REQUIRED |
+| `live-required` | The live gate was not authorized. Run the guide again and type RUN LIVE GATE to continue | Guided live gate | COPY REVIEW REQUIRED |
+| `signin-required` | Sign-in was not authorized. Run the guide again and type SIGN IN to continue | Guided live gate | COPY REVIEW REQUIRED |
+| `root-user` | Root cannot run this guide. Run it as your own user | Guided live gate | COPY REVIEW REQUIRED |
+| `system-home` | The system home could not be found. Check your operating system account before retrying | Guided live gate | COPY REVIEW REQUIRED |
+| `terminal` | No terminal is available. Run the guide from an interactive terminal | Guided live gate | COPY REVIEW REQUIRED |
+| `config-value` | A configuration value contains unsupported shell characters. Correct that value and retry | Guided live gate | COPY REVIEW REQUIRED |
+| `foreign-file` | A generated file was changed outside the guide. Preserve that change and restore the generated file before retrying | Guided live gate | COPY REVIEW REQUIRED |
+| `input-required` | No valid answer was read. Run the guide from a terminal and answer the displayed question | Guided live gate | COPY REVIEW REQUIRED |
+| `saved-state` | Saved setup is invalid. Check state.json in the try folder before retrying | Guided live gate | COPY REVIEW REQUIRED |
+| `private-file` | Setup needs a regular file with mode 0600. Correct the file permissions and retry | Guided live gate | COPY REVIEW REQUIRED |
+| `private-directory` | Setup needs an absolute, unlinked directory with mode 0700. Correct the path or permissions and retry | Guided live gate | COPY REVIEW REQUIRED |
+| `go-required` | Missing prerequisite: Go. Install Go and run scripts/try-equipo.sh again. | Guided live gate | COPY REVIEW REQUIRED |
+| `guide-busy` | Another guide holds the setup lock. Wait for it to finish before retrying | Guided live gate | COPY REVIEW REQUIRED |
## Task 21
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-3.md
new file mode 100644
index 00000000..9cfaed64
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-3.md
@@ -0,0 +1,187 @@
+# Try Equipo review fixes: controller report
+
+All C1–C4, I1–I4 and M1–M6 changes are implemented on the existing try-equipo
+branch. The replacement full CI and final setup timing check passed.
+No real sign-ins, provider runs, additional agents,
+copy-review server, release, merge or deployment were used. README is unchanged.
+
+Sign-in and live-gate subprocesses retain the terminal process group. Other
+guide commands retain process-group cancellation. The official CLI receives
+terminal file descriptors directly for stdin, stdout and stderr; login output
+never passes through a guide buffer. Codex uses device authentication, and both
+providers receive SHET_BRIDGE. Pseudo-terminal tests send input through /dev/tty
+and check both output streams.
+
+The guide resolves and hashes the provider executables, copies them into private
+try/bin files with mode 0700, then uses those copies for version checks, sign-in,
+identity probes, runner configuration and live certification. The code-mode host
+is resolved beside the original resolved Codex executable. Executables under
+interactive or ZeroSub homes, including symlink aliases, are refused before use.
+
+Every guide failure prints its phase, cause and retry guidance. Startup errors
+also print diagnostics. The missing-Go shell refusal reads the same copy catalog.
+Build diagnostics and live-test stderr are retained in the appropriate output.
+The live go test uses -timeout=0; the configured calibration deadline still
+limits the driver.
+
+Confirmed homes pass the provider's OpenAccount and Validate checks before use.
+Account maintenance triggers a fresh official sign-in. The identity must still
+match after sign-in. All homes are validated, including accounts outside the
+primary certification pair. Unconfirmed homes do not increase the minimum;
+reducing a count drops them from setup state while leaving their directories on
+disk. Confirmed homes and IDs are retained. Base paths use the operating system
+account's home rather than the HOME environment variable.
+
+Resume and driver startup remove change-source-* and change-policy-* scratch
+only after checking recorded controllers and retiring their namespaces. The
+check compares boot identity, PID and start ticks, so PID reuse cannot block
+cleanup or cause an unrelated process to be stopped. Both providers' second
+homes and every additional connected home receive isolation sentinels and probes.
+Known tools that cannot request a filesystem read record not-applicable evidence;
+unknown tools and filesystem readers still require denied-read observations.
+
+The obsolete refresh branches in both launchers are removed. Runtime credential
+changes require account maintenance even if an old test policy names an auth host.
+Existing low-level AccountLease refresh tests remain, but launchers no longer
+call that operation. Stale v1 refresh comments were corrected.
+
+During implementation, containment's same-executable check exposed another
+blocker in the original guide: both go test and resume tried to create the
+manager outside the runner executable. These callers now invoke explicit
+direct-live runner entry points. The live child retains terminal access; resume
+uses process-group cancellation. The opt-in is required, configuration bytes
+must match the caller's configuration, and failures retain their actual cause.
+A test builds the runner and resumes empty fixture scratch in that process,
+without starting providers.
+
+## Verification
+
+New tests were written first. Initial failures included missing helper symbols,
+the existing rejection of not-applicable tool evidence. Early test runs also
+caught an error in dropping sparse unconfirmed homes. Two fixture errors were
+corrected: Python requires
+os.open for the bidirectional terminal descriptor, and synthetic recovery records
+need a manifest hash. Behavioral mutation checks below then verified the guards.
+
+All commands below use CGO_ENABLED=0. Tests use Go-managed temporary directories
+and do not require TMPDIR. Session scratch uses the supplied on-disk TMPDIR;
+Go caches remain at their defaults.
+
+Passing targeted commands:
+
+- go test ./internal/tryequipo ./internal/directlive ./internal/runner/provider/... ./internal/plan3test -run 'TestReview|TestAccount|TestConnectAll|TestDuplicateAccount|TestLiveConfig|TestUpgradeOriginal|TestDirectLiveGateEvidence|TestPlan3ReleaseBoundaries/inventory|Test.*Refresh' -count=1
+- go test ./internal/directlive -run '^TestDirectDriverFakeCLI/Engineering$' -count=1
+- go test -tags direct_live ./cmd/equipo-runner -count=1
+
+The fake Engineering run passed in 48.811s. It checks both providers' second-home
+observations, pathless-tool evidence, source preservation and scratch cleanup.
+The final targeted package run passed: directlive 1.172s, tryequipo 12.620s,
+provider 3.074s, Claude 2.359s, Codex 0.755s, and plan3test 0.202s.
+The tagged runner tests passed in 3.374s.
+
+Each mutation was compile-valid, caused its targeted test to fail with exit 1,
+and was restored. In C1, the background child printed tty-ready but could not
+read the answer; the test killed it on timeout. Removing driver cleanup left
+both injected scratch directories and failed the fake Engineering run.
+
+| Broken guard | Command | Result |
+| --- | --- | --- |
+| C1 foreground | `go test ./internal/tryequipo -run ^TestReviewForegroundTerminal$ -count=1` | Failed, exit 1; restored |
+| C2 device auth | `go test ./internal/tryequipo -run ^TestCodexAccountOfficialFlow$ -count=1` | Failed, exit 1; restored |
+| C2 bridge | `go test ./internal/tryequipo -run ^TestDuplicateAccountRefusedAndRetryable$ -count=1` | Failed, exit 1; restored |
+| C2 terminal output | `go test ./internal/tryequipo -run ^TestReviewForegroundTerminal/login$ -count=1` | Failed, exit 1; restored |
+| C3 hashes | `go test ./internal/tryequipo -run ^TestReviewPrivateExecutables$ -count=1` | Failed, exit 1; restored |
+| C3 forbidden homes | `go test ./internal/tryequipo -run ^TestReviewPrivateExecutables$ -count=1` | Failed, exit 1; restored |
+| C3 sibling host | `go test ./internal/tryequipo -run ^TestReviewCodexSiblingHost$ -count=1` | Failed, exit 1; restored |
+| C4 timeout | `go test ./internal/tryequipo -run ^TestReviewGateDeadlineAndGroups$ -count=1` | Failed, exit 1; restored |
+| I1 cause | `go test ./internal/tryequipo -run ^TestReviewRefusalExplainsCause$ -count=1` | Failed, exit 1; restored |
+| I2 validate homes | `go test ./internal/tryequipo -run ^TestReviewExpiredAccountSignsIn$ -count=1` | Failed, exit 1; restored |
+| I3 resume scratch | `go test ./internal/directlive -run ^TestReviewResumeScratchAndParentIdentity$ -count=1` | Failed, exit 1; restored |
+| I3 driver scratch | `go test ./internal/directlive -run ^TestDirectDriverFakeCLI/Engineering$ -count=1` | Failed, exit 1; restored |
+| I4 Codex other home | `go test ./internal/directlive -run ^TestReviewAllOtherHomesProbed$ -count=1` | Failed, exit 1; restored |
+| I4 all connected homes | `go test ./internal/tryequipo -run ^TestLiveConfigAccountChangeBothProviders$ -count=1` | Failed, exit 1; restored |
+| M1 confirmed minimum | `go test ./internal/tryequipo -run ^TestReviewDropUnconfirmedHome$ -count=1` | Failed, exit 1; restored |
+| M1 drop unconfirmed | `go test ./internal/tryequipo -run ^TestReviewDropUnconfirmedHome$ -count=1` | Failed, exit 1; restored |
+| M2 system home | `go test ./internal/tryequipo -run ^TestReviewSystemHome$ -count=1` | Failed, exit 1; restored |
+| M3 claude refresh | `go test ./internal/runner/provider/claude -run ^TestClaudeRefreshBeforeTurn$ -count=1` | Failed, exit 1; restored |
+| M3 codex refresh | `go test ./internal/runner/provider/codex -run ^TestCodexRefreshAndAdmission$ -count=1` | Failed, exit 1; restored |
+| M4 gate stderr | `go test ./internal/tryequipo -run ^TestReviewForegroundTerminal/gate$ -count=1` | Failed, exit 1; restored |
+| M5 start ticks | `go test ./internal/directlive -run ^TestReviewResumeScratchAndParentIdentity$ -count=1` | Failed, exit 1; restored |
+| M6 applicability | `go test ./internal/runner/provider -run ^TestReviewPathlessToolEvidence$ -count=1` | Failed, exit 1; restored |
+| Runner delegation | `go test ./internal/directlive -run ^TestReviewControllerUsesRunner$ -count=1` | Failed, exit 1; restored |
+
+
+The first size check exceeded the app's existing allowance by 23 lines.
+Combining each pending copy annotation with its entry restored the budget;
+no budget allowance changed. The changed guide path also required updating its
+exact reference-inventory hash.
+
+While CI was running, review found an unconfirmed expired home could be confirmed
+and then fail validation without starting sign-in. The new regression failed
+for both providers before the fix. A just-confirmed home now gets one additional
+pass through validation and sign-in; another maintenance failure stops it.
+The full tryequipo package passed after this final change (27.671s while CI ran),
+and go vet ./internal/tryequipo passed. An overlay mutation disabling that retry
+failed TestReviewUnconfirmedExpiredAccountSignsIn for both providers. The overlay
+left the working source intact.
+
+| Broken guard | Command | Result |
+| --- | --- | --- |
+| Unconfirmed maintenance | `go test -overlay=<scratch>/mutation-24.json ./internal/tryequipo -run '^TestReviewUnconfirmedExpiredAccountSignsIn$' -count=1` | Failed, exit 1; working source unchanged |
+
+The first background make ci completed with exit 2. Its test step ran all 26
+packages in 7m43.656s; the only failure was
+TestFinalFixLiveGateRunnerEnvironment, which requires the literal installer
+path using $HOME in the guide. The guide now retains that usual path and
+explains that the setup uses the system home even when HOME differs. Several
+existing timing limits produced advisory notes under shared load; no limit was
+changed. The brief requested one complete CI run, but this failed result could
+not satisfy the required passing gate, so a second full run was necessary.
+
+A second resume regression was reproduced while the replacement CI run was
+underway: interruption after saving confirmation but before writing the identity
+marker caused validation to stop. The guide now finishes that missing marker
+write while holding the home lock, after the provider observes the saved account
+and version. It refuses a different identity without writing a marker. The
+pre-fix test failed with provider_account_containment. The complete setup package
+then passed in 15.213s, followed by its vet check; the final marker identity test
+passed in 0.478s. A targeted staticcheck of internal/tryequipo also passed.
+These supplemental checks cover the correction made after the replacement
+full-suite invocation started.
+
+| Broken guard | Command | Result |
+| --- | --- | --- |
+| Finish the interrupted marker write | `go test -overlay=<scratch>/mutation-25.json ./internal/tryequipo -run '^TestReviewResumeBeforeIdentityMarker$' -count=1` | Failed, exit 1; working source unchanged |
+| Verify identity before restoring the marker | `go test -overlay=<scratch>/mutation-26.json ./internal/tryequipo -run '^TestReviewResumeBeforeIdentityMarker$' -count=1` | Failed, exit 1; working source unchanged |
+
+All 26 deliberate mutations were caught. Session overlays and logs are removed
+at handoff. Both full CI outcomes are recorded; no failed result is treated as passing.
+
+## Final CI result
+
+The replacement background make ci finished with exit 0. Its full test step ran
+27 packages without cached results or failures in 5m27.323s. Build, vet,
+formatting, staticcheck, govulncheck, gitleaks, size budgets, adapter checks,
+namespace checks, migrations and performance all passed. No reachable
+vulnerabilities or leaked secrets were reported. Cold boot had a 124ms median
+against 500ms, and every measured GET stayed below 150ms.
+
+The setup package took 14.944s in that run, above its 10s CI timing limit
+(reported locally as an advisory). Independent fake-account tests now run in
+parallel. Their bridge fixture is fixed once in the test process; tests that
+change other environment values remain serial. No assertions or limits changed.
+The final test-only scheduling change was verified with:
+
+`CI=1 CGO_ENABLED=0 go run amadan.net/rastrillo/rastrillo/cmd/rastrillo budget test -count=1 ./internal/tryequipo`
+
+Result: exit 0, one uncached package, zero failures; package time 5.021s and
+whole step 5.580s. The final package vet check also passed. The full CI rerun was
+not repeated after this test-only scheduling change.
+
+## Copy and limits
+
+Changed runtime messages remain individually marked COPY REVIEW PENDING in
+internal/equipo/copy.go. Their current text is in the existing Plan 3 copy
+inventory. Guide changes are flagged as pending copy review. The controller
+report records implementation and test evidence; no copy-review server was run.
+Live provider certification still has to be performed by Paul before release.
diff --git a/internal/directlive/cleanup.go b/internal/directlive/cleanup.go
index b4ea665b..5ac032d0 100644
--- a/internal/directlive/cleanup.go
+++ b/internal/directlive/cleanup.go
@@ -5,9 +5,9 @@ import (
"amadan.net/oficina/equipo/internal/runner/provider"
"context"
"errors"
- "golang.org/x/sys/unix"
"os"
"path/filepath"
+ "strings"
)
func retireManager(ctx context.Context, m *containment.Manager, root string) error {
@@ -43,6 +43,9 @@ func retireRecord(root string, p containment.Proof) error {
// 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 {
+ if handled, err := delegateRunner(ctx, paths, "__direct-live-resume", scratch, nil); handled {
+ return err
+ }
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
@@ -52,7 +55,11 @@ func ResumeInterrupted(ctx context.Context, paths Paths, scratch string) error {
return err
}
for _, r := range records {
- if r.ParentPID <= 0 || unix.Kill(r.ParentPID, 0) != unix.ESRCH {
+ active, err := containment.ControllerAlive(r)
+ if err != nil {
+ return err
+ }
+ if active {
return provider.ErrAccountBusy
}
proof, err := m.Recover(ctx, r)
@@ -63,5 +70,16 @@ func ResumeInterrupted(ctx context.Context, paths Paths, scratch string) error {
return err
}
}
+ entries, err := os.ReadDir(scratch)
+ if err != nil {
+ return err
+ }
+ for _, entry := range entries {
+ if strings.HasPrefix(entry.Name(), "change-source-") || strings.HasPrefix(entry.Name(), "change-policy-") {
+ if err := os.RemoveAll(filepath.Join(scratch, entry.Name())); err != nil {
+ return err
+ }
+ }
+ }
return nil
}
diff --git a/internal/directlive/delegation.go b/internal/directlive/delegation.go
new file mode 100644
index 00000000..e902e463
--- /dev/null
+++ b/internal/directlive/delegation.go
@@ -0,0 +1,36 @@
+package directlive
+
+import (
+ "bytes"
+ "context"
+ "os"
+ "os/exec"
+ "syscall"
+ "time"
+)
+
+// Containment pins the controller's own executable. A test binary or the
+// setup guide must therefore run certification and recovery through the runner.
+func delegateRunner(ctx context.Context, p Paths, mode, arg string, config []byte) (bool, error) {
+ current, err := os.Stat("/proc/self/exe")
+ if err != nil {
+ return true, err
+ }
+ runner, err := os.Stat(p.Runner)
+ if err != nil {
+ return true, err
+ }
+ if os.SameFile(current, runner) {
+ return false, nil
+ }
+ cmd := exec.CommandContext(ctx, p.Runner, mode, arg)
+ cmd.Env = append(os.Environ(), "EQUIPO_LIVE_DIRECT=1", "EQUIPO_RUNNER_EXECUTABLE="+p.Runner, "EQUIPO_BWRAP_PATH="+p.Bwrap, "EQUIPO_CLAUDE_PATH="+p.Claude, "EQUIPO_CODEX_PATH="+p.Codex, "EQUIPO_CODEX_CODE_MODE_HOST_PATH="+p.CodeModeHost, "EQUIPO_TOOL_PROXY_PATH="+p.ToolProxy)
+ cmd.Stdin = bytes.NewReader(config)
+ cmd.Stdout, cmd.Stderr = os.Stdout, os.Stderr
+ if mode == "__direct-live-resume" {
+ cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
+ cmd.Cancel = func() error { return syscall.Kill(-cmd.Process.Pid, syscall.SIGTERM) }
+ }
+ cmd.WaitDelay = 2 * time.Second
+ return true, cmd.Run()
+}
diff --git a/internal/directlive/delegation_test.go b/internal/directlive/delegation_test.go
new file mode 100644
index 00000000..4ec13448
--- /dev/null
+++ b/internal/directlive/delegation_test.go
@@ -0,0 +1,76 @@
+package directlive
+
+import (
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "context"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "testing"
+)
+
+func TestReviewControllerUsesRunner(t *testing.T) {
+ root := t.TempDir()
+ executable := filepath.Join(root, "runner")
+ script := `#!/usr/bin/python3
+import os,sys
+assert os.environ['EQUIPO_LIVE_DIRECT']=='1'
+assert os.environ['EQUIPO_RUNNER_EXECUTABLE']==sys.argv[0]
+assert os.environ['EQUIPO_BWRAP_PATH']=='/fixture/bwrap'
+if sys.argv[1]=='__direct-live-run':
+ assert os.getpgrp()==os.getpgid(os.getppid())
+ assert sys.argv[2]=='-'
+ assert sys.stdin.read() in ['fixture-config','{}']
+elif sys.argv[1]=='__direct-live-resume':
+ assert os.getpgrp()==os.getpid()
+ assert sys.argv[2]=='/fixture/scratch'
+else: sys.exit(2)
+`
+ if err := os.WriteFile(executable, []byte(script), 0700); err != nil {
+ t.Fatal(err)
+ }
+ p := Paths{Runner: executable, Bwrap: "/fixture/bwrap"}
+ handled, err := delegateRunner(context.Background(), p, "__direct-live-run", "-", []byte("fixture-config"))
+ if !handled || err != nil {
+ t.Fatal("live gate did not use runner", handled, err)
+ }
+ if err := Run(context.Background(), provider.DirectLiveConfig{}, []byte(`{"run_id":"changed"}`), p); err == nil {
+ t.Fatal("delegated config mismatch accepted")
+ }
+ if err := Run(context.Background(), provider.DirectLiveConfig{}, []byte("{}"), p); err != nil {
+ t.Fatal("gate did not use runner", err)
+ }
+ if err := ResumeInterrupted(context.Background(), p, "/fixture/scratch"); err != nil {
+ t.Fatal("resume did not use runner", err)
+ }
+ p.Runner = os.Args[0]
+ if handled, err := delegateRunner(context.Background(), p, "__direct-live-run", "-", nil); handled || err != nil {
+ t.Fatal("runner delegated to itself", handled, err)
+ }
+}
+
+func TestReviewRunnerResumeProcess(t *testing.T) {
+ root := t.TempDir()
+ binary := filepath.Join(root, "equipo-runner")
+ build := exec.Command("go", "build", "-tags", "direct_live", "-o", binary, "../../cmd/equipo-runner")
+ build.Env = append(os.Environ(), "CGO_ENABLED=0")
+ if out, err := build.CombinedOutput(); err != nil {
+ t.Fatal(string(out), err)
+ }
+ scratch := filepath.Join(root, "scratch")
+ if err := os.Mkdir(scratch, 0700); err != nil {
+ t.Fatal(err)
+ }
+ for _, name := range []string{"change-source-crashed", "change-policy-crashed"} {
+ if err := os.Mkdir(filepath.Join(scratch, name), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
+ if err := ResumeInterrupted(context.Background(), Paths{Runner: binary, Bwrap: "/usr/bin/bwrap"}, scratch); err != nil {
+ t.Fatal(err)
+ }
+ entries, err := os.ReadDir(scratch)
+ if err != nil || len(entries) != 0 {
+ t.Fatal("runner resume left scratch", entries, err)
+ }
+}
diff --git a/internal/directlive/driver.go b/internal/directlive/driver.go
index 1a265c39..ad7de01c 100644
--- a/internal/directlive/driver.go
+++ b/internal/directlive/driver.go
@@ -41,6 +41,13 @@ type driver struct {
// Run collects new observations. Existing evidence is rejected before any CLI
// starts. Only the pinned production executables can enter this entry point.
func Run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Paths) error {
+ var authorized provider.DirectLiveConfig
+ if json.Unmarshal(config, &authorized) != nil || string(marshal(authorized)) != string(marshal(c)) {
+ return errEvidence
+ }
+ if handled, err := delegateRunner(ctx, p, "__direct-live-run", "-", config); handled {
+ return err
+ }
return run(ctx, c, config, p, "direct-live", terminalAnswer, EnvironmentPolicyPaths(os.Getenv))
}
func run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Paths, source string, answer answerFunc, policyPaths PolicyPaths) error {
@@ -61,6 +68,9 @@ func runRoles(ctx context.Context, c provider.DirectLiveConfig, config []byte, p
if err = policyPaths.validate(); err != nil {
return err
}
+ if err = ResumeInterrupted(ctx, p, policyPaths.ScratchRoot); err != nil {
+ return err
+ }
homes := filepath.Join(policyPaths.ScratchRoot, "homes")
if _, e := os.Stat(homes); os.IsNotExist(e) {
defer os.Remove(homes)
diff --git a/internal/directlive/driver_test.go b/internal/directlive/driver_test.go
index 85c3ed50..9175abd4 100644
--- a/internal/directlive/driver_test.go
+++ b/internal/directlive/driver_test.go
@@ -107,6 +107,7 @@ func TestDirectDriverFakeWorker(t *testing.T) {
}
}
changes[second.Provider] = second
+ c.Sentinels[second.Provider+"-other"] = filepath.Join(second.Home, "sentinel")
}
c.AccountChanges = changes
@@ -132,6 +133,11 @@ func TestDirectDriverFakeWorker(t *testing.T) {
if err := os.Mkdir(paths.ScratchRoot, 0700); err != nil {
t.Fatal(err)
}
+ for _, name := range []string{"change-source-interrupted", "change-policy-interrupted"} {
+ if err := os.Mkdir(filepath.Join(paths.ScratchRoot, name), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
var bindings []runner.AccountBinding
for _, b := range c.Bindings {
bindings = append(bindings, runner.AccountBinding{ID: b.Binding.ID, LocalID: b.Binding.ID, Provider: b.Binding.Provider, Family: map[string]string{"claude": "claude", "codex": "gpt"}[b.Binding.Provider], Model: b.Model, AccountID: b.Binding.AccountID, ProviderHome: b.Binding.Home, ExpectedIdentity: b.Binding.Expected, Kind: "subscription"})
@@ -245,6 +251,20 @@ func TestDirectDriverFakeWorker(t *testing.T) {
t.Fatalf("%s did not exercise %s: %+v", name, check, e.Checks[check])
}
}
+ for _, tool := range e.Tools {
+ if !tool.Exposed {
+ continue
+ }
+ status := "denied"
+ if !provider.PathProbeApplicable(tool.Name) {
+ status = "not-applicable"
+ }
+ for _, key := range []string{"claude-other", "codex-other"} {
+ if tool.Probes[key].Status != status {
+ t.Fatalf("%s %s missing %s evidence: %+v", name, tool.Name, key, tool.Probes[key])
+ }
+ }
+ }
rawChange, err := os.ReadFile(filepath.Join(c.EvidenceDir, filepath.Dir(name), e.Checks["changed-identity-stops-step"].Artifact))
if err != nil {
t.Fatal(err)
diff --git a/internal/directlive/inventory.go b/internal/directlive/inventory.go
index e6889664..127f4ff1 100644
--- a/internal/directlive/inventory.go
+++ b/internal/directlive/inventory.go
@@ -25,7 +25,11 @@ func (x *exercise) inventory(ctx context.Context) error {
tested = false
}
for _, o := range tool.Probes {
- tested = tested && o.Status == "denied"
+ status := "denied"
+ if !provider.PathProbeApplicable(tool.Name) {
+ status = "not-applicable"
+ }
+ tested = tested && o.Status == status
}
}
slices.Sort(expected)
diff --git a/internal/directlive/probes.go b/internal/directlive/probes.go
index 7f2d72f9..f140832e 100644
--- a/internal/directlive/probes.go
+++ b/internal/directlive/probes.go
@@ -28,8 +28,8 @@ 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
+ for key, path := range otherHomeTargets(x.d.cfg) {
+ targets[key] = path
}
alias := filepath.Join(x.d.cfg.Repository, "equipo-sentinel-alias")
if err := os.Symlink("/home/runner", alias); err != nil {
@@ -78,6 +78,17 @@ func (x *exercise) probes(ctx context.Context, inventory []string) error {
surface = "mcp"
}
entry := provider.LiveTool{Name: tool, Surface: surface, Exposed: true, Probes: map[string]provider.LiveObservation{}}
+ if !provider.PathProbeApplicable(tool) {
+ for i, key := range keys {
+ o, err := observation(x.root, fmt.Sprintf("probe-na-%d-%d-%d.json", x.sequence, len(x.evidence.Tools), i), "not-applicable", map[string]string{"tool": tool, "reason": "pinned tool schema cannot request a filesystem read"})
+ if err != nil {
+ return err
+ }
+ entry.Probes[key] = o
+ }
+ x.evidence.Tools = append(x.evidence.Tools, entry)
+ continue
+ }
var prompt strings.Builder
for _, key := range keys {
fmt.Fprintf(&prompt, "Use exactly the %s tool to attempt reading %s.\n", tool, targets[key])
@@ -157,3 +168,13 @@ func (x *exercise) calibration() error {
}
return nil
}
+
+func otherHomeTargets(c provider.DirectLiveConfig) map[string]string {
+ targets := map[string]string{}
+ for key, path := range c.Sentinels {
+ if key == "claude-other" || key == "codex-other" || strings.HasPrefix(key, "claude-other-") || strings.HasPrefix(key, "codex-other-") {
+ targets[key] = path
+ }
+ }
+ return targets
+}
diff --git a/internal/directlive/review_fixes_test.go b/internal/directlive/review_fixes_test.go
new file mode 100644
index 00000000..2973448b
--- /dev/null
+++ b/internal/directlive/review_fixes_test.go
@@ -0,0 +1,82 @@
+package directlive
+
+import (
+ "context"
+ "encoding/json"
+ "os"
+ "path/filepath"
+ "strconv"
+ "strings"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/runner/containment"
+ "amadan.net/oficina/equipo/internal/runner/provider"
+)
+
+func TestReviewResumeScratchAndParentIdentity(t *testing.T) {
+ root := t.TempDir()
+ if err := os.Chmod(root, 0700); err != nil {
+ t.Fatal(err)
+ }
+ paths := Paths{Bwrap: "/usr/bin/bwrap", Runner: os.Args[0]}
+ for _, name := range []string{"change-source-left", "change-policy-left", "unrelated"} {
+ if err := os.Mkdir(filepath.Join(root, name), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
+ boot, err := os.ReadFile("/proc/sys/kernel/random/boot_id")
+ if err != nil {
+ t.Fatal(err)
+ }
+ raw, err := os.ReadFile("/proc/self/stat")
+ if err != nil {
+ t.Fatal(err)
+ }
+ fields := strings.Fields(string(raw)[strings.LastIndexByte(string(raw), ')')+1:])
+ ticks, err := strconv.ParseUint(fields[19], 10, 64)
+ if err != nil {
+ t.Fatal(err)
+ }
+ r := containment.Record{ID: strings.Repeat("a", 32), AttemptKey: "fixture", ManifestHash: "fixture", BootID: strings.TrimSpace(string(boot)), PolicyHash: "fixture", ParentPID: os.Getpid(), ParentTicks: ticks}
+ record := filepath.Join(root, r.ID+".json")
+ write := func() {
+ t.Helper()
+ b, _ := json.Marshal(r)
+ if err := os.WriteFile(record, b, 0600); err != nil {
+ t.Fatal(err)
+ }
+ }
+ write()
+ if err := ResumeInterrupted(context.Background(), paths, root); err == nil {
+ t.Fatal("active parent accepted")
+ }
+ if _, err := os.Stat(filepath.Join(root, "change-source-left")); err != nil {
+ t.Fatal("active scratch removed")
+ }
+ r.ParentTicks++
+ write()
+ if err := ResumeInterrupted(context.Background(), paths, root); err != nil {
+ t.Fatal("reused PID blocked cleanup", err)
+ }
+ for _, name := range []string{"change-source-left", "change-policy-left"} {
+ if _, err := os.Stat(filepath.Join(root, name)); !os.IsNotExist(err) {
+ t.Fatal("stale scratch remains", name, err)
+ }
+ }
+ if _, err := os.Stat(filepath.Join(root, "unrelated")); err != nil {
+ t.Fatal("unrelated scratch removed", err)
+ }
+ if err := ResumeInterrupted(context.Background(), paths, root); err != nil {
+ t.Fatal(err)
+ }
+}
+
+func TestReviewAllOtherHomesProbed(t *testing.T) {
+ c := provider.DirectLiveConfig{Sentinels: map[string]string{"claude-other": "/claude/second", "codex-other": "/codex/second", "claude-other-3": "/claude/third"}}
+ targets := otherHomeTargets(c)
+ for key, path := range c.Sentinels {
+ if targets[key] != path {
+ t.Fatal("missing other home", key)
+ }
+ }
+}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index cfcbe9d6..bab99072 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -1112,56 +1112,55 @@ var copyOnboardingFirstInstructions = pageCopy["onboarding.first_instructions"]
func TryText(key string) string { return tryCopy[key] }
var tryCopy = map[string]string{
- "claude-accounts": "Total Claude accounts to connect", // COPY REVIEW PENDING: try.claude-accounts
- "codex-accounts": "Total Codex accounts to connect", // COPY REVIEW PENDING: try.codex-accounts
- "account-minimum": "Enter a whole number of at least %d. Keep all existing accounts connected.\n", // COPY REVIEW PENDING: try.account-minimum
- "duplicate-account": "This account is already connected in another home. Run the guide again and sign in to a different account.\n", // COPY REVIEW PENDING: try.duplicate-account
- // 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",
+ "config-value": "A configuration value contains unsupported shell characters. Correct that value and retry", // COPY REVIEW PENDING: try.config-value
+ "foreign-file": "A generated file was changed outside the guide. Preserve that change and restore the generated file before retrying", // COPY REVIEW PENDING: try.foreign-file
+ "input-required": "No valid answer was read. Run the guide from a terminal and answer the displayed question", // COPY REVIEW PENDING: try.input-required
+ "saved-state": "Saved setup is invalid. Check state.json in the try folder before retrying", // COPY REVIEW PENDING: try.saved-state
+ "private-file": "Setup needs a regular file with mode 0600. Correct the file permissions and retry", // COPY REVIEW PENDING: try.private-file
+ "private-directory": "Setup needs an absolute, unlinked directory with mode 0700. Correct the path or permissions and retry", // COPY REVIEW PENDING: try.private-directory
+ "go-required": "Missing prerequisite: Go. Install Go and run scripts/try-equipo.sh again.", // COPY REVIEW PENDING: try.go-required
+ "guide-busy": "Another guide holds the setup lock. Wait for it to finish before retrying", // COPY REVIEW PENDING: try.guide-busy
+ "login-failed": "The official sign-in did not finish. Follow its terminal instructions and run the guide again", // COPY REVIEW PENDING: try.login-failed
+ "confirmation-required": "The account was not confirmed. Run the guide again to confirm it or lower the account count to drop it", // COPY REVIEW PENDING: try.confirmation-required
+ "identity-mismatch": "The observed account does not match the confirmed identity. Sign in to the confirmed account in this dedicated home and retry", // COPY REVIEW PENDING: try.identity-mismatch
+ "account-check": "Account validation failed. Check this dedicated home and sign in again through the guide", // COPY REVIEW PENDING: try.account-check
+ "prerequisite-cause": "Cannot use %s: %v\n", // COPY REVIEW PENDING: try.prerequisite-cause
+ "executable-hash": "Executable does not match its pinned hash. Install the pinned version and retry", // COPY REVIEW PENDING: try.executable-hash
+ "executable-file": "Executable is not a runnable regular file. Correct its EQUIPO path or permissions", // COPY REVIEW PENDING: try.executable-file
+ "executable-home": "Executable is inside an interactive or ZeroSub home. Install the pinned CLI outside those homes and set its EQUIPO path", // COPY REVIEW PENDING: try.executable-home
+ "funding-invalid": "Funding limits must be positive whole numbers and seconds must be at most 86400. Enter valid limits on the next run", // COPY REVIEW PENDING: try.funding-invalid
+ "forge-path": "The Amadan credential must be an absolute path to a regular file with mode 0600. Correct its path or permissions", // COPY REVIEW PENDING: try.forge-path
+ "live-required": "The live gate was not authorized. Run the guide again and type RUN LIVE GATE to continue", // COPY REVIEW PENDING: try.live-required
+ "signin-required": "Sign-in was not authorized. Run the guide again and type SIGN IN to continue", // COPY REVIEW PENDING: try.signin-required
+ "root-user": "Root cannot run this guide. Run it as your own user", // COPY REVIEW PENDING: try.root-user
+ "system-home": "The system home could not be found. Check your operating system account before retrying", // COPY REVIEW PENDING: try.system-home
+ "terminal": "No terminal is available. Run the guide from an interactive terminal", // COPY REVIEW PENDING: try.terminal
+ "claude-accounts": "Total Claude accounts to connect", // COPY REVIEW PENDING: try.claude-accounts
+ "codex-accounts": "Total Codex accounts to connect", // COPY REVIEW PENDING: try.codex-accounts
+ "account-minimum": "Enter a whole number of at least %d. Keep all confirmed accounts connected. Lower the count to drop an unconfirmed account.\n", // COPY REVIEW PENDING: try.account-minimum
+ "duplicate-account": "This account is already connected in another home. Run the guide again and sign in to a different account.\n", // COPY REVIEW PENDING: try.duplicate-account
+ "prerequisite": "Missing prerequisite: %s. Install the pinned version outside interactive homes and run the guide again.\n", // COPY REVIEW PENDING: try.prerequisite
+ "prompt": "%s [%s]: ", // COPY REVIEW PENDING: try.prompt
+ "confirm": "Observed account for %s: %s. Confirm this account? [yes/no]: ", // COPY REVIEW PENDING: try.confirm
+ "login": "Signing in to %s in its dedicated home. Follow the official CLI instructions in this terminal.\n", // COPY REVIEW PENDING: try.login
+ "failed": "Stopped at %s: %v. Correct the cause above. Saved setup can be resumed by running scripts/try-equipo.sh again. No release was made.\n", // COPY REVIEW PENDING: try.failed
+ "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.ready
+ "live": "Type RUN LIVE GATE to authorize the displayed limits and disposable exercises", // COPY REVIEW PENDING: try.live
+ "signin": "Type SIGN IN to start official sign-ins in dedicated homes", // COPY REVIEW PENDING: try.signin
+ "instance": "Instance ID from Equipo", // COPY REVIEW PENDING: try.instance
+ "person": "Your Equipo person ID", // COPY REVIEW PENDING: try.person
+ "claude-model": "Exact Claude model", // COPY REVIEW PENDING: try.claude-model
+ "codex-model": "Exact Codex model", // COPY REVIEW PENDING: try.codex-model
+ "forge": "Absolute path to the runner's Amadan credential file", // COPY REVIEW PENDING: try.forge
+ "Calls": "Maximum calibration calls", // COPY REVIEW PENDING: try.Calls
+ "InputTokens": "Maximum calibration input tokens", // COPY REVIEW PENDING: try.InputTokens
+ "OutputTokens": "Maximum calibration output tokens", // COPY REVIEW PENDING: try.OutputTokens
+ "Seconds": "Maximum calibration seconds", // COPY REVIEW PENDING: try.Seconds
+ "JobInput": "Job input token funding", // COPY REVIEW PENDING: try.JobInput
+ "JobOutput": "Job output token funding", // COPY REVIEW PENDING: try.JobOutput
+ "ProjectInputHeadroom": "Remaining project input tokens", // COPY REVIEW PENDING: try.ProjectInputHeadroom
+ "ProjectOutputHeadroom": "Remaining project output tokens", // COPY REVIEW PENDING: try.ProjectOutputHeadroom
+ "TeamInputHeadroom": "Remaining team input tokens", // COPY REVIEW PENDING: try.TeamInputHeadroom
+ "TeamOutputHeadroom": "Remaining team output tokens", // COPY REVIEW PENDING: try.TeamOutputHeadroom
+ "limits": "Authorized limits: %s\n", // COPY REVIEW PENDING: try.limits
}
diff --git a/internal/runner/containment/recovery.go b/internal/runner/containment/recovery.go
index edf5cc42..d925cb0f 100644
--- a/internal/runner/containment/recovery.go
+++ b/internal/runner/containment/recovery.go
@@ -356,3 +356,34 @@ func (m *Manager) Forget(ctx context.Context, r Record) error {
m.mu.Unlock()
return nil
}
+
+// ControllerAlive compares the recorded boot and process start time before
+// treating a PID as the controller that owns interrupted certification files.
+func ControllerAlive(r Record) (bool, error) {
+ boot, err := bootID()
+ if err != nil {
+ return false, err
+ }
+ if boot != r.BootID {
+ return false, nil
+ }
+ if r.ParentPID <= 0 || r.ParentTicks == 0 {
+ return false, errIdentity
+ }
+ fd, err := unix.PidfdOpen(r.ParentPID, 0)
+ if err == unix.ESRCH {
+ return false, nil
+ }
+ if err != nil {
+ return false, err
+ }
+ defer unix.Close(fd)
+ ticks, _, err := identity(r.ParentPID)
+ if errors.Is(err, os.ErrNotExist) {
+ return false, nil
+ }
+ if err != nil {
+ return false, err
+ }
+ return ticks == r.ParentTicks, nil
+}
diff --git a/internal/runner/egress/policy.go b/internal/runner/egress/policy.go
index 49d4cad4..4416cc94 100644
--- a/internal/runner/egress/policy.go
+++ b/internal/runner/egress/policy.go
@@ -24,7 +24,7 @@ var ErrConflict = errors.New("egress_certified_auth_conflict")
var errPolicy = errors.New("egress_policy_rejected")
// ProviderPolicy consumes an installed contract, never model or permission input.
-// AuthHost remains empty until refresh certification pins an exact hostname.
+// V1 rejects auth hosts; expired logins need a new sign-in.
func ProviderPolicy(c provider.NetworkContract, dedicated bool) (Policy, error) {
if c.Conflict != "" {
return Policy{}, fmt.Errorf("%w: %s", ErrConflict, c.Conflict)
diff --git a/internal/runner/provider/accounts.go b/internal/runner/provider/accounts.go
index d678eb7e..f26d14c2 100644
--- a/internal/runner/provider/accounts.go
+++ b/internal/runner/provider/accounts.go
@@ -102,7 +102,7 @@ func privateDirectory(f *os.File) bool {
}
// AccountLease holds a directory flock until Close, including across preflight,
-// all turns and token refresh. Claude's identity is trust-on-first-use: Paul
+// all turns. Claude's identity is trust-on-first-use: Paul
// confirms CLI-observed metadata at enrolment. It is not remote attestation.
type AccountLease struct {
mu sync.Mutex
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go
index ab71e3a3..cb8b08f9 100644
--- a/internal/runner/provider/claude/launcher.go
+++ b/internal/runner/provider/claude/launcher.go
@@ -314,12 +314,7 @@ func (l *Launcher) preflight(ctx context.Context, b provider.Binding, lease *pro
return observed, e
}
if e = lease.Validate(ctx); errors.Is(e, provider.ErrRefreshPending) {
- if in.AuthHost == "" {
- return observed, provider.ErrAccountMaintenance
- }
- if e = lease.CommitRefresh(ctx, probe); e != nil {
- return observed, e
- }
+ return observed, provider.ErrAccountMaintenance
}
if e = lease.Preflight(ctx, probe); e != nil {
return observed, e
diff --git a/internal/runner/provider/claude/launcher_test.go b/internal/runner/provider/claude/launcher_test.go
index 6f55b993..97fd3f66 100644
--- a/internal/runner/provider/claude/launcher_test.go
+++ b/internal/runner/provider/claude/launcher_test.go
@@ -637,15 +637,20 @@ func TestClaudeRefreshBeforeTurn(t *testing.T) {
home = f.lease.Binding().Home
}
os.WriteFile(filepath.Join(home, ".credentials.json"), []byte(`{"fake":"new generation"}`), 0600)
- if e := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "t", AdmissionID: "a", Prompt: "tiny"}); e != nil {
- t.Fatal(e)
- }
- terminal(t, events)
+ e := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "t", AdmissionID: "a", Prompt: "tiny"})
if kind == "runtime" {
+ if !errors.Is(e, provider.ErrAccountMaintenance) {
+ t.Fatal("runtime refresh did not require sign-in", e)
+ }
got, _ := os.ReadFile(filepath.Join(f.lease.Binding().CredentialHome, ".credentials.json"))
- if string(got) != `{"fake":"new generation"}` {
- t.Fatal("refresh not committed before prompt")
+ if string(got) == `{"fake":"new generation"}` {
+ t.Fatal("runtime credentials committed")
+ }
+ } else {
+ if e != nil {
+ t.Fatal(e)
}
+ terminal(t, events)
}
})
}
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go
index c4c64a24..9191b0f1 100644
--- a/internal/runner/provider/codex/launcher.go
+++ b/internal/runner/provider/codex/launcher.go
@@ -446,12 +446,7 @@ func (l *Launcher) preflight(ctx context.Context, b provider.Binding, lease *pro
return observed, e
}
if errors.Is(e, provider.ErrRefreshPending) {
- if in.AuthHost == "" {
- return observed, provider.ErrAccountMaintenance
- }
- if e = lease.CommitRefresh(ctx, probe); e != nil {
- return observed, e
- }
+ return observed, provider.ErrAccountMaintenance
}
if e = lease.Preflight(ctx, probe); e != nil {
return observed, e
diff --git a/internal/runner/provider/codex/launcher_test.go b/internal/runner/provider/codex/launcher_test.go
index 235b44e6..50278c2a 100644
--- a/internal/runner/provider/codex/launcher_test.go
+++ b/internal/runner/provider/codex/launcher_test.go
@@ -526,17 +526,17 @@ func TestCodexRefreshAndAdmission(t *testing.T) {
terminal(t, ch)
checks := f.host.count("account/read")
os.WriteFile(filepath.Join(f.launch.Binding.Home, "auth.json"), []byte(`{"fake":"refreshed"}`), 0600)
- if e := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "l2", AdmissionID: "a2", Prompt: "again"}); e != nil {
- t.Fatal(e)
+ if e := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "l2", AdmissionID: "a2", Prompt: "again"}); !errors.Is(e, provider.ErrAccountMaintenance) {
+ t.Fatal("runtime refresh did not require sign-in", e)
}
- terminal(t, ch)
- if f.host.count("account/read") < checks+3 {
- t.Fatal("refresh missed commit/preflight/readback")
+ if f.host.count("account/read") != checks {
+ t.Fatal("refresh ran an identity probe")
}
raw, _ := os.ReadFile(filepath.Join(f.launch.Binding.CredentialHome, "auth.json"))
- if string(raw) != `{"fake":"refreshed"}` {
- t.Fatal("refresh not committed")
+ if string(raw) == `{"fake":"refreshed"}` {
+ t.Fatal("runtime credentials committed")
}
+
if e := f.l.StartTurn(context.Background(), s, turn); e == nil {
t.Fatal("admission replayed")
}
@@ -797,8 +797,8 @@ func TestCodexRefreshRejectsChangedIdentity(t *testing.T) {
if e := f.l.StartTurn(context.Background(), s, provider.Turn{ID: "t2", AdmissionID: "a2", Prompt: "again"}); e == nil {
t.Fatal("wrong identity refreshed")
}
- if e := f.lease.Validate(context.Background()); !errors.Is(e, provider.ErrContainment) {
- t.Fatal("identity failure did not latch containment", e)
+ if e := f.lease.Validate(context.Background()); !errors.Is(e, provider.ErrRefreshPending) {
+ t.Fatal("runtime login did not remain pending sign-in", e)
}
raw, _ := os.ReadFile(filepath.Join(f.launch.Binding.CredentialHome, "auth.json"))
if bytes.Contains(raw, []byte("other login")) {
diff --git a/internal/runner/provider/direct_certification.go b/internal/runner/provider/direct_certification.go
index 15319102..e68d2c5a 100644
--- a/internal/runner/provider/direct_certification.go
+++ b/internal/runner/provider/direct_certification.go
@@ -220,7 +220,11 @@ func (e DirectEvidence) validateTools(root string, probes bool) error {
}
if probes {
for _, path := range []string{"selected-home", "other-home", "runner-state", "/egress", "/tool/equipo.sock", "symlink", "/proc/*/root", "/proc/*/fd", "/dev/fd"} {
- if VerifyDirectObservation(root, tool.Probes[path], "denied") != nil {
+ status := "denied"
+ if !PathProbeApplicable(tool.Name) {
+ status = "not-applicable"
+ }
+ if VerifyDirectObservation(root, tool.Probes[path], status) != nil {
return ErrPolicy
}
}
diff --git a/internal/runner/provider/path_tools.go b/internal/runner/provider/path_tools.go
new file mode 100644
index 00000000..edf69841
--- /dev/null
+++ b/internal/runner/provider/path_tools.go
@@ -0,0 +1,19 @@
+package provider
+
+// PathProbeApplicable excludes only pinned tools whose input cannot request a
+// filesystem read. Unknown tools still require evidence of denied reads.
+func PathProbeApplicable(tool string) bool {
+ switch tool {
+ case "mcp__equipo__ask_person", "mcp__equipo__permission",
+ "mcp__equipo__submit_candidate", "mcp__equipo__submit_review",
+ "mcp__equipo__submit_reproduction", "mcp__equipo__submit_acceptance",
+ "mcp__equipo__submit_answer", "mcp__equipo__submit_render",
+ "mcp__equipo__read_project", "mcp__equipo__read_task",
+ "mcp__equipo__propose_plan", "mcp__equipo__route_to_task",
+ "mcp__equipo__post_message", "mcp__equipo__suggest_preference",
+ "mcp__equipo__suggest_specialist", "mcp__equipo__suggest_playbook",
+ "list_mcp_resources", "list_mcp_resource_templates", "read_mcp_resource", "web_search", "update_plan", "request_user_input":
+ return false
+ }
+ return true
+}
diff --git a/internal/runner/provider/review_tools_test.go b/internal/runner/provider/review_tools_test.go
new file mode 100644
index 00000000..b7498ad6
--- /dev/null
+++ b/internal/runner/provider/review_tools_test.go
@@ -0,0 +1,24 @@
+package provider
+
+import "testing"
+
+func TestReviewPathlessToolEvidence(t *testing.T) {
+ e, root := directEvidenceFixture(t)
+ tool := LiveTool{Name: "mcp__equipo__ask_person", Surface: "mcp", Exposed: true, Probes: map[string]LiveObservation{}}
+ for path, o := range e.Tools[0].Probes {
+ o.Status = "not-applicable"
+ tool.Probes[path] = o
+ }
+ e.Tools = append(e.Tools, tool)
+ if err := e.validateTools(root, true); err != nil {
+ t.Fatal("pathless tool was not applicable", err)
+ }
+ e.Tools[len(e.Tools)-1].Name = "read_file"
+ if err := e.validateTools(root, true); err == nil {
+ t.Fatal("reader bypassed probes")
+ }
+ e.Tools[len(e.Tools)-1].Name = "unknown_tool"
+ if err := e.validateTools(root, true); err == nil {
+ t.Fatal("unknown tool bypassed probes")
+ }
+}
diff --git a/internal/runner/provider/types.go b/internal/runner/provider/types.go
index cfc0323f..19cbfde4 100644
--- a/internal/runner/provider/types.go
+++ b/internal/runner/provider/types.go
@@ -23,7 +23,7 @@ type Binding struct {
}
// NetworkContract is installed by the runner, never supplied by a permission answer.
-// AuthHost is empty until Task 11b certifies refresh for this provider.
+// V1 requires AuthHost to be empty; expired logins need a new sign-in.
type NetworkContract struct {
Conflict string
Provider string
diff --git a/internal/runner/setup/account_bindings.go b/internal/runner/setup/account_bindings.go
index 3be1a052..d194ddca 100644
--- a/internal/runner/setup/account_bindings.go
+++ b/internal/runner/setup/account_bindings.go
@@ -27,8 +27,8 @@ type AccountBinding struct {
Kind string `json:"kind"`
}
-// SaveAccountBinding appends a verified account atomically. Refresh belongs to
-// AccountLease, so this path refuses any existing account identity or home.
+// SaveAccountBinding appends a verified account atomically and refuses any
+// existing account identity or home.
func SaveAccountBinding(ctx context.Context, path, person, model string, s runnerproto.AccountSetup, b provider.Binding) error {
if err := ctx.Err(); err != nil {
return err
diff --git a/internal/tryequipo/account_set.go b/internal/tryequipo/account_set.go
index a4d9a0fa..26b3beb5 100644
--- a/internal/tryequipo/account_set.go
+++ b/internal/tryequipo/account_set.go
@@ -3,6 +3,7 @@ package tryequipo
import (
"context"
"fmt"
+ "sort"
"strconv"
"strings"
@@ -26,14 +27,13 @@ func (w *Wizard) connectAccounts(ctx context.Context, paths map[string]string) (
counts := map[string]int{}
for _, family := range []string{"claude", "codex"} {
minimum := 2
- for key := range w.State.Homes {
- for index := 1; index <= len(w.State.Homes)+1; index++ {
- if key == accountKey(family, index) {
- minimum = max(minimum, index)
- break
- }
+ confirmed := 0
+ for key, home := range w.State.Homes {
+ if accountFamily(key) == family && home.Identity.AccountID != "" {
+ confirmed++
}
}
+ minimum = max(minimum, confirmed)
def := max(minimum, map[string]int{"claude": 6, "codex": 2}[family])
key := family + "-accounts"
if saved, err := strconv.Atoi(w.State.Values[key]); err == nil {
@@ -50,16 +50,37 @@ func (w *Wizard) connectAccounts(ctx context.Context, paths map[string]string) (
}
counts[family] = count
}
- for family, count := range counts {
+ selected := map[string][]string{}
+ for _, family := range []string{"claude", "codex"} {
+ count := counts[family]
w.State.Values[family+"-accounts"] = strconv.Itoa(count)
+ used := map[string]bool{}
+ for key, h := range w.State.Homes {
+ if accountFamily(key) == family && h.Identity.AccountID != "" {
+ selected[family] = append(selected[family], key)
+ used[key] = true
+ }
+ }
+ for index := 1; len(selected[family]) < count; index++ {
+ key := accountKey(family, index)
+ if !used[key] {
+ selected[family] = append(selected[family], key)
+ used[key] = true
+ }
+ }
+ sort.Slice(selected[family], func(i, j int) bool { return accountIndex(selected[family][i]) < accountIndex(selected[family][j]) })
+ for key, h := range w.State.Homes {
+ if accountFamily(key) == family && h.Identity.AccountID == "" && !used[key] {
+ delete(w.State.Homes, key)
+ }
+ }
}
if err := w.save(); err != nil {
return nil, err
}
var bindings []provider.Binding
for _, family := range []string{"claude", "codex"} {
- for index := 1; index <= counts[family]; index++ {
- key := accountKey(family, index)
+ for _, key := range selected[family] {
w.phase = key
b, err := w.account(ctx, key, family, paths["EQUIPO_"+strings.ToUpper(family)+"_PATH"])
if err != nil {
@@ -87,3 +108,22 @@ func (w *Wizard) writeBindings(path string, bindings []provider.Binding) error {
}
return w.ownedJSON(path, rows)
}
+
+func accountFamily(key string) string {
+ for _, family := range []string{"claude", "codex"} {
+ if key == family || strings.HasPrefix(key, family+"-") {
+ return family
+ }
+ }
+ return ""
+}
+func accountIndex(key string) int {
+ switch key {
+ case "claude-a", "codex":
+ return 1
+ case "claude-b":
+ return 2
+ }
+ index, _ := strconv.Atoi(strings.TrimPrefix(key, accountFamily(key)+"-"))
+ return index
+}
diff --git a/internal/tryequipo/accounts.go b/internal/tryequipo/accounts.go
index 30f14454..defe25f6 100644
--- a/internal/tryequipo/accounts.go
+++ b/internal/tryequipo/accounts.go
@@ -4,6 +4,7 @@ import (
"context"
"crypto/rand"
"encoding/json"
+ "errors"
"fmt"
"golang.org/x/sys/unix"
"os"
@@ -17,6 +18,7 @@ import (
func (w *Wizard) account(ctx context.Context, key, family, binary string) (provider.Binding, error) {
h := w.State.Homes[key]
+ confirmedAtStart := h.Identity.AccountID != ""
if h.Path == "" {
home, err := provider.NewLoginHome(w.Accounts)
if err != nil {
@@ -54,6 +56,26 @@ func (w *Wizard) account(ctx context.Context, key, family, binary string) (provi
})
b := provider.Binding{ID: key, Home: h.Path, Provider: family}
id, err := probe.Probe(ctx, b)
+ if err == nil && h.Identity.AccountID != "" {
+ b.Expected, b.AccountID = h.Identity, h.Identity.AccountID
+ // Confirmation is saved before its marker. Finish an interrupted write
+ // only after the provider has observed that same confirmed identity.
+ if _, e := os.Lstat(filepath.Join(h.Path, provider.IdentityFile)); os.IsNotExist(e) && id.AccountID == h.Identity.AccountID && id.ProviderVersion == h.Identity.ProviderVersion {
+ if e := writeJSON(filepath.Join(h.Path, provider.IdentityFile), h.Identity); e != nil {
+ return b, e
+ }
+ }
+ if err = unix.Flock(int(lock.Fd()), unix.LOCK_UN); err != nil {
+ return b, err
+ }
+ err = w.validateAccount(ctx, b)
+ if err != nil && !errors.Is(err, provider.ErrAccountMaintenance) {
+ return b, refusal("account-check", err)
+ }
+ if e := unix.Flock(int(lock.Fd()), unix.LOCK_EX|unix.LOCK_NB); e != nil {
+ return b, provider.ErrAccountBusy
+ }
+ }
// A refused duplicate is unconfirmed. Let its next invocation sign in to
// another account without disturbing any confirmed home's credentials.
if err == nil && h.Identity.AccountID == "" && w.duplicateAccount(key, family, id.AccountID) {
@@ -63,17 +85,17 @@ func (w *Wizard) account(ctx context.Context, key, family, binary string) (provi
fmt.Fprintf(w.Output, equipo.TryText("login"), key)
args := []string{"auth", "login"}
if family == "codex" {
- args = []string{"login"}
+ args = []string{"login", "--device-auth"}
}
- // The official CLI opens the browser. Its output is never copied to logs.
+ // The provider writes its instructions directly to the terminal.
env := provider.LoginEnvironment(family, h.Path)
- for _, key := range []string{"BROWSER", "DISPLAY", "WAYLAND_DISPLAY", "XDG_RUNTIME_DIR", "DBUS_SESSION_BUS_ADDRESS"} {
+ for _, key := range []string{"SHET_BRIDGE", "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
+ if err = w.loginCommand(ctx, binary, args, h.Path, env); err != nil {
+ return b, refusal("login-failed", err)
}
id, err = probe.Probe(ctx, b)
if err != nil {
@@ -81,15 +103,15 @@ func (w *Wizard) account(ctx context.Context, key, family, binary string) (provi
}
}
if strings.ContainsAny(id.AccountID, "\r\n\x1b") {
- return b, provider.ErrIdentity
+ return b, refusal("identity-mismatch", provider.ErrIdentity)
}
if w.duplicateAccount(key, family, id.AccountID) {
fmt.Fprint(w.Output, equipo.TryText("duplicate-account"))
- return b, provider.ErrIdentity
+ return b, refusal("identity-mismatch", provider.ErrIdentity)
}
if h.Identity.AccountID != "" {
if id.AccountID != h.Identity.AccountID || id.ProviderVersion != h.Identity.ProviderVersion {
- return b, provider.ErrIdentity
+ return b, refusal("identity-mismatch", provider.ErrIdentity)
}
} else {
fmt.Fprintf(w.Output, equipo.TryText("confirm"), key, id.AccountID)
@@ -98,7 +120,7 @@ func (w *Wizard) account(ctx context.Context, key, family, binary string) (provi
return b, err
}
if strings.TrimSpace(answer) != "yes" {
- return b, provider.ErrIdentity
+ return b, refusal("confirmation-required", provider.ErrIdentity)
}
id.HomeID = rand.Text()
h.Identity = id
@@ -111,7 +133,7 @@ func (w *Wizard) account(ctx context.Context, key, family, binary string) (provi
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
+ return b, refusal("identity-mismatch", provider.ErrIdentity)
}
} else if !os.IsNotExist(err) {
return b, err
@@ -121,5 +143,35 @@ func (w *Wizard) account(ctx context.Context, key, family, binary string) (provi
}
b.Expected = h.Identity
b.AccountID = h.Identity.AccountID
+ if err = unix.Flock(int(lock.Fd()), unix.LOCK_UN); err != nil {
+ return b, err
+ }
+ if err = w.validateAccount(ctx, b); err != nil {
+ if errors.Is(err, provider.ErrAccountMaintenance) && !confirmedAtStart {
+ // The new identity is now confirmed, so the next pass can check
+ // this home before sign-in. A second maintenance failure stops.
+ return w.account(ctx, key, family, binary)
+ }
+ return b, refusal("account-check", err)
+ }
return b, nil
}
+
+func (w *Wizard) validateAccount(ctx context.Context, b provider.Binding) error {
+ root, err := os.MkdirTemp(w.Root, "validate-")
+ if err != nil {
+ return err
+ }
+ defer os.RemoveAll(root)
+ b.RuntimeRoot = filepath.Join(root, "homes")
+ lease, err := provider.OpenAccount(ctx, b)
+ if err != nil {
+ return err
+ }
+ defer lease.Close()
+ err = lease.Validate(ctx)
+ if errors.Is(err, provider.ErrPreflightRequired) {
+ return nil
+ }
+ return err
+}
diff --git a/internal/tryequipo/accounts_test.go b/internal/tryequipo/accounts_test.go
index 4d73ab41..6b786a5e 100644
--- a/internal/tryequipo/accounts_test.go
+++ b/internal/tryequipo/accounts_test.go
@@ -12,6 +12,7 @@ import (
)
func TestAccountResumeAndMismatch(t *testing.T) {
+ t.Parallel()
root := t.TempDir()
if err := os.Chmod(root, 0700); err != nil {
t.Fatal(err)
@@ -35,6 +36,7 @@ esac
}
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.openTerminal = func() (*os.File, error) { return os.OpenFile(os.DevNull, os.O_RDWR, 0) }
w.init()
// Interrupted confirmation keeps the signed-in dedicated home for a rerun.
w.reader.Reset(strings.NewReader(""))
@@ -88,6 +90,7 @@ func TestRefuseInteractiveHome(t *testing.T) {
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.openTerminal = func() (*os.File, error) { return os.OpenFile(os.DevNull, os.O_RDWR, 0) }
w.init()
if _, err := w.account(context.Background(), "claude-a", "claude", binary); err == nil {
t.Fatal("interactive home adopted")
@@ -114,7 +117,7 @@ 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']:
+elif sys.argv[1:] == ['login','--device-auth']:
with open(home+'/auth.json','w') as f: f.write('{"fixture":true}')
os.chmod(home+'/auth.json',0o600)
print('https://secret.invalid/token')
@@ -138,6 +141,7 @@ else: sys.exit(2)
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.openTerminal = func() (*os.File, error) { return os.OpenFile(os.DevNull, os.O_RDWR, 0) }
w.init()
b, err := w.account(context.Background(), "codex", "codex", binary)
if err != nil {
@@ -158,12 +162,14 @@ else: sys.exit(2)
}
func TestResumeInterruptedConfigurationWrite(t *testing.T) {
+ t.Parallel()
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.openTerminal = func() (*os.File, error) { return os.OpenFile(os.DevNull, os.O_RDWR, 0) }
w.init()
prior := []byte("interrupted replacement")
if err := privateWrite(path, prior); err != nil {
@@ -182,11 +188,13 @@ func TestResumeInterruptedConfigurationWrite(t *testing.T) {
}
func TestSavedSetupValueCanBeCorrected(t *testing.T) {
+ t.Parallel()
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.openTerminal = func() (*os.File, error) { return os.OpenFile(os.DevNull, os.O_RDWR, 0) }
w.init()
got, err := w.value("forge", "")
if err != nil || got != "/corrected/path" {
diff --git a/internal/tryequipo/budget_test.go b/internal/tryequipo/budget_test.go
index c28574de..05ef9953 100644
--- a/internal/tryequipo/budget_test.go
+++ b/internal/tryequipo/budget_test.go
@@ -6,4 +6,11 @@ import (
"testing"
)
-func TestMain(m *testing.M) { os.Exit(budget.Main(m)) }
+func TestMain(m *testing.M) {
+ // Fake sign-ins verify bridge forwarding. Keep this test-process value fixed
+ // so independent account fixtures can run together without changing the env.
+ if err := os.Setenv("SHET_BRIDGE", "fixture-bridge"); err != nil {
+ panic(err)
+ }
+ os.Exit(budget.Main(m))
+}
diff --git a/internal/tryequipo/command.go b/internal/tryequipo/command.go
index 31fb1c4c..b371308b 100644
--- a/internal/tryequipo/command.go
+++ b/internal/tryequipo/command.go
@@ -4,6 +4,7 @@ import (
"bytes"
"context"
"io"
+ "os"
"os/exec"
"syscall"
"time"
@@ -17,16 +18,48 @@ func (b *boundedOutput) Write(p []byte) (int, error) {
}
return b.Buffer.Write(p)
}
-func command(ctx context.Context, path string, args []string, dir string, env []string, input io.Reader) ([]byte, error) {
+func childCommand(ctx context.Context, path string, args []string, dir string, env []string, terminal bool) *exec.Cmd {
cmd := exec.CommandContext(ctx, path, args...)
- cmd.Dir = dir
- cmd.Env = env
+ cmd.Dir, cmd.Env = dir, env
+ if !terminal {
+ cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
+ cmd.Cancel = func() error { return syscall.Kill(-cmd.Process.Pid, syscall.SIGTERM) }
+ }
+ cmd.WaitDelay = 2 * time.Second
+ return cmd
+}
+func command(ctx context.Context, path string, args []string, dir string, env []string, input io.Reader) ([]byte, error) {
+ cmd := childCommand(ctx, path, args, dir, env, false)
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
+ cmd.Stdout, cmd.Stderr = out, out
err := cmd.Run()
return out.Bytes(), err
}
+func gateCommand(ctx context.Context, path string, args []string, dir string, env []string) ([]byte, error) {
+ cmd := childCommand(ctx, path, args, dir, env, true)
+ out := &boundedOutput{}
+ cmd.Stdout, cmd.Stderr = out, out
+ err := cmd.Run()
+ return out.Bytes(), err
+}
+func (w *Wizard) loginCommand(ctx context.Context, path string, args []string, dir string, env []string) error {
+ open := w.openTerminal
+ if open == nil {
+ open = func() (*os.File, error) { return os.OpenFile("/dev/tty", os.O_RDWR, 0) }
+ }
+ tty, err := open()
+ if err != nil {
+ return refusal("terminal", err)
+ }
+ defer tty.Close()
+ cmd := childCommand(ctx, path, args, dir, env, true)
+ // Give the provider the terminal descriptors directly. No pipe or buffer
+ // carries sign-in output through the guide.
+ cmd.Stdin, cmd.Stdout, cmd.Stderr = tty, tty, tty
+ return cmd.Run()
+}
+
+func liveGateArgs() []string {
+ return []string{"test", "-timeout=0", "-tags", "direct_live", "./internal/runner/provider", "-run", "^TestDirectLive(Contract|Isolation|Recovery|Calibration)$", "-count=1"}
+}
diff --git a/internal/tryequipo/config.go b/internal/tryequipo/config.go
index 76985fe1..6a47f536 100644
--- a/internal/tryequipo/config.go
+++ b/internal/tryequipo/config.go
@@ -4,6 +4,7 @@ import (
"amadan.net/oficina/equipo/internal/runner/provider"
"context"
"encoding/json"
+ "fmt"
"os"
"path/filepath"
)
@@ -22,7 +23,8 @@ func (w *Wizard) build(ctx context.Context, paths map[string]string) error {
}
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 {
+ if out, err := command(ctx, paths["EQUIPO_GO_BINARY"], args, w.Repository, env, nil); err != nil {
+ fmt.Fprintln(w.Output, string(out))
return err
}
key := "EQUIPO_TOOL_PROXY_PATH"
@@ -56,6 +58,8 @@ func (w *Wizard) config(ctx context.Context, root string, paths map[string]strin
} else if _, exists := c.AccountChanges[b.Provider]; !exists {
c.AccountChanges[b.Provider] = b
c.Sentinels[b.Provider+"-other"] = filepath.Join(b.Home, "equipo-try-sentinel")
+ } else {
+ c.Sentinels[b.Provider+"-other-"+b.ID] = filepath.Join(b.Home, "equipo-try-sentinel")
}
}
if len(c.AccountChanges) != 2 {
diff --git a/internal/tryequipo/diagnostics.go b/internal/tryequipo/diagnostics.go
new file mode 100644
index 00000000..110da297
--- /dev/null
+++ b/internal/tryequipo/diagnostics.go
@@ -0,0 +1,28 @@
+package tryequipo
+
+import (
+ "fmt"
+ "io"
+ "os"
+ "os/user"
+ "path/filepath"
+ "strconv"
+
+ "amadan.net/oficina/equipo/internal/equipo"
+ "amadan.net/oficina/equipo/internal/runner/provider"
+)
+
+func refusal(key string, err error) error { return fmt.Errorf("%s: %w", equipo.TryText(key), err) }
+func ReportFailure(out io.Writer, phase string, err error) {
+ fmt.Fprintf(out, equipo.TryText("failed"), phase, err)
+}
+func SystemHome() (string, error) {
+ u, err := user.LookupId(strconv.Itoa(os.Geteuid()))
+ if err != nil {
+ return "", refusal("system-home", err)
+ }
+ if !filepath.IsAbs(u.HomeDir) || filepath.Clean(u.HomeDir) != u.HomeDir || u.HomeDir == "/" {
+ return "", refusal("system-home", provider.ErrPolicy)
+ }
+ return u.HomeDir, nil
+}
diff --git a/internal/tryequipo/executable.go b/internal/tryequipo/executable.go
new file mode 100644
index 00000000..d829d37f
--- /dev/null
+++ b/internal/tryequipo/executable.go
@@ -0,0 +1,75 @@
+package tryequipo
+
+import (
+ "os"
+ "path/filepath"
+
+ "amadan.net/oficina/equipo/internal/runner/provider"
+)
+
+func executablePath(path string) (string, error) {
+ absolute, err := filepath.Abs(path)
+ if err != nil {
+ return "", err
+ }
+ real, err := filepath.EvalSymlinks(absolute)
+ if err != nil {
+ return "", err
+ }
+ rules := provider.DefaultHomeRules()
+ if rules.RefusesPath(absolute) || rules.RefusesPath(real) {
+ return "", refusal("executable-home", provider.ErrPolicy)
+ }
+ st, err := os.Stat(real)
+ if err != nil {
+ return "", err
+ }
+ if !st.Mode().IsRegular() || st.Mode().Perm()&0111 == 0 {
+ return "", refusal("executable-file", provider.ErrPolicy)
+ }
+ return real, nil
+}
+func pinExecutable(source, dir, name, hash string) (string, error) {
+ source, err := executablePath(source)
+ if err != nil {
+ return "", err
+ }
+ raw, err := os.ReadFile(source)
+ if err != nil {
+ return "", err
+ }
+ if provider.DigestDirectEvidence(raw) != hash {
+ return "", refusal("executable-hash", provider.ErrPolicy)
+ }
+ if err := privateDir(dir); err != nil {
+ return "", err
+ }
+ path := filepath.Join(dir, name)
+ if st, err := os.Lstat(path); err == nil && (!st.Mode().IsRegular() || st.Mode().Perm() != 0700) {
+ return "", provider.ErrPolicy
+ } else if err != nil && !os.IsNotExist(err) {
+ return "", err
+ }
+ f, err := os.CreateTemp(dir, ".executable-")
+ if err != nil {
+ return "", err
+ }
+ defer os.Remove(f.Name())
+ if _, err = f.Write(raw); err == nil {
+ err = f.Chmod(0700)
+ }
+ if err == nil {
+ err = f.Sync()
+ }
+ closeErr := f.Close()
+ if err != nil {
+ return "", err
+ }
+ if closeErr != nil {
+ return "", closeErr
+ }
+ if err = os.Rename(f.Name(), path); err != nil {
+ return "", err
+ }
+ return path, nil
+}
diff --git a/internal/tryequipo/multiple_accounts_test.go b/internal/tryequipo/multiple_accounts_test.go
index c50c806c..dcdd9b8a 100644
--- a/internal/tryequipo/multiple_accounts_test.go
+++ b/internal/tryequipo/multiple_accounts_test.go
@@ -35,7 +35,8 @@ assert 'OPENAI_API_KEY' not in os.environ and 'ANTHROPIC_API_KEY' not in os.envi
credential=home+('/.credentials.json' if family=='claude' else '/auth.json')
if sys.argv[1:]==['--version']: print('2.1.312 (Claude Code)' if family=='claude' else 'codex-cli 0.165.0')
elif '--help' in sys.argv: pass
-elif sys.argv[1:]==(['auth','login'] if family=='claude' else ['login']):
+elif sys.argv[1:]==(['auth','login'] if family=='claude' else ['login','--device-auth']):
+ assert os.environ.get('SHET_BRIDGE')=='fixture-bridge'
with open(%q,'a') as f: f.write(home+'\n')
identity=open(home+'/next-identity').read() if os.path.exists(home+'/next-identity') else os.path.basename(home)+'@example.invalid'
with open(credential,'w') as f: json.dump({'email':identity},f)
@@ -65,11 +66,13 @@ else: sys.exit(2)
paths["EQUIPO_"+strings.ToUpper(family)+"_PATH"] = binary
}
w := &Wizard{Root: root, Accounts: accounts, Input: strings.NewReader(input), Output: &bytes.Buffer{}}
+ w.openTerminal = func() (*os.File, error) { return os.OpenFile(os.DevNull, os.O_RDWR, 0) }
w.init()
return w, paths, log
}
func TestConnectAllAccountsAndAddOnRerun(t *testing.T) {
+ t.Parallel()
w, paths, log := multiAccountWizard(t, "\n\n"+strings.Repeat("yes\n", 8))
bindings, err := w.connectAccounts(context.Background(), paths)
if err != nil {
@@ -189,6 +192,7 @@ func TestConnectAllAccountsAndAddOnRerun(t *testing.T) {
}
func TestAccountCountMinimumAndNoRemoval(t *testing.T) {
+ t.Parallel()
for _, input := range []string{"1\n2\n", "2\n1\n", "0\n", "-1\n", "many\n"} {
t.Run(strings.TrimSpace(input), func(t *testing.T) {
w, paths, log := multiAccountWizard(t, input)
@@ -211,6 +215,7 @@ func TestAccountCountMinimumAndNoRemoval(t *testing.T) {
}
func TestDuplicateAccountRefusedAndRetryable(t *testing.T) {
+ t.Parallel()
for _, family := range []string{"claude", "codex"} {
t.Run(family, func(t *testing.T) {
w, paths, _ := multiAccountWizard(t, "yes\nyes\n")
@@ -244,6 +249,7 @@ func TestDuplicateAccountRefusedAndRetryable(t *testing.T) {
}
func TestLiveConfigAccountChangeBothProviders(t *testing.T) {
+ t.Parallel()
w, paths, _ := multiAccountWizard(t, "\n\n"+strings.Repeat("yes\n", 8))
bindings, err := w.connectAccounts(context.Background(), paths)
if err != nil {
@@ -269,6 +275,17 @@ func TestLiveConfigAccountChangeBothProviders(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+ for _, b := range bindings {
+ found := false
+ for _, path := range config.Sentinels {
+ if path == filepath.Join(b.Home, "equipo-try-sentinel") {
+ found = true
+ }
+ }
+ if !found {
+ t.Fatal("connected home omitted from probes", b.ID)
+ }
+ }
var wire struct {
AccountChanges map[string]provider.Binding `json:"account_changes"`
}
@@ -287,6 +304,7 @@ func TestLiveConfigAccountChangeBothProviders(t *testing.T) {
}
func TestUpgradeOriginalThreeHomes(t *testing.T) {
+ t.Parallel()
w, paths, log := multiAccountWizard(t, strings.Repeat("yes\n", 3))
for _, spec := range [][2]string{{"claude-a", "claude"}, {"claude-b", "claude"}, {"codex", "codex"}} {
if _, err := w.account(context.Background(), spec[0], spec[1], paths["EQUIPO_"+strings.ToUpper(spec[1])+"_PATH"]); err != nil {
diff --git a/internal/tryequipo/prerequisites.go b/internal/tryequipo/prerequisites.go
index f1a9023a..c3ee0b31 100644
--- a/internal/tryequipo/prerequisites.go
+++ b/internal/tryequipo/prerequisites.go
@@ -17,6 +17,7 @@ import (
func (w *Wizard) prerequisites(ctx context.Context) (map[string]string, error) {
paths := map[string]string{}
+ var codexSource string
missing := false
scratch, err := os.MkdirTemp(w.Root, "prerequisites-")
if err != nil {
@@ -30,25 +31,19 @@ func (w *Wizard) prerequisites(ctx context.Context) (map[string]string, error) {
{"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)
+ path, resolveErr := resolveExecutable(d.Name, os.Getenv(d.Variable), codexSource)
+ err = resolveErr
+ if err == nil && d.Name == "codex" {
+ codexSource = path
}
- if err == nil {
- path, err = filepath.EvalSymlinks(path)
- }
- if err == nil {
- path, err = filepath.Abs(path)
+ if err == nil && d.Hash != "" {
+ path, err = pinExecutable(path, filepath.Join(w.Root, "bin"), d.Name, d.Hash)
}
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 err != nil {
+ fmt.Fprintf(w.Output, equipo.TryText("prerequisite-cause"), d.Name, err)
}
+
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)
@@ -82,3 +77,20 @@ func (w *Wizard) prerequisites(ctx context.Context) (map[string]string, error) {
paths["EQUIPO_GO_ROOT"] = strings.TrimSpace(string(out))
return paths, nil
}
+
+func resolveExecutable(name, configured, codexSource string) (string, error) {
+ path := configured
+ var err error
+ if name == "codex-code-mode-host" {
+ if codexSource == "" {
+ return "", provider.ErrCapability
+ }
+ path = filepath.Join(filepath.Dir(codexSource), name)
+ } else if path == "" {
+ path, err = exec.LookPath(name)
+ }
+ if err != nil {
+ return "", err
+ }
+ return executablePath(path)
+}
diff --git a/internal/tryequipo/review_fixes_test.go b/internal/tryequipo/review_fixes_test.go
new file mode 100644
index 00000000..002785ab
--- /dev/null
+++ b/internal/tryequipo/review_fixes_test.go
@@ -0,0 +1,323 @@
+package tryequipo
+
+import (
+ "bytes"
+ "context"
+ "fmt"
+ "os"
+ "os/exec"
+ "os/user"
+ "path/filepath"
+ "strings"
+ "testing"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/runner/provider"
+)
+
+func TestReviewTerminalHelper(t *testing.T) {
+ mode := os.Getenv("EQUIPO_TEST_TERMINAL")
+ if mode == "" {
+ return
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
+ defer cancel()
+ script := `import os,sys
+fd=os.open('/dev/tty',os.O_RDWR)
+os.write(fd,b'tty-ready\n')
+assert os.read(fd,100).strip()==b'answer'
+print('provider-code',flush=True)
+print('provider-error',file=sys.stderr,flush=True)
+`
+ if mode == "login" {
+ w := Wizard{}
+ if err := w.loginCommand(ctx, "/usr/bin/python3", []string{"-c", script}, "", os.Environ()); err != nil {
+ t.Fatal(err)
+ }
+ } else {
+ out, err := gateCommand(ctx, "/usr/bin/python3", []string{"-c", script}, "", os.Environ())
+ if err != nil || !bytes.Contains(out, []byte("provider-error")) || !bytes.Contains(out, []byte("provider-code")) {
+ t.Fatalf("gate terminal or stderr: %q %v", out, err)
+ }
+ }
+}
+
+func TestReviewForegroundTerminal(t *testing.T) {
+ t.Parallel()
+ for _, mode := range []string{"login", "gate"} {
+ t.Run(mode, func(t *testing.T) {
+ script := `import os,pty,select,signal,sys,time
+pid,fd=pty.fork()
+if pid==0:
+ os.environ['EQUIPO_TEST_TERMINAL']=sys.argv[2]
+ os.execv(sys.argv[1],[sys.argv[1],'-test.run=^TestReviewTerminalHelper$'])
+data=b''
+got=0
+sent=False
+try:
+ deadline=time.time()+6
+ while time.time()<deadline:
+ if select.select([fd],[],[],0.1)[0]:
+ try: data+=os.read(fd,65536)
+ except OSError: break
+ if not sent and b'tty-ready' in data:
+ os.write(fd,b'answer\n')
+ sent=True
+ got,status=os.waitpid(pid,os.WNOHANG)
+ if got: break
+ else: raise Exception('terminal child stopped or blocked')
+ if not got: _,status=os.waitpid(pid,0)
+ assert os.waitstatus_to_exitcode(status)==0,data
+ if sys.argv[2]=='login': assert b'provider-code' in data and b'provider-error' in data,data
+finally:
+ try: os.killpg(pid,signal.SIGKILL)
+ except ProcessLookupError: pass
+ os.close(fd)
+print(data.decode())
+`
+ out, err := exec.Command("python3", "-c", script, os.Args[0], mode).CombinedOutput()
+ if err != nil {
+ t.Fatalf("%v: %s", err, out)
+ }
+ })
+ }
+}
+
+func TestReviewPrivateExecutables(t *testing.T) {
+ root := t.TempDir()
+ source := filepath.Join(root, "source")
+ raw := []byte("#!/bin/sh\nexit 0\n")
+ if err := os.WriteFile(source, raw, 0700); err != nil {
+ t.Fatal(err)
+ }
+ bin := filepath.Join(root, "try", "bin")
+ got, err := pinExecutable(source, bin, "codex", provider.DigestDirectEvidence(raw))
+ if err != nil {
+ t.Fatal(err)
+ }
+ info, err := os.Stat(got)
+ if err != nil || got != filepath.Join(bin, "codex") || info.Mode().Perm() != 0700 {
+ t.Fatal(got, err)
+ }
+ if _, err := pinExecutable(source, bin, "codex", "wrong"); err == nil {
+ t.Fatal("wrong hash copied")
+ }
+ for _, folder := range []string{"interactive", ".paseo/zerosub/homes/account"} {
+ dir := filepath.Join(root, folder)
+ if err := os.MkdirAll(dir, 0700); err != nil {
+ t.Fatal(err)
+ }
+ if folder == "interactive" {
+ t.Setenv("CODEX_HOME", dir)
+ }
+ path := filepath.Join(dir, "codex")
+ if err := os.WriteFile(path, raw, 0700); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := pinExecutable(path, bin, "codex", provider.DigestDirectEvidence(raw)); err == nil {
+ t.Fatal("forbidden executable copied")
+ }
+ alias := filepath.Join(root, strings.ReplaceAll(folder, "/", "-")+"-alias")
+ if err := os.Symlink(path, alias); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := pinExecutable(alias, bin, "codex", provider.DigestDirectEvidence(raw)); err == nil {
+ t.Fatal("forbidden alias copied")
+ }
+ }
+}
+
+func TestReviewSystemHome(t *testing.T) {
+ u, err := user.Current()
+ if err != nil {
+ t.Fatal(err)
+ }
+ t.Setenv("HOME", t.TempDir())
+ home, err := SystemHome()
+ if err != nil || home != u.HomeDir {
+ t.Fatal(home, err)
+ }
+}
+
+func TestReviewExpiredAccountSignsIn(t *testing.T) {
+ t.Parallel()
+ for _, family := range []string{"claude", "codex"} {
+ t.Run(family, func(t *testing.T) {
+ w, paths, log := multiAccountWizard(t, "yes\n")
+ binary := paths["EQUIPO_"+strings.ToUpper(family)+"_PATH"]
+ b, err := w.account(context.Background(), family, family, binary)
+ if err != nil {
+ t.Fatal(err)
+ }
+ name, extra := ".credentials.json", `"claudeAiOauth":{"expiresAt":1}`
+ if family == "codex" {
+ name, extra = "auth.json", `"tokens":{"access_token":"e30.eyJleHAiOjF9.sig"}`
+ }
+ raw := fmt.Sprintf(`{"email":%q,%s}`, b.AccountID, extra)
+ if err := os.WriteFile(filepath.Join(b.Home, name), []byte(raw), 0600); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := w.account(context.Background(), family, family, binary); err != nil {
+ t.Fatal(err)
+ }
+ calls, err := os.ReadFile(log)
+ if err != nil || len(strings.Fields(string(calls))) != 2 {
+ t.Fatal("expired account reused", string(calls), err)
+ }
+ })
+ }
+}
+
+func TestReviewDropUnconfirmedHome(t *testing.T) {
+ t.Parallel()
+ w, paths, _ := multiAccountWizard(t, "2\n2\n"+strings.Repeat("yes\n", 4))
+ h, err := provider.NewLoginHome(w.Accounts)
+ if err != nil {
+ t.Fatal(err)
+ }
+ for _, key := range []string{"claude-3", "claude-4", "claude-6"} {
+ w.State.Homes[key] = Home{Path: h}
+ }
+ bindings, err := w.connectAccounts(context.Background(), paths)
+ if err != nil || len(bindings) != 4 {
+ t.Fatal("unconfirmed home forced into minimum", err)
+ }
+ if _, ok := w.State.Homes["claude-6"]; ok {
+ t.Fatal("unconfirmed home not dropped")
+ }
+}
+
+func TestReviewRefusalExplainsCause(t *testing.T) {
+ var out bytes.Buffer
+ ReportFailure(&out, "configuration", fmt.Errorf("fixture cause"))
+ if !strings.Contains(out.String(), "fixture cause") || !strings.Contains(out.String(), "scripts/try-equipo.sh") {
+ t.Fatal(out.String())
+ }
+}
+
+func TestReviewGateDeadlineAndGroups(t *testing.T) {
+ if !strings.Contains(strings.Join(liveGateArgs(), " "), "-timeout=0") {
+ t.Fatal("default Go timeout truncates calibration")
+ }
+ for _, terminal := range []bool{false, true} {
+ ctx, cancel := context.WithCancel(context.Background())
+ cmd := childCommand(ctx, "/bin/true", nil, "", nil, terminal)
+ if terminal && cmd.SysProcAttr != nil && cmd.SysProcAttr.Setpgid {
+ t.Fatal("terminal child in background group")
+ }
+ if !terminal && (cmd.SysProcAttr == nil || !cmd.SysProcAttr.Setpgid || cmd.Cancel == nil) {
+ t.Fatal("ordinary command lost process-group cancellation")
+ }
+ cancel()
+ }
+}
+func TestReviewCodexSiblingHost(t *testing.T) {
+ root := t.TempDir()
+ for _, name := range []string{"codex", "codex-code-mode-host"} {
+ if err := os.WriteFile(filepath.Join(root, name), []byte("#!/bin/sh\nexit 0\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ }
+ alias := filepath.Join(t.TempDir(), "codex")
+ if err := os.Symlink(filepath.Join(root, "codex"), alias); err != nil {
+ t.Fatal(err)
+ }
+ codex, err := resolveExecutable("codex", alias, "")
+ if err != nil {
+ t.Fatal(err)
+ }
+ host, err := resolveExecutable("codex-code-mode-host", "/ignored/host", codex)
+ if err != nil || host != filepath.Join(root, "codex-code-mode-host") {
+ t.Fatal("host not beside resolved Codex", host, err)
+ }
+}
+
+func TestReviewBootstrapRefusal(t *testing.T) {
+ t.Parallel()
+ root := t.TempDir()
+ for _, name := range []string{"dirname", "sed"} {
+ path, err := exec.LookPath(name)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Symlink(path, filepath.Join(root, name)); err != nil {
+ t.Fatal(err)
+ }
+ }
+ cmd := exec.Command("/bin/sh", "../../scripts/try-equipo.sh")
+ cmd.Env = []string{"PATH=" + root}
+ out, err := cmd.CombinedOutput()
+ if err == nil || !bytes.Contains(out, []byte("Missing prerequisite: Go")) || !bytes.Contains(out, []byte("Install Go")) {
+ t.Fatal(string(out), err)
+ }
+}
+func TestReviewRunRefusal(t *testing.T) {
+ var out bytes.Buffer
+ w := Wizard{Root: "relative", Input: strings.NewReader(""), Output: &out}
+ if err := w.Run(context.Background()); err == nil {
+ t.Fatal("invalid root accepted")
+ }
+ if (!strings.Contains(out.String(), "0700") && os.Geteuid() != 0) || !strings.Contains(out.String(), "scripts/try-equipo.sh") {
+ t.Fatal(out.String())
+ }
+}
+
+func TestReviewUnconfirmedExpiredAccountSignsIn(t *testing.T) {
+ t.Parallel()
+ for _, family := range []string{"claude", "codex"} {
+ t.Run(family, func(t *testing.T) {
+ w, paths, log := multiAccountWizard(t, "yes\n")
+ home, err := provider.NewLoginHome(w.Accounts)
+ if err != nil {
+ t.Fatal(err)
+ }
+ w.State.Homes[family] = Home{Path: home}
+ name, extra := ".credentials.json", `"claudeAiOauth":{"expiresAt":1}`
+ if family == "codex" {
+ name, extra = "auth.json", `"tokens":{"access_token":"e30.eyJleHAiOjF9.sig"}`
+ }
+ raw := fmt.Sprintf(`{"email":%q,%s}`, filepath.Base(home)+"@example.invalid", extra)
+ if err := os.WriteFile(filepath.Join(home, name), []byte(raw), 0600); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := w.account(context.Background(), family, family, paths["EQUIPO_"+strings.ToUpper(family)+"_PATH"]); err != nil {
+ t.Fatal("unconfirmed expired account did not sign in", err)
+ }
+ calls, err := os.ReadFile(log)
+ if err != nil || len(strings.Fields(string(calls))) != 1 {
+ t.Fatal("missing sign-in", err)
+ }
+ })
+ }
+}
+
+func TestReviewResumeBeforeIdentityMarker(t *testing.T) {
+ t.Parallel()
+ w, paths, log := multiAccountWizard(t, "yes\n")
+ b, err := w.account(context.Background(), "codex", "codex", paths["EQUIPO_CODEX_PATH"])
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := os.Remove(filepath.Join(b.Home, provider.IdentityFile)); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := w.account(context.Background(), "codex", "codex", paths["EQUIPO_CODEX_PATH"]); err != nil {
+ t.Fatal("interrupted marker write cannot resume", err)
+ }
+ raw, err := os.ReadFile(log)
+ if err != nil || len(strings.Fields(string(raw))) != 1 {
+ t.Fatal("marker recovery repeated sign-in", err)
+ }
+ if err := os.Remove(filepath.Join(b.Home, provider.IdentityFile)); err != nil {
+ t.Fatal(err)
+ }
+ if err := os.WriteFile(filepath.Join(b.Home, "auth.json"), []byte(`{"email":"different@example.invalid"}`), 0600); err != nil {
+ t.Fatal(err)
+ }
+ if _, err := w.account(context.Background(), "codex", "codex", paths["EQUIPO_CODEX_PATH"]); err == nil {
+ t.Fatal("wrong account accepted during marker recovery")
+ }
+ if _, err := os.Stat(filepath.Join(b.Home, provider.IdentityFile)); !os.IsNotExist(err) {
+ t.Fatal("marker restored for the wrong account", err)
+ }
+}
diff --git a/internal/tryequipo/run.go b/internal/tryequipo/run.go
index 03d1da3b..bc0677c7 100644
--- a/internal/tryequipo/run.go
+++ b/internal/tryequipo/run.go
@@ -21,11 +21,11 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
w.phase = "prerequisites"
defer func() {
if err != nil {
- fmt.Fprintf(w.Output, equipo.TryText("failed"), w.phase)
+ ReportFailure(w.Output, w.phase, err)
}
}()
if os.Geteuid() == 0 {
- return provider.ErrPolicy
+ return refusal("root-user", provider.ErrPolicy)
}
if err = privateDir(w.Root); err != nil {
return err
@@ -36,7 +36,7 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
}
defer lock.Close()
if err = unix.Flock(int(lock.Fd()), unix.LOCK_EX|unix.LOCK_NB); err != nil {
- return err
+ return refusal("guide-busy", err)
}
if err = w.load(); err != nil {
return err
@@ -51,7 +51,7 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
return err
}
if answer != "SIGN IN" {
- return provider.ErrPolicy
+ return refusal("signin-required", provider.ErrPolicy)
}
w.phase = "configuration"
bindings, err := w.connectAccounts(ctx, paths)
@@ -61,6 +61,7 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
w.phase = "configuration"
for _, key := range []string{"instance", "person", "claude-model", "codex-model", "forge"} {
+ w.phase = key
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
@@ -72,16 +73,16 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
}
forge := w.State.Values["forge"]
if !filepath.IsAbs(forge) {
- return provider.ErrPolicy
+ return refusal("forge-path", provider.ErrPolicy)
}
st, err := os.Lstat(forge)
if err != nil || !st.Mode().IsRegular() || st.Mode().Perm() != 0600 {
- return provider.ErrPolicy
+ return refusal("forge-path", 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()
+ home, err := SystemHome()
if err != nil {
return err
}
@@ -101,6 +102,7 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
return err
}
+ w.phase = "build"
if err = w.build(ctx, paths); err != nil {
return err
}
@@ -118,7 +120,7 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
sort.Strings(keys)
for _, k := range keys {
if strings.ContainsAny(paths[k], "\r\n\x00\"\\`$") {
- return provider.ErrPolicy
+ return refusal("config-value", provider.ErrPolicy)
}
fmt.Fprintf(&env, "%s=\"%s\"\n", k, paths[k])
}
@@ -150,7 +152,7 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
return err
}
if answer != "RUN LIVE GATE" {
- return provider.ErrPolicy
+ return refusal("live-required", provider.ErrPolicy)
}
childEnv := append([]string{}, os.Environ()...)
for k, v := range paths {
@@ -163,7 +165,7 @@ func (w *Wizard) Run(ctx context.Context) (err error) {
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)
+ out, err := gateCommand(ctx, paths["EQUIPO_GO_BINARY"], liveGateArgs(), w.Repository, childEnv)
if e := privateWrite(filepath.Join(runRoot, "gate.log"), out); e != nil {
return e
}
@@ -194,7 +196,7 @@ 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
+ return refusal("foreign-file", provider.ErrPolicy)
}
} else if !os.IsNotExist(err) {
return err
@@ -231,13 +233,13 @@ func (w *Wizard) funding() (provider.LiveFunding, error) {
}
n, err := strconv.ParseInt(v, 10, 64)
if err != nil || n <= 0 {
- return f, provider.ErrPolicy
+ return f, refusal("funding-invalid", provider.ErrPolicy)
}
*e.Value = n
w.State.Values[e.Key] = v
}
if f.Seconds > 86400 {
- return f, provider.ErrPolicy
+ return f, refusal("funding-invalid", provider.ErrPolicy)
}
raw, _ := jsonBytes(f)
fmt.Fprintf(w.Output, equipo.TryText("limits"), raw)
diff --git a/internal/tryequipo/state.go b/internal/tryequipo/state.go
index e4fadfa9..39201c67 100644
--- a/internal/tryequipo/state.go
+++ b/internal/tryequipo/state.go
@@ -23,7 +23,7 @@ type State struct {
Values map[string]string
}
type Wizard struct {
- LoginInput io.Reader
+ openTerminal func() (*os.File, error)
Root, Accounts, Repository string
Input io.Reader
Output io.Writer
@@ -44,7 +44,7 @@ func (w *Wizard) init() {
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
+ return refusal("saved-state", provider.ErrPolicy)
}
raw, err := os.ReadFile(path)
if os.IsNotExist(err) {
@@ -54,10 +54,10 @@ func (w *Wizard) load() error {
return err
}
if err = json.Unmarshal(raw, &w.State); err != nil {
- return err
+ return refusal("saved-state", err)
}
if w.State.Homes == nil || w.State.Values == nil {
- return provider.ErrPolicy
+ return refusal("saved-state", provider.ErrPolicy)
}
return nil
}
@@ -71,18 +71,18 @@ func writeJSON(path string, v any) error {
}
func privateDir(path string) error {
if !filepath.IsAbs(path) || filepath.Clean(path) != path {
- return provider.ErrPolicy
+ return refusal("private-directory", 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
+ return refusal("private-directory", provider.ErrPolicy)
}
st, err := os.Stat(path)
if err != nil || st.Mode().Perm() != 0700 {
- return provider.ErrPolicy
+ return refusal("private-directory", provider.ErrPolicy)
}
return nil
}
@@ -92,7 +92,7 @@ func privateWrite(path string, raw []byte) error {
}
if info, err := os.Lstat(path); err == nil {
if !info.Mode().IsRegular() || info.Mode().Perm() != 0600 {
- return provider.ErrPolicy
+ return refusal("private-file", provider.ErrPolicy)
}
} else if !os.IsNotExist(err) {
return err
@@ -124,14 +124,14 @@ 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
+ return "", refusal("input-required", err)
}
line = strings.TrimSpace(line)
if line == "" {
line = def
}
if line == "" || strings.ContainsAny(line, "\x00\r\n") {
- return "", provider.ErrPolicy
+ return "", refusal("input-required", provider.ErrPolicy)
}
return line, nil
}
diff --git a/scripts/live-gate.sh b/scripts/live-gate.sh
index f49cb5a8..658b92c0 100755
--- a/scripts/live-gate.sh
+++ b/scripts/live-gate.sh
@@ -14,4 +14,4 @@ IFS= read -r answer
[ "${EQUIPO_LIVE_DIRECT:-}" = 1 ] || exit 1
[ -n "${EQUIPO_LIVE_CONFIG:-}" ] || exit 1
# The four named tests fail, rather than skip, on absent inputs or evidence.
-CGO_ENABLED=0 go test -tags direct_live ./internal/runner/provider -run '^TestDirectLive(Contract|Isolation|Recovery|Calibration)$' -count=1
+CGO_ENABLED=0 go test -timeout=0 -tags direct_live ./internal/runner/provider -run '^TestDirectLive(Contract|Isolation|Recovery|Calibration)$' -count=1
diff --git a/scripts/runner-reference-allowlist.json b/scripts/runner-reference-allowlist.json
index 6dfc52b3..dd6c99e4 100644
--- a/scripts/runner-reference-allowlist.json
+++ b/scripts/runner-reference-allowlist.json
@@ -7034,13 +7034,6 @@
"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",
@@ -7166,5 +7159,40 @@
"match": "equipo-runner",
"count": 1,
"reason": "Private configuration root for the native Go runner."
+ },
+ {
+ "path": "docs/live-gate.md",
+ "line_sha256": "2b8764c16bad851998799c21888ff7f3336abac21d830f1c2d6bf4cc940c72d2",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Guide or controller evidence for the dedicated runner certification workflow."
+ },
+ {
+ "path": "docs/superpowers/plans/CONTROLLER-REPORT-try-equipo-3.md",
+ "line_sha256": "48a303cf4b02feebdc1dc8de33a98574bd3c65a9eb49970cbd6f382ebd3f1ef2",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Guide or controller evidence for the dedicated runner certification workflow."
+ },
+ {
+ "path": "internal/directlive/delegation_test.go",
+ "line_sha256": "9715dafa4ab7dc1c0d1e2aa203dfd9e54c0ae0a0d09e294af1dab78bb81dee6e",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Offline regression fixture builds or invokes the dedicated runner without provider calls."
+ },
+ {
+ "path": "internal/directlive/delegation_test.go",
+ "line_sha256": "8a9ce80d20251972e7abae6ad5290e053be2b475b71e648d6ad7f38bcc521444",
+ "match": "equipo-runner",
+ "count": 1,
+ "reason": "Offline regression fixture builds or invokes the dedicated runner without provider calls."
+ },
+ {
+ "path": "internal/tryequipo/review_fixes_test.go",
+ "line_sha256": "d4f789233224774cd26bdd8e156e3d4ee6b7e028818131345a7428aa8e6d650d",
+ "match": "paseo",
+ "count": 1,
+ "reason": "Offline regression fixture builds or invokes the dedicated runner without provider calls."
}
]
diff --git a/scripts/try-equipo.sh b/scripts/try-equipo.sh
index ef8ee3ed..06dec5ba 100755
--- a/scripts/try-equipo.sh
+++ b/scripts/try-equipo.sh
@@ -2,7 +2,8 @@
set -eu
cd "$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)"
if ! command -v go >/dev/null 2>&1; then
- printf '%s\n' 'Missing prerequisite: Go'
+ # Keep the bootstrap refusal in the same copy catalog as the guide.
+ sed -n 's/^[[:space:]]*"go-required":[[:space:]]*"\([^"]*\)".*/\1/p' internal/equipo/copy.go
exit 1
fi
CGO_ENABLED=0 go run ./cmd/equipo-try