Skip to content

Commit 38e7b8a

Browse files
committed
Add isolated fallback attribution capture envelope
1 parent 35749f4 commit 38e7b8a

6 files changed

Lines changed: 878 additions & 65 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: One fallback attribution capture
2+
on:
3+
push:
4+
branches: [codex/fallback-attribution-35749f4]
5+
permissions:
6+
contents: read
7+
jobs:
8+
capture:
9+
runs-on: ubuntu-26.04
10+
timeout-minutes: 20
11+
steps:
12+
- name: Retain initial envelope before checkout or runtime setup
13+
run: |
14+
mkdir -p "$RUNNER_TEMP/fallback-capture/evidence"
15+
printf '{"schema":"fallback-initial.v1","consumerExecutions":0,"status":"before-checkout-and-setup","envelope":"%s","run":"%s","attempt":"%s","image":"%s","runner":"%s"}\n' "$GITHUB_SHA" "$GITHUB_RUN_ID" "$GITHUB_RUN_ATTEMPT" "$ImageVersion" "$RUNNER_NAME" > "$RUNNER_TEMP/fallback-capture/evidence/initial-manifest.json"
16+
uname -a > "$RUNNER_TEMP/fallback-capture/evidence/initial-uname.txt"
17+
cat /etc/os-release > "$RUNNER_TEMP/fallback-capture/evidence/initial-os-release.txt"
18+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
19+
with:
20+
fetch-depth: 0
21+
persist-credentials: false
22+
- uses: denoland/setup-deno@e95548e56dfa95d4e1a28d6f422fafe75c4c26fb
23+
with:
24+
deno-version: v2.9.5
25+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
26+
with:
27+
node-version: "22.23.4"
28+
- uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1
29+
- uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6
30+
with:
31+
bun-version: 1.4.0
32+
- name: Admit runner, prepare exact product once, then instrument
33+
run: |
34+
runner_binary="$(readlink -f "/proc/$PPID/exe")"
35+
printf '%s\n' "$runner_binary" > "$RUNNER_TEMP/fallback-capture/evidence/runner-worker-path.txt"
36+
export CAPTURE_RUNNER_VERSION="$("$(dirname "$runner_binary")/Runner.Listener" --version)"
37+
deno run --allow-all --node-modules-dir=none --frozen scripts/fallback-capture-deno.ts prepare
38+
- name: Capture the complete consumer exactly once
39+
timeout-minutes: 6
40+
run: deno run --allow-all --node-modules-dir=none --frozen scripts/fallback-capture-deno.ts consume
41+
- name: Retain partial evidence after every terminal outcome
42+
if: always()
43+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a
44+
with:
45+
name: fallback-capture-35749f4-${{ github.run_id }}-attempt-${{ github.run_attempt }}
46+
path: ${{ runner.temp }}/fallback-capture/evidence
47+
include-hidden-files: true
48+
if-no-files-found: error
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { Component } from "@executablemd/core/api";
2+
import { env } from "@executablemd/runtime";
3+
import { scoped } from "effection";
4+
import { z } from "zod";
5+
import { captureCase, ownCapture } from "./capture-state.ts";
6+
7+
export const props = {
8+
type: "object",
9+
properties: { scenario: { type: "string" }, fixture: { type: "object" } },
10+
required: ["scenario", "fixture"],
11+
additionalProperties: false,
12+
};
13+
export default function CaptureCase(value: unknown) {
14+
return scoped(function* () {
15+
const { scenario, fixture } = z
16+
.object({
17+
scenario: z.string(),
18+
fixture: z.object({
19+
root: z.string(),
20+
repository: z.string(),
21+
directory: z.string(),
22+
}),
23+
})
24+
.parse(value);
25+
const destination = yield* env("XMD_TEST_ARTIFACTS");
26+
if (!destination) {
27+
throw new Error("Fallback capture requires inherited XMD_TEST_ARTIFACTS");
28+
}
29+
const capture = yield* ownCapture(destination, scenario, {
30+
root: fixture.root,
31+
repository: fixture.repository,
32+
delivery: fixture.directory + "/delivery",
33+
});
34+
yield* captureCase.set(capture);
35+
try {
36+
const content = yield* Component.operations.content();
37+
yield* capture.write({ schema: "fallback-case-completed.v1" });
38+
if (capture.failure() !== undefined) {
39+
throw new Error("Fallback diagnostic capture failed: " + capture.failure());
40+
}
41+
return content;
42+
} catch (error) {
43+
yield* capture.write({ schema: "fallback-case-failed.v1", error: String(error) });
44+
throw error;
45+
}
46+
});
47+
}

0 commit comments

Comments
 (0)