oficina / equipo Public

Merge branch 'tty-answers' into main

live gate: automatic control answers; funding bounds from run evidence

The gate no longer asks a person to type answers; every control is answered
automatically through the same relay and still required per tuple. Job
input funding defaults to 60M (3x the highest measured need).
claude agent, operated by paul@keymail.dev b4f7bde4bbbe5ccc35866fd96aaccf445b670457 parent a2774dcparent 86741b2
48 files changed, +1,016 −864
  • docs/live-gate.md +3 −2
  • docs/superpowers/plans/CODEX-BRIEF-tty-answers-2.md +31 −0
  • docs/superpowers/plans/CODEX-BRIEF-tty-answers-3.md +27 −0
  • docs/superpowers/plans/CODEX-BRIEF-tty-answers.md +43 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +0 −4
  • docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md +434 −0
  • internal/directlive/answer_source.go +3 −10
  • internal/directlive/answer_source_test.go +54 −48
  • internal/directlive/approval_controls_test.go +0 −101
  • internal/directlive/{fewer_prompts_test.go => automatic_controls_test.go} +2 −27
  • internal/directlive/certificate.go +2 −18
  • internal/directlive/controls.go +0 −3
  • internal/directlive/coordinator_certificate_test.go +20 −85
  • internal/directlive/driver.go +6 −9
  • internal/directlive/driver_test.go +7 −21
  • internal/directlive/final_gaps_test.go +2 −8
  • internal/directlive/person_controls.go +0 −12
  • internal/directlive/probe_answers.go +0 −8
  • internal/directlive/probe_answers_test.go +3 −17
  • internal/directlive/recovery.go +1 −1
  • internal/directlive/routing_approval_test.go +3 −7
  • internal/directlive/terminal.go +0 −84
  • internal/directlive/terminal_probe_test.go +0 −63
  • internal/directlive/terminal_retry_test.go +0 −76
  • internal/directlive/turn.go +2 −6
  • internal/equipo/copy.go +0 −7
  • internal/equipotest/runner_release_test.go +4 −4
  • internal/plan3test/plan3_release_test.go +2 −3
  • internal/release/manifest.go +16 −17
  • internal/release/manifest.json +18 −18
  • internal/runner/provider/claude/launcher.go +1 −0
  • internal/runner/provider/claude/person_timeout_test.go +17 −0
  • internal/runner/provider/codex/launcher.go +3 −1
  • internal/runner/provider/codex/person_timeout_test.go +21 −0
  • internal/runner/provider/control_checks.go +3 −0
  • internal/runner/provider/person_controls.go +0 −92
  • internal/runner/provider/providertest/control_failures.go +30 −0
  • internal/runner/provider/providertest/person_controls.go +0 −68
  • internal/tryequipo/funding_test.go +6 −3
  • internal/tryequipo/run.go +4 −4
  • internal/tryequipo/testdata/tty-chain/answer.go.txt +48 −0
  • internal/tryequipo/testdata/tty-chain/drive.py +57 −0
  • internal/tryequipo/testdata/tty-chain/live_test.go.txt +17 −0
  • internal/tryequipo/testdata/tty-chain/main.go.txt +5 −0
  • internal/tryequipo/testdata/tty-chain/runner.go.txt +5 −0
  • internal/tryequipo/testdata/tty-chain/wizard.go.txt +27 −0
  • internal/tryequipo/tty_chain_test.go +89 −0
  • scripts/runner-release-check.py +0 −37

CI failed — run details

landed from tty-answers

diff --git a/docs/live-gate.md b/docs/live-gate.md
index 913941bd..7b31ecb5 100644
--- a/docs/live-gate.md
+++ b/docs/live-gate.md
@@ -65,8 +65,9 @@ before a human question. Model probes record workspace and outside-workspace
routing per tool; declines are allowed except where they leave Claude’s
staged-home isolation unproven. The account-change
check uses private copies of two connected accounts for each provider, leaving their credential sources
-untouched. Human approval questions
-arrive through the terminal for only the first specialist tuple of each provider, expire after 60 seconds, and are answered automatically for later tuples.
+untouched. Every live-gate control answer is automatic and uses the same relay,
+validation and timing; you do not type answers during the run. You approve real
+tasks in Equipo’s app or API.
V1 does not refresh tokens. A manifest candidate records `certified_refresh:
null` and a reason. Egress permits only the provider's inference host. An expired
diff --git a/docs/superpowers/plans/CODEX-BRIEF-tty-answers-2.md b/docs/superpowers/plans/CODEX-BRIEF-tty-answers-2.md
new file mode 100644
index 00000000..a6de4d60
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-BRIEF-tty-answers-2.md
@@ -0,0 +1,31 @@
+# Brief: tty answers round 2 — timing, retry, funding
+
+Same branch at 501533c. OFFLINE ONLY (no provider launches; evidence
+read-only). Controller decisions after run-4024280761:
+
+- T1 Person prompts (answer source "person") wait 5 minutes, not 60 s;
+ automatic answers keep today's timing. On expiry print one plain line
+ that the request expired and the check will be retried or failed (copy
+ accepted for now under Paul's 2026-11-04/05 ruling; mark it so). The
+ confirmation after a read answer stays (also mark accepted for now).
+ Make sure provider-side turn/control deadlines exceed 5 minutes for
+ person-answered steps, so nothing else times out first.
+- T2 Person-proof retry: if the first tuple of a provider fails to obtain
+ passing person-answered controls (timeout, expiry, invalid), the next
+ specialist tuple of that provider asks the person again, until one
+ passes or the provider's tuples run out. Certification rule unchanged
+ (at least one passing person-answered tuple per provider). Driver test.
+- T3 Funding: run-4024280761 measured Claude job needs up to
+ JobInput=18,308,000 (claude-Design; Copy 11,546,000, Scope 11,684,000,
+ Engineering-reproduction 14,375,000; read evidence for any JobOutput
+ and calibration totals needed). Set defaults to at least 3x the
+ highest measured need, rounded up: JobInput and both input headrooms
+ 60,000,000; recompute JobOutput/headroom outputs from evidence with 3x
+ margin (not below today's 1,150,000); calibration totals: InputTokens
+ and OutputTokens at 3x the sum the full family needs per evidence
+ (show arithmetic). Add the current defaults (11,500,000 etc.) to the
+ re-propose list. These are bounds, not spend.
+- T4 Targeted tests, ONE full `make -k ci` (rerun at most twice). Commit
+ subject < 80, body `Co-Authored-By: Astra <noreply@openai.com>`, push.
+ "Round 2" in CONTROLLER-REPORT-tty-answers.md. Scratch removed;
+ nothing running; no copy-review server. Print a five-line summary.
diff --git a/docs/superpowers/plans/CODEX-BRIEF-tty-answers-3.md b/docs/superpowers/plans/CODEX-BRIEF-tty-answers-3.md
new file mode 100644
index 00000000..b7257366
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-BRIEF-tty-answers-3.md
@@ -0,0 +1,27 @@
+# Brief: tty answers round 3 — no typed answers in the live gate
+
+Same branch at 722b566. OFFLINE ONLY. Paul's ruling (2026-11-05): the
+live gate must not ask him to type answers. The terminal is not the
+production approval path (people approve in Equipo's app/API), so a
+typed terminal answer proves nothing beyond an automatic answer through
+the same relay and validation. The person path is exercised by his first
+real task in the app.
+
+- U1 Every control answer in the live gate comes from the automatic
+ answer source, through the same relay, validation and timing as
+ today; recorded `answered_by: "automatic"`. No /dev/tty prompts during
+ RUN LIVE GATE. Keep the person answer source and terminalAnswer code
+ only if something else uses it; otherwise remove dead code.
+- U2 Remove the provider-level `person-answered-controls` requirement
+ from the candidate builder, Go validators and
+ scripts/runner-release-check.py; replace it with nothing (do not
+ invent a substitute check). Keep every control check itself
+ (allow/deny/question/stale/invalid/escalation) required per tuple.
+- U3 Update docs/live-gate.md (one or two plain sentences; copy accepted
+ for now) and any guide text that mentions answering prompts. The
+ guide's earlier interactive prompts (SIGN IN, totals, limits, RUN LIVE
+ GATE) stay.
+- U4 Targeted tests, ONE full `make -k ci` (rerun at most twice). Commit
+ subject < 80, body `Co-Authored-By: Astra <noreply@openai.com>`, push.
+ "Round 3" in CONTROLLER-REPORT-tty-answers.md. Scratch removed;
+ nothing running; no copy-review server. Print a five-line summary.
diff --git a/docs/superpowers/plans/CODEX-BRIEF-tty-answers.md b/docs/superpowers/plans/CODEX-BRIEF-tty-answers.md
new file mode 100644
index 00000000..f542cad6
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-BRIEF-tty-answers.md
@@ -0,0 +1,43 @@
+# Brief: Paul's typed answers never reach terminalAnswer
+
+Branch `tty-answers` from main a2774dc. OFFLINE ONLY: Paul's run
+(run-4024280761) is live right now on his accounts; do not launch
+providers, do not touch ~/.local/share/equipo*, read-only evidence ok.
+
+Symptom across every real run: Paul types `Allow once` + Return at the
+guide's prompt (printed by internal/directlive/terminal.go via /dev/tty),
+the line echoes in his terminal, and nothing is ever read: no person
+answer artifact, the control step times out (run-4024280761
+claude-Engineering: `controls: context deadline exceeded`, only an
+`answered_by: automatic` answer-8 file exists; run-582068017 Codex
+controls timed out after his Allow once; run 3's "recorded" message was
+printed before reading, so no person answer has EVER been read).
+Astra's previous pty tests fed terminalAnswer directly, not the real
+process chain.
+
+Real chain: Paul's interactive bash on docs-t1 (ssh or local terminal)
+→ scripts/try-equipo.sh (sh) → `go run ./cmd/equipo-try` → wizard reads
+earlier prompts from stdin via bufio (internal/tryequipo/state.go) →
+spawns `go test -timeout=0 -tags direct_live ./internal/runner/provider
+-run ^TestDirectLive...` (internal/tryequipo/command.go childCommand,
+process group / Setpgid / Ctty settings) → test binary → directlive
+driver → provider launches in bwrap (--new-session?) → terminalAnswer
+opens /dev/tty O_NONBLOCK, TCIFLUSH, prints, polls, reads.
+
+Find the root cause by reproducing the WHOLE chain under a real pty (e.g.
+python pty.fork or `script -qfc`) with a fake answer request (no
+provider: stub the driver or use an existing fake-CLI harness), typing as
+a human would AFTER the prompt appears. Candidates to test, not assume:
+another process in the chain reading the tty (wizard bufio on stdin,
+`go test` stdin handling, a provider or bwrap child inheriting the tty),
+the reader's process not in the foreground process group (SIGTTIN/EIO),
+TCIFLUSH discarding the line (timing), O_NONBLOCK + poll on a different
+open file description, canonical-mode differences, `go test` buffering.
+Fix it so the real chain delivers the line, add a regression test that
+runs the real chain (wizard → go test → reader) under a pty, and make
+the guide print a short confirmation only AFTER an answer is actually
+read and accepted. Targeted tests, ONE full `make -k ci` (rerun at most
+twice). Commit subject < 80, body `Co-Authored-By: Astra
+<noreply@openai.com>`, push. CONTROLLER-REPORT-tty-answers.md. Scratch
+removed; nothing running; no copy-review server. Print a five-line
+summary.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 5846b20a..57706015 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5154,10 +5154,6 @@ records to satisfy a gate. Release remains blocked while any row is pending.
| `go-required` | Missing prerequisite: Go. Install Go and run scripts/try-equipo.sh again. | Guided live gate | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
| `guide-busy` | Another guide holds the setup lock. Wait for it to finish before retrying | Guided live gate | COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context) |
-| `live.check-deny` | Equipo is checking that this is refused. Type Deny. | Guided live probe controls | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; live-probe brief) |
-| `live.check-allow` | Equipo is checking one-time approval. Type Allow once. | Guided live probe controls | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; live-probe brief) |
-| `live.check-question` | Equipo is checking that your answer reaches the agent. Enter an answers JSON object. | Guided live probe controls | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; live-probe brief) |
-| `live.answer-retry` | Enter Allow once, Deny, or a valid JSON object. | Guided live control typo retry | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context) |
| `CopyCalibrationFunding` | calibration funding is too low; rerun with JobInput=%d JobOutput=%d ProjectInputHeadroom=%d ProjectOutputHeadroom=%d TeamInputHeadroom=%d TeamOutputHeadroom=%d: %w | Direct isolation Round 3 | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context) |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md b/docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md
new file mode 100644
index 00000000..457149fb
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md
@@ -0,0 +1,434 @@
+# Typed terminal answers
+
+Round 1 status: incomplete. The reported lost-input failure did not reproduce offline.
+This branch adds process-chain coverage and confirmation after a valid answer;
+it does not claim to fix the cause of Paul's live timeout.
+
+## Reproduction and findings
+
+The committed PTY test runs an interactive bash, the unchanged
+`scripts/try-equipo.sh`, `go run ./cmd/equipo-try`, the real wizard buffered
+prompt, `gateCommand`, the production `liveGateArgs`, `go test`, and the
+production `directlive.Run` / `delegateRunner` handoff. A fixture runner calls
+`exercise.answer`, `answerSource.answer`, and `terminalAnswer` and writes the
+normal person-answer artifacts. Go overlays replace account setup and the
+provider exercise. They add no production bypass and never open account homes.
+
+The feeder waits for each visible prompt and types individual characters and
+Return into a real PTY. It checks allow, deny, structured answers, a typo retry,
+an invalid answer object, and timeout. Valid answers must have person attribution
+in their artifacts. Invalid and expired answers must have no artifact or
+confirmation. The runner also checks that its process group owns the terminal.
+
+Before implementation, an immediate answer and a delayed, character-by-character
+answer both reached the reader through this chain. The missing confirmation,
+not the reported lost input, is the regression that failed on the base.
+
+An additional temporary fixture ran the existing full fake-CLI Engineering
+harness through the wizard and nested `go test`, with its answer callback changed
+to `terminalAnswer`. Both fake providers completed allow, deny and question
+controls, and all six artifacts said `answered_by: person`. The inner gate exited
+successfully in 62.961 seconds. The exploratory outer feeder returned failure
+because it looked for `PASS`, which the successful outer package-mode `go test`
+suppressed. Its transcript instead ended with the provider package's `ok` line.
+The committed feeder checks exit status and explicit fixture completion instead.
+The temporary fake-provider changes were removed.
+
+Read-only inspection of the still-running real chain found the guide, Go tools,
+test binary and runner in foreground process group 329465 on pts/5. The terminal
+had ICANON, ICRNL and ECHO enabled. A later snapshot found no thread blocked in
+read/readv in the guide, Go test, test binary or runner, and no extra terminal
+reader among their session descendants. These are current snapshots, not proof
+of the state when the earlier answer was lost.
+
+The offline evidence therefore does not establish a competing reader, background
+process group, flush race, nonblocking-descriptor problem, canonical-mode problem,
+or Go output-buffering problem as the cause. The prompt uses `/dev/tty` and was
+visible before input despite Go's captured test output. Existing raw-terminal
+and stale-input tests also pass. No speculative process-group or terminal-mode
+change was made.
+
+## Changes
+
+`terminalAnswer` prints `Answer received.` only after reading a complete answer,
+checking the context, and validating the answer against the question. The message
+confirms receipt and validation; it does not claim provider execution or delivery.
+The new catalog entry is individually marked `COPY REVIEW PENDING`. The unused
+old `live.beyond-profile` message was removed. No copy-review server was started,
+and no README was changed.
+
+## Verification
+
+Before implementation:
+
+```
+CGO_ENABLED=0 go test ./internal/tryequipo -run '^TestTerminalAnswerProcessChain$' -count=1 -v
+```
+
+Failed at the second prompt with `missing or premature answer confirmation`.
+The first typed answer had already reached the reader.
+
+After implementation:
+
+```
+CGO_ENABLED=0 go test ./internal/tryequipo ./internal/directlive -run '^Test(TerminalAnswerProcessChain|ControlTerminal|TerminalRetry|TerminalProbe|AnswerSources)' -count=1
+```
+
+Passed: tryequipo 3.574 seconds, directlive 3.200 seconds. This includes the
+existing CR, LF, CRLF, stale-input, typo, deadline and answer-validation checks.
+
+Each mutation below used the process-chain command above. Source was restored
+immediately after each run.
+
+| Deliberate fault | Result |
+| --- | --- |
+| Print confirmation before the prompt | Failed: premature confirmation |
+| Skip terminal answer validation | Failed: invalid object was confirmed |
+| Print confirmation when the read times out | Failed: expired answer was confirmed |
+| Start the gate in a separate background process group | Failed: reader is not in the foreground |
+
+A fifth experiment changed the terminal timeout return to nil without printing
+confirmation. That mutation survived because `answerSource.answer` independently
+checks the expired context and rejects the answer. This is not evidence that the
+terminal timeout return is independently guarded by the end-to-end test.
+
+One full `make -k ci` ran and exited 2. It found two failures introduced by
+this change: the new catalog entry exceeded the app's source budget by one
+line, and the entry was absent from the consolidated copy-review inventory.
+Removing the unused old message fixed the size budget. Adding the pending entry
+to `CONTROLLER-REPORT-plan-3.md` fixed the inventory. No budget was increased
+and no pending copy was marked approved.
+
+The following focused rechecks passed after both corrections:
+
+```
+make budget fmt-check
+CGO_ENABLED=0 go test ./internal/plan3test -run '^TestPlan3ReleaseBoundaries$' -count=1
+CGO_ENABLED=0 go test ./internal/tryequipo ./internal/directlive -run '^Test(TerminalAnswerProcessChain|ControlTerminal|TerminalRetry|TerminalProbe|AnswerSources)' -count=1
+```
+
+Budget: 39 directories within limits. Release-boundary tests: 0.821 seconds.
+Terminal checks: tryequipo 4.278 seconds, directlive 3.139 seconds. The full gate
+was not rerun. Its remaining lanes passed: reference scan, build, vet, formatting,
+staticcheck, vulnerability scan, secret scan, other test packages, adapter and
+namespace tests, migrations and performance. Cold boot median was 119 ms against
+500 ms; every screen was below its 150 ms budget.
+
+The full suite reported timing overruns in runner (343.161 s / 330 s), provider
+(20.777 s / 15 s), Claude (47.291 s / 45 s), and Codex (39.060 s / 35 s). They are
+notes locally and failures under CI timing enforcement. These existing timing
+budgets were not changed. This report does not claim a clean full CI invocation.
+
+## Remaining work
+
+The root cause and a regression that reproduces Paul's actual timeout remain
+unresolved. I asked which terminal he used and how long elapsed between the
+prompt and Return. No answer arrived during this task. A live
+provider rerun was outside this brief's authorization, so none was attempted.
+
+No production account files were changed and no real provider was launched.
+Only read-only process metadata, terminal settings and selected saved evidence
+were inspected. The PTY fixtures clean up their private sessions. Fixture builds and audit
+logs were removed before handoff; no process started by this task remains.
+The user-provided worktree was retained. No merge or deployment was performed.
+
+## Round 2
+
+The round-two brief replaces the request to diagnose the earlier lost-input
+report with changes to timing, person-proof retries and proposed funding. These
+changes are verified offline. They do not establish the cause of that live run's
+lost-input report.
+
+### Timing and retry
+
+Person answer sources now allow five minutes; automatic sources still allow one
+minute. The terminal reader uses the source's context, removing its separate
+60-second limit. Earlier cancellation and the authorized run deadline still win.
+The default run deadline remains 7,200 seconds. Provider tool deadlines are ten
+minutes: Claude's explicit settings contain `MCP_TOOL_TIMEOUT=600000`, and Codex's
+Equipo MCP settings contain `tool_timeout_sec=600`. Both settings are included in
+the existing policy hashes and validation. Codex's policy serializer now handles
+integer TOML values. No provider binary was launched to inspect these options;
+the installed binaries were read for the setting names.
+
+The terminal prints `The request expired. This check will be retried or failed.`
+once on deadline expiry. `Answer received.` remains after validation only. The
+prompt now says five minutes. All three entries are individually marked
+`COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context)` under the brief's
+2026-11-04/05 ruling. The consolidated inventory and its acceptance check include
+them. No copy-review server was started and README prose is unchanged.
+
+The driver no longer consumes a provider's person-proof opportunity when choosing
+a tuple. After completing a tuple, it validates the saved person proof before
+switching later tuples to automatic answers. A failed tuple, invalid proof or
+missing answer leaves the next specialist eligible. Coordinator and recovery
+workers remain automatic. Certification still requires a passing person-answered
+tuple for each provider; earlier failures remain failures in the run report.
+
+The new fake-CLI driver scenario uses both providers and four specialist tuples:
+Review expires, Engineering returns an invalid answer, Copy passes with person
+answers, and Design uses automatic answers. It checks saved proof, attribution,
+answer counts and the four retained tuple failures. Existing successful-run
+coverage still checks that later tuples do not prompt again.
+
+### Funding arithmetic
+
+Evidence was read only from
+`/home/paulca/.local/share/equipo/try/run-4024280761/evidence` on 2026-11-05.
+The run was still accumulating evidence. The calculation below uses the observed
+snapshot; unfinished tuples are estimates, not zero usage or certified results.
+
+For rows with `23-reservations-per-job.json`, the needs are 23 times that file's
+input and output reservations. For Claude Engineering and Coordinator, the same
+formula is applied to the completed `turn-*.json` usage frames, including cache
+creation and cache reads. Codex's completed token-usage frames use the `last`
+input/output counts. Each reservation is twice the largest sample, rounded up
+to the next 1,000 tokens, then multiplied by 23.
+
+| Tuple | Input need | Output need |
+| --- | ---: | ---: |
+| Claude Engineering | 17,986,000 | 184,000 |
+| Claude Engineering-reproduction | 14,375,000 | 184,000 |
+| Claude Review | 11,040,000 | 161,000 |
+| Claude Product | 11,270,000 | 161,000 |
+| Claude Scope | 11,684,000 | 184,000 |
+| Claude Research | 11,247,000 | 161,000 |
+| Claude Investigation | 9,568,000 | 161,000 |
+| Claude Copy | 11,546,000 | 184,000 |
+| Claude Design | 18,308,000 | 184,000 |
+| Claude Coordinator | 414,000 | 23,000 |
+| Codex Engineering, partial | 437,000 | 23,000 |
+| Codex Engineering-reproduction, partial | 391,000 | 23,000 |
+| Observed sum | 118,266,000 | 1,633,000 |
+
+The maximum input need is 18,308,000. Three times that is 54,924,000, rounded
+up to 60,000,000 for JobInput and both input headrooms. The maximum output need
+is 184,000; three times that is 552,000. JobOutput and both output headrooms
+retain the required 1,150,000 floor.
+
+For the full 19-tuple family, the seven missing tuples and both partial Codex
+rows are provisioned at the largest observed need, 18,308,000 input and 184,000
+output. The Claude row sums are 117,438,000 input and 1,587,000 output. The full
+bounds are `(117,438,000 + 9 × 18,308,000) × 3 = 846,630,000` input and
+`(1,587,000 + 9 × 184,000) × 3 = 9,729,000` output. The proposed calibration
+bounds are 900,000,000 input, rounded up to the next 100 million, and the existing
+16,000,000 output. These conservative reservation sums are bounds, not predicted
+spend. They exceed the observed charged totals as well as the measured usage sums.
+
+The old 11,500,000 input, 1,150,000 output, 100,000,000 total input and 16,000,000
+total output defaults are in the re-propose lists. The output proposals currently
+remain the same. Custom values remain selected, and the person must authorize the
+displayed limits before any live run.
+
+### Verification
+
+Before implementation, the focused tests failed for the one-minute person limit,
+missing expiry notice, missing provider tool deadlines and old funding bounds.
+`TestControlSourcesRetryUntilPass` failed with
+`Engineering lost person retry: automatic`. The first full fake-driver attempt
+also caught the shortened person deadline. A later development run caught missing
+integer TOML support; that serializer correction is included above.
+
+The combined driver run passed in 211.320 seconds, including both
+`TestPersonProofRetryFakeCLI` and `TestFewerPromptsFakeCLI`. That invocation also
+found the missing inventory row for the changed prompt; the row was added and
+the inventory check passed on rerun.
+
+After restoring all deliberate faults, this focused command passed:
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive ./internal/tryequipo ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/plan3test -run '^Test(ControlSources|PersonAnswerHasFiveMinutes|AnswerSources|TerminalAnswerProcessChain|FundingProposedDefaults|PersonControlProviderTimeout|Plan3ReleaseBoundaries)' -count=1
+```
+
+Times: directlive 0.113 s, tryequipo 3.830 s, Claude 0.223 s, Codex 0.207 s,
+plan3test 0.785 s. The five-minute source test uses Go's virtual clock; expiry is
+also checked through the real terminal process chain with a shortened parent
+context. No test sleeps for five minutes.
+
+Each mutation below failed, then its source was restored. Each command starts
+with `CGO_ENABLED=0 go test`, ends with `-count=1`, and uses the listed package
+and `-run` selector.
+
+| Deliberate fault | Package and selector | Observed failure |
+| --- | --- | --- |
+| Person limit back to one minute | `./internal/directlive -run '^TestPersonAnswerHasFiveMinutes$'` | Person expired after 1m, wanted 5m |
+| Automatic limit raised to five minutes | Same command | Automatic expired after 5m, wanted 1m |
+| Consume proof when selecting a tuple | `./internal/directlive -run '^TestControlSourcesRetryUntilPass$'` | Engineering lost person retry |
+| Suppress deadline notice | `./internal/tryequipo -run '^TestTerminalAnswerProcessChain$'` | Missing expiry notice |
+| Claude MCP timeout back to 60 seconds | `./internal/runner/provider/claude -run '^TestPersonControlProviderTimeout$'` | Provider tool timeout must exceed five minutes |
+| Codex MCP timeout back to 60 seconds | Same selector in `./internal/runner/provider/codex` | Provider tool timeout must exceed five minutes |
+| Input job/headroom proposals back to 11.5 million | `./internal/tryequipo -run '^TestFundingProposedDefaults$'` | Funding mismatch |
+| Omit 11.5 million from the legacy list | Same command | Saved round-one funding was retained |
+
+`make budget` passed for all 39 directories. A blank line beside the changed
+catalog entries was removed to keep the existing 10,800-line source ceiling;
+no budget was increased. `git diff --check` passed.
+
+
+The provider timeout settings change policy fingerprints. This offline work does
+not issue a certificate for either real provider; a separately authorized live
+run must collect fresh evidence. No existing production evidence or account file
+was modified. No merge, default-branch push or deployment was performed.
+
+The first full `CGO_ENABLED=0 make -k ci` exited 2. Besides the formatting issue,
+it found two stale policy-inventory tests and an existing PTY reap race. All
+18 portable inventory hashes were updated to match the timeout settings; every
+entry remains `uncertified`, and the certificate lists remain empty. The PTY
+feeder now waits for the child after terminal closure, within the original
+three-second deadline. Previously it could read `PASS`, receive terminal EOF,
+then fail because a nonblocking wait had not yet reaped the child.
+
+The focused correction check passed:
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive ./internal/release -run '^Test(MergedPlanPolicyInventory|PlanWorkflowReleasePolicyInventory|TerminalRetryDeadlineAndValidObject)$' -count=1
+make fmt-check budget
+```
+
+Directlive took 0.899 s; release took 0.004 s. The first full run's remaining
+lanes passed, including adapter/namespace tests, migrations and performance.
+Cold boot was 103 ms against 500 ms; every screen was within 150 ms. It reported
+existing timing-budget overruns in runner (357.469 s / 330 s), provider
+(20.710 s / 15 s), Claude (46.596 s / 45 s), and Codex (39.045 s / 35 s). These
+are local notes and become failures with CI timing enforcement. The new full
+directlive suite took 318.087 s against its unchanged 360 s ceiling.
+
+One permitted full rerun of `CGO_ENABLED=0 make -k ci` exited 0. All 29 test
+packages passed, along with build, vet, formatting, staticcheck, vulnerability
+and secret scans, size budgets, adapters, namespaces, migrations and performance.
+Directlive took 324.969 s against 360 s, including the retry regression. Cold boot
+was 101 ms; all screen checks stayed below 150 ms.
+
+The rerun retained timing warnings: runner 358.634 s / 330 s, provider 20.616 s /
+15 s, Claude 46.095 s / 45 s, Codex 38.686 s / 35 s, and tryequipo 11.503 s /
+10 s. The command passed locally; these overruns would fail with CI timing
+enforcement. No timing budget was raised. There were two full gate invocations
+in total, with no second rerun.
+
+Task scratch and logs were removed after their results were recorded here.
+All task test processes exited. The user-provided worktree remains in place.
+
+## Round 3
+
+Every live-gate control now uses the automatic answer source, including the first
+specialist tuple of each provider, later tuples and recovery workers. Answers
+retain the existing relay, validation and one-minute automatic deadline, bounded
+by the run deadline, and record `answered_by: "automatic"`.
+
+The terminal answer reader had no other production caller. It and its person
+source, proof retries, proof artifacts and unused copy entries were removed.
+The candidate builder, Go evidence code and Python release checker no longer
+require `person-answered-controls`. No substitute requirement was added.
+All existing per-tuple control requirements remain in
+`internal/runner/provider/direct_requirements.json`, unchanged.
+
+The guide now says answers are automatic and real tasks are approved in Equipo's
+app or API. Its sign-in, account totals, limits and RUN LIVE GATE confirmations
+remain. The two guide sentences use the brief's accepted-copy ruling. No
+copy-review server was started; README prose and production account files were
+not changed. All provider exercises used offline fixtures.
+
+### Reproduction and focused verification
+
+Before implementation, these commands failed:
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive ./internal/equipotest -run '^(TestEveryControlSourceAutomatic|TestCandidateAcceptsAutomaticControls|TestDirectReleaseRequiresCertification/release/clean)$' -count=1
+CGO_ENABLED=0 go test ./internal/equipotest -run '^TestDirectReleaseRequiresCertification$/^release$/^clean$' -count=1
+```
+
+The source-selection test reported person answers for every initial specialist.
+The candidate builder rejected evidence without person proof. The Python release
+checker rejected the clean packaging fixture after its person proof was removed.
+The combined command selected the first two tests; its packaging pattern matched
+no tests, so the separate command above was run.
+
+The process-chain test still runs the real shell, guide, wizard prompt, Go test
+command, `directlive.Run` and runner delegation. Its feeder types only RUN LIVE
+GATE. Automatic allow, deny and structured answers must arrive with automatic
+attribution; invalid and expired answers must leave no answer artifact.
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive -run '^TestAutomaticControlsFakeCLI$' -count=1 -v
+```
+
+Passed in 73.193 seconds. Both fake providers completed Review and Engineering
+through the production relay. Every answer artifact had automatic attribution;
+all seven control observations passed for all four tuples.
+
+The focused suite also covers automatic source selection and fallback, validation,
+deadlines, candidate acceptance, missing/failed/tampered per-tuple controls,
+release packaging, routing approvals and the copy inventory. Early verification
+found remaining test-only references to the removed driver callback, unstaged
+file deletions in the packaging fixture's tracked-file copy, and an exclusive
+create in the candidate mutation fixture. These were corrected before CI.
+
+### Mutation verification
+
+Each command below uses `CGO_ENABLED=0 go test`, the package and `-run` pattern
+shown, and `-count=1`. Each deliberate fault failed its test, then the source was
+restored.
+
+| Deliberate fault | Package and pattern | Observed failure |
+| --- | --- | --- |
+| Record the automatic source as person | `./internal/directlive -run '^TestEveryControlSourceAutomatic$'` | Wrong attribution |
+| Skip answer validation | `./internal/directlive -run '^TestAnswerSourcesShareValidationAndDeadline$'` | Invalid answer accepted |
+| Read after context expiry | Same command | Expired source read an answer |
+| Accept an answer returned after expiry | `./internal/directlive -run '^TestAutomaticAnswerDeadline$'` | Deadline error missing |
+| Extend the automatic timeout to two minutes | Same command | Wrong elapsed duration |
+| Remove all seven control requirements | `./internal/directlive ./internal/equipotest -run '^(TestCandidateRequiresEveryControl|TestReleaseRequiresEveryControl)$'` | All 21 candidate cases and all 28 packaging cases failed |
+
+The last mutation removed the requirements only from a temporary edit of
+`direct_requirements.json`. Candidate tests independently removed, failed or
+changed the hash of each control. Packaging tests independently removed or failed
+each control for both release targets. The requirement file was restored byte
+for byte; no weakened requirements remain.
+
+
+After restoring the mutations, this focused command passed:
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive ./internal/equipotest ./internal/tryequipo ./internal/plan3test -run '^(TestEveryControlSourceAutomatic|TestAnswerSourcesShareValidationAndDeadline|TestAutomaticAnswerDeadline|TestCandidate.*|TestCoordinatorManifestExclusion|TestAutomaticAnswerProcessChain|TestReleaseRequiresEveryControl|TestDirectReleaseRequiresCertification|TestPlan3ReleaseBoundaries|TestRouting.*|TestProbeAnswersWithoutHuman)$' -count=1
+```
+
+Directlive: 0.739 s; equipotest: 6.854 s; tryequipo: 1.437 s; plan3test: 0.882 s.
+
+### Full CI
+
+The first `make -k ci` found formatting in `internal/equipo/copy.go` after the
+unused entries were removed, and 13,217 equipotest lines against its existing
+13,200-line limit. Formatting was corrected. The new packaging cases were folded
+into the existing release table, and candidate/packaging control-failure setup
+was shared in `providertest`. The test now runs those cases under
+`TestDirectReleaseRequiresCertification`; no cases or size budgets were removed
+or raised.
+
+The first invocation exited 2. Its 29 test packages passed. Adapter, namespace,
+migration and performance checks passed too; cold boot was 104 ms against 500 ms,
+and all screens stayed below 150 ms. Timing warnings were runner 332.696 s / 330 s,
+provider 20.949 s / 15 s, Claude 48.461 s / 45 s and Codex 40.706 s / 35 s.
+These are warnings locally and failures under CI timing enforcement.
+
+After sharing the fixtures, removing the seven requirements again failed every
+candidate case and every control case for both release targets. This used:
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive ./internal/equipotest -run '^(TestCandidateRequiresEveryControl|TestDirectReleaseRequiresCertification)$' -count=1
+```
+
+The source was restored. `make budget fmt-check` passed with all 39 directories
+within budget, and the same focused test command passed on the restored source.
+
+The single rerun of `make -k ci` exited 0. All 29 test packages, build, vet,
+formatting, staticcheck, vulnerability scan, secret scan, size budgets, adapter
+checks, namespaces, migrations and performance passed. Directlive took 251.692 s
+against its 360 s budget. Cold boot was 105 ms; every screen stayed below 150 ms.
+
+Four timing warnings remain: runner 330.526 s / 330 s, provider 20.680 s / 15 s,
+Claude 47.598 s / 45 s and Codex 38.976 s / 35 s. The local command passed; these
+warnings would fail under CI timing enforcement. No timing budget was raised.
+There were two full CI invocations in total, with one rerun.
+
+No live provider gate, copy-review server, merge or deployment was started.
+The user-provided worktree is retained. Test processes exited; task scratch and
+logs are removed after recording their results in this report.
diff --git a/internal/directlive/answer_source.go b/internal/directlive/answer_source.go
index b6aed98a..4b051233 100644
--- a/internal/directlive/answer_source.go
+++ b/internal/directlive/answer_source.go
@@ -14,7 +14,7 @@ type answerSource struct {
}
func (s answerSource) answer(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
+ ctx, cancel := context.WithTimeout(ctx, time.Minute)
defer cancel()
if err := ctx.Err(); err != nil {
return runnerproto.QuestionAnswer{}, err
@@ -29,14 +29,7 @@ func (s answerSource) answer(ctx context.Context, q runnerproto.Question) (runne
return a, err
}
-func (d *driver) controlSource(family, role string) answerSource {
- if d.personControls == nil {
- d.personControls = map[string]bool{}
- }
- if role != "Coordinator" && !d.worker && !d.personControls[family] {
- d.personControls[family] = true
- return answerSource{"person", d.answer}
- }
+func automaticAnswers() answerSource {
return answerSource{"automatic", expectedAnswer}
}
@@ -72,5 +65,5 @@ func (x *exercise) source(ctx context.Context) answerSource {
if expectation.control != "" && x.controlSource.read != nil {
return x.controlSource
}
- return answerSource{"person", x.d.answer}
+ return automaticAnswers()
}
diff --git a/internal/directlive/answer_source_test.go b/internal/directlive/answer_source_test.go
index c5c78179..7a6b9709 100644
--- a/internal/directlive/answer_source_test.go
+++ b/internal/directlive/answer_source_test.go
@@ -4,76 +4,82 @@ import (
"context"
"errors"
"testing"
+ "testing/synctest"
"time"
"amadan.net/oficina/equipo/internal/runnerproto"
)
-func TestControlSourcesFollowRunOrder(t *testing.T) {
- calls := 0
- d := driver{answer: func(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- calls++
- return expectedAnswer(ctx, q)
- }}
- for _, family := range []string{"codex", "claude"} {
- if got := d.controlSource(family, "Coordinator").answeredBy; got != "automatic" {
- t.Fatal(got)
- }
- for i, role := range []string{"Review", "Engineering", "Engineering-reproduction", "Copy"} {
- source := d.controlSource(family, role)
- want := "automatic"
- if i == 0 {
- want = "person"
- }
- if source.answeredBy != want {
- t.Fatalf("%s/%s: %s", family, role, source.answeredBy)
- }
- for _, control := range []string{"workspace", "allow", "deny", "question"} {
+func TestEveryControlSourceAutomatic(t *testing.T) {
+ for _, explicit := range []bool{false, true} {
+ for _, control := range []string{"workspace", "allow", "deny", "question"} {
+ t.Run(control+map[bool]string{false: "/fallback", true: "/control"}[explicit], func(t *testing.T) {
+ x := exercise{}
+ if explicit {
+ x.controlSource = automaticAnswers()
+ }
+ ctx := withControlExpectation(context.Background(), control)
+ source := x.source(ctx)
+ if source.answeredBy != "automatic" {
+ t.Fatal(source.answeredBy)
+ }
q := runnerproto.Question{Kind: "tool", RawRequest: []byte(`{"direct":true,"provider":"claude","name":"Read","input":{"file_path":"/workspace/sentinel"}}`)}
if control == "question" {
q.Kind = "person"
q.RawRequest = []byte(`{"kind":"person","question":"Which case?"}`)
}
- a, err := source.answer(withControlExpectation(context.Background(), control), q)
+ a, err := source.answer(ctx, q)
want := "allow"
if control == "deny" {
want = "deny"
}
if err != nil || a.Behavior != want {
- t.Fatalf("%s/%s/%s: %+v %v", family, role, control, a, err)
+ t.Fatalf("%+v %v", a, err)
}
- }
+ })
}
}
- if calls != 8 {
- t.Fatalf("person prompts = %d, want 8", calls)
- }
}
func TestAnswerSourcesShareValidationAndDeadline(t *testing.T) {
- for _, by := range []string{"person", "automatic"} {
- t.Run(by, func(t *testing.T) {
- s := answerSource{by, expectedAnswer}
- q := runnerproto.Question{Kind: "other"}
- ctx := withControlExpectation(context.Background(), "allow")
- if _, err := s.answer(ctx, q); !errors.Is(err, runnerproto.ErrInvalid) {
- t.Fatalf("invalid answer accepted: %v", err)
- }
- expired, cancel := context.WithDeadline(ctx, time.Now().Add(-time.Second))
- defer cancel()
- if _, err := s.answer(expired, q); !errors.Is(err, context.DeadlineExceeded) {
- t.Fatalf("expired answer accepted: %v", err)
- }
- s.read = func(ctx context.Context, _ runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- deadline, ok := ctx.Deadline()
- if !ok || time.Until(deadline) > 60*time.Second {
- t.Fatal("missing answer deadline")
+ s := automaticAnswers()
+ q := runnerproto.Question{Kind: "other"}
+ ctx := withControlExpectation(context.Background(), "allow")
+ if _, err := s.answer(ctx, q); !errors.Is(err, runnerproto.ErrInvalid) {
+ t.Fatalf("invalid answer accepted: %v", err)
+ }
+ expired, cancel := context.WithDeadline(ctx, time.Now().Add(-time.Second))
+ defer cancel()
+ s.read = func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error) {
+ t.Fatal("expired source read an answer")
+ return runnerproto.QuestionAnswer{}, nil
+ }
+ if _, err := s.answer(expired, q); !errors.Is(err, context.DeadlineExceeded) {
+ t.Fatalf("expired answer accepted: %v", err)
+ }
+}
+
+func TestAutomaticAnswerDeadline(t *testing.T) {
+ for _, limit := range []time.Duration{time.Minute, 20 * time.Second} {
+ t.Run(limit.String(), func(t *testing.T) {
+ synctest.Test(t, func(t *testing.T) {
+ start := time.Now()
+ s := automaticAnswers()
+ s.read = func(ctx context.Context, _ runnerproto.Question) (runnerproto.QuestionAnswer, error) {
+ <-ctx.Done()
+ return runnerproto.QuestionAnswer{Behavior: "deny"}, nil
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), limit)
+ defer cancel()
+ // The source must impose its own minute even when the run allows longer.
+ if limit == time.Minute {
+ ctx = context.Background()
+ }
+ _, err := s.answer(ctx, runnerproto.Question{})
+ if !errors.Is(err, context.DeadlineExceeded) || time.Since(start) != limit {
+ t.Fatalf("expired after %s, want %s: %v", time.Since(start), limit, err)
}
- return runnerproto.QuestionAnswer{Behavior: "deny"}, nil
- }
- if _, err := s.answer(ctx, q); err != nil {
- t.Fatal(err)
- }
+ })
})
}
}
diff --git a/internal/directlive/approval_controls_test.go b/internal/directlive/approval_controls_test.go
deleted file mode 100644
index 64487154..00000000
--- a/internal/directlive/approval_controls_test.go
+++ /dev/null
@@ -1,101 +0,0 @@
-package directlive
-
-import (
- "context"
- "os"
- "os/exec"
- "strings"
- "testing"
- "time"
-
- "amadan.net/oficina/equipo/internal/runnerproto"
-)
-
-func TestControlTerminalRawReturn(t *testing.T) {
- if os.Getenv("EQUIPO_TEST_RAW_RETURN") == "1" {
- ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
- defer cancel()
- q := runnerproto.Question{ID: "q", TaskID: "task", ServerID: "direct", AgentID: "agent", SessionID: "session", PermissionID: "p", Kind: "tool", RawRequest: []byte(`{"id":"p","kind":"tool","direct":true,"provider":"claude","name":"Bash","turn_id":"turn","input":{"command":"printf fixture"},"request":{"tool_name":"Bash","input":{"command":"printf fixture"}}}`)}
- if _, err := q.NativeApproval(); err != nil {
- t.Fatal(err)
- }
- for _, behavior := range []string{"allow", "deny", "question"} {
- if os.Getenv("EQUIPO_TEST_STALE_INPUT") == "1" {
- time.Sleep(100 * time.Millisecond)
- }
- if behavior == "question" {
- q.Kind = "person"
- q.RawRequest = []byte(`{"id":"p","kind":"person","question":"Which case?"}`)
- }
- a, err := terminalAnswer(withControlExpectation(ctx, behavior), q)
- want := behavior
- if want == "question" {
- want = "allow"
- }
- if err != nil || a.Behavior != want {
- t.Fatalf("raw Return lost: %+v %v", a, err)
- }
- }
- return
- }
- script := `import os,pty,select,signal,sys,termios,time
-pid,fd=pty.fork()
-if pid==0:
- attr=termios.tcgetattr(0)
- attr[0]&=~termios.ICRNL
- attr[3]&=~(termios.ICANON|termios.ECHO)
- termios.tcsetattr(0,termios.TCSANOW,attr)
- os.environ['EQUIPO_TEST_RAW_RETURN']='1'
- os.execv(sys.argv[1],[sys.argv[1],'-test.run=^TestControlTerminalRawReturn$'])
-output=b'';pending=b'';sent=0
-answers=[b'Allow once',b'Deny',b'{"answers":{"answer":"ordinary"}}']
-ending={'cr':b'\r','crlf':b'\r\n','lf':b'\n'}[sys.argv[2]]
-if os.environ.get('EQUIPO_TEST_STALE_INPUT')=='1': os.write(fd,b'Deny\n')
-try:
- end=time.monotonic()+5
- while time.monotonic()<end:
- if not select.select([fd],[],[],0.1)[0]:continue
- try:data=os.read(fd,65536)
- except OSError:break
- output+=data;pending+=data
- while b'\n' in pending:
- line,pending=pending.split(b'\n',1)
- if line.startswith(b'Type Allow once, Deny,'):
- os.write(fd,(b'Alloe once\r[]\rnull\r{broken\r \r' if os.environ.get('EQUIPO_TEST_TYPOS')=='1' else b'')+answers[sent]+ending+(b'Allow once\n' if os.environ.get('EQUIPO_TEST_STALE_INPUT')=='1' else b''));sent+=1
- _,status=os.waitpid(pid,0)
- print(output.decode())
- sys.exit(os.waitstatus_to_exitcode(status))
-finally:
- try:os.kill(pid,signal.SIGKILL)
- except ProcessLookupError:pass
- os.close(fd)
-`
- for _, ending := range []string{"cr", "crlf", "lf"} {
- t.Run(ending, func(t *testing.T) {
- ctx, cancel := context.WithTimeout(context.Background(), 8*time.Second)
- defer cancel()
- self, _ := os.Executable()
- output, err := exec.CommandContext(ctx, "python3", "-c", script, self, ending).CombinedOutput()
- if err != nil {
- t.Fatalf("raw terminal: %v\n%s", err, output)
- }
- if strings.Contains(string(output), "Allow once is recorded") {
- t.Fatal("approval claimed before delivery")
- }
- if !strings.Contains(string(output), "PASS") {
- t.Fatal(string(output))
- }
-
- })
- }
-}
-
-func TestControlTerminalFlushPending(t *testing.T) {
- t.Setenv("EQUIPO_TEST_STALE_INPUT", "1")
- TestControlTerminalRawReturn(t)
-}
-
-func TestControlTerminalRetriesTypos(t *testing.T) {
- t.Setenv("EQUIPO_TEST_TYPOS", "1")
- TestControlTerminalRawReturn(t)
-}
diff --git a/internal/directlive/fewer_prompts_test.go b/internal/directlive/automatic_controls_test.go
similarity index 58%
rename from internal/directlive/fewer_prompts_test.go
rename to internal/directlive/automatic_controls_test.go
index 9c035ee9..5dfabd9c 100644
--- a/internal/directlive/fewer_prompts_test.go
+++ b/internal/directlive/automatic_controls_test.go
@@ -6,17 +6,11 @@ import (
"path/filepath"
"testing"
- "amadan.net/oficina/equipo/internal/release"
"amadan.net/oficina/equipo/internal/runner/provider"
)
-func checkFewerPromptRun(t *testing.T, root string, calls int) {
+func checkAutomaticControlRun(t *testing.T, root string) {
t.Helper()
- // The fake workspace read needs no approval, leaving three controls per provider.
- if calls != 6 {
- t.Fatalf("person prompts = %d, want 6", calls)
- }
- m := release.Manifest{ProviderChecks: map[string]map[string]release.Certification{}}
for _, family := range []string{"claude", "codex"} {
for _, role := range []string{"Review", "Engineering"} {
dir := filepath.Join(root, family+"-"+role)
@@ -29,16 +23,6 @@ func checkFewerPromptRun(t *testing.T, root string, calls int) {
t.Fatal(err)
}
want := "automatic"
- if role == "Review" {
- want = "person"
- }
- if (e.ValidatePersonControls(dir) == nil) != (want == "person") {
- t.Fatalf("%s/%s: wrong person proof", family, role)
- }
- m.DirectPolicies = append(m.DirectPolicies, release.PolicyCertificate{Provider: family, PolicyHash: e.PolicyHash})
- if e.ValidatePersonControls(dir) == nil {
- m.ProviderChecks[family] = map[string]release.Certification{provider.PersonAnsweredControls: {Provider: family, PolicyHash: e.PolicyHash}}
- }
for _, name := range provider.ControlChecks {
if e.Checks[name].Status != "pass" {
t.Fatalf("%s/%s: %s failed", family, role, name)
@@ -65,7 +49,7 @@ func checkFewerPromptRun(t *testing.T, root string, calls int) {
if err != nil || json.Unmarshal(raw, &a) != nil {
t.Fatalf("answer: %s %v", raw, err)
}
- if a.AnsweredBy != "automatic" && a.AnsweredBy != "person" {
+ if a.AnsweredBy != "automatic" {
t.Fatal("missing answer attribution")
}
if a.Control != "" {
@@ -80,13 +64,4 @@ func checkFewerPromptRun(t *testing.T, root string, calls int) {
}
}
}
- if err := requireProviderControls(m); err != nil {
- t.Fatal("mixed-source run rejected", err)
- }
- for _, family := range []string{"codex", "claude"} {
- delete(m.ProviderChecks, family)
- if err := requireProviderControls(m); err == nil {
- t.Fatal("run without person-answered controls certified", family)
- }
- }
}
diff --git a/internal/directlive/certificate.go b/internal/directlive/certificate.go
index 8ccd6ad9..3986f1f9 100644
--- a/internal/directlive/certificate.go
+++ b/internal/directlive/certificate.go
@@ -20,7 +20,6 @@ func ManifestCandidate(root string) error {
return errEvidence
}
m := release.BuildManifest()
- m.ProviderChecks = map[string]map[string]release.Certification{}
m.DirectPolicies = nil
m.Certifications = nil
m.VerifiedIsolationTuples = nil
@@ -59,9 +58,6 @@ func ManifestCandidate(root string) error {
m.DirectPolicies = append(m.DirectPolicies, c)
destination := filepath.Join("internal/release/evidence", provider.DigestDirectEvidence([]byte(e.RunID))[:16], name)
m.Certifications = append(m.Certifications, release.Certification{Provider: e.Provider, PolicyHash: e.PolicyHash, Path: destination, SHA256: digest, DirectIsolationSHA256: e.Checks["direct-isolation"].SHA256})
- if e.ValidatePersonControls(filepath.Dir(path)) == nil {
- m.ProviderChecks[e.Provider] = map[string]release.Certification{provider.PersonAnsweredControls: m.Certifications[len(m.Certifications)-1]}
- }
m.VerifiedIsolationTuples = append(m.VerifiedIsolationTuples, team.IsolationTuple{Provider: e.Provider, ProviderVersion: e.ProviderVersion, LauncherVersion: e.LauncherVersion, BwrapVersion: e.BwrapVersion, PolicyVersion: e.PolicyVersion, IsolationConfigHash: e.PolicyHash})
if binaries != nil && string(marshal(binaries)) != string(marshal(e.Binaries)) {
return errEvidence
@@ -71,8 +67,8 @@ func ManifestCandidate(root string) error {
}
binaries = e.Binaries
}
- if err := requireProviderControls(m); err != nil {
- return err
+ if len(m.DirectPolicies) == 0 {
+ return errEvidence
}
for _, name := range []string{"claude", "codex", "codex-code-mode-host", "bwrap", "equipo-tool-proxy"} {
version := map[string]string{"claude": m.Claude, "codex": m.Codex, "codex-code-mode-host": m.Codex, "bwrap": m.BwrapVersion, "equipo-tool-proxy": m.LauncherVersion}[name]
@@ -80,15 +76,3 @@ func ManifestCandidate(root string) error {
}
return save(root, "candidate-manifest.json", m)
}
-
-func requireProviderControls(m release.Manifest) error {
- if len(m.DirectPolicies) == 0 {
- return errEvidence
- }
- for _, c := range m.DirectPolicies {
- if _, ok := m.ProviderChecks[c.Provider][provider.PersonAnsweredControls]; !ok {
- return errEvidence
- }
- }
- return nil
-}
diff --git a/internal/directlive/controls.go b/internal/directlive/controls.go
index 3ef752d6..14dbfa41 100644
--- a/internal/directlive/controls.go
+++ b/internal/directlive/controls.go
@@ -69,9 +69,6 @@ func (x *exercise) controls(ctx context.Context) error {
return err
}
}
- if err := x.personControlCheck(); err != nil {
- return err
- }
return x.namespaceChecks(ctx)
}
func (x *exercise) namespaceChecks(ctx context.Context) error {
diff --git a/internal/directlive/coordinator_certificate_test.go b/internal/directlive/coordinator_certificate_test.go
index 18fd1270..ee0b6998 100644
--- a/internal/directlive/coordinator_certificate_test.go
+++ b/internal/directlive/coordinator_certificate_test.go
@@ -16,7 +16,7 @@ import (
func candidateFixture(t *testing.T) string {
root := t.TempDir()
- raw := []byte("synthetic manifest-selection fixture")
+ raw := []byte(`{"fixture":"synthetic manifest-selection", "answered_by":"automatic"}`)
hash := provider.DigestDirectEvidence(raw)
observation := provider.LiveObservation{Status: "pass", Artifact: "capture.json", SHA256: hash, Detail: "synthetic unit-test fixture"}
e := provider.DirectEvidence{Schema: 2, Source: "direct-live", RunID: "fixture", Provider: "codex", ProviderVersion: "0.165.0", LauncherVersion: provider.LauncherVersion, BwrapVersion: "0.11.0", PolicyVersion: provider.PolicyVersion, PolicyHash: strings.Repeat("a", 64), AccountID: "fixture", HomeID: "fixture", Model: "fixture", Specialist: "Engineering", AuthHost: "", ConfigSHA256: hash, Artifacts: map[string]string{"capture.json": hash}, Checks: map[string]provider.LiveObservation{}, Binaries: map[string]string{}, Usage: []provider.LiveUsage{{Input: 1, Output: 1, Complete: true}}, Funding: provider.LiveFunding{Calls: 1, Seconds: 60, InputTokens: 1000, OutputTokens: 1000, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}, CodexPolicy: &provider.LiveCodexPolicy{ApprovalPolicy: "on-request", ApprovalsReviewer: "user", StrictConfig: true, DenyProfile: true}}
@@ -70,7 +70,6 @@ func candidateFixture(t *testing.T) string {
func TestCoordinatorManifestExclusion(t *testing.T) {
root := candidateFixture(t)
- addCandidatePersonProof(t, root)
if err := ManifestCandidate(root); err != nil {
t.Fatal("coordinator failure blocked specialist candidate", err)
}
@@ -110,99 +109,35 @@ func TestMergedPlanPolicyInventory(t *testing.T) {
}
}
-func TestCandidateRequiresPersonControls(t *testing.T) {
+func TestCandidateAcceptsAutomaticControls(t *testing.T) {
root := candidateFixture(t)
- if err := ManifestCandidate(root); err == nil {
- t.Fatal("candidate accepted a run with no person-answered tuple")
- }
-}
-
-func addCandidatePersonProof(t *testing.T, root string) {
- t.Helper()
- dir := filepath.Join(root, "specialist")
- raw, err := os.ReadFile(filepath.Join(dir, "certification.json"))
- if err != nil {
- t.Fatal(err)
- }
- var e provider.DirectEvidence
- if err = json.Unmarshal(raw, &e); err != nil {
- t.Fatal(err)
- }
- providertest.PersonControls(t, dir, &e, "")
- if err = os.WriteFile(filepath.Join(dir, "certification.json"), marshal(e), 0600); err != nil {
- t.Fatal(err)
+ if err := ManifestCandidate(root); err != nil {
+ t.Fatal("candidate requires person proof", err)
}
}
-func TestCandidateRejectsFalsePersonProof(t *testing.T) {
- for _, mode := range []string{"automatic-proof", "automatic-answer", "wrong-answer", "missing-question", "failed-control", "failed-tuple", "bad-answer-hash"} {
- t.Run(mode, func(t *testing.T) {
- root := candidateFixture(t)
- addCandidatePersonProof(t, root)
- dir := filepath.Join(root, "specialist")
- raw, err := os.ReadFile(filepath.Join(dir, "certification.json"))
- if err != nil {
- t.Fatal(err)
- }
- var e provider.DirectEvidence
- if err = json.Unmarshal(raw, &e); err != nil {
- t.Fatal(err)
- }
- proofRef := e.Checks[provider.PersonAnsweredControls]
- raw, err = os.ReadFile(filepath.Join(dir, proofRef.Artifact))
- if err != nil {
- t.Fatal(err)
- }
- var proof provider.PersonControlProof
- if err = json.Unmarshal(raw, &proof); err != nil {
- t.Fatal(err)
- }
- switch mode {
- case "automatic-proof":
- proof.AnsweredBy = "automatic"
- case "missing-question":
- delete(proof.Answers, "question")
- case "failed-control", "failed-tuple":
- key := "person-native-approval"
- if mode == "failed-tuple" {
- key = "tuple-completed"
- }
- o := e.Checks[key]
- o.Status = "not-certified"
- e.Checks[key] = o
- default:
- o := proof.Answers["allow"][0]
- raw, err = os.ReadFile(filepath.Join(dir, o.Artifact))
+func TestCandidateRequiresEveryControl(t *testing.T) {
+ for _, name := range provider.ControlChecks {
+ for _, mode := range []string{"missing", "failed", "tampered"} {
+ t.Run(name+"/"+mode, func(t *testing.T) {
+ root := candidateFixture(t)
+ dir := filepath.Join(root, "specialist")
+ raw, err := os.ReadFile(filepath.Join(dir, "certification.json"))
if err != nil {
t.Fatal(err)
}
- if mode == "wrong-answer" {
- raw = []byte(strings.Replace(string(raw), `"behavior":"allow"`, `"behavior":"deny"`, 1))
- } else {
- raw = []byte(strings.Replace(string(raw), `"person"`, `"automatic"`, 1))
+ var e provider.DirectEvidence
+ if err = json.Unmarshal(raw, &e); err != nil {
+ t.Fatal(err)
}
- if err = os.WriteFile(filepath.Join(dir, o.Artifact), raw, 0600); err != nil {
+ providertest.ControlFailure(&e, mode+"_control/"+name)
+ if err = os.WriteFile(filepath.Join(dir, "certification.json"), marshal(e), 0600); err != nil {
t.Fatal(err)
}
- e.Artifacts[o.Artifact] = provider.DigestDirectEvidence(raw)
- if mode != "bad-answer-hash" {
- o.SHA256 = e.Artifacts[o.Artifact]
- proof.Answers["allow"][0] = o
+ if err = ManifestCandidate(root); err == nil {
+ t.Fatal("invalid control accepted")
}
- }
- raw = marshal(proof)
- if err = os.WriteFile(filepath.Join(dir, proofRef.Artifact), raw, 0600); err != nil {
- t.Fatal(err)
- }
- proofRef.SHA256 = provider.DigestDirectEvidence(raw)
- e.Artifacts[proofRef.Artifact] = proofRef.SHA256
- e.Checks[provider.PersonAnsweredControls] = proofRef
- if err = os.WriteFile(filepath.Join(dir, "certification.json"), marshal(e), 0600); err != nil {
- t.Fatal(err)
- }
- if err = ManifestCandidate(root); err == nil {
- t.Fatal("false person proof accepted", mode)
- }
- })
+ })
+ }
}
}
diff --git a/internal/directlive/driver.go b/internal/directlive/driver.go
index 0c32a117..695ca459 100644
--- a/internal/directlive/driver.go
+++ b/internal/directlive/driver.go
@@ -27,7 +27,6 @@ func EnvironmentPaths(getenv func(string) string) Paths {
}
type driver struct {
- personControls map[string]bool
currencyCap bool
invalidFrame bool
stagedMarker string
@@ -40,7 +39,6 @@ type driver struct {
hashes map[string]string
configHash, source, root string
calls, input, output int64
- answer answerFunc
}
// Run collects new observations. Existing evidence is rejected before any CLI
@@ -53,12 +51,12 @@ func Run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Path
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))
+ return run(ctx, c, config, p, "direct-live", EnvironmentPolicyPaths(os.Getenv))
}
-func run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Paths, source string, answer answerFunc, policyPaths PolicyPaths) error {
- return runRoles(ctx, c, config, p, source, answer, policyPaths, []string{"Engineering", "Engineering-reproduction", "Review", "Product", "Scope", "Research", "Investigation", "Copy", "Design", "Coordinator"})
+func run(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Paths, source string, policyPaths PolicyPaths) error {
+ return runRoles(ctx, c, config, p, source, policyPaths, []string{"Engineering", "Engineering-reproduction", "Review", "Product", "Scope", "Research", "Investigation", "Copy", "Design", "Coordinator"})
}
-func runRoles(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Paths, source string, answer answerFunc, policyPaths PolicyPaths, roles []string) error {
+func runRoles(ctx context.Context, c provider.DirectLiveConfig, config []byte, p Paths, source string, policyPaths PolicyPaths, roles []string) error {
if err := c.Validate("1"); err != nil {
return err
}
@@ -80,7 +78,7 @@ func runRoles(ctx context.Context, c provider.DirectLiveConfig, config []byte, p
if _, e := os.Stat(homes); os.IsNotExist(e) {
defer os.Remove(homes)
}
- d := &driver{currencyCap: currencyCapSignal(config), policyPaths: policyPaths, cfg: c, paths: p, configHash: provider.DigestDirectEvidence(config), source: source, root: root, answer: answer}
+ d := &driver{currencyCap: currencyCapSignal(config), policyPaths: policyPaths, cfg: c, paths: p, configHash: provider.DigestDirectEvidence(config), source: source, root: root}
d.hashes, err = p.verify()
if err != nil {
return err
@@ -189,7 +187,6 @@ type exercise struct {
controlPassed map[string]bool
answerContext context.Context
controlSource answerSource
- controlAnswers map[string][]provider.LiveObservation
claudeSettings []claudeSettingsReadback
inputs provider.PolicyInputs
mu sync.Mutex
@@ -222,7 +219,7 @@ func (d *driver) exercise(ctx context.Context, b provider.DirectLiveBinding, rol
err = fmt.Errorf("%s: %w", phase, err)
}
}()
- x := &exercise{d: d, root: root, evidence: e, answers: map[string]int{}, controlSource: d.controlSource(b.Binding.Provider, role)}
+ x := &exercise{d: d, root: root, evidence: e, answers: map[string]int{}, controlSource: automaticAnswers()}
defer func() { e = x.evidence }()
scratch := d.workerRoot
if scratch == "" {
diff --git a/internal/directlive/driver_test.go b/internal/directlive/driver_test.go
index 43d5e6ad..79beadd8 100644
--- a/internal/directlive/driver_test.go
+++ b/internal/directlive/driver_test.go
@@ -5,7 +5,6 @@ import (
"amadan.net/oficina/equipo/internal/runner/provider"
"amadan.net/oficina/equipo/internal/runner/provider/claude"
"amadan.net/oficina/equipo/internal/runner/provider/codex"
- "amadan.net/oficina/equipo/internal/runnerproto"
"context"
"encoding/json"
"errors"
@@ -32,9 +31,9 @@ func TestDirectDriverFakeCLI(t *testing.T) {
})
}
}
-func TestFewerPromptsFakeCLI(t *testing.T) {
+func TestAutomaticControlsFakeCLI(t *testing.T) {
t.Parallel()
- runFakeDriver(t, false, "EQUIPO_FAKE_FEWER_PROMPTS=1")
+ runFakeDriver(t, false, "EQUIPO_FAKE_AUTOMATIC_CONTROLS=1")
}
func runFakeDriver(t *testing.T, badCoordinator bool, env ...string) {
@@ -130,20 +129,6 @@ func TestDirectDriverFakeWorker(t *testing.T) {
}
}
p := Paths{Claude: filepath.Join(root, "claude"), Codex: filepath.Join(root, "codex"), CodeModeHost: filepath.Join(root, "codex-code-mode-host"), Bwrap: "/usr/bin/bwrap", Runner: os.Args[0], ToolProxy: filepath.Join(root, "equipo-tool-proxy")}
- personCalls := 0
- answer := func(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- if os.Getenv("EQUIPO_FAKE_FEWER_PROMPTS") == "1" {
- personCalls++
- return expectedAnswer(ctx, q)
- }
- if q.Kind == "person" || q.Kind == "question" {
- return runnerproto.QuestionAnswer{Behavior: "allow", UpdatedInput: json.RawMessage(`{"answers":{"answer":"fixture"}}`)}, nil
- }
- if strings.Contains(string(q.RawRequest), "equipo-cert-allow") {
- return runnerproto.QuestionAnswer{Behavior: "allow"}, nil
- }
- return runnerproto.QuestionAnswer{Behavior: "deny"}, nil
- }
paths := PolicyPaths{StateDir: filepath.Join(root, "state"), AccountBindingsPath: filepath.Join(root, "bindings.json"), AmadanCredentialPath: filepath.Join(root, "state/forge.json"), WorkspaceRoot: c.Repository, ScratchRoot: filepath.Join(root, "runtime-scratch")}
if err := os.Mkdir(paths.ScratchRoot, 0700); err != nil {
t.Fatal(err)
@@ -195,14 +180,14 @@ func TestDirectDriverFakeWorker(t *testing.T) {
if os.Getenv("EQUIPO_FAKE_BAD_COORDINATOR") == "1" {
roles = []string{"Engineering", "Coordinator"}
}
- if os.Getenv("EQUIPO_FAKE_FEWER_PROMPTS") == "1" {
+ if os.Getenv("EQUIPO_FAKE_AUTOMATIC_CONTROLS") == "1" {
roles = []string{"Review", "Engineering"}
}
source := "fake-cli"
if os.Getenv("EQUIPO_FAKE_LIVE_MODE") == "1" {
source = "direct-live"
}
- runErr := runRoles(context.Background(), c, marshal(c), p, source, answer, paths, roles)
+ runErr := runRoles(context.Background(), c, marshal(c), p, source, paths, roles)
if os.Getenv("EQUIPO_FAKE_BAD_COORDINATOR") == "1" {
var tuples *TupleFailures
if !errors.As(runErr, &tuples) || !strings.Contains(runErr.Error(), "codex-Coordinator") || strings.Contains(runErr.Error(), "Engineering") {
@@ -219,8 +204,8 @@ func TestDirectDriverFakeWorker(t *testing.T) {
if os.Getenv("EQUIPO_FAKE_COORDINATOR_ONLY") == "1" && ManifestCandidate(c.EvidenceDir) == nil {
t.Fatal("coordinator-only observations became release authority")
}
- if os.Getenv("EQUIPO_FAKE_FEWER_PROMPTS") == "1" {
- checkFewerPromptRun(t, c.EvidenceDir, personCalls)
+ if os.Getenv("EQUIPO_FAKE_AUTOMATIC_CONTROLS") == "1" {
+ checkAutomaticControlRun(t, c.EvidenceDir)
}
for path, before := range original {
raw, err := os.ReadFile(path)
@@ -264,6 +249,7 @@ func TestDirectDriverFakeWorker(t *testing.T) {
if json.Unmarshal(raw, &e) != nil || len(e.Usage) == 0 || e.Checks["workspace-positive-control"].Status != "pass" {
t.Fatalf("driver did not observe tools and usage: %s", raw)
}
+
if e.Checks["tuple-completed"].Status == "not-certified" || e.Checks["complete-input-output"].Status != "pass" {
t.Fatal("specialist contaminated by coordinator", name)
}
diff --git a/internal/directlive/final_gaps_test.go b/internal/directlive/final_gaps_test.go
index a3b5290d..a6048e25 100644
--- a/internal/directlive/final_gaps_test.go
+++ b/internal/directlive/final_gaps_test.go
@@ -18,10 +18,7 @@ func TestRoutingSetupCompletable(t *testing.T) {
}
func TestRoutingQuestionAutomatic(t *testing.T) {
- x := exercise{root: t.TempDir(), answers: map[string]int{}, d: &driver{answer: func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- t.Fatal("routing question reached person")
- return runnerproto.QuestionAnswer{}, nil
- }}}
+ x := exercise{root: t.TempDir(), answers: map[string]int{}}
q := runnerproto.Question{ID: "routing", Kind: "question", RawRequest: []byte(`{"provider":"codex","name":"request_user_input","input":{"questions":[{"header":"routing","question":"Continue?"}]}}`)}
a, err := x.answer(withProbeExpectation(context.Background(), "allow"), q)
if err != nil || a.Behavior != "allow" || string(a.UpdatedInput) != `{"answers":{"routing":"Continue"}}` {
@@ -30,10 +27,7 @@ func TestRoutingQuestionAutomatic(t *testing.T) {
}
func TestRoutingMCPQuestionAutomatic(t *testing.T) {
- x := exercise{routing: true, root: t.TempDir(), answers: map[string]int{}, d: &driver{answer: func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- t.Fatal("routing MCP question reached person")
- return runnerproto.QuestionAnswer{}, nil
- }}}
+ x := exercise{routing: true, root: t.TempDir(), answers: map[string]int{}}
q := runnerproto.Question{ID: "routing", Kind: "person", RawRequest: []byte(`{"id":"routing","kind":"person","question":"Continue?"}`)}
a, err := x.answer(context.Background(), q)
if err != nil || a.Behavior != "allow" {
diff --git a/internal/directlive/person_controls.go b/internal/directlive/person_controls.go
deleted file mode 100644
index abf05fda..00000000
--- a/internal/directlive/person_controls.go
+++ /dev/null
@@ -1,12 +0,0 @@
-package directlive
-
-import "amadan.net/oficina/equipo/internal/runner/provider"
-
-func (x *exercise) personControlCheck() error {
- proof := provider.PersonControlProof{AnsweredBy: x.controlSource.answeredBy, Answers: x.controlAnswers}
- ok := proof.Validate(x.root) == nil
- for _, name := range provider.ControlChecks {
- ok = ok && x.evidence.Checks[name].Status == "pass"
- }
- return x.check(provider.PersonAnsweredControls, ok, proof)
-}
diff --git a/internal/directlive/probe_answers.go b/internal/directlive/probe_answers.go
index ab0aeac1..edfbbce0 100644
--- a/internal/directlive/probe_answers.go
+++ b/internal/directlive/probe_answers.go
@@ -19,11 +19,3 @@ func withControlExpectation(ctx context.Context, behavior string) context.Contex
}
return context.WithValue(ctx, probeExpectationKey{}, probeExpectation{behavior: behavior, control: control})
}
-func terminalGuidance(ctx context.Context) string {
- expectation, _ := ctx.Value(probeExpectationKey{}).(probeExpectation)
- switch expectation.behavior {
- case "allow", "deny", "question":
- return "live.check-" + expectation.behavior
- }
- return ""
-}
diff --git a/internal/directlive/probe_answers_test.go b/internal/directlive/probe_answers_test.go
index e0ec51ac..d3e2d52d 100644
--- a/internal/directlive/probe_answers_test.go
+++ b/internal/directlive/probe_answers_test.go
@@ -7,24 +7,10 @@ import (
)
func TestProbeAnswersWithoutHuman(t *testing.T) {
- human := false
- x := exercise{probing: true, d: &driver{answer: func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- human = true
- return runnerproto.QuestionAnswer{}, nil
- }}, root: t.TempDir(), answers: map[string]int{}}
+ x := exercise{probing: true, root: t.TempDir(), answers: map[string]int{}}
q := runnerproto.Question{Kind: "tool", ID: "fixture", RawRequest: []byte(`{"name":"Read","input":{"file_path":"/protected/sentinel"},"provider":"claude","kind":"tool"}`)}
a, err := x.answer(context.Background(), q)
- if err != nil || a.Behavior != "deny" || human {
- t.Fatalf("probe asked human: answer=%+v err=%v human=%v", a, err, human)
- }
-}
-func TestControlGuidance(t *testing.T) {
- for expectation, key := range map[string]string{"allow": "live.check-allow", "deny": "live.check-deny", "question": "live.check-question"} {
- if got := terminalGuidance(withProbeExpectation(context.Background(), expectation)); got != key {
- t.Fatalf("%s: %s", expectation, got)
- }
- }
- if terminalGuidance(context.Background()) != "" {
- t.Fatal("unscoped expectation")
+ if err != nil || a.Behavior != "deny" {
+ t.Fatalf("probe asked human: answer=%+v err=%v", a, err)
}
}
diff --git a/internal/directlive/recovery.go b/internal/directlive/recovery.go
index 0b93349e..f0b5dbe7 100644
--- a/internal/directlive/recovery.go
+++ b/internal/directlive/recovery.go
@@ -47,7 +47,7 @@ func RecoveryWorker(ctx context.Context, path string) error {
}
ctx, cancel := context.WithTimeout(ctx, time.Duration(p.Config.Funding.Seconds)*time.Second)
defer cancel()
- d := &driver{policyPaths: p.PolicyPaths, cfg: p.Config, paths: p.Paths, hashes: hashes, source: "direct-live", worker: true, workerRoot: p.Root, answer: terminalAnswer}
+ d := &driver{policyPaths: p.PolicyPaths, cfg: p.Config, paths: p.Paths, hashes: hashes, source: "direct-live", worker: true, workerRoot: p.Root}
_, err = d.exercise(ctx, p.Binding, p.Role, filepath.Join(p.Root, "artifacts"))
if err != nil {
_ = save(p.Root, "worker-error.json", err.Error())
diff --git a/internal/directlive/routing_approval_test.go b/internal/directlive/routing_approval_test.go
index 248cf067..bde1cbe8 100644
--- a/internal/directlive/routing_approval_test.go
+++ b/internal/directlive/routing_approval_test.go
@@ -18,16 +18,12 @@ func TestRoutingApprovalsNeverAskPerson(t *testing.T) {
{"review", "Bash", "allow"},
} {
t.Run(tc.action+tc.name, func(t *testing.T) {
- human := false
- x := exercise{routing: true, root: t.TempDir(), answers: map[string]int{}, d: &driver{answer: func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- human = true
- return runnerproto.QuestionAnswer{Behavior: "allow"}, nil
- }}, launch: provider.Launch{Policy: provider.Policy{Manifest: marshal(map[string]string{"action": tc.action})}}}
+ x := exercise{routing: true, root: t.TempDir(), answers: map[string]int{}, launch: provider.Launch{Policy: provider.Policy{Manifest: marshal(map[string]string{"action": tc.action})}}}
ctx := withProbeExpectation(context.Background(), "allow")
q := runnerproto.Question{ID: "approval", Kind: "tool", RawRequest: marshal(map[string]any{"name": tc.name, "direct": true, "provider": "claude"})}
a, err := x.answer(ctx, q)
- if err != nil || human || a.Behavior != tc.want {
- t.Fatalf("answer=%+v err=%v person=%v want=%s", a, err, human, tc.want)
+ if err != nil || a.Behavior != tc.want {
+ t.Fatalf("answer=%+v err=%v want=%s", a, err, tc.want)
}
x.answerContext = ctx
if x.source(context.Background()).answeredBy != "automatic" {
diff --git a/internal/directlive/terminal.go b/internal/directlive/terminal.go
deleted file mode 100644
index 0af53b10..00000000
--- a/internal/directlive/terminal.go
+++ /dev/null
@@ -1,84 +0,0 @@
-package directlive
-
-import (
- "amadan.net/oficina/equipo/internal/equipo"
- "amadan.net/oficina/equipo/internal/runnerproto"
- "context"
- "encoding/json"
- "fmt"
- "golang.org/x/sys/unix"
- "os"
- "strings"
- "time"
-)
-
-func terminalAnswer(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
- var answer runnerproto.QuestionAnswer
- tty, err := os.OpenFile("/dev/tty", os.O_RDWR|unix.O_NONBLOCK, 0)
- if err != nil {
- return answer, err
- }
- defer tty.Close()
- if _, err = unix.IoctlGetTermios(int(tty.Fd()), unix.TCGETS); err != nil {
- return answer, err
- }
- if err = unix.IoctlSetInt(int(tty.Fd()), unix.TCFLSH, unix.TCIFLUSH); err != nil {
- return answer, err
- }
- key := terminalGuidance(ctx)
- if key == "" && (q.Kind == "person" || q.Kind == "question") {
- key = "live.check-question"
- }
- if key != "" {
- fmt.Fprintln(tty, equipo.RunnerText(key))
- }
- fmt.Fprintln(tty, equipo.RunnerText("live.answer"))
- fmt.Fprintln(tty, string(q.RawRequest))
- ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
- defer cancel()
- raw := []byte{}
- for len(raw) < 8192 {
- if err = ctx.Err(); err != nil {
- return answer, err
- }
- poll := []unix.PollFd{{Fd: int32(tty.Fd()), Events: unix.POLLIN}}
- if _, err = unix.Poll(poll, 100); err != nil && err != unix.EINTR {
- return answer, err
- }
- if poll[0].Revents&unix.POLLIN == 0 {
- continue
- }
- var b [1]byte
- n, e := unix.Read(int(tty.Fd()), b[:])
- if e == unix.EAGAIN || e == unix.EINTR {
- continue
- }
- if e != nil || n != 1 {
- return answer, runnerproto.ErrInvalid
- }
- if b[0] == '\n' || b[0] == '\r' {
- text := strings.TrimSpace(string(raw))
- raw = raw[:0]
- if text == "" {
- continue
- }
- switch text {
- case "Allow once":
- answer.Behavior = "allow"
- case "Deny":
- answer.Behavior = "deny"
- default:
- var object map[string]json.RawMessage
- if json.Unmarshal([]byte(text), &object) != nil || object == nil {
- fmt.Fprintln(tty, equipo.RunnerText("live.answer-retry"))
- continue
- }
- answer.Behavior = "allow"
- answer.UpdatedInput = json.RawMessage(text)
- }
- return answer, q.ValidateAnswer(answer)
- }
- raw = append(raw, b[0])
- }
- return answer, runnerproto.ErrInvalid
-}
diff --git a/internal/directlive/terminal_probe_test.go b/internal/directlive/terminal_probe_test.go
deleted file mode 100644
index 219daa49..00000000
--- a/internal/directlive/terminal_probe_test.go
+++ /dev/null
@@ -1,63 +0,0 @@
-package directlive
-
-import (
- "amadan.net/oficina/equipo/internal/equipo"
- "amadan.net/oficina/equipo/internal/runnerproto"
- "context"
- "os"
- "os/exec"
- "strings"
- "testing"
- "time"
-)
-
-func TestTerminalProbeGuidanceAndAnswer(t *testing.T) {
- if mode := os.Getenv("EQUIPO_TEST_TERMINAL_PROBE"); mode != "" {
- ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
- defer cancel()
- q := runnerproto.Question{Kind: "tool", RawRequest: []byte(`{"direct":true,"provider":"claude","name":"Bash","input":{"command":"printf fixture"}}`)}
- answer, err := terminalAnswer(withControlExpectation(ctx, mode), q)
- if err != nil || answer.Behavior != mode {
- t.Fatalf("terminal answer=%+v error=%v", answer, err)
- }
- return
- }
- for _, mode := range []string{"allow", "deny"} {
- 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_PROBE']=sys.argv[2]
- os.execv(sys.argv[1],[sys.argv[1],'-test.run=^TestTerminalProbeGuidanceAndAnswer$','-test.v'])
-output=b''; sent=False; reaped=False; end=time.monotonic()+8
-try:
- while time.monotonic()<end:
- ready,_,_=select.select([fd],[],[],0.1)
- if ready:
- try: data=os.read(fd,8192)
- except OSError: break
- if not data: break
- output+=data
- if not sent and b'Type Allow once, Deny,' in output:
- os.write(fd,b'Allow once\n' if sys.argv[2]=='allow' else b'Deny\n');sent=True
- _,status=os.waitpid(pid,0); reaped=True
- print(output.decode())
- sys.exit(os.waitstatus_to_exitcode(status))
-finally:
- if not reaped:
- try: os.kill(pid,signal.SIGKILL)
- except ProcessLookupError: pass
- os.waitpid(pid,0)
- os.close(fd)
-`
- ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
- defer cancel()
- self, _ := os.Executable()
- cmd := exec.CommandContext(ctx, "python3", "-c", script, self, mode)
- output, err := cmd.CombinedOutput()
- if err != nil || !strings.Contains(string(output), equipo.RunnerText("live.check-"+mode)) {
- t.Fatalf("terminal guidance/answer: %v\n%s", err, output)
- }
- })
- }
-}
diff --git a/internal/directlive/terminal_retry_test.go b/internal/directlive/terminal_retry_test.go
deleted file mode 100644
index 90523f55..00000000
--- a/internal/directlive/terminal_retry_test.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package directlive
-
-import (
- "context"
- "errors"
- "os"
- "os/exec"
- "strings"
- "testing"
- "time"
-
- "amadan.net/oficina/equipo/internal/runnerproto"
-)
-
-func TestTerminalRetryDeadlineAndValidObject(t *testing.T) {
- if mode := os.Getenv("EQUIPO_TEST_RETRY_MODE"); mode != "" {
- ctx, cancel := context.WithTimeout(context.Background(), 600*time.Millisecond)
- defer cancel()
- q := runnerproto.Question{Kind: "person", RawRequest: []byte(`{"kind":"person","question":"Which case?"}`)}
- _, err := terminalAnswer(withControlExpectation(ctx, "question"), q)
- want := runnerproto.ErrInvalid
- if mode == "deadline" {
- want = context.DeadlineExceeded
- }
- if !errors.Is(err, want) {
- t.Fatalf("answer error = %v, want %v", err, want)
- }
- return
- }
- script := `import os,pty,select,signal,sys,time
-pid,fd=pty.fork()
-if pid==0:
- os.environ['EQUIPO_TEST_RETRY_MODE']=sys.argv[2]
- os.execv(sys.argv[1],[sys.argv[1],'-test.run=^TestTerminalRetryDeadlineAndValidObject$'])
-output=b''; sent=False; reaped=False; end=time.monotonic()+3; last=0
-try:
- while time.monotonic()<end:
- if select.select([fd],[],[],0.05)[0]:
- try:data=os.read(fd,65536)
- except OSError:break
- output+=data
- if b'Type Allow once, Deny,' in output:
- if sys.argv[2]=='object' and not sent:os.write(fd,b'{}\n');sent=True
- if sys.argv[2]=='deadline' and time.monotonic()-last>0.15:os.write(fd,b'Alloe once\n');last=time.monotonic()
- done,status=os.waitpid(pid,os.WNOHANG)
- if done:reaped=True;break
- if not reaped:
- done,status=os.waitpid(pid,os.WNOHANG)
- reaped=bool(done)
- print(output.decode())
- if not reaped:raise RuntimeError('answer deadline was extended')
- if sys.argv[2]=='object' and b'Enter Allow once' in output:raise RuntimeError('valid JSON object was retried')
- if sys.argv[2]=='deadline' and output.count(b'Enter Allow once')<2:raise RuntimeError('typos were not retried')
- sys.exit(os.waitstatus_to_exitcode(status))
-finally:
- if not reaped:
- try:os.kill(pid,signal.SIGKILL)
- except ProcessLookupError:pass
- os.waitpid(pid,0)
- os.close(fd)
-`
- for _, mode := range []string{"object", "deadline"} {
- t.Run(mode, func(t *testing.T) {
- self, err := os.Executable()
- if err != nil {
- t.Fatal(err)
- }
- ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
- defer cancel()
- out, err := exec.CommandContext(ctx, "python3", "-c", script, self, mode).CombinedOutput()
- if err != nil || !strings.Contains(string(out), "PASS") {
- t.Fatalf("terminal retry: %s %v", out, err)
- }
- })
- }
-}
diff --git a/internal/directlive/turn.go b/internal/directlive/turn.go
index 88cf9e88..4b0400b3 100644
--- a/internal/directlive/turn.go
+++ b/internal/directlive/turn.go
@@ -219,15 +219,12 @@ func (x *exercise) answer(ctx context.Context, q runnerproto.Question) (runnerpr
}
x.mu.Unlock()
name := fmt.Sprintf("answer-%d-%s.json", x.sequence, q.ID)
- o, err := observation(x.root, name, "pass", map[string]any{"question": q, "answer": a, "answered_by": answeredBy, "control": expectation.control})
+ _, err = observation(x.root, name, "pass", map[string]any{"question": q, "answer": a, "answered_by": answeredBy, "control": expectation.control})
if err != nil {
return a, err
}
if expectation.control != "" {
x.mu.Lock()
- if x.controlAnswers == nil {
- x.controlAnswers = map[string][]provider.LiveObservation{}
- }
if x.controlPassed == nil {
x.controlPassed = map[string]bool{}
}
@@ -235,11 +232,10 @@ func (x *exercise) answer(ctx context.Context, q runnerproto.Question) (runnerpr
if expectation.behavior == "question" {
matches = (q.Kind == "person" || q.Kind == "question") && a.Behavior == "allow"
}
- if len(x.controlAnswers[expectation.control]) == 0 {
+ if _, seen := x.controlPassed[expectation.control]; !seen {
x.controlPassed[expectation.control] = true
}
x.controlPassed[expectation.control] = x.controlPassed[expectation.control] && matches
- x.controlAnswers[expectation.control] = append(x.controlAnswers[expectation.control], o)
x.mu.Unlock()
}
return a, nil
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 1416cf8a..38033bdb 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -798,13 +798,6 @@ var runnerDraftCopy = map[string]string{
"plan.changes": "Plan changes",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): task.state.proposed
"task.state.proposed": "Proposed",
-
- "live.check-deny": "Equipo is checking that this is refused. Type Deny.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05, live-probe brief): live.check-deny
- "live.check-allow": "Equipo is checking one-time approval. Type Allow once.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05, live-probe brief): live.check-allow
- "live.check-question": "Equipo is checking that your answer reaches the agent. Enter an answers JSON object.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05, live-probe brief): live.check-question
- "live.answer-retry": "Enter Allow once, Deny, or a valid JSON object.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context)
- "live.answer": "Type Allow once, Deny, or an answers JSON object. This request expires in 60 seconds.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): live.answer
- "live.beyond-profile": "Allow once is recorded as approved beyond profile.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): live.beyond-profile
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): isolation.approved_beyond_profile
"isolation.approved_beyond_profile": "approved beyond profile",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): trial.history
diff --git a/internal/equipotest/runner_release_test.go b/internal/equipotest/runner_release_test.go
index 5b801916..ff2f874b 100644
--- a/internal/equipotest/runner_release_test.go
+++ b/internal/equipotest/runner_release_test.go
@@ -57,7 +57,8 @@ func TestRunnerReleaseContractPackaging(t *testing.T) {
func TestDirectReleaseRequiresCertification(t *testing.T) {
for _, target := range []string{"release", "release-runner"} {
t.Run(target, func(t *testing.T) {
- runnerPackagingScenarios(t, target, []string{"clean", "missing_certification", "changed_policy", "fake_evidence", "fake_cli", "bwrap", "copy", "changed_tuple", "missing_assertion", "pending_live_copy", "pending_plan3_docs", "missing_plan3_inventory", "tampered_capture", "codex_policy", "tool_inventory", "underfunded", "no_person_controls", "automatic_controls", "missing_provider_check", "wrong_provider_check", "tampered_person_answer"})
+ scenarios := []string{"clean", "missing_certification", "changed_policy", "fake_evidence", "fake_cli", "bwrap", "copy", "changed_tuple", "missing_assertion", "pending_live_copy", "pending_plan3_docs", "missing_plan3_inventory", "tampered_capture", "codex_policy", "tool_inventory", "underfunded"}
+ runnerPackagingScenarios(t, target, append(scenarios, providertest.ControlFailureScenarios()...))
})
}
}
@@ -180,7 +181,7 @@ func installCertificationFixture(t *testing.T, root string, m *release.Manifest,
for i, c := range m.DirectPolicies {
dir := filepath.Join(root, "internal/release/evidence", c.Provider)
executionMust(t, os.MkdirAll(dir, 0700))
- artifact := []byte("synthetic observation for packaging tests only\n")
+ artifact := []byte(`{"fixture":"synthetic packaging observation", "answered_by":"automatic"}`)
executionMust(t, os.WriteFile(filepath.Join(dir, "capture.json"), artifact, 0600))
o := provider.LiveObservation{Status: "pass", Artifact: "capture.json", SHA256: fmt.Sprintf("%x", sha256.Sum256(artifact)), Detail: "synthetic fixture"}
e := provider.DirectEvidence{Artifacts: map[string]string{"capture.json": o.SHA256}, Schema: 2, Source: "direct-live", RunID: "fixture", Provider: c.Provider, ProviderVersion: c.ProviderVersion, LauncherVersion: c.LauncherVersion, BwrapVersion: c.BwrapVersion, PolicyVersion: m.PolicyVersion, PolicyHash: c.PolicyHash, AccountID: "fixture", HomeID: "fixture", Model: "fixture", Specialist: "Engineering", AuthHost: "", ConfigSHA256: strings.Repeat("c", 64), Binaries: binaryHashes, Checks: map[string]provider.LiveObservation{}, Usage: []provider.LiveUsage{{Input: 1, Output: 1, Complete: true}}, Funding: provider.LiveFunding{Calls: 1, InputTokens: 1000, OutputTokens: 1000, Seconds: 60, JobInput: 23000, JobOutput: 23000, ProjectInputHeadroom: 23000, ProjectOutputHeadroom: 23000, TeamInputHeadroom: 23000, TeamOutputHeadroom: 23000}}
@@ -191,7 +192,6 @@ func installCertificationFixture(t *testing.T, root string, m *release.Manifest,
}
}
providertest.SaveIsolation(t, dir, &e)
- providertest.PersonControls(t, dir, &e, scenario)
tools := map[string]string{"Read": "native", "Write": "native", "Edit": "native", "Glob": "search", "Grep": "search", "Bash": "shell", "mcp__equipo__submit_render": "mcp", "mcp__equipo__ask_person": "mcp", "mcp__equipo__submit_candidate": "mcp"}
for name, surface := range tools {
tool := provider.LiveTool{Name: name, Surface: surface, Exposed: true, Probes: map[string]provider.LiveObservation{}}
@@ -207,6 +207,7 @@ func installCertificationFixture(t *testing.T, root string, m *release.Manifest,
if c.Provider == "codex" {
e.CodexPolicy = &provider.LiveCodexPolicy{ApprovalPolicy: "on-request", ApprovalsReviewer: "user", StrictConfig: true, DenyProfile: true}
}
+ providertest.ControlFailure(&e, scenario)
switch scenario {
case "fake_evidence":
e.Source = "fake-cli"
@@ -234,7 +235,6 @@ func installCertificationFixture(t *testing.T, root string, m *release.Manifest,
executionMust(t, os.WriteFile(filepath.Join(dir, "capture.json"), []byte("changed"), 0600))
}
}
- providertest.PersonControlReferences(m, scenario)
switch scenario {
case "missing_certification":
m.Certifications = []release.Certification{}
diff --git a/internal/plan3test/plan3_release_test.go b/internal/plan3test/plan3_release_test.go
index 4604250f..e2c18b79 100644
--- a/internal/plan3test/plan3_release_test.go
+++ b/internal/plan3test/plan3_release_test.go
@@ -172,9 +172,8 @@ func plan3CopyInventory(t *testing.T) {
key := strings.TrimPrefix(strings.TrimSuffix(cells[0], "`"), "| `")
rows[key] = html.UnescapeString(strings.ReplaceAll(cells[1], "<br>", "\n"))
acceptedGuide := strings.HasPrefix(cells[2], "Guided live gate") && strings.TrimSuffix(cells[3], " |") == "COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context)"
- acceptedProbe := slices.Contains([]string{"live.check-deny", "live.check-allow", "live.check-question"}, key) && cells[2] == "Guided live probe controls" && strings.TrimSuffix(cells[3], " |") == "COPY ACCEPTED FOR NOW (Paul, 2026-11-05; live-probe brief)"
- acceptedRound2 := slices.Contains([]string{"live.answer-retry", "CopyCalibrationFunding"}, key) && strings.TrimSuffix(cells[3], " |") == "COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context)"
- if !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedGuide && !acceptedProbe && !acceptedRound2 {
+ acceptedRound2 := slices.Contains([]string{"CopyCalibrationFunding"}, key) && strings.TrimSuffix(cells[3], " |") == "COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context)"
+ if !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedGuide && !acceptedRound2 {
t.Fatal("entry has no copy review status or applicable acceptance", key)
}
}
diff --git a/internal/release/manifest.go b/internal/release/manifest.go
index 707f34bd..68d6a892 100644
--- a/internal/release/manifest.go
+++ b/internal/release/manifest.go
@@ -48,23 +48,22 @@ type Certification struct {
}
type Manifest struct {
- ProviderChecks map[string]map[string]Certification `json:"provider_checks,omitempty"`
- UncertifiedPolicies []UncertifiedPolicy `json:"uncertified_policies,omitempty"`
- Certifications []Certification `json:"certifications"`
- LiveGateCopyReviewed bool `json:"live_gate_copy_reviewed"`
- Binaries []BinaryDigest `json:"binaries"`
- DirectPolicies []PolicyCertificate `json:"direct_policies,omitempty"`
- LauncherVersion string `json:"launcher_version,omitempty"`
- BwrapVersion string `json:"bwrap_version,omitempty"`
- PolicyVersion string `json:"policy_version,omitempty"`
- Schema int `json:"schema"`
- RunnerTarget string `json:"runner_target"`
- InstanceTarget string `json:"instance_target"`
- Go string `json:"go"`
- Codex string `json:"codex"`
- Claude string `json:"claude"`
- VerifiedIsolationTuples []team.IsolationTuple `json:"verified_isolation_tuples"`
- GateEvidence []string `json:"gate_evidence"`
+ UncertifiedPolicies []UncertifiedPolicy `json:"uncertified_policies,omitempty"`
+ Certifications []Certification `json:"certifications"`
+ LiveGateCopyReviewed bool `json:"live_gate_copy_reviewed"`
+ Binaries []BinaryDigest `json:"binaries"`
+ DirectPolicies []PolicyCertificate `json:"direct_policies,omitempty"`
+ LauncherVersion string `json:"launcher_version,omitempty"`
+ BwrapVersion string `json:"bwrap_version,omitempty"`
+ PolicyVersion string `json:"policy_version,omitempty"`
+ Schema int `json:"schema"`
+ RunnerTarget string `json:"runner_target"`
+ InstanceTarget string `json:"instance_target"`
+ Go string `json:"go"`
+ Codex string `json:"codex"`
+ Claude string `json:"claude"`
+ VerifiedIsolationTuples []team.IsolationTuple `json:"verified_isolation_tuples"`
+ GateEvidence []string `json:"gate_evidence"`
}
func BuildManifest() Manifest {
diff --git a/internal/release/manifest.json b/internal/release/manifest.json
index 9b5b2158..c35f3875 100644
--- a/internal/release/manifest.json
+++ b/internal/release/manifest.json
@@ -18,109 +18,109 @@
{
"provider": "claude",
"action": "reproduce",
- "inventory_hash": "2d30111832a765985325c0c65ad47145f2fc20f91589f1d6a31f53cbe25064bc",
+ "inventory_hash": "d802e8240ad3ca9596d49474c9326a08247781c622524ac365d87f93772d6c6a",
"status": "uncertified"
},
{
"provider": "claude",
"action": "scope",
- "inventory_hash": "542e489e809d8033a6695465083e8465c7d56653afd19a9ae4b57c7fd1902416",
+ "inventory_hash": "7fe4e64e6c15483747018194e98be1f96f106a1c9ffd046a3ba31ab93873466a",
"status": "uncertified"
},
{
"provider": "claude",
"action": "recommend",
- "inventory_hash": "5793cd626d236cd3d88b5963c09902c14f1043a8933fa166398ce7f1c208e7fc",
+ "inventory_hash": "9e8ebe265a6bca64bccbf8fea3870330df0c3eedaa7199485b1fbd08aca96c9c",
"status": "uncertified"
},
{
"provider": "claude",
"action": "investigate",
- "inventory_hash": "32f8044b4fe444bebb181a1c0e08a3f9fcce322aec821e8fd03c0fdb0fea2ba7",
+ "inventory_hash": "060d0dfc291972fd62531f60473b9452421ded41ddb3a397718a1ec780b778d4",
"status": "uncertified"
},
{
"provider": "claude",
"action": "implement",
- "inventory_hash": "72a972b9044c47ce5ac1a113300c106ce7ce6042b637f588d95fbc21992240bf",
+ "inventory_hash": "7b789913bac4eda97c50d6371cf77649b5b4e0a33c61c8dd26a1e4959a7c4d56",
"status": "uncertified"
},
{
"provider": "claude",
"action": "copy",
- "inventory_hash": "4089970bdc8d187421aa4a47d910e0ca557a2f53d1131f1f5ee2a9e2bc3dc891",
+ "inventory_hash": "04edfb7745cf0165a7de42efa3df30664f65071fadb333a7eb02af905d2d792a",
"status": "uncertified"
},
{
"provider": "claude",
"action": "design",
- "inventory_hash": "0bb7c9b79bd32d907786dee975bd7d1af9ded0d643560cb65060d44f9f7514a6",
+ "inventory_hash": "d4c63e082e1999db25b3df3f069cf35666c0ecf376a86da36b2c78299089e7c9",
"status": "uncertified"
},
{
"provider": "claude",
"action": "review",
- "inventory_hash": "1575c1af43786b4051c966b76529a4e0c5da218d1628294c6248e652129dd320",
+ "inventory_hash": "4da217f49bbbf4b91bb1a633960f168d591cec6fe9872efcff73864f338cba77",
"status": "uncertified"
},
{
"provider": "codex",
"action": "reproduce",
- "inventory_hash": "901526200f84751107212e20d37ba0fb69b7327c68f22fb848bce0b1e8d8015a",
+ "inventory_hash": "b6e655f8fcf1a0034d53746b9b4d787231507bbbe5dd8bdf1f2808396ef61330",
"status": "uncertified"
},
{
"provider": "codex",
"action": "scope",
- "inventory_hash": "d4ca8ac8de09708ff436f6e6f9f37c7633f0f142ed8f05dc0323fd125067d7cb",
+ "inventory_hash": "1bed31cbb9eae1492739d411096cc12f7b26cdab00afe05edd1407372221231d",
"status": "uncertified"
},
{
"provider": "codex",
"action": "recommend",
- "inventory_hash": "1b74ea49e9ea967cc5e45259f5083a1e72a075f0c4a36966bf7b547cd35b63b4",
+ "inventory_hash": "b7859832d33116d86e7286b0bffd3f90c8e08d2f56e61c56f14f37027346ddd8",
"status": "uncertified"
},
{
"provider": "codex",
"action": "investigate",
- "inventory_hash": "41d48df7ddc595e8bf8d18af7aec7949d061e3f623be652acb641701bbe14c7d",
+ "inventory_hash": "3a958ba7d6be9e64ab95b3c605044c84b295c3d8b8d7c340f0d918fe64fdeae0",
"status": "uncertified"
},
{
"provider": "codex",
"action": "implement",
- "inventory_hash": "c17dcf2652a12d934d315a9851ef30c2a44e28c0b335821fd37130d80073ce5d",
+ "inventory_hash": "28be065a40027bf8cfdb6155f44da69bdcf30b6eae13babf7ea4a2612fb83ed3",
"status": "uncertified"
},
{
"provider": "codex",
"action": "copy",
- "inventory_hash": "07d46054cadebbb157b506214dc68dd28f603c7b7626a24d2f7a68fd9dab58cd",
+ "inventory_hash": "37431eba8f27d0692ab5a418621b14d4c24b6d94762bd8683b7f76b6ee0e0398",
"status": "uncertified"
},
{
"provider": "codex",
"action": "design",
- "inventory_hash": "f9c15cf275406039ca47da0b22b7d3fdaaabde84d320690a965c0cb53bbf5623",
+ "inventory_hash": "a33a8c70e38254817d814c407657d541a5ddaf363014aa15869e5f98e1d27ec6",
"status": "uncertified"
},
{
"provider": "codex",
"action": "review",
- "inventory_hash": "93d34cac547f6daef7ef6d6d0a4220df25fbb98bf03e15e5e743f694bc2a35a7",
+ "inventory_hash": "787313a03304024b83146a6ed21d8e559afaa28e85aa65423e9f78bd2f2d9f39",
"status": "uncertified"
},
{
"provider": "claude",
"action": "coordinate",
- "inventory_hash": "dd19cd361277bd2cce8ca708c9b43ded23b71fb6d8bd3df4e244d0f1f4921a31",
+ "inventory_hash": "a671f7b2fe5b2d9864684d2260400f278041f35f0b33afbe7e2569551aba9e7f",
"status": "uncertified"
},
{
"provider": "codex",
"action": "coordinate",
- "inventory_hash": "87c00f178407f7bd3868f1c22cf1c8ac0bbc4f0e011f68d49cb308098003452d",
+ "inventory_hash": "d6815e9d94c8c96ae63e40505011be6c7ec226db1e2479454eee83ca6b8f4c6e",
"status": "uncertified"
}
]
diff --git a/internal/runner/provider/claude/launcher.go b/internal/runner/provider/claude/launcher.go
index 712eb731..52d2ab14 100644
--- a/internal/runner/provider/claude/launcher.go
+++ b/internal/runner/provider/claude/launcher.go
@@ -160,6 +160,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, specialist, mode
}
}
settings := map[string]any{
+ "env": map[string]string{"MCP_TOOL_TIMEOUT": "600000"},
"disableAllHooks": true, "enabledPlugins": map[string]any{"agents-md@builtin": false, "plugin-authoring@builtin": false}, "autoMemoryEnabled": false, "autoDreamEnabled": false,
"sandbox": map[string]any{"enabled": true, "failIfUnavailable": true, "allowUnsandboxedCommands": false, "autoAllowBashIfSandboxed": true, "excludedCommands": []string{}, "filesystem": map[string]any{"denyRead": settingsDenied, "denyWrite": settingsDenied}, "network": map[string]any{"allowUnixSockets": []string{}}},
"permissions": map[string]any{"deny": nativeDenies, "allow": allow, "ask": ask},
diff --git a/internal/runner/provider/claude/person_timeout_test.go b/internal/runner/provider/claude/person_timeout_test.go
new file mode 100644
index 00000000..668c769e
--- /dev/null
+++ b/internal/runner/provider/claude/person_timeout_test.go
@@ -0,0 +1,17 @@
+package claude
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestPersonControlProviderTimeout(t *testing.T) {
+ f := fixtureFor(t, "Engineering")
+ var settings struct{ Env map[string]string }
+ if err := json.Unmarshal(f.launch.Policy.Settings, &settings); err != nil {
+ t.Fatal(err)
+ }
+ if settings.Env["MCP_TOOL_TIMEOUT"] != "600000" {
+ t.Fatalf("provider tool timeout must exceed five minutes: %+v", settings)
+ }
+}
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go
index f30c94ac..94dd64cf 100644
--- a/internal/runner/provider/codex/launcher.go
+++ b/internal/runner/provider/codex/launcher.go
@@ -139,7 +139,7 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p
"skills": map[string]any{"bundled": map[string]any{"enabled": false}},
"model": model, "model_provider": "openai", "approval_policy": "on-request", "approvals_reviewer": "user", "default_permissions": "equipo",
"permissions": map[string]any{"equipo": map[string]any{"filesystem": fs, "network": map[string]any{"enabled": false}}},
- "features": map[string]any{"incremental_tools": true, "apps": false, "multi_agent": false, "remote_control": false, "memories": false, "goals": false, "plugins": false, "remote_plugin": false, "tool_suggest": false, "tool_call_mcp_elicitation": true}, "mcp_servers": map[string]any{"equipo": map[string]any{"command": "/opt/equipo-tool-proxy", "args": []string{"--socket", "/tool/equipo.sock"}}},
+ "features": map[string]any{"incremental_tools": true, "apps": false, "multi_agent": false, "remote_control": false, "memories": false, "goals": false, "plugins": false, "remote_plugin": false, "tool_suggest": false, "tool_call_mcp_elicitation": true}, "mcp_servers": map[string]any{"equipo": map[string]any{"tool_timeout_sec": 600, "command": "/opt/equipo-tool-proxy", "args": []string{"--socket", "/tool/equipo.sock"}}},
}
// Code mode hides the native tool schemas from the captured catalog. The
// v2 collaboration switches are independent of the legacy multi_agent flag.
@@ -184,6 +184,8 @@ func PolicyInputs(b provider.Binding, in provider.PolicyInputs, model string) (p
}
func toml(v any) string {
switch x := v.(type) {
+ case int:
+ return strconv.Itoa(x)
case string:
return strconv.Quote(x)
case bool:
diff --git a/internal/runner/provider/codex/person_timeout_test.go b/internal/runner/provider/codex/person_timeout_test.go
new file mode 100644
index 00000000..aed1afb5
--- /dev/null
+++ b/internal/runner/provider/codex/person_timeout_test.go
@@ -0,0 +1,21 @@
+package codex
+
+import (
+ "encoding/json"
+ "testing"
+)
+
+func TestPersonControlProviderTimeout(t *testing.T) {
+ f := fixtureFor(t)
+ var settings struct {
+ MCP map[string]struct {
+ Timeout int `json:"tool_timeout_sec"`
+ } `json:"mcp_servers"`
+ }
+ if err := json.Unmarshal(f.launch.Policy.Settings, &settings); err != nil {
+ t.Fatal(err)
+ }
+ if settings.MCP["equipo"].Timeout != 600 {
+ t.Fatalf("provider tool timeout must exceed five minutes: %+v", settings)
+ }
+}
diff --git a/internal/runner/provider/control_checks.go b/internal/runner/provider/control_checks.go
new file mode 100644
index 00000000..1bf480d9
--- /dev/null
+++ b/internal/runner/provider/control_checks.go
@@ -0,0 +1,3 @@
+package provider
+
+var ControlChecks = []string{"workspace-positive-control", "person-native-approval", "real-question-answer", "policy-escalation-denied", "equipo-broker-approval", "stale-broker-denied", "invalid-broker-denied"}
diff --git a/internal/runner/provider/person_controls.go b/internal/runner/provider/person_controls.go
deleted file mode 100644
index 79ae15e6..00000000
--- a/internal/runner/provider/person_controls.go
+++ /dev/null
@@ -1,92 +0,0 @@
-package provider
-
-import (
- "encoding/json"
- "os"
- "path/filepath"
- "slices"
-)
-
-const PersonAnsweredControls = "person-answered-controls"
-
-var ControlChecks = []string{"workspace-positive-control", "person-native-approval", "real-question-answer", "policy-escalation-denied", "equipo-broker-approval", "stale-broker-denied", "invalid-broker-denied"}
-
-type PersonControlProof struct {
- AnsweredBy string `json:"answered_by"`
- Answers map[string][]LiveObservation `json:"answers"`
-}
-
-func (e DirectEvidence) ValidatePersonControls(root string) error {
- if e.Specialist == "Coordinator" || e.Checks["tuple-completed"].Status == "not-certified" {
- return ErrPolicy
- }
- for _, key := range append([]string{PersonAnsweredControls}, ControlChecks...) {
- if VerifyDirectObservation(root, e.Checks[key], "pass") != nil {
- return ErrPolicy
- }
- raw, err := os.ReadFile(filepath.Join(root, e.Checks[key].Artifact))
- var attribution struct {
- AnsweredBy string `json:"answered_by"`
- }
- if err != nil || json.Unmarshal(raw, &attribution) != nil || attribution.AnsweredBy != "person" {
- return ErrPolicy
- }
- }
- raw, err := os.ReadFile(filepath.Join(root, e.Checks[PersonAnsweredControls].Artifact))
- var proof PersonControlProof
- if err != nil || json.Unmarshal(raw, &proof) != nil || proof.AnsweredBy != "person" {
- return ErrPolicy
- }
- return proof.Validate(root)
-}
-
-func (p PersonControlProof) Validate(root string) error {
- if p.AnsweredBy != "person" || (len(p.Answers) < 3 || len(p.Answers) > 4) {
- return ErrPolicy
- }
- for key := range p.Answers {
- if !slices.Contains([]string{"workspace", "allow", "deny", "question"}, key) {
- return ErrPolicy
- }
- }
- seen := map[string]bool{}
- for _, control := range []string{"workspace", "allow", "deny", "question"} {
- if control != "workspace" && len(p.Answers[control]) == 0 {
- return ErrPolicy
- }
- for _, o := range p.Answers[control] {
- if seen[o.Artifact] || VerifyDirectObservation(root, o, "pass") != nil {
- return ErrPolicy
- }
- seen[o.Artifact] = true
- raw, err := os.ReadFile(filepath.Join(root, o.Artifact))
- var a struct {
- AnsweredBy string `json:"answered_by"`
- Control string `json:"control"`
- Answer struct {
- Behavior string `json:"behavior"`
- UpdatedInput json.RawMessage `json:"updated_input"`
- } `json:"answer"`
- }
- if err != nil || json.Unmarshal(raw, &a) != nil || a.AnsweredBy != "person" || a.Control != control {
- return ErrPolicy
- }
- want := "allow"
- if control == "deny" {
- want = "deny"
- }
- if a.Answer.Behavior != want {
- return ErrPolicy
- }
- if control == "question" {
- var input struct {
- Answers map[string]string `json:"answers"`
- }
- if json.Unmarshal(a.Answer.UpdatedInput, &input) != nil || input.Answers["answer"] == "" {
- return ErrPolicy
- }
- }
- }
- }
- return nil
-}
diff --git a/internal/runner/provider/providertest/control_failures.go b/internal/runner/provider/providertest/control_failures.go
new file mode 100644
index 00000000..191246a5
--- /dev/null
+++ b/internal/runner/provider/providertest/control_failures.go
@@ -0,0 +1,30 @@
+package providertest
+
+import (
+ "strings"
+
+ "amadan.net/oficina/equipo/internal/runner/provider"
+)
+
+func ControlFailureScenarios() []string {
+ var scenarios []string
+ for _, name := range provider.ControlChecks {
+ scenarios = append(scenarios, "missing_control/"+name, "failed_control/"+name)
+ }
+ return scenarios
+}
+
+func ControlFailure(e *provider.DirectEvidence, scenario string) {
+ mode, name, _ := strings.Cut(scenario, "/")
+ o := e.Checks[name]
+ switch mode {
+ case "missing_control":
+ delete(e.Checks, name)
+ case "failed_control":
+ o.Status = "not-certified"
+ e.Checks[name] = o
+ case "tampered_control":
+ o.SHA256 = strings.Repeat("f", 64)
+ e.Checks[name] = o
+ }
+}
diff --git a/internal/runner/provider/providertest/person_controls.go b/internal/runner/provider/providertest/person_controls.go
deleted file mode 100644
index a814d685..00000000
--- a/internal/runner/provider/providertest/person_controls.go
+++ /dev/null
@@ -1,68 +0,0 @@
-package providertest
-
-import (
- "encoding/json"
- "os"
- "path/filepath"
- "testing"
-
- "amadan.net/oficina/equipo/internal/release"
- "amadan.net/oficina/equipo/internal/runner/provider"
-)
-
-// PersonControls writes synthetic person-answer evidence for offline fixtures.
-func PersonControls(t *testing.T, root string, e *provider.DirectEvidence, scenario string) {
- t.Helper()
- write := func(name string, value any) provider.LiveObservation {
- raw, err := json.Marshal(value)
- if err != nil {
- t.Fatal(err)
- }
- if err = os.WriteFile(filepath.Join(root, name), raw, 0600); err != nil {
- t.Fatal(err)
- }
- hash := provider.DigestDirectEvidence(raw)
- e.Artifacts[name] = hash
- return provider.LiveObservation{Status: "pass", Artifact: name, SHA256: hash, Detail: "synthetic unit-test fixture"}
- }
- for _, name := range provider.ControlChecks {
- e.Checks[name] = write(name+".json", map[string]string{"answered_by": "person"})
- }
- proof := provider.PersonControlProof{AnsweredBy: "person", Answers: map[string][]provider.LiveObservation{}}
- for _, control := range []string{"workspace", "allow", "deny", "question"} {
- behavior := "allow"
- if control == "deny" {
- behavior = "deny"
- }
- answer := map[string]any{"behavior": behavior}
- if control == "question" {
- answer["updated_input"] = map[string]any{"answers": map[string]string{"answer": "ordinary"}}
- }
- proof.Answers[control] = []provider.LiveObservation{write("answer-"+control+".json", map[string]any{"answered_by": "person", "control": control, "answer": answer})}
- }
- if scenario == "automatic_controls" {
- proof.AnsweredBy = "automatic"
- }
- e.Checks[provider.PersonAnsweredControls] = write("person-answered-controls.json", proof)
- if scenario == "no_person_controls" {
- delete(e.Checks, provider.PersonAnsweredControls)
- }
- if scenario == "tampered_person_answer" {
- if err := os.WriteFile(filepath.Join(root, "answer-allow.json"), []byte("changed"), 0600); err != nil {
- t.Fatal(err)
- }
- }
-}
-
-func PersonControlReferences(m *release.Manifest, scenario string) {
- m.ProviderChecks = map[string]map[string]release.Certification{}
- for _, ref := range m.Certifications {
- m.ProviderChecks[ref.Provider] = map[string]release.Certification{provider.PersonAnsweredControls: ref}
- }
- switch scenario {
- case "missing_provider_check":
- delete(m.ProviderChecks, "codex")
- case "wrong_provider_check":
- m.ProviderChecks["codex"] = m.ProviderChecks["claude"]
- }
-}
diff --git a/internal/tryequipo/funding_test.go b/internal/tryequipo/funding_test.go
index e74756ce..6805c299 100644
--- a/internal/tryequipo/funding_test.go
+++ b/internal/tryequipo/funding_test.go
@@ -8,7 +8,7 @@ import (
)
func TestFundingProposedDefaults(t *testing.T) {
- for _, saved := range []string{"fresh", "legacy", "recent", "custom"} {
+ for _, saved := range []string{"fresh", "legacy", "recent", "round-one", "custom"} {
t.Run(saved, func(t *testing.T) {
values := map[string]string{}
if saved == "legacy" {
@@ -17,6 +17,9 @@ func TestFundingProposedDefaults(t *testing.T) {
if saved == "recent" {
values = map[string]string{"OutputTokens": "2000000", "JobOutput": "230000", "ProjectOutputHeadroom": "230000", "TeamOutputHeadroom": "230000", "InputTokens": "50000000", "JobInput": "5750000", "ProjectInputHeadroom": "5750000", "TeamInputHeadroom": "5750000"}
}
+ if saved == "round-one" {
+ values = map[string]string{"InputTokens": "100000000", "OutputTokens": "16000000", "JobInput": "11500000", "JobOutput": "1150000", "ProjectInputHeadroom": "11500000", "TeamInputHeadroom": "11500000", "ProjectOutputHeadroom": "1150000", "TeamOutputHeadroom": "1150000"}
+ }
if saved == "custom" {
values = map[string]string{"JobInput": "3000000", "OutputTokens": "17000000", "JobOutput": "1300000", "ProjectOutputHeadroom": "1300000", "TeamOutputHeadroom": "1300000"}
}
@@ -29,13 +32,13 @@ func TestFundingProposedDefaults(t *testing.T) {
if err != nil {
t.Fatal(err)
}
- want := int64(11500000)
+ want := int64(60000000)
wantOut, wantTotalOut := int64(1150000), int64(16000000)
if saved == "custom" {
want = 3000000
wantOut, wantTotalOut = 1300000, 17000000
}
- if f.JobInput != want || f.ProjectInputHeadroom != 11500000 || f.TeamInputHeadroom != 11500000 || f.JobOutput != wantOut || f.ProjectOutputHeadroom != wantOut || f.TeamOutputHeadroom != wantOut || f.InputTokens != 100000000 || f.OutputTokens != wantTotalOut || f.Calls != 500 || f.Seconds != 7200 {
+ if f.JobInput != want || f.ProjectInputHeadroom != 60000000 || f.TeamInputHeadroom != 60000000 || f.JobOutput != wantOut || f.ProjectOutputHeadroom != wantOut || f.TeamOutputHeadroom != wantOut || f.InputTokens != 900000000 || f.OutputTokens != wantTotalOut || f.Calls != 500 || f.Seconds != 7200 {
t.Fatalf("funding: %+v", f)
}
})
diff --git a/internal/tryequipo/run.go b/internal/tryequipo/run.go
index f763f49f..bfd2c041 100644
--- a/internal/tryequipo/run.go
+++ b/internal/tryequipo/run.go
@@ -217,16 +217,16 @@ func (w *Wizard) ownedWrite(path string, raw []byte) error {
func (w *Wizard) funding() (provider.LiveFunding, error) {
var f provider.LiveFunding
// Legacy holds earlier proposals; a saved value equal to one is re-proposed.
- // Job input is 23 x 500,000: run 4 measured 6,072,000 for Claude Engineering.
- in, out := []int64{2300000, 5750000}, []int64{230000}
+ // Round 2 bounds include 3x the saved family needs; see the tty answers report.
+ in, out := []int64{2300000, 5750000, 11500000}, []int64{230000, 1150000}
entries := []struct {
Key string
Value *int64
Default int64
Legacy []int64
}{
- {"Calls", &f.Calls, 500, nil}, {"InputTokens", &f.InputTokens, 100000000, []int64{10000000, 50000000}}, {"OutputTokens", &f.OutputTokens, 16000000, []int64{1000000, 2000000}}, {"Seconds", &f.Seconds, 7200, nil},
- {"JobInput", &f.JobInput, 11500000, in}, {"JobOutput", &f.JobOutput, 1150000, out}, {"ProjectInputHeadroom", &f.ProjectInputHeadroom, 11500000, in}, {"ProjectOutputHeadroom", &f.ProjectOutputHeadroom, 1150000, out}, {"TeamInputHeadroom", &f.TeamInputHeadroom, 11500000, in}, {"TeamOutputHeadroom", &f.TeamOutputHeadroom, 1150000, out},
+ {"Calls", &f.Calls, 500, nil}, {"InputTokens", &f.InputTokens, 900000000, []int64{10000000, 50000000, 100000000}}, {"OutputTokens", &f.OutputTokens, 16000000, []int64{1000000, 2000000, 16000000}}, {"Seconds", &f.Seconds, 7200, nil},
+ {"JobInput", &f.JobInput, 60000000, in}, {"JobOutput", &f.JobOutput, 1150000, out}, {"ProjectInputHeadroom", &f.ProjectInputHeadroom, 60000000, in}, {"ProjectOutputHeadroom", &f.ProjectOutputHeadroom, 1150000, out}, {"TeamInputHeadroom", &f.TeamInputHeadroom, 60000000, in}, {"TeamOutputHeadroom", &f.TeamOutputHeadroom, 1150000, out},
}
for _, e := range entries {
def := strconv.FormatInt(e.Default, 10)
diff --git a/internal/tryequipo/testdata/tty-chain/answer.go.txt b/internal/tryequipo/testdata/tty-chain/answer.go.txt
new file mode 100644
index 00000000..2b03656e
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/answer.go.txt
@@ -0,0 +1,48 @@
+package directlive
+
+import (
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "context"
+ "errors"
+ "fmt"
+ "os"
+ "time"
+)
+
+func TTYChainFixture() {
+ x := &exercise{root: os.Getenv("EQUIPO_TTY_FIXTURE_EVIDENCE"), answers: map[string]int{}, controlSource: automaticAnswers()}
+ for i, mode := range []string{"allow", "deny", "question", "invalid", "timeout"} {
+ q := runnerproto.Question{ID: mode, Kind: "tool", RawRequest: []byte(`{"direct":true,"provider":"claude","name":"Bash","input":{"command":"printf fixture"}}`)}
+ if mode == "question" || mode == "invalid" {
+ q.Kind = "person"
+ q.RawRequest = []byte(`{"kind":"person","question":"Which case?"}`)
+ }
+ duration := 3 * time.Second
+ if mode == "timeout" {
+ duration = -time.Second
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), duration)
+ x.sequence = i + 1
+ answer, err := x.answer(withControlExpectation(ctx, mode), q)
+ cancel()
+ switch mode {
+ case "invalid":
+ if !errors.Is(err, runnerproto.ErrInvalid) {
+ panic(fmt.Sprint("invalid answer: ", err))
+ }
+ case "timeout":
+ if !errors.Is(err, context.DeadlineExceeded) {
+ panic(fmt.Sprint("timeout: ", err))
+ }
+ default:
+ want := mode
+ if mode == "question" {
+ want = "allow"
+ }
+ if err != nil || answer.Behavior != want {
+ panic(fmt.Sprintf("answer=%+v error=%v", answer, err))
+ }
+ }
+ }
+ fmt.Println("fixture answers verified")
+}
diff --git a/internal/tryequipo/testdata/tty-chain/drive.py b/internal/tryequipo/testdata/tty-chain/drive.py
new file mode 100644
index 00000000..dbadb86b
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/drive.py
@@ -0,0 +1,57 @@
+import os
+import pty
+import select
+import signal
+import sys
+import time
+
+pid, fd = pty.fork()
+if pid == 0:
+ os.chdir(sys.argv[1])
+ os.execv('/bin/bash', ['bash', '--noprofile', '--norc', '-i'])
+output = b''
+stage = 0
+reaped = False
+status = None
+prompt = b'Type Allow once, Deny,'
+try:
+ os.write(fd, b'./scripts/try-equipo.sh; result=$?; exit "$result"\n')
+ end = time.monotonic() + 60
+ while time.monotonic() < end:
+ if select.select([fd], [], [], 0.1)[0]:
+ try:
+ data = os.read(fd, 65536)
+ except OSError:
+ break
+ if not data:
+ break
+ output += data
+ if stage == 0 and b'[]: ' in output:
+ os.write(fd, b'RUN LIVE GATE\r')
+ stage = 1
+ if prompt in output:
+ raise RuntimeError('live gate requested a typed control answer')
+ if not reaped:
+ done, status = os.waitpid(pid, os.WNOHANG)
+ if done:
+ reaped = True
+ if not reaped:
+ done, status = os.waitpid(pid, os.WNOHANG)
+ reaped = bool(done)
+ if not reaped or os.waitstatus_to_exitcode(status) != 0:
+ raise RuntimeError('process chain did not finish successfully')
+ if stage != 1:
+ raise RuntimeError('RUN LIVE GATE confirmation was skipped')
+finally:
+ print(output.decode(errors='replace'))
+ # Kill only descendants in this fixture's private terminal session.
+ for name in os.listdir('/proc'):
+ if name.isdigit():
+ try:
+ if os.getsid(int(name)) == pid:
+ os.kill(int(name), signal.SIGKILL)
+ except (ProcessLookupError, PermissionError):
+ pass
+ if not reaped:
+ os.waitpid(pid, 0)
+ os.close(fd)
diff --git a/internal/tryequipo/testdata/tty-chain/live_test.go.txt b/internal/tryequipo/testdata/tty-chain/live_test.go.txt
new file mode 100644
index 00000000..3d2d882f
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/live_test.go.txt
@@ -0,0 +1,17 @@
+//go:build direct_live
+
+package provider_test
+
+import (
+ "amadan.net/oficina/equipo/internal/directlive"
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "context"
+ "os"
+ "testing"
+)
+
+func TestDirectLiveContract(t *testing.T) {
+ if err := directlive.Run(context.Background(), provider.DirectLiveConfig{}, []byte("{}"), directlive.Paths{Runner: os.Getenv("EQUIPO_TTY_FIXTURE_RUNNER")}); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/internal/tryequipo/testdata/tty-chain/main.go.txt b/internal/tryequipo/testdata/tty-chain/main.go.txt
new file mode 100644
index 00000000..e417db59
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/main.go.txt
@@ -0,0 +1,5 @@
+package main
+
+import "amadan.net/oficina/equipo/internal/tryequipo"
+
+func main() { tryequipo.TTYChainFixture() }
diff --git a/internal/tryequipo/testdata/tty-chain/runner.go.txt b/internal/tryequipo/testdata/tty-chain/runner.go.txt
new file mode 100644
index 00000000..eaa798c7
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/runner.go.txt
@@ -0,0 +1,5 @@
+package main
+
+import "amadan.net/oficina/equipo/internal/directlive"
+
+func main() { directlive.TTYChainFixture() }
diff --git a/internal/tryequipo/testdata/tty-chain/wizard.go.txt b/internal/tryequipo/testdata/tty-chain/wizard.go.txt
new file mode 100644
index 00000000..47d39640
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/wizard.go.txt
@@ -0,0 +1,27 @@
+package tryequipo
+
+import (
+ "context"
+ "fmt"
+ "os"
+ "time"
+)
+
+func TTYChainFixture() {
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ w := Wizard{Input: os.Stdin, Output: os.Stdout}
+ w.init()
+ if answer, err := w.ask("live", ""); err != nil || answer != "RUN LIVE GATE" {
+ panic(fmt.Sprint(answer, err))
+ }
+ cwd, err := os.Getwd()
+ if err != nil {
+ panic(err)
+ }
+ out, err := gateCommand(ctx, "go", liveGateArgs(), cwd, os.Environ())
+ fmt.Print(string(out))
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/internal/tryequipo/tty_chain_test.go b/internal/tryequipo/tty_chain_test.go
new file mode 100644
index 00000000..df0d6f68
--- /dev/null
+++ b/internal/tryequipo/tty_chain_test.go
@@ -0,0 +1,89 @@
+package tryequipo
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "testing"
+ "time"
+)
+
+// TestAutomaticAnswerProcessChain keeps the shell, Go tools, wizard input, and
+// runner delegation real. Overlays replace account setup and the provider work.
+func TestAutomaticAnswerProcessChain(t *testing.T) {
+ root, err := filepath.Abs("../..")
+ if err != nil {
+ t.Fatal(err)
+ }
+ scratch := t.TempDir()
+ replacements := map[string]string{}
+ for target, fixture := range map[string]string{
+ "cmd/equipo-try/main.go": "main.go.txt",
+ "internal/tryequipo/tty_fixture.go": "wizard.go.txt",
+ "internal/runner/provider/live_test.go": "live_test.go.txt",
+ "internal/directlive/tty_fixture.go": "answer.go.txt",
+ } {
+ replacements[filepath.Join(root, target)] = filepath.Join(root, "internal/tryequipo/testdata/tty-chain", fixture)
+ }
+ overlay := filepath.Join(scratch, "overlay.json")
+ runner := filepath.Join(scratch, "runner")
+ ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
+ defer cancel()
+ main := filepath.Join(root, "cmd/equipo-try/main.go")
+ replacements[main] = filepath.Join(root, "internal/tryequipo/testdata/tty-chain/runner.go.txt")
+ raw, err := json.Marshal(map[string]any{"Replace": replacements})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = os.WriteFile(overlay, raw, 0600); err != nil {
+ t.Fatal(err)
+ }
+ cmd := exec.CommandContext(ctx, "go", "build", "-overlay", overlay, "-o", runner, "./cmd/equipo-try")
+ cmd.Dir = root
+ cmd.Env = append(os.Environ(), "CGO_ENABLED=0", "TMPDIR="+scratch)
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("fixture build: %s %v", out, err)
+ }
+ replacements[main] = filepath.Join(root, "internal/tryequipo/testdata/tty-chain/main.go.txt")
+ raw, err = json.Marshal(map[string]any{"Replace": replacements})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = os.WriteFile(overlay, raw, 0600); err != nil {
+ t.Fatal(err)
+ }
+ cmd = exec.CommandContext(ctx, "python3", "testdata/tty-chain/drive.py", root)
+ cmd.Env = append(os.Environ(), "CGO_ENABLED=0", "TMPDIR="+scratch, "GOFLAGS=-overlay="+overlay, "EQUIPO_TTY_FIXTURE_RUNNER="+runner, "EQUIPO_TTY_FIXTURE_EVIDENCE="+scratch)
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("terminal process chain: %v\n%s", err, out)
+ } else {
+ t.Logf("%s", out)
+ }
+ for i, name := range []string{"allow", "deny", "question"} {
+ raw, err := os.ReadFile(filepath.Join(scratch, fmt.Sprintf("answer-%d-%s.json", i+1, name)))
+ var answer struct {
+ AnsweredBy string `json:"answered_by"`
+ Answer struct {
+ Behavior string `json:"behavior"`
+ } `json:"answer"`
+ }
+ if err != nil || json.Unmarshal(raw, &answer) != nil || answer.AnsweredBy != "automatic" {
+ t.Fatalf("missing automatic answer: %s %v", raw, err)
+ }
+ want := name
+ if name == "question" {
+ want = "allow"
+ }
+ if answer.Answer.Behavior != want {
+ t.Fatalf("answer=%s, want %s", raw, want)
+ }
+ }
+ for i, name := range []string{"invalid", "timeout"} {
+ if _, err := os.Stat(filepath.Join(scratch, fmt.Sprintf("answer-%d-%s.json", i+4, name))); !os.IsNotExist(err) {
+ t.Fatalf("invalid answer artifact: %v", err)
+ }
+ }
+}
diff --git a/scripts/runner-release-check.py b/scripts/runner-release-check.py
index 3e695ffc..d3ffd673 100644
--- a/scripts/runner-release-check.py
+++ b/scripts/runner-release-check.py
@@ -40,42 +40,6 @@ def observation(base, value, status):
require(digest(local_file(base, value["artifact"])) == value["sha256"])
-def person_controls(base, record):
- require(record["specialist"] != "Coordinator")
- require(record["checks"].get("tuple-completed", {}).get("status") != "not-certified")
- for name in ("person-answered-controls", "workspace-positive-control", "person-native-approval", "real-question-answer", "policy-escalation-denied", "equipo-broker-approval", "stale-broker-denied", "invalid-broker-denied"):
- observation(base, record["checks"][name], "pass")
- check = json.loads(local_file(base, record["checks"][name]["artifact"]).read_text())
- require(check["answered_by"] == "person")
- proof = json.loads(local_file(base, record["checks"]["person-answered-controls"]["artifact"]).read_text())
- require(proof["answered_by"] == "person" and set(proof["answers"]) in ({"allow", "deny", "question"}, {"workspace", "allow", "deny", "question"}))
- seen = set()
- for control, answers in proof["answers"].items():
- require(answers or control == "workspace")
- for ref in answers:
- observation(base, ref, "pass")
- require(ref["artifact"] not in seen)
- seen.add(ref["artifact"])
- answer = json.loads(local_file(base, ref["artifact"]).read_text())
- require(answer["answered_by"] == "person" and answer["control"] == control)
- require(answer["answer"]["behavior"] == ("deny" if control == "deny" else "allow"))
- if control == "question":
- require(answer["answer"]["updated_input"]["answers"]["answer"])
-
-
-def provider_checks(manifest):
- families = {p["provider"] for p in manifest["direct_policies"]}
- require(set(manifest["provider_checks"]) == families)
- for family in families:
- ref = manifest["provider_checks"][family]["person-answered-controls"]
- require(ref["provider"] == family and ref in manifest["certifications"])
- path = local_file(root, ref["path"])
- require(digest(path) == ref["sha256"])
- record = json.loads(path.read_text())
- require(record["provider"] == family and record["policy_hash"] == ref["policy_hash"])
- person_controls(path.parent, record)
-
-
def native_refusal(frames, tool, path):
calls, valid = {}, True
for frame in frames:
@@ -282,7 +246,6 @@ try:
require(pin and installed[name] == pin[1])
require(len(manifest["certifications"]) == len(manifest["direct_policies"]))
require(len(manifest["verified_isolation_tuples"]) == len(manifest["direct_policies"]))
- provider_checks(manifest)
seen = set()
for certificate in manifest["direct_policies"]:
require(certificate["provider_version"] == manifest[certificate["provider"]])