oficina / equipo Public

Merge branch 'fewer-prompts' into main

live gate: person answers controls once per provider; typos re-prompt

Later tuples answer controls automatically through the same relay; each
provider needs a person-answered tuple to certify. Read-only roles get an
automatic deny for workspace writes during routing; ask_person goes first.
claude agent, operated by paul@keymail.dev a2774dc8bee9537895150fd2da219fe4bcb98466 parent 35e2cabparent 80bad79
38 files changed, +1,273 −54
  • docs/live-gate.md +1 −1
  • docs/superpowers/plans/CODEX-BRIEF-fewer-prompts-2.md +30 −0
  • docs/superpowers/plans/CODEX-BRIEF-fewer-prompts.md +41 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-fewer-prompts.md +255 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +2 −1
  • internal/directlive/answer_source.go +76 −0
  • internal/directlive/answer_source_test.go +79 −0
  • internal/directlive/approval_controls_test.go +6 −1
  • internal/directlive/certificate.go +18 −2
  • internal/directlive/certification_gaps_test.go +2 −2
  • internal/directlive/controls.go +5 −2
  • internal/directlive/coordinator_certificate_test.go +104 −1
  • internal/directlive/driver.go +6 −1
  • internal/directlive/driver_test.go +17 −1
  • internal/directlive/fewer_prompts_test.go +92 −0
  • internal/directlive/inventory.go +3 −3
  • internal/directlive/person_controls.go +12 −0
  • internal/directlive/probe_answers.go +7 −2
  • internal/directlive/probes.go +2 −2
  • internal/directlive/routing_approval_test.go +55 −0
  • internal/directlive/routing_codex.go +2 −2
  • internal/directlive/routing_order.go +25 −0
  • internal/directlive/routing_order_test.go +19 −0
  • internal/directlive/terminal.go +6 −0
  • internal/directlive/terminal_retry_test.go +76 −0
  • internal/directlive/tool_routing.go +12 −3
  • internal/directlive/tool_routing_test.go +18 −0
  • internal/directlive/turn.go +44 −4
  • internal/equipo/copy.go +2 −2
  • internal/equipotest/runner_release_test.go +3 −3
  • internal/plan3test/plan3_release_test.go +2 −1
  • internal/release/manifest.go +17 −16
  • internal/runner/provider/direct_certification.go +12 −1
  • internal/runner/provider/isolation_boundary_test.go +16 −0
  • internal/runner/provider/person_controls.go +92 −0
  • internal/runner/provider/providertest/isolation_test.go +5 −0
  • internal/runner/provider/providertest/person_controls.go +68 −0
  • scripts/runner-release-check.py +41 −3

CI passed — run details

landed from fewer-prompts

diff --git a/docs/live-gate.md b/docs/live-gate.md
index 4e55e343..913941bd 100644
--- a/docs/live-gate.md
+++ b/docs/live-gate.md
@@ -66,7 +66,7 @@ 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 and expire after 60 seconds.
+arrive through the terminal for only the first specialist tuple of each provider, expire after 60 seconds, and are answered automatically for later tuples.
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-fewer-prompts-2.md b/docs/superpowers/plans/CODEX-BRIEF-fewer-prompts-2.md
new file mode 100644
index 00000000..6e99c5c1
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-BRIEF-fewer-prompts-2.md
@@ -0,0 +1,30 @@
+# Brief: fewer prompts round 2 — read-only Codex routing hang
+
+Same branch at a5f18b8 (CI green). Paul's run-1968907576 (evidence
+read-only under ~/.local/share/equipo/try/run-1968907576/) ran on main
+35e2cab: Paul stopped answering prompts, so control timeouts are
+expected. Unexpected: codex-Review, -Scope, -Research, -Investigation
+(read-only roles) failed `tool-routing: context deadline exceeded`;
+turn-5 completed, no turn-6 artifact. Likely a beyond-profile approval
+(e.g. apply_patch or a write in a read-only role) or another request
+reached the terminal/person during routing instead of the automatic
+routing answer, or the routing prompt for a read-only role waits on a
+tool it cannot use. Find the exact cause from the evidence first.
+
+AUTHORISATION: as before (paul@tito.io Codex only, sequential, no full
+gate, no bundle, no credential contents, no sign-ins). Budget 10 model
+turns. Prove live, on this branch, that codex-Review completes
+catalog + tool-routing with no person prompt, and that a read-only role's
+routing rows have the right expected outcome per tool (a write tool in
+a read-only role is a policy refusal, not a pass and not a hang).
+Also check claude-Review (read-only Claude) offline/replay for the same
+class of issue; a live Claude check is allowed within the same budget if
+needed. Then also change the `live.answer-retry` marker in
+internal/equipo/copy.go to `// COPY ACCEPTED FOR NOW (Paul, 2026-11-05;
+iterate in context)` and the same for CopyCalibrationFunding if still
+pending (Paul's ruling covers guide copy), updating inventories.
+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-fewer-prompts.md with the launch log.
+Scratch removed; nothing running; no copy-review server. Print a
+five-line summary.
diff --git a/docs/superpowers/plans/CODEX-BRIEF-fewer-prompts.md b/docs/superpowers/plans/CODEX-BRIEF-fewer-prompts.md
new file mode 100644
index 00000000..77e4fa62
--- /dev/null
+++ b/docs/superpowers/plans/CODEX-BRIEF-fewer-prompts.md
@@ -0,0 +1,41 @@
+# Brief: ask Paul 6 times, not ~70
+
+Branch `fewer-prompts` from main 35e2cab. Paul's final run (run-1968907576)
+asks a person ~4 times per specialist tuple (probes.go:162 control turn +
+controls.go:60 allow/deny/question), ~70 prompts at 60 s each; a typo
+("Alloe once") is read as a JSON answer and fails the control. Paul ruled
+(2026-11-05): he should not have to babysit this.
+
+Controller decisions:
+- P1 A real person answers the control prompts (allow, deny, question,
+ and the probes.go:162 allow) only for the FIRST specialist tuple of
+ each provider in run order (one Claude, one Codex): 4 prompts each at
+ most, so ~8 total. For every other tuple the guide answers those
+ prompts itself, through the SAME terminalAnswer path semantics (same
+ validation, same relay, same timing rules) but without reading the
+ tty: it supplies the exact expected answer and records
+ `answered_by: "automatic"` vs `"person"` in the answer artifact and
+ the check evidence. Prefer one injection point (an answer source
+ interface) over branching inside the relay.
+- P2 Certification: `person-native-approval`, `real-question-answer` and
+ the other control checks pass for a tuple when the relay behaved
+ correctly with its answer source; additionally require, per provider,
+ at least one tuple whose control answers were `person` and passed
+ (record as a provider-level check, e.g. `person-answered-controls`, in
+ the manifest candidate and release checker). A missing person proof
+ for a provider fails certification.
+- P3 Typos: if the typed line is not `Allow once`, `Deny`, or a JSON
+ object that parses, print a one-line hint and read again within the
+ same 60 s (do not fail the control on a typo). A JSON object that
+ parses but fails ValidateAnswer is still a real answer and is
+ validated as today.
+- P4 Remove the stray-input race: keep TCIFLUSH before each prompt.
+- P5 Docs: docs/live-gate.md one sentence (copy accepted for now; plain).
+- P6 Targeted tests (pty for P3; driver test for P1/P2 including a run
+ with no person-answered tuple failing), ONE full `make -k ci` (rerun at
+ most twice). Commit subject < 80, body
+ `Co-Authored-By: Astra <noreply@openai.com>`, push. Report in
+ CONTROLLER-REPORT-fewer-prompts.md. OFFLINE ONLY: no live launches
+ (Paul may be running the gate); no reading account homes. Scratch
+ removed; nothing running; no copy-review server. Print a five-line
+ summary.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-fewer-prompts.md b/docs/superpowers/plans/CONTROLLER-REPORT-fewer-prompts.md
new file mode 100644
index 00000000..49c6fb3f
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-fewer-prompts.md
@@ -0,0 +1,255 @@
+# Fewer prompts, 2026-11-05
+
+The first specialist tuple in run order uses a person for its controls, once
+per provider. Later tuples supply the expected answers automatically. Both
+sources use the same validation, 60-second answer deadline and production
+relay. The native approval receipt records the selected source too.
+
+Answer artifacts and control checks record `answered_by: "person"` or
+`"automatic"`. MCP questions inherit the active turn's control expectation
+and deadline; their proxy context previously lacked that information.
+Control checks count answers from their own control turns, so unrelated probe
+answers cannot satisfy them.
+
+Each manifest candidate needs `provider_checks.<provider>.person-answered-controls`
+for every provider it certifies. The reference identifies a certified tuple.
+The candidate builder and release checker verify that tuple's passing control
+checks, source attribution and hashed answer artifacts. Allow, deny and question
+answers are required. Workspace approval answers are verified when the provider
+requests approval; a workspace read that needs no approval still has to pass.
+Coordinator evidence cannot satisfy this requirement.
+
+The terminal retries misspellings, malformed JSON and JSON values that are not
+objects. It clears the previous line without extending the deadline. A parsed
+object still goes straight to `ValidateAnswer`, so an invalid structured answer
+fails normally. `TCIFLUSH` remains before each prompt.
+
+`docs/live-gate.md` changes one sentence under the brief's copy acceptance.
+The new `live.answer-retry` hint in `internal/equipo/copy.go` is individually
+marked `COPY REVIEW PENDING`: “Enter Allow once, Deny, or a valid JSON object.”
+The same hint is listed as pending in the existing Plan 3 copy inventory.
+No copy-review server was started. README prose is unchanged.
+
+## Verification
+
+Before implementation, these commands failed for the reported defects:
+
+- `CGO_ENABLED=0 go test ./internal/directlive -run '^TestControlTerminalRetriesTypos$' -count=1`: all three line endings failed on `Alloe once` with `runner.invalid`.
+- `CGO_ENABLED=0 go test ./internal/directlive -run '^TestCandidateRequiresPersonControls$' -count=1`: a candidate with no person-answered tuple was accepted.
+
+After implementation:
+
+- `CGO_ENABLED=0 go test ./internal/directlive -run '^Test(Candidate|CoordinatorManifest|ControlSources|AnswerSources|ControlTerminal|TerminalRetry)' -count=1`: passed. Covers run-order selection, validation, deadlines, false person proofs, typo retries, CR/LF/CRLF, valid but invalid answer objects, and queued-input flushing.
+- `CGO_ENABLED=0 go test ./internal/directlive -run '^TestFewerPromptsFakeCLI$' -count=1`: passed in 79.482 seconds. Both providers run Review first and Engineering second. The first tuples use a person; later tuples answer automatically through the production relay. Every control check passes and all answer artifacts have attribution. The fixture's workspace reads need no approval, giving six person answers total. The source-selection test also exercises workspace approval and counts eight answers. Removing one provider's proof, then both proofs, fails the same provider gate used by the candidate builder.
+- `CGO_ENABLED=0 go test ./internal/equipotest -run '^TestDirectReleaseRequiresCertification$' -count=1`: passed for both release targets. Missing person proof, automatic proof, missing provider checks, another provider's reference and changed answer artifacts all fail before a build.
+
+An early version of the driver test attempted to certify the fake CLI's entire
+bundle. It correctly failed because the fake Codex has no provider sandbox.
+The test now verifies its real control observations through the provider gate;
+separate synthetic candidate fixtures test complete manifest construction.
+No fake CLI bundle is represented as production certification.
+
+Each guard below was disabled separately. Every listed test failed for the
+protected behavior, with no compilation failures. The original source was
+restored after each test. Commands use `CGO_ENABLED=0 go test <package> -run
+'<pattern>' -count=1`.
+
+| Guard disabled | Package | Pattern | Observed failure |
+| --- | --- | --- | --- |
+| First tuple only | `./internal/directlive` | `^TestControlSourcesFollowRunOrder$` | Later Codex tuple selected a person |
+| Candidate provider requirement | `./internal/directlive` | `^TestCandidateRequiresPersonControls$` | Candidate accepted without person proof |
+| Individual answer attribution | `./internal/directlive` | `^TestCandidateRejectsFalsePersonProof$/automatic-answer$` | Automatic answer accepted as person proof |
+| Release provider requirement | `./internal/equipotest` | `^TestDirectReleaseRequiresCertification$/release$/no_person_controls$` | Synthetic release reached its fake build without person proof |
+| Typo recognition | `./internal/directlive` | `^TestControlTerminalRetriesTypos$` | Misspelling ended each control |
+| Parsed-object validation | `./internal/directlive` | `^TestTerminalRetryDeadlineAndValidObject$/object$` | `{}` was accepted |
+| Deadline enforcement | `./internal/directlive` | `^TestTerminalRetryDeadlineAndValidObject$/deadline$` | Typo loop outlived its deadline |
+| Input flushing | `./internal/directlive` | `^TestControlTerminalFlushPending$` | Queued `Deny` answered the next allow prompt |
+
+The restored targeted commands passed again before the full gate.
+
+The first `make -k ci` completed with failures in size budgets and the Plan 3
+copy inventory. All other lanes passed. The app was one source line over its
+limit; the release tests were 26 test lines over. The inventory was missing the
+new hint. The fixture setup now lives with the existing provider test helpers,
+spare blank lines were removed, and the hint has its required inventory row.
+All existing budget limits remain unchanged. `make budget` and the targeted
+release, candidate and `TestPlan3ReleaseBoundaries` tests passed after repair.
+The new fake-driver test joins the existing parallel queue and three-worker
+limit, so it does not hold up unrelated fake-driver scenarios.
+
+The single full rerun, `make -k ci`, exited 0. It passed build, vet,
+formatting, staticcheck, govulncheck, gitleaks, size budgets, all 29 tested
+packages, adapter checks, namespace checks, migrations and performance.
+The test step took 5m31.608s; directlive took 4m11.981s, within its 360s budget.
+Cold boot measured 102ms against 500ms. There were no vulnerability findings
+in called code and no secret findings.
+
+Provider timing warnings were nonfatal locally: provider 20.656s against 15s,
+Claude 45.989s against 45s, and Codex 38.361s against 35s. CI mode enforces those
+timing limits, so equivalent load on the remote runner could still fail them.
+No timing allowance was raised. Total full gate runs: two, including one rerun.
+
+## Delivery
+
+OFFLINE ONLY: zero live provider launches and no account-home reads. Tests used
+disposable fake accounts and executables. No default-branch push, merge,
+deployment or execution enablement was attempted. Go caches stayed at their
+default locations.
+
+Delivery branch: `fewer-prompts`. Commit subject:
+`Reduce live control prompts to the first tuple per provider`.
+Commit body: `Co-Authored-By: Astra <noreply@openai.com>`.
+The verification scratch was removed. No process started for this task remains
+running. The branch is for controller review; deployment remains a human action.
+
+## Round 2
+
+The read-only Codex hang was a file-change approval waiting for a person.
+In Paul's read-only `run-1968907576` evidence, each of codex-Review,
+codex-Scope, codex-Research and codex-Investigation ends its routing turn at
+`item/fileChange/requestApproval`. The preceding item is an `apply_patch`
+update of `/workspace/equipo-routing-0`. Review's request identifies
+`call_dfbf641058eb4c7299ae257daac18f05`. Turn 5 completed; turn 6 never
+produced a completed artifact. The configured workspace was read-only.
+The routing answer handler handled questions automatically but fell through
+to the terminal for native approvals. This is separate from the expected
+unanswered person-control timeouts.
+
+Automatic probe expectations now select the automatic answer source for native
+approvals too. Read-only file changes receive `deny` through the existing
+validation and relay. Ordinary person controls retain their selected source.
+Answer-source attribution also inherits the active turn for proxy callbacks.
+No provider policy, sandbox or production authority check was relaxed.
+
+Routing completion, Go certification and the Python release checker now require
+`denied` for a read-only specialist's workspace write tool. Permitted workspace
+tools still require `pass`. A model decline without a write attempt does not
+prove the workspace refusal. Codex patch refusals require the matching call ID,
+path, update kind and completed file-change item with status `declined`.
+Uncorrelated results and successful writes cannot satisfy that row.
+
+Claude Review exposed a second defect. Its catalog lists `submit_review` before
+`ask_person`. The review submission occupies the broker's pending slot, so the
+following question is rejected before the answer callback. Saved evidence and
+the first focused Claude run both show that rejection. Claude Review exposes
+Read, Glob, Grep, Bash and its two Equipo tools; Write and Edit are absent.
+The routing prompt now puts `ask_person` first and requests sequential calls.
+The existing callback acknowledges the answered question before the submission.
+The other tools retain their order, including candidate before render.
+
+### Live launch log
+
+All times below are UTC on 2026-11-05. Launches were sequential and used only
+Paul's `paul@tito.io` bindings: Codex `codex` and Claude `claude-a`. Total model
+turns: **9 of 10 authorized**. Each launch used one catalog turn followed by
+workspace and outside routing turns.
+
+| UTC interval | Tuple | Turns | Result |
+| --- | --- | ---: | --- |
+| 16:51:01–16:52:03 | codex-Review | 3 | Catalog and routing passed; no person prompt |
+| 16:53:00–16:53:37 | claude-Review | 3 | Reproduced question rejection after review submission |
+| 16:55:31–16:56:15 | claude-Review | 3 | Final ordering passed every routing row; no person prompt |
+
+Codex discovered nine tools. Workspace outcomes were `denied` for apply_patch
+and `pass` for exec_command, list_mcp_resource_templates, list_mcp_resources,
+ask_person, submit_review, read_mcp_resource, view_image and write_stdin.
+All outside rows were `declined`, which is the existing accepted outside
+outcome. The write refusal passed through the production relay automatically. Its two
+answer artifacts record automatic denial of the patch and automatic allowance
+of the question. The final Claude question artifact also records automatic
+allowance.
+
+Final Claude outcomes were `pass` for all six exposed workspace tools and
+`denied` for all six outside rows. Its first focused run also left the outside
+Bash row uncertified because the debug harness had omitted the outer-isolation
+proof. The final harness ran the production direct isolation probe before
+routing. No parser allowance was added for that harness omission.
+
+The temporary harness used this branch's production leases, policy builder,
+launchers, journal, broker, answer relay and routing code. A Go overlay stopped
+the normal exercise after the focused phases. The answer callback failed on
+any person prompt. Disposable observations were debugging scratch: no full live
+gate, certification bundle, manifest candidate, generation or account-change
+exercise ran. The harness did not inspect credential contents, sign in, or
+change saved setup, bindings or Paul's evidence. Production leases staged the
+authorized credentials. The final Claude run included the attribution fix;
+Codex's successful run preceded that fix and the question-order change.
+
+### Tests and guard checks
+
+Before implementation:
+
+- `CGO_ENABLED=0 go test ./internal/directlive -run '^TestRoutingApprovalsNeverAskPerson$' -count=1` failed because native routing approvals called the person. Its later callback-attribution assertion also failed before that fix.
+- `CGO_ENABLED=0 go test ./internal/runner/provider -run '^TestRoutingReadOnlyWriteRefusal$' -count=1` rejected Review's expected refusal.
+- `CGO_ENABLED=0 go test ./internal/directlive -run '^TestRoutingQuestionPrecedesSubmission$' -count=1` failed with the question after the review submission.
+
+The restored targeted tests passed:
+
+```sh
+CGO_ENABLED=0 go test ./internal/directlive ./internal/runner/provider ./internal/runner/provider/providertest ./internal/equipotest -run 'TestRouting|TestReadOnlyPatch|TestToolRouting|TestCodexRouting|TestReleaseIsolation|TestControlSources|TestAnswerSources|TestPlan3ReleaseBoundaries|TestDirectReleaseRequiresCertification' -count=1
+CGO_ENABLED=0 go test ./internal/directlive -run '^TestDirectDriverFakeCLI/Review$' -count=1
+```
+
+The fake-driver Review test passed in 31.719s and exercised both providers.
+A temporary `TestRound2ClaudeReplay` read all 12 saved Claude routing artifacts.
+It confirmed five workspace passes, the rejected workspace question, four
+outside filesystem refusals and two outside MCP declines. The initial replay
+assertion expecting all workspace tools to pass failed on ask_person; the
+replay then checked that observed failure explicitly. No old evidence was
+changed or promoted to a passing certificate.
+
+Each guard below was disabled separately and restored. Every test failed for
+the intended behavior, without a compilation failure. Go mutations used
+`CGO_ENABLED=0 go test -overlay <overlay> <package> -run '<pattern>' -count=1`.
+The Python mutation was restored in a `finally` block and tested through Go.
+
+| Guard disabled | Package | Test | Observed failure |
+| --- | --- | --- | --- |
+| Automatic probe source | `./internal/directlive` | TestRoutingApprovalsNeverAskPerson | Person callback called |
+| Read-only write denial | `./internal/directlive` | TestRoutingApprovalsNeverAskPerson | Write or Edit allowed |
+| Active-turn attribution | `./internal/directlive` | TestRoutingApprovalsNeverAskPerson | Proxy callback attributed to a person |
+| Role-specific completion | `./internal/directlive` | TestRoutingCompletionUsesRole | Review's successful patch accepted |
+| Role-specific Go certification | `./internal/runner/provider` | TestRoutingReadOnlyWriteRefusal | Expected refusal rejected |
+| Patch result correlation | `./internal/directlive` | TestReadOnlyPatchRoutingRequiresCorrelatedRefusal | Wrong call ID accepted |
+| Question before submission | `./internal/directlive` | TestRoutingQuestionPrecedesSubmission | Submission retained the first broker slot |
+| Role-specific release certification | `./internal/runner/provider/providertest` | TestReleaseIsolationGuards | Expected refusal rejected |
+
+### Copy and delivery
+
+Both `live.answer-retry` and `CopyCalibrationFunding` now have the exact marker
+`// COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context)`.
+Their current Plan 3 inventory rows record the same acceptance. This supersedes
+the pending status described in the earlier report. Runtime wording is unchanged.
+No copy-review server was started and README prose was left unchanged.
+
+The first full `make -k ci` completed with two test failures. The Plan 3 inventory
+validator did not recognize the new acceptance date for these two entries; its
+exception now names exactly those entries and Paul's exact marker. The other
+failure was `TestReviewExpiredAccountSignsIn/claude`, which returned
+`provider_account_busy`. It passed on an isolated rerun without account-code
+changes. All other lanes passed. The test step took 5m25.533s, directlive took
+4m9.612s and cold boot measured 105ms against 500ms.
+
+The repaired inventory gate passed with
+`CGO_ENABLED=0 go test ./internal/plan3test -run '^TestPlan3ReleaseBoundaries$' -count=1`.
+The account retry used
+`CGO_ENABLED=0 go test ./internal/tryequipo -run '^TestReviewExpiredAccountSignsIn$' -count=1`.
+
+The single full rerun, `make -k ci`, exited 0. All 29 tested packages and every
+other lane passed, including adapter checks, namespace checks, migrations and
+performance. The test step took 5m26.229s; directlive took 4m13.755s against its
+360s limit. Cold boot measured 100ms against 500ms. There were no called-code
+vulnerability findings or secret findings. Total full gate runs for Round 2:
+two, including one rerun.
+
+Provider timing warnings remain nonfatal locally: provider 20.509s against
+15s, Claude 45.710s against 45s, and Codex 38.199s against 35s. CI mode enforces
+those limits, so equivalent load on a remote runner could fail them. No timing
+allowance was raised.
+
+Delivery branch: `fewer-prompts`. Commit subject:
+`Fix read-only routing approvals and question ordering` (53 characters).
+Commit body: `Co-Authored-By: Astra <noreply@openai.com>`.
+The temporary harness, observations, binaries, overlays and logs were removed.
+No task process or server remains running. Go caches stayed at their defaults.
+No default-branch push, merge, release or deployment was performed.
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index f2e6fabf..5846b20a 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5157,8 +5157,9 @@ records to satisfy a gate. Release remains blocked while any row is pending.
| `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 REVIEW REQUIRED |
+| `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) |
## Task 21
diff --git a/internal/directlive/answer_source.go b/internal/directlive/answer_source.go
new file mode 100644
index 00000000..b6aed98a
--- /dev/null
+++ b/internal/directlive/answer_source.go
@@ -0,0 +1,76 @@
+package directlive
+
+import (
+ "context"
+ "encoding/json"
+ "time"
+
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+type answerSource struct {
+ answeredBy string
+ read answerFunc
+}
+
+func (s answerSource) answer(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
+ ctx, cancel := context.WithTimeout(ctx, 60*time.Second)
+ defer cancel()
+ if err := ctx.Err(); err != nil {
+ return runnerproto.QuestionAnswer{}, err
+ }
+ a, err := s.read(ctx, q)
+ if err == nil {
+ err = ctx.Err()
+ }
+ if err == nil {
+ err = q.ValidateAnswer(a)
+ }
+ 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}
+ }
+ return answerSource{"automatic", expectedAnswer}
+}
+
+func expectedAnswer(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
+ expectation, _ := ctx.Value(probeExpectationKey{}).(probeExpectation)
+ a := runnerproto.QuestionAnswer{Behavior: expectation.behavior}
+ if expectation.behavior == "question" {
+ a.Behavior = "allow"
+ a.UpdatedInput = marshal(map[string]any{"answers": map[string]string{"answer": "ordinary"}})
+ }
+ return a, nil
+}
+
+func (x *exercise) source(ctx context.Context) answerSource {
+ expectation, _ := ctx.Value(probeExpectationKey{}).(probeExpectation)
+ x.mu.Lock()
+ if expectation.control == "" && !expectation.automatic && x.answerContext != nil {
+ expectation, _ = x.answerContext.Value(probeExpectationKey{}).(probeExpectation)
+ }
+ x.mu.Unlock()
+ if expectation.automatic {
+ return answerSource{"automatic", func(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
+ var request struct{ Name string }
+ if json.Unmarshal(q.RawRequest, &request) != nil {
+ return runnerproto.QuestionAnswer{}, runnerproto.ErrInvalid
+ }
+ if x.launch.Policy.ReadOnlyWorkspace() && (request.Name == "Write" || request.Name == "Edit" || request.Name == "item/fileChange/requestApproval" || request.Name == "applyPatchApproval") {
+ return runnerproto.QuestionAnswer{Behavior: "deny"}, nil
+ }
+ return expectedAnswer(context.WithValue(ctx, probeExpectationKey{}, expectation), q)
+ }}
+ }
+ if expectation.control != "" && x.controlSource.read != nil {
+ return x.controlSource
+ }
+ return answerSource{"person", x.d.answer}
+}
diff --git a/internal/directlive/answer_source_test.go b/internal/directlive/answer_source_test.go
new file mode 100644
index 00000000..c5c78179
--- /dev/null
+++ b/internal/directlive/answer_source_test.go
@@ -0,0 +1,79 @@
+package directlive
+
+import (
+ "context"
+ "errors"
+ "testing"
+ "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"} {
+ 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)
+ 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)
+ }
+ }
+ }
+ }
+ 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")
+ }
+ 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
index cfcb8f1a..64487154 100644
--- a/internal/directlive/approval_controls_test.go
+++ b/internal/directlive/approval_controls_test.go
@@ -61,7 +61,7 @@ try:
while b'\n' in pending:
line,pending=pending.split(b'\n',1)
if line.startswith(b'Type Allow once, Deny,'):
- os.write(fd,answers[sent]+ending+(b'Allow once\n' if os.environ.get('EQUIPO_TEST_STALE_INPUT')=='1' else b''));sent+=1
+ 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))
@@ -94,3 +94,8 @@ 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/certificate.go b/internal/directlive/certificate.go
index 3986f1f9..8ccd6ad9 100644
--- a/internal/directlive/certificate.go
+++ b/internal/directlive/certificate.go
@@ -20,6 +20,7 @@ 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
@@ -58,6 +59,9 @@ 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
@@ -67,8 +71,8 @@ func ManifestCandidate(root string) error {
}
binaries = e.Binaries
}
- if len(m.DirectPolicies) == 0 {
- return errEvidence
+ if err := requireProviderControls(m); err != nil {
+ return err
}
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]
@@ -76,3 +80,15 @@ 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/certification_gaps_test.go b/internal/directlive/certification_gaps_test.go
index 80943f62..7a8a43dd 100644
--- a/internal/directlive/certification_gaps_test.go
+++ b/internal/directlive/certification_gaps_test.go
@@ -131,14 +131,14 @@ func TestFinalCurrencyIncludesLateFrames(t *testing.T) {
}
func TestRoutingControls(t *testing.T) {
- if routingComplete(nil) {
+ if routingComplete(nil, "Engineering") {
t.Fatal("empty inventory certified")
}
for _, workspace := range []string{"pass", "declined", "not-exercisable", "not-certified", ""} {
for _, outside := range []string{"denied", "declined", "pass", "not-certified", ""} {
tools := []provider.LiveTool{{Name: "Read", Exposed: true, Routing: map[string]provider.LiveObservation{"workspace": {Status: workspace}, "outside": {Status: outside}}}}
want := workspace == "pass" && (outside == "denied" || outside == "declined")
- if routingComplete(tools) != want {
+ if routingComplete(tools, "Engineering") != want {
t.Fatalf("workspace=%s outside=%s", workspace, outside)
}
}
diff --git a/internal/directlive/controls.go b/internal/directlive/controls.go
index cd6dd9ae..3ef752d6 100644
--- a/internal/directlive/controls.go
+++ b/internal/directlive/controls.go
@@ -62,13 +62,16 @@ func (x *exercise) controls(ctx context.Context) error {
}
}
x.mu.Lock()
- checks := map[string]bool{"person-native-approval": x.answers["allow"] > 0 && x.answers["deny"] > 0, "real-question-answer": x.questions > 0, "policy-escalation-denied": x.escalationDenied, "equipo-broker-approval": x.brokerApprovals > 0, "stale-broker-denied": x.staleDenied, "invalid-broker-denied": x.invalidDenied}
+ checks := map[string]bool{"person-native-approval": x.controlPassed["allow"] && x.controlPassed["deny"], "real-question-answer": x.controlPassed["question"], "policy-escalation-denied": x.escalationDenied, "equipo-broker-approval": x.brokerApprovals > 0, "stale-broker-denied": x.staleDenied, "invalid-broker-denied": x.invalidDenied}
x.mu.Unlock()
for name, ok := range checks {
- if err := x.check(name, ok, map[string]any{"answers": x.answers, "questions": x.questions, "broker_approvals": x.brokerApprovals, "stale_denied": x.staleDenied, "invalid_denied": x.invalidDenied}); err != nil {
+ if err := x.check(name, ok, map[string]any{"answered_by": x.controlSource.answeredBy, "answers": x.answers, "questions": x.questions, "broker_approvals": x.brokerApprovals, "stale_denied": x.staleDenied, "invalid_denied": x.invalidDenied}); err != nil {
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 11a1b44c..18fd1270 100644
--- a/internal/directlive/coordinator_certificate_test.go
+++ b/internal/directlive/coordinator_certificate_test.go
@@ -14,7 +14,7 @@ import (
"amadan.net/oficina/equipo/internal/runner/provider/providertest"
)
-func TestCoordinatorManifestExclusion(t *testing.T) {
+func candidateFixture(t *testing.T) string {
root := t.TempDir()
raw := []byte("synthetic manifest-selection fixture")
hash := provider.DigestDirectEvidence(raw)
@@ -65,6 +65,12 @@ func TestCoordinatorManifestExclusion(t *testing.T) {
if err := save(root, "index.json", []string{"specialist/certification.json", "coordinator/certification.json"}); err != nil {
t.Fatal(err)
}
+ return root
+}
+
+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)
}
@@ -103,3 +109,100 @@ func TestMergedPlanPolicyInventory(t *testing.T) {
}
}
}
+
+func TestCandidateRequiresPersonControls(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)
+ }
+}
+
+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))
+ 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))
+ }
+ if err = os.WriteFile(filepath.Join(dir, o.Artifact), raw, 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
+ }
+ }
+ 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 6c3a63a5..0c32a117 100644
--- a/internal/directlive/driver.go
+++ b/internal/directlive/driver.go
@@ -27,6 +27,7 @@ func EnvironmentPaths(getenv func(string) string) Paths {
}
type driver struct {
+ personControls map[string]bool
currencyCap bool
invalidFrame bool
stagedMarker string
@@ -185,6 +186,10 @@ func (p Paths) verify() (map[string]string, error) {
func marshal(v any) []byte { raw, _ := json.Marshal(v); return raw }
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
@@ -217,7 +222,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{}}
+ x := &exercise{d: d, root: root, evidence: e, answers: map[string]int{}, controlSource: d.controlSource(b.Binding.Provider, role)}
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 8625aba8..43d5e6ad 100644
--- a/internal/directlive/driver_test.go
+++ b/internal/directlive/driver_test.go
@@ -32,6 +32,11 @@ func TestDirectDriverFakeCLI(t *testing.T) {
})
}
}
+func TestFewerPromptsFakeCLI(t *testing.T) {
+ t.Parallel()
+ runFakeDriver(t, false, "EQUIPO_FAKE_FEWER_PROMPTS=1")
+}
+
func runFakeDriver(t *testing.T, badCoordinator bool, env ...string) {
t.Helper()
defer fakeDriverWorkers.acquire()()
@@ -125,7 +130,12 @@ 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")}
- answer := func(_ context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
+ 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
}
@@ -185,6 +195,9 @@ 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" {
+ roles = []string{"Review", "Engineering"}
+ }
source := "fake-cli"
if os.Getenv("EQUIPO_FAKE_LIVE_MODE") == "1" {
source = "direct-live"
@@ -206,6 +219,9 @@ 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)
+ }
for path, before := range original {
raw, err := os.ReadFile(path)
if err != nil || string(raw) != before {
diff --git a/internal/directlive/fewer_prompts_test.go b/internal/directlive/fewer_prompts_test.go
new file mode 100644
index 00000000..9c035ee9
--- /dev/null
+++ b/internal/directlive/fewer_prompts_test.go
@@ -0,0 +1,92 @@
+package directlive
+
+import (
+ "encoding/json"
+ "os"
+ "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) {
+ 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)
+ 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)
+ }
+ 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)
+ }
+ raw, err = os.ReadFile(filepath.Join(dir, e.Checks[name].Artifact))
+ var check struct {
+ AnsweredBy string `json:"answered_by"`
+ }
+ if err != nil || json.Unmarshal(raw, &check) != nil || check.AnsweredBy != want {
+ t.Fatalf("%s/%s: %s attribution: %s %v", family, role, name, raw, err)
+ }
+ }
+ files, err := filepath.Glob(filepath.Join(dir, "answer-*.json"))
+ if err != nil {
+ t.Fatal(err)
+ }
+ controls := 0
+ for _, file := range files {
+ raw, err = os.ReadFile(file)
+ var a struct {
+ AnsweredBy string `json:"answered_by"`
+ Control string `json:"control"`
+ }
+ if err != nil || json.Unmarshal(raw, &a) != nil {
+ t.Fatalf("answer: %s %v", raw, err)
+ }
+ if a.AnsweredBy != "automatic" && a.AnsweredBy != "person" {
+ t.Fatal("missing answer attribution")
+ }
+ if a.Control != "" {
+ controls++
+ if a.AnsweredBy != want {
+ t.Fatalf("%s: %s", file, a.AnsweredBy)
+ }
+ }
+ }
+ if controls != 3 {
+ t.Fatalf("%s/%s: %d controls", family, role, controls)
+ }
+ }
+ }
+ 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/inventory.go b/internal/directlive/inventory.go
index 8ec9f7df..9a05ea4b 100644
--- a/internal/directlive/inventory.go
+++ b/internal/directlive/inventory.go
@@ -13,7 +13,7 @@ func (x *exercise) inventory(ctx context.Context) error {
return err
}
expected := []string{}
- tested := routingComplete(x.evidence.Tools)
+ tested := routingComplete(x.evidence.Tools, x.evidence.Specialist)
missingRecorded := true
for _, tool := range x.evidence.Tools {
if !tool.Exposed {
@@ -55,14 +55,14 @@ func (x *exercise) inventory(ctx context.Context) error {
return nil
}
-func routingComplete(tools []provider.LiveTool) bool {
+func routingComplete(tools []provider.LiveTool, specialist string) bool {
exposed := 0
for _, tool := range tools {
if !tool.Exposed {
continue
}
exposed++
- if tool.Routing["workspace"].Status != "pass" {
+ if tool.Routing["workspace"].Status != provider.RoutingWorkspaceStatus(specialist, tool.Name) {
return false
}
status := tool.Routing["outside"].Status
diff --git a/internal/directlive/person_controls.go b/internal/directlive/person_controls.go
new file mode 100644
index 00000000..abf05fda
--- /dev/null
+++ b/internal/directlive/person_controls.go
@@ -0,0 +1,12 @@
+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 2eaaf709..ab0aeac1 100644
--- a/internal/directlive/probe_answers.go
+++ b/internal/directlive/probe_answers.go
@@ -5,14 +5,19 @@ import "context"
type probeExpectationKey struct{}
type probeExpectation struct {
behavior string
+ control string
automatic bool
}
func withProbeExpectation(ctx context.Context, behavior string) context.Context {
- return context.WithValue(ctx, probeExpectationKey{}, probeExpectation{behavior, true})
+ return context.WithValue(ctx, probeExpectationKey{}, probeExpectation{behavior: behavior, automatic: true})
}
func withControlExpectation(ctx context.Context, behavior string) context.Context {
- return context.WithValue(ctx, probeExpectationKey{}, probeExpectation{behavior, false})
+ control := behavior
+ if behavior == "workspace" {
+ behavior = "allow"
+ }
+ return context.WithValue(ctx, probeExpectationKey{}, probeExpectation{behavior: behavior, control: control})
}
func terminalGuidance(ctx context.Context) string {
expectation, _ := ctx.Value(probeExpectationKey{}).(probeExpectation)
diff --git a/internal/directlive/probes.go b/internal/directlive/probes.go
index a62df95e..35c08f95 100644
--- a/internal/directlive/probes.go
+++ b/internal/directlive/probes.go
@@ -159,11 +159,11 @@ func (x *exercise) probes(ctx context.Context, inventory []string) error {
x.mu.Lock()
x.probing = false
x.mu.Unlock()
- frames, err := x.turn(withControlExpectation(ctx, "allow"), prompt)
+ frames, err := x.turn(withControlExpectation(ctx, "workspace"), prompt)
if err != nil {
return err
}
- return x.check("workspace-positive-control", observedRead(x.evidence.Provider, frames, tool, path, false), map[string]any{"path": path, "turn": x.sequence})
+ return x.check("workspace-positive-control", observedRead(x.evidence.Provider, frames, tool, path, false), map[string]any{"path": path, "turn": x.sequence, "answered_by": x.controlSource.answeredBy})
}
func (x *exercise) calibration() error {
in, out, err := provider.DirectReservations(x.evidence.Usage)
diff --git a/internal/directlive/routing_approval_test.go b/internal/directlive/routing_approval_test.go
new file mode 100644
index 00000000..248cf067
--- /dev/null
+++ b/internal/directlive/routing_approval_test.go
@@ -0,0 +1,55 @@
+package directlive
+
+import (
+ "context"
+ "testing"
+
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "amadan.net/oficina/equipo/internal/runnerproto"
+)
+
+func TestRoutingApprovalsNeverAskPerson(t *testing.T) {
+ for _, tc := range []struct{ action, name, want string }{
+ {"review", "item/fileChange/requestApproval", "deny"},
+ {"scope", "applyPatchApproval", "deny"},
+ {"recommend", "Write", "deny"},
+ {"investigate", "Edit", "deny"},
+ {"implement", "Write", "allow"},
+ {"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})}}}
+ 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)
+ }
+ x.answerContext = ctx
+ if x.source(context.Background()).answeredBy != "automatic" {
+ t.Fatal("relay attribution is not automatic")
+ }
+ })
+ }
+}
+
+func TestRoutingCompletionUsesRole(t *testing.T) {
+ for _, role := range []string{"Review", "Scope", "Research", "Investigation", "Engineering"} {
+ for _, tool := range []string{"apply_patch", "exec_command", "mcp__equipo__submit_review"} {
+ for _, status := range []string{"pass", "denied", "declined", "not-certified", ""} {
+ want := "pass"
+ if role != "Engineering" && tool == "apply_patch" {
+ want = "denied"
+ }
+ tools := []provider.LiveTool{{Name: tool, Exposed: true, Routing: map[string]provider.LiveObservation{"workspace": {Status: status}, "outside": {Status: "declined"}}}}
+ if routingComplete(tools, role) != (status == want) {
+ t.Fatalf("%s/%s/%s: wrong completion", role, tool, status)
+ }
+ }
+ }
+ }
+}
diff --git a/internal/directlive/routing_codex.go b/internal/directlive/routing_codex.go
index cb9b4cde..8d578658 100644
--- a/internal/directlive/routing_codex.go
+++ b/internal/directlive/routing_codex.go
@@ -5,7 +5,7 @@ import (
"strings"
)
-func codexRoutingPositive(frames [][]byte, tool, path string) bool {
+func codexRoutingResult(frames [][]byte, tool, path, status string) bool {
calls := map[string]bool{}
for _, raw := range frames {
var v struct {
@@ -46,7 +46,7 @@ func codexRoutingPositive(frames [][]byte, tool, path string) bool {
}
}
}
- if tool == "apply_patch" && v.Method == "item/completed" && b.Type == "fileChange" && calls[b.ID] && b.Status == "completed" && len(b.Changes) == 1 {
+ if tool == "apply_patch" && v.Method == "item/completed" && b.Type == "fileChange" && calls[b.ID] && b.Status == status && len(b.Changes) == 1 {
c := b.Changes[0]
if c.Path == path && c.Kind.Type == "update" && c.Kind.MovePath == nil && c.Diff != "" {
return true
diff --git a/internal/directlive/routing_order.go b/internal/directlive/routing_order.go
new file mode 100644
index 00000000..901e891e
--- /dev/null
+++ b/internal/directlive/routing_order.go
@@ -0,0 +1,25 @@
+package directlive
+
+import (
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "slices"
+)
+
+// A pending submission occupies the broker slot. Finish and acknowledge the
+// question first, preserving candidate-before-render order among submissions.
+func routingTools(tools []provider.LiveTool) []provider.LiveTool {
+ ordered := slices.Clone(tools)
+ slices.SortStableFunc(ordered, func(a, b provider.LiveTool) int {
+ if a.Name == b.Name {
+ return 0
+ }
+ if a.Name == "mcp__equipo__ask_person" {
+ return -1
+ }
+ if b.Name == "mcp__equipo__ask_person" {
+ return 1
+ }
+ return 0
+ })
+ return ordered
+}
diff --git a/internal/directlive/routing_order_test.go b/internal/directlive/routing_order_test.go
new file mode 100644
index 00000000..f788580a
--- /dev/null
+++ b/internal/directlive/routing_order_test.go
@@ -0,0 +1,19 @@
+package directlive
+
+import (
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "testing"
+)
+
+func TestRoutingQuestionPrecedesSubmission(t *testing.T) {
+ for _, submission := range []string{"submit_review", "submit_acceptance", "submit_answer", "submit_candidate"} {
+ tools := []provider.LiveTool{{Name: "Read", Exposed: true}, {Name: "mcp__equipo__" + submission, Exposed: true}, {Name: "mcp__equipo__ask_person", Exposed: true}, {Name: "mcp__equipo__submit_render", Exposed: true}}
+ ordered := routingTools(tools)
+ if ordered[0].Name != "mcp__equipo__ask_person" || ordered[2].Name != "mcp__equipo__"+submission || ordered[3].Name != "mcp__equipo__submit_render" {
+ t.Fatalf("question must finish before a submission occupies the broker slot: %+v", ordered)
+ }
+ if tools[0].Name != "Read" {
+ t.Fatal("catalog order changed")
+ }
+ }
+}
diff --git a/internal/directlive/terminal.go b/internal/directlive/terminal.go
index ab989f6a..0af53b10 100644
--- a/internal/directlive/terminal.go
+++ b/internal/directlive/terminal.go
@@ -58,6 +58,7 @@ func terminalAnswer(ctx context.Context, q runnerproto.Question) (runnerproto.Qu
}
if b[0] == '\n' || b[0] == '\r' {
text := strings.TrimSpace(string(raw))
+ raw = raw[:0]
if text == "" {
continue
}
@@ -67,6 +68,11 @@ func terminalAnswer(ctx context.Context, q runnerproto.Question) (runnerproto.Qu
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)
}
diff --git a/internal/directlive/terminal_retry_test.go b/internal/directlive/terminal_retry_test.go
new file mode 100644
index 00000000..90523f55
--- /dev/null
+++ b/internal/directlive/terminal_retry_test.go
@@ -0,0 +1,76 @@
+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/tool_routing.go b/internal/directlive/tool_routing.go
index 8ce75b9f..125e560e 100644
--- a/internal/directlive/tool_routing.go
+++ b/internal/directlive/tool_routing.go
@@ -14,12 +14,15 @@ import (
)
func routingStatus(family string, frames [][]byte, tool, path string, outside bool) string {
- if family == "codex" && !outside && (codexRoutingPositive(frames, tool, path) || codexResourcePositive(frames, tool) || tool == "write_stdin" && codexStdinPositive(frames)) {
+ if family == "codex" && !outside && (codexRoutingResult(frames, tool, path, "completed") || codexResourcePositive(frames, tool) || tool == "write_stdin" && codexStdinPositive(frames)) {
return "pass"
}
if family == "codex" && tool == "write_stdin" && !outside {
return "not-certified"
}
+ if family == "codex" && outside && tool == "apply_patch" && codexRoutingResult(frames, tool, path, "declined") {
+ return "denied"
+ }
matchPath := path
if !outside && !provider.PathProbeApplicable(tool) {
matchPath = ""
@@ -76,6 +79,7 @@ func routingAttempted(frames [][]byte, tool string) bool {
}
func (x *exercise) toolRouting(ctx context.Context) error {
+ x.evidence.Tools = routingTools(x.evidence.Tools)
x.mu.Lock()
x.probing = true
x.mu.Unlock()
@@ -90,6 +94,7 @@ func (x *exercise) toolRouting(ctx context.Context) error {
key = "outside"
}
var prompt strings.Builder
+ prompt.WriteString("Call tools sequentially in the listed order. Finish ask_person before any submission tool.\n")
paths := map[string]string{}
for i, tool := range x.evidence.Tools {
if !tool.Exposed {
@@ -193,7 +198,11 @@ func (x *exercise) toolRouting(ctx context.Context) error {
}
return provider.ErrIsolation
}
- status := routingStatus(x.evidence.Provider, frames, tool.Name, paths[tool.Name], outside)
+ refusal := !outside && provider.RoutingWorkspaceStatus(x.evidence.Specialist, tool.Name) == "denied"
+ status := routingStatus(x.evidence.Provider, frames, tool.Name, paths[tool.Name], outside || refusal)
+ if refusal && status != "denied" {
+ status = "not-certified"
+ }
if outside && tool.Name == "Bash" && x.evidence.Provider == "claude" && x.outerPresent(paths[tool.Name]) {
rawFrames := make([]json.RawMessage, len(frames))
for j, f := range frames {
@@ -221,5 +230,5 @@ func (x *exercise) toolRouting(ctx context.Context) error {
tool.Routing[key] = o
}
}
- return x.check("tool-routing", routingComplete(x.evidence.Tools), x.evidence.Tools)
+ return x.check("tool-routing", routingComplete(x.evidence.Tools, x.evidence.Specialist), x.evidence.Tools)
}
diff --git a/internal/directlive/tool_routing_test.go b/internal/directlive/tool_routing_test.go
index cdeede56..5c5d06ed 100644
--- a/internal/directlive/tool_routing_test.go
+++ b/internal/directlive/tool_routing_test.go
@@ -57,3 +57,21 @@ func TestCodexRoutingPinnedFrames(t *testing.T) {
t.Fatal("MCP attempt mislabeled", got)
}
}
+
+func TestReadOnlyPatchRoutingRequiresCorrelatedRefusal(t *testing.T) {
+ call := `{"method":"rawResponseItem/completed","params":{"item":{"type":"custom_tool_call","name":"apply_patch","call_id":"p","input":"*** Begin Patch\n*** Update File: /workspace/route\n@@\n-routing-before\n+routing-after\n*** End Patch"}}}`
+ result := `{"method":"item/completed","params":{"item":{"type":"fileChange","id":"p","status":"declined","changes":[{"path":"/workspace/route","kind":{"type":"update","move_path":null},"diff":"changed"}]}}}`
+ for _, tc := range []struct{ name, call, result, want string }{
+ {"refusal", call, result, "denied"},
+ {"success", call, strings.ReplaceAll(result, "declined", "completed"), "not-certified"},
+ {"wrong-call", call, strings.ReplaceAll(result, `"id":"p"`, `"id":"other"`), "not-certified"},
+ {"wrong-path", call, strings.ReplaceAll(result, "/workspace/route", "/different"), "not-certified"},
+ {"attempt-only", call, `{}`, "not-certified"},
+ } {
+ t.Run(tc.name, func(t *testing.T) {
+ if got := routingStatus("codex", [][]byte{[]byte(tc.call), []byte(tc.result)}, "apply_patch", "/workspace/route", true); got != tc.want {
+ t.Fatalf("got %s want %s", got, tc.want)
+ }
+ })
+ }
+}
diff --git a/internal/directlive/turn.go b/internal/directlive/turn.go
index 46d7c4fc..88cf9e88 100644
--- a/internal/directlive/turn.go
+++ b/internal/directlive/turn.go
@@ -25,7 +25,9 @@ func (x *exercise) relay() runner.DirectQuestionRelay {
return time.Time{}, provider.ErrIdentity
}
return x.binding.LeaseDeadline, nil
- }, Answerer: func(context.Context, runnerproto.Question) (string, error) { return "terminal-operator", nil }}
+ }, Answerer: func(ctx context.Context, _ runnerproto.Question) (string, error) {
+ return x.source(ctx).answeredBy, nil
+ }}
}
func (x *exercise) open(ctx context.Context, tool string) error {
deadline, _ := ctx.Deadline()
@@ -80,6 +82,10 @@ func (x *exercise) open(ctx context.Context, tool string) error {
return err
}
func (x *exercise) turn(ctx context.Context, prompt string) ([][]byte, error) {
+ x.mu.Lock()
+ x.answerContext = ctx
+ x.mu.Unlock()
+ defer func() { x.mu.Lock(); x.answerContext = nil; x.mu.Unlock() }()
d := x.d
beforeInput, beforeOutput := d.input, d.output
if err := d.reserveRecovery(); err != nil {
@@ -169,10 +175,22 @@ func (x *exercise) turn(ctx context.Context, prompt string) ([][]byte, error) {
func (x *exercise) answer(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) {
var a runnerproto.QuestionAnswer
var err error
+ answeredBy := "automatic"
expectation, _ := ctx.Value(probeExpectationKey{}).(probeExpectation)
x.mu.Lock()
- probing, routing := x.probing, x.routing
+ probing, routing, turnCtx := x.probing, x.routing, x.answerContext
x.mu.Unlock()
+ if turnCtx != nil {
+ if expectation.control == "" && !expectation.automatic {
+ expectation, _ = turnCtx.Value(probeExpectationKey{}).(probeExpectation)
+ ctx = context.WithValue(ctx, probeExpectationKey{}, expectation)
+ }
+ if deadline, ok := turnCtx.Deadline(); ok {
+ var cancel context.CancelFunc
+ ctx, cancel = context.WithDeadline(ctx, deadline)
+ defer cancel()
+ }
+ }
if probing || expectation.automatic && expectation.behavior == "deny" {
a.Behavior = "deny"
} else if (routing || expectation.automatic && expectation.behavior == "allow") && (q.Kind == "question" || q.Kind == "person") {
@@ -183,7 +201,9 @@ func (x *exercise) answer(ctx context.Context, q runnerproto.Question) (runnerpr
}
a.UpdatedInput = marshal(map[string]any{"answers": map[string]string{key: "Continue"}})
} else {
- a, err = x.d.answer(ctx, q)
+ source := x.source(ctx)
+ answeredBy = source.answeredBy
+ a, err = source.answer(ctx, q)
}
if err != nil {
return a, err
@@ -199,8 +219,28 @@ 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)
- if err = save(x.root, name, map[string]any{"question": q, "answer": a}); err != nil {
+ o, 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{}
+ }
+ matches := a.Behavior == expectation.behavior
+ if expectation.behavior == "question" {
+ matches = (q.Kind == "person" || q.Kind == "question") && a.Behavior == "allow"
+ }
+ if len(x.controlAnswers[expectation.control]) == 0 {
+ 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 4846eb79..1416cf8a 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -11,7 +11,7 @@ import (
// App-owned runtime strings belong here, including boot diagnostics.
// Existing copy accepted for now by Paul, 2026-11-04; new entries stay marked pending.
const (
- CopyCalibrationFunding = "calibration funding is too low; rerun with JobInput=%d JobOutput=%d ProjectInputHeadroom=%d ProjectOutputHeadroom=%d TeamInputHeadroom=%d TeamOutputHeadroom=%d: %w" // COPY REVIEW REQUIRED: Round 3 funding guidance.
+ CopyCalibrationFunding = "calibration funding is too low; rerun with JobInput=%d JobOutput=%d ProjectInputHeadroom=%d ProjectOutputHeadroom=%d TeamInputHeadroom=%d TeamOutputHeadroom=%d: %w" // COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context)
copyObserverFailure = "The live update could not be sent. The change was saved."
copyDecisionOwnerAssigned = "Reassign this person's project decisions before removing them."
copyBindingInUse = "Another project uses this repository and app. Choose a different pair."
@@ -766,7 +766,6 @@ var runnerDraftCopy = map[string]string{
"evidence.after": "After",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): evidence.approved
"evidence.approved": "Approved",
-
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): plan.awaiting_approval
"plan.awaiting_approval": "Waiting for your plan approval",
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): plan.proposed
@@ -803,6 +802,7 @@ var runnerDraftCopy = map[string]string{
"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
diff --git a/internal/equipotest/runner_release_test.go b/internal/equipotest/runner_release_test.go
index 1545b97c..5b801916 100644
--- a/internal/equipotest/runner_release_test.go
+++ b/internal/equipotest/runner_release_test.go
@@ -57,7 +57,7 @@ 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"})
+ 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"})
})
}
}
@@ -191,6 +191,7 @@ 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{}}
@@ -233,6 +234,7 @@ 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{}
@@ -254,7 +256,6 @@ func releaseCertificationFixture(t *testing.T, root, bin, scenario string) []str
if scenario == "missing_plan3_inventory" {
executionMust(t, os.Remove(filepath.Join(root, "docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md")))
}
-
t.Helper()
var fixture release.Manifest
rawManifest, err := os.ReadFile(filepath.Join(root, "internal/release/manifest.json"))
@@ -285,6 +286,5 @@ func releaseCertificationFixture(t *testing.T, root, bin, scenario string) []str
bytes, err := json.Marshal(fixture)
executionMust(t, err)
executionMust(t, os.WriteFile(filepath.Join(root, "internal/release/manifest.json"), bytes, 0600))
-
return installed
}
diff --git a/internal/plan3test/plan3_release_test.go b/internal/plan3test/plan3_release_test.go
index 5cdf9bc8..4604250f 100644
--- a/internal/plan3test/plan3_release_test.go
+++ b/internal/plan3test/plan3_release_test.go
@@ -173,7 +173,8 @@ func plan3CopyInventory(t *testing.T) {
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)"
- if !strings.Contains(cells[3], "COPY REVIEW REQUIRED") && !acceptedGuide && !acceptedProbe {
+ 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 {
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 68d6a892..707f34bd 100644
--- a/internal/release/manifest.go
+++ b/internal/release/manifest.go
@@ -48,22 +48,23 @@ type Certification struct {
}
type Manifest struct {
- 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"`
+ 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"`
}
func BuildManifest() Manifest {
diff --git a/internal/runner/provider/direct_certification.go b/internal/runner/provider/direct_certification.go
index 430a697c..a396f0e5 100644
--- a/internal/runner/provider/direct_certification.go
+++ b/internal/runner/provider/direct_certification.go
@@ -234,7 +234,7 @@ func (e DirectEvidence) validateTools(root string, probes bool) error {
return ErrPolicy
}
if probes {
- for key, want := range map[string]string{"workspace": "pass", "outside": "denied"} {
+ for key, want := range map[string]string{"workspace": RoutingWorkspaceStatus(e.Specialist, tool.Name), "outside": "denied"} {
o := tool.Routing[key]
if key == "outside" && o.Status == "declined" {
want = "declined"
@@ -291,3 +291,14 @@ func (e DirectEvidence) validateTools(root string, probes bool) error {
}
return nil
}
+
+// Workspace write tools must be refused for specialists with read-only workspaces.
+func RoutingWorkspaceStatus(specialist, tool string) string {
+ switch specialist {
+ case "Review", "Product", "Scope", "Research", "Investigation", "Coordinator":
+ if tool == "apply_patch" || tool == "Write" || tool == "Edit" {
+ return "denied"
+ }
+ }
+ return "pass"
+}
diff --git a/internal/runner/provider/isolation_boundary_test.go b/internal/runner/provider/isolation_boundary_test.go
index c24135b7..6574397e 100644
--- a/internal/runner/provider/isolation_boundary_test.go
+++ b/internal/runner/provider/isolation_boundary_test.go
@@ -160,3 +160,19 @@ func TestClaudeIsolationRejectsComputedProof(t *testing.T) {
t.Fatal("computed-only native proof certified")
}
}
+
+func TestRoutingReadOnlyWriteRefusal(t *testing.T) {
+ for _, role := range []string{"Review", "Scope", "Research", "Investigation"} {
+ for _, status := range []string{"denied", "pass", "declined", "not-certified", ""} {
+ e, root := directEvidenceFixture(t)
+ e.Specialist = role
+ e.Tools[0].Name = "apply_patch"
+ o := e.Tools[0].Routing["workspace"]
+ o.Status = status
+ e.Tools[0].Routing["workspace"] = o
+ if err := e.ValidateGroup(root, "Isolation"); (err == nil) != (status == "denied") {
+ t.Fatalf("%s %s: %v", role, status, err)
+ }
+ }
+ }
+}
diff --git a/internal/runner/provider/person_controls.go b/internal/runner/provider/person_controls.go
new file mode 100644
index 00000000..79ae15e6
--- /dev/null
+++ b/internal/runner/provider/person_controls.go
@@ -0,0 +1,92 @@
+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/isolation_test.go b/internal/runner/provider/providertest/isolation_test.go
index 2f4ec1a2..692dd50d 100644
--- a/internal/runner/provider/providertest/isolation_test.go
+++ b/internal/runner/provider/providertest/isolation_test.go
@@ -64,6 +64,11 @@ except ValueError:pass
else:raise AssertionError('provider launch mismatch accepted')
# Stub only file hashing: status policy must still reject a declined workspace control.
observation=lambda *args: None
+for role in ('Review','Scope','Research','Investigation'):
+ for status in ('denied','pass','declined','not-certified',''):
+ try:routing_observation(None,'workspace',dict(status=status),role,'apply_patch')
+ except ValueError:assert status!='denied'
+ else:assert status=='denied'
routing_observation(None,'workspace',dict(status='pass'))
routing_observation(None,'outside',dict(status='declined'))
try:routing_observation(None,'workspace',dict(status='declined'))
diff --git a/internal/runner/provider/providertest/person_controls.go b/internal/runner/provider/providertest/person_controls.go
new file mode 100644
index 00000000..a814d685
--- /dev/null
+++ b/internal/runner/provider/providertest/person_controls.go
@@ -0,0 +1,68 @@
+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/scripts/runner-release-check.py b/scripts/runner-release-check.py
index 6f041682..3e695ffc 100644
--- a/scripts/runner-release-check.py
+++ b/scripts/runner-release-check.py
@@ -40,6 +40,42 @@ 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:
@@ -66,8 +102,9 @@ def isolation_artifact(record, artifact, launch):
require(record["provider_launch"][key] == launch[field])
-def routing_observation(base, key, route):
- wanted = "pass" if key == "workspace" else "denied"
+def routing_observation(base, key, route, specialist="", tool=""):
+ refused = specialist in ("Review", "Product", "Scope", "Research", "Investigation", "Coordinator") and tool in ("apply_patch", "Write", "Edit")
+ wanted = "pass" if key == "workspace" and not refused else "denied"
require(route["status"] == wanted or key == "outside" and route["status"] == "declined")
observation(base, route, route["status"])
@@ -169,7 +206,7 @@ def evidence(manifest, certificate, reference, installed):
exposed.add(tool["name"])
for key, wanted in (("workspace", "pass"), ("outside", "denied")):
route = tool["routing"][key]
- routing_observation(path.parent, key, route)
+ routing_observation(path.parent, key, route, record["specialist"], tool["name"])
require(not tool.get("missing_reason"))
require(exposed)
require(surfaces == {"native", "shell", "search", "image", "mcp"})
@@ -245,6 +282,7 @@ 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"]])