Use automatic answers for every live-gate control
Co-Authored-By: Astra <noreply@openai.com>
35 files changed,
+291
−1,046
docs/live-gate.md+3 −2docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md+0 −7docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md+125 −0internal/directlive/answer_source.go+3 −15internal/directlive/answer_source_test.go+44 −86internal/directlive/approval_controls_test.go+0 −101internal/directlive/{fewer_prompts_test.go => automatic_controls_test.go}+2 −27internal/directlive/certificate.go+2 −18internal/directlive/controls.go+0 −3internal/directlive/coordinator_certificate_test.go+20 −85internal/directlive/driver.go+6 −12internal/directlive/driver_test.go+8 −35internal/directlive/final_gaps_test.go+2 −8internal/directlive/person_controls.go+0 −12internal/directlive/person_retry_test.go+0 −94internal/directlive/probe_answers.go+0 −8internal/directlive/probe_answers_test.go+3 −17internal/directlive/recovery.go+1 −1internal/directlive/routing_approval_test.go+3 −7internal/directlive/terminal.go+0 −93internal/directlive/terminal_probe_test.go+0 −63internal/directlive/terminal_retry_test.go+0 −79internal/directlive/turn.go+2 −6internal/equipo/copy.go+1 −8internal/equipotest/runner_release_test.go+4 −4internal/plan3test/plan3_release_test.go+2 −3internal/release/manifest.go+16 −17internal/runner/provider/control_checks.go+3 −0internal/runner/provider/person_controls.go+0 −92internal/runner/provider/providertest/control_failures.go+30 −0internal/runner/provider/providertest/person_controls.go+0 −68internal/tryequipo/testdata/tty-chain/answer.go.txt+3 −15internal/tryequipo/testdata/tty-chain/drive.py+4 −19internal/tryequipo/tty_chain_test.go+4 −4scripts/runner-release-check.py+0 −37
CI passed — run details
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/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md| index 3e0683ca..57706015 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md |
| @@ -5154,13 +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` | Type Allow once, Deny, or an answers JSON object. This request expires in 5 minutes. | Guided live answer prompt | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context) | |
| -| `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) | |
| -| `live.answer-expired` | The request expired. This check will be retried or failed. | Guided live answer expiry | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context) | |
| -| `live.answer-received` | Answer received. | Guided live answer confirmation after validation | 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| index 9d8a1f3a..457149fb 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md |
| @@ -307,3 +307,128 @@ 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 0c565b85..4b051233 100644 |
| --- a/internal/directlive/answer_source.go |
| +++ b/internal/directlive/answer_source.go |
| @@ -8,19 +8,13 @@ import ( |
| "amadan.net/oficina/equipo/internal/runnerproto" |
| ) |
| -const personAnswerTimeout = 5 * time.Minute |
| - |
| type answerSource struct { |
| answeredBy string |
| read answerFunc |
| } |
| func (s answerSource) answer(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) { |
| - timeout := time.Minute |
| - if s.answeredBy == "person" { |
| - timeout = personAnswerTimeout |
| - } |
| - ctx, cancel := context.WithTimeout(ctx, timeout) |
| + ctx, cancel := context.WithTimeout(ctx, time.Minute) |
| defer cancel() |
| if err := ctx.Err(); err != nil { |
| return runnerproto.QuestionAnswer{}, err |
| @@ -35,13 +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] { |
| - return answerSource{"person", d.answer} |
| - } |
| +func automaticAnswers() answerSource { |
| return answerSource{"automatic", expectedAnswer} |
| } |
| @@ -77,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 f470d211..7a6b9709 100644 |
| --- a/internal/directlive/answer_source_test.go |
| +++ b/internal/directlive/answer_source_test.go |
| @@ -10,118 +10,76 @@ import ( |
| "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) |
| } |
| - } |
| - d.personControls[family] = true // The completed tuple has supplied passing proof. |
| + }) |
| } |
| } |
| - 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() |
| - want := time.Minute |
| - if by == "person" { |
| - want = 5 * time.Minute |
| - } |
| - if !ok || time.Until(deadline) > want || time.Until(deadline) < want-time.Second { |
| - t.Fatal("missing answer deadline") |
| - } |
| - return runnerproto.QuestionAnswer{Behavior: "deny"}, nil |
| - } |
| - if _, err := s.answer(ctx, q); err != nil { |
| - t.Fatal(err) |
| - } |
| - }) |
| + 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 TestPersonAnswerHasFiveMinutes(t *testing.T) { |
| - for _, by := range []string{"person", "automatic"} { |
| - t.Run(by, func(t *testing.T) { |
| +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 := answerSource{by, func(ctx context.Context, _ runnerproto.Question) (runnerproto.QuestionAnswer, error) { |
| + s := automaticAnswers() |
| + s.read = func(ctx context.Context, _ runnerproto.Question) (runnerproto.QuestionAnswer, error) { |
| <-ctx.Done() |
| return runnerproto.QuestionAnswer{Behavior: "deny"}, nil |
| - }} |
| - _, err := s.answer(context.Background(), runnerproto.Question{}) |
| - want := time.Minute |
| - if by == "person" { |
| - want = 5 * time.Minute |
| } |
| - if !errors.Is(err, context.DeadlineExceeded) || time.Since(start) != want { |
| - t.Fatalf("%s expired after %s, want %s: %v", by, time.Since(start), want, err) |
| + 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) |
| } |
| }) |
| }) |
| } |
| } |
| - |
| -func TestControlSourcesRetryUntilPass(t *testing.T) { |
| - d := driver{answer: expectedAnswer} |
| - for _, role := range []string{"Review", "Engineering", "Copy"} { |
| - if got := d.controlSource("claude", role).answeredBy; got != "person" { |
| - t.Fatalf("%s lost person retry: %s", role, got) |
| - } |
| - } |
| - d.personControls["claude"] = true |
| - if got := d.controlSource("claude", "Design").answeredBy; got != "automatic" { |
| - t.Fatal(got) |
| - } |
| - if got := d.controlSource("codex", "Design").answeredBy; got != "person" { |
| - t.Fatal("one provider consumed another's proof", got) |
| - } |
| - d.worker = true |
| - if got := d.controlSource("codex", "Review").answeredBy; got != "automatic" { |
| - t.Fatal("worker asked person", got) |
| - } |
| -} |
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 09340d30..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 |
| @@ -120,9 +118,6 @@ func runRoles(ctx context.Context, c provider.DirectLiveConfig, config []byte, p |
| } |
| e = failed.evidence |
| } |
| - if e.ValidatePersonControls(dir) == nil { |
| - d.personControls[b.Binding.Provider] = true |
| - } |
| records = append(records, e) |
| index = append(index, name+"/certification.json") |
| } |
| @@ -192,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 |
| @@ -225,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 22a4dfc9..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,24 +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 |
| - retryAnswer := personRetryAnswer() |
| - answer := func(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) { |
| - if os.Getenv("EQUIPO_FAKE_PERSON_RETRY") == "1" { |
| - return retryAnswer(ctx, q) |
| - } |
| - 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) |
| @@ -199,21 +180,15 @@ 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"} |
| } |
| - if os.Getenv("EQUIPO_FAKE_PERSON_RETRY") == "1" { |
| - roles = []string{"Review", "Engineering", "Copy", "Design"} |
| - c.Funding.Seconds = 720 |
| - } |
| 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) |
| - if os.Getenv("EQUIPO_FAKE_PERSON_RETRY") == "1" { |
| - checkPersonRetryRun(t, c.EvidenceDir, runErr) |
| - } else if os.Getenv("EQUIPO_FAKE_BAD_COORDINATOR") == "1" { |
| + 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") { |
| t.Fatalf("coordinator failure not isolated: %v", runErr) |
| @@ -229,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) |
| @@ -274,9 +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 os.Getenv("EQUIPO_FAKE_PERSON_RETRY") == "1" && (strings.Contains(name, "-Review/") || strings.Contains(name, "-Engineering/")) { |
| - continue |
| - } |
| + |
| 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/person_retry_test.go b/internal/directlive/person_retry_test.go| deleted file mode 100644 |
| index ea751c93..00000000 |
| --- a/internal/directlive/person_retry_test.go |
| +++ /dev/null |
| @@ -1,94 +0,0 @@ |
| -package directlive |
| - |
| -import ( |
| - "context" |
| - "encoding/json" |
| - "errors" |
| - "fmt" |
| - "os" |
| - "path/filepath" |
| - "strings" |
| - "testing" |
| - "time" |
| - |
| - "amadan.net/oficina/equipo/internal/runner/provider" |
| - "amadan.net/oficina/equipo/internal/runnerproto" |
| -) |
| - |
| -func TestPersonProofRetryFakeCLI(t *testing.T) { |
| - t.Parallel() |
| - runFakeDriver(t, false, "EQUIPO_FAKE_PERSON_RETRY=1") |
| -} |
| - |
| -func personRetryAnswer() answerFunc { |
| - return func(ctx context.Context, q runnerproto.Question) (runnerproto.QuestionAnswer, error) { |
| - deadline, ok := ctx.Deadline() |
| - if !ok || time.Until(deadline) < 4*time.Minute { |
| - return runnerproto.QuestionAnswer{}, fmt.Errorf("person answer cut short: %v", deadline) |
| - } |
| - if strings.HasSuffix(q.AgentID, "/Review") { |
| - return runnerproto.QuestionAnswer{}, context.DeadlineExceeded |
| - } |
| - if strings.HasSuffix(q.AgentID, "/Engineering") { |
| - return runnerproto.QuestionAnswer{Behavior: "invalid"}, nil |
| - } |
| - if !strings.HasSuffix(q.AgentID, "/Copy") { |
| - return runnerproto.QuestionAnswer{}, fmt.Errorf("person asked after passing proof: %s", q.AgentID) |
| - } |
| - return expectedAnswer(ctx, q) |
| - } |
| -} |
| - |
| -func checkPersonRetryRun(t *testing.T, root string, runErr error) { |
| - t.Helper() |
| - var failures *TupleFailures |
| - if !errors.As(runErr, &failures) || len(failures.Failures) != 4 { |
| - t.Fatalf("want two failed tuples per provider: %v", runErr) |
| - } |
| - for _, family := range []string{"claude", "codex"} { |
| - for _, role := range []string{"Review", "Engineering", "Copy", "Design"} { |
| - dir := filepath.Join(root, family+"-"+role) |
| - raw, err := os.ReadFile(filepath.Join(dir, "certification.json")) |
| - var e provider.DirectEvidence |
| - if err != nil || json.Unmarshal(raw, &e) != nil { |
| - t.Fatal("missing evidence", dir, err) |
| - } |
| - if (e.ValidatePersonControls(dir) == nil) != (role == "Copy") { |
| - t.Fatal("wrong person proof", family, role) |
| - } |
| - 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.Fatal("invalid answer artifact", file, err) |
| - } |
| - if a.Control == "" { |
| - continue |
| - } |
| - controls++ |
| - want := "automatic" |
| - if role == "Copy" { |
| - want = "person" |
| - } |
| - if a.AnsweredBy != want { |
| - t.Fatal("wrong answer source", file, a.AnsweredBy) |
| - } |
| - } |
| - want := 3 |
| - if role == "Review" || role == "Engineering" { |
| - want = 0 |
| - } |
| - if controls != want { |
| - t.Fatal("wrong control answer count", family, role, controls) |
| - } |
| - } |
| - } |
| -} |
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 3f6e0ed5..00000000 |
| --- a/internal/directlive/terminal.go |
| +++ /dev/null |
| @@ -1,93 +0,0 @@ |
| -package directlive |
| - |
| -import ( |
| - "amadan.net/oficina/equipo/internal/equipo" |
| - "amadan.net/oficina/equipo/internal/runnerproto" |
| - "context" |
| - "encoding/json" |
| - "errors" |
| - "fmt" |
| - "golang.org/x/sys/unix" |
| - "os" |
| - "strings" |
| -) |
| - |
| -func terminalAnswer(ctx context.Context, q runnerproto.Question) (answer runnerproto.QuestionAnswer, err error) { |
| - 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)) |
| - defer func() { |
| - if errors.Is(err, context.DeadlineExceeded) { |
| - fmt.Fprintln(tty, equipo.RunnerText("live.answer-expired")) |
| - } |
| - }() |
| - 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) |
| - } |
| - if err = ctx.Err(); err != nil { |
| - return answer, err |
| - } |
| - if err = q.ValidateAnswer(answer); err != nil { |
| - return answer, err |
| - } |
| - fmt.Fprintln(tty, equipo.RunnerText("live.answer-received")) |
| - return answer, nil |
| - } |
| - 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 0063ed2b..00000000 |
| --- a/internal/directlive/terminal_retry_test.go |
| +++ /dev/null |
| @@ -1,79 +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; eof=False; end=time.monotonic()+3; last=0 |
| -try: |
| - while time.monotonic()<end: |
| - if not eof and select.select([fd],[],[],0.05)[0]: |
| - try:data=os.read(fd,65536) |
| - except OSError:data=b'';eof=True |
| - if not data:eof=True |
| - output+=data |
| - if not eof and 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 |
| - # A closed PTY can precede the child becoming waitable. Keep the same deadline. |
| - if eof:time.sleep(0.01) |
| - 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 e040bb11..38033bdb 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -797,14 +797,7 @@ var runnerDraftCopy = map[string]string{ |
| // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): plan.changes |
| "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-expired": "The request expired. This check will be retried or failed.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context) |
| - "live.answer-received": "Answer received.", // 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 5 minutes.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context): live.answer |
| + "task.state.proposed": "Proposed", |
| // 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 024edbe6..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", "live.answer-retry", "live.answer-received", "live.answer-expired", "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/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/testdata/tty-chain/answer.go.txt b/internal/tryequipo/testdata/tty-chain/answer.go.txt| index 6bb69c36..2b03656e 100644 |
| --- a/internal/tryequipo/testdata/tty-chain/answer.go.txt |
| +++ b/internal/tryequipo/testdata/tty-chain/answer.go.txt |
| @@ -5,24 +5,12 @@ import ( |
| "context" |
| "errors" |
| "fmt" |
| - "golang.org/x/sys/unix" |
| "os" |
| "time" |
| ) |
| func TTYChainFixture() { |
| - tty, err := os.OpenFile("/dev/tty", os.O_RDWR, 0) |
| - if err != nil { |
| - panic(err) |
| - } |
| - defer tty.Close() |
| - foreground, err := unix.IoctlGetInt(int(tty.Fd()), unix.TIOCGPGRP) |
| - if err != nil || foreground != unix.Getpgrp() { |
| - panic("reader is not in the foreground") |
| - } |
| - fmt.Fprintln(tty, "fixture foreground verified") |
| - d := &driver{answer: terminalAnswer} |
| - x := &exercise{d: d, root: os.Getenv("EQUIPO_TTY_FIXTURE_EVIDENCE"), answers: map[string]int{}, controlSource: answerSource{"person", terminalAnswer}} |
| + 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" { |
| @@ -31,7 +19,7 @@ func TTYChainFixture() { |
| } |
| duration := 3 * time.Second |
| if mode == "timeout" { |
| - duration = 300 * time.Millisecond |
| + duration = -time.Second |
| } |
| ctx, cancel := context.WithTimeout(context.Background(), duration) |
| x.sequence = i + 1 |
| @@ -56,5 +44,5 @@ func TTYChainFixture() { |
| } |
| } |
| } |
| - fmt.Fprintln(tty, "fixture answers verified") |
| + fmt.Println("fixture answers verified") |
| } |
diff --git a/internal/tryequipo/testdata/tty-chain/drive.py b/internal/tryequipo/testdata/tty-chain/drive.py| index 05f4a71d..dbadb86b 100644 |
| --- a/internal/tryequipo/testdata/tty-chain/drive.py |
| +++ b/internal/tryequipo/testdata/tty-chain/drive.py |
| @@ -14,9 +14,6 @@ stage = 0 |
| reaped = False |
| status = None |
| prompt = b'Type Allow once, Deny,' |
| -confirmation = b'Answer received.' |
| -answers = [b'Alloe once\rAllow once\r', b'Deny\r', |
| - b'{"answers":{"answer":"fixture"}}\r', b'{}\r', b''] |
| try: |
| os.write(fd, b'./scripts/try-equipo.sh; result=$?; exit "$result"\n') |
| end = time.monotonic() + 60 |
| @@ -32,16 +29,8 @@ try: |
| if stage == 0 and b'[]: ' in output: |
| os.write(fd, b'RUN LIVE GATE\r') |
| stage = 1 |
| - if stage >= 1 and output.count(prompt) >= stage: |
| - if output.count(confirmation) != min(stage - 1, 3): |
| - raise RuntimeError('missing or premature answer confirmation') |
| - # Wait after the prompt, then type characters with real Return. |
| - # The initial typo must be retried without confirming it. |
| - time.sleep(0.15) |
| - for byte in answers[stage - 1]: |
| - os.write(fd, bytes([byte])) |
| - time.sleep(0.01) |
| - 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: |
| @@ -51,12 +40,8 @@ try: |
| reaped = bool(done) |
| if not reaped or os.waitstatus_to_exitcode(status) != 0: |
| raise RuntimeError('process chain did not finish successfully') |
| - if b'fixture answers verified' not in output or stage != 6: |
| - raise RuntimeError('typed answers never arrived') |
| - if output.count(b'The request expired. This check will be retried or failed.') != 1: |
| - raise RuntimeError('missing or repeated expiry notice') |
| - if output.count(confirmation) != 3: |
| - raise RuntimeError('invalid or expired answer was confirmed') |
| + 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. |
diff --git a/internal/tryequipo/tty_chain_test.go b/internal/tryequipo/tty_chain_test.go| index 8c023a44..df0d6f68 100644 |
| --- a/internal/tryequipo/tty_chain_test.go |
| +++ b/internal/tryequipo/tty_chain_test.go |
| @@ -11,9 +11,9 @@ import ( |
| "time" |
| ) |
| -// TestTerminalAnswerProcessChain keeps the shell, Go tools, wizard input, and |
| +// TestAutomaticAnswerProcessChain keeps the shell, Go tools, wizard input, and |
| // runner delegation real. Overlays replace account setup and the provider work. |
| -func TestTerminalAnswerProcessChain(t *testing.T) { |
| +func TestAutomaticAnswerProcessChain(t *testing.T) { |
| root, err := filepath.Abs("../..") |
| if err != nil { |
| t.Fatal(err) |
| @@ -70,8 +70,8 @@ func TestTerminalAnswerProcessChain(t *testing.T) { |
| Behavior string `json:"behavior"` |
| } `json:"answer"` |
| } |
| - if err != nil || json.Unmarshal(raw, &answer) != nil || answer.AnsweredBy != "person" { |
| - t.Fatalf("missing person answer: %s %v", raw, err) |
| + 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" { |
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"]]) |