diff --git a/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-1/report.json b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-1/report.json new file mode 100644 index 00000000..891ead12 --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-1/report.json @@ -0,0 +1,42 @@ +{ + "schema": "terragucci.report/v1", + "minor": 41, + "run": { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "job_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/actions/runs/6745", + "commit_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/commit/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "stage": "tf-apply", + "wave": 1, + "binary": "choudoufu", + "runtime": "forge", + "started": "2026-10-19T01:58:21.644Z", + "finished": "2026-10-19T01:58:26.314Z", + "terragucci": "0.4.35", + "trace_id": "5c4aa580584fe2d4ad0cedf4a561c28b" + }, + "roots": [ + { + "path": "network", + "status": "planned", + "changes": [] + } + ], + "waves": [ + { + "number": 1, + "roots": [ + "network" + ], + "set_digest": "jcs1-sha256:094a1ea8e9881d1641cdf7f58ea3b7fb97c47e770c907912cb820bc52699ee32", + "approval": "not-required", + "state": "applied", + "outcomes": [ + { + "root": "network", + "outcome": "applied" + } + ] + } + ] +} diff --git a/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-2/report.json b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-2/report.json new file mode 100644 index 00000000..c6808a8c --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-2/report.json @@ -0,0 +1,53 @@ +{ + "schema": "terragucci.report/v1", + "minor": 41, + "run": { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "job_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/actions/runs/6745", + "commit_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/commit/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "stage": "tf-apply", + "wave": 2, + "binary": "choudoufu", + "runtime": "forge", + "started": "2026-10-19T01:58:31.495Z", + "finished": "2026-10-19T01:58:37.730Z", + "terragucci": "0.4.35", + "trace_id": "c18806d0867a8ceed4bb6239abf32633" + }, + "roots": [ + { + "path": "cluster-a", + "status": "planned", + "changes": [] + }, + { + "path": "cluster-b", + "status": "planned", + "changes": [] + } + ], + "waves": [ + { + "number": 2, + "roots": [ + "cluster-a", + "cluster-b" + ], + "set_digest": "jcs1-sha256:aa1d23387b8a7e87974317acfd96626b9a0541e8eaa8d6cdb57d8adc0ebac061", + "approval": "not-required", + "state": "failed", + "outcomes": [ + { + "root": "cluster-a", + "outcome": "failed", + "error": "Error: creating SQS Queue (fan-out-choudoufu-network-events): operation error SQS: CreateQueue, https response error StatusCode: 400, RequestID: 8bc82e82-3a97-4b59-8ef1-b4e901474ca2, QueueAlreadyExists: A queue already exists with the same name but different attributes." + }, + { + "root": "cluster-b", + "outcome": "applied" + } + ] + } + ] +} diff --git a/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-3/report.json b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-3/report.json new file mode 100644 index 00000000..3d6b8e58 --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-3/report.json @@ -0,0 +1,148 @@ +{ + "schema": "terragucci.report/v1", + "minor": 41, + "run": { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "job_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/actions/runs/6745", + "commit_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/commit/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "stage": "tf-apply", + "wave": 3, + "binary": "choudoufu", + "runtime": "forge", + "started": "2026-10-19T01:58:42.521Z", + "finished": "2026-10-19T01:58:52.464Z", + "terragucci": "0.4.35", + "trace_id": "8ebb6c1aee7a752e5a2a4d2b16407975" + }, + "roots": [ + { + "path": "app-07", + "status": "planned", + "changes": [] + }, + { + "path": "app-08", + "status": "planned", + "changes": [] + }, + { + "path": "app-09", + "status": "planned", + "changes": [] + }, + { + "path": "app-10", + "status": "planned", + "changes": [] + }, + { + "path": "app-11", + "status": "planned", + "changes": [] + }, + { + "path": "app-12", + "status": "planned", + "changes": [] + } + ], + "waves": [ + { + "number": 3, + "roots": [ + "app-07", + "app-08", + "app-09", + "app-10", + "app-11", + "app-12" + ], + "set_digest": "jcs1-sha256:5f21673dded02f8058c07d7700a863cf395e5e9cd570ea47cc3375556fadaf07", + "approval": "not-required", + "state": "applied", + "blocked": [ + { + "root": "app-01", + "blocked_by": "cluster-a" + }, + { + "root": "app-02", + "blocked_by": "cluster-a" + }, + { + "root": "app-03", + "blocked_by": "cluster-a" + }, + { + "root": "app-04", + "blocked_by": "cluster-a" + }, + { + "root": "app-05", + "blocked_by": "cluster-a" + }, + { + "root": "app-06", + "blocked_by": "cluster-a" + } + ], + "outcomes": [ + { + "root": "app-01", + "outcome": "blocked", + "blocked_by": "cluster-a" + }, + { + "root": "app-02", + "outcome": "blocked", + "blocked_by": "cluster-a" + }, + { + "root": "app-03", + "outcome": "blocked", + "blocked_by": "cluster-a" + }, + { + "root": "app-04", + "outcome": "blocked", + "blocked_by": "cluster-a" + }, + { + "root": "app-05", + "outcome": "blocked", + "blocked_by": "cluster-a" + }, + { + "root": "app-06", + "outcome": "blocked", + "blocked_by": "cluster-a" + }, + { + "root": "app-07", + "outcome": "applied" + }, + { + "root": "app-08", + "outcome": "applied" + }, + { + "root": "app-09", + "outcome": "applied" + }, + { + "root": "app-10", + "outcome": "applied" + }, + { + "root": "app-11", + "outcome": "applied" + }, + { + "root": "app-12", + "outcome": "applied" + } + ] + } + ] +} diff --git a/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-1/report.json b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-1/report.json new file mode 100644 index 00000000..7089d707 --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-1/report.json @@ -0,0 +1,42 @@ +{ + "schema": "terragucci.report/v1", + "minor": 41, + "run": { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "job_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/actions/runs/6748", + "commit_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/commit/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "stage": "tf-apply", + "wave": 1, + "binary": "choudoufu", + "runtime": "forge", + "started": "2026-10-19T02:00:48.850Z", + "finished": "2026-10-19T02:00:52.952Z", + "terragucci": "0.4.35", + "trace_id": "5f9f243aa5384ec205b9282910a3316a" + }, + "roots": [ + { + "path": "network", + "status": "planned", + "changes": [] + } + ], + "waves": [ + { + "number": 1, + "roots": [ + "network" + ], + "set_digest": "jcs1-sha256:4965a930452383249f46923206c190b9d4ef0e4a02aa1ceecd0907ca29293284", + "approval": "not-required", + "state": "applied", + "outcomes": [ + { + "root": "network", + "outcome": "unchanged" + } + ] + } + ] +} diff --git a/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-2/report.json b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-2/report.json new file mode 100644 index 00000000..3ebe119a --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-2/report.json @@ -0,0 +1,52 @@ +{ + "schema": "terragucci.report/v1", + "minor": 41, + "run": { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "job_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/actions/runs/6748", + "commit_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/commit/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "stage": "tf-apply", + "wave": 2, + "binary": "choudoufu", + "runtime": "forge", + "started": "2026-10-19T02:00:57.332Z", + "finished": "2026-10-19T02:01:27.524Z", + "terragucci": "0.4.35", + "trace_id": "b01df6315fb821d4161f3dd35f0aab96" + }, + "roots": [ + { + "path": "cluster-a", + "status": "planned", + "changes": [] + }, + { + "path": "cluster-b", + "status": "planned", + "changes": [] + } + ], + "waves": [ + { + "number": 2, + "roots": [ + "cluster-a", + "cluster-b" + ], + "set_digest": "jcs1-sha256:d701980961cff78373cbaf5576815244f7d633bf617979561bf01438f3c7c9c4", + "approval": "not-required", + "state": "applied", + "outcomes": [ + { + "root": "cluster-a", + "outcome": "applied" + }, + { + "root": "cluster-b", + "outcome": "unchanged" + } + ] + } + ] +} diff --git a/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-3/report.json b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-3/report.json new file mode 100644 index 00000000..66d89b08 --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-3/report.json @@ -0,0 +1,152 @@ +{ + "schema": "terragucci.report/v1", + "minor": 41, + "run": { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "job_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/actions/runs/6748", + "commit_url": "http://forgejo:3000/terragucci-admin/demo-choudoufu-fanout/commit/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "stage": "tf-apply", + "wave": 3, + "binary": "choudoufu", + "runtime": "forge", + "started": "2026-10-19T02:01:32.459Z", + "finished": "2026-10-19T02:01:47.700Z", + "terragucci": "0.4.35", + "trace_id": "f90b82490188b6f6d9953ea8f1f9db1a" + }, + "roots": [ + { + "path": "app-01", + "status": "planned", + "changes": [] + }, + { + "path": "app-02", + "status": "planned", + "changes": [] + }, + { + "path": "app-03", + "status": "planned", + "changes": [] + }, + { + "path": "app-04", + "status": "planned", + "changes": [] + }, + { + "path": "app-05", + "status": "planned", + "changes": [] + }, + { + "path": "app-06", + "status": "planned", + "changes": [] + }, + { + "path": "app-07", + "status": "planned", + "changes": [] + }, + { + "path": "app-08", + "status": "planned", + "changes": [] + }, + { + "path": "app-09", + "status": "planned", + "changes": [] + }, + { + "path": "app-10", + "status": "planned", + "changes": [] + }, + { + "path": "app-11", + "status": "planned", + "changes": [] + }, + { + "path": "app-12", + "status": "planned", + "changes": [] + } + ], + "waves": [ + { + "number": 3, + "roots": [ + "app-01", + "app-02", + "app-03", + "app-04", + "app-05", + "app-06", + "app-07", + "app-08", + "app-09", + "app-10", + "app-11", + "app-12" + ], + "set_digest": "jcs1-sha256:0edb0b0b555a0d24abee90f5adceb8eebd7c0ca3cffa685c246314823fd62c9f", + "approval": "not-required", + "state": "applied", + "outcomes": [ + { + "root": "app-01", + "outcome": "applied" + }, + { + "root": "app-02", + "outcome": "applied" + }, + { + "root": "app-03", + "outcome": "applied" + }, + { + "root": "app-04", + "outcome": "applied" + }, + { + "root": "app-05", + "outcome": "applied" + }, + { + "root": "app-06", + "outcome": "applied" + }, + { + "root": "app-07", + "outcome": "unchanged" + }, + { + "root": "app-08", + "outcome": "unchanged" + }, + { + "root": "app-09", + "outcome": "unchanged" + }, + { + "root": "app-10", + "outcome": "unchanged" + }, + { + "root": "app-11", + "outcome": "unchanged" + }, + { + "root": "app-12", + "outcome": "unchanged" + } + ] + } + ] +} diff --git a/src/__fixtures__/terragucci-wave-results/index.json b/src/__fixtures__/terragucci-wave-results/index.json new file mode 100644 index 00000000..ddd57f31 --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/index.json @@ -0,0 +1,59 @@ +{ + "schema": "terragucci.report-index/v1", + "reports": [ + { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "stage": "tf-apply", + "wave": 3, + "finished": "2026-10-19T02:01:47.700Z", + "path": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-3", + "approval": "not-required" + }, + { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "stage": "tf-apply", + "wave": 2, + "finished": "2026-10-19T02:01:27.524Z", + "path": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-2", + "approval": "not-required" + }, + { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "stage": "tf-apply", + "wave": 1, + "finished": "2026-10-19T02:00:52.952Z", + "path": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e/tf-apply-wave-1", + "approval": "not-required" + }, + { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "stage": "tf-apply", + "wave": 3, + "finished": "2026-10-19T01:58:52.464Z", + "path": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-3", + "approval": "not-required" + }, + { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "stage": "tf-apply", + "wave": 2, + "finished": "2026-10-19T01:58:37.730Z", + "path": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-2", + "approval": "not-required" + }, + { + "project": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout", + "commit": "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "stage": "tf-apply", + "wave": 1, + "finished": "2026-10-19T01:58:26.314Z", + "path": "forgejo:3000/terragucci-admin/demo-choudoufu-fanout/2026/10/2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab/tf-apply-wave-1", + "approval": "not-required" + } + ] +} diff --git a/src/__fixtures__/terragucci-wave-results/run-6745.json b/src/__fixtures__/terragucci-wave-results/run-6745.json new file mode 100644 index 00000000..e616c6d7 --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/run-6745.json @@ -0,0 +1,265 @@ +{ + "schema": "demo.run/v1", + "id": 6745, + "title": "Merge pull request 'A broken estate shouldn't stall the rollout' (#55) from demo-fan-out-choudoufu into main", + "event": "push", + "trigger": "merge", + "repo": "terragucci-admin/demo-choudoufu-fanout", + "tool": "choudoufu-fanout", + "commit": "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab", + "pull": 55, + "cycle": 605, + "scenario": "fan-out-choudoufu", + "status": "failure", + "created_at": "2026-10-19T01:57:38Z", + "started_at": "2026-10-19T01:57:38Z", + "ended_at": "2026-10-19T01:58:54.209Z", + "jobs": [ + { + "id": 39658, + "name": "check", + "needs": [], + "status": "success", + "started_at": "2026-10-19T01:57:38.223Z", + "ended_at": "2026-10-19T01:58:16.976Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "Check out the change", + "status": "success" + }, + { + "name": "Format check and validate, every root", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + }, + { + "id": 39659, + "name": "check-report", + "needs": [ + "check" + ], + "status": "success", + "started_at": "2026-10-19T01:58:19.214Z", + "ended_at": "2026-10-19T01:58:20.354Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "Take the check report from the check job", + "status": "success" + }, + { + "name": "Keep the check report", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + }, + { + "id": 39660, + "name": "plan", + "needs": [], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39661, + "name": "plan-note", + "needs": [ + "plan" + ], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39662, + "name": "replan", + "needs": [], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39663, + "name": "replan-note", + "needs": [ + "replan" + ], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39664, + "name": "fmt", + "needs": [ + "check" + ], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39665, + "name": "apply-comment", + "needs": [], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39666, + "name": "apply-wave-1", + "needs": [ + "check" + ], + "status": "success", + "started_at": "2026-10-19T01:58:19.214Z", + "ended_at": "2026-10-19T01:58:26.622Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Apply wave 1 of 3", + "status": "success" + }, + { + "name": "Keep the apply report", + "status": "success" + }, + { + "name": "Post https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + }, + { + "id": 39667, + "name": "apply-wave-2", + "needs": [ + "apply-wave-1" + ], + "status": "failure", + "started_at": "2026-10-19T01:58:28.221Z", + "ended_at": "2026-10-19T01:58:38.359Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Fetch the earlier waves' outcomes", + "status": "success" + }, + { + "name": "Apply wave 2 of 3", + "status": "failure" + }, + { + "name": "Keep the apply report", + "status": "success" + }, + { + "name": "Post https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Complete job", + "status": "failure" + } + ] + }, + { + "id": 39668, + "name": "apply-wave-3", + "needs": [ + "apply-wave-2" + ], + "status": "failure", + "started_at": "2026-10-19T01:58:39.208Z", + "ended_at": "2026-10-19T01:58:53.081Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Fetch the earlier waves' outcomes", + "status": "success" + }, + { + "name": "Apply wave 3 of 3", + "status": "failure" + }, + { + "name": "Keep the apply report", + "status": "success" + }, + { + "name": "Post https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Complete job", + "status": "failure" + } + ] + }, + { + "id": 39669, + "name": "tips", + "needs": [ + "apply-wave-3" + ], + "status": "skipped", + "started_at": "2026-10-19T01:58:54.208Z", + "ended_at": "2026-10-19T01:58:54.209Z", + "steps": [ + { + "name": "Set up job", + "status": "skipped" + } + ] + } + ] +} diff --git a/src/__fixtures__/terragucci-wave-results/run-6748.json b/src/__fixtures__/terragucci-wave-results/run-6748.json new file mode 100644 index 00000000..724cd03d --- /dev/null +++ b/src/__fixtures__/terragucci-wave-results/run-6748.json @@ -0,0 +1,281 @@ +{ + "schema": "demo.run/v1", + "id": 6748, + "title": "Merge pull request 'cluster-a: its events queue gets a name of its own' (#56) from demo-fan-out-choudoufu-fix into main", + "event": "push", + "trigger": "merge", + "repo": "terragucci-admin/demo-choudoufu-fanout", + "tool": "choudoufu-fanout", + "commit": "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e", + "pull": 56, + "cycle": 605, + "scenario": "fan-out-choudoufu", + "status": "success", + "created_at": "2026-10-19T02:00:03Z", + "started_at": "2026-10-19T02:00:04Z", + "ended_at": "2026-10-19T02:01:52Z", + "jobs": [ + { + "id": 39694, + "name": "check", + "needs": [], + "status": "success", + "started_at": "2026-10-19T02:00:04.216Z", + "ended_at": "2026-10-19T02:00:44.363Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "Check out the change", + "status": "success" + }, + { + "name": "Format check and validate, every root", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + }, + { + "id": 39695, + "name": "check-report", + "needs": [ + "check" + ], + "status": "success", + "started_at": "2026-10-19T02:00:46.250Z", + "ended_at": "2026-10-19T02:00:47.580Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "Take the check report from the check job", + "status": "success" + }, + { + "name": "Keep the check report", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + }, + { + "id": 39696, + "name": "plan", + "needs": [], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39697, + "name": "plan-note", + "needs": [ + "plan" + ], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39698, + "name": "replan", + "needs": [], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39699, + "name": "replan-note", + "needs": [ + "replan" + ], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39700, + "name": "fmt", + "needs": [ + "check" + ], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39701, + "name": "apply-comment", + "needs": [], + "status": "skipped", + "started_at": null, + "ended_at": null, + "steps": [] + }, + { + "id": 39702, + "name": "apply-wave-1", + "needs": [ + "check" + ], + "status": "success", + "started_at": "2026-10-19T02:00:46.249Z", + "ended_at": "2026-10-19T02:00:53.252Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Apply wave 1 of 3", + "status": "success" + }, + { + "name": "Keep the apply report", + "status": "success" + }, + { + "name": "Post https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + }, + { + "id": 39703, + "name": "apply-wave-2", + "needs": [ + "apply-wave-1" + ], + "status": "success", + "started_at": "2026-10-19T02:00:54.229Z", + "ended_at": "2026-10-19T02:01:27.831Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Fetch the earlier waves' outcomes", + "status": "success" + }, + { + "name": "Apply wave 2 of 3", + "status": "success" + }, + { + "name": "Keep the apply report", + "status": "success" + }, + { + "name": "Post https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + }, + { + "id": 39704, + "name": "apply-wave-3", + "needs": [ + "apply-wave-2" + ], + "status": "success", + "started_at": "2026-10-19T02:01:29.240Z", + "ended_at": "2026-10-19T02:01:48.121Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Fetch the earlier waves' outcomes", + "status": "success" + }, + { + "name": "Apply wave 3 of 3", + "status": "success" + }, + { + "name": "Keep the apply report", + "status": "success" + }, + { + "name": "Post https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + }, + { + "id": 39705, + "name": "tips", + "needs": [ + "apply-wave-3" + ], + "status": "success", + "started_at": "2026-10-19T02:01:50.243Z", + "ended_at": "2026-10-19T02:01:51.933Z", + "steps": [ + { + "name": "Set up job", + "status": "success" + }, + { + "name": "https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Open a pull request for each tip", + "status": "success" + }, + { + "name": "Post https://code.forgejo.org/actions/checkout@v4", + "status": "success" + }, + { + "name": "Complete job", + "status": "success" + } + ] + } + ] +} diff --git a/src/terragucci-reports.ts b/src/terragucci-reports.ts index 621ffb59..5649a2d4 100644 --- a/src/terragucci-reports.ts +++ b/src/terragucci-reports.ts @@ -604,6 +604,48 @@ export function waveBlocked(w: Pick | undefined): { root: return rows.flatMap((b) => (isRecord(b) && str(b.root) && b.root && str(b.blocked_by) && b.blocked_by ? [{ root: b.root, by: b.blocked_by }] : [])); } +/** + * behold#751: how a tf-apply wave came out, as its own report says it, for the + * wave's words in place of its Forgejo job's status. terragucci ends a wave's + * job as a failure while any root of it is blocked (terragucci#1161), so the + * commit status isn't green with roots unapplied; the report's `state` + * (terragucci's waveState) is `applied` for a wave that applied all it + * planned and blocked the rest, `blocked` only when it planned nothing, and + * `failed` when a root of its own failed. `finished` is the report's, so a + * reader can tell a report of an earlier run on the commit from this one's. + */ +export interface WaveResult { + wave: number; + state: ReportWaveState; + finished: string; + /** The roots that applied a change; the wave's roots, less the blocked, when the report names no outcome. */ + applied: string[]; + /** The roots whose apply changed nothing. */ + unchanged: string[]; + failed: { root: string; error?: string }[]; + blocked: { root: string; by: string }[]; +} + +/** behold#751: how many tf-apply commits, newest first, {@link TerragucciRead.results} keeps the waves of. */ +export const RESULT_COMMITS = 4; + +/** behold#751: a tf-apply wave's result from its report; none for a report without the wave's `state` (before minor 21). Pure. */ +export function waveResult(w: ReportWave | undefined, finished: string): WaveResult | undefined { + if (!w || !Number.isInteger(w.number) || !str(w.state) || !w.state) return undefined; + const outcomes = waveOutcomes(w); + const blocked = waveBlocked(w); + const held = new Set(blocked.map((b) => b.root)); + return { + wave: w.number, + state: w.state, + finished, + applied: outcomes.length ? outcomes.filter((o) => o.outcome === "applied").map((o) => o.root) : w.state === "applied" ? waveRootNames(w).filter((r) => !held.has(r)) : [], + unchanged: outcomes.filter((o) => o.outcome === "unchanged").map((o) => o.root), + failed: outcomes.filter((o) => o.outcome === "failed").map((o) => ({ root: o.root, ...(o.error ? { error: o.error } : {}) })), + blocked, + }; +} + export interface TerragucciRead { source: string; kind: TerragucciSource["kind"]; @@ -633,6 +675,12 @@ export interface TerragucciRead { blocked?: BlockedRead; /** behold#741: each root's own outcome in the newest apply's waves; absent when no report carries one. */ outcomes?: OutcomesRead; + /** + * behold#751: each wave's result by its own report, for the newest + * {@link RESULT_COMMITS} tf-apply commits, by commit, each wave by its + * newest report. Absent when no report carries a wave's `state`. + */ + results?: Record; } export interface ReadOptions { @@ -887,6 +935,26 @@ export async function readTerragucci(source: TerragucciSource, opts: ReadOptions if (commit && Object.keys(own).length) outcomes = { commit, roots: own }; } + // behold#751: each wave's result by its report, for the newest tf-apply commits (a fix's apply, and the change's before it), + // each wave by its newest report: a wave's words follow what it did ("applied 6, 6 blocked by cluster-a"), not its job's + // exit, which terragucci fails while roots are blocked. + const results: Record = {}; + { + const applies = rows.filter((r) => r.stage === "tf-apply" && r.wave !== undefined); + for (const commit of [...new Set(applies.map((r) => r.commit))].slice(0, RESULT_COMMITS)) { + const seen = new Set(); + const out: WaveResult[] = []; + for (const r of applies.filter((a) => a.commit === commit)) { + if (seen.has(r.wave!)) continue; + seen.add(r.wave!); + const doc = await report(r); + const res = waveResult(doc?.waves.find((w) => w.number === r.wave) ?? doc?.waves[0], doc?.run.finished ?? r.finished); + if (res) out.push({ ...res, wave: r.wave! }); + } + if (out.length) results[commit] = out.sort((a, b) => a.wave - b.wave); + } + } + // minor 34: a cone plan, with every root of the estate the read knows and the instances each cone's plan.json planned. if (pullRequest && prRow && prDoc) { await Promise.all([...cache.values()].map((p) => p.catch(() => undefined))); @@ -921,6 +989,7 @@ export async function readTerragucci(source: TerragucciSource, opts: ReadOptions : {}), ...(blocked ? { blocked } : {}), ...(outcomes ? { outcomes } : {}), + ...(Object.keys(results).length ? { results } : {}), }; } diff --git a/src/terragucci-view.ts b/src/terragucci-view.ts index c89b418e..addfff2f 100644 --- a/src/terragucci-view.ts +++ b/src/terragucci-view.ts @@ -241,6 +241,8 @@ export function terragucciRoutes(app: Hono, opts: TerragucciOptions, dirs: () => ...(r.blocked ? { blocked: r.blocked } : {}), // behold#741: each root's own outcome in the newest apply's waves, absent when no report carries one. ...(r.outcomes ? { outcomes: r.outcomes } : {}), + // behold#751: each wave's result by its own report, for the newest tf-apply commits; absent when no report says one. + ...(r.results ? { results: r.results } : {}), ...(r.binaries ? { binaries: r.binaries } : {}), ...marks, }); diff --git a/src/terragucci-wave-results.test.ts b/src/terragucci-wave-results.test.ts new file mode 100644 index 00000000..361a5979 --- /dev/null +++ b/src/terragucci-wave-results.test.ts @@ -0,0 +1,47 @@ +import { describe, expect, it } from "vitest"; +import { join } from "node:path"; +import { readTerragucci, waveResult, type Validator } from "./terragucci-reports.ts"; +import { terragucciSource } from "./terragucci-source.ts"; + +// behold#751: a terragucci wave's result, as its own report says it. The +// fixture is a real fan-out-choudoufu cycle's tf-apply reports, trimmed to the +// run, the roots and the waves: the change's merge (2a615596, run 6745), where +// cluster-a failed in wave 2 and wave 3 applied cluster-b's six apps and +// blocked cluster-a's six, and the fix's merge (5cfbdb79, run 6748). Forgejo +// ended the change's wave 3 job as a failure (terragucci#1161); its report +// says `state: "applied"`. +const FIXTURE = join(import.meta.dirname, "__fixtures__", "terragucci-wave-results"); +const CHANGE = "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab"; +const FIX = "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e"; +const APPS_A = ["app-01", "app-02", "app-03", "app-04", "app-05", "app-06"]; +const APPS_B = ["app-07", "app-08", "app-09", "app-10", "app-11", "app-12"]; +const structural = (): Validator => ({ validation: { by: "structural" }, check: (_name, doc) => (doc && typeof doc === "object" ? undefined : "not an object") }); + +describe("a wave's result from its report (behold#751)", () => { + it("reads the change's waves: wave 2 failed, wave 3 applied six and blocked six by cluster-a", async () => { + const r = await readTerragucci(terragucciSource(FIXTURE), { validator: structural() }); + expect(Object.keys(r.results ?? {}).sort()).toEqual([CHANGE, FIX].sort()); + const [w1, w2, w3] = r.results![CHANGE]!; + expect(w1).toMatchObject({ wave: 1, state: "applied", applied: ["network"], failed: [], blocked: [] }); + expect(w2).toMatchObject({ wave: 2, state: "failed", applied: ["cluster-b"], blocked: [] }); + expect(w2!.failed).toEqual([{ root: "cluster-a", error: expect.stringContaining("QueueAlreadyExists") }]); + expect(w3).toMatchObject({ wave: 3, state: "applied", applied: APPS_B, unchanged: [], failed: [], finished: "2026-10-19T01:58:52.464Z" }); + expect(w3!.blocked).toEqual(APPS_A.map((root) => ({ root, by: "cluster-a" }))); + }); + + it("reads the fix's waves as applied, with nothing blocked", async () => { + const r = await readTerragucci(terragucciSource(FIXTURE), { validator: structural() }); + expect(r.results![FIX]!.map((w) => [w.wave, w.state, w.applied.length, w.unchanged.length, w.blocked.length])).toEqual([ + [1, "applied", 0, 1, 0], + [2, "applied", 1, 1, 0], + [3, "applied", 6, 6, 0], + ]); + }); + + it("is none for a wave without a state (before report minor 21), and the roots stand in for outcomes", () => { + expect(waveResult({ number: 2, roots: ["a"], set_digest: null, approval: "not-required" }, "2026-10-19T00:00:00Z")).toBeUndefined(); + expect(waveResult(undefined, "2026-10-19T00:00:00Z")).toBeUndefined(); + const older = waveResult({ number: 3, roots: ["app-07", "app-01"], set_digest: null, approval: "not-required", state: "applied", blocked: [{ root: "app-01", blocked_by: "cluster-a" }] }, "t"); + expect(older).toMatchObject({ applied: ["app-07"], blocked: [{ root: "app-01", by: "cluster-a" }] }); + }); +}); diff --git a/web/kiosk-event-help.js b/web/kiosk-event-help.js index a73fbbff..29ce6598 100644 --- a/web/kiosk-event-help.js +++ b/web/kiosk-event-help.js @@ -15,6 +15,7 @@ import { STRIP, matchingPull, matchingRun } from "./kiosk.js"; import { defaultStep } from "./kiosk-runs.js"; import { traceReadyWords } from "./kiosk-wave-traces.js"; +import { resultBlocked, resultFailed, resultWords, waveResultOf } from "./terragucci-change.js"; export { EH_STORE, ehStore, ehStored } from "./event-help-store.js"; @@ -68,6 +69,16 @@ export function ehSnapshot({ demo = null, answer = null, progress = null, runDoc const pr = matchingPull(answer, demo) || (answer && !answer.error && answer.pull_request && demo.pull !== null && String(answer.pull_request.run && answer.pull_request.run.pull_request) === String(demo.pull) ? answer.pull_request : null); const run = matchingRun(progress, demo); const jobs = runDoc && Array.isArray(runDoc.jobs) && (!demo.cycle || runDoc.cycle === undefined || runDoc.cycle === demo.cycle) ? runDoc.jobs : []; + // behold#751: a wave's result by its own report, of the commit the run applied: its job's status is no witness to it, + // since terragucci fails the job of a wave that applied what it planned and blocked the rest (terragucci#1161). + const resultOf = (commit, name, started) => { + const n = waveOfJob(name, waves); + return n === null ? null : waveResultOf(answer, commit, n, { after: started || null }); + }; + // The cycle's earlier runs' wave jobs that ended as failures, each with its report's word on the wave when there is one. + const pastJobs = (runDocs || []) + .filter((d) => d && d.id !== (runDoc && runDoc.id) && (!demo.cycle || d.cycle === undefined || d.cycle === demo.cycle) && Array.isArray(d.jobs)) + .flatMap((d) => d.jobs.filter((j) => j.status === "failure" && waveOfJob(j.name, waves) !== null).map((j) => ({ wave: waveOfJob(j.name, waves), job: j.name, run: d.id, refusal: yodelRefusal(jobLines(j)), result: resultOf(d.commit, j.name, j.started_at) }))); return { cycle: demo.cycle, // behold#631: a chant repo's pull-request loop: a cycle may hold a fix's pull request after the first, each told as its own run of beats. @@ -78,8 +89,9 @@ export function ehSnapshot({ demo = null, answer = null, progress = null, runDoc pull: demo.pull, label: demo.label || "", plan: pr ? { totals: pr.totals || null, roots: pr.roots || [], reads: pr.reads || [] } : null, - states: run ? progress.states || [] : [], - run: runDoc ? { id: runDoc.id, jobs: jobs.map((j) => ({ name: j.name, status: j.status, wave: waveOfJob(j.name, waves), refusal: j.status === "failure" ? yodelRefusal(jobLines(j)) : null, step: j.steps ? defaultStep(j.steps) : -1 })) } : null, + // behold#751: each wave with its report's result, of the run view's commit. + states: run ? (progress.states || []).map((s) => ({ ...s, result: waveResultOf(answer, run.commit, s.number) })) : [], + run: runDoc ? { id: runDoc.id, jobs: jobs.map((j) => ({ name: j.name, status: j.status, wave: waveOfJob(j.name, waves), refusal: j.status === "failure" ? yodelRefusal(jobLines(j)) : null, step: j.steps ? defaultStep(j.steps) : -1, result: resultOf(runDoc.commit, j.name, j.started_at) })) } : null, approval: approval && Array.isArray(approval.rows) ? { wave: approval.wave, rows: approval.rows.filter((r) => r.state === "lit").map((r) => ({ id: r.id, at: r.at || null, actor: r.id === "approved" ? actorOf(r.text) : null, signed: !!(r.seal && /^signed/.test(r.seal.text || "")) })), ...(Array.isArray(approval.chantWaves) ? { chantWaves: approval.chantWaves } : {}) } : null, // The numbers of this cycle's merge only: from the merge on, and only for its commit. metrics: metrics && metrics.run && metrics.run.current && stepRank(demo.step, strip) >= stepRank("merged", strip) && (!demo.commit || String(metrics.run.label || "").includes(String(demo.commit).slice(0, 8))) ? metrics.run.waves.map((w) => ({ wave: w.wave, words: [w.seconds, w.held ? `held ${w.held}` : null, w.changed].filter(Boolean).join(" · ") })).filter((w) => w.words) : [], @@ -91,9 +103,9 @@ export function ehSnapshot({ demo = null, answer = null, progress = null, runDoc // The waves this cycle saw fail, kept by the kiosk: a re-run is news only against a failure seen before it. failed: [...new Set(failed)], // The cycle's earlier runs' failures (the approval panel reads them): a viewer who arrives after the re-run still gets the refusal. - pastFailures: (runDocs || []) - .filter((d) => d && d.id !== (runDoc && runDoc.id) && (!demo.cycle || d.cycle === undefined || d.cycle === demo.cycle) && Array.isArray(d.jobs)) - .flatMap((d) => d.jobs.filter((j) => j.status === "failure" && waveOfJob(j.name, waves) !== null).map((j) => ({ wave: waveOfJob(j.name, waves), job: j.name, run: d.id, refusal: yodelRefusal(jobLines(j)) }))), + // behold#751: a failed job whose wave's report says it applied and blocked roots is no failure of the wave: it is `pastBlocked`. + pastFailures: pastJobs.filter((f) => !f.result || resultFailed(f.result)).map(({ result, ...f }) => f), + pastBlocked: pastJobs.filter((f) => f.result && !resultFailed(f.result) && resultBlocked(f.result)), }; } @@ -153,7 +165,8 @@ export function cycleFacts(snap) { const jobOf = (n) => (snap.run ? snap.run.jobs.find((j) => j.wave === n) : null); const approved = snap.approval ? snap.approval.rows.find((r) => r.id === "approved") : null; const states = [...snap.states].sort((a, b) => a.number - b.number); - const failedBefore = new Set([...(snap.failed || []), ...(snap.pastFailures || []).map((f) => f.wave)]); + // behold#751: a wave an earlier run left roots of blocked runs again, as a failed one does. + const failedBefore = new Set([...(snap.failed || []), ...(snap.pastFailures || []).map((f) => f.wave), ...(snap.pastBlocked || []).map((f) => f.wave)]); for (const s of states) { const n = s.number; const roots = rootsOfWave(n, snap.waves, states); @@ -162,7 +175,9 @@ export function cycleFacts(snap) { const base = 10 + n * 10; if (["applying", "waiting", "applied", "failed", "refused"].includes(s.state)) add({ id: `${c}|w${n}|start`, kind: "started", text: `wave ${n} started`, order: base, subjects, trail: false }); // A failure the run view no longer shows (the re-run moved on) is still the pipeline's run's. - const failedJob = job && job.status === "failure" ? job : null; + // behold#751: unless the wave's report says otherwise: a wave that applied what it planned and blocked the rest ends its + // job as a failure (terragucci#1161), and is no failed wave. The job's status speaks only where no report of the wave does. + const failedJob = job && job.status === "failure" && !(job.result && !resultFailed(job.result)) ? job : null; const past = (snap.pastFailures || []).find((f) => f.wave === n); if (s.state === "failed" || s.state === "refused" || failedJob || past) { failedBefore.add(n); @@ -181,7 +196,16 @@ export function cycleFacts(snap) { } } if (failedBefore.has(n) && (s.state === "applying" || s.state === "applied") && !failedJob) add({ id: `${c}|w${n}|rerun`, kind: "rerun", text: `wave ${n} runs again`, order: base + 6, subjects }); - if (s.state === "applied") { + // behold#751: what the wave's report says it held back, once the run view settles it, or an earlier run of the cycle did: + // "wave 3 applied 6, 6 blocked by cluster-a", "wave 3: 6 blocked by cluster-a" for one that ran nothing. + const nowHeld = ["applied", "blocked"].includes(s.state) ? [s.result, job && job.result].find((r) => r && !resultFailed(r) && resultBlocked(r)) : null; + const pastHeld = (snap.pastBlocked || []).find((f) => f.wave === n); + const held = nowHeld || (pastHeld && pastHeld.result); + if (held) { + const words = resultWords(held); + add({ id: `${c}|w${n}|blocked`, kind: "blocked", text: held.state === "applied" ? `wave ${n} ${words}` : `wave ${n}: ${words}`, order: base + 7, subjects: pastHeld && !(job && job.status === "failure") ? { ...subjects, job: pastHeld.job, run: pastHeld.run } : subjects }); + } + if (s.state === "applied" && !nowHeld) { const changed = changedWords(s.totals); const under = approved && snap.approval.wave === n && approved.actor ? ` under ${approved.actor}'s approval` : ""; add({ id: `${c}|w${n}|applied`, kind: "applied-wave", text: `wave ${n} applied${under || (changed ? `: ${changed}` : "")}`, order: base + 7, subjects }); diff --git a/web/terragucci-change.js b/web/terragucci-change.js index 3670c4f5..daa8b78f 100644 --- a/web/terragucci-change.js +++ b/web/terragucci-change.js @@ -521,6 +521,58 @@ export function blockedHeader(roots, blocked, state) { return state === "applied" ? `${ran} applied, ${words}` : `${ran} ${STATE_WORDS[state] || state}, ${words}`; } +/** + * behold#751: a wave's result as its own report says it (/api/terragucci's + * `results`, by commit), for the commit the run that applied it is of. A + * wave's job is no witness to it: terragucci ends the job of a wave that + * applied what it planned and blocked the rest as a failure (terragucci#1161), + * so the commit status isn't green while roots are unapplied. `after` is when + * the job started: a report finished before it is an earlier run's on the + * commit, and says nothing of this one. Null without a report of the wave, + * where the job's status is all there is. + */ +export function waveResultOf(answer, commit, wave, { after = null } = {}) { + const all = answer && !answer.error && answer.results && typeof answer.results === "object" ? answer.results : null; + if (!all || typeof commit !== "string" || !commit || !Number.isInteger(wave)) return null; + const key = Object.keys(all).find((c) => sameCommit(c, commit)); + const r = key && Array.isArray(all[key]) ? all[key].find((x) => x && x.wave === wave && typeof x.state === "string") : null; + if (!r) return null; + const done = Date.parse(r.finished); + const start = after ? Date.parse(after) : NaN; + if (Number.isFinite(done) && Number.isFinite(start) && done < start) return null; + return r; +} + +/** behold#751: whether a wave's report says the wave itself failed (a root of its own failed, or the wave was refused). */ +export const resultFailed = (r) => !!r && (r.state === "failed" || r.state === "refused"); + +/** behold#751: whether a wave's report says it held roots back: some blocked, or the whole wave. */ +export const resultBlocked = (r) => !!r && (r.state === "blocked" || (Array.isArray(r.blocked) && r.blocked.length > 0)); + +/** + * behold#751: a wave's result in words, from its report: "applied 6, 6 + * blocked by cluster-a" for a wave that applied what it planned and blocked + * the rest, "6 blocked by cluster-a" for one that ran nothing, "1 failed, 1 + * applied" for one a root of its own failed, else its state ("applied"). + */ +export function resultWords(r) { + if (!r) return null; + const held = Array.isArray(r.blocked) ? r.blocked : []; + const by = [...new Set(held.map((b) => b && b.by).filter(Boolean))].sort(); + const blocked = held.length ? `${held.length} blocked${by.length ? ` by ${and(by)}` : ""}` : null; + const ran = (Array.isArray(r.applied) ? r.applied.length : 0) + (Array.isArray(r.unchanged) ? r.unchanged.length : 0); + if (r.state === "applied") return blocked ? `applied ${ran}, ${blocked}` : "applied"; + if (r.state === "blocked") return blocked || "blocked"; + if (r.state === "failed") { + const failed = Array.isArray(r.failed) ? r.failed.length : 0; + return failed ? `${failed} failed${ran ? `, ${ran} applied` : ""}${blocked ? `, ${blocked}` : ""}` : "failed"; + } + return STATE_WORDS[r.state] || r.state; +} + +/** behold#751: the tone a wave's result is drawn in: blocked's for one that held roots back, bad for a failure. */ +export const resultTone = (r) => (resultFailed(r) ? "bad" : resultBlocked(r) ? BLOCKED_TONE : r && r.state === "applied" ? "ok" : "idle"); + /** * #569 review: whether a root of a run-view wave plans a change. A root its * wave planned without a change (`changed`, the roots whose plan changes a diff --git a/web/terragucci-components-live.js b/web/terragucci-components-live.js index a04578ff..5e9b22d9 100644 --- a/web/terragucci-components-live.js +++ b/web/terragucci-components-live.js @@ -11,7 +11,7 @@ // wave that failed says the waves before it stay applied, and nothing here is // all-or-nothing. -import { BLOCKED_TONE, blockedHeader, blockedOf, pinsCommit, rootStates, totalsLine } from "./terragucci-change.js"; +import { BLOCKED_TONE, blockedHeader, blockedOf, pinsCommit, resultFailed, resultTone, resultWords, rootStates, totalsLine, waveResultOf } from "./terragucci-change.js"; import { shortReason } from "./chant-pr-marks.js"; import { rootNames } from "./cone.js"; @@ -110,6 +110,20 @@ export function waveStatus(status, state) { return { status: state, words: WAVE_WORDS[state], tone: toneOf(state), run: status.superseded }; } +/** + * behold#751: a wave's job status, unless the job failed and the wave's own + * report (`result`, terragucci-change.js waveResultOf) says the wave did not: + * terragucci ends the job of a wave that applied what it planned and blocked + * the rest as a failure (terragucci#1161), so the commit status isn't green + * while roots are unapplied. Then the box says what the report does, "applied + * 6, 6 blocked by cluster-a", in its tone (`report`). A wave the report says + * failed, and a job with no report of its wave, keep the job's status. + */ +export function reportStatus(status, result) { + if (!status || status.status !== "failure" || !result || resultFailed(result)) return status; + return { status: result.state === "blocked" ? "blocked" : "done", words: resultWords(result), tone: resultTone(result), report: true, ...(status.run ? { run: status.run } : {}) }; +} + /** A status's words in a narrow box, where the full words cross an edge (behold#693): "held" for a wave held at its gate. */ export function statusShort(status) { if (!status) return null; @@ -192,7 +206,8 @@ export function componentMarks(answer, progress, facets, { runs = null, pin = nu const jobName = jobs.find((j) => j.wave === n).jobName; const members = jobs.filter((j) => j.wave === n).map((j) => cards[j.component]).filter(Boolean); const w = waveState(answer, progress, stage, n); - const status = commit ? waveStatus(jobStatus(runs, commit, jobName), w) : null; + // behold#751: a job that failed while its wave's report says the wave applied (and blocked the rest) reads as the report says. + const status = commit ? reportStatus(waveStatus(jobStatus(runs, commit, jobName), w), waveResultOf(answer, commit, n)) : null; // The wave's job ended well and the run view never started a root: the wave applied nothing to it. Say so, // never "queued" under a box that says the job succeeded. if (stage === "apply" && status && status.status === "success") for (const m of members) settleMember(m, progress, n); @@ -230,7 +245,7 @@ export function componentMarks(answer, progress, facets, { runs = null, pin = nu job: jobName, state: w, // A re-run held at its gate (behold#693) tones the box as its title says. - tone: header ? headerTone : shown && shown.held && shown.status === "waiting" ? shown.tone : w ? toneOf(w) : shown ? shown.tone : "idle", + tone: header ? headerTone : shown && ((shown.held && shown.status === "waiting") || shown.report) ? shown.tone : w ? toneOf(w) : shown ? shown.tone : "idle", status: shown, title: waveTitle(jobName, shown), facts, diff --git a/web/terragucci-wave-results.test.js b/web/terragucci-wave-results.test.js new file mode 100644 index 00000000..618ea0cb --- /dev/null +++ b/web/terragucci-wave-results.test.js @@ -0,0 +1,125 @@ +// behold#751: a terragucci wave's result is worded from its own report, not +// its Forgejo job's status. terragucci ends the job of a wave that applied +// what it planned and blocked the rest as a failure (terragucci#1161), so the +// commit status isn't green while roots are unapplied. On the fan-out kiosks +// that read "wave 3 failed" in the fix chapter, where cluster-a broke in wave +// 2 and wave 3 applied cluster-b's six apps and blocked cluster-a's six. +// +// The reports and runs are a real fan-out-choudoufu cycle's +// (src/__fixtures__/terragucci-wave-results: run 6745, the change's merge, +// and 6748, the fix's), read the way /api/terragucci reads them. +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { beforeAll, describe, expect, it } from "vitest"; +import { readTerragucci } from "../src/terragucci-reports.ts"; +import { terragucciSource } from "../src/terragucci-source.ts"; +import { cycleFacts, ehSnapshot, storyTrail } from "./kiosk-event-help.js"; +import { componentMarks, reportStatus } from "./terragucci-components-live.js"; +import { resultWords, waveResultOf } from "./terragucci-change.js"; + +const FIXTURE = join(import.meta.dirname, "..", "src", "__fixtures__", "terragucci-wave-results"); +const CHANGE = "2a615596a4f0ed954bdcaa83f77e575eaf2cb5ab"; +const FIX = "5cfbdb79c7a45d4b4d80e4c8e2a200afcc9c225e"; +const FIX_PR = "57fcc6ed000000000000000000000000000000aa"; +const APPS_A = ["app-01", "app-02", "app-03", "app-04", "app-05", "app-06"]; +const APPS_B = ["app-07", "app-08", "app-09", "app-10", "app-11", "app-12"]; +const run6745 = JSON.parse(readFileSync(join(FIXTURE, "run-6745.json"), "utf8")); +const run6748 = JSON.parse(readFileSync(join(FIXTURE, "run-6748.json"), "utf8")); +// The fix's pull request's plan run: its apply jobs skipped. +const run6746 = { schema: "demo.run/v1", id: 6746, commit: FIX_PR, cycle: 605, pull: 56, status: "success", jobs: [1, 2, 3].map((n) => ({ name: `apply-wave-${n}`, status: "skipped", steps: [] })) }; +const waves = [ + { job: "apply-wave-1", wave: 1, roots: ["network"] }, + { job: "apply-wave-2", wave: 2, roots: ["cluster-a", "cluster-b"] }, + { job: "apply-wave-3", wave: 3, roots: [...APPS_A, ...APPS_B] }, +]; +const demo = (step, more = {}) => ({ cycle: 605, scenario: "fan-out-choudoufu", step, label: "", started_at: "2026-10-19T01:57:00Z", pull: 55, commit: CHANGE, ...more }); +// The run views as terragucci wrote them: the change's (wave 2 failed, wave 3 applied) and the fix's. +const runView = (commit, updated, states) => ({ run: { present: true, commit, updated }, states: states.map(([number, state, roots]) => ({ number, state, roots, changed: roots, totals: {} })), reads: [] }); +const changeView = runView(CHANGE, "2026-10-19T01:58:52.600Z", [[1, "applied", ["network"]], [2, "failed", ["cluster-a", "cluster-b"]], [3, "applied", [...APPS_A, ...APPS_B]]]); +const fixView = runView(FIX, "2026-10-19T02:01:47.800Z", [[1, "applied", ["network"]], [2, "applied", ["cluster-a", "cluster-b"]], [3, "applied", [...APPS_A, ...APPS_B]]]); + +let answer; +beforeAll(async () => { + const structural = { validation: { by: "structural" }, check: (_n, doc) => (doc && typeof doc === "object" ? undefined : "not an object") }; + const r = await readTerragucci(terragucciSource(FIXTURE), { validator: structural }); + answer = { roots: [], pull_request: null, results: r.results }; +}); + +const facts = (snap) => cycleFacts(ehSnapshot({ waves, ...snap })); +const byId = (fs, tail) => fs.find((f) => f.id.endsWith(tail)); +const failedWaves = (fs) => fs.filter((f) => f.kind === "failed").map((f) => f.subjects.wave); + +describe("a wave's result from its report (behold#751)", () => { + it("words run 6745's wave 3 as its report does, and its wave 2 as failed", () => { + expect(resultWords(waveResultOf(answer, CHANGE, 3))).toBe("applied 6, 6 blocked by cluster-a"); + expect(resultWords(waveResultOf(answer, CHANGE.slice(0, 8), 2))).toBe("1 failed, 1 applied"); + expect(resultWords(waveResultOf(answer, FIX, 3))).toBe("applied"); + // A report finished before the job started is an earlier run's: the job's status speaks. + expect(waveResultOf(answer, CHANGE, 3, { after: "2026-10-19T02:30:00Z" })).toBeNull(); + expect(waveResultOf(answer, CHANGE, 3, { after: run6745.jobs.find((j) => j.name === "apply-wave-3").started_at })).not.toBeNull(); + expect(waveResultOf({ roots: [] }, CHANGE, 3)).toBeNull(); + }); +}); + +describe("event-help: the failure chapter and the fix chapter (behold#751)", () => { + it("in the failure chapter, wave 2 failed and wave 3 applied 6 with 6 blocked, never 'wave 3 failed'", () => { + const fs = facts({ demo: demo("failed"), answer, progress: changeView, runDoc: run6745, runDocs: [run6745] }); + expect(failedWaves(fs)).toEqual([2]); + expect(byId(fs, "|w2|failed")).toMatchObject({ text: "wave 2 failed", critical: true }); + expect(byId(fs, "|w3|blocked")).toMatchObject({ kind: "blocked", text: "wave 3 applied 6, 6 blocked by cluster-a", critical: false, subjects: { wave: 3, job: "apply-wave-3", run: 6745 } }); + // The run view's "wave 3 applied" is the blocked fact's to say, with what it held back. + expect(byId(fs, "|w3|applied")).toBeUndefined(); + expect(storyTrail(fs).map((f) => f.text)).toEqual(expect.arrayContaining(["wave 2 failed", "wave 3 applied 6, 6 blocked by cluster-a"])); + }); + + it("in the fix chapter, the pill and trail say the same of the change's run, now an earlier one", () => { + const fs = facts({ demo: demo("planned", { pull: 56, commit: FIX_PR }), answer, progress: changeView, runDoc: run6746, runDocs: [run6745, run6746] }); + expect(failedWaves(fs)).toEqual([2]); + expect(fs.some((f) => f.text === "wave 3 failed")).toBe(false); + expect(byId(fs, "|w3|blocked")).toMatchObject({ text: "wave 3 applied 6, 6 blocked by cluster-a", subjects: { wave: 3, job: "apply-wave-3", run: 6745 } }); + }); + + it("in the fix's apply, wave 3 runs again and applies", () => { + const fs = facts({ demo: demo("applied", { pull: 56, commit: FIX }), answer, progress: fixView, runDoc: run6748, runDocs: [run6745, run6746, run6748] }); + expect(fs.some((f) => f.text === "wave 3 failed")).toBe(false); + expect(byId(fs, "|w3|rerun")).toMatchObject({ text: "wave 3 runs again" }); + expect(byId(fs, "|w3|applied")).toMatchObject({ text: "wave 3 applied" }); + }); + + it("falls back to the job's status where no report of the wave is read", () => { + const fs = facts({ demo: demo("failed"), answer: { roots: [] }, progress: changeView, runDoc: run6745, runDocs: [run6745] }); + expect(failedWaves(fs)).toEqual([2, 3]); + const later = facts({ demo: demo("planned", { pull: 56, commit: FIX_PR }), answer: { roots: [] }, progress: changeView, runDoc: run6746, runDocs: [run6745, run6746] }); + expect(failedWaves(later)).toEqual([2, 3]); + }); +}); + +describe("the wave box's title (behold#751)", () => { + const facets = { + jobs: [ + { component: "network", jobName: "apply-wave-1", wave: 1 }, + { component: "cluster-a", jobName: "apply-wave-2", wave: 2 }, + { component: "cluster-b", jobName: "apply-wave-2", wave: 2 }, + ...[...APPS_A, ...APPS_B].map((c) => ({ component: c, jobName: "apply-wave-3", wave: 3 })), + ], + }; + const runs = { doc: { runs: [{ id: 6745, commit: CHANGE, jobs: run6745.jobs.map(({ name, status }) => ({ name, status })) }] } }; + + it("says wave 3 applied 6 with 6 blocked, and wave 2 failed, on run 6745", () => { + const m = componentMarks(answer, changeView, facets, { runs }); + expect(m.waves[3].title).toBe("apply-wave-3 · applied 6, 6 blocked by cluster-a"); + expect(m.waves[3].tone).toBe("wait"); + expect(m.waves[2].title).toBe("apply-wave-2 · failed"); + expect(m.waves[2].tone).toBe("bad"); + expect(m.waves[1].title).toBe("apply-wave-1 · succeeded"); + }); + + it("keeps the job's status with no report of the wave, and for any job that did not fail", () => { + expect(componentMarks({ roots: [] }, changeView, facets, { runs }).waves[3].title).toBe("apply-wave-3 · failed"); + const ok = { status: "success", words: "succeeded", tone: "ok", run: 6748 }; + expect(reportStatus(ok, waveResultOf(answer, CHANGE, 3))).toBe(ok); + const failed = { status: "failure", words: "failed", tone: "bad", run: 6745 }; + expect(reportStatus(failed, waveResultOf(answer, CHANGE, 2))).toBe(failed); + expect(reportStatus(failed, null)).toBe(failed); + }); +});