Skip to content

Commit 063fcaf

Browse files
authored
improve(ci): add trusted FRV proof broker (#128966)
* improve(ci): add trusted FRV proof broker * fix(ci): tighten FRV proof broker boundaries * test(ci): narrow FRV broker workflow lookup * fix(ci): renew FRV broker mutation authority * fix(ci): bind FRV proof to broker attempt
1 parent 15e8a60 commit 063fcaf

5 files changed

Lines changed: 988 additions & 0 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: FRV Proof Broker
2+
run-name: FRV Proof Broker PR #${{ inputs.pr_number }} run ${{ github.run_id }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
pr_number:
8+
description: Open OpenClaw pull request containing the FRV recovery candidate
9+
required: true
10+
type: string
11+
head_sha:
12+
description: Exact lowercase 40-character pull request head SHA
13+
required: true
14+
type: string
15+
permissions: {}
16+
17+
concurrency:
18+
group: frv-proof-broker
19+
cancel-in-progress: false
20+
21+
jobs:
22+
prove:
23+
name: Prove failed-job rerun boundary
24+
runs-on: ubuntu-24.04
25+
timeout-minutes: 20
26+
permissions:
27+
actions: write
28+
contents: read
29+
pull-requests: read
30+
steps:
31+
- name: Checkout trusted main broker
32+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
33+
with:
34+
ref: ${{ github.workflow_sha }}
35+
fetch-depth: 1
36+
persist-credentials: false
37+
38+
- name: Setup Node
39+
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
40+
with:
41+
node-version: "24"
42+
43+
- name: Run trusted FRV proof broker
44+
id: proof
45+
env:
46+
GH_TOKEN: ${{ github.token }}
47+
FRV_PROOF_RECEIPT: ${{ runner.temp }}/frv-proof-receipt.json
48+
run: node scripts/frv-proof-broker.mjs
49+
50+
- name: Upload proof receipt
51+
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
52+
with:
53+
name: frv-proof-${{ github.run_id }}
54+
path: ${{ steps.proof.outputs.receipt_path }}
55+
if-no-files-found: error
56+
retention-days: 30
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: FRV Proof Fixture
2+
run-name: FRV Proof Fixture [${{ inputs.operation }}] ${{ inputs.correlation }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
operation:
8+
description: Fixed harmless operation used by the FRV recovery proof
9+
required: true
10+
default: noop
11+
type: choice
12+
options:
13+
- noop
14+
correlation:
15+
description: Broker-generated correlation identifier
16+
required: true
17+
type: string
18+
19+
permissions: {}
20+
21+
jobs:
22+
fixture:
23+
name: Fail once, then pass
24+
runs-on: ubuntu-24.04
25+
timeout-minutes: 5
26+
permissions: {}
27+
steps:
28+
- name: Exercise failed-job rerun
29+
env:
30+
CORRELATION: ${{ inputs.correlation }}
31+
OPERATION: ${{ inputs.operation }}
32+
RUN_ATTEMPT: ${{ github.run_attempt }}
33+
run: |
34+
set -euo pipefail
35+
[[ "$OPERATION" == "noop" ]] || {
36+
echo "FRV proof fixture accepts only the fixed noop operation." >&2
37+
exit 2
38+
}
39+
[[ "$CORRELATION" =~ ^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$ ]] || {
40+
echo "FRV proof fixture correlation is invalid." >&2
41+
exit 2
42+
}
43+
if [[ "$RUN_ATTEMPT" == "1" ]]; then
44+
echo "Intentional first-attempt failure for $CORRELATION." >&2
45+
exit 42
46+
fi
47+
echo "No-op fixture passed on rerun attempt $RUN_ATTEMPT."

‎scripts/frv-proof-broker.d.mts‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
export type BrokerContext = {
2+
actor: string;
3+
correlation: string;
4+
headSha: string;
5+
prNumber: number;
6+
repository: "openclaw/openclaw";
7+
runId: number;
8+
workflowSha: string;
9+
};
10+
11+
export type GitHubApi = {
12+
request(method: string, path: string, body?: unknown): Promise<unknown>;
13+
};
14+
15+
export type FixtureRunExpectation = {
16+
attempt: number;
17+
branch: string;
18+
conclusion: "failure" | "success";
19+
correlation: string;
20+
headSha: string;
21+
repository: string;
22+
runId?: number;
23+
};
24+
25+
export type ProofReceipt = {
26+
actor: string;
27+
correlation: string;
28+
fixtureRunAttempt: 2;
29+
fixtureRunId: number;
30+
headSha: string;
31+
operation: "noop";
32+
prNumber: number;
33+
repository: "openclaw/openclaw";
34+
sourceRef: "refs/heads/main";
35+
workflowSha: string;
36+
};
37+
38+
export function validateBrokerRequest(event: unknown, env: NodeJS.ProcessEnv): BrokerContext;
39+
export function validateFixtureRun(
40+
value: unknown,
41+
expected: FixtureRunExpectation,
42+
): Record<string, unknown>;
43+
export function runProofBroker(options: {
44+
api: GitHubApi;
45+
env: NodeJS.ProcessEnv;
46+
event: unknown;
47+
sleep?: (milliseconds: number) => Promise<void>;
48+
}): Promise<ProofReceipt>;
49+
export function createGitHubApi(options: {
50+
repository: string;
51+
token: string;
52+
fetchImpl?: typeof fetch;
53+
}): GitHubApi;

0 commit comments

Comments
 (0)