| index fd5a35d2..f23c1de9 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md |
| @@ -17010,3 +17010,176 @@ No new user-facing prose or copy.go entries. Claude denial replies newly seriali |
| All four round 1 findings are fixed, with no unresolved test failures or new release concerns. The original limits remain: native Codex command/file approvals are deny-only, Task 9 owns runtime composition, and Task 11b owns live provider and deployed-policy certification. No live gate, sign-in, enrolment, real credential-home creation, provider prompt, push, merge or deployment ran. Tests use synthetic fixtures only. The required commit uses the requested subject and author; the controller owns the push. |
| |
| `git diff --check` passed. All test and mutation processes were awaited. No server was started. Session scratch is removed after saving these reports and committing. The task report retains the original report above this appended section. |
| + |
| + |
| +## Task 8 fix round 2: Refuse stale relay calls without invalidating the proxy |
| + |
| +Status: DONE. |
| +Baseline: `67bac31`, branch `plan-2b`. |
| +Commit subject: `fix: refuse stale relay calls without invalidating the proxy`. |
| +All repository work stayed in `/home/paulca/amadan.net/oficina/equipo-plan-2b`. |
| + |
| +### What changed |
| + |
| +Both round 2 findings are fixed. `authorityLocked` now permanently invalidates the broker when `ToolBinding.Current` fails. The capability callback and tool submission path return other validation errors without invalidating the broker. A concurrent binding change or a stale durable turn still refuses the call. Lease expiry, cancellation, recovery and explicit invalidation retain their existing lifecycle checks. |
| + |
| +`TestToolProxyCapabilityConcurrentBind` blocks the capability callback's `Current` check on a real Unix endpoint and binds the next turn before releasing it. It covers initial binding and binding between turns. The in-flight request is refused, the broker remains valid, and a fresh ping through `ServeToolProxy` succeeds. |
| + |
| +`TestDirectToolStaleTurnKeepsProxy` completes the bound turn, refuses a late tool call and verifies that it wrote no journal submission. It then binds, admits and dispatches a new turn, submits a fresh tool call and verifies the journal contains only that submission. |
| + |
| +`TestToolProxyAuthorityLossPermanent` covers both the capability callback and tool submission. Once `Current` fails, later success from that callback cannot revive authority. |
| + |
| +### Files |
| + |
| +- `internal/runner/tool_proxy.go`: move authority-loss invalidation into `authorityLocked`; remove blanket invalidation from the capability callback. |
| +- `internal/runner/tool_socket.go`: remove blanket invalidation from `submit` after `current` refuses a call. |
| +- `internal/runner/tool_proxy_r2_test.go`: concurrent binding, stale-turn continuation and permanent authority-loss regressions. |
| +- `docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md`: this appended evidence section. |
| +- `.superpowers/sdd/2026-11-03-equipo-plan-2b-direct/task-8-report.md`: the same appended section, retaining all earlier reports. This report path is ignored by git and remains available on disk. |
| + |
| +### Interpretations |
| + |
| +The round 2 dispatch supplies the commit subject and narrower covering command, superseding the original Task 8 brief for this fix. Paths in commands are absolute as required; package selection matches the supplied relative covering command. |
| + |
| +A failed `Current` check means authority is lost, regardless of its returned error value. A successful check followed by a changed session, turn or agent is a refused call, not permanent revocation. The same rule applies when durable turn validation refuses a stale call. The capability failure closes that request's connection under the existing `serveTools` contract; the endpoint survives and the next connection succeeds. |
| + |
| +An initial test variant assigned the synthetic state `interrupted`, then tried admitting a new turn. The first green attempt correctly failed with `runner.direct_uncertain`: `BeginTurn` requires prior turns to be completed. That variant was removed rather than weakening admission. The final regression uses a completed stale turn. The baseline was restored, the final tests were observed red again, and implementation, green and every mutation were repeated. Early mutation runs are superseded by the post-green evidence below. |
| + |
| +### RED evidence |
| + |
| +Tests were added before production edits. The initial focused run exited 1 with both requested regressions failing. After correcting the fixture, the final tests were also run against the unchanged production baseline. Exact command: |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run 'TestToolProxyCapabilityConcurrentBind|TestDirectToolStaleTurnKeepsProxy|TestToolProxyAuthorityLossPermanent' -count=1 |
| +``` |
| + |
| +```text |
| +--- FAIL: TestToolProxyCapabilityConcurrentBind (0.18s) |
| + --- FAIL: TestToolProxyCapabilityConcurrentBind/startup (0.09s) |
| + tool_proxy_r2_test.go:67: concurrent BindTurn permanently invalidated proxy |
| + --- FAIL: TestToolProxyCapabilityConcurrentBind/between-turns (0.09s) |
| + tool_proxy_r2_test.go:67: concurrent BindTurn permanently invalidated proxy |
| +--- FAIL: TestDirectToolStaleTurnKeepsProxy (0.09s) |
| + --- FAIL: TestDirectToolStaleTurnKeepsProxy/completed (0.09s) |
| + tool_proxy_r2_test.go:109: stale call disabled next turn: runner.invalid |
| +FAIL |
| +rastrillo-budget/v1 ran 551ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.554s |
| +FAIL |
| +``` |
| + |
| +Exit 1. The code compiled. Startup and between-turn binding invalidated the proxy; the stale call prevented binding the next turn. The authority-loss regression passed on the baseline. |
| + |
| +The discarded fixture failure used the same focused command: |
| + |
| +```text |
| +--- FAIL: TestDirectToolStaleTurnKeepsProxy (0.40s) |
| + --- FAIL: TestDirectToolStaleTurnKeepsProxy/interrupted (0.16s) |
| + tool_proxy_r2_test.go:112: runner.direct_uncertain |
| +FAIL |
| +rastrillo-budget/v1 ran 1.091s |
| +FAIL amadan.net/oficina/equipo/internal/runner 1.095s |
| +FAIL |
| +``` |
| + |
| +### GREEN evidence |
| + |
| +After implementation, the required covering selection passed, exit 0: |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/... -run 'TestToolProxy|TestDirectTool|TestCodexApproval|TestDirectStaleAnswer' -count=1 |
| +``` |
| + |
| +```text |
| +ok amadan.net/oficina/equipo/internal/runner 8.841s |
| +ok amadan.net/oficina/equipo/internal/runner/provider 0.003s [no tests to run] |
| +ok amadan.net/oficina/equipo/internal/runner/provider/claude 0.003s [no tests to run] |
| +ok amadan.net/oficina/equipo/internal/runner/provider/codex 3.186s |
| +``` |
| + |
| +### Compiling mutation evidence |
| + |
| +Each mutation changed only the stated guard, ran its named test, and restored the source before the next mutation. Every mutant compiled and exited 1 with the expected assertion failure. |
| + |
| +#### capability-invalidates-binding |
| + |
| +File: `internal/runner/tool_proxy.go`. Restore `p.broker.invalidateLocked()` inside the capability callback when `authorityLocked` returns an error. |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run '^TestToolProxyCapabilityConcurrentBind$' -count=1 |
| +``` |
| + |
| +```text |
| +--- FAIL: TestToolProxyCapabilityConcurrentBind (0.27s) |
| + --- FAIL: TestToolProxyCapabilityConcurrentBind/startup (0.15s) |
| + tool_proxy_r2_test.go:67: concurrent BindTurn permanently invalidated proxy |
| + --- FAIL: TestToolProxyCapabilityConcurrentBind/between-turns (0.11s) |
| + tool_proxy_r2_test.go:67: concurrent BindTurn permanently invalidated proxy |
| +FAIL |
| +rastrillo-budget/v1 ran 266ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.268s |
| +FAIL |
| +``` |
| + |
| +#### submit-invalidates-stale-turn |
| + |
| +File: `internal/runner/tool_socket.go`. Restore `s.invalidateLocked()` inside `submit` when `s.current(ctx)` returns an error. |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run '^TestDirectToolStaleTurnKeepsProxy$' -count=1 |
| +``` |
| + |
| +```text |
| +--- FAIL: TestDirectToolStaleTurnKeepsProxy (0.15s) |
| + --- FAIL: TestDirectToolStaleTurnKeepsProxy/completed (0.15s) |
| + tool_proxy_r2_test.go:109: stale call disabled next turn: runner.invalid |
| +FAIL |
| +rastrillo-budget/v1 ran 154ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.157s |
| +FAIL |
| +``` |
| + |
| +#### authority-loss-revivable |
| + |
| +File: `internal/runner/tool_proxy.go`. Remove `s.invalidateLocked()` from the `b.Current(ctx)` error branch in `authorityLocked`. |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run '^TestToolProxyAuthorityLossPermanent$' -count=1 |
| +``` |
| + |
| +```text |
| +--- FAIL: TestToolProxyAuthorityLossPermanent (0.17s) |
| + --- FAIL: TestToolProxyAuthorityLossPermanent/capability (0.08s) |
| + tool_proxy_r2_test.go:151: lost authority revived after Current recovered |
| + --- FAIL: TestToolProxyAuthorityLossPermanent/submit (0.09s) |
| + tool_proxy_r2_test.go:151: lost authority revived after Current recovered |
| +FAIL |
| +rastrillo-budget/v1 ran 170ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.174s |
| +FAIL |
| +``` |
| + |
| +### Restored verification |
| + |
| +After restoring all mutations, the same covering command passed again, exit 0: |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/... -run 'TestToolProxy|TestDirectTool|TestCodexApproval|TestDirectStaleAnswer' -count=1 |
| +``` |
| + |
| +```text |
| +ok amadan.net/oficina/equipo/internal/runner 10.206s |
| +ok amadan.net/oficina/equipo/internal/runner/provider 0.002s [no tests to run] |
| +ok amadan.net/oficina/equipo/internal/runner/provider/claude 0.002s [no tests to run] |
| +ok amadan.net/oficina/equipo/internal/runner/provider/codex 3.941s |
| +``` |
| + |
| +`git diff --check` passed. `gofmt -l` returned no paths for the three changed Go files. Only targeted tests ran; no full suite, `make ci`, live provider run, sign-in, enrollment or credential-home creation ran. |
| + |
| +### User-facing strings |
| + |
| +None. No runtime strings or `copy.go` entries were added or changed. Existing pending copy remains unchanged. No copy-review skill or server was invoked. |
| + |
| +### Concerns and completion |
| + |
| +No new concerns or unresolved failures for these two findings. Existing Task 8 limits remain: native Codex command/file approvals are deny-only, Task 9 owns runtime composition, and Task 11b owns live provider and deployed-policy certification. No agents, pushes, merges or deployments were started. Test processes were awaited, and test-owned endpoints and temporary directories were closed and removed. Session scratch under `$TMPDIR/t8r2` is removed after saving this evidence and committing. No session process is intended to outlive this task. |