Skip to content

Commit ab8e486

Browse files
authored
fix(queue): recover source callbacks and asynchronous queue advance (#82)
* Recover source validation callbacks and asynchronous queue advance Signed-off-by: IanHollow <72767437+IanHollow@users.noreply.github.com> * Ignore obsolete source callbacks and finish empty queues quietly Signed-off-by: IanHollow <72767437+IanHollow@users.noreply.github.com> * Document v2.12 source callbacks and queue recovery Signed-off-by: IanHollow <72767437+IanHollow@users.noreply.github.com> * docs: register v2.12 release notes in strict site navigation Signed-off-by: IanHollow <72767437+IanHollow@users.noreply.github.com> * test: bind callback fixture to the sandbox Python interpreter Signed-off-by: IanHollow <72767437+IanHollow@users.noreply.github.com> --------- Signed-off-by: IanHollow <72767437+IanHollow@users.noreply.github.com>
1 parent 1e0a32f commit ab8e486

8 files changed

Lines changed: 910 additions & 23 deletions

File tree

‎README.md‎

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,32 @@ mirrors skipped validation as success. `actions/queue-completion` notifies this
105105
trusted reconciler from dispatched queue runs. Retain the caller's existing
106106
`Queue completion callback` name and event guard.
107107

108+
Package-source callers can also notify the reconciler when validation starts and
109+
finishes. Add optional `source_run_attempt` and `source_activity` dispatch inputs
110+
to the default-branch reconciler, forwarding them to `source-run-attempt` and
111+
`source-activity` on `actions/reconcile-queue`. Source callback jobs use
112+
`actions/queue-completion` with `source-activity: in_progress` at start and
113+
`source-activity: completed` after all validation jobs. Restrict these jobs to
114+
same-repository dispatched `automation/package-updates-` branches and retain
115+
only their existing `actions: write` permission. Queue callbacks can omit the
116+
new input and keep their original payload.
117+
118+
The reconciler validates the producer run's repository, workflow identity,
119+
path, branch, head and attempt before using its metadata. Start notifications
120+
invalidate previous mirrored jobs and admission without waiting for builds;
121+
completion notifications wait briefly for their own producer to finish and
122+
revalidate its actual attempt. A delayed start for a completed attempt reads
123+
the completed results. Verified obsolete attempts or advanced/deleted producer
124+
branches stop without any status or queue writes; tampered identities and future
125+
attempts remain errors. An already queued source PR cannot bypass this check.
126+
Statuses never replace the required native jobs or relax branch protection.
127+
After publishing new complete queue success, reconciliation waits at most 55
128+
seconds for GitHub's asynchronous merge to expose a different live front ref.
129+
It verifies that ref and dispatches its missing validation through the existing
130+
handler once. An empty queue returns immediately without a warning. Running or
131+
failed candidates do not start this additional poll;
132+
there is no recursive recovery dispatch.
133+
108134
The actions read the default branch from GitHub's repository event metadata.
109135
Use that same default branch in the caller's callback guard. A package updater
110136
can opt in to admission with `automation-branch`; it accepts only that exact
@@ -128,8 +154,8 @@ workflow and required job passes on the exact source SHA. A blocked approval run
128154
can be ignored only when its jobs endpoint proves zero jobs. Failed, pending,
129155
skipped, missing, stale and untrusted evidence never becomes success; newer
130156
attempts invalidate older source adapter results. Actual failed required jobs
131-
receive failure statuses linking the current failed job. Normal required checks and
132-
expected-head merge-queue admission still apply. Unchanged completed runs reuse
157+
receive failure statuses linking the current failed job. Normal required checks
158+
and expected-head merge-queue admission still apply. Unchanged completed runs reuse
133159
only this bot's previously verified job attestations for the same run and attempt;
134160
latest-run metadata remains live. Immutable Git objects and workflow identity are
135161
cached only within one reconciliation. Opted-in callers should also reconcile
@@ -173,8 +199,9 @@ release. Do not provide privileged tokens to PR build steps.
173199
`actions/discover-lockfiles` emits a JSON `lockfiles` output for a workflow matrix.
174200
It requires a tracked `flake.lock` for each tracked `flake.nix` in the caller
175201
repository. Deleting only the lockfile fails discovery; deleting the entire
176-
partition removes its matrix entry. Added, renamed and deleted partitions change that inventory
177-
without edits to the workflow. Submodules own their lockfile health jobs.
202+
partition removes its matrix entry. Added, renamed and deleted partitions change
203+
that inventory without edits to the workflow. Submodules own their lockfile
204+
health jobs.
178205
Require a stable aggregate job that waits for the complete matrix and fails for
179206
any failed, cancelled or skipped matrix. Protect that aggregate instead of
180207
individual lockfile names, so adding coverage cannot be bypassed and deleting a

‎actions/queue-completion/action.yml‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Notify queue completion
22
description: Notify the trusted default-branch reconciler after manually dispatched validation.
3+
inputs:
4+
source-activity:
5+
description: Optional package-source notification phase, in_progress or completed. Requires matching reconciler dispatch inputs.
6+
default: ''
37
runs:
48
using: composite
59
steps:
@@ -9,9 +13,17 @@ runs:
913
GH_TOKEN: ${{ github.token }}
1014
GH_REPO: ${{ github.repository }}
1115
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
16+
SOURCE_ACTIVITY: ${{ inputs.source-activity }}
1217
run: |
18+
args=(-f source_run_id="$GITHUB_RUN_ID")
19+
case "$SOURCE_ACTIVITY" in
20+
'') ;;
21+
in_progress|completed)
22+
args+=(-f source_run_attempt="$GITHUB_RUN_ATTEMPT" -f source_activity="$SOURCE_ACTIVITY") ;;
23+
*) echo '::error::Invalid package-source notification phase'; exit 1 ;;
24+
esac
1325
for attempt in 1 2 3; do
14-
if gh workflow run reconcile-merge-queue.yml --ref "$DEFAULT_BRANCH" -f source_run_id="$GITHUB_RUN_ID"; then
26+
if gh workflow run reconcile-merge-queue.yml --ref "$DEFAULT_BRANCH" "${args[@]}"; then
1527
exit 0
1628
fi
1729
echo "::warning::Queue completion notification attempt $attempt failed"

‎actions/reconcile-queue/action.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ inputs:
1616
source-run-id:
1717
description: Optional dispatch completion notification.
1818
default: ''
19+
source-run-attempt:
20+
description: Producer run attempt for a package-source start or completion callback.
21+
default: ''
22+
source-activity:
23+
description: Package-source callback phase, in_progress or completed.
24+
default: ''
1925
runs:
2026
using: composite
2127
steps:
@@ -27,6 +33,8 @@ runs:
2733
BASE_SHA_WORKFLOWS: ${{ inputs.base-sha-workflows }}
2834
QUEUE_WORKFLOWS: ${{ inputs.workflows }}
2935
SOURCE_RUN_ID: ${{ inputs.source-run-id }}
36+
SOURCE_RUN_ATTEMPT: ${{ inputs.source-run-attempt }}
37+
SOURCE_NOTIFICATION_ACTIVITY: ${{ inputs.source-activity }}
3038
SOURCE_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
3139
SOURCE_ACTIVITY: ${{ github.event.action }}
3240
run: |
@@ -90,6 +98,8 @@ runs:
9098
BASE_SHA_WORKFLOWS: ${{ inputs.base-sha-workflows }}
9199
QUEUE_WORKFLOWS: ${{ inputs.workflows }}
92100
SOURCE_RUN_ID: ${{ inputs.source-run-id }}
101+
SOURCE_RUN_ATTEMPT: ${{ inputs.source-run-attempt }}
102+
SOURCE_NOTIFICATION_ACTIVITY: ${{ inputs.source-activity }}
93103
SOURCE_HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
94104
SOURCE_ACTIVITY: ${{ github.event.action }}
95105
run: python3 "$ACTION_PATH/../../scripts/reconcile-queue.py"

‎docs/releases/v2.12.0.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Nix Forge CI v2.12.0
2+
3+
## Changelog
4+
5+
- Add explicit package-source start and completion notifications using the
6+
existing repository token and narrowly scoped callback jobs. Validate actual
7+
producer identity and run attempt before deriving its source head or activity.
8+
- Invalidate all previous required source results and admission when a rerun
9+
starts. Completion waits for its producer, revalidates current attempts and
10+
preserves actual failed-job links. Verified obsolete callbacks make no writes;
11+
tampered producer metadata and future attempts remain errors.
12+
- After publishing complete queue success, wait at most 55 seconds for GitHub's
13+
asynchronous merge to expose the next verified front ref, then dispatch its
14+
missing validation once. Empty queues return quietly. Running, failed or
15+
incomplete candidates do not start this additional poll.
16+
17+
Existing queue callbacks retain their original payload. Opted-in package
18+
callers declare optional `source_run_attempt` and `source_activity` reconciler
19+
dispatch inputs and forward them to `source-run-attempt` and `source-activity`.
20+
Use `source-activity: in_progress` in a source-only start callback, then
21+
`source-activity: completed` after all source validation jobs. Retain the queue
22+
completion callback name and restrict callbacks to their approved ref namespaces.
23+
Update source branches only after the new caller workflow contract is merged.
24+
25+
No token permissions, required job gates, signing trust or release-builder pins
26+
change. Full expected-head PR and merge-group validation remains required.
27+
The 161 repository regression tests and offline workflow/security checks passed
28+
locally; required hosted validation must pass before publishing this release.
29+
Coverage includes actual callback payloads, immutable producer identity,
30+
completion races, obsolete notifications, 16-job source invalidation, request
31+
budgets and asynchronous next-candidate dispatch.
32+
33+
The source implementation was reviewed at
34+
`8cc10aa7a626997ef82bb46b6c3e91e0544869ef`. The signed tag and verified release
35+
manifest identify the protected source commit including these notes. Publication
36+
uses the separately pinned SLSA source builder and verifies archive checksums,
37+
all provenance subjects and protected-main ancestry. Restore the v2.11.0 pin and
38+
remove the optional source notification inputs to roll back. Compatible v2.x
39+
consumers have no scheduled support end date.

0 commit comments

Comments
 (0)