# Typed terminal answers

Round 1 status: incomplete. The reported lost-input failure did not reproduce offline.
This branch adds process-chain coverage and confirmation after a valid answer;
it does not claim to fix the cause of Paul's live timeout.

## Reproduction and findings

The committed PTY test runs an interactive bash, the unchanged
`scripts/try-equipo.sh`, `go run ./cmd/equipo-try`, the real wizard buffered
prompt, `gateCommand`, the production `liveGateArgs`, `go test`, and the
production `directlive.Run` / `delegateRunner` handoff. A fixture runner calls
`exercise.answer`, `answerSource.answer`, and `terminalAnswer` and writes the
normal person-answer artifacts. Go overlays replace account setup and the
provider exercise. They add no production bypass and never open account homes.

The feeder waits for each visible prompt and types individual characters and
Return into a real PTY. It checks allow, deny, structured answers, a typo retry,
an invalid answer object, and timeout. Valid answers must have person attribution
in their artifacts. Invalid and expired answers must have no artifact or
confirmation. The runner also checks that its process group owns the terminal.

Before implementation, an immediate answer and a delayed, character-by-character
answer both reached the reader through this chain. The missing confirmation,
not the reported lost input, is the regression that failed on the base.

An additional temporary fixture ran the existing full fake-CLI Engineering
harness through the wizard and nested `go test`, with its answer callback changed
to `terminalAnswer`. Both fake providers completed allow, deny and question
controls, and all six artifacts said `answered_by: person`. The inner gate exited
successfully in 62.961 seconds. The exploratory outer feeder returned failure
because it looked for `PASS`, which the successful outer package-mode `go test`
suppressed. Its transcript instead ended with the provider package's `ok` line.
The committed feeder checks exit status and explicit fixture completion instead.
The temporary fake-provider changes were removed.

Read-only inspection of the still-running real chain found the guide, Go tools,
test binary and runner in foreground process group 329465 on pts/5. The terminal
had ICANON, ICRNL and ECHO enabled. A later snapshot found no thread blocked in
read/readv in the guide, Go test, test binary or runner, and no extra terminal
reader among their session descendants. These are current snapshots, not proof
of the state when the earlier answer was lost.

The offline evidence therefore does not establish a competing reader, background
process group, flush race, nonblocking-descriptor problem, canonical-mode problem,
or Go output-buffering problem as the cause. The prompt uses `/dev/tty` and was
visible before input despite Go's captured test output. Existing raw-terminal
and stale-input tests also pass. No speculative process-group or terminal-mode
change was made.

## Changes

`terminalAnswer` prints `Answer received.` only after reading a complete answer,
checking the context, and validating the answer against the question. The message
confirms receipt and validation; it does not claim provider execution or delivery.
The new catalog entry is individually marked `COPY REVIEW PENDING`. The unused
old `live.beyond-profile` message was removed. No copy-review server was started,
and no README was changed.

## Verification

Before implementation:

```
CGO_ENABLED=0 go test ./internal/tryequipo -run '^TestTerminalAnswerProcessChain$' -count=1 -v
```

Failed at the second prompt with `missing or premature answer confirmation`.
The first typed answer had already reached the reader.

After implementation:

```
CGO_ENABLED=0 go test ./internal/tryequipo ./internal/directlive -run '^Test(TerminalAnswerProcessChain|ControlTerminal|TerminalRetry|TerminalProbe|AnswerSources)' -count=1
```

Passed: tryequipo 3.574 seconds, directlive 3.200 seconds. This includes the
existing CR, LF, CRLF, stale-input, typo, deadline and answer-validation checks.

Each mutation below used the process-chain command above. Source was restored
immediately after each run.

| Deliberate fault | Result |
| --- | --- |
| Print confirmation before the prompt | Failed: premature confirmation |
| Skip terminal answer validation | Failed: invalid object was confirmed |
| Print confirmation when the read times out | Failed: expired answer was confirmed |
| Start the gate in a separate background process group | Failed: reader is not in the foreground |

A fifth experiment changed the terminal timeout return to nil without printing
confirmation. That mutation survived because `answerSource.answer` independently
checks the expired context and rejects the answer. This is not evidence that the
terminal timeout return is independently guarded by the end-to-end test.

One full `make -k ci` ran and exited 2. It found two failures introduced by
this change: the new catalog entry exceeded the app's source budget by one
line, and the entry was absent from the consolidated copy-review inventory.
Removing the unused old message fixed the size budget. Adding the pending entry
to `CONTROLLER-REPORT-plan-3.md` fixed the inventory. No budget was increased
and no pending copy was marked approved.

The following focused rechecks passed after both corrections:

```
make budget fmt-check
CGO_ENABLED=0 go test ./internal/plan3test -run '^TestPlan3ReleaseBoundaries$' -count=1
CGO_ENABLED=0 go test ./internal/tryequipo ./internal/directlive -run '^Test(TerminalAnswerProcessChain|ControlTerminal|TerminalRetry|TerminalProbe|AnswerSources)' -count=1
```

Budget: 39 directories within limits. Release-boundary tests: 0.821 seconds.
Terminal checks: tryequipo 4.278 seconds, directlive 3.139 seconds. The full gate
was not rerun. Its remaining lanes passed: reference scan, build, vet, formatting,
staticcheck, vulnerability scan, secret scan, other test packages, adapter and
namespace tests, migrations and performance. Cold boot median was 119 ms against
500 ms; every screen was below its 150 ms budget.

The full suite reported timing overruns in runner (343.161 s / 330 s), provider
(20.777 s / 15 s), Claude (47.291 s / 45 s), and Codex (39.060 s / 35 s). They are
notes locally and failures under CI timing enforcement. These existing timing
budgets were not changed. This report does not claim a clean full CI invocation.

## Remaining work

The root cause and a regression that reproduces Paul's actual timeout remain
unresolved. I asked which terminal he used and how long elapsed between the
prompt and Return. No answer arrived during this task. A live
provider rerun was outside this brief's authorization, so none was attempted.

No production account files were changed and no real provider was launched.
Only read-only process metadata, terminal settings and selected saved evidence
were inspected. The PTY fixtures clean up their private sessions. Fixture builds and audit
logs were removed before handoff; no process started by this task remains.
The user-provided worktree was retained. No merge or deployment was performed.

## Round 2

The round-two brief replaces the request to diagnose the earlier lost-input
report with changes to timing, person-proof retries and proposed funding. These
changes are verified offline. They do not establish the cause of that live run's
lost-input report.

### Timing and retry

Person answer sources now allow five minutes; automatic sources still allow one
minute. The terminal reader uses the source's context, removing its separate
60-second limit. Earlier cancellation and the authorized run deadline still win.
The default run deadline remains 7,200 seconds. Provider tool deadlines are ten
minutes: Claude's explicit settings contain `MCP_TOOL_TIMEOUT=600000`, and Codex's
Equipo MCP settings contain `tool_timeout_sec=600`. Both settings are included in
the existing policy hashes and validation. Codex's policy serializer now handles
integer TOML values. No provider binary was launched to inspect these options;
the installed binaries were read for the setting names.

The terminal prints `The request expired. This check will be retried or failed.`
once on deadline expiry. `Answer received.` remains after validation only. The
prompt now says five minutes. All three entries are individually marked
`COPY ACCEPTED FOR NOW (Paul, 2026-11-05; iterate in context)` under the brief's
2026-11-04/05 ruling. The consolidated inventory and its acceptance check include
them. No copy-review server was started and README prose is unchanged.

The driver no longer consumes a provider's person-proof opportunity when choosing
a tuple. After completing a tuple, it validates the saved person proof before
switching later tuples to automatic answers. A failed tuple, invalid proof or
missing answer leaves the next specialist eligible. Coordinator and recovery
workers remain automatic. Certification still requires a passing person-answered
tuple for each provider; earlier failures remain failures in the run report.

The new fake-CLI driver scenario uses both providers and four specialist tuples:
Review expires, Engineering returns an invalid answer, Copy passes with person
answers, and Design uses automatic answers. It checks saved proof, attribution,
answer counts and the four retained tuple failures. Existing successful-run
coverage still checks that later tuples do not prompt again.

### Funding arithmetic

Evidence was read only from
`/home/paulca/.local/share/equipo/try/run-4024280761/evidence` on 2026-11-05.
The run was still accumulating evidence. The calculation below uses the observed
snapshot; unfinished tuples are estimates, not zero usage or certified results.

For rows with `23-reservations-per-job.json`, the needs are 23 times that file's
input and output reservations. For Claude Engineering and Coordinator, the same
formula is applied to the completed `turn-*.json` usage frames, including cache
creation and cache reads. Codex's completed token-usage frames use the `last`
input/output counts. Each reservation is twice the largest sample, rounded up
to the next 1,000 tokens, then multiplied by 23.

| Tuple | Input need | Output need |
| --- | ---: | ---: |
| Claude Engineering | 17,986,000 | 184,000 |
| Claude Engineering-reproduction | 14,375,000 | 184,000 |
| Claude Review | 11,040,000 | 161,000 |
| Claude Product | 11,270,000 | 161,000 |
| Claude Scope | 11,684,000 | 184,000 |
| Claude Research | 11,247,000 | 161,000 |
| Claude Investigation | 9,568,000 | 161,000 |
| Claude Copy | 11,546,000 | 184,000 |
| Claude Design | 18,308,000 | 184,000 |
| Claude Coordinator | 414,000 | 23,000 |
| Codex Engineering, partial | 437,000 | 23,000 |
| Codex Engineering-reproduction, partial | 391,000 | 23,000 |
| Observed sum | 118,266,000 | 1,633,000 |

The maximum input need is 18,308,000. Three times that is 54,924,000, rounded
up to 60,000,000 for JobInput and both input headrooms. The maximum output need
is 184,000; three times that is 552,000. JobOutput and both output headrooms
retain the required 1,150,000 floor.

For the full 19-tuple family, the seven missing tuples and both partial Codex
rows are provisioned at the largest observed need, 18,308,000 input and 184,000
output. The Claude row sums are 117,438,000 input and 1,587,000 output. The full
bounds are `(117,438,000 + 9 × 18,308,000) × 3 = 846,630,000` input and
`(1,587,000 + 9 × 184,000) × 3 = 9,729,000` output. The proposed calibration
bounds are 900,000,000 input, rounded up to the next 100 million, and the existing
16,000,000 output. These conservative reservation sums are bounds, not predicted
spend. They exceed the observed charged totals as well as the measured usage sums.

The old 11,500,000 input, 1,150,000 output, 100,000,000 total input and 16,000,000
total output defaults are in the re-propose lists. The output proposals currently
remain the same. Custom values remain selected, and the person must authorize the
displayed limits before any live run.

### Verification

Before implementation, the focused tests failed for the one-minute person limit,
missing expiry notice, missing provider tool deadlines and old funding bounds.
`TestControlSourcesRetryUntilPass` failed with
`Engineering lost person retry: automatic`. The first full fake-driver attempt
also caught the shortened person deadline. A later development run caught missing
integer TOML support; that serializer correction is included above.

The combined driver run passed in 211.320 seconds, including both
`TestPersonProofRetryFakeCLI` and `TestFewerPromptsFakeCLI`. That invocation also
found the missing inventory row for the changed prompt; the row was added and
the inventory check passed on rerun.

After restoring all deliberate faults, this focused command passed:

```sh
CGO_ENABLED=0 go test ./internal/directlive ./internal/tryequipo ./internal/runner/provider/claude ./internal/runner/provider/codex ./internal/plan3test -run '^Test(ControlSources|PersonAnswerHasFiveMinutes|AnswerSources|TerminalAnswerProcessChain|FundingProposedDefaults|PersonControlProviderTimeout|Plan3ReleaseBoundaries)' -count=1
```

Times: directlive 0.113 s, tryequipo 3.830 s, Claude 0.223 s, Codex 0.207 s,
plan3test 0.785 s. The five-minute source test uses Go's virtual clock; expiry is
also checked through the real terminal process chain with a shortened parent
context. No test sleeps for five minutes.

Each mutation below failed, then its source was restored. Each command starts
with `CGO_ENABLED=0 go test`, ends with `-count=1`, and uses the listed package
and `-run` selector.

| Deliberate fault | Package and selector | Observed failure |
| --- | --- | --- |
| Person limit back to one minute | `./internal/directlive -run '^TestPersonAnswerHasFiveMinutes$'` | Person expired after 1m, wanted 5m |
| Automatic limit raised to five minutes | Same command | Automatic expired after 5m, wanted 1m |
| Consume proof when selecting a tuple | `./internal/directlive -run '^TestControlSourcesRetryUntilPass$'` | Engineering lost person retry |
| Suppress deadline notice | `./internal/tryequipo -run '^TestTerminalAnswerProcessChain$'` | Missing expiry notice |
| Claude MCP timeout back to 60 seconds | `./internal/runner/provider/claude -run '^TestPersonControlProviderTimeout$'` | Provider tool timeout must exceed five minutes |
| Codex MCP timeout back to 60 seconds | Same selector in `./internal/runner/provider/codex` | Provider tool timeout must exceed five minutes |
| Input job/headroom proposals back to 11.5 million | `./internal/tryequipo -run '^TestFundingProposedDefaults$'` | Funding mismatch |
| Omit 11.5 million from the legacy list | Same command | Saved round-one funding was retained |

`make budget` passed for all 39 directories. A blank line beside the changed
catalog entries was removed to keep the existing 10,800-line source ceiling;
no budget was increased. `git diff --check` passed.


The provider timeout settings change policy fingerprints. This offline work does
not issue a certificate for either real provider; a separately authorized live
run must collect fresh evidence. No existing production evidence or account file
was modified. No merge, default-branch push or deployment was performed.

The first full `CGO_ENABLED=0 make -k ci` exited 2. Besides the formatting issue,
it found two stale policy-inventory tests and an existing PTY reap race. All
18 portable inventory hashes were updated to match the timeout settings; every
entry remains `uncertified`, and the certificate lists remain empty. The PTY
feeder now waits for the child after terminal closure, within the original
three-second deadline. Previously it could read `PASS`, receive terminal EOF,
then fail because a nonblocking wait had not yet reaped the child.

The focused correction check passed:

```sh
CGO_ENABLED=0 go test ./internal/directlive ./internal/release -run '^Test(MergedPlanPolicyInventory|PlanWorkflowReleasePolicyInventory|TerminalRetryDeadlineAndValidObject)$' -count=1
make fmt-check budget
```

Directlive took 0.899 s; release took 0.004 s. The first full run's remaining
lanes passed, including adapter/namespace tests, migrations and performance.
Cold boot was 103 ms against 500 ms; every screen was within 150 ms. It reported
existing timing-budget overruns in runner (357.469 s / 330 s), provider
(20.710 s / 15 s), Claude (46.596 s / 45 s), and Codex (39.045 s / 35 s). These
are local notes and become failures with CI timing enforcement. The new full
directlive suite took 318.087 s against its unchanged 360 s ceiling.

One permitted full rerun of `CGO_ENABLED=0 make -k ci` exited 0. All 29 test
packages passed, along with build, vet, formatting, staticcheck, vulnerability
and secret scans, size budgets, adapters, namespaces, migrations and performance.
Directlive took 324.969 s against 360 s, including the retry regression. Cold boot
was 101 ms; all screen checks stayed below 150 ms.

The rerun retained timing warnings: runner 358.634 s / 330 s, provider 20.616 s /
15 s, Claude 46.095 s / 45 s, Codex 38.686 s / 35 s, and tryequipo 11.503 s /
10 s. The command passed locally; these overruns would fail with CI timing
enforcement. No timing budget was raised. There were two full gate invocations
in total, with no second rerun.

Task scratch and logs were removed after their results were recorded here.
All task test processes exited. The user-provided worktree remains in place.

## Round 3

Every live-gate control now uses the automatic answer source, including the first
specialist tuple of each provider, later tuples and recovery workers. Answers
retain the existing relay, validation and one-minute automatic deadline, bounded
by the run deadline, and record `answered_by: "automatic"`.

The terminal answer reader had no other production caller. It and its person
source, proof retries, proof artifacts and unused copy entries were removed.
The candidate builder, Go evidence code and Python release checker no longer
require `person-answered-controls`. No substitute requirement was added.
All existing per-tuple control requirements remain in
`internal/runner/provider/direct_requirements.json`, unchanged.

The guide now says answers are automatic and real tasks are approved in Equipo's
app or API. Its sign-in, account totals, limits and RUN LIVE GATE confirmations
remain. The two guide sentences use the brief's accepted-copy ruling. No
copy-review server was started; README prose and production account files were
not changed. All provider exercises used offline fixtures.

### Reproduction and focused verification

Before implementation, these commands failed:

```sh
CGO_ENABLED=0 go test ./internal/directlive ./internal/equipotest -run '^(TestEveryControlSourceAutomatic|TestCandidateAcceptsAutomaticControls|TestDirectReleaseRequiresCertification/release/clean)$' -count=1
CGO_ENABLED=0 go test ./internal/equipotest -run '^TestDirectReleaseRequiresCertification$/^release$/^clean$' -count=1
```

The source-selection test reported person answers for every initial specialist.
The candidate builder rejected evidence without person proof. The Python release
checker rejected the clean packaging fixture after its person proof was removed.
The combined command selected the first two tests; its packaging pattern matched
no tests, so the separate command above was run.

The process-chain test still runs the real shell, guide, wizard prompt, Go test
command, `directlive.Run` and runner delegation. Its feeder types only RUN LIVE
GATE. Automatic allow, deny and structured answers must arrive with automatic
attribution; invalid and expired answers must leave no answer artifact.

```sh
CGO_ENABLED=0 go test ./internal/directlive -run '^TestAutomaticControlsFakeCLI$' -count=1 -v
```

Passed in 73.193 seconds. Both fake providers completed Review and Engineering
through the production relay. Every answer artifact had automatic attribution;
all seven control observations passed for all four tuples.

The focused suite also covers automatic source selection and fallback, validation,
deadlines, candidate acceptance, missing/failed/tampered per-tuple controls,
release packaging, routing approvals and the copy inventory. Early verification
found remaining test-only references to the removed driver callback, unstaged
file deletions in the packaging fixture's tracked-file copy, and an exclusive
create in the candidate mutation fixture. These were corrected before CI.

### Mutation verification

Each command below uses `CGO_ENABLED=0 go test`, the package and `-run` pattern
shown, and `-count=1`. Each deliberate fault failed its test, then the source was
restored.

| Deliberate fault | Package and pattern | Observed failure |
| --- | --- | --- |
| Record the automatic source as person | `./internal/directlive -run '^TestEveryControlSourceAutomatic$'` | Wrong attribution |
| Skip answer validation | `./internal/directlive -run '^TestAnswerSourcesShareValidationAndDeadline$'` | Invalid answer accepted |
| Read after context expiry | Same command | Expired source read an answer |
| Accept an answer returned after expiry | `./internal/directlive -run '^TestAutomaticAnswerDeadline$'` | Deadline error missing |
| Extend the automatic timeout to two minutes | Same command | Wrong elapsed duration |
| Remove all seven control requirements | `./internal/directlive ./internal/equipotest -run '^(TestCandidateRequiresEveryControl|TestReleaseRequiresEveryControl)$'` | All 21 candidate cases and all 28 packaging cases failed |

The last mutation removed the requirements only from a temporary edit of
`direct_requirements.json`. Candidate tests independently removed, failed or
changed the hash of each control. Packaging tests independently removed or failed
each control for both release targets. The requirement file was restored byte
for byte; no weakened requirements remain.


After restoring the mutations, this focused command passed:

```sh
CGO_ENABLED=0 go test ./internal/directlive ./internal/equipotest ./internal/tryequipo ./internal/plan3test -run '^(TestEveryControlSourceAutomatic|TestAnswerSourcesShareValidationAndDeadline|TestAutomaticAnswerDeadline|TestCandidate.*|TestCoordinatorManifestExclusion|TestAutomaticAnswerProcessChain|TestReleaseRequiresEveryControl|TestDirectReleaseRequiresCertification|TestPlan3ReleaseBoundaries|TestRouting.*|TestProbeAnswersWithoutHuman)$' -count=1
```

Directlive: 0.739 s; equipotest: 6.854 s; tryequipo: 1.437 s; plan3test: 0.882 s.

### Full CI

The first `make -k ci` found formatting in `internal/equipo/copy.go` after the
unused entries were removed, and 13,217 equipotest lines against its existing
13,200-line limit. Formatting was corrected. The new packaging cases were folded
into the existing release table, and candidate/packaging control-failure setup
was shared in `providertest`. The test now runs those cases under
`TestDirectReleaseRequiresCertification`; no cases or size budgets were removed
or raised.

The first invocation exited 2. Its 29 test packages passed. Adapter, namespace,
migration and performance checks passed too; cold boot was 104 ms against 500 ms,
and all screens stayed below 150 ms. Timing warnings were runner 332.696 s / 330 s,
provider 20.949 s / 15 s, Claude 48.461 s / 45 s and Codex 40.706 s / 35 s.
These are warnings locally and failures under CI timing enforcement.

After sharing the fixtures, removing the seven requirements again failed every
candidate case and every control case for both release targets. This used:

```sh
CGO_ENABLED=0 go test ./internal/directlive ./internal/equipotest -run '^(TestCandidateRequiresEveryControl|TestDirectReleaseRequiresCertification)$' -count=1
```

The source was restored. `make budget fmt-check` passed with all 39 directories
within budget, and the same focused test command passed on the restored source.

The single rerun of `make -k ci` exited 0. All 29 test packages, build, vet,
formatting, staticcheck, vulnerability scan, secret scan, size budgets, adapter
checks, namespaces, migrations and performance passed. Directlive took 251.692 s
against its 360 s budget. Cold boot was 105 ms; every screen stayed below 150 ms.

Four timing warnings remain: runner 330.526 s / 330 s, provider 20.680 s / 15 s,
Claude 47.598 s / 45 s and Codex 38.976 s / 35 s. The local command passed; these
warnings would fail under CI timing enforcement. No timing budget was raised.
There were two full CI invocations in total, with one rerun.

No live provider gate, copy-review server, merge or deployment was started.
The user-provided worktree is retained. Test processes exited; task scratch and
logs are removed after recording their results in this report.
