oficina / equipo Public

fix: pin the amadan CLI path and retry descriptions never sent

codex agent, operated by paul@keymail.dev pushed by claude agent, operated by paul@keymail.dev 5e65e7da3be0baf347f8256f984034db60a4a613 parent 97126e1
11 files changed, +818 −19
  • docs/live-gate.md +1 −0
  • docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md +658 −0
  • internal/equipotest/publish_test.go +1 −1
  • internal/runner/config.go +7 −3
  • internal/runner/config_test.go +54 −1
  • internal/runner/final_diagnostics_test.go +1 −1
  • internal/runner/forge/description_test.go +48 −3
  • internal/runner/forge/description_transport.go +20 −4
  • internal/runner/forge/publisher.go +9 −1
  • internal/runner/forge/publisher_test.go +18 −4
  • internal/runner/runtime_workflow.go +1 −1

CI failed — run details

diff --git a/docs/live-gate.md b/docs/live-gate.md
index 6b53a2c0..55622451 100644
--- a/docs/live-gate.md
+++ b/docs/live-gate.md
@@ -395,6 +395,7 @@ value. `runner.config.path` means the path must be absolute and canonical;
| EQUIPO_WORKSPACE_ROOT | Disposable checkout directory outside private state | /home/equipo-runner/equipo-work |
| EQUIPO_SCRATCH_ROOT | On-disk scratch directory outside private state | /home/equipo-runner/.cache/equipo-scratch |
| EQUIPO_GIT_PATH | Git executable | /usr/bin/git |
+| EQUIPO_AMADAN_PATH | Absolute path to the installed Amadan executable | /home/equipo-runner/.local/bin/amadan |
| EQUIPO_RUNNER_EXECUTABLE | Runner from the versioned bundle | /home/equipo-runner/.local/lib/equipo-runner/equipo-runner |
The runner supplies the following variables to its children. Do not set them in
diff --git a/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md b/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md
index 5be0877a..198f26d5 100644
--- a/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md
+++ b/docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md
@@ -22720,3 +22720,661 @@ intentional conservative outcome, not delivery success.
All test servers close through cleanup. All fake commands exit or are killed on
cancellation. Task scratch under `/home/paulca/t/e2b/task10` is removed after its
evidence is copied here. Go caches are unchanged. No push, merge or deployment.
+
+
+# Task 10 fix round 1: pinned CLI and never-sent description recovery
+
+Status: DONE_WITH_CONCERNS. Baseline: `97126e1`. Branch: `plan-2b`.
+Workspace: `/home/paulca/amadan.net/oficina/equipo-plan-2b`.
+Commit subject: `fix: pin the amadan CLI path and retry descriptions never sent`.
+
+## Built
+
+The runner now requires `EQUIPO_AMADAN_PATH`. Startup rejects missing, relative,
+unclean, nonexistent, directory and non-executable paths. Runtime publication
+passes this configured absolute path to the writer. The live-gate prerequisite
+table includes it; the release manifest and live-gate script have no comparable
+Git/Amadan binary prerequisite list to extend.
+
+The writer uses the existing distinct `team.ErrNotDispatched` sentinel for
+failures before `cmd.Start` succeeds, including validation, scratch setup,
+credential serialization/write and command startup. The original sanitized error
+remains available through `errors.Is`. A missing writer also returns this sentinel.
+Once Start succeeds, cancellation and nonzero exit remain uncertain. The writer
+still discards child output and removes its fake/test or production temporary
+command state on return.
+
+The publisher journals the attempted flag before calling Set. Only a returned
+not-dispatched error allows it to persist a cleared flag for a later reconciliation.
+It still returns uncertain because the review ref already exists. A crash before
+that reset is durable leaves the flag set. An unsuccessful reset also returns
+uncertain. Any command that started retains the flag, so recovery only reads.
+The restart regression proves one failed dispatch, one later write, GET confirmation
+and exactly one Git push. Existing lost-reply and empty-readback tests remain green.
+
+The credential file is now a flat JSON map from hub origin to token, as required by
+Amadan at `bcc0e66`. The fake-command test checks that exact layout, the credential
+path and modes, existing argv order, stdin body, private environment and cleanup.
+The argv order and integer `at` reader already match the source and need no change.
+
+## Files
+
+- `internal/runner/config.go`: configured Amadan executable and startup validation.
+- `internal/runner/config_test.go`: missing/relative/unclean/missing-file/directory/non-executable tests and a local executable fixture.
+- `internal/runner/final_diagnostics_test.go`: add the Amadan path diagnostic case.
+- `internal/runner/runtime_workflow.go`: pass the configured path.
+- `internal/runner/forge/description_transport.go`: pre-start classification, Start/Wait boundary and flat credentials map.
+- `internal/runner/forge/description_test.go`: source-backed credential fixture and failure classification tests.
+- `internal/runner/forge/publisher.go`: durable retry permission for a proven unsent description.
+- `internal/runner/forge/publisher_test.go`: restart recovery and durable-intent assertions.
+- `internal/equipotest/publish_test.go`: require the configured executable in production wiring.
+- `docs/live-gate.md`: one prerequisite row, covered by the file's existing draft-copy marker.
+- `docs/superpowers/plans/CONTROLLER-REPORT-plan-2b.md`: this appended fix section.
+- `.superpowers/sdd/2026-11-03-equipo-plan-2b-direct/task-10-report.md`: the same appended section in the ignored controller workspace.
+
+## Source verification at Amadan bcc0e66
+
+The only access to `/home/paulca/amadan.net/amadan/amadan` was read-only `git show`
+and `git grep` at the requested commit. No Amadan command or endpoint was called.
+These source findings supersede the original report's binary-inspection inference
+about a nested `tokens` map:
+
+- `internal/helper/state.go:69-95`: Home uses AMADAN_HOME directly, and CredentialsPath appends `credentials`.
+- `internal/helper/state.go:154-179`: Credentials is `map[string]string`; LoadCredentials unmarshals the entire file directly into that flat map.
+- `internal/cli/hubaddr.go:232-249`: CredentialFor normalizes the hub and indexes the loaded map by the hub origin. The writer supplies only the `https://amadan.net` entry with the fake test token in offline tests.
+- `cmd/amadan/main.go:1386-1430`: branch describe registers body and hub flags, invokes parseInterspersed at line 1398, accepts repository plus branch positionals and reads body from stdin.
+- `cmd/amadan/main.go:555-565`: the parser delegates to cli.ParseInterspersed.
+- `internal/cli/argparse.go:32-58`: separates flags from positionals before calling Go's flag parser, consuming `-` as the body flag value. Thus the existing `branch describe <ns>/<repo> <name> -hub https://amadan.net -body -` order is supported.
+- `internal/hub/branch_description.go:20-26,43-47,65-70`: the GET response's `at` is int64 JSON, taken from int64 description_at. The existing reader accepts int64; TestAmadanDescriptionReadback checks retained numeric `at` and rejects malformed `at`.
+
+Exact source commands (line ranges above identify the inspected portions):
+
+```sh
+git -C /home/paulca/amadan.net/amadan/amadan show bcc0e66:internal/helper/state.go
+git -C /home/paulca/amadan.net/amadan/amadan show bcc0e66:internal/cli/hubaddr.go
+git -C /home/paulca/amadan.net/amadan/amadan show bcc0e66:cmd/amadan/main.go
+git -C /home/paulca/amadan.net/amadan/amadan show bcc0e66:internal/cli/argparse.go
+git -C /home/paulca/amadan.net/amadan/amadan show bcc0e66:internal/hub/branch_description.go
+```
+
+## Interpretations
+
+1. The round-1 findings and requested commit subject supersede the original brief's implementation/commit instructions where they differ.
+2. The source at `bcc0e66` is the requested CLI contract. The flat credential map is mandatory despite the original report's contrary inference. No fallback to another credential format or live CLI probe was added.
+3. `team.ErrNotDispatched` already distinguishes a known unsent operation. Reusing it avoids another public error string. Publisher returns `team.ErrUncertain`, rather than claiming the whole publication was not dispatched, because the Git ref was pushed.
+4. The explicit source-inspection request permits read-only access to the named Amadan repository. All edits, tests and Git mutations stayed in the Equipo workspace; scratch stayed under the supplied on-disk TMPDIR.
+5. Tests use disposable state containing only `fake-only` credentials and fake commands, as the original offline tests do. No real credential home, provider session, enrollment or login was created or accessed.
+6. Controller evidence is written directly under the run instructions. No copy-review skill/server, agent, handoff file or README edit was used.
+7. The initial broad test command exposed existing diagnostics assertions for five optional legacy Paseo settings. Those requirements are outside this fix. The adjusted targeted command keeps TestRunnerConfig and TestRunnerConfigAmadanPath, plus the relevant AmadanPath/GitPath diagnostic cases. It does not change legacy runtime validation to make obsolete expectations pass.
+
+## RED evidence
+
+Tests were changed before production code. The initial run compiled and failed on
+the flat credentials fixture, missing pre-start classification, permanently latched
+unsent description, missing executable validation and production path wiring.
+All commands ran in the workspace above with CGO_ENABLED=0 and default Go caches.
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge ./internal/runner ./internal/equipotest -run 'TestAmadanDescription|TestPublishDescription|TestPublishTransport|TestConfig|TestRunnerConfig' -count=1
+```
+
+Go exit 1. Recorded output:
+
+```text
+--- FAIL: TestAmadanDescriptionCommand (0.02s)
+ description_test.go:214: team: uncertain
+--- FAIL: TestAmadanDescriptionNotDispatched (0.00s)
+ --- FAIL: TestAmadanDescriptionNotDispatched/validation (0.00s)
+ description_test.go:320: pre-start failure must allow retry: team: invalid
+ --- FAIL: TestAmadanDescriptionNotDispatched/relative_path (0.00s)
+ description_test.go:320: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/unclean_path (0.00s)
+ description_test.go:320: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/missing_command (0.00s)
+ description_test.go:320: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/not_executable (0.00s)
+ description_test.go:320: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/scratch (0.00s)
+ description_test.go:320: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/cancelled (0.00s)
+ description_test.go:320: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/missing_writer (0.00s)
+ description_test.go:320: pre-start failure must allow retry: team: uncertain
+--- FAIL: TestPublishDescriptionRecovery (1.21s)
+ --- FAIL: TestPublishDescriptionRecovery/not_dispatched (0.13s)
+ publisher_test.go:645: never-sent description latched as attempted
+FAIL
+rastrillo-budget/v1 ran 1.853s
+FAIL amadan.net/oficina/equipo/internal/runner/forge 1.856s
+--- FAIL: TestRunnerConfigAmadanPath (0.00s)
+ --- FAIL: TestRunnerConfigAmadanPath/unset (0.00s)
+ config_test.go:192: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+ --- FAIL: TestRunnerConfigAmadanPath/relative (0.00s)
+ config_test.go:192: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+ --- FAIL: TestRunnerConfigAmadanPath/unclean (0.00s)
+ config_test.go:192: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+ --- FAIL: TestRunnerConfigAmadanPath/missing (0.00s)
+ config_test.go:192: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+ --- FAIL: TestRunnerConfigAmadanPath/directory (0.00s)
+ config_test.go:192: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+ --- FAIL: TestRunnerConfigAmadanPath/not_executable (0.00s)
+ config_test.go:192: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+--- FAIL: TestConfigDiagnosticNamesVariable (0.00s)
+ --- FAIL: TestConfigDiagnosticNamesVariable/PaseoEndpoint (0.00s)
+ final_diagnostics_test.go:17: diagnostic lost variable runner.command -
+ --- FAIL: TestConfigDiagnosticNamesVariable/NodePath (0.00s)
+ final_diagnostics_test.go:17: diagnostic lost variable runner.command -
+ --- FAIL: TestConfigDiagnosticNamesVariable/PaseoServerID (0.00s)
+ final_diagnostics_test.go:17: diagnostic lost variable runner.command -
+ --- FAIL: TestConfigDiagnosticNamesVariable/BridgePath (0.00s)
+ final_diagnostics_test.go:17: diagnostic lost variable runner.command -
+ --- FAIL: TestConfigDiagnosticNamesVariable/PaseoHome (0.00s)
+ final_diagnostics_test.go:17: diagnostic lost variable runner.command -
+FAIL
+rastrillo-budget/v1 ran 7ms
+FAIL amadan.net/oficina/equipo/internal/runner 0.009s
+--- FAIL: TestPublishTransportIsProduction (0.00s)
+ publish_test.go:103: runtime publication still uses unavailable description transport
+FAIL
+rastrillo-budget/v1 ran 5ms
+FAIL amadan.net/oficina/equipo/internal/equipotest 0.055s
+FAIL
+```
+
+## GREEN evidence
+
+After implementation, the adjusted covering command passed. It was repeated after
+all mutations were restored; all three packages passed again.
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge ./internal/runner ./internal/equipotest -run 'TestAmadanDescription|TestPublishDescription|TestPublishTransport|TestRunnerConfig|TestConfigDiagnosticNamesVariable/(AmadanPath|GitPath)$' -count=1
+```
+
+Final Go exit 0:
+
+```text
+ok amadan.net/oficina/equipo/internal/runner/forge 2.030s
+ok amadan.net/oficina/equipo/internal/runner 0.006s
+ok amadan.net/oficina/equipo/internal/equipotest 0.055s
+```
+
+`git diff --check` passed. Only targeted tests were run; no make ci, whole suite,
+live gate, real Amadan CLI invocation, live read or live write was performed.
+
+## Mutation evidence
+
+Each mutation below was applied alone, compiled, failed the named test with Go
+exit 1, and was restored before the next mutation. None was a compile failure.
+The final covering GREEN above ran after restoring all 13 mutations.
+
+### R1-M1: config_load
+
+File: `internal/runner/config.go`. Replace:
+
+```go
+AmadanPath: getenv("EQUIPO_AMADAN_PATH")
+```
+
+with:
+
+```go
+AmadanPath: ""
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner -run '^TestRunnerConfigAmadanPath$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestRunnerConfigAmadanPath (0.00s)
+ config_test.go:183: runner.config.path:EQUIPO_AMADAN_PATH
+FAIL
+rastrillo-budget/v1 ran 0s
+FAIL amadan.net/oficina/equipo/internal/runner 0.002s
+FAIL
+```
+
+### R1-M2: config_absolute_clean
+
+File: `internal/runner/config.go`. Replace:
+
+```go
+{"EQUIPO_AMADAN_PATH", c.AmadanPath},
+```
+
+with:
+
+```go
+
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner -run '^TestRunnerConfigAmadanPath$/(relative|unclean)$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestRunnerConfigAmadanPath (0.00s)
+ --- FAIL: TestRunnerConfigAmadanPath/relative (0.00s)
+ config_test.go:209: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+ --- FAIL: TestRunnerConfigAmadanPath/unclean (0.00s)
+ config_test.go:209: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+FAIL
+rastrillo-budget/v1 ran 1ms
+FAIL amadan.net/oficina/equipo/internal/runner 0.003s
+FAIL
+```
+
+### R1-M3: config_executable
+
+File: `internal/runner/config.go`. Replace:
+
+```go
+if err != nil || !info.Mode().IsRegular() || info.Mode().Perm()&0111 == 0 {
+```
+
+with:
+
+```go
+if false && (err != nil || !info.Mode().IsRegular() || info.Mode().Perm()&0111 == 0) {
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner -run '^TestRunnerConfigAmadanPath$/(missing|directory|not_executable)$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestRunnerConfigAmadanPath (0.00s)
+ --- FAIL: TestRunnerConfigAmadanPath/missing (0.00s)
+ config_test.go:209: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+ --- FAIL: TestRunnerConfigAmadanPath/directory (0.00s)
+ config_test.go:209: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+ --- FAIL: TestRunnerConfigAmadanPath/not_executable (0.00s)
+ config_test.go:209: invalid Amadan path accepted or misdiagnosed: <nil> (-)
+FAIL
+rastrillo-budget/v1 ran 1ms
+FAIL amadan.net/oficina/equipo/internal/runner 0.005s
+FAIL
+```
+
+### R1-M4: runtime_path
+
+File: `internal/runner/runtime_workflow.go`. Replace:
+
+```go
+NewCommandDescriptionWriter(r.cfg.AmadanPath,
+```
+
+with:
+
+```go
+NewCommandDescriptionWriter("amadan",
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/equipotest -run '^TestPublishTransportIsProduction$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestPublishTransportIsProduction (0.00s)
+ publish_test.go:103: runtime publication still uses unavailable description transport
+FAIL
+rastrillo-budget/v1 ran 0s
+FAIL amadan.net/oficina/equipo/internal/equipotest 0.057s
+FAIL
+```
+
+### R1-M5: writer_path
+
+File: `internal/runner/forge/description_transport.go`. Replace:
+
+```go
+if !filepath.IsAbs(w.path) || filepath.Clean(w.path) != w.path {
+```
+
+with:
+
+```go
+if false && (!filepath.IsAbs(w.path) || filepath.Clean(w.path) != w.path) {
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestAmadanDescriptionNotDispatched$/(relative_path|unclean_path)$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestAmadanDescriptionNotDispatched (0.00s)
+ --- FAIL: TestAmadanDescriptionNotDispatched/relative_path (0.00s)
+ description_test.go:330: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/unclean_path (0.00s)
+ description_test.go:330: pre-start failure must allow retry: team: uncertain
+FAIL
+rastrillo-budget/v1 ran 3ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.005s
+FAIL
+```
+
+### R1-M6: prestart_classification
+
+File: `internal/runner/forge/description_transport.go`. Replace:
+
+```go
+if err != nil && !started {
+```
+
+with:
+
+```go
+if false && err != nil && !started {
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestAmadanDescriptionNotDispatched$/(validation|missing_command|not_executable|scratch|cancelled)$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestAmadanDescriptionNotDispatched (0.00s)
+ --- FAIL: TestAmadanDescriptionNotDispatched/validation (0.00s)
+ description_test.go:330: pre-start failure must allow retry: team: invalid
+ --- FAIL: TestAmadanDescriptionNotDispatched/missing_command (0.00s)
+ description_test.go:330: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/not_executable (0.00s)
+ description_test.go:330: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/scratch (0.00s)
+ description_test.go:330: pre-start failure must allow retry: team: uncertain
+ --- FAIL: TestAmadanDescriptionNotDispatched/cancelled (0.00s)
+ description_test.go:330: pre-start failure must allow retry: team: uncertain
+FAIL
+rastrillo-budget/v1 ran 1ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.004s
+FAIL
+```
+
+### R1-M7: started_classification
+
+File: `internal/runner/forge/description_transport.go`. Replace:
+
+```go
+started = true
+```
+
+with:
+
+```go
+started = false
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestAmadanDescriptionNotDispatched$/started$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestAmadanDescriptionNotDispatched (0.00s)
+ --- FAIL: TestAmadanDescriptionNotDispatched/started (0.00s)
+ description_test.go:327: started command declared safe to retry: team: not_dispatched
+ team: uncertain
+FAIL
+rastrillo-budget/v1 ran 2ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.004s
+FAIL
+```
+
+### R1-M8: missing_writer
+
+File: `internal/runner/forge/description_transport.go`. Replace:
+
+```go
+if t.writer == nil {
+ return team.ErrNotDispatched
+```
+
+with:
+
+```go
+if t.writer == nil {
+ return team.ErrUncertain
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestAmadanDescriptionNotDispatched$/missing_writer$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestAmadanDescriptionNotDispatched (0.00s)
+ --- FAIL: TestAmadanDescriptionNotDispatched/missing_writer (0.00s)
+ description_test.go:330: pre-start failure must allow retry: team: uncertain
+FAIL
+rastrillo-budget/v1 ran 1ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.003s
+FAIL
+```
+
+### R1-M9: credential_layout
+
+File: `internal/runner/forge/description_transport.go`. Replace:
+
+```go
+json.Marshal(map[string]string{"https://amadan.net": c.Bearer})
+```
+
+with:
+
+```go
+json.Marshal(map[string]any{"tokens": map[string]string{"https://amadan.net": c.Bearer}})
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestAmadanDescriptionCommand$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestAmadanDescriptionCommand (0.02s)
+ description_test.go:214: team: uncertain
+FAIL
+rastrillo-budget/v1 ran 20ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.022s
+FAIL
+```
+
+### R1-M10: retry_never_sent
+
+File: `internal/runner/forge/publisher.go`. Replace:
+
+```go
+errors.Is(e, team.ErrNotDispatched) {
+```
+
+with:
+
+```go
+false && errors.Is(e, team.ErrNotDispatched) {
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestPublishDescriptionRecovery$/not_dispatched$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestPublishDescriptionRecovery (0.22s)
+ --- FAIL: TestPublishDescriptionRecovery/not_dispatched (0.22s)
+ publisher_test.go:648: never-sent description latched as attempted
+FAIL
+rastrillo-budget/v1 ran 221ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.229s
+FAIL
+```
+
+### R1-M11: retry_durable
+
+File: `internal/runner/forge/publisher.go`. Replace:
+
+```go
+r.DescriptionAttempted = false
+ if e = runnerproto.JournalCredentials(p.path(r.Authorization.Ticket.Dispatch), *r); e != nil {
+```
+
+with:
+
+```go
+r.DescriptionAttempted = false
+ if false {
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestPublishDescriptionRecovery$/not_dispatched$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestPublishDescriptionRecovery (0.17s)
+ --- FAIL: TestPublishDescriptionRecovery/not_dispatched (0.17s)
+ publisher_test.go:648: never-sent description latched as attempted
+FAIL
+rastrillo-budget/v1 ran 168ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.171s
+FAIL
+```
+
+### R1-M12: retry_uncertain
+
+File: `internal/runner/forge/publisher.go`. Replace:
+
+```go
+errors.Is(e, team.ErrNotDispatched) {
+```
+
+with:
+
+```go
+(errors.Is(e, team.ErrNotDispatched) || e != nil) {
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestPublishDescriptionRecovery$/empty$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestPublishDescriptionRecovery (0.18s)
+ --- FAIL: TestPublishDescriptionRecovery/empty (0.18s)
+ publisher_test.go:672: duplicate write/push or skipped GET 3 1 3
+FAIL
+rastrillo-budget/v1 ran 179ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.182s
+FAIL
+```
+
+### R1-M13: intent_before_start
+
+File: `internal/runner/forge/publisher.go`. Replace:
+
+```go
+r.DescriptionAttempted = true
+ if e = runnerproto.JournalCredentials(p.path(r.Authorization.Ticket.Dispatch), *r); e != nil {
+```
+
+with:
+
+```go
+r.DescriptionAttempted = true
+ if false {
+```
+
+Command:
+
+```sh
+CGO_ENABLED=0 go test ./internal/runner/forge -run '^TestPublishDescriptionRecovery$/lost_reply$' -count=1
+```
+
+Go exit 1; output:
+
+```text
+--- FAIL: TestPublishDescriptionRecovery (0.11s)
+ --- FAIL: TestPublishDescriptionRecovery/lost_reply (0.11s)
+ publisher_test.go:616: description intent not durable before write
+FAIL
+rastrillo-budget/v1 ran 109ms
+FAIL amadan.net/oficina/equipo/internal/runner/forge 0.111s
+FAIL
+```
+
+## User-facing strings
+
+No new copy.go entries or application prose. Existing configuration diagnostics
+and team error sentinels are reused. `EQUIPO_AMADAN_PATH` is the new diagnostic
+variable identifier. The one new documentation row is:
+
+```text
+| EQUIPO_AMADAN_PATH | Absolute path to the installed Amadan executable | /home/equipo-runner/.local/bin/amadan |
+```
+
+This row remains pending copy review under docs/live-gate.md's existing
+`DRAFT: copy review required` marker. New test diagnostics and internal code
+comments are not application copy. No copy-review server was started.
+
+## Concerns and cleanup
+
+The broad initial command still includes five pre-existing failing subtests in
+TestConfigDiagnosticNamesVariable: PaseoEndpoint, PaseoServerID, PaseoHome, NodePath
+and BridgePath. They expect required settings that config.validate already treats
+as optional. Their production behavior and test assertions were left unchanged.
+The controller should reconcile those assertions during the remaining direct-runner
+cutover. All tests selected for this fix pass.
+
+Previously latched journals cannot prove whether a command started. They remain
+read-only after upgrade; this change does not clear historical uncertain attempts.
+A crash between journaling intent and persisting a proven pre-start failure likewise
+remains conservative. These limits prevent an automatic duplicate write.
+
+The real installed binary was not executed. Compatibility was checked against the
+requested source revision and offline fixtures; live publication remains untested.
+The configured installation must implement that source contract.
+
+All local test servers and fake children finished through test cleanup. Scratch
+under `/home/paulca/t/e2b/task10-r1` is removed after copying its evidence into these
+reports. Go caches remain at their defaults. No push, merge or deployment.
diff --git a/internal/equipotest/publish_test.go b/internal/equipotest/publish_test.go
index 11da1001..c387f357 100644
--- a/internal/equipotest/publish_test.go
+++ b/internal/equipotest/publish_test.go
@@ -99,7 +99,7 @@ func TestPublishTransportIsProduction(t *testing.T) {
raw, err := os.ReadFile("../runner/runtime_workflow.go")
executionMust(t, err)
source := string(raw)
- if strings.Contains(source, "unavailableDescription") || !strings.Contains(source, "Description: forge.NewDescriptionTransport(") || !strings.Contains(source, "forge.NewCommandDescriptionWriter(") {
+ if strings.Contains(source, "unavailableDescription") || !strings.Contains(source, "Description: forge.NewDescriptionTransport(") || !strings.Contains(source, "forge.NewCommandDescriptionWriter(r.cfg.AmadanPath, r.cfg.ScratchRoot)") {
t.Fatal("runtime publication still uses unavailable description transport")
}
for _, wiring := range []string{"Launchers: r.launchers", "Namespaces: r.namespaces", "Launch: r.directLaunch"} {
diff --git a/internal/runner/config.go b/internal/runner/config.go
index 370cef20..23cab788 100644
--- a/internal/runner/config.go
+++ b/internal/runner/config.go
@@ -21,13 +21,13 @@ type Config struct {
ClaudePath string
Report func(string)
Origin, StateDir, PaseoHome, NodePath, BridgePath, AmadanCredentialPath, AccountBindingsPath, CodexPath string
- GoRoot, GoBinary, WorkspaceRoot, ScratchRoot, GitPath, Executable string
+ GoRoot, GoBinary, WorkspaceRoot, ScratchRoot, GitPath, AmadanPath, Executable string
PaseoEndpoint, PaseoServerID, InstanceID string
Copy ToolCopy
}
func LoadConfig(getenv func(string) string) (Config, error) {
- c := Config{BwrapPath: getenv("EQUIPO_BWRAP_PATH"), ModuleCache: getenv("EQUIPO_GO_MODULE_CACHE"), ClaudePath: getenv("EQUIPO_CLAUDE_PATH"), Origin: getenv("EQUIPO_ORIGIN"), StateDir: getenv("EQUIPO_RUNNER_STATE_DIR"), PaseoHome: getenv("EQUIPO_PASEO_HOME"), NodePath: getenv("EQUIPO_NODE_PATH"), BridgePath: getenv("EQUIPO_BRIDGE_PATH"), AmadanCredentialPath: getenv("EQUIPO_AMADAN_CREDENTIAL_PATH"), AccountBindingsPath: getenv("EQUIPO_ACCOUNT_BINDINGS_PATH"), CodexPath: getenv("EQUIPO_CODEX_PATH"), GoRoot: getenv("EQUIPO_GO_ROOT"), GoBinary: getenv("EQUIPO_GO_BINARY"), WorkspaceRoot: getenv("EQUIPO_WORKSPACE_ROOT"), ScratchRoot: getenv("EQUIPO_SCRATCH_ROOT"), GitPath: getenv("EQUIPO_GIT_PATH"), Executable: getenv("EQUIPO_RUNNER_EXECUTABLE"), PaseoEndpoint: getenv("EQUIPO_PASEO_ENDPOINT"), PaseoServerID: getenv("EQUIPO_PASEO_SERVER_ID"), InstanceID: getenv("EQUIPO_INSTANCE_ID")}
+ c := Config{BwrapPath: getenv("EQUIPO_BWRAP_PATH"), ModuleCache: getenv("EQUIPO_GO_MODULE_CACHE"), ClaudePath: getenv("EQUIPO_CLAUDE_PATH"), Origin: getenv("EQUIPO_ORIGIN"), StateDir: getenv("EQUIPO_RUNNER_STATE_DIR"), PaseoHome: getenv("EQUIPO_PASEO_HOME"), NodePath: getenv("EQUIPO_NODE_PATH"), BridgePath: getenv("EQUIPO_BRIDGE_PATH"), AmadanCredentialPath: getenv("EQUIPO_AMADAN_CREDENTIAL_PATH"), AccountBindingsPath: getenv("EQUIPO_ACCOUNT_BINDINGS_PATH"), CodexPath: getenv("EQUIPO_CODEX_PATH"), GoRoot: getenv("EQUIPO_GO_ROOT"), GoBinary: getenv("EQUIPO_GO_BINARY"), WorkspaceRoot: getenv("EQUIPO_WORKSPACE_ROOT"), ScratchRoot: getenv("EQUIPO_SCRATCH_ROOT"), GitPath: getenv("EQUIPO_GIT_PATH"), AmadanPath: getenv("EQUIPO_AMADAN_PATH"), Executable: getenv("EQUIPO_RUNNER_EXECUTABLE"), PaseoEndpoint: getenv("EQUIPO_PASEO_ENDPOINT"), PaseoServerID: getenv("EQUIPO_PASEO_SERVER_ID"), InstanceID: getenv("EQUIPO_INSTANCE_ID")}
return c, c.validate()
}
func validOrigin(origin string) bool {
@@ -50,12 +50,16 @@ func (c Config) validate() error {
}
}
for _, v := range []struct{ name, path string }{
- {"EQUIPO_RUNNER_STATE_DIR", c.StateDir}, {"EQUIPO_AMADAN_CREDENTIAL_PATH", c.AmadanCredentialPath}, {"EQUIPO_ACCOUNT_BINDINGS_PATH", c.AccountBindingsPath}, {"EQUIPO_CODEX_PATH", c.CodexPath}, {"EQUIPO_GO_ROOT", c.GoRoot}, {"EQUIPO_GO_BINARY", c.GoBinary}, {"EQUIPO_WORKSPACE_ROOT", c.WorkspaceRoot}, {"EQUIPO_SCRATCH_ROOT", c.ScratchRoot}, {"EQUIPO_GIT_PATH", c.GitPath}, {"EQUIPO_RUNNER_EXECUTABLE", c.Executable},
+ {"EQUIPO_RUNNER_STATE_DIR", c.StateDir}, {"EQUIPO_AMADAN_CREDENTIAL_PATH", c.AmadanCredentialPath}, {"EQUIPO_ACCOUNT_BINDINGS_PATH", c.AccountBindingsPath}, {"EQUIPO_CODEX_PATH", c.CodexPath}, {"EQUIPO_GO_ROOT", c.GoRoot}, {"EQUIPO_GO_BINARY", c.GoBinary}, {"EQUIPO_WORKSPACE_ROOT", c.WorkspaceRoot}, {"EQUIPO_SCRATCH_ROOT", c.ScratchRoot}, {"EQUIPO_GIT_PATH", c.GitPath}, {"EQUIPO_AMADAN_PATH", c.AmadanPath}, {"EQUIPO_RUNNER_EXECUTABLE", c.Executable},
} {
if !filepath.IsAbs(v.path) || filepath.Clean(v.path) != v.path || v.path == "/" {
return configIssue("runner.config.path", v.name, paseo.ErrContract)
}
}
+ info, err := os.Stat(c.AmadanPath)
+ if err != nil || !info.Mode().IsRegular() || info.Mode().Perm()&0111 == 0 {
+ return configIssue("runner.config.path", "EQUIPO_AMADAN_PATH", paseo.ErrContract)
+ }
for _, v := range []struct{ name, path string }{{"EQUIPO_WORKSPACE_ROOT", c.WorkspaceRoot}, {"EQUIPO_SCRATCH_ROOT", c.ScratchRoot}} {
if containsPath(c.StateDir, v.path) || containsPath(v.path, c.StateDir) {
return configIssue("runner.config.overlap", v.name, paseo.ErrPolicy)
diff --git a/internal/runner/config_test.go b/internal/runner/config_test.go
index e5f3dfb5..1ab59ebe 100644
--- a/internal/runner/config_test.go
+++ b/internal/runner/config_test.go
@@ -19,7 +19,11 @@ import (
func configFixture(t *testing.T) Config {
t.Helper()
root := t.TempDir()
- return Config{Origin: "https://equipo.example", StateDir: filepath.Join(root, "state"), PaseoHome: filepath.Join(root, "paseo"), NodePath: "/usr/local/bin/node", BridgePath: filepath.Join(root, "bridge.mjs"), AmadanCredentialPath: filepath.Join(root, "forge.json"), AccountBindingsPath: filepath.Join(root, "bindings.json"), CodexPath: "/usr/bin/codex", GoRoot: "/opt/go", GoBinary: "/opt/go/bin/go", WorkspaceRoot: filepath.Join(root, "work"), ScratchRoot: filepath.Join(root, "scratch"), GitPath: "/usr/bin/git", Executable: "/usr/bin/equipo-runner", PaseoEndpoint: "127.0.0.1:1234", PaseoServerID: "server", InstanceID: "instance"}
+ amadan := filepath.Join(root, "amadan")
+ if err := os.WriteFile(amadan, []byte("#!/bin/sh\nexit 0\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ return Config{Origin: "https://equipo.example", StateDir: filepath.Join(root, "state"), PaseoHome: filepath.Join(root, "paseo"), NodePath: "/usr/local/bin/node", BridgePath: filepath.Join(root, "bridge.mjs"), AmadanCredentialPath: filepath.Join(root, "forge.json"), AccountBindingsPath: filepath.Join(root, "bindings.json"), CodexPath: "/usr/bin/codex", GoRoot: "/opt/go", GoBinary: "/opt/go/bin/go", WorkspaceRoot: filepath.Join(root, "work"), ScratchRoot: filepath.Join(root, "scratch"), GitPath: "/usr/bin/git", AmadanPath: amadan, Executable: "/usr/bin/equipo-runner", PaseoEndpoint: "127.0.0.1:1234", PaseoServerID: "server", InstanceID: "instance"}
}
func TestRunnerConfig(t *testing.T) {
c := configFixture(t)
@@ -158,3 +162,52 @@ func TestEffectivePolicyReleaseManifest(t *testing.T) {
}
}
}
+
+func TestRunnerConfigAmadanPath(t *testing.T) {
+ c := configFixture(t)
+ command := filepath.Join(t.TempDir(), "amadan")
+ t.Chdir(filepath.Dir(command))
+ if err := os.WriteFile(command, []byte("#!/bin/sh\nexit 0\n"), 0700); err != nil {
+ t.Fatal(err)
+ }
+ env := map[string]string{
+ "EQUIPO_ORIGIN": c.Origin, "EQUIPO_INSTANCE_ID": c.InstanceID,
+ "EQUIPO_RUNNER_STATE_DIR": c.StateDir, "EQUIPO_AMADAN_CREDENTIAL_PATH": c.AmadanCredentialPath,
+ "EQUIPO_ACCOUNT_BINDINGS_PATH": c.AccountBindingsPath, "EQUIPO_CODEX_PATH": c.CodexPath,
+ "EQUIPO_GO_ROOT": c.GoRoot, "EQUIPO_GO_BINARY": c.GoBinary,
+ "EQUIPO_WORKSPACE_ROOT": c.WorkspaceRoot, "EQUIPO_SCRATCH_ROOT": c.ScratchRoot,
+ "EQUIPO_GIT_PATH": c.GitPath, "EQUIPO_RUNNER_EXECUTABLE": c.Executable,
+ "EQUIPO_AMADAN_PATH": command,
+ }
+ if _, err := LoadConfig(func(k string) string { return env[k] }); err != nil {
+ t.Fatal(err)
+ }
+ for _, mode := range []string{"unset", "relative", "unclean", "missing", "directory", "not_executable"} {
+ t.Run(mode, func(t *testing.T) {
+ path := command
+ switch mode {
+ case "unset":
+ path = ""
+ case "relative":
+ path = "amadan"
+ case "unclean":
+ path = filepath.Dir(command) + "/./amadan"
+ case "missing":
+ path += "-missing"
+ case "directory":
+ path = filepath.Dir(command)
+ case "not_executable":
+ path += "-not-executable"
+ if err := os.WriteFile(path, []byte("exit 0"), 0600); err != nil {
+ t.Fatal(err)
+ }
+ }
+ env["EQUIPO_AMADAN_PATH"] = path
+ _, err := LoadConfig(func(k string) string { return env[k] })
+ _, variable := Diagnostic(err)
+ if err == nil || variable != "EQUIPO_AMADAN_PATH" {
+ t.Fatalf("invalid Amadan path accepted or misdiagnosed: %v (%s)", err, variable)
+ }
+ })
+ }
+}
diff --git a/internal/runner/final_diagnostics_test.go b/internal/runner/final_diagnostics_test.go
index e6b9eab4..24617b7e 100644
--- a/internal/runner/final_diagnostics_test.go
+++ b/internal/runner/final_diagnostics_test.go
@@ -7,7 +7,7 @@ import (
)
func TestConfigDiagnosticNamesVariable(t *testing.T) {
- vars := map[string]string{"Origin": "EQUIPO_ORIGIN", "InstanceID": "EQUIPO_INSTANCE_ID", "PaseoServerID": "EQUIPO_PASEO_SERVER_ID", "PaseoEndpoint": "EQUIPO_PASEO_ENDPOINT", "StateDir": "EQUIPO_RUNNER_STATE_DIR", "PaseoHome": "EQUIPO_PASEO_HOME", "NodePath": "EQUIPO_NODE_PATH", "BridgePath": "EQUIPO_BRIDGE_PATH", "AmadanCredentialPath": "EQUIPO_AMADAN_CREDENTIAL_PATH", "AccountBindingsPath": "EQUIPO_ACCOUNT_BINDINGS_PATH", "CodexPath": "EQUIPO_CODEX_PATH", "GoRoot": "EQUIPO_GO_ROOT", "GoBinary": "EQUIPO_GO_BINARY", "WorkspaceRoot": "EQUIPO_WORKSPACE_ROOT", "ScratchRoot": "EQUIPO_SCRATCH_ROOT", "GitPath": "EQUIPO_GIT_PATH", "Executable": "EQUIPO_RUNNER_EXECUTABLE"}
+ vars := map[string]string{"Origin": "EQUIPO_ORIGIN", "InstanceID": "EQUIPO_INSTANCE_ID", "PaseoServerID": "EQUIPO_PASEO_SERVER_ID", "PaseoEndpoint": "EQUIPO_PASEO_ENDPOINT", "StateDir": "EQUIPO_RUNNER_STATE_DIR", "PaseoHome": "EQUIPO_PASEO_HOME", "NodePath": "EQUIPO_NODE_PATH", "BridgePath": "EQUIPO_BRIDGE_PATH", "AmadanCredentialPath": "EQUIPO_AMADAN_CREDENTIAL_PATH", "AccountBindingsPath": "EQUIPO_ACCOUNT_BINDINGS_PATH", "CodexPath": "EQUIPO_CODEX_PATH", "GoRoot": "EQUIPO_GO_ROOT", "GoBinary": "EQUIPO_GO_BINARY", "WorkspaceRoot": "EQUIPO_WORKSPACE_ROOT", "ScratchRoot": "EQUIPO_SCRATCH_ROOT", "GitPath": "EQUIPO_GIT_PATH", "AmadanPath": "EQUIPO_AMADAN_PATH", "Executable": "EQUIPO_RUNNER_EXECUTABLE"}
for field, want := range vars {
t.Run(field, func(t *testing.T) {
c := configFixture(t)
diff --git a/internal/runner/forge/description_test.go b/internal/runner/forge/description_test.go
index 8c011b77..ea541ecc 100644
--- a/internal/runner/forge/description_test.go
+++ b/internal/runner/forge/description_test.go
@@ -201,7 +201,7 @@ assert home != '/must-not-use-person-login'
assert stat.S_IMODE(os.stat(home).st_mode) == 0o700
path = home+'/credentials'
assert stat.S_IMODE(os.stat(path).st_mode) == 0o600
-assert json.load(open(path)) == {'tokens': {'https://amadan.net':'fake-only'}}
+assert json.load(open(path)) == {'https://amadan.net':'fake-only'}
assert sys.stdin.read() == ' Equipo café\n unconfined; approved beyond profile\n'
`
must(t, os.WriteFile(command, []byte(script), 0700))
@@ -212,10 +212,10 @@ assert sys.stdin.read() == ' Equipo café\n unconfined; approved beyond profile\
must(t, os.Mkdir(scratch, 0700))
writer := NewCommandDescriptionWriter(command, scratch)
must(t, writer.Set(context.Background(), cred, desc))
- if err := NewCommandDescriptionWriter(command, "relative").Set(context.Background(), cred, desc); err != team.ErrInvalid {
+ if err := NewCommandDescriptionWriter(command, "relative").Set(context.Background(), cred, desc); !errors.Is(err, team.ErrInvalid) {
t.Fatal("relative scratch accepted", err)
}
- if err := NewDescriptionTransport(nil, nil).Set(context.Background(), cred, desc); err != team.ErrUncertain {
+ if err := NewDescriptionTransport(nil, nil).Set(context.Background(), cred, desc); err != team.ErrNotDispatched {
t.Fatal("missing writer accepted", err)
}
entries, err := os.ReadDir(scratch)
@@ -287,3 +287,48 @@ assert sys.stdin.read() == ' Equipo café\n unconfined; approved beyond profile\
t.Fatal("failed command retained credentials")
}
}
+
+func TestAmadanDescriptionNotDispatched(t *testing.T) {
+ root := t.TempDir()
+ command := filepath.Join(root, "command")
+ must(t, os.WriteFile(command, []byte("#!/bin/sh\nexit 1\n"), 0700))
+ cred := Credential{Remote: "https://amadan.net/oficina/equipo", Agent: "equipo~owner@example.com", Bearer: "fake-only"}
+ desc := Description{Repository: "amadan.net/oficina/equipo", Ref: "review/trial", Agent: cred.Agent, Body: "body"}
+ desc.Digest = Digest([]byte(desc.Body))
+ for _, mode := range []string{"validation", "relative_path", "unclean_path", "missing_command", "not_executable", "scratch", "cancelled", "started", "missing_writer"} {
+ t.Run(mode, func(t *testing.T) {
+ path, scratch, d := command, root, desc
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+ switch mode {
+ case "validation":
+ d.Digest = "invalid"
+ case "relative_path":
+ path = "sh"
+ case "unclean_path":
+ path = root + "/./command"
+ case "missing_command":
+ path = filepath.Join(root, "missing")
+ case "not_executable":
+ path = filepath.Join(root, "not-executable")
+ must(t, os.WriteFile(path, []byte("exit 1"), 0600))
+ case "scratch":
+ scratch = filepath.Join(root, "missing-scratch")
+ case "cancelled":
+ cancel()
+ }
+ var writer DescriptionWriter = NewCommandDescriptionWriter(path, scratch)
+ if mode == "missing_writer" {
+ writer = NewDescriptionTransport(nil, nil)
+ }
+ err := writer.Set(ctx, cred, d)
+ if mode == "started" {
+ if !errors.Is(err, team.ErrUncertain) || errors.Is(err, team.ErrNotDispatched) {
+ t.Fatalf("started command declared safe to retry: %v", err)
+ }
+ } else if !errors.Is(err, team.ErrNotDispatched) {
+ t.Fatalf("pre-start failure must allow retry: %v", err)
+ }
+ })
+ }
+}
diff --git a/internal/runner/forge/description_transport.go b/internal/runner/forge/description_transport.go
index a69f1b12..1c7c7f28 100644
--- a/internal/runner/forge/description_transport.go
+++ b/internal/runner/forge/description_transport.go
@@ -3,6 +3,7 @@ package forge
import (
"context"
"encoding/json"
+ "errors"
"io"
"net/http"
"os"
@@ -16,6 +17,8 @@ import (
"amadan.net/oficina/equipo/internal/equipo/team"
)
+// Set may return team.ErrNotDispatched only when no command started.
+// Every failure after Start must remain uncertain, even a nonzero exit.
type DescriptionWriter interface {
Set(context.Context, Credential, Description) error
}
@@ -31,7 +34,7 @@ func NewDescriptionTransport(client *http.Client, writer DescriptionWriter) Desc
func (*descriptionTransport) BeforePush() bool { return false }
func (t *descriptionTransport) Set(ctx context.Context, c Credential, d Description) error {
if t.writer == nil {
- return team.ErrUncertain
+ return team.ErrNotDispatched
}
return t.writer.Set(ctx, c, d)
}
@@ -46,7 +49,16 @@ type commandDescriptionWriter struct{ path, scratch string }
func NewCommandDescriptionWriter(path, scratch string) DescriptionWriter {
return commandDescriptionWriter{path: path, scratch: scratch}
}
-func (w commandDescriptionWriter) Set(ctx context.Context, c Credential, d Description) error {
+func (w commandDescriptionWriter) Set(ctx context.Context, c Credential, d Description) (err error) {
+ started := false
+ defer func() {
+ if err != nil && !started {
+ err = errors.Join(team.ErrNotDispatched, err)
+ }
+ }()
+ if !filepath.IsAbs(w.path) || filepath.Clean(w.path) != w.path {
+ return team.ErrInvalid
+ }
if !validDescriptionTarget(c, d.Repository, d.Ref) || d.Agent != c.Agent || d.Body == "" || !utf8.ValidString(d.Body) || len(d.Body) > 1<<20 || d.Digest != Digest([]byte(d.Body)) || !filepath.IsAbs(w.scratch) {
return team.ErrInvalid
}
@@ -57,7 +69,7 @@ func (w commandDescriptionWriter) Set(ctx context.Context, c Credential, d Descr
return team.ErrUncertain
}
defer os.RemoveAll(dir)
- credentials, err := json.Marshal(map[string]any{"tokens": map[string]string{"https://amadan.net": c.Bearer}})
+ credentials, err := json.Marshal(map[string]string{"https://amadan.net": c.Bearer})
if err != nil {
return team.ErrUncertain
}
@@ -72,7 +84,11 @@ func (w commandDescriptionWriter) Set(ctx context.Context, c Credential, d Descr
cmd.SysProcAttr = &syscall.SysProcAttr{Setpgid: true}
cmd.Cancel = func() error { return syscall.Kill(-cmd.Process.Pid, syscall.SIGKILL) }
cmd.WaitDelay = time.Second
- if err = cmd.Run(); err != nil {
+ if err = cmd.Start(); err != nil {
+ return team.ErrUncertain
+ }
+ started = true
+ if err = cmd.Wait(); err != nil {
return team.ErrUncertain
}
return nil
diff --git a/internal/runner/forge/publisher.go b/internal/runner/forge/publisher.go
index 5f6227f1..2a50348b 100644
--- a/internal/runner/forge/publisher.go
+++ b/internal/runner/forge/publisher.go
@@ -322,7 +322,15 @@ func (p *Publisher) confirmDescription(ctx context.Context, cred Credential, r *
return team.ErrUncertain
}
// A failed command may have stored the description before losing its reply.
- _ = p.cfg.Description.Set(ctx, cred, desc)
+ if e = p.cfg.Description.Set(ctx, cred, desc); errors.Is(e, team.ErrNotDispatched) {
+ // Only a proven pre-start failure permits a later write. Persist that
+ // proof; a crash before this journal update keeps the conservative latch.
+ r.DescriptionAttempted = false
+ if e = runnerproto.JournalCredentials(p.path(r.Authorization.Ticket.Dispatch), *r); e != nil {
+ r.DescriptionAttempted = true
+ }
+ return team.ErrUncertain
+ }
got, e = p.cfg.Description.Read(ctx, cred, desc.Repository, desc.Ref)
if e != nil || !descriptionMatches(got, desc) {
return team.ErrUncertain
diff --git a/internal/runner/forge/publisher_test.go b/internal/runner/forge/publisher_test.go
index aa80e45b..445a1fd8 100644
--- a/internal/runner/forge/publisher_test.go
+++ b/internal/runner/forge/publisher_test.go
@@ -571,7 +571,7 @@ func (f descriptionWriterFunc) Set(ctx context.Context, c Credential, d Descript
}
func TestPublishDescriptionRecovery(t *testing.T) {
- for _, mode := range []string{"lost_reply", "delayed_readback", "empty", "trimmed", "wrong_digest", "wrong_ref", "wrong_repo", "wrong_body", "wrong_agent"} {
+ for _, mode := range []string{"not_dispatched", "lost_reply", "delayed_readback", "empty", "trimmed", "wrong_digest", "wrong_ref", "wrong_repo", "wrong_body", "wrong_agent"} {
t.Run(mode, func(t *testing.T) {
f := newFixture(t)
f.auth.Publication.Description = " unconfined; approved beyond profile\n"
@@ -580,7 +580,7 @@ func TestPublishDescriptionRecovery(t *testing.T) {
f.auth.Ticket.Dispatch.Payload, f.auth.Ticket.Dispatch.Hash, _ = Canonical(raw)
var mu sync.Mutex
body := ""
- writes, reads := 0, 0
+ writes, reads, calls := 0, 0, 0
f.p.beforePush = func() {
saved, err := f.p.load(f.auth.Ticket.Dispatch)
must(t, err)
@@ -606,7 +606,7 @@ func TestPublishDescriptionRecovery(t *testing.T) {
transport := NewDescriptionTransport(client, descriptionWriterFunc(func(_ context.Context, c Credential, d Description) error {
mu.Lock()
defer mu.Unlock()
- writes++
+ calls++
if f.pushes != 1 || gitTest(t, f.root, "--git-dir="+f.remote, "rev-parse", "refs/heads/heads/main") != f.auth.Candidate.Commit {
t.Fatal("describe before exact ref exists")
}
@@ -615,6 +615,10 @@ func TestPublishDescriptionRecovery(t *testing.T) {
if saved.Description.Body != d.Body || !saved.DescriptionAttempted {
t.Fatal("description intent not durable before write")
}
+ if mode == "not_dispatched" && calls == 1 {
+ return fmt.Errorf("local setup: %w", team.ErrNotDispatched)
+ }
+ writes++
body = d.Body
if mode == "trimmed" {
body = strings.TrimSpace(body)
@@ -637,6 +641,13 @@ func TestPublishDescriptionRecovery(t *testing.T) {
} else if err == nil {
t.Fatal("unconfirmed description delivered success")
}
+ if mode == "not_dispatched" {
+ saved, e := f.p.load(f.auth.Ticket.Dispatch)
+ must(t, e)
+ if saved.DescriptionAttempted {
+ t.Fatal("never-sent description latched as attempted")
+ }
+ }
mu.Lock()
visible = true
mu.Unlock()
@@ -645,7 +656,7 @@ func TestPublishDescriptionRecovery(t *testing.T) {
must(t, err)
restarted.beforePush = f.p.beforePush
result, err := restarted.Reconcile(ctx, f.auth.Ticket.Dispatch)
- if mode == "lost_reply" || mode == "delayed_readback" {
+ if mode == "lost_reply" || mode == "delayed_readback" || mode == "not_dispatched" {
must(t, err)
if result.Receipt == nil || result.Receipt.Fields["description_hash"] != f.auth.Publication.DescriptionHash {
t.Fatal("lost body digest")
@@ -654,6 +665,9 @@ func TestPublishDescriptionRecovery(t *testing.T) {
t.Fatal("unconfirmed description reconciled success")
}
_, _ = restarted.Execute(ctx, f.auth.Ticket.Dispatch)
+ if mode == "not_dispatched" && calls != 2 {
+ t.Fatal("never-sent description not retried exactly once", calls)
+ }
if writes != 1 || f.pushes != 1 || reads < 3 {
t.Fatal("duplicate write/push or skipped GET", writes, f.pushes, reads)
}
diff --git a/internal/runner/runtime_workflow.go b/internal/runner/runtime_workflow.go
index c1137a92..445c809d 100644
--- a/internal/runner/runtime_workflow.go
+++ b/internal/runner/runtime_workflow.go
@@ -163,7 +163,7 @@ func (r *Runtime) wire(ctx context.Context) error {
return paseo.ErrIdentity
}
return r.api.Call(ctx, "validate", claimRequest(c, "publish-validate"), nil)
- }, Export: manager.ExportCandidate, Credential: credentials.credential, Description: forge.NewDescriptionTransport(nil, forge.NewCommandDescriptionWriter("amadan", r.cfg.ScratchRoot))})
+ }, Export: manager.ExportCandidate, Credential: credentials.credential, Description: forge.NewDescriptionTransport(nil, forge.NewCommandDescriptionWriter(r.cfg.AmadanPath, r.cfg.ScratchRoot))})
}
workflow, err := NewBugWorkflow(BugWorkflowConfig{Workspaces: manager, Launchers: r.launchers, Namespaces: r.namespaces, Launch: r.directLaunch, Witness: w, Policy: r.policy, Executor: executor, PublisherFor: publisherFor, StateDir: r.cfg.StateDir, Executable: r.cfg.Executable, InstanceID: r.cfg.InstanceID, Copy: r.cfg.Copy})
if err != nil {