feat: allow once for native Codex approvals with a profile label
22 files changed,
+3,094
−37
docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md+1,936 −0internal/equipo/copy.go+2 −0internal/equipo/questions.go+50 −0internal/equipo/runner_execution.go+1 −0internal/equipo/team/approval_profile_test.go+40 −0internal/equipo/team/git_evidence.go+9 −7internal/equipo/team/profile_approval.go+50 −0internal/equipo/templates/task_card.html+1 −1internal/equipotest/approval_once_test.go+140 −0internal/runner/approval_once_test.go+189 −0internal/runner/direct_questions.go+48 −5internal/runner/direct_workflow.go+33 −15internal/runner/forge/approval_profile_test.go+31 −0internal/runner/forge/publisher.go+5 −0internal/runner/provider/codex/answers.go+29 −4internal/runner/provider/codex/approval_once_test.go+296 −0internal/runner/provider/codex/events.go+9 −5internal/runner/provider/codex/launcher.go+23 −0internal/runner/provider/codex/native_approval.go+138 −0internal/runner/provider/types.go+1 −0internal/runner/questions.go+18 −0internal/runnerproto/questions.go+45 −0
CI failed — run details
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md| index ca530c4f..86fbf78c 100644 |
| --- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md |
| +++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md |
| @@ -19106,3 +19106,1939 @@ No new `copy.go` entries or app-owned UI prose were added, so there are no new p |
| - The new workflow-level lease-loss tests and retained namespace parent-death/direct-journal tests divide the crash coverage across boundaries. The fake CLI graph is not a live provider certification. |
| The task remains on `plan-2b`. No agent or subagent was spawned, no other worktree was changed, and no `.claude/HANDOFF.md` was created. The controller performs the review and push. |
| + |
| + |
| +## Task 8b: Native Codex approvals, 2026-11-03 |
| + |
| +Status: DONE_WITH_CONCERNS. |
| +Branch: `plan-2b`, starting at `532e867`. |
| +Commit subject: `feat: allow once for native Codex approvals with a profile label`. |
| +Author: `codex <codex~paul@keymail.dev>`. |
| +All repository work stayed in `/home/paulca/amadan.net/oficina/equipo-plan-2b`. |
| + |
| +### What changed |
| + |
| +A person can allow one native Codex command or file change. The scriptless form has exactly two decision buttons for a supported, bounded request: **Allow once** and **Deny**. Provider-advertised session approvals, permanent policy changes and amendments are never decision controls and are never sent. Modern approvals send only `decision: accept`; legacy approvals send only `decision: approved`. Modern denial remains `decision: decline`. The legacy denial shape is the pinned `denied` object. An unsupported or inherently persistent request cannot be allowed. |
| + |
| +The adapter retains the numeric or string JSON server request ID, local turn, provider turn, session and original frame. File approvals also retain the matching `item/started` frame, including every path, move target and diff. The item is checked again before the response is reserved. A completed, missing or changed item cannot be approved. The final response check rejects a request resolved while the authorization callback was running. An answer is consumed once before I/O. A new request ID for the same command requires another person answer. Commands are not parsed and rebuilt: modern command strings and legacy argv/cwd stay as Codex sent them. |
| + |
| +The runner obtains the allowing person from the authenticated instance answer API. Immediately before delivery it requires the same answer, person, task, attempt, fence, revision, session, request and payload. A missing answer now fails closed; the old current check allowed an answer to disappear after revocation. At the instance, the existing verified-session Actor and transaction-local roster check remain authoritative. Form fields cannot select the actor or inject approval options. |
| + |
| +The runner records a `profile-approval` entry in `journal_supervisor`, atomically with the pending `journal_answers` intent and `direct_answer_scopes`. It contains the full safe question request, item frame and the instance's `AnsweredBy`. The test checks this record before provider I/O. The allowing person is part of the native answer's idempotency hash. A failed journal insert rolls back before fencing the journal; it sends no provider response and cannot leave a partial answer transaction. A revoked final native authorization returns an error rather than being acknowledged as delivered. Existing Equipo MCP rejection behavior remains unchanged. |
| + |
| +The instance persists a `ProfileApproval` in the assignment's existing isolation JSON when the person authorizes it. The record contains the original request, correlated file item where applicable, request/item/provider-turn/session IDs, question ID, verified person's address and label. Existing questions and audit rows remain the answer history. The instance already has the exact safe request before the answer, and receives the normal delivery resolution afterward. No new application table or migration is needed; old snapshots remain readable because the new JSON field is optional. |
| + |
| +Profile approvals merge through the same isolation history used for trial and unconfined evidence. They reach existing artifacts and events for the step, later artifact provenance, independent review, and publication descriptions. Evidence containment refuses a snapshot that strips an approval. The shared isolation-label template renders the label on the task-card header, Journey step chip and task-detail history. HTTP assertions locate those surfaces separately. The publisher refuses a description missing a label required by the authorization, and the publication test checks the description actually written to the fake forge. |
| + |
| +An approval does not change the isolation status, taint the runner, replace its certification tuple or authorize a later launch. The Codex response changes only that one inner decision. No containment or namespace implementation changed. Tests snapshot the full launch policy, including hash, manifest, mounts, settings and network policy. Mutations that change its hash, manifest, mounts or network policy fail those assertions. |
| + |
| +Claude's adapter required no change. It already responds to the original permission request with allow/deny. Its permission regression tests passed. The strengthened shared current-answer check also protects direct person-answer delivery without changing Claude's response format. |
| + |
| +### Interpretations |
| + |
| +1. Paul's follow-up supersedes Task 8's former deny-only native Codex rule. The follow-up also supersedes generic copy-review, subagent and handoff workflows. No copy-review skill/server, provider drafter, subagent or `.claude/HANDOFF.md` was used or created. |
| +2. The installed `codex-cli 0.165.0` generated its JSON schemas locally with `codex app-server generate-json-schema --out /home/paulca/t/e2b/t8b/schema`. This was an offline schema operation, not a provider session. The modern methods and pinned legacy `execCommandApproval` and `applyPatchApproval` are supported. Legacy frames omit a turn ID, so they are accepted only while the adapter has an active, known provider turn; that turn is captured separately and checked through delivery. Modern commands are strings; the implementation does not invent argv for them. Legacy argv is preserved as an array. |
| +3. The pinned `grantRoot` description says it grants writes for the remainder of the session. Such a request remains unapprovable even if a caller asks for ordinary allow. There is no proven one-request interpretation for it. Commands missing command/cwd, file approvals without the exact live item, `writeStdin` requests without a bounded command shape, and unknown methods also remain deny-only. This exception to two available choices follows the instruction to refuse persistent authority and unsupported shapes. |
| +4. Proposed exec/network policy amendments may be present in the original request as evidence. They are never selected, reflected into a response or installed. An answer with any updated input or persistent decision spelling is refused. |
| +5. Secret redaction remains mandatory. If sanitization changes a request or correlated item, the runner refuses to authorize the unseen original bytes. This preserves exact-action consent without persisting credentials. JSON object key order may change during storage; number spelling, string values, argv order, cwd, paths and diffs are preserved. Provider-to-relay correlation also checks the captured frame bytes. |
| +6. The label is conservative authorization history, recorded before the action could execute. It is not proof that Codex executed the action successfully. Revocation or uncertain delivery does not erase the person's historical authorization or remove the label from evidence. A later identical action still needs a new answer. This follows the existing historical isolation-label mechanism. |
| +7. The runner's approval evidence uses existing FULL-synchronous journal transactions. The instance's evidence uses its existing answer transaction. No broad policy flag or new authority-bearing database column was added. |
| + |
| +### Files |
| + |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team/approval_profile_test.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team/profile_approval.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest/approval_once_test.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/approval_once_test.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/forge/approval_profile_test.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/approval_once_test.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/copy.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/questions.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/runner_execution.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team/git_evidence.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/templates/task_card.html` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_questions.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_workflow.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/forge/publisher.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/events.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/launcher.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/types.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/questions.go` |
| +- `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runnerproto/questions.go` |
| + |
| +The controller section is appended to `docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md`. The full task report is saved at `.superpowers/sdd/2026-11-03-equipo-plan-2b-direct/task-8b-report.md`; that directory is already ignored, as for the preceding task reports. |
| + |
| +### RED evidence |
| + |
| +The initial approval, HTTP and publication tests were added before the primary implementation. They compiled and failed on the deny-only behavior and missing evidence. Further current-answer, publisher, root-grant and delivery regressions were observed red before their fixes. The current-answer predicate was extracted without changing its behavior before its stale-answer regression was run. |
| + |
| +#### Initial native approval, HTTP and provenance tests |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team -run 'TestCodexApprovalAllowOnce|TestCodexApprovalPersistentRefused|TestApprovedBeyondProfile|TestDirectStaleAnswerNative' -count=1 |
| +``` |
| + |
| +Exit 1; compiled. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAllowOnce (0.84s) |
| + --- FAIL: TestCodexApprovalAllowOnce/item/commandExecution/requestApproval (0.45s) |
| + approval_once_test.go:42: allow once refused provider_policy_rejected |
| + --- FAIL: TestCodexApprovalAllowOnce/item/fileChange/requestApproval (0.39s) |
| + approval_once_test.go:42: allow once refused provider_policy_rejected |
| +FAIL |
| +rastrillo-budget/v1 ran 1.248s |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 1.251s |
| +--- FAIL: TestApprovedBeyondProfileHTTP (4.09s) |
| + approval_once_test.go:32: native approval must have exactly Allow once and Deny |
| +--- FAIL: TestDirectStaleAnswerNativeRevocation (0.46s) |
| + approval_once_test.go:52: One or more values are invalid. Check the form and try again. |
| +FAIL |
| +rastrillo-budget/v1 ran 4.558s |
| +FAIL amadan.net/oficina/equipo/internal/equipotest 4.619s |
| +--- FAIL: TestApprovedBeyondProfilePublication (0.22s) |
| + approval_profile_test.go:22: publication lost approved profile evidence {"version":1,"target":{"kind":"repository","repository":"example/shop","ref":"team/fix-sum","default_ref":"main","base_revision":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},"label":"unconfined","isolation":{"status":"unconfined","runner_tainted":true,"acknowledgement_ids":["ack-1"],"observed_tuples":[{"provider":"provider-a","provider_version":"1","paseo_version":"0.14.0" [excerpt truncated] |
| +FAIL |
| +rastrillo-budget/v1 ran 225ms |
| +FAIL amadan.net/oficina/equipo/internal/equipo/team 0.228s |
| +FAIL |
| +``` |
| + |
| +#### Current answer disappears or changes |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestDirectStaleAnswerNativeCurrent -count=1 |
| +``` |
| + |
| +Exit 1; compiled. |
| + |
| +```text |
| +--- FAIL: TestDirectStaleAnswerNativeCurrent (0.00s) |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/removed (0.00s) |
| + approval_once_test.go:33: stale answer accepted removed |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/person (0.00s) |
| + approval_once_test.go:33: stale answer accepted person |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/payload (0.00s) |
| + approval_once_test.go:33: stale answer accepted payload |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/answer (0.00s) |
| + approval_once_test.go:33: stale answer accepted answer |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/fence (0.00s) |
| + approval_once_test.go:33: stale answer accepted fence |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/attempt (0.00s) |
| + approval_once_test.go:33: stale answer accepted attempt |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/task (0.00s) |
| + approval_once_test.go:33: stale answer accepted task |
| +FAIL |
| +rastrillo-budget/v1 ran 0s |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.003s |
| +FAIL |
| +``` |
| + |
| +#### Pinned legacy native approvals |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalLegacyOnce -count=1 |
| +``` |
| + |
| +Exit 1; compiled. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalLegacyOnce (0.87s) |
| + --- FAIL: TestCodexApprovalLegacyOnce/execCommandApproval (0.43s) |
| + approval_once_test.go:74: pinned legacy request not relayed codex_protocol_rejected |
| + --- FAIL: TestCodexApprovalLegacyOnce/applyPatchApproval (0.44s) |
| + approval_once_test.go:74: pinned legacy request not relayed codex_protocol_rejected |
| +FAIL |
| +rastrillo-budget/v1 ran 873ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.875s |
| +FAIL |
| +``` |
| + |
| +#### Publisher loses the required label |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/forge -run TestApprovedBeyondProfilePublisher -count=1 |
| +``` |
| + |
| +Exit 1; compiled. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfilePublisher (0.02s) |
| + approval_profile_test.go:21: publisher lost profile label guard unconfined <nil> |
| +FAIL |
| +rastrillo-budget/v1 ran 16ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/forge 0.018s |
| +FAIL |
| +``` |
| + |
| +#### Persistent file root grant |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalRootGrantRefused -count=1 |
| +``` |
| + |
| +Exit 1; compiled. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalRootGrantRefused (0.24s) |
| + approval_once_test.go:190: session root grant accepted |
| +FAIL |
| +rastrillo-budget/v1 ran 238ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.240s |
| +FAIL |
| +``` |
| + |
| +#### Journal failure and late revocation |
| + |
| +```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/codex -run 'TestCodexApprovalJournalWriteFailure|TestCodexApprovalAuthorizationRefused' -count=1 |
| +``` |
| + |
| +Exit 1; compiled. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalWriteFailure (1.16s) |
| + approval_once_test.go:179: journal failure waited for the request deadline instead of releasing the write transaction |
| +FAIL |
| +rastrillo-budget/v1 ran 1.167s |
| +FAIL amadan.net/oficina/equipo/internal/runner 1.174s |
| +--- FAIL: TestCodexApprovalAuthorizationRefused (0.21s) |
| + approval_once_test.go:273: revoked authorization reported as delivered |
| +FAIL |
| +rastrillo-budget/v1 ran 207ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.208s |
| +FAIL |
| +``` |
| + |
| +### GREEN evidence |
| + |
| +The full covering selection passed after the implementation and the first 48 restored mutations. It includes the requested selection, independent-review/publication checks, Claude permission regressions, policy checks and the offline direct bug workflow. No full suite or `make ci` ran. |
| + |
| +```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/... /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/forge /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runnerproto -run 'TestCodexApproval|TestDirectStaleAnswer|TestToolProxy|TestDirectTool|TestQuestion|TestApprovedBeyondProfile|TestTask|TestJourney|TestPublish|TestClaudePermission|TestDirectBugWorkflow|TestCodexAppServerPolicy|TestCodexPolicyHashIncludesRPC' -count=1 |
| +``` |
| + |
| +Exit 0. |
| + |
| +```text |
| +ok amadan.net/oficina/equipo/internal/runner 75.676s |
| +ok amadan.net/oficina/equipo/internal/runner/provider 0.003s [no tests to run] |
| +ok amadan.net/oficina/equipo/internal/runner/provider/claude 1.032s |
| +ok amadan.net/oficina/equipo/internal/runner/provider/codex 8.319s |
| +ok amadan.net/oficina/equipo/internal/equipotest 58.766s |
| +ok amadan.net/oficina/equipo/internal/equipo 0.898s |
| +ok amadan.net/oficina/equipo/internal/equipo/team 1.463s |
| +ok amadan.net/oficina/equipo/internal/runner/forge 6.348s |
| +? amadan.net/oficina/equipo/internal/runnerproto [no test files] |
| +``` |
| + |
| +The last change strengthened only HTTP assertions so each display surface is checked independently. The three additional template mutations failed their named assertions. After restoring them, all new instance label tests passed: |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest -run TestApprovedBeyondProfile -count=1 |
| +``` |
| + |
| +Exit 0. |
| + |
| +```text |
| +ok amadan.net/oficina/equipo/internal/equipotest 4.136s |
| +``` |
| + |
| +### Compiling mutation evidence |
| + |
| +Each mutation was applied alone, tested, and restored in a `finally` block before the next mutation. All 51 final mutations compiled and exited 1 with a named test failure. Commands below are shell equivalents of the exact `go test` argv and `CGO_ENABLED=0` environment used by the harness. No compilation failure counts as evidence. |
| + |
| +Two initial mutation-harness attempts matched the older MCP comparison instead of the native comparison. Their native tests passed, so those attempts were rejected as evidence. The targets were narrowed to the native block and the same named tests then failed. Only the corrected results appear below. No failed mutation remained in the source. |
| + |
| +#### 1. native-allow-disabled |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +_, nativeErr := NativeApproval(ev) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +_, nativeErr := NativeApproval(ev) |
| + nativeErr = provider.ErrPolicy |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalAllowOnce -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAllowOnce (0.35s) |
| + --- FAIL: TestCodexApprovalAllowOnce/item/commandExecution/requestApproval (0.18s) |
| + approval_once_test.go:51: allow once refused provider_policy_rejected |
| + --- FAIL: TestCodexApprovalAllowOnce/item/fileChange/requestApproval (0.17s) |
| + approval_once_test.go:51: allow once refused provider_policy_rejected |
| +FAIL |
| +rastrillo-budget/v1 ran 348ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.351s |
| +FAIL |
| +``` |
| + |
| +#### 2. persistent-behavior-admitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +} else if a.Behavior != "deny" { |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +} else if false { |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalPersistentRefused -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalPersistentRefused (0.14s) |
| + approval_once_test.go:76: persistent option accepted acceptForSession |
| +FAIL |
| +rastrillo-budget/v1 ran 141ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.146s |
| +FAIL |
| +``` |
| + |
| +#### 3. amendment-input-admitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +if len(a.Input) != 0 { |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +if false { |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalPersistentRefused -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalPersistentRefused (0.14s) |
| + approval_once_test.go:81: amendment accepted {"decision":"acceptForSession"} |
| +FAIL |
| +rastrillo-budget/v1 ran 139ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.142s |
| +FAIL |
| +``` |
| + |
| +#### 4. persistent-wire-decision |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +decision = "accept" |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +decision = "acceptForSession" |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalAllowOnce -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAllowOnce (0.27s) |
| + --- FAIL: TestCodexApprovalAllowOnce/item/commandExecution/requestApproval (0.13s) |
| + approval_once_test.go:55: broader or wrong response: {"id":7,"result":{"decision":"acceptForSession"}} |
| + --- FAIL: TestCodexApprovalAllowOnce/item/fileChange/requestApproval (0.13s) |
| + approval_once_test.go:55: broader or wrong response: {"id":7,"result":{"decision":"acceptForSession"}} |
| +FAIL |
| +rastrillo-budget/v1 ran 267ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.269s |
| +FAIL |
| +``` |
| + |
| +#### 5. request-replayed |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +delete(s.requests, a.RequestID) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +// mutation: keep request |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalAllowOnce -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAllowOnce (0.29s) |
| + --- FAIL: TestCodexApprovalAllowOnce/item/commandExecution/requestApproval (0.16s) |
| + approval_once_test.go:61: request replay approved |
| + --- FAIL: TestCodexApprovalAllowOnce/item/fileChange/requestApproval (0.13s) |
| + approval_once_test.go:61: request replay approved |
| +FAIL |
| +rastrillo-budget/v1 ran 289ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.291s |
| +FAIL |
| +``` |
| + |
| +#### 6. resolved-request-accepted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +if !present || !bytes.Equal(current.Payload, ev.Payload) || !bytes.Equal(current.ToolCall, ev.ToolCall) { |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +_ = current; _ = present |
| + if false { |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalResolvedDuringAuthorization -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalResolvedDuringAuthorization (0.13s) |
| + approval_once_test.go:171: resolved request approved |
| +FAIL |
| +rastrillo-budget/v1 ran 133ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.135s |
| +FAIL |
| +``` |
| + |
| +#### 7. file-item-revalidation-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +if a.Behavior == "allow" && v.Method == "item/fileChange/requestApproval" { |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +if false { |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalFileCorrelation -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalFileCorrelation (0.80s) |
| + --- FAIL: TestCodexApprovalFileCorrelation/completed (0.13s) |
| + approval_once_test.go:150: changed file item approved completed |
| + --- FAIL: TestCodexApprovalFileCorrelation/changed (0.13s) |
| + approval_once_test.go:150: changed file item approved changed |
| + --- FAIL: TestCodexApprovalFileCorrelation/missing (0.13s) |
| + approval_once_test.go:150: changed file item approved missing |
| + --- FAIL: TestCodexApprovalFileCorrelation/wrong-item (0.13s) |
| + approval_once_test.go:150: changed file item approved wrong-item |
| + --- FAIL: TestCodexApprovalFileCorrelation/wrong-turn (0.13s) |
| + approval_once_test.go:150: changed file item approved wrong-turn |
| + --- FAIL: TestCodexApprovalFileCorrelation/wrong-session (0.13s) |
| + approval_once_test.go:150: changed file item approved wrong-session |
| +FAIL |
| +rastrillo-budget/v1 ran 798ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.800s |
| +FAIL |
| +``` |
| + |
| +#### 8. deny-becomes-accept |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +decision := "decline" |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +decision := "accept" |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalPersistentRefused -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalPersistentRefused (0.14s) |
| + approval_once_test.go:93: deny changed |
| +FAIL |
| +rastrillo-budget/v1 ran 137ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.138s |
| +FAIL |
| +``` |
| + |
| +#### 9. native-id-type-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +string(v.ID) != ev.RequestID |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.26s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/commandExecution/requestApproval/id (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted id |
| + --- FAIL: TestCodexApprovalNativeShape/item/fileChange/requestApproval/id (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted id |
| +FAIL |
| +rastrillo-budget/v1 ran 264ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.265s |
| +FAIL |
| +``` |
| + |
| +#### 10. native-session-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +p.ThreadID != ev.SessionID |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.26s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/commandExecution/requestApproval/session (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted session |
| + --- FAIL: TestCodexApprovalNativeShape/item/fileChange/requestApproval/session (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted session |
| +FAIL |
| +rastrillo-budget/v1 ran 262ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.264s |
| +FAIL |
| +``` |
| + |
| +#### 11. native-turn-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +(ev.ProviderTurnID != "" && ev.ProviderTurnID != p.TurnID) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.26s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/commandExecution/requestApproval/provider-turn (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted provider-turn |
| + --- FAIL: TestCodexApprovalNativeShape/item/fileChange/requestApproval/provider-turn (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted provider-turn |
| +FAIL |
| +rastrillo-budget/v1 ran 265ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.267s |
| +FAIL |
| +``` |
| + |
| +#### 12. native-item-required-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +p.ItemID == "" |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.27s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/commandExecution/requestApproval/item (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted item |
| +FAIL |
| +rastrillo-budget/v1 ran 265ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.267s |
| +FAIL |
| +``` |
| + |
| +#### 13. native-command-required-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +p.Command == "" |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.26s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/commandExecution/requestApproval/command (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted command |
| +FAIL |
| +rastrillo-budget/v1 ran 265ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.266s |
| +FAIL |
| +``` |
| + |
| +#### 14. native-cwd-required-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +p.Cwd == "" |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.26s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/commandExecution/requestApproval/cwd (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted cwd |
| +FAIL |
| +rastrillo-budget/v1 ran 263ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.265s |
| +FAIL |
| +``` |
| + |
| +#### 15. file-path-required-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +change.Path == "" |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.27s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/fileChange/requestApproval/file-path (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted file-path |
| +FAIL |
| +rastrillo-budget/v1 ran 267ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.270s |
| +FAIL |
| +``` |
| + |
| +#### 16. file-diff-required-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +change.Diff == nil |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.26s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/fileChange/requestApproval/file-diff (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted file-diff |
| +FAIL |
| +rastrillo-budget/v1 ran 262ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.264s |
| +FAIL |
| +``` |
| + |
| +#### 17. file-item-correlation-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +c.Item.ID != p.ItemID |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.26s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/fileChange/requestApproval/file-item (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted file-item |
| +FAIL |
| +rastrillo-budget/v1 ran 263ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.264s |
| +FAIL |
| +``` |
| + |
| +#### 18. file-turn-correlation-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +c.TurnID != p.TurnID |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.26s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/fileChange/requestApproval/file-turn (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted file-turn |
| +FAIL |
| +rastrillo-budget/v1 ran 263ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.264s |
| +FAIL |
| +``` |
| + |
| +#### 19. file-session-correlation-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +c.ThreadID != p.ThreadID |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalNativeShape -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalNativeShape (0.28s) |
| + --- FAIL: TestCodexApprovalNativeShape/item/fileChange/requestApproval/file-session (0.00s) |
| + approval_once_test.go:261: incomplete or mismatched native action accepted file-session |
| +FAIL |
| +rastrillo-budget/v1 ran 283ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.285s |
| +FAIL |
| +``` |
| + |
| +#### 20. persistent-root-admitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/native_approval.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +p.GrantRoot != "" |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalRootGrantRefused -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalRootGrantRefused (0.14s) |
| + approval_once_test.go:194: session root grant accepted |
| +FAIL |
| +rastrillo-budget/v1 ran 143ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.145s |
| +FAIL |
| +``` |
| + |
| +#### 21. relay-request-id-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +original.RequestID != ev.RequestID || !bytes.Equal(original.Payload, ev.Payload) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false || !bytes.Equal(original.Payload, ev.Payload) |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestCodexApprovalJournalAndExactRequest/id -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalAndExactRequest (0.10s) |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/id (0.10s) |
| + approval_once_test.go:131: changed or revoked request approved id |
| +FAIL |
| +rastrillo-budget/v1 ran 101ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.104s |
| +FAIL |
| +``` |
| + |
| +#### 22. relay-turn-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +original.TurnID != ev.TurnID || original.ProviderTurnID |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false || original.ProviderTurnID |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestCodexApprovalJournalAndExactRequest/turn -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalAndExactRequest (0.10s) |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/turn (0.10s) |
| + approval_once_test.go:131: changed or revoked request approved turn |
| +FAIL |
| +rastrillo-budget/v1 ran 104ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.107s |
| +FAIL |
| +``` |
| + |
| +#### 23. relay-session-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +original.SessionID != ev.SessionID || original.TurnID != ev.TurnID || original.ProviderTurnID |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false || original.TurnID != ev.TurnID || original.ProviderTurnID |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestCodexApprovalJournalAndExactRequest/session -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalAndExactRequest (0.11s) |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/session (0.11s) |
| + approval_once_test.go:131: changed or revoked request approved session |
| +FAIL |
| +rastrillo-budget/v1 ran 112ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.115s |
| +FAIL |
| +``` |
| + |
| +#### 24. relay-payload-binding-skipped |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +original.ProviderTurnID != ev.ProviderTurnID || original.RequestID != ev.RequestID || !bytes.Equal(original.Payload, ev.Payload) || !bytes.Equal(original.ToolCall, ev.ToolCall) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +original.ProviderTurnID != ev.ProviderTurnID || original.RequestID != ev.RequestID || false || !bytes.Equal(original.ToolCall, ev.ToolCall) |
| +``` |
| + |
| +Changed: |
| + |
| +```text |
| +!runnerproto.SameRequestJSON(original.Payload, saved.Request) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run 'TestCodexApprovalJournalAndExactRequest/(item|command|cwd)' -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalAndExactRequest (0.32s) |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/item (0.11s) |
| + approval_once_test.go:131: changed or revoked request approved item |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/command (0.11s) |
| + approval_once_test.go:131: changed or revoked request approved command |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/cwd (0.10s) |
| + approval_once_test.go:131: changed or revoked request approved cwd |
| +FAIL |
| +rastrillo-budget/v1 ran 321ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.324s |
| +FAIL |
| +``` |
| + |
| +#### 25. redacted-payload-approved |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +!runnerproto.SameRequestJSON(original.Payload, saved.Request) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestCodexApprovalJournalAndExactRequest/redacted -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalAndExactRequest (0.10s) |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/redacted (0.10s) |
| + approval_once_test.go:131: changed or revoked request approved redacted |
| +FAIL |
| +rastrillo-budget/v1 ran 103ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.105s |
| +FAIL |
| +``` |
| + |
| +#### 26. delivery-revocation-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +if err != nil || deadline.IsZero() || !time.Now().Before(deadline) { |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +_ = deadline; _ = err |
| + if false { |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestCodexApprovalJournalAndExactRequest/revoked -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalAndExactRequest (0.11s) |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/revoked (0.11s) |
| + approval_once_test.go:131: changed or revoked request approved revoked |
| +FAIL |
| +rastrillo-budget/v1 ran 107ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.110s |
| +FAIL |
| +``` |
| + |
| +#### 27. missing-current-answer-accepted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_workflow.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +if q.Answer != nil { |
| + return runnerproto.Question{}, provider.ErrIdentity |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +if false { |
| + return runnerproto.Question{}, provider.ErrIdentity |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestDirectStaleAnswerNativeCurrent/removed -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestDirectStaleAnswerNativeCurrent (0.00s) |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/removed (0.00s) |
| + approval_once_test.go:46: stale answer accepted removed |
| +FAIL |
| +rastrillo-budget/v1 ran 0s |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.002s |
| +FAIL |
| +``` |
| + |
| +#### 28. current-person-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_workflow.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +(q.AnsweredBy != "" && saved.AnsweredBy != q.AnsweredBy) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestDirectStaleAnswerNativeCurrent/person -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestDirectStaleAnswerNativeCurrent (0.00s) |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/person (0.00s) |
| + approval_once_test.go:46: stale answer accepted person |
| +FAIL |
| +rastrillo-budget/v1 ran 0s |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.005s |
| +FAIL |
| +``` |
| + |
| +#### 29. current-payload-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_workflow.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +!runnerproto.SameRequestJSON(saved.RawRequest, q.RawRequest) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestDirectStaleAnswerNativeCurrent/payload -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestDirectStaleAnswerNativeCurrent (0.00s) |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/payload (0.00s) |
| + approval_once_test.go:46: stale answer accepted payload |
| +FAIL |
| +rastrillo-budget/v1 ran 0s |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.003s |
| +FAIL |
| +``` |
| + |
| +#### 30. current-answer-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_workflow.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +runnerproto.EventHash(saved.Answer) != runnerproto.EventHash(q.Answer) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestDirectStaleAnswerNativeCurrent/answer -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestDirectStaleAnswerNativeCurrent (0.00s) |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/answer (0.00s) |
| + approval_once_test.go:46: stale answer accepted answer |
| +FAIL |
| +rastrillo-budget/v1 ran 0s |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.003s |
| +FAIL |
| +``` |
| + |
| +#### 31. current-fence-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_workflow.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +saved.Fence != q.Fence |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestDirectStaleAnswerNativeCurrent/fence -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestDirectStaleAnswerNativeCurrent (0.00s) |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/fence (0.00s) |
| + approval_once_test.go:46: stale answer accepted fence |
| +FAIL |
| +rastrillo-budget/v1 ran 0s |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.002s |
| +FAIL |
| +``` |
| + |
| +#### 32. current-attempt-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_workflow.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +saved.Attempt != q.Attempt |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestDirectStaleAnswerNativeCurrent/attempt -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestDirectStaleAnswerNativeCurrent (0.00s) |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/attempt (0.00s) |
| + approval_once_test.go:46: stale answer accepted attempt |
| +FAIL |
| +rastrillo-budget/v1 ran 0s |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.003s |
| +FAIL |
| +``` |
| + |
| +#### 33. current-task-ignored |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/direct_workflow.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +saved.TaskID != q.TaskID |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestDirectStaleAnswerNativeCurrent/task -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestDirectStaleAnswerNativeCurrent (0.00s) |
| + --- FAIL: TestDirectStaleAnswerNativeCurrent/task (0.00s) |
| + approval_once_test.go:46: stale answer accepted task |
| +FAIL |
| +rastrillo-budget/v1 ran 0s |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.003s |
| +FAIL |
| +``` |
| + |
| +#### 34. journal-evidence-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +nativeErr == nil && answer.Behavior == "allow" |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +nativeErr == nil && false |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestCodexApprovalJournalAndExactRequest/none -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalAndExactRequest (0.11s) |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/none (0.11s) |
| + approval_once_test.go:93: approval was not durable before provider I/O |
| +FAIL |
| +rastrillo-budget/v1 ran 113ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.116s |
| +FAIL |
| +``` |
| + |
| +#### 35. journal-actor-unbound |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +hash = runnerproto.EventHash([]any{q.ID, q.Revision, q.RawRequest, answer, q.AnsweredBy}) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +hash = runnerproto.EventHash([]any{q.ID, q.Revision, q.RawRequest, answer}) |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestCodexApprovalJournalAndExactRequest/none -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalAndExactRequest (0.14s) |
| + --- FAIL: TestCodexApprovalJournalAndExactRequest/none (0.14s) |
| + approval_once_test.go:155: changed allowing person replay accepted |
| +FAIL |
| +rastrillo-budget/v1 ran 141ms |
| +FAIL amadan.net/oficina/equipo/internal/runner 0.144s |
| +FAIL |
| +``` |
| + |
| +#### 36. instance-evidence-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +if err := recordProfileApproval(tx, q.AssignmentID, approval); err != nil { |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +_ = approval |
| + if err := error(nil); err != nil { |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest -run TestApprovedBeyondProfileHTTP -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfileHTTP (3.45s) |
| + approval_once_test.go:60: assignment missing approval evidence {"status":"confined","runner_tainted":true,"acknowledgement_ids":["MZ6SM5H2YFX2A2EETDKKATDDKP"],"observed_tuples":[{"provider":"claude","provider_version":"2.1.312","paseo_version":"0.14.0","isolation_config_hash":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"},{"provider":"codex","provider_version":"0.165.0","paseo_version":"0.14.0","isolation_config_hash":"aa [excerpt truncated] |
| +FAIL |
| +rastrillo-budget/v1 ran 3.446s |
| +FAIL amadan.net/oficina/equipo/internal/equipotest 3.486s |
| +FAIL |
| +``` |
| + |
| +#### 37. instance-actor-forged |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +Person: member.Address, Label: copyText("isolation.approved_beyond_profile") |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +Person: "forged", Label: copyText("isolation.approved_beyond_profile") |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest -run TestApprovedBeyondProfileHTTP -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfileHTTP (3.46s) |
| + approval_once_test.go:60: assignment missing approval evidence {"profile_approvals":[{"question_id":"native","request_id":"7","item_id":"item","turn_id":"provider-turn","session_id":"session","person":"forged","label":"approved beyond profile","request":{"id":7,"method":"item/commandExecution/requestApproval","params":{"command":"printf hello","cwd":"/workspace","itemId":"item","threadId":"session","turnId":"provider-turn"}}}],"status":"confi [excerpt truncated] |
| +FAIL |
| +rastrillo-budget/v1 ran 3.462s |
| +FAIL amadan.net/oficina/equipo/internal/equipotest 3.507s |
| +FAIL |
| +``` |
| + |
| +#### 38. lineage-approval-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team/git_evidence.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +a.ProfileApprovals = MergeProfileApprovals(a.ProfileApprovals, b.ProfileApprovals) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +// mutation: lose inherited approvals |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team -run TestApprovedBeyondProfilePublication -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfilePublication (0.08s) |
| + approval_profile_test.go:24: unexpected: team: evidence: publication_evidence_invalid |
| +FAIL |
| +rastrillo-budget/v1 ran 81ms |
| +FAIL amadan.net/oficina/equipo/internal/equipo/team 0.085s |
| +FAIL |
| +``` |
| + |
| +#### 39. instance-merge-approval-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/runner_execution.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +a.ProfileApprovals = team.MergeProfileApprovals(a.ProfileApprovals, b.ProfileApprovals) |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +// mutation: lose task history |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest -run TestApprovedBeyondProfileHTTP -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfileHTTP (3.46s) |
| + approval_once_test.go:65: task card or Journey chip lost label /journey |
| +FAIL |
| +rastrillo-budget/v1 ran 3.46s |
| +FAIL amadan.net/oficina/equipo/internal/equipotest 3.502s |
| +FAIL |
| +``` |
| + |
| +#### 40. stripped-evidence-accepted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team/git_evidence.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +!profileApprovalsContain(have.ProfileApprovals, need.ProfileApprovals) || |
| +``` |
| + |
| +To: |
| + |
| +```text |
| + |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/team -run TestApprovedBeyondProfilePublication -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfilePublication (0.07s) |
| + approval_profile_test.go:38: label stripping accepted |
| +FAIL |
| +rastrillo-budget/v1 ran 71ms |
| +FAIL amadan.net/oficina/equipo/internal/equipo/team 0.073s |
| +FAIL |
| +``` |
| + |
| +#### 41. task-label-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/templates/task_card.html`. |
| + |
| +Changed: |
| + |
| +```text |
| +{{if .ProfileApprovals}}<span equipo-isolation>{{copy "isolation.approved_beyond_profile"}}</span>{{end}} |
| +``` |
| + |
| +To: |
| + |
| +```text |
| + |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest -run TestApprovedBeyondProfileHTTP -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfileHTTP (3.46s) |
| + approval_once_test.go:65: task card or Journey chip lost label /journey |
| +FAIL |
| +rastrillo-budget/v1 ran 3.457s |
| +FAIL amadan.net/oficina/equipo/internal/equipotest 3.497s |
| +FAIL |
| +``` |
| + |
| +#### 42. publisher-label-guard-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/forge/publisher.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +if !strings.Contains(v.Description, approval.Label) { |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +_ = approval |
| + if false { |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/forge -run TestApprovedBeyondProfilePublisher -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfilePublisher (0.02s) |
| + approval_profile_test.go:23: publisher lost profile label guard unconfined <nil> |
| +FAIL |
| +rastrillo-budget/v1 ran 18ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/forge 0.020s |
| +FAIL |
| +``` |
| + |
| +#### 43. approval-mutates-hash |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +// Reserve the one response before I/O. |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +s.launch.Policy.Hash = "changed" |
| + // Reserve the one response before I/O. |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalAllowOnce -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAllowOnce (0.29s) |
| + --- FAIL: TestCodexApprovalAllowOnce/item/commandExecution/requestApproval (0.14s) |
| + approval_once_test.go:65: policy hash, manifest, network or namespace mounts changed |
| + --- FAIL: TestCodexApprovalAllowOnce/item/fileChange/requestApproval (0.14s) |
| + approval_once_test.go:65: policy hash, manifest, network or namespace mounts changed |
| +FAIL |
| +rastrillo-budget/v1 ran 286ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.287s |
| +FAIL |
| +``` |
| + |
| +#### 44. approval-mutates-manifest |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +// Reserve the one response before I/O. |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +s.launch.Policy.Manifest = json.RawMessage(`{}`) |
| + // Reserve the one response before I/O. |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalAllowOnce -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAllowOnce (0.28s) |
| + --- FAIL: TestCodexApprovalAllowOnce/item/commandExecution/requestApproval (0.14s) |
| + approval_once_test.go:65: policy hash, manifest, network or namespace mounts changed |
| + --- FAIL: TestCodexApprovalAllowOnce/item/fileChange/requestApproval (0.14s) |
| + approval_once_test.go:65: policy hash, manifest, network or namespace mounts changed |
| +FAIL |
| +rastrillo-budget/v1 ran 279ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.281s |
| +FAIL |
| +``` |
| + |
| +#### 45. approval-mutates-mounts |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +// Reserve the one response before I/O. |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +s.launch.Policy.Mounts = append(s.launch.Policy.Mounts, provider.Mount{Source:"/",Target:"/host"}) |
| + // Reserve the one response before I/O. |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalAllowOnce -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAllowOnce (0.27s) |
| + --- FAIL: TestCodexApprovalAllowOnce/item/commandExecution/requestApproval (0.14s) |
| + approval_once_test.go:65: policy hash, manifest, network or namespace mounts changed |
| + --- FAIL: TestCodexApprovalAllowOnce/item/fileChange/requestApproval (0.13s) |
| + approval_once_test.go:65: policy hash, manifest, network or namespace mounts changed |
| +FAIL |
| +rastrillo-budget/v1 ran 268ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.270s |
| +FAIL |
| +``` |
| + |
| +#### 46. approval-mutates-network |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +// Reserve the one response before I/O. |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +s.launch.Policy.ThreadPolicy = json.RawMessage(`{"networkAccess":true}`) |
| + // Reserve the one response before I/O. |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalAllowOnce -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAllowOnce (0.26s) |
| + --- FAIL: TestCodexApprovalAllowOnce/item/commandExecution/requestApproval (0.13s) |
| + approval_once_test.go:65: policy hash, manifest, network or namespace mounts changed |
| + --- FAIL: TestCodexApprovalAllowOnce/item/fileChange/requestApproval (0.13s) |
| + approval_once_test.go:65: policy hash, manifest, network or namespace mounts changed |
| +FAIL |
| +rastrillo-budget/v1 ran 264ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.266s |
| +FAIL |
| +``` |
| + |
| +#### 47. journal-rollback-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/questions.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +"INSERT INTO journal_supervisor(kind,state_key,body) VALUES('profile-approval',?,?)", key, raw); err != nil { |
| + tx.Rollback() |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +"INSERT INTO journal_supervisor(kind,state_key,body) VALUES('profile-approval',?,?)", key, raw); err != nil { |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner -run TestCodexApprovalJournalWriteFailure -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalJournalWriteFailure (1.09s) |
| + approval_once_test.go:179: journal failure waited for the request deadline instead of releasing the write transaction |
| +FAIL |
| +rastrillo-budget/v1 ran 1.087s |
| +FAIL amadan.net/oficina/equipo/internal/runner 1.090s |
| +FAIL |
| +``` |
| + |
| +#### 48. revoked-native-reported-delivered |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex/answers.go`. |
| + |
| +Changed: |
| + |
| +```text |
| +if nativeErr == nil { |
| + return e |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +if false { |
| + return e |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/runner/provider/codex -run TestCodexApprovalAuthorizationRefused -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestCodexApprovalAuthorizationRefused (0.13s) |
| + approval_once_test.go:273: revoked authorization reported as delivered |
| +FAIL |
| +rastrillo-budget/v1 ran 134ms |
| +FAIL amadan.net/oficina/equipo/internal/runner/provider/codex 0.135s |
| +FAIL |
| +``` |
| + |
| +#### 49. task-card-header-label-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/templates/task_card.html`. |
| + |
| +Changed: |
| + |
| +```text |
| +{{end}}{{template "trial-label" .Isolation}}</div> |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +{{end}}</div> |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest -run TestApprovedBeyondProfileHTTP -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfileHTTP (3.44s) |
| + approval_once_test.go:76: task card header lost label /journey |
| +FAIL |
| +rastrillo-budget/v1 ran 3.444s |
| +FAIL amadan.net/oficina/equipo/internal/equipotest 3.485s |
| +FAIL |
| +``` |
| + |
| +#### 50. journey-step-label-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/templates/task_card.html`. |
| + |
| +Changed: |
| + |
| +```text |
| +{{end}}{{template "trial-label" .Isolation}}</li> |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +{{end}}</li> |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest -run TestApprovedBeyondProfileHTTP -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfileHTTP (3.45s) |
| + approval_once_test.go:79: Journey step chip lost label /journey |
| +FAIL |
| +rastrillo-budget/v1 ran 3.449s |
| +FAIL amadan.net/oficina/equipo/internal/equipotest 3.490s |
| +FAIL |
| +``` |
| + |
| +#### 51. task-detail-label-omitted |
| + |
| +File: `/home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipo/templates/task.html`. |
| + |
| +Changed: |
| + |
| +```text |
| +{{define "isolation-history"}}{{template "trial-label" .}} |
| +``` |
| + |
| +To: |
| + |
| +```text |
| +{{define "isolation-history"}} |
| +``` |
| + |
| +```sh |
| +CGO_ENABLED=0 go test /home/paulca/amadan.net/oficina/equipo-plan-2b/internal/equipotest -run TestApprovedBeyondProfileHTTP -count=1 |
| +``` |
| + |
| +Exit 1; compiled; restored. |
| + |
| +```text |
| +--- FAIL: TestApprovedBeyondProfileHTTP (3.45s) |
| + approval_once_test.go:84: task detail lost label |
| +FAIL |
| +rastrillo-budget/v1 ran 3.454s |
| +FAIL amadan.net/oficina/equipo/internal/equipotest 3.496s |
| +FAIL |
| +``` |
| + |
| +### User-facing strings |
| + |
| +- New: `isolation.approved_beyond_profile` = `approved beyond profile`, in `internal/equipo/copy.go`, individually marked `COPY REVIEW REQUIRED`. |
| +- Reused unchanged: `question.allow_once` = `Allow once`, already individually marked `COPY REVIEW REQUIRED` in `copy.go`. |
| +- Reused unchanged: the existing Deny copy and scriptless question form. |
| + |
| +No other runtime copy was added. The label enters persisted provenance from `copy.go` and is retained in the published description. No stylesheet, vendored theme or README changed. Existing day-theme label markup is used; no coloured left-border accents were introduced. |
| + |
| +### Verification, concerns and handback |
| + |
| +`git diff --check` passed. `gofmt -l` returned no changed Go files. The exact supplied commit subject is 64 characters. Only this task's files and this appended controller section are staged. The original report and Task 9 work remain unchanged. |
| + |
| +Copy review remains a release requirement. No live provider, account sign-in, machine enrollment or real credential-home creation was performed. Existing offline fixtures use synthetic provider data and local fake CLIs. A response is evidence of scoped consent and transport, not proof of a live provider's effects. Task 11b still owns deployed-policy and live-provider certification. Persistent root grants and unsupported action shapes remain refused as described above. |
| + |
| +All test processes were awaited. Test-owned HTTP servers and fixture processes use their existing cleanup hooks. Session scratch is confined to `/home/paulca/t/e2b/t8b` and will be removed after the report and commit are saved. Go caches remained at their defaults, and every build/test used `CGO_ENABLED=0`. No merge, push, deployment, server intended to outlive the task, subagent or change in another worktree occurred. |
diff --git a/internal/equipo/copy.go b/internal/equipo/copy.go| index d322da95..0d5a13f5 100644 |
| --- a/internal/equipo/copy.go |
| +++ b/internal/equipo/copy.go |
| @@ -201,6 +201,8 @@ func RunnerToolCopy() runner.ToolCopy { |
| // runnerDraftCopy is the Task 16 runtime inventory. Each entry needs review. |
| var runnerDraftCopy = map[string]string{ |
| + // COPY REVIEW REQUIRED: isolation.approved_beyond_profile |
| + "isolation.approved_beyond_profile": "approved beyond profile", |
| // COPY REVIEW REQUIRED: trial.label |
| "trial.label": "supervised trial", |
| // COPY REVIEW REQUIRED: trial.off |
diff --git a/internal/equipo/questions.go b/internal/equipo/questions.go| index 194afd85..43717e70 100644 |
| --- a/internal/equipo/questions.go |
| +++ b/internal/equipo/questions.go |
| @@ -199,6 +199,12 @@ func (s *Store) answerQuestion(ctx context.Context, actor Actor, taskID, id stri |
| if err := tx.Model(&questionRecord{}).Where("id=?", id).Select("State", "Answer", "AnsweredBy").Updates(&q).Error; err != nil { |
| return storeError(err) |
| } |
| + if native, err := value.NativeApproval(); err == nil && answer.Behavior == "allow" { |
| + approval := team.ProfileApproval{QuestionID: q.ID, RequestID: native.RequestID, ItemID: native.ItemID, TurnID: native.TurnID, SessionID: native.SessionID, Person: member.Address, Label: copyText("isolation.approved_beyond_profile"), Request: native.Request, ToolCall: native.ToolCall} |
| + if err := recordProfileApproval(tx, q.AssignmentID, approval); err != nil { |
| + return err |
| + } |
| + } |
| return appendAudit(tx, actor, "question.answer", id) |
| }) |
| } |
| @@ -287,3 +293,47 @@ func (e *Execution) resolveQuestion(ctx context.Context, tx *gorm.DB, a runnerAs |
| func questionAnswerAllowed(member Member, task Task) bool { |
| return member.Active && (member.Address == task.Requester || member.Role == RoleOwner) |
| } |
| + |
| +func recordProfileApproval(tx *gorm.DB, id string, approval team.ProfileApproval) error { |
| + var a runnerAssignment |
| + if err := tx.First(&a, "id=?", id).Error; err != nil { |
| + return storeError(err) |
| + } |
| + value, err := assignmentValue(a) |
| + if err != nil { |
| + return err |
| + } |
| + iso := value.Selection.Isolation |
| + iso.ProfileApprovals = team.MergeProfileApprovals(iso.ProfileApprovals, []team.ProfileApproval{approval}) |
| + raw, err := json.Marshal(iso) |
| + if err != nil { |
| + return err |
| + } |
| + if err = tx.Model(&runnerAssignment{}).Where("id=?", id).Select("Isolation").Updates(&runnerAssignment{Isolation: string(raw)}).Error; err != nil { |
| + return storeError(err) |
| + } |
| + if err = syncRunnerEventExposure(tx, id, iso); err != nil { |
| + return err |
| + } |
| + // Earlier artifacts from this step retain the escalation too. Independent |
| + // review and publication use this same persisted provenance lineage. |
| + var artifacts []executionArtifacts |
| + if err = tx.Where("attempt_id=? AND job_id=?", a.AttemptID, a.JobID).Find(&artifacts).Error; err != nil { |
| + return storeError(err) |
| + } |
| + for _, art := range artifacts { |
| + var p team.Provenance |
| + if err = json.Unmarshal([]byte(art.Provenance), &p); err != nil { |
| + return err |
| + } |
| + p.Isolation = mergeIsolation(p.Isolation, iso) |
| + raw, err = json.Marshal(p) |
| + if err != nil { |
| + return err |
| + } |
| + if err = tx.Model(&executionArtifacts{}).Where("id=?", art.ID).Select("Provenance").Updates(&executionArtifacts{Provenance: string(raw)}).Error; err != nil { |
| + return storeError(err) |
| + } |
| + } |
| + return nil |
| +} |
diff --git a/internal/equipo/runner_execution.go b/internal/equipo/runner_execution.go| index d4cd9039..70c77a00 100644 |
| --- a/internal/equipo/runner_execution.go |
| +++ b/internal/equipo/runner_execution.go |
| @@ -52,6 +52,7 @@ func specialistFor(step string) string { |
| } |
| } |
| func mergeIsolation(a, b team.IsolationSnapshot) team.IsolationSnapshot { |
| + a.ProfileApprovals = team.MergeProfileApprovals(a.ProfileApprovals, b.ProfileApprovals) |
| a.Trial = team.MergeTrial(a.Trial, b.Trial) |
| if a.Trial != nil { |
| a.Status = "unconfined" |
diff --git a/internal/equipo/team/approval_profile_test.go b/internal/equipo/team/approval_profile_test.go| new file mode 100644 |
| index 00000000..6f0aa9dd |
| --- /dev/null |
| +++ b/internal/equipo/team/approval_profile_test.go |
| @@ -0,0 +1,40 @@ |
| +package team |
| + |
| +import ( |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +func TestApprovedBeyondProfilePublication(t *testing.T) { |
| + g := newGitEnv(t) |
| + var raw map[string]any |
| + must(t, json.Unmarshal(mustJSON(g.observed.Isolation), &raw)) |
| + raw["profile_approvals"] = []any{map[string]any{"question_id": "q", "request_id": "7", "item_id": "item", "turn_id": "turn", "session_id": "session", "person": "owner@example.com", "label": "approved beyond profile", "request": json.RawMessage(`{"id":7,"command":"printf hello","cwd":"/workspace"}`)}} |
| + must(t, json.Unmarshal(mustJSON(raw), &g.observed.Isolation)) |
| + g.build() |
| + // Independent review inherits the builder's approval evidence. |
| + delete(raw, "profile_approvals") |
| + g.observed.Isolation = IsolationSnapshot{} |
| + must(t, json.Unmarshal(mustJSON(raw), &g.observed.Isolation)) |
| + g.review() |
| + g.verify(true) |
| + h := g.claimStep("publish") |
| + p, err := g.store.Publication(g.ctx, g.scope, h) |
| + must(t, err) |
| + if !strings.Contains(p.Description, "approved beyond profile") || !strings.Contains(p.Description, "owner@example.com") || !strings.Contains(p.Description, "printf hello") { |
| + t.Fatal("publication lost approved profile evidence", p.Description) |
| + } |
| + var d PublicationDescription |
| + must(t, json.Unmarshal([]byte(p.Description), &d)) |
| + for _, e := range d.Evidence { |
| + if !strings.Contains(string(mustJSON(e.Provenance.Isolation)), "approved beyond profile") { |
| + t.Fatal("review evidence lost approval", e.Role) |
| + } |
| + } |
| + var stripped IsolationSnapshot |
| + must(t, json.Unmarshal(mustJSON(raw), &stripped)) |
| + if IsolationContains(stripped, p.Isolation) { |
| + t.Fatal("label stripping accepted") |
| + } |
| +} |
diff --git a/internal/equipo/team/git_evidence.go b/internal/equipo/team/git_evidence.go| index 36406c46..73b709de 100644 |
| --- a/internal/equipo/team/git_evidence.go |
| +++ b/internal/equipo/team/git_evidence.go |
| @@ -50,11 +50,12 @@ type IsolationTuple struct { |
| } |
| type IsolationSnapshot struct { |
| - Trial *TrialSnapshot `json:"trial,omitempty"` |
| - Status string `json:"status"` |
| - RunnerTainted bool `json:"runner_tainted"` |
| - AcknowledgementIDs []string `json:"acknowledgement_ids"` |
| - ObservedTuples []IsolationTuple `json:"observed_tuples"` |
| + ProfileApprovals []ProfileApproval `json:"profile_approvals,omitempty"` |
| + Trial *TrialSnapshot `json:"trial,omitempty"` |
| + Status string `json:"status"` |
| + RunnerTainted bool `json:"runner_tainted"` |
| + AcknowledgementIDs []string `json:"acknowledgement_ids"` |
| + ObservedTuples []IsolationTuple `json:"observed_tuples"` |
| } |
| // ProvenanceResolver reads the authorized assignment and observed session using |
| @@ -91,7 +92,7 @@ func gitCandidate(a *Artifact, j jobRow) (GitCandidate, error) { |
| func (p IsolationSnapshot) Valid() bool { return p.valid() } |
| func (p IsolationSnapshot) valid() bool { |
| - if !p.Trial.valid() || (p.Trial != nil && (p.Status != "unconfined" || !p.RunnerTainted)) { |
| + if !validProfileApprovals(p.ProfileApprovals) || !p.Trial.valid() || (p.Trial != nil && (p.Status != "unconfined" || !p.RunnerTainted)) { |
| return false |
| } |
| if p.Status != "confined" && p.Status != "unconfined" { |
| @@ -150,6 +151,7 @@ func (v IsolationTuple) direct() bool { |
| } |
| func mergeIsolation(a, b IsolationSnapshot) IsolationSnapshot { |
| + a.ProfileApprovals = MergeProfileApprovals(a.ProfileApprovals, b.ProfileApprovals) |
| a.Trial = MergeTrial(a.Trial, b.Trial) |
| if a.Trial != nil { |
| a.Status = "unconfined" |
| @@ -276,7 +278,7 @@ func publicationMatches(p publication, cand *Artifact, j jobRow) bool { |
| } |
| func isolationContains(have, need IsolationSnapshot) bool { |
| - if !trialContains(have.Trial, need.Trial) || !have.valid() || !need.valid() || need.RunnerTainted && !have.RunnerTainted { |
| + if !profileApprovalsContain(have.ProfileApprovals, need.ProfileApprovals) || !trialContains(have.Trial, need.Trial) || !have.valid() || !need.valid() || need.RunnerTainted && !have.RunnerTainted { |
| return false |
| } |
| for _, id := range need.AcknowledgementIDs { |
diff --git a/internal/equipo/team/profile_approval.go b/internal/equipo/team/profile_approval.go| new file mode 100644 |
| index 00000000..a6086fa3 |
| --- /dev/null |
| +++ b/internal/equipo/team/profile_approval.go |
| @@ -0,0 +1,50 @@ |
| +package team |
| + |
| +import ( |
| + "encoding/json" |
| + "slices" |
| +) |
| + |
| +// ProfileApproval is evidence of a person's one-request authorization. It does |
| +// not alter the connection's confinement tuple or grant later authority. |
| +type ProfileApproval struct { |
| + QuestionID string `json:"question_id"` |
| + RequestID string `json:"request_id"` |
| + ItemID string `json:"item_id"` |
| + TurnID string `json:"turn_id"` |
| + SessionID string `json:"session_id"` |
| + Person string `json:"person"` |
| + Label string `json:"label"` |
| + Request json.RawMessage `json:"request"` |
| + ToolCall json.RawMessage `json:"tool_call,omitempty"` |
| +} |
| + |
| +func MergeProfileApprovals(a, b []ProfileApproval) []ProfileApproval { |
| + out := slices.Clone(a) |
| + for _, v := range b { |
| + if !slices.ContainsFunc(out, func(x ProfileApproval) bool { return profileApprovalKey(x) == profileApprovalKey(v) }) { |
| + out = append(out, v) |
| + } |
| + } |
| + slices.SortFunc(out, func(a, b ProfileApproval) int { |
| + return slices.Compare([]byte(profileApprovalKey(a)), []byte(profileApprovalKey(b))) |
| + }) |
| + return out |
| +} |
| +func profileApprovalKey(a ProfileApproval) string { raw, _ := json.Marshal(a); return string(raw) } |
| +func profileApprovalsContain(have, need []ProfileApproval) bool { |
| + for _, v := range need { |
| + if !slices.ContainsFunc(have, func(x ProfileApproval) bool { return profileApprovalKey(x) == profileApprovalKey(v) }) { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
| +func validProfileApprovals(values []ProfileApproval) bool { |
| + for _, v := range values { |
| + if v.QuestionID == "" || v.RequestID == "" || v.ItemID == "" || v.TurnID == "" || v.SessionID == "" || v.Person == "" || v.Label == "" || !json.Valid(v.Request) { |
| + return false |
| + } |
| + } |
| + return true |
| +} |
diff --git a/internal/equipo/templates/task_card.html b/internal/equipo/templates/task_card.html| index 2de10a02..624405c7 100644 |
| --- a/internal/equipo/templates/task_card.html |
| +++ b/internal/equipo/templates/task_card.html |
| @@ -6,4 +6,4 @@ |
| {{end}} |
| {{define "task-groups"}}{{range $group := taskGroups}}<section><h2>{{copy (printf "task.group.%s" $group)}}</h2>{{range $.Tasks}}{{if eq .Group $group}}{{template "task-card" .}}{{end}}{{end}}</section>{{end}}{{if not .Tasks}}<p data-empty-state="{{.Key}}.empty">{{copy "task.empty"}}</p>{{end}}{{end}} |
| -{{define "trial-label"}}{{with .Trial}}<span equipo-isolation>{{copy "trial.label"}}: {{range .UnverifiedChecks}}<span>{{copy (printf "trial.check.%s" .)}}</span> {{end}}<span>{{copy "trial.observed_locally"}}</span></span>{{end}}{{end}} |
| +{{define "trial-label"}}{{if .ProfileApprovals}}<span equipo-isolation>{{copy "isolation.approved_beyond_profile"}}</span>{{end}}{{with .Trial}}<span equipo-isolation>{{copy "trial.label"}}: {{range .UnverifiedChecks}}<span>{{copy (printf "trial.check.%s" .)}}</span> {{end}}<span>{{copy "trial.observed_locally"}}</span></span>{{end}}{{end}} |
diff --git a/internal/equipotest/approval_once_test.go b/internal/equipotest/approval_once_test.go| new file mode 100644 |
| index 00000000..965049d6 |
| --- /dev/null |
| +++ b/internal/equipotest/approval_once_test.go |
| @@ -0,0 +1,140 @@ |
| +package equipotest |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "encoding/json" |
| + "net/http/httptest" |
| + "net/url" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +func nativeQuestionFixture(t *testing.T) (runnerFixture, runnerproto.Question) { |
| + f, q := questionFixture(t) |
| + q.ID = "native" |
| + q.PermissionID = "7" |
| + q.Kind = "tool" |
| + q.RawRequest = json.RawMessage(`{"id":"7","kind":"tool","direct":true,"provider":"codex","name":"item/commandExecution/requestApproval","turn_id":"local-turn","input":{"threadId":"session","turnId":"provider-turn","itemId":"item","command":"printf hello","cwd":"/workspace"},"request":{"id":7,"method":"item/commandExecution/requestApproval","params":{"threadId":"session","turnId":"provider-turn","itemId":"item","command":"printf hello","cwd":"/workspace"}}}`) |
| + r := f.request() |
| + r.RequestID = "native" |
| + r.Question = &q |
| + _, err := f.x.Mutate(connectionContext, f.principal, "questions", r) |
| + executionMust(t, err) |
| + return f, q |
| +} |
| + |
| +func TestApprovedBeyondProfileHTTP(t *testing.T) { |
| + f, q := nativeQuestionFixture(t) |
| + mail := &capturingMailer{} |
| + router, err := equipo.RouterWithStore(f.d, testConfig(testOrigin), mail, nil, f.s) |
| + executionMust(t, err) |
| + server := httptest.NewServer(router) |
| + t.Cleanup(server.Close) |
| + client := signinClient(t, server.URL) |
| + signinEmail(t, client, server.URL, testOrigin, mail, ownerAddress) |
| + path := "/tasks/" + f.a.TaskID + "/questions/" + q.ID |
| + body := taskGet(t, client, server.URL, path, 200) |
| + if strings.Count(body, `name="behavior"`) != 2 || !strings.Contains(body, ">Allow once</button>") || !strings.Contains(body, ">Deny</button>") { |
| + t.Fatal("native approval must have exactly Allow once and Deny") |
| + } |
| + for _, extra := range []string{"actor", "answered_by", "grantRoot", "decision"} { |
| + res := clientPost(t, client, server.URL+path+"/answer", testOrigin, url.Values{"revision": {"1"}, "behavior": {"allow"}, extra: {"forged"}}) |
| + res.Body.Close() |
| + if res.StatusCode != 422 { |
| + t.Fatal("authority or amendment accepted", extra, res.StatusCode) |
| + } |
| + } |
| + res := clientPost(t, client, server.URL+path+"/answer", testOrigin, url.Values{"revision": {"1"}, "behavior": {"allow"}}) |
| + res.Body.Close() |
| + if res.StatusCode != 303 { |
| + t.Fatal("allow once refused", res.StatusCode) |
| + } |
| + var who, raw, iso string |
| + executionMust(t, f.d.Writer().QueryRow("SELECT answered_by,raw_request FROM questions WHERE id=?", q.ID).Scan(&who, &raw)) |
| + executionMust(t, f.d.Writer().QueryRow("SELECT isolation FROM runner_assignments WHERE id=?", f.a.ID).Scan(&iso)) |
| + if who != ownerAddress || !strings.Contains(raw, "printf hello") || !strings.Contains(raw, "provider-turn") { |
| + t.Fatal("instance approval lost actor or exact request", who, raw) |
| + } |
| + if !strings.Contains(iso, "approved beyond profile") || !strings.Contains(iso, ownerAddress) { |
| + t.Fatal("assignment missing approval evidence", iso) |
| + } |
| + for _, route := range []string{"/journey", "/tasks/" + f.a.TaskID, "/specialists/engineering"} { |
| + body = taskGet(t, client, server.URL, route, 200) |
| + part := func(start, end string) string { |
| + _, rest, ok := strings.Cut(body, start) |
| + if !ok { |
| + t.Fatalf("missing surface %s on %s", start, route) |
| + } |
| + value, _, ok := strings.Cut(rest, end) |
| + if !ok { |
| + t.Fatalf("unclosed surface %s on %s", start, route) |
| + } |
| + return value |
| + } |
| + if !strings.Contains(part("<div equipo-card>", "</div>"), "approved beyond profile") { |
| + t.Fatal("task card header lost label", route) |
| + } |
| + if !strings.Contains(part(`data-step="`+f.a.StepKey+`"`, "</li>"), "approved beyond profile") { |
| + t.Fatal("Journey step chip lost label", route) |
| + } |
| + if route == "/tasks/"+f.a.TaskID { |
| + _, detail, _ := strings.Cut(body, "</article>") |
| + if !strings.Contains(detail, "approved beyond profile") { |
| + t.Fatal("task detail lost label") |
| + } |
| + } |
| + } |
| +} |
| + |
| +func TestDirectStaleAnswerNativeRevocation(t *testing.T) { |
| + f, q := nativeQuestionFixture(t) |
| + executionMust(t, f.s.AnswerQuestion(connectionContext, ownerActor, q.ID, 1, runnerproto.QuestionAnswer{Behavior: "allow"})) |
| + mustSQL(t, f.d, "UPDATE members SET active=0 WHERE address=?", ownerAddress) |
| + r := f.request() |
| + r.RequestID = "poll-native" |
| + result, err := f.x.Mutate(connectionContext, f.principal, "answers", r) |
| + if err == nil && len(result.([]runnerproto.Question)) != 0 { |
| + t.Fatal("revoked native allow polled") |
| + } |
| +} |
| + |
| +func TestApprovedBeyondProfileFileRecord(t *testing.T) { |
| + f, q := nativeQuestionFixture(t) |
| + q.ID = "files" |
| + q.PermissionID = "8" |
| + q.RawRequest = json.RawMessage(`{"id":"8","kind":"tool","direct":true,"provider":"codex","name":"item/fileChange/requestApproval","turn_id":"local-turn","input":{"threadId":"session","turnId":"provider-turn","itemId":"files"},"request":{"id":8,"method":"item/fileChange/requestApproval","params":{"threadId":"session","turnId":"provider-turn","itemId":"files"}},"tool_call":{"method":"item/started","params":{"threadId":"session","turnId":"provider-turn","item":{"id":"files","type":"fileChange","status":"inProgress","changes":[{"path":"/workspace/a.txt","diff":"-old\n+new","kind":{"type":"update","move_path":"/workspace/b.txt"}}]}}}}`) |
| + r := f.request() |
| + r.RequestID = "files" |
| + r.Question = &q |
| + _, err := f.x.Mutate(connectionContext, f.principal, "questions", r) |
| + executionMust(t, err) |
| + executionMust(t, f.s.AnswerQuestion(connectionContext, ownerActor, q.ID, 1, runnerproto.QuestionAnswer{Behavior: "allow"})) |
| + var iso string |
| + executionMust(t, f.d.Writer().QueryRow("SELECT isolation FROM runner_assignments WHERE id=?", f.a.ID).Scan(&iso)) |
| + for _, want := range []string{"approved beyond profile", ownerAddress, "/workspace/a.txt", "/workspace/b.txt", "provider-turn", `"request_id":"8"`, `"item_id":"files"`} { |
| + if !strings.Contains(iso, want) { |
| + t.Fatal("file approval evidence lost", want, iso) |
| + } |
| + } |
| +} |
| + |
| +func TestApprovedBeyondProfileLegacyArgv(t *testing.T) { |
| + f, q := nativeQuestionFixture(t) |
| + q.ID = "argv" |
| + q.PermissionID = "9" |
| + q.RawRequest = json.RawMessage(`{"id":"9","kind":"tool","direct":true,"provider":"codex","name":"execCommandApproval","turn_id":"local-turn","provider_turn_id":"provider-turn","input":{"conversationId":"session","callId":"command","command":["/bin/sh","-c","printf '%s' 'hello world'"],"cwd":"/workspace"},"request":{"id":9,"method":"execCommandApproval","params":{"conversationId":"session","callId":"command","command":["/bin/sh","-c","printf '%s' 'hello world'"],"cwd":"/workspace"}}}`) |
| + r := f.request() |
| + r.RequestID = "argv" |
| + r.Question = &q |
| + _, err := f.x.Mutate(connectionContext, f.principal, "questions", r) |
| + executionMust(t, err) |
| + executionMust(t, f.s.AnswerQuestion(connectionContext, ownerActor, q.ID, 1, runnerproto.QuestionAnswer{Behavior: "allow"})) |
| + var iso string |
| + executionMust(t, f.d.Writer().QueryRow("SELECT isolation FROM runner_assignments WHERE id=?", f.a.ID).Scan(&iso)) |
| + for _, want := range []string{`"command":["/bin/sh","-c","printf '%s' 'hello world'"]`, `"cwd":"/workspace"`, `"turn_id":"provider-turn"`, ownerAddress} { |
| + if !strings.Contains(iso, want) { |
| + t.Fatal("argv or person changed", want, iso) |
| + } |
| + } |
| +} |
diff --git a/internal/runner/approval_once_test.go b/internal/runner/approval_once_test.go| new file mode 100644 |
| index 00000000..c1dc3566 |
| --- /dev/null |
| +++ b/internal/runner/approval_once_test.go |
| @@ -0,0 +1,189 @@ |
| +package runner |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runnerproto" |
| + "context" |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| + "time" |
| +) |
| + |
| +type approvalAPI struct{ values []runnerproto.Question } |
| + |
| +func (a *approvalAPI) Call(_ context.Context, _ string, _ runnerproto.RunnerRequest, out any) error { |
| + *out.(*[]runnerproto.Question) = a.values |
| + return nil |
| +} |
| + |
| +func TestDirectStaleAnswerNativeCurrent(t *testing.T) { |
| + q := runnerproto.Question{ID: "q", TaskID: "task", Attempt: 1, Fence: 7, AgentID: "agent", SessionID: "session", PermissionID: "7", Revision: 1, AnsweredBy: "person", RawRequest: json.RawMessage(`{"command":"printf hello"}`), Answer: &runnerproto.QuestionAnswer{Behavior: "allow"}} |
| + for _, change := range []string{"removed", "person", "payload", "answer", "fence", "attempt", "task", "revision"} { |
| + t.Run(change, func(t *testing.T) { |
| + saved := q |
| + api := &approvalAPI{values: []runnerproto.Question{saved}} |
| + switch change { |
| + case "removed": |
| + api.values = nil |
| + case "person": |
| + api.values[0].AnsweredBy = "other" |
| + case "payload": |
| + api.values[0].RawRequest = json.RawMessage(`{"command":"changed"}`) |
| + case "answer": |
| + api.values[0].Answer = &runnerproto.QuestionAnswer{Behavior: "deny"} |
| + case "fence": |
| + api.values[0].Fence++ |
| + case "attempt": |
| + api.values[0].Attempt++ |
| + case "task": |
| + api.values[0].TaskID = "other" |
| + case "revision": |
| + api.values[0].Revision++ |
| + } |
| + s := &Supervisor{api: api} |
| + if _, err := s.currentDirectQuestion(context.Background(), &attemptState{}, q, func(context.Context) error { return nil }); err == nil { |
| + t.Fatal("stale answer accepted", change) |
| + } |
| + }) |
| + } |
| +} |
| + |
| +type nativeAnswerLauncher struct { |
| + directAnswerLauncher |
| + event provider.Event |
| + change func(provider.Event) provider.Event |
| + sent int |
| + before func() |
| +} |
| + |
| +func (l *nativeAnswerLauncher) Respond(ctx context.Context, _ provider.Session, a provider.Answer) error { |
| + if l.before != nil { |
| + l.before() |
| + } |
| + if a.Behavior == "allow" { |
| + if a.Authorize == nil { |
| + return provider.ErrPolicy |
| + } |
| + ev := l.event |
| + if l.change != nil { |
| + ev = l.change(ev) |
| + } |
| + if err := a.Authorize(ctx, ev); err != nil { |
| + return err |
| + } |
| + } |
| + l.sent++ |
| + return nil |
| +} |
| +func TestCodexApprovalJournalAndExactRequest(t *testing.T) { |
| + for _, change := range []string{"none", "id", "item", "turn", "session", "command", "cwd", "revoked", "redacted"} { |
| + t.Run(change, func(t *testing.T) { |
| + b := directToolFixture(t) |
| + ctx := context.Background() |
| + ev := provider.Event{Kind: "request", RequestID: "7", SessionID: b.Session.ID, TurnID: b.TurnID, Payload: json.RawMessage(`{"id":7,"method":"item/commandExecution/requestApproval","params":{"threadId":"session","turnId":"provider-turn","itemId":"item","command":"printf hello","cwd":"/workspace"}}`)} |
| + if change == "redacted" { |
| + ev.Payload = json.RawMessage(strings.Replace(string(ev.Payload), "printf hello", "printf Bearer secret-token-value", 1)) |
| + } |
| + l := &nativeAnswerLauncher{event: ev} |
| + l.before = func() { |
| + var records []runnerproto.Question |
| + mustJournal(t, b.Journal.readStates(ctx, "profile-approval", &records)) |
| + if len(records) == 0 || records[0].AnsweredBy != "person@example.com" { |
| + t.Fatal("approval was not durable before provider I/O") |
| + } |
| + } |
| + current := true |
| + l.change = func(ev provider.Event) provider.Event { |
| + switch change { |
| + case "id": |
| + ev.RequestID = "8" |
| + case "turn": |
| + ev.TurnID = "other" |
| + case "session": |
| + ev.SessionID = "other" |
| + case "item": |
| + ev.Payload = json.RawMessage(strings.Replace(string(ev.Payload), `"itemId":"item"`, `"itemId":"other"`, 1)) |
| + case "command": |
| + ev.Payload = json.RawMessage(strings.Replace(string(ev.Payload), "printf hello", "printf changed", 1)) |
| + case "cwd": |
| + ev.Payload = json.RawMessage(strings.Replace(string(ev.Payload), "/workspace", "/elsewhere", 1)) |
| + case "revoked": |
| + current = false |
| + } |
| + return ev |
| + } |
| + person := "person@example.com" |
| + relay := DirectQuestionRelay{Binding: b, Launcher: l, Answerer: func(context.Context, runnerproto.Question) (string, error) { return person, nil }, Current: func(context.Context, runnerproto.Question) (time.Time, error) { |
| + if !current { |
| + return time.Time{}, provider.ErrPolicy |
| + } |
| + return b.LeaseDeadline, nil |
| + }} |
| + asks := 0 |
| + ask := func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error) { |
| + asks++ |
| + return runnerproto.QuestionAnswer{Behavior: "allow"}, nil |
| + } |
| + err := relay.Handle(ctx, ev, ask) |
| + if change != "none" { |
| + if err == nil || l.sent != 0 { |
| + t.Fatal("changed or revoked request approved", change) |
| + } |
| + return |
| + } |
| + mustJournal(t, err) |
| + ev.RequestID = "8" |
| + ev.Payload = json.RawMessage(strings.Replace(string(ev.Payload), `"id":7`, `"id":8`, 1)) |
| + l.event = ev |
| + mustJournal(t, relay.Handle(ctx, ev, ask)) |
| + if asks != 2 || l.sent != 2 { |
| + t.Fatal("later identical request reused approval", asks, l.sent) |
| + } |
| + var saved []runnerproto.Question |
| + mustJournal(t, b.Journal.readStates(ctx, "profile-approval", &saved)) |
| + if len(saved) != 2 { |
| + t.Fatal("durable approval absent", len(saved)) |
| + } |
| + for _, q := range saved { |
| + if q.AnsweredBy != "person@example.com" || !strings.Contains(string(q.RawRequest), "printf hello") || !strings.Contains(string(q.RawRequest), "provider-turn") || q.Answer == nil || q.Answer.Behavior != "allow" { |
| + t.Fatal("journal lost request or allowing person", q) |
| + } |
| + } |
| + person = "other@example.com" |
| + if relay.Handle(ctx, ev, ask) == nil { |
| + t.Fatal("changed allowing person replay accepted") |
| + } |
| + |
| + }) |
| + } |
| +} |
| + |
| +func TestCodexApprovalJournalWriteFailure(t *testing.T) { |
| + b := directToolFixture(t) |
| + ctx, cancel := context.WithTimeout(context.Background(), time.Second) |
| + defer cancel() |
| + ev := provider.Event{Kind: "request", RequestID: "7", SessionID: b.Session.ID, TurnID: b.TurnID, Payload: json.RawMessage(`{"id":7,"method":"item/commandExecution/requestApproval","params":{"threadId":"session","turnId":"provider-turn","itemId":"item","command":"printf hello","cwd":"/workspace"}}`)} |
| + q, err := DirectQuestionFromEvent(ev, b) |
| + mustJournal(t, err) |
| + q.AnsweredBy = "person@example.com" |
| + _, err = b.Journal.db.Exec("CREATE TRIGGER reject_approval BEFORE INSERT ON journal_supervisor WHEN NEW.kind='profile-approval' BEGIN SELECT RAISE(ABORT,'approval write refused'); END") |
| + mustJournal(t, err) |
| + client := &answerClient{} |
| + relay := QuestionRelay{Journal: b.Journal, Client: client, Agent: b.Agent, DirectSession: b.Session, TurnID: b.TurnID, Current: func(context.Context, runnerproto.Question) (time.Time, error) { return b.LeaseDeadline, nil }} |
| + err = relay.Deliver(ctx, q, runnerproto.QuestionAnswer{Behavior: "allow"}) |
| + if err == nil || len(client.responses) != 0 { |
| + t.Fatal("approval sent without durable evidence", err) |
| + } |
| + if ctx.Err() != nil { |
| + t.Fatal("journal failure waited for the request deadline instead of releasing the write transaction") |
| + } |
| + if b.Journal.AdmissionAllowed(context.Background()) == nil { |
| + t.Fatal("journal failure did not fence admission") |
| + } |
| + var count int |
| + mustJournal(t, b.Journal.db.QueryRow("SELECT count(*) FROM journal_answers").Scan(&count)) |
| + if count != 0 { |
| + t.Fatal("partial approval transaction persisted") |
| + } |
| +} |
diff --git a/internal/runner/direct_questions.go b/internal/runner/direct_questions.go| index fe51708a..24b9425a 100644 |
| --- a/internal/runner/direct_questions.go |
| +++ b/internal/runner/direct_questions.go |
| @@ -20,6 +20,7 @@ type DirectQuestionRelay struct { |
| Proxy *ToolProxy |
| Launcher provider.Launcher |
| Current func(context.Context, runnerproto.Question) (time.Time, error) |
| + Answerer func(context.Context, runnerproto.Question) (string, error) |
| } |
| func (r *DirectQuestionRelay) Handle(ctx context.Context, ev provider.Event, ask func(context.Context, runnerproto.Question) (runnerproto.QuestionAnswer, error)) error { |
| @@ -87,7 +88,48 @@ func (r *DirectQuestionRelay) Handle(ctx context.Context, ev provider.Event, ask |
| if e != nil { |
| return e |
| } |
| + q.Answer = &answer |
| + if _, err := q.NativeApproval(); err == nil && answer.Behavior == "allow" { |
| + if r.Answerer == nil { |
| + return runnerproto.ErrInvalid |
| + } |
| + q.AnsweredBy, e = r.Answerer(waitCtx, q) |
| + if e != nil || q.AnsweredBy == "" { |
| + return runnerproto.ErrInvalid |
| + } |
| + } |
| client := &directQuestionClient{launcher: r.Launcher, session: b.Session, turn: b.TurnID} |
| + if _, err := q.NativeApproval(); err == nil && answer.Behavior == "allow" { |
| + client.authorize = func(ctx context.Context, original provider.Event) error { |
| + if original.SessionID != ev.SessionID || original.TurnID != ev.TurnID || original.ProviderTurnID != ev.ProviderTurnID || original.RequestID != ev.RequestID || !bytes.Equal(original.Payload, ev.Payload) || !bytes.Equal(original.ToolCall, ev.ToolCall) { |
| + return runnerproto.ErrInvalid |
| + } |
| + // A redacted request cannot confer authority over unseen bytes. |
| + var saved struct { |
| + Request json.RawMessage |
| + ToolCall json.RawMessage `json:"tool_call"` |
| + } |
| + if json.Unmarshal(q.RawRequest, &saved) != nil || !runnerproto.SameRequestJSON(original.Payload, saved.Request) { |
| + return runnerproto.ErrInvalid |
| + } |
| + if len(original.ToolCall) > 0 { |
| + if !runnerproto.SameRequestJSON(original.ToolCall, saved.ToolCall) { |
| + return runnerproto.ErrInvalid |
| + } |
| + } |
| + if err := b.Current(ctx); err != nil { |
| + return err |
| + } |
| + if err := b.Journal.currentDirectTurn(ctx, b.Session, b.TurnID); err != nil { |
| + return err |
| + } |
| + deadline, err := r.Current(ctx, q) |
| + if err != nil || deadline.IsZero() || !time.Now().Before(deadline) { |
| + return runnerproto.ErrInvalid |
| + } |
| + return nil |
| + } |
| + } |
| relay := QuestionRelay{Journal: b.Journal, Client: client, Agent: b.Agent, DirectSession: b.Session, TurnID: b.TurnID, Current: func(ctx context.Context, q runnerproto.Question) (time.Time, error) { |
| if e := b.Current(ctx); e != nil { |
| return time.Time{}, e |
| @@ -98,13 +140,14 @@ func (r *DirectQuestionRelay) Handle(ctx context.Context, ev provider.Event, ask |
| } |
| type directQuestionClient struct { |
| - launcher provider.Launcher |
| - session provider.Session |
| - turn string |
| + launcher provider.Launcher |
| + session provider.Session |
| + turn string |
| + authorize func(context.Context, provider.Event) error |
| } |
| func (c *directQuestionClient) Respond(ctx context.Context, _ paseo.Agent, a paseo.PermissionResponse) error { |
| - return c.launcher.Respond(ctx, c.session, provider.Answer{RequestID: a.RequestID, TurnID: c.turn, Behavior: a.Behavior, Input: a.UpdatedInput}) |
| + return c.launcher.Respond(ctx, c.session, provider.Answer{RequestID: a.RequestID, TurnID: c.turn, Behavior: a.Behavior, Input: a.UpdatedInput, Authorize: c.authorize}) |
| } |
| func (c *directQuestionClient) Send(context.Context, paseo.Agent, string, string) error { |
| return runnerproto.ErrInvalid |
| @@ -153,7 +196,7 @@ func DirectQuestionFromEvent(ev provider.Event, b ToolBinding) (runnerproto.Ques |
| } else { |
| return q, runnerproto.ErrInvalid |
| } |
| - q.RawRequest, _ = json.Marshal(map[string]any{"id": q.PermissionID, "kind": q.Kind, "provider": b.Session.Provider, "name": name, "input": input, "direct": true, "turn_id": b.TurnID, "request": json.RawMessage(ev.Payload)}) |
| + q.RawRequest, _ = json.Marshal(map[string]any{"id": q.PermissionID, "kind": q.Kind, "provider": b.Session.Provider, "name": name, "input": input, "direct": true, "turn_id": b.TurnID, "request": json.RawMessage(ev.Payload), "tool_call": ev.ToolCall, "provider_turn_id": ev.ProviderTurnID}) |
| q.RawRequest = RedactJSON(q.RawRequest, nil) |
| return q, q.Validate() |
| } |
diff --git a/internal/runner/direct_workflow.go b/internal/runner/direct_workflow.go| index 22ee63a6..6e5da41e 100644 |
| --- a/internal/runner/direct_workflow.go |
| +++ b/internal/runner/direct_workflow.go |
| @@ -25,23 +25,16 @@ func (w *BugWorkflow) directModel(ctx context.Context, s *Supervisor, r *attempt |
| var proxy *ToolProxy |
| ask := w.directAsk(s, r, l, current) |
| questionCurrent := func(ctx context.Context, q runnerproto.Question) (time.Time, error) { |
| - if err := current(ctx); err != nil { |
| - return time.Time{}, err |
| - } |
| - var answers []runnerproto.Question |
| - if err := s.api.Call(ctx, "answers", r.request("answers-current"), &answers); err != nil { |
| - return time.Time{}, err |
| - } |
| - for _, saved := range answers { |
| - if saved.ID == q.ID && (saved.Revision != q.Revision || saved.PermissionID != q.PermissionID || saved.SessionID != q.SessionID || saved.AgentID != q.AgentID) { |
| - return time.Time{}, provider.ErrIdentity |
| - } |
| - } |
| - return l.bound(), nil |
| + _, err := s.currentDirectQuestion(ctx, r, q, current) |
| + return l.bound(), err |
| + } |
| + answerer := func(ctx context.Context, q runnerproto.Question) (string, error) { |
| + saved, err := s.currentDirectQuestion(ctx, r, q, current) |
| + return saved.AnsweredBy, err |
| } |
| b := ToolBinding{ReadPolicy: policy, Copy: w.cfg.Copy, InstanceID: w.cfg.InstanceID, TaskID: r.Claim.Assignment.TaskID, Attempt: int64(r.Claim.Handle.Attempt), Fence: r.Claim.Handle.Fence, Tools: []string{tool, "ask_person"}, LeaseDeadline: l.bound(), Agent: paseo.Agent{ServerID: "direct", Provider: r.Claim.Assignment.Selection.Provider, AccountID: r.Claim.Assignment.Selection.AccountID, Family: r.Claim.Assignment.Selection.Family, Model: r.Claim.Assignment.Selection.Model}, Isolation: r.Claim.Assignment.Selection.Isolation, Journal: s.journal, Current: current} |
| b.Ask = func(ctx context.Context, bound ToolBinding, id string, args json.RawMessage) (json.RawMessage, error) { |
| - relay := DirectQuestionRelay{Binding: bound, Proxy: proxy, Launcher: launcher, Current: questionCurrent} |
| + relay := DirectQuestionRelay{Binding: bound, Proxy: proxy, Launcher: launcher, Current: questionCurrent, Answerer: answerer} |
| answer, err := relay.Ask(ctx, id, args, ask) |
| if err != nil { |
| return nil, err |
| @@ -216,7 +209,7 @@ func (w *BugWorkflow) directModel(ctx context.Context, s *Supervisor, r *attempt |
| proxy.broker.mu.Lock() |
| bound := proxy.broker.binding |
| proxy.broker.mu.Unlock() |
| - relay := DirectQuestionRelay{Binding: bound, Proxy: proxy, Launcher: launcher, Current: questionCurrent} |
| + relay := DirectQuestionRelay{Binding: bound, Proxy: proxy, Launcher: launcher, Current: questionCurrent, Answerer: answerer} |
| if err = current(ctx); err != nil { |
| return err |
| } |
| @@ -371,3 +364,28 @@ func (j *Journal) requireDirectCompletion(ctx context.Context, s provider.Sessio |
| } |
| return nil |
| } |
| + |
| +func (s *Supervisor) currentDirectQuestion(ctx context.Context, r *attemptState, q runnerproto.Question, current func(context.Context) error) (runnerproto.Question, error) { |
| + if err := current(ctx); err != nil { |
| + return runnerproto.Question{}, err |
| + } |
| + var answers []runnerproto.Question |
| + if err := s.api.Call(ctx, "answers", r.request("answers-current"), &answers); err != nil { |
| + return runnerproto.Question{}, err |
| + } |
| + for _, saved := range answers { |
| + if saved.ID == q.ID { |
| + if saved.Revision != q.Revision || saved.PermissionID != q.PermissionID || saved.SessionID != q.SessionID || saved.AgentID != q.AgentID { |
| + return runnerproto.Question{}, provider.ErrIdentity |
| + } |
| + if q.Answer != nil && (saved.Answer == nil || saved.AnsweredBy == "" || (q.AnsweredBy != "" && saved.AnsweredBy != q.AnsweredBy) || saved.TaskID != q.TaskID || saved.Attempt != q.Attempt || saved.Fence != q.Fence || !runnerproto.SameRequestJSON(saved.RawRequest, q.RawRequest) || runnerproto.EventHash(saved.Answer) != runnerproto.EventHash(q.Answer)) { |
| + return runnerproto.Question{}, provider.ErrIdentity |
| + } |
| + return saved, nil |
| + } |
| + } |
| + if q.Answer != nil { |
| + return runnerproto.Question{}, provider.ErrIdentity |
| + } |
| + return runnerproto.Question{}, nil |
| +} |
diff --git a/internal/runner/forge/approval_profile_test.go b/internal/runner/forge/approval_profile_test.go| new file mode 100644 |
| index 00000000..4afe72b9 |
| --- /dev/null |
| +++ b/internal/runner/forge/approval_profile_test.go |
| @@ -0,0 +1,31 @@ |
| +package forge |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/equipo/team" |
| + "context" |
| + "encoding/json" |
| + "strings" |
| + "testing" |
| +) |
| + |
| +func TestApprovedBeyondProfilePublisher(t *testing.T) { |
| + f := newFixture(t) |
| + approval := team.ProfileApproval{QuestionID: "q", RequestID: "7", ItemID: "item", TurnID: "turn", SessionID: "session", Person: "owner@example.com", Label: "approved beyond profile", Request: json.RawMessage(`{"command":"printf hello","cwd":"/workspace"}`)} |
| + f.auth.Publication.Isolation.ProfileApprovals = []team.ProfileApproval{approval} |
| + for _, label := range []string{"unconfined", "unconfined; approved beyond profile"} { |
| + f.auth.Publication.Description = label |
| + f.auth.Publication.DescriptionHash = Digest([]byte(label)) |
| + raw, _ := json.Marshal(f.auth.Publication) |
| + raw, hash, _ := Canonical(raw) |
| + f.auth.Ticket.Dispatch.Payload, f.auth.Ticket.Dispatch.Hash = raw, hash |
| + err := f.p.validate(f.auth, f.auth.Ticket.Dispatch) |
| + if (err == nil) != strings.Contains(label, approval.Label) { |
| + t.Fatal("publisher lost profile label guard", label, err) |
| + } |
| + } |
| + _, err := f.p.Execute(context.Background(), f.auth.Ticket.Dispatch) |
| + must(t, err) |
| + if !strings.Contains(f.desc.value.Body, approval.Label) { |
| + t.Fatal("published branch description lost label") |
| + } |
| +} |
diff --git a/internal/runner/forge/publisher.go b/internal/runner/forge/publisher.go| index fdb0c3ce..d51c02ff 100644 |
| --- a/internal/runner/forge/publisher.go |
| +++ b/internal/runner/forge/publisher.go |
| @@ -125,6 +125,11 @@ func (p *Publisher) validate(a Authorization, d team.Dispatch) error { |
| return team.ErrEvidence |
| } |
| iso := v.Isolation |
| + for _, approval := range iso.ProfileApprovals { |
| + if !strings.Contains(v.Description, approval.Label) { |
| + return team.ErrEvidence |
| + } |
| + } |
| if !iso.Valid() || (iso.Trial != nil && !strings.Contains(v.Description, "supervised trial")) || ((iso.RunnerTainted || iso.Status == "unconfined") && !strings.Contains(v.Description, "unconfined")) { |
| return team.ErrEvidence |
| } |
diff --git a/internal/runner/provider/codex/answers.go b/internal/runner/provider/codex/answers.go| index 7229026b..963bc06f 100644 |
| --- a/internal/runner/provider/codex/answers.go |
| +++ b/internal/runner/provider/codex/answers.go |
| @@ -161,26 +161,36 @@ func (l *Launcher) respond(ctx context.Context, session provider.Session, a prov |
| return provider.ErrPolicy |
| } |
| switch v.Method { |
| - case "item/commandExecution/requestApproval", "item/fileChange/requestApproval", "mcpServer/elicitation/request": |
| + case "item/commandExecution/requestApproval", "item/fileChange/requestApproval", "mcpServer/elicitation/request", "execCommandApproval", "applyPatchApproval": |
| default: |
| return provider.ErrPolicy |
| } |
| decision := "decline" |
| if a.Behavior == "allow" { |
| - // Native approval requests may escape the inner sandbox. No currently |
| - // certified action schema proves otherwise, so only Equipo MCP can pass. |
| - if _, _, e := MCPApproval(ev); e != nil || a.Authorize == nil { |
| + _, nativeErr := NativeApproval(ev) |
| + _, _, mcpErr := MCPApproval(ev) |
| + if a.Authorize == nil || (nativeErr != nil && mcpErr != nil) { |
| return provider.ErrPolicy |
| } |
| if e = a.Authorize(ctx, ev); e == nil { |
| decision = "accept" |
| } else { |
| + if nativeErr == nil { |
| + return e |
| + } |
| a.Behavior = "deny" |
| } |
| } else if a.Behavior != "deny" { |
| return provider.ErrPolicy |
| } |
| result = map[string]any{"decision": decision} |
| + if v.Method == "execCommandApproval" || v.Method == "applyPatchApproval" { |
| + if decision == "accept" { |
| + result = map[string]any{"decision": "approved"} |
| + } else { |
| + result = map[string]any{"decision": map[string]any{"denied": map[string]any{"rejection": ""}}} |
| + } |
| + } |
| if v.Method == "mcpServer/elicitation/request" { |
| var content any |
| if decision == "accept" { |
| @@ -199,12 +209,27 @@ func (l *Launcher) respond(ctx context.Context, session provider.Session, a prov |
| return provider.ErrPolicy |
| } |
| } |
| + if a.Behavior == "allow" && v.Method == "item/fileChange/requestApproval" { |
| + s.mu.Lock() |
| + current := ev |
| + current.ToolCall = nil |
| + s.correlateNative(¤t) |
| + s.mu.Unlock() |
| + if len(current.ToolCall) == 0 || !bytes.Equal(current.ToolCall, ev.ToolCall) { |
| + return provider.ErrPolicy |
| + } |
| + } |
| // Reserve the one response before I/O. A lost write cannot be replayed. |
| s.mu.Lock() |
| if !s.active || s.closed || s.err != nil || s.providerTurn != providerTurn || s.turn.ID != a.TurnID { |
| s.mu.Unlock() |
| return errNotReady |
| } |
| + current, present := s.requests[a.RequestID] |
| + if !present || !bytes.Equal(current.Payload, ev.Payload) || !bytes.Equal(current.ToolCall, ev.ToolCall) { |
| + s.mu.Unlock() |
| + return provider.ErrPolicy |
| + } |
| delete(s.requests, a.RequestID) |
| s.mu.Unlock() |
| if steer { |
diff --git a/internal/runner/provider/codex/approval_once_test.go b/internal/runner/provider/codex/approval_once_test.go| new file mode 100644 |
| index 00000000..f84218ae |
| --- /dev/null |
| +++ b/internal/runner/provider/codex/approval_once_test.go |
| @@ -0,0 +1,296 @@ |
| +package codex |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "bytes" |
| + "context" |
| + "encoding/json" |
| + "fmt" |
| + "testing" |
| +) |
| + |
| +func nativeRequest(t *testing.T, s *sessionState, id, method string) []byte { |
| + t.Helper() |
| + params := map[string]any{"threadId": s.session.ID, "turnId": "provider-turn", "itemId": "native-item", "startedAtMs": 1} |
| + if method == "item/commandExecution/requestApproval" { |
| + params["command"] = "printf '%s' hello" |
| + params["cwd"] = "/workspace" |
| + params["proposedExecpolicyAmendment"] = []string{"printf"} |
| + } else { |
| + item := marshal(map[string]any{"method": "item/started", "params": map[string]any{"threadId": s.session.ID, "turnId": "provider-turn", "item": map[string]any{"id": "native-item", "type": "fileChange", "status": "inProgress", "changes": []any{map[string]any{"path": "/workspace/a.txt", "kind": map[string]any{"type": "update", "move_path": "/workspace/b.txt"}, "diff": "-old\n+new"}}}}}) |
| + if err := s.handle(provider.Frame{Sequence: 98, Bytes: item}); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + raw := marshal(map[string]any{"id": json.RawMessage(id), "method": method, "params": params}) |
| + if err := s.handle(provider.Frame{Sequence: 99, Bytes: raw}); err != nil { |
| + t.Fatal(err) |
| + } |
| + return raw |
| +} |
| + |
| +func TestCodexApprovalAllowOnce(t *testing.T) { |
| + for _, method := range []string{"item/commandExecution/requestApproval", "item/fileChange/requestApproval"} { |
| + t.Run(method, func(t *testing.T) { |
| + l, s, w, _ := answerFixture(t) |
| + before := marshal(s.launch.Policy) |
| + for _, id := range []string{"7", `"7"`} { |
| + raw := nativeRequest(t, s, id, method) |
| + checked := 0 |
| + a := provider.Answer{RequestID: id, TurnID: "local-turn", Behavior: "allow", Authorize: func(_ context.Context, ev provider.Event) error { |
| + checked++ |
| + if ev.RequestID != id || !bytes.Equal(ev.Payload, raw) { |
| + t.Fatal("original request changed") |
| + } |
| + if method == "item/fileChange/requestApproval" && !bytes.Contains(ev.ToolCall, []byte("/workspace/a.txt")) { |
| + t.Fatal("file payload missing") |
| + } |
| + return nil |
| + }} |
| + if err := l.Respond(context.Background(), s.session, a); err != nil { |
| + t.Fatal("allow once refused", err) |
| + } |
| + wire := <-w.sent |
| + if string(wire) != fmt.Sprintf(`{"id":%s,"result":{"decision":"accept"}}`+"\n", id) { |
| + t.Fatalf("broader or wrong response: %s", wire) |
| + } |
| + if checked != 1 { |
| + t.Fatal("original not authorized") |
| + } |
| + if l.Respond(context.Background(), s.session, a) == nil { |
| + t.Fatal("request replay approved") |
| + } |
| + } |
| + if !bytes.Equal(before, marshal(s.launch.Policy)) { |
| + t.Fatal("policy hash, manifest, network or namespace mounts changed") |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestCodexApprovalPersistentRefused(t *testing.T) { |
| + l, s, w, _ := answerFixture(t) |
| + nativeRequest(t, s, "7", "item/commandExecution/requestApproval") |
| + for _, behavior := range []string{"acceptForSession", "approved_for_session", "allow_always", "acceptWithExecpolicyAmendment", "applyNetworkPolicyAmendment", "approved_mcp_policy_amendment"} { |
| + if l.Respond(context.Background(), s.session, provider.Answer{RequestID: "7", TurnID: "local-turn", Behavior: behavior, Authorize: func(context.Context, provider.Event) error { return nil }}) == nil { |
| + t.Fatal("persistent option accepted", behavior) |
| + } |
| + } |
| + for _, input := range []string{`{"decision":"acceptForSession"}`, `{"execpolicy_amendment":["printf"]}`, `{"network_policy_amendment":{"host":"example.com","action":"allow"}}`, `{"grantRoot":"/"}`} { |
| + if l.Respond(context.Background(), s.session, provider.Answer{RequestID: "7", TurnID: "local-turn", Behavior: "allow", Input: json.RawMessage(input), Authorize: func(context.Context, provider.Event) error { return nil }}) == nil { |
| + t.Fatal("amendment accepted", input) |
| + } |
| + } |
| + select { |
| + case wire := <-w.sent: |
| + t.Fatalf("refusal sent a response: %s", wire) |
| + default: |
| + } |
| + if err := l.Respond(context.Background(), s.session, provider.Answer{RequestID: "7", TurnID: "local-turn", Behavior: "deny"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if !bytes.Contains(<-w.sent, []byte(`"decision":"decline"`)) { |
| + t.Fatal("deny changed") |
| + } |
| +} |
| + |
| +func TestCodexApprovalLegacyOnce(t *testing.T) { |
| + for _, method := range []string{"execCommandApproval", "applyPatchApproval"} { |
| + t.Run(method, func(t *testing.T) { |
| + l, s, w, _ := answerFixture(t) |
| + params := map[string]any{"conversationId": s.session.ID, "callId": "call"} |
| + if method == "execCommandApproval" { |
| + params["command"] = []string{"/bin/sh", "-c", "printf hello"} |
| + params["cwd"] = "/workspace" |
| + params["parsedCmd"] = []any{} |
| + } else { |
| + params["fileChanges"] = map[string]any{"/workspace/a.txt": map[string]any{"type": "add", "content": "hello"}} |
| + } |
| + raw := marshal(map[string]any{"id": 7, "method": method, "params": params}) |
| + if err := s.handle(provider.Frame{Sequence: 99, Bytes: raw}); err != nil { |
| + t.Fatal("pinned legacy request not relayed", err) |
| + } |
| + a := provider.Answer{RequestID: "7", TurnID: "local-turn", Behavior: "allow", Authorize: func(_ context.Context, ev provider.Event) error { |
| + if !bytes.Equal(ev.Payload, raw) { |
| + t.Fatal("argv or paths changed") |
| + } |
| + return nil |
| + }} |
| + if err := l.Respond(context.Background(), s.session, a); err != nil { |
| + t.Fatal(err) |
| + } |
| + if wire := <-w.sent; string(wire) != `{"id":7,"result":{"decision":"approved"}}`+"\n" { |
| + t.Fatalf("legacy scope broadened: %s", wire) |
| + } |
| + denied := marshal(map[string]any{"id": 9, "method": method, "params": params}) |
| + if err := s.handle(provider.Frame{Sequence: 100, Bytes: denied}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := l.Respond(context.Background(), s.session, provider.Answer{RequestID: "9", TurnID: "local-turn", Behavior: "deny"}); err != nil { |
| + t.Fatal(err) |
| + } |
| + if wire := <-w.sent; string(wire) != `{"id":9,"result":{"decision":{"denied":{"rejection":""}}}}`+"\n" { |
| + t.Fatalf("legacy deny changed: %s", wire) |
| + } |
| + select { |
| + case wire := <-w.sent: |
| + t.Fatalf("extra response: %s", wire) |
| + default: |
| + } |
| + |
| + }) |
| + } |
| +} |
| + |
| +func TestCodexApprovalFileCorrelation(t *testing.T) { |
| + for _, change := range []string{"completed", "changed", "missing", "wrong-item", "wrong-turn", "wrong-session"} { |
| + t.Run(change, func(t *testing.T) { |
| + l, s, w, _ := answerFixture(t) |
| + nativeRequest(t, s, "7", "item/fileChange/requestApproval") |
| + // Change the captured item after the approval was raised. |
| + s.mu.Lock() |
| + switch change { |
| + case "completed", "missing": |
| + delete(s.nativeCalls, "native-item") |
| + case "changed": |
| + s.nativeCalls["native-item"] = bytes.ReplaceAll(s.nativeCalls["native-item"], []byte("a.txt"), []byte("changed.txt")) |
| + case "wrong-item": |
| + s.nativeCalls["native-item"] = bytes.ReplaceAll(s.nativeCalls["native-item"], []byte("native-item"), []byte("other")) |
| + case "wrong-turn": |
| + s.nativeCalls["native-item"] = bytes.ReplaceAll(s.nativeCalls["native-item"], []byte("provider-turn"), []byte("other-turn")) |
| + case "wrong-session": |
| + s.nativeCalls["native-item"] = bytes.ReplaceAll(s.nativeCalls["native-item"], []byte(s.session.ID), []byte("other-session")) |
| + } |
| + s.mu.Unlock() |
| + if l.Respond(context.Background(), s.session, provider.Answer{RequestID: "7", TurnID: "local-turn", Behavior: "allow", Authorize: func(context.Context, provider.Event) error { return nil }}) == nil { |
| + t.Fatal("changed file item approved", change) |
| + } |
| + select { |
| + case wire := <-w.sent: |
| + t.Fatalf("stale file approval sent: %s", wire) |
| + default: |
| + } |
| + }) |
| + } |
| +} |
| + |
| +func TestCodexApprovalResolvedDuringAuthorization(t *testing.T) { |
| + l, s, w, _ := answerFixture(t) |
| + nativeRequest(t, s, "7", "item/commandExecution/requestApproval") |
| + err := l.Respond(context.Background(), s.session, provider.Answer{RequestID: "7", TurnID: "local-turn", Behavior: "allow", Authorize: func(context.Context, provider.Event) error { |
| + s.mu.Lock() |
| + delete(s.requests, "7") |
| + s.mu.Unlock() |
| + return nil |
| + }}) |
| + if err == nil { |
| + t.Fatal("resolved request approved") |
| + } |
| + select { |
| + case wire := <-w.sent: |
| + t.Fatalf("resolved approval sent: %s", wire) |
| + default: |
| + } |
| +} |
| + |
| +func TestCodexApprovalRootGrantRefused(t *testing.T) { |
| + l, s, w, _ := answerFixture(t) |
| + nativeRequest(t, s, "7", "item/fileChange/requestApproval") |
| + s.mu.Lock() |
| + ev := s.requests["7"] |
| + var frame map[string]any |
| + if err := json.Unmarshal(ev.Payload, &frame); err != nil { |
| + t.Fatal(err) |
| + } |
| + frame["params"].(map[string]any)["grantRoot"] = "/workspace" |
| + ev.Payload = marshal(frame) |
| + s.requests["7"] = ev |
| + s.mu.Unlock() |
| + if l.Respond(context.Background(), s.session, provider.Answer{RequestID: "7", TurnID: "local-turn", Behavior: "allow", Authorize: func(context.Context, provider.Event) error { return nil }}) == nil { |
| + t.Fatal("session root grant accepted") |
| + } |
| + select { |
| + case wire := <-w.sent: |
| + t.Fatalf("persistent root grant sent: %s", wire) |
| + default: |
| + } |
| +} |
| + |
| +func TestCodexApprovalNativeShape(t *testing.T) { |
| + for _, method := range []string{"item/commandExecution/requestApproval", "item/fileChange/requestApproval"} { |
| + l, s, _, _ := answerFixture(t) |
| + _ = l |
| + nativeRequest(t, s, "7", method) |
| + s.mu.Lock() |
| + original := s.requests["7"] |
| + s.mu.Unlock() |
| + for _, change := range []string{"id", "session", "provider-turn", "item", "turn", "command", "cwd", "file-path", "file-diff", "file-item", "file-turn", "file-session"} { |
| + t.Run(method+"/"+change, func(t *testing.T) { |
| + ev := original |
| + var frame map[string]any |
| + if err := json.Unmarshal(ev.Payload, &frame); err != nil { |
| + t.Fatal(err) |
| + } |
| + params := frame["params"].(map[string]any) |
| + switch change { |
| + case "id": |
| + ev.RequestID = `"7"` |
| + case "session": |
| + ev.SessionID = "other" |
| + case "provider-turn": |
| + ev.ProviderTurnID = "other" |
| + case "item": |
| + params["itemId"] = "" |
| + case "turn": |
| + params["turnId"] = "" |
| + case "command", "cwd": |
| + if method != "item/commandExecution/requestApproval" { |
| + t.Skip() |
| + } |
| + params[change] = "" |
| + default: |
| + if method != "item/fileChange/requestApproval" { |
| + t.Skip() |
| + } |
| + var call map[string]any |
| + if err := json.Unmarshal(ev.ToolCall, &call); err != nil { |
| + t.Fatal(err) |
| + } |
| + cp := call["params"].(map[string]any) |
| + item := cp["item"].(map[string]any) |
| + switch change { |
| + case "file-path": |
| + item["changes"].([]any)[0].(map[string]any)["path"] = "" |
| + case "file-diff": |
| + delete(item["changes"].([]any)[0].(map[string]any), "diff") |
| + case "file-item": |
| + item["id"] = "other" |
| + case "file-turn": |
| + cp["turnId"] = "other" |
| + case "file-session": |
| + cp["threadId"] = "other" |
| + } |
| + ev.ToolCall = marshal(call) |
| + } |
| + ev.Payload = marshal(frame) |
| + if _, err := NativeApproval(ev); err == nil { |
| + t.Fatal("incomplete or mismatched native action accepted", change) |
| + } |
| + }) |
| + } |
| + } |
| +} |
| + |
| +func TestCodexApprovalAuthorizationRefused(t *testing.T) { |
| + l, s, w, _ := answerFixture(t) |
| + nativeRequest(t, s, "7", "item/commandExecution/requestApproval") |
| + err := l.Respond(context.Background(), s.session, provider.Answer{RequestID: "7", TurnID: "local-turn", Behavior: "allow", Authorize: func(context.Context, provider.Event) error { return provider.ErrPolicy }}) |
| + if err == nil { |
| + t.Fatal("revoked authorization reported as delivered") |
| + } |
| + select { |
| + case wire := <-w.sent: |
| + t.Fatalf("revoked approval produced a response: %s", wire) |
| + default: |
| + } |
| +} |
diff --git a/internal/runner/provider/codex/events.go b/internal/runner/provider/codex/events.go| index 8b510e47..5e3cfb7d 100644 |
| --- a/internal/runner/provider/codex/events.go |
| +++ b/internal/runner/provider/codex/events.go |
| @@ -54,11 +54,12 @@ func Decode(raw []byte) ([]provider.Event, error) { |
| return nil, nil |
| } |
| var p struct { |
| - ThreadID string `json:"threadId"` |
| - TurnID string `json:"turnId"` |
| - Thread struct{ ID string } |
| - Turn struct{ ID, Status string } |
| - Item struct { |
| + ConversationID string `json:"conversationId"` |
| + ThreadID string `json:"threadId"` |
| + TurnID string `json:"turnId"` |
| + Thread struct{ ID string } |
| + Turn struct{ ID, Status string } |
| + Item struct { |
| Type, ID, Delivery string |
| Questions json.RawMessage |
| } |
| @@ -69,6 +70,9 @@ func Decode(raw []byte) ([]provider.Event, error) { |
| if p.ThreadID == "" { |
| p.ThreadID = p.Thread.ID |
| } |
| + if (v.Method == "execCommandApproval" || v.Method == "applyPatchApproval") && p.ThreadID == "" { |
| + p.ThreadID = p.ConversationID |
| + } |
| if p.TurnID == "" { |
| p.TurnID = p.Turn.ID |
| } |
diff --git a/internal/runner/provider/codex/launcher.go b/internal/runner/provider/codex/launcher.go| index 393feafc..7063cd66 100644 |
| --- a/internal/runner/provider/codex/launcher.go |
| +++ b/internal/runner/provider/codex/launcher.go |
| @@ -37,6 +37,7 @@ type Launcher struct { |
| } |
| type sessionState struct { |
| mcpCalls map[string]json.RawMessage |
| + nativeCalls map[string]json.RawMessage |
| requests map[string]provider.Event |
| mu sync.Mutex |
| op sync.Mutex |
| @@ -741,7 +742,14 @@ func (s *sessionState) handle(frame provider.Frame) error { |
| if ev.SessionID != "" && s.session.ID != "" && ev.SessionID != s.session.ID { |
| return provider.ErrIdentity |
| } |
| + if ev.TurnID == "" && ev.Kind == "request" { |
| + v, _ := parse(ev.Payload) |
| + if (v.Method == "execCommandApproval" || v.Method == "applyPatchApproval") && s.active && s.providerTurn != "" { |
| + ev.TurnID = s.providerTurn |
| + } |
| + } |
| if ev.TurnID != "" { |
| + ev.ProviderTurnID = ev.TurnID |
| if !s.active { |
| return errProtocol |
| } |
| @@ -779,8 +787,22 @@ func (s *sessionState) handle(frame provider.Frame) error { |
| delete(s.mcpCalls, envelope.Params.Item.ID) |
| } |
| } |
| + if envelope.Params.Item.Type == "fileChange" { |
| + if envelope.Method == "item/started" { |
| + if s.nativeCalls == nil { |
| + s.nativeCalls = map[string]json.RawMessage{} |
| + } |
| + if len(s.nativeCalls) >= 64 { |
| + return errProtocol |
| + } |
| + s.nativeCalls[envelope.Params.Item.ID] = bytes.Clone(ev.Payload) |
| + } else if envelope.Method == "item/completed" { |
| + delete(s.nativeCalls, envelope.Params.Item.ID) |
| + } |
| + } |
| if ev.Kind == "request" { |
| s.correlateMCP(&ev) |
| + s.correlateNative(&ev) |
| if s.requests == nil { |
| s.requests = map[string]provider.Event{} |
| } |
| @@ -794,6 +816,7 @@ func (s *sessionState) handle(frame provider.Frame) error { |
| s.active = false |
| s.requests = nil |
| s.mcpCalls = nil |
| + s.nativeCalls = nil |
| if e != nil && !errors.Is(e, provider.ErrRefreshPending) { |
| return e |
| } |
diff --git a/internal/runner/provider/codex/native_approval.go b/internal/runner/provider/codex/native_approval.go| new file mode 100644 |
| index 00000000..77ed9853 |
| --- /dev/null |
| +++ b/internal/runner/provider/codex/native_approval.go |
| @@ -0,0 +1,138 @@ |
| +package codex |
| + |
| +import ( |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "bytes" |
| + "encoding/json" |
| +) |
| + |
| +// NativeRequest retains the exact request and correlated file item. It carries |
| +// evidence, never a policy update or a replacement command. |
| +type NativeRequest struct { |
| + RequestID string `json:"request_id"` |
| + ItemID string `json:"item_id"` |
| + TurnID string `json:"turn_id"` |
| + SessionID string `json:"session_id"` |
| + Request json.RawMessage `json:"request"` |
| + ToolCall json.RawMessage `json:"tool_call,omitempty"` |
| +} |
| + |
| +func NativeApproval(ev provider.Event) (NativeRequest, error) { |
| + n := NativeRequest{RequestID: ev.RequestID, Request: bytes.Clone(ev.Payload)} |
| + v, err := parse(ev.Payload) |
| + if err != nil || string(v.ID) != ev.RequestID { |
| + return n, provider.ErrPolicy |
| + } |
| + if v.Method == "execCommandApproval" || v.Method == "applyPatchApproval" { |
| + return legacyNativeApproval(ev, v) |
| + } |
| + var p struct { |
| + ThreadID, TurnID, ItemID, Command, Cwd, Kind, GrantRoot string |
| + } |
| + if json.Unmarshal(v.Params, &p) != nil || p.ThreadID == "" || p.ThreadID != ev.SessionID || p.GrantRoot != "" || p.TurnID == "" || (ev.ProviderTurnID != "" && ev.ProviderTurnID != p.TurnID) || p.ItemID == "" { |
| + return n, provider.ErrPolicy |
| + } |
| + n.ItemID, n.TurnID, n.SessionID = p.ItemID, p.TurnID, p.ThreadID |
| + switch v.Method { |
| + case "item/commandExecution/requestApproval": |
| + if p.Command == "" || p.Cwd == "" || (p.Kind != "" && p.Kind != "command") { |
| + return n, provider.ErrPolicy |
| + } |
| + case "item/fileChange/requestApproval": |
| + call, err := parse(ev.ToolCall) |
| + if err != nil || call.Method != "item/started" { |
| + return n, provider.ErrPolicy |
| + } |
| + var c struct { |
| + ThreadID, TurnID string |
| + Item struct { |
| + ID, Type, Status string |
| + Changes []struct { |
| + Path string |
| + Diff *string |
| + Kind struct { |
| + Type string |
| + MovePath *string `json:"move_path"` |
| + } |
| + } |
| + } |
| + } |
| + if json.Unmarshal(call.Params, &c) != nil || c.ThreadID != p.ThreadID || c.TurnID != p.TurnID || c.Item.ID != p.ItemID || c.Item.Type != "fileChange" || c.Item.Status != "inProgress" || len(c.Item.Changes) == 0 { |
| + return n, provider.ErrPolicy |
| + } |
| + for _, change := range c.Item.Changes { |
| + if change.Path == "" || change.Diff == nil { |
| + return n, provider.ErrPolicy |
| + } |
| + switch change.Kind.Type { |
| + case "add", "delete", "update": |
| + default: |
| + return n, provider.ErrPolicy |
| + } |
| + } |
| + n.ToolCall = bytes.Clone(ev.ToolCall) |
| + default: |
| + return n, provider.ErrPolicy |
| + } |
| + return n, nil |
| +} |
| + |
| +func (s *sessionState) correlateNative(ev *provider.Event) { |
| + v, err := parse(ev.Payload) |
| + if err != nil || v.Method != "item/fileChange/requestApproval" { |
| + return |
| + } |
| + var p struct{ ItemID string } |
| + if json.Unmarshal(v.Params, &p) == nil { |
| + ev.ToolCall = bytes.Clone(s.nativeCalls[p.ItemID]) |
| + } |
| +} |
| + |
| +func legacyNativeApproval(ev provider.Event, v envelope) (NativeRequest, error) { |
| + n := NativeRequest{RequestID: ev.RequestID, Request: bytes.Clone(ev.Payload), TurnID: ev.ProviderTurnID} |
| + var p struct { |
| + ConversationID, CallID, Cwd, GrantRoot string |
| + Command []string |
| + FileChanges map[string]struct { |
| + Type string |
| + Content, UnifiedDiff *string |
| + MovePath *string `json:"move_path"` |
| + } |
| + } |
| + // Legacy update diffs use snake case. |
| + var changes struct{ FileChanges map[string]json.RawMessage } |
| + if json.Unmarshal(v.Params, &p) != nil || p.ConversationID != ev.SessionID || p.ConversationID == "" || p.CallID == "" || p.GrantRoot != "" || ev.ProviderTurnID == "" { |
| + return n, provider.ErrPolicy |
| + } |
| + n.SessionID, n.ItemID = p.ConversationID, p.CallID |
| + if v.Method == "execCommandApproval" { |
| + if len(p.Command) == 0 || p.Command[0] == "" || p.Cwd == "" { |
| + return n, provider.ErrPolicy |
| + } |
| + } else { |
| + if len(p.FileChanges) == 0 || json.Unmarshal(v.Params, &changes) != nil { |
| + return n, provider.ErrPolicy |
| + } |
| + for path, change := range p.FileChanges { |
| + if path == "" { |
| + return n, provider.ErrPolicy |
| + } |
| + switch change.Type { |
| + case "add", "delete": |
| + if change.Content == nil { |
| + return n, provider.ErrPolicy |
| + } |
| + case "update": |
| + var c struct { |
| + Diff *string `json:"unified_diff"` |
| + } |
| + if json.Unmarshal(changes.FileChanges[path], &c) != nil || c.Diff == nil { |
| + return n, provider.ErrPolicy |
| + } |
| + default: |
| + return n, provider.ErrPolicy |
| + } |
| + } |
| + } |
| + return n, nil |
| +} |
diff --git a/internal/runner/provider/types.go b/internal/runner/provider/types.go| index 5f9719b1..b27bc731 100644 |
| --- a/internal/runner/provider/types.go |
| +++ b/internal/runner/provider/types.go |
| @@ -79,6 +79,7 @@ type Answer struct { |
| } |
| type Event struct { |
| + ProviderTurnID string `json:"provider_turn_id,omitempty"` |
| // ToolCall is the captured item/started frame correlated by the adapter. |
| ToolCall json.RawMessage `json:",omitempty"` |
| Sequence int64 `json:"capture_sequence,omitempty"` |
diff --git a/internal/runner/questions.go b/internal/runner/questions.go| index b0d5c51f..1ca8c47e 100644 |
| --- a/internal/runner/questions.go |
| +++ b/internal/runner/questions.go |
| @@ -97,6 +97,9 @@ func (r *QuestionRelay) Deliver(ctx context.Context, q runnerproto.Question, ans |
| } |
| key := runnerproto.EventHash([]any{q.TaskID, q.Attempt, q.Fence, q.ServerID, q.AgentID, q.SessionID, q.PermissionID}) |
| hash := runnerproto.EventHash([]any{q.ID, q.Revision, q.RawRequest, answer}) |
| + if _, err := q.NativeApproval(); err == nil && answer.Behavior == "allow" { |
| + hash = runnerproto.EventHash([]any{q.ID, q.Revision, q.RawRequest, answer, q.AnsweredBy}) |
| + } |
| if err := r.Journal.AdmissionAllowed(ctx); err != nil { |
| return err |
| } |
| @@ -138,6 +141,21 @@ func (r *QuestionRelay) Deliver(ctx context.Context, q runnerproto.Question, ans |
| return err |
| } |
| } |
| + if _, nativeErr := q.NativeApproval(); nativeErr == nil && answer.Behavior == "allow" { |
| + if q.AnsweredBy == "" { |
| + return runnerproto.ErrInvalid |
| + } |
| + saved := q |
| + saved.Answer = &answer |
| + raw, err := json.Marshal(saved) |
| + if err != nil { |
| + return err |
| + } |
| + if _, err = tx.ExecContext(ctx, "INSERT INTO journal_supervisor(kind,state_key,body) VALUES('profile-approval',?,?)", key, raw); err != nil { |
| + tx.Rollback() |
| + return r.Journal.storageFailure(ctx, err) |
| + } |
| + } |
| if err = tx.Commit(); err != nil { |
| return r.Journal.storageFailure(ctx, err) |
| } |
diff --git a/internal/runnerproto/questions.go b/internal/runnerproto/questions.go| index bce051c2..022e6ed9 100644 |
| --- a/internal/runnerproto/questions.go |
| +++ b/internal/runnerproto/questions.go |
| @@ -1,6 +1,8 @@ |
| package runnerproto |
| import ( |
| + "amadan.net/oficina/equipo/internal/runner/provider" |
| + "amadan.net/oficina/equipo/internal/runner/provider/codex" |
| "bytes" |
| "encoding/json" |
| "slices" |
| @@ -80,6 +82,9 @@ func (q Question) ValidateAnswer(a QuestionAnswer) error { |
| if DecodeLimit(bytes.NewReader(q.RawRequest), new(map[string]any), MaxEventBytes) != nil || json.Unmarshal(q.RawRequest, &raw) != nil { |
| return ErrInvalid |
| } |
| + if _, err := q.NativeApproval(); err == nil { |
| + return nil |
| + } |
| if raw.Direct && raw.Provider == "claude" && slices.Contains([]string{"Read", "Write", "Edit", "Glob", "Grep", "Bash"}, raw.Name) { |
| return nil |
| } |
| @@ -161,3 +166,43 @@ func (q Question) ValidateAnswer(a QuestionAnswer) error { |
| } |
| return nil |
| } |
| + |
| +// NativeApproval validates the saved envelope as well as its original Codex |
| +// frame. The local turn and provider turn are deliberately separate identities. |
| +func (q Question) NativeApproval() (codex.NativeRequest, error) { |
| + var raw struct { |
| + Direct bool |
| + Provider, Name string |
| + TurnID string `json:"turn_id"` |
| + ProviderTurnID string `json:"provider_turn_id"` |
| + Request json.RawMessage |
| + ToolCall json.RawMessage `json:"tool_call"` |
| + Input json.RawMessage |
| + } |
| + if q.Validate() != nil || q.Kind != "tool" || json.Unmarshal(q.RawRequest, &raw) != nil || !raw.Direct || raw.Provider != "codex" || raw.TurnID == "" { |
| + return codex.NativeRequest{}, ErrInvalid |
| + } |
| + var frame struct { |
| + Method string |
| + Params json.RawMessage |
| + } |
| + if json.Unmarshal(raw.Request, &frame) != nil || raw.Name != frame.Method || !SameRequestJSON(raw.Input, frame.Params) { |
| + return codex.NativeRequest{}, ErrInvalid |
| + } |
| + return codex.NativeApproval(provider.Event{Kind: "request", SessionID: q.SessionID, TurnID: raw.TurnID, ProviderTurnID: raw.ProviderTurnID, RequestID: q.PermissionID, Payload: raw.Request, ToolCall: raw.ToolCall}) |
| +} |
| + |
| +// SameRequestJSON preserves string bytes and JSON number spelling while allowing |
| +// object key order to change during durable encoding. |
| +func SameRequestJSON(a, b json.RawMessage) bool { |
| + decode := func(raw json.RawMessage) (any, error) { |
| + var v any |
| + d := json.NewDecoder(bytes.NewReader(raw)) |
| + d.UseNumber() |
| + err := d.Decode(&v) |
| + return v, err |
| + } |
| + x, ex := decode(a) |
| + y, ey := decode(b) |
| + return ex == nil && ey == nil && EventHash(x) == EventHash(y) |
| +} |