Skip to content

Commit b30773a

Browse files
authored
Merge pull request #521 from openclaw/feat/action-ledger-repair-ops
feat(ledger): record ClawSweeper action lifecycles
2 parents 3ab249b + b37f1f0 commit b30773a

197 files changed

Lines changed: 53271 additions & 3658 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/setup-action-ledger/action.yml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ inputs:
55
description: ClawSweeper checkout path relative to the workspace.
66
required: false
77
default: "."
8+
outputs:
9+
output-root:
10+
description: Canonical action ledger shard output root.
11+
value: ${{ steps.context.outputs.output-root }}
812
runs:
913
using: composite
1014
steps:
1115
- name: Export immutable action ledger context
16+
id: context
1217
shell: bash
1318
env:
1419
GH_TOKEN: ${{ github.token }}
@@ -30,3 +35,4 @@ runs:
3035
echo "CLAWSWEEPER_ACTION_LEDGER_OUTPUT_ROOT=$output_root"
3136
echo "GITHUB_RUN_STARTED_AT=$run_started_at"
3237
} >> "$GITHUB_ENV"
38+
echo "output-root=$output_root" >> "$GITHUB_OUTPUT"

‎.github/actions/setup-state/action.yml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ inputs:
2828
description: Optional newline-separated state paths to hydrate.
2929
required: false
3030
default: ""
31+
hydrate-paths:
32+
description: Optional newline-separated approved generated roots to hydrate. Defaults to the standard roots; ledger must be selected explicitly.
33+
required: false
34+
default: ""
3135
persist-credentials:
3236
description: Persist the checkout token in local git config for later state publication.
3337
required: false
@@ -58,4 +62,5 @@ runs:
5862
shell: bash
5963
env:
6064
CLAWSWEEPER_STATE_DIR: ${{ inputs.state-path }}
65+
CLAWSWEEPER_HYDRATE_PATHS: ${{ inputs.hydrate-paths }}
6166
run: node "${{ inputs.worktree-path }}/scripts/hydrate-state.ts" --state-dir "${{ inputs.state-path }}" --worktree "${{ inputs.worktree-path }}"
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"action_ledger": true,
3+
"schema": "clawsweeper.repair-worker-capabilities",
4+
"schema_version": 1,
5+
"sealed_source": true
6+
}

‎.github/workflows/assist.yml‎

Lines changed: 90 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ jobs:
8888
fi
8989
expected_title="Assist ${TARGET_REPO}#${ITEM_NUMBER} [${DISPATCH_KEY}]"
9090
owner="$(bash scripts/dispatch-receipt-owner.sh \
91-
assist.yml "$expected_title" "$GITHUB_RUN_ID" assist)"
91+
assist.yml "$expected_title" "$GITHUB_RUN_ID" \
92+
"Publish trusted assist comment" "Revalidate and publish assist comment")"
9293
if [ "$owner" = "owner" ]; then
9394
echo "proceed=false" >> "$GITHUB_OUTPUT"
9495
echo "An older active or successfully executed command dispatch already exists; skipping duplicate assist."
@@ -176,6 +177,9 @@ jobs:
176177
filter: blob:none
177178
persist-credentials: false
178179

180+
- uses: ./.github/actions/setup-action-ledger
181+
id: assist-action-ledger
182+
179183
- uses: ./.github/actions/setup-pnpm
180184
with:
181185
build-script: build
@@ -246,6 +250,7 @@ jobs:
246250
echo "generation_attempt=$GITHUB_RUN_ATTEMPT" >> "$GITHUB_OUTPUT"
247251
248252
- name: Upload assist artifact
253+
if: ${{ steps.generate.outcome == 'success' }}
249254
uses: actions/upload-artifact@v7
250255
with:
251256
name: clawsweeper-assist-${{ github.run_id }}-${{ steps.generate.outputs.generation_attempt }}
@@ -254,10 +259,20 @@ jobs:
254259
if-no-files-found: error
255260
retention-days: 1
256261

262+
- name: Upload assist generation action ledger
263+
if: ${{ always() && steps.assist-action-ledger.outcome == 'success' }}
264+
uses: actions/upload-artifact@v7
265+
with:
266+
name: action-ledger-assist-${{ github.run_id }}-${{ github.run_attempt }}
267+
path: ${{ steps.assist-action-ledger.outputs.output-root }}/**
268+
include-hidden-files: true
269+
if-no-files-found: warn
270+
retention-days: 90
271+
257272
publish:
258273
name: Publish trusted assist comment
259274
needs: assist
260-
if: ${{ needs.assist.result == 'success' }}
275+
if: ${{ always() && needs.assist.result != 'skipped' }}
261276
runs-on: ubuntu-latest
262277
timeout-minutes: 5
263278
steps:
@@ -267,15 +282,33 @@ jobs:
267282
filter: blob:none
268283
persist-credentials: false
269284

285+
- uses: ./.github/actions/setup-action-ledger
286+
id: publish-action-ledger
287+
288+
- name: Create state token
289+
id: state-token
290+
uses: ./.github/actions/create-state-token
291+
with:
292+
client-id: ${{ env.CLAWSWEEPER_APP_CLIENT_ID }}
293+
private-key: ${{ secrets.CLAWSWEEPER_APP_PRIVATE_KEY }}
294+
295+
- uses: ./.github/actions/setup-state
296+
id: setup-state
297+
with:
298+
token: ${{ steps.state-token.outputs.token }}
299+
270300
- uses: ./.github/actions/setup-pnpm
301+
id: setup-pnpm
271302
with:
272303
build-script: build
273304

274305
- name: Verify exact workflow source
306+
if: ${{ needs.assist.result == 'success' }}
275307
run: test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
276308

277309
- name: Resolve validated target repository
278310
id: target
311+
if: ${{ needs.assist.result == 'success' }}
279312
env:
280313
TARGET_REPO: ${{ github.event.client_payload.target_repo || inputs.target_repo }}
281314
run: |
@@ -288,12 +321,22 @@ jobs:
288321
} >> "$GITHUB_OUTPUT"
289322
290323
- name: Download assist artifact
324+
if: ${{ needs.assist.result == 'success' }}
291325
uses: actions/download-artifact@v8
292326
with:
293327
name: clawsweeper-assist-${{ github.run_id }}-${{ needs.assist.outputs.generation_attempt }}
294328
path: .artifacts/publish
295329

330+
- name: Download assist generation action ledger
331+
id: download-assist-action-ledger
332+
continue-on-error: true
333+
uses: actions/download-artifact@v8
334+
with:
335+
name: action-ledger-assist-${{ github.run_id }}-${{ needs.assist.outputs.generation_attempt }}
336+
path: .clawsweeper-repair/action-ledger-download/assist
337+
296338
- name: Validate untrusted assist artifact
339+
if: ${{ needs.assist.result == 'success' }}
297340
env:
298341
TARGET_REPO: ${{ steps.target.outputs.target_repo }}
299342
ITEM_NUMBER: ${{ github.event.client_payload.item_number || inputs.item_number }}
@@ -323,6 +366,7 @@ jobs:
323366
324367
- name: Create narrow GitHub App write token
325368
id: write_token
369+
if: ${{ needs.assist.result == 'success' }}
326370
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
327371
with:
328372
client-id: ${{ env.CLAWSWEEPER_APP_CLIENT_ID }}
@@ -333,6 +377,8 @@ jobs:
333377
permission-pull-requests: write
334378

335379
- name: Revalidate and publish assist comment
380+
id: publish-comment
381+
if: ${{ needs.assist.result == 'success' }}
336382
env:
337383
GH_TOKEN: ${{ steps.write_token.outputs.token }}
338384
TARGET_REPO: ${{ steps.target.outputs.target_repo }}
@@ -361,3 +407,45 @@ jobs:
361407
--codex-reasoning-effort "$REASONING_EFFORT" \
362408
--run-id "$GITHUB_RUN_ID" \
363409
--run-attempt "$GENERATION_ATTEMPT"
410+
411+
- name: Publish immutable assist action ledger
412+
if: ${{ always() && steps.setup-state.outcome == 'success' && steps.setup-pnpm.outcome == 'success' && steps.publish-action-ledger.outcome == 'success' }}
413+
env:
414+
GENERATION_ATTEMPT: ${{ needs.assist.outputs.generation_attempt }}
415+
GENERATION_LEDGER_OUTCOME: ${{ steps.download-assist-action-ledger.outcome }}
416+
run: |
417+
set -euo pipefail
418+
test -n "${CLAWSWEEPER_STATE_DIR:-}"
419+
test -n "$GENERATION_ATTEMPT"
420+
event_paths_file=".artifacts/assist-action-ledger-paths.txt"
421+
mkdir -p .artifacts
422+
: > "$event_paths_file"
423+
if [ "$GENERATION_LEDGER_OUTCOME" = "success" ]; then
424+
pnpm run --silent publish-action-events -- \
425+
--source-root .clawsweeper-repair/action-ledger-download/assist \
426+
--state-root "$CLAWSWEEPER_STATE_DIR" \
427+
--expected-run-attempt "$GENERATION_ATTEMPT" \
428+
--expected-producer-job assist |
429+
jq -r '.paths[]?' >> "$event_paths_file"
430+
fi
431+
if [ -d "$CLAWSWEEPER_ACTION_LEDGER_OUTPUT_ROOT/ledger" ]; then
432+
pnpm run --silent publish-action-events -- \
433+
--source-root "$CLAWSWEEPER_ACTION_LEDGER_OUTPUT_ROOT" \
434+
--state-root "$CLAWSWEEPER_STATE_DIR" \
435+
--expected-producer-job "$GITHUB_JOB" |
436+
jq -r '.paths[]?' >> "$event_paths_file"
437+
fi
438+
sort -u -o "$event_paths_file" "$event_paths_file"
439+
if [ ! -s "$event_paths_file" ]; then
440+
echo "No immutable assist action events to publish."
441+
exit 0
442+
fi
443+
while IFS= read -r event_path; do
444+
durable_event_path="$CLAWSWEEPER_STATE_DIR/$event_path"
445+
test -f "$durable_event_path"
446+
mkdir -p "$(dirname "$event_path")"
447+
cp "$durable_event_path" "$event_path"
448+
done < "$event_paths_file"
449+
node dist/clawsweeper.js publish-action-event-paths \
450+
--paths-file "$event_paths_file" \
451+
--message "chore: append assist action ledger"

0 commit comments

Comments
 (0)