oficina / equipo Public

Test terminal answer process chain and confirm validated input

Co-Authored-By: Astra <noreply@openai.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev 501533cb5543140576df5753a52a255ac62d9c82 parent 65856ee
11 files changed, +421 −7
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md +1 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md +133 −0
  • internal/directlive/terminal.go +8 −1
  • internal/equipo/copy.go +6 −6
  • internal/tryequipo/testdata/tty-chain/answer.go.txt +60 −0
  • internal/tryequipo/testdata/tty-chain/drive.py +70 −0
  • internal/tryequipo/testdata/tty-chain/live_test.go.txt +17 −0
  • internal/tryequipo/testdata/tty-chain/main.go.txt +5 −0
  • internal/tryequipo/testdata/tty-chain/runner.go.txt +5 −0
  • internal/tryequipo/testdata/tty-chain/wizard.go.txt +27 −0
  • internal/tryequipo/tty_chain_test.go +89 −0

CI cancelled — superseded by a newer push — run details

diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
index 5846b20a..8eee89b9 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-3.md
@@ -5158,6 +5158,7 @@ records to satisfy a gate. Release remains blocked while any row is pending.
| `live.check-allow` | Equipo is checking one-time approval. Type Allow once. | Guided live probe controls | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; live-probe brief) |
| `live.check-question` | Equipo is checking that your answer reaches the agent. Enter an answers JSON object. | Guided live probe controls | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; live-probe brief) |
| `live.answer-retry` | Enter Allow once, Deny, or a valid JSON object. | Guided live control typo retry | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context) |
+| `live.answer-received` | Answer received. | Guided live answer confirmation after validation | COPY REVIEW REQUIRED |
| `CopyCalibrationFunding` | calibration funding is too low; rerun with JobInput=%d JobOutput=%d ProjectInputHeadroom=%d ProjectOutputHeadroom=%d TeamInputHeadroom=%d TeamOutputHeadroom=%d: %w | Direct isolation Round 3 | COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context) |
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md b/docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md
new file mode 100644
index 00000000..1e70074f
--- /dev/null
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-tty-answers.md
@@ -0,0 +1,133 @@
+# Typed terminal answers
+
+Status: incomplete. The reported lost-input failure did not reproduce offline.
+This branch adds process-chain coverage and confirmation after a valid answer;
+it does not claim to fix the cause of Paul's live timeout.
+
+## Reproduction and findings
+
+The committed PTY test runs an interactive bash, the unchanged
+`scripts/try-equipo.sh`, `go run ./cmd/equipo-try`, the real wizard buffered
+prompt, `gateCommand`, the production `liveGateArgs`, `go test`, and the
+production `directlive.Run` / `delegateRunner` handoff. A fixture runner calls
+`exercise.answer`, `answerSource.answer`, and `terminalAnswer` and writes the
+normal person-answer artifacts. Go overlays replace account setup and the
+provider exercise. They add no production bypass and never open account homes.
+
+The feeder waits for each visible prompt and types individual characters and
+Return into a real PTY. It checks allow, deny, structured answers, a typo retry,
+an invalid answer object, and timeout. Valid answers must have person attribution
+in their artifacts. Invalid and expired answers must have no artifact or
+confirmation. The runner also checks that its process group owns the terminal.
+
+Before implementation, an immediate answer and a delayed, character-by-character
+answer both reached the reader through this chain. The missing confirmation,
+not the reported lost input, is the regression that failed on the base.
+
+An additional temporary fixture ran the existing full fake-CLI Engineering
+harness through the wizard and nested `go test`, with its answer callback changed
+to `terminalAnswer`. Both fake providers completed allow, deny and question
+controls, and all six artifacts said `answered_by: person`. The inner gate exited
+successfully in 62.961 seconds. The exploratory outer feeder returned failure
+because it looked for `PASS`, which the successful outer package-mode `go test`
+suppressed. Its transcript instead ended with the provider package's `ok` line.
+The committed feeder checks exit status and explicit fixture completion instead.
+The temporary fake-provider changes were removed.
+
+Read-only inspection of the still-running real chain found the guide, Go tools,
+test binary and runner in foreground process group 329465 on pts/5. The terminal
+had ICANON, ICRNL and ECHO enabled. A later snapshot found no thread blocked in
+read/readv in the guide, Go test, test binary or runner, and no extra terminal
+reader among their session descendants. These are current snapshots, not proof
+of the state when the earlier answer was lost.
+
+The offline evidence therefore does not establish a competing reader, background
+process group, flush race, nonblocking-descriptor problem, canonical-mode problem,
+or Go output-buffering problem as the cause. The prompt uses `/dev/tty` and was
+visible before input despite Go's captured test output. Existing raw-terminal
+and stale-input tests also pass. No speculative process-group or terminal-mode
+change was made.
+
+## Changes
+
+`terminalAnswer` prints `Answer received.` only after reading a complete answer,
+checking the context, and validating the answer against the question. The message
+confirms receipt and validation; it does not claim provider execution or delivery.
+The new catalog entry is individually marked `COPY REVIEW PENDING`. The unused
+old `live.beyond-profile` message was removed. No copy-review server was started,
+and no README was changed.
+
+## Verification
+
+Before implementation:
+
+```
+CGO_ENABLED=0 go test ./internal/tryequipo -run '^TestTerminalAnswerProcessChain$' -count=1 -v
+```
+
+Failed at the second prompt with `missing or premature answer confirmation`.
+The first typed answer had already reached the reader.
+
+After implementation:
+
+```
+CGO_ENABLED=0 go test ./internal/tryequipo ./internal/directlive -run '^Test(TerminalAnswerProcessChain|ControlTerminal|TerminalRetry|TerminalProbe|AnswerSources)' -count=1
+```
+
+Passed: tryequipo 3.574 seconds, directlive 3.200 seconds. This includes the
+existing CR, LF, CRLF, stale-input, typo, deadline and answer-validation checks.
+
+Each mutation below used the process-chain command above. Source was restored
+immediately after each run.
+
+| Deliberate fault | Result |
+| --- | --- |
+| Print confirmation before the prompt | Failed: premature confirmation |
+| Skip terminal answer validation | Failed: invalid object was confirmed |
+| Print confirmation when the read times out | Failed: expired answer was confirmed |
+| Start the gate in a separate background process group | Failed: reader is not in the foreground |
+
+A fifth experiment changed the terminal timeout return to nil without printing
+confirmation. That mutation survived because `answerSource.answer` independently
+checks the expired context and rejects the answer. This is not evidence that the
+terminal timeout return is independently guarded by the end-to-end test.
+
+One full `make -k ci` ran and exited 2. It found two failures introduced by
+this change: the new catalog entry exceeded the app's source budget by one
+line, and the entry was absent from the consolidated copy-review inventory.
+Removing the unused old message fixed the size budget. Adding the pending entry
+to `CONTROLLER-REPORT-plan-3.md` fixed the inventory. No budget was increased
+and no pending copy was marked approved.
+
+The following focused rechecks passed after both corrections:
+
+```
+make budget fmt-check
+CGO_ENABLED=0 go test ./internal/plan3test -run '^TestPlan3ReleaseBoundaries$' -count=1
+CGO_ENABLED=0 go test ./internal/tryequipo ./internal/directlive -run '^Test(TerminalAnswerProcessChain|ControlTerminal|TerminalRetry|TerminalProbe|AnswerSources)' -count=1
+```
+
+Budget: 39 directories within limits. Release-boundary tests: 0.821 seconds.
+Terminal checks: tryequipo 4.278 seconds, directlive 3.139 seconds. The full gate
+was not rerun. Its remaining lanes passed: reference scan, build, vet, formatting,
+staticcheck, vulnerability scan, secret scan, other test packages, adapter and
+namespace tests, migrations and performance. Cold boot median was 119 ms against
+500 ms; every screen was below its 150 ms budget.
+
+The full suite reported timing overruns in runner (343.161 s / 330 s), provider
+(20.777 s / 15 s), Claude (47.291 s / 45 s), and Codex (39.060 s / 35 s). They are
+notes locally and failures under CI timing enforcement. These existing timing
+budgets were not changed. This report does not claim a clean full CI invocation.
+
+## Remaining work
+
+The root cause and a regression that reproduces Paul's actual timeout remain
+unresolved. I asked which terminal he used and how long elapsed between the
+prompt and Return. No answer arrived during this task. A live
+provider rerun was outside this brief's authorization, so none was attempted.
+
+No production account files were changed and no real provider was launched.
+Only read-only process metadata, terminal settings and selected saved evidence
+were inspected. The PTY fixtures clean up their private sessions. Fixture builds and audit
+logs were removed before handoff; no process started by this task remains.
+The user-provided worktree was retained. No merge or deployment was performed.
diff --git a/internal/directlive/terminal.go b/internal/directlive/terminal.go
index 0af53b10..f21f53f3 100644
--- a/internal/directlive/terminal.go
+++ b/internal/directlive/terminal.go
@@ -76,7 +76,14 @@ func terminalAnswer(ctx context.Context, q runnerproto.Question) (runnerproto.Qu
answer.Behavior = "allow"
answer.UpdatedInput = json.RawMessage(text)
}
- return answer, q.ValidateAnswer(answer)
+ 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])
}
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go
index 1416cf8a..46fa8553 100644
--- a/internal/equipo/copy.go
+++ b/internal/equipo/copy.go
@@ -799,12 +799,12 @@ var runnerDraftCopy = map[string]string{
// COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): task.state.proposed
"task.state.proposed": "Proposed",
- "live.check-deny": "Equipo is checking that this is refused. Type Deny.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05, live-probe brief): live.check-deny
- "live.check-allow": "Equipo is checking one-time approval. Type Allow once.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05, live-probe brief): live.check-allow
- "live.check-question": "Equipo is checking that your answer reaches the agent. Enter an answers JSON object.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05, live-probe brief): live.check-question
- "live.answer-retry": "Enter Allow once, Deny, or a valid JSON object.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context)
- "live.answer": "Type Allow once, Deny, or an answers JSON object. This request expires in 60 seconds.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): live.answer
- "live.beyond-profile": "Allow once is recorded as approved beyond profile.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): live.beyond-profile
+ "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-received": "Answer received.", // COPY REVIEW PENDING: live.answer-received
+ "live.answer": "Type Allow once, Deny, or an answers JSON object. This request expires in 60 seconds.", // COPY ACCEPTED FOR NOW (Paul, 2026-11-04; iterate in context): live.answer
// 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/tryequipo/testdata/tty-chain/answer.go.txt b/internal/tryequipo/testdata/tty-chain/answer.go.txt
new file mode 100644
index 00000000..6bb69c36
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/answer.go.txt
@@ -0,0 +1,60 @@
+package directlive
+
+import (
+ "amadan.net/oficina/equipo/internal/runnerproto"
+ "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}}
+ for i, mode := range []string{"allow", "deny", "question", "invalid", "timeout"} {
+ q := runnerproto.Question{ID: mode, Kind: "tool", RawRequest: []byte(`{"direct":true,"provider":"claude","name":"Bash","input":{"command":"printf fixture"}}`)}
+ if mode == "question" || mode == "invalid" {
+ q.Kind = "person"
+ q.RawRequest = []byte(`{"kind":"person","question":"Which case?"}`)
+ }
+ duration := 3 * time.Second
+ if mode == "timeout" {
+ duration = 300 * time.Millisecond
+ }
+ ctx, cancel := context.WithTimeout(context.Background(), duration)
+ x.sequence = i + 1
+ answer, err := x.answer(withControlExpectation(ctx, mode), q)
+ cancel()
+ switch mode {
+ case "invalid":
+ if !errors.Is(err, runnerproto.ErrInvalid) {
+ panic(fmt.Sprint("invalid answer: ", err))
+ }
+ case "timeout":
+ if !errors.Is(err, context.DeadlineExceeded) {
+ panic(fmt.Sprint("timeout: ", err))
+ }
+ default:
+ want := mode
+ if mode == "question" {
+ want = "allow"
+ }
+ if err != nil || answer.Behavior != want {
+ panic(fmt.Sprintf("answer=%+v error=%v", answer, err))
+ }
+ }
+ }
+ fmt.Fprintln(tty, "fixture answers verified")
+}
diff --git a/internal/tryequipo/testdata/tty-chain/drive.py b/internal/tryequipo/testdata/tty-chain/drive.py
new file mode 100644
index 00000000..cd8267ca
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/drive.py
@@ -0,0 +1,70 @@
+import os
+import pty
+import select
+import signal
+import sys
+import time
+
+pid, fd = pty.fork()
+if pid == 0:
+ os.chdir(sys.argv[1])
+ os.execv('/bin/bash', ['bash', '--noprofile', '--norc', '-i'])
+output = b''
+stage = 0
+reaped = False
+status = None
+prompt = b'Type Allow once, Deny,'
+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
+ while time.monotonic() < end:
+ if select.select([fd], [], [], 0.1)[0]:
+ try:
+ data = os.read(fd, 65536)
+ except OSError:
+ break
+ if not data:
+ break
+ output += data
+ if stage == 0 and b'[]: ' in output:
+ os.write(fd, b'RUN LIVE GATE\r')
+ stage = 1
+ if 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 not reaped:
+ done, status = os.waitpid(pid, os.WNOHANG)
+ if done:
+ reaped = True
+ if not reaped:
+ done, status = os.waitpid(pid, os.WNOHANG)
+ reaped = bool(done)
+ if not reaped or os.waitstatus_to_exitcode(status) != 0:
+ raise RuntimeError('process chain did not finish successfully')
+ if b'fixture answers verified' not in output or stage != 6:
+ raise RuntimeError('typed answers never arrived')
+ if output.count(confirmation) != 3:
+ raise RuntimeError('invalid or expired answer was confirmed')
+finally:
+ print(output.decode(errors='replace'))
+ # Kill only descendants in this fixture's private terminal session.
+ for name in os.listdir('/proc'):
+ if name.isdigit():
+ try:
+ if os.getsid(int(name)) == pid:
+ os.kill(int(name), signal.SIGKILL)
+ except (ProcessLookupError, PermissionError):
+ pass
+ if not reaped:
+ os.waitpid(pid, 0)
+ os.close(fd)
diff --git a/internal/tryequipo/testdata/tty-chain/live_test.go.txt b/internal/tryequipo/testdata/tty-chain/live_test.go.txt
new file mode 100644
index 00000000..3d2d882f
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/live_test.go.txt
@@ -0,0 +1,17 @@
+//go:build direct_live
+
+package provider_test
+
+import (
+ "amadan.net/oficina/equipo/internal/directlive"
+ "amadan.net/oficina/equipo/internal/runner/provider"
+ "context"
+ "os"
+ "testing"
+)
+
+func TestDirectLiveContract(t *testing.T) {
+ if err := directlive.Run(context.Background(), provider.DirectLiveConfig{}, []byte("{}"), directlive.Paths{Runner: os.Getenv("EQUIPO_TTY_FIXTURE_RUNNER")}); err != nil {
+ t.Fatal(err)
+ }
+}
diff --git a/internal/tryequipo/testdata/tty-chain/main.go.txt b/internal/tryequipo/testdata/tty-chain/main.go.txt
new file mode 100644
index 00000000..e417db59
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/main.go.txt
@@ -0,0 +1,5 @@
+package main
+
+import "amadan.net/oficina/equipo/internal/tryequipo"
+
+func main() { tryequipo.TTYChainFixture() }
diff --git a/internal/tryequipo/testdata/tty-chain/runner.go.txt b/internal/tryequipo/testdata/tty-chain/runner.go.txt
new file mode 100644
index 00000000..eaa798c7
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/runner.go.txt
@@ -0,0 +1,5 @@
+package main
+
+import "amadan.net/oficina/equipo/internal/directlive"
+
+func main() { directlive.TTYChainFixture() }
diff --git a/internal/tryequipo/testdata/tty-chain/wizard.go.txt b/internal/tryequipo/testdata/tty-chain/wizard.go.txt
new file mode 100644
index 00000000..47d39640
--- /dev/null
+++ b/internal/tryequipo/testdata/tty-chain/wizard.go.txt
@@ -0,0 +1,27 @@
+package tryequipo
+
+import (
+ "context"
+ "fmt"
+ "os"
+ "time"
+)
+
+func TTYChainFixture() {
+ ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
+ defer cancel()
+ w := Wizard{Input: os.Stdin, Output: os.Stdout}
+ w.init()
+ if answer, err := w.ask("live", ""); err != nil || answer != "RUN LIVE GATE" {
+ panic(fmt.Sprint(answer, err))
+ }
+ cwd, err := os.Getwd()
+ if err != nil {
+ panic(err)
+ }
+ out, err := gateCommand(ctx, "go", liveGateArgs(), cwd, os.Environ())
+ fmt.Print(string(out))
+ if err != nil {
+ panic(err)
+ }
+}
diff --git a/internal/tryequipo/tty_chain_test.go b/internal/tryequipo/tty_chain_test.go
new file mode 100644
index 00000000..8c023a44
--- /dev/null
+++ b/internal/tryequipo/tty_chain_test.go
@@ -0,0 +1,89 @@
+package tryequipo
+
+import (
+ "context"
+ "encoding/json"
+ "fmt"
+ "os"
+ "os/exec"
+ "path/filepath"
+ "testing"
+ "time"
+)
+
+// TestTerminalAnswerProcessChain keeps the shell, Go tools, wizard input, and
+// runner delegation real. Overlays replace account setup and the provider work.
+func TestTerminalAnswerProcessChain(t *testing.T) {
+ root, err := filepath.Abs("../..")
+ if err != nil {
+ t.Fatal(err)
+ }
+ scratch := t.TempDir()
+ replacements := map[string]string{}
+ for target, fixture := range map[string]string{
+ "cmd/equipo-try/main.go": "main.go.txt",
+ "internal/tryequipo/tty_fixture.go": "wizard.go.txt",
+ "internal/runner/provider/live_test.go": "live_test.go.txt",
+ "internal/directlive/tty_fixture.go": "answer.go.txt",
+ } {
+ replacements[filepath.Join(root, target)] = filepath.Join(root, "internal/tryequipo/testdata/tty-chain", fixture)
+ }
+ overlay := filepath.Join(scratch, "overlay.json")
+ runner := filepath.Join(scratch, "runner")
+ ctx, cancel := context.WithTimeout(context.Background(), 90*time.Second)
+ defer cancel()
+ main := filepath.Join(root, "cmd/equipo-try/main.go")
+ replacements[main] = filepath.Join(root, "internal/tryequipo/testdata/tty-chain/runner.go.txt")
+ raw, err := json.Marshal(map[string]any{"Replace": replacements})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = os.WriteFile(overlay, raw, 0600); err != nil {
+ t.Fatal(err)
+ }
+ cmd := exec.CommandContext(ctx, "go", "build", "-overlay", overlay, "-o", runner, "./cmd/equipo-try")
+ cmd.Dir = root
+ cmd.Env = append(os.Environ(), "CGO_ENABLED=0", "TMPDIR="+scratch)
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("fixture build: %s %v", out, err)
+ }
+ replacements[main] = filepath.Join(root, "internal/tryequipo/testdata/tty-chain/main.go.txt")
+ raw, err = json.Marshal(map[string]any{"Replace": replacements})
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err = os.WriteFile(overlay, raw, 0600); err != nil {
+ t.Fatal(err)
+ }
+ cmd = exec.CommandContext(ctx, "python3", "testdata/tty-chain/drive.py", root)
+ cmd.Env = append(os.Environ(), "CGO_ENABLED=0", "TMPDIR="+scratch, "GOFLAGS=-overlay="+overlay, "EQUIPO_TTY_FIXTURE_RUNNER="+runner, "EQUIPO_TTY_FIXTURE_EVIDENCE="+scratch)
+ if out, err := cmd.CombinedOutput(); err != nil {
+ t.Fatalf("terminal process chain: %v\n%s", err, out)
+ } else {
+ t.Logf("%s", out)
+ }
+ for i, name := range []string{"allow", "deny", "question"} {
+ raw, err := os.ReadFile(filepath.Join(scratch, fmt.Sprintf("answer-%d-%s.json", i+1, name)))
+ var answer struct {
+ AnsweredBy string `json:"answered_by"`
+ Answer struct {
+ Behavior string `json:"behavior"`
+ } `json:"answer"`
+ }
+ if err != nil || json.Unmarshal(raw, &answer) != nil || answer.AnsweredBy != "person" {
+ t.Fatalf("missing person answer: %s %v", raw, err)
+ }
+ want := name
+ if name == "question" {
+ want = "allow"
+ }
+ if answer.Answer.Behavior != want {
+ t.Fatalf("answer=%s, want %s", raw, want)
+ }
+ }
+ for i, name := range []string{"invalid", "timeout"} {
+ if _, err := os.Stat(filepath.Join(scratch, fmt.Sprintf("answer-%d-%s.json", i+4, name))); !os.IsNotExist(err) {
+ t.Fatalf("invalid answer artifact: %v", err)
+ }
+ }
+}