@juangcarmona/lighthouse-sdlc 0.22.0 → 0.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/github-actions.md
CHANGED
|
@@ -134,17 +134,19 @@ The `apply-review` worker is installed with proposal support. It also handles im
|
|
|
134
134
|
|
|
135
135
|
## Worker maintenance
|
|
136
136
|
|
|
137
|
-
Install the optional deterministic workflow with `--with-maintenance`. After reviewing its permissions, set `LIGHTHOUSE_MAINTENANCE_ENABLED=true` and the existing `LIGHTHOUSE_AUTOMATION_ENABLED=true` to observe
|
|
137
|
+
Install the optional deterministic workflow with `--with-maintenance`. After reviewing its permissions, set `LIGHTHOUSE_MAINTENANCE_ENABLED=true` and the existing `LIGHTHOUSE_AUTOMATION_ENABLED=true` to observe owner issues every 30 minutes, or dispatch a single issue manually. Native `review` completion also wakes maintenance for its authenticated before-admission rejection; unrelated or uncertain completions select no issue. Observation alone performs no retry. Set `LIGHTHOUSE_RECOVERY_ENABLED=true` separately to permit bounded recovery; removing it also stops admission of already-requested retries.
|
|
138
138
|
|
|
139
139
|
For a scoped acceptance, set `LIGHTHOUSE_MAINTENANCE_ISSUES` to a JSON array of issue numbers before enabling maintenance or recovery. `[]` selects no issues; an absent value retains the open-owner-issue scan. Invalid configuration stops admission. Preserve prior variable values and disable recovery before removing a temporary scope. Report publication remains separately configured.
|
|
140
140
|
|
|
141
|
+
A confirmed automatic final-review rejection before admission has a separate limit of one linked retry. Completion wakes the existing reconciler and retains the original worker, revisions and receipt; it reuses the original merge, CI and product apply. Changed current authority blocks recovery. Duplicate completion signals and the scheduled sweep share the same retry identity and issue lease. GitHub event delivery and schedules provide no recovery latency guarantee.
|
|
142
|
+
|
|
141
143
|
Recovery authenticates the original dispatch and its bounded chain, current source and workflow revision, owner intent, reservation and Actions job evidence. It retries only failed or timed-out refine/propose/implement/apply-review executions whose preparation passed and whose trusted publication step is positively recorded as skipped. Each retry is a new receipt and immutable request, at most two per original request, delayed at least 30 minutes after the previous execution. A newer owner request supersedes older recovery candidates. Workers retain their lifecycle gates and current authority checks.
|
|
142
144
|
|
|
143
145
|
When the current dispatched agent failed or was cancelled and the publication step is confirmed skipped, maintenance can recreate a missing terminal notice without granting a retry. It can restore a missing triage or refinement handoff when retained validated output, owner intent, source, workflow and current labels still match. If a failed publication left the original stage label in place, maintenance can complete its outcome-label transition before restoring the handoff; a competing stage or status blocks this recovery. A restored result does not imply that an interrupted automatic continuation ran; the owner requests the next stage after inspection. A missing or unverified version 3 label adoption is reported in the failure notice; the host does not create the label implicitly. Confirmed implementation publication can resume its CI request through the reconciliation below. Confirmed integration can restore its report and continuation. A confirmed blocked integration report can also restore its missing handoff while keeping the blocker and requiring separate authorization to continue. Other interrupted publications require operator inspection.
|
|
144
146
|
|
|
145
147
|
For a completed triage or refinement whose agent failed or was cancelled before publication, maintenance can release `agent-working` only when the authenticated request artifact, job results and unchanged bot label event identify that reservation. A human hold, newer dispatch, changed intent or source, missing evidence, uncertain publication, or an already published failure notice prevents cleanup. The cleanup does not authorize a retry.
|
|
146
148
|
|
|
147
|
-
Cancellation, review execution, human decisions, stale intent/source, expired artifacts, incomplete jobs, uncertain dispatch or publication, and reservations without the evidence above require operator inspection. When an authenticated triage or refinement preparation failed and both the agent and publisher were skipped, maintenance can record that failure and restore its notice without retrying. An unclaimed dispatch additionally requires exactly one matching authenticated execution. Missing or ambiguous confirmation never authorizes resend. Inspect the linked run and its actual effects before making a new owner request. Retries never clear another execution's reservation. Current receipt and Actions observations determine the decision; raw agent prose cannot grant retry authority.
|
|
149
|
+
Cancellation, admitted review execution, human decisions, stale intent/source, expired artifacts, incomplete jobs, uncertain dispatch or publication, and reservations without the evidence above require operator inspection. When an authenticated triage or refinement preparation failed and both the agent and publisher were skipped, maintenance can record that failure and restore its notice without retrying. An unclaimed dispatch additionally requires exactly one matching authenticated execution. Missing or ambiguous confirmation never authorizes resend. Inspect the linked run and its actual effects before making a new owner request. Retries never clear another execution's reservation. Current receipt and Actions observations determine the decision; raw agent prose cannot grant retry authority.
|
|
148
150
|
|
|
149
151
|
Implementation and correction workers retain `ci-requests.json` beside `published-pr.json`. CI launch records its send state before the API call. Recovery rechecks the candidate, owner intent, policy and review, then observes matching native CI runs before doing anything else. A confirmed unsent or rejected request may use the same two-retry, 30-minute limit. An unknown or acknowledged request without a matching run stops for inspection. Legacy publications without send-state evidence also stop. Recovery never reruns the agent or edits the candidate to start CI. A technical retry of a CI correction retains its original correction round and budget.
|
|
150
152
|
|
|
@@ -152,7 +154,7 @@ After a confirmed integration, maintenance can use the original authenticated re
|
|
|
152
154
|
|
|
153
155
|
A complete router rerun can remove the original dispatch artifact. Maintenance identifies the original run, attempt and expected digest and leaves an unconfirmed dispatch stopped. Restore only authenticated original bytes; otherwise use a fresh supported owner request after inspecting actual effects. Updating the default branch or npm package does not replace workflow definitions carried by an existing PR. Record the event, candidate, router, worker and harness revisions separately when qualifying an upgrade.
|
|
154
156
|
|
|
155
|
-
Maintenance bounds are 100 open owner issues, 500 scanned issue/PR entries, 1,000 comments per issue and 100 jobs per execution. Exceeding a bound fails visibly. Original dispatch artifacts retain their existing 14-day lifetime. Recovery does not outlive missing evidence.
|
|
157
|
+
Maintenance bounds are 100 open owner issues, 500 scanned issue/PR entries, 1,000 comments per issue and 100 jobs per execution. Exceeding a bound fails visibly. Original dispatch artifacts retain their existing 14-day lifetime. Recovery does not outlive missing evidence. The scheduled scan includes open owner issues and recent closed owner issues whose final-review receipt remains unresolved.
|
|
156
158
|
|
|
157
159
|
An active or queued execution without an Actions update for two hours is reported as stalled. Maintenance does not cancel it or release its reservation.
|
|
158
160
|
|
|
@@ -170,4 +172,4 @@ Reports group failures by worker and a fixed cause code. They contain source iss
|
|
|
170
172
|
|
|
171
173
|
The index prevents duplicate creation when a GitHub response is lost. A later pass links a uniquely matching bot-owned report. If creation is still unconfirmed, reporting stops for inspection instead of sending again. Disable reporting, inspect the maintenance run and search open and closed reports for that worker/cause before editing the index. Preserve a pending entry until a report can be linked or the owner has established that no creation occurred; deleting it permits a new create. Resume only after reconciling actual effects.
|
|
172
174
|
|
|
173
|
-
The reporter scans at most 500 issue/PR entries and retains at most 100 worker/cause entries and 200 distinct observations per report, within a 60 KB body. Overflow fails visibly and requires operator archival; nothing is silently evicted. Counts reflect observations made while reporting was enabled.
|
|
175
|
+
The reporter scans at most 500 issue/PR entries and retains at most 100 worker/cause entries and 200 distinct observations per report, within a 60 KB body. Overflow fails visibly and requires operator archival; nothing is silently evicted. Counts reflect observations made while reporting was enabled. Closed source issues outside the recent unresolved final-review inventory require an explicit maintenance dispatch. All report writes share one repository-wide Actions concurrency group. Existing version 1 reports migrate when next updated. CI-request failures retain allowlisted method/path, HTTP status or exception class, candidate and execution identities in the publication artifact, issue/PR handoff and job log; response bodies and credentials are excluded.
|
package/package.json
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { productModelDirectoryFromConfig } from './product-change.mjs';
|
|
2
|
+
import { readActionsJson } from './actions-artifact.mjs';
|
|
2
3
|
import { digest } from './digests.mjs';
|
|
3
4
|
import { inspectCompletion, assertChecks, postMergeRuns } from './completion-state.mjs';
|
|
4
5
|
import { deliveryAfterChecks } from './delivery-events.mjs';
|
|
@@ -19,6 +20,22 @@ async function rejectedJobs(api, { dispatch, run }) {
|
|
|
19
20
|
return jobs;
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
// Completion is a wake-up only: admission still rechecks the original grant and current authority.
|
|
24
|
+
export async function admissionCompletion(api, repository, owner, event, readArtifact = readActionsJson) {
|
|
25
|
+
const signal = event.workflow_run;
|
|
26
|
+
if (event.action !== 'completed' || signal?.repository?.full_name !== repository || !Number.isSafeInteger(signal.id) || signal.id < 1 || signal.run_attempt !== 1 || signal.status !== 'completed' || signal.conclusion !== 'failure') return null;
|
|
27
|
+
const run = await api(`actions/runs/${signal.id}/attempts/${signal.run_attempt}`);
|
|
28
|
+
if (run?.repository?.full_name !== repository || run.path !== stagePath('review') || run.event !== 'workflow_dispatch' || run.head_sha !== signal.head_sha || run.run_attempt !== signal.run_attempt || run.status !== 'completed' || run.conclusion !== 'failure') return null;
|
|
29
|
+
const match = /^review #([1-9][0-9]*) · request ([1-9][0-9]*)$/.exec(run.display_title ?? '');
|
|
30
|
+
if (!match) return null;
|
|
31
|
+
let rejection;
|
|
32
|
+
try { await loadDispatch(api, repository, owner, Number(match[1]), Number(match[2]), run, readArtifact); }
|
|
33
|
+
catch (error) { rejection = error.rejection; }
|
|
34
|
+
const request = rejection?.dispatch.request;
|
|
35
|
+
if (!request || request.recovery || request.stage !== 'review' || request.worker || request.handoff || request.completionRecovery || !isBotContinuation(request.event, rejection.parent.event, rejection.parent.actor?.login, rejection.parent.triggering_actor?.login) || !await rejectedJobs(api, rejection)) return null;
|
|
36
|
+
return { issue: Number(match[1]), runId: String(run.id), attempt: run.run_attempt, revision: run.head_sha, commentId: Number(match[2]) };
|
|
37
|
+
}
|
|
38
|
+
|
|
22
39
|
// A changed ref never admits work; only a terminal native job inventory can establish skipped effects.
|
|
23
40
|
export async function observeAdmissionRejection(api, repository, owner, rejection, issue, comments) {
|
|
24
41
|
const { dispatch, parent, run } = rejection, request = dispatch.request;
|
|
@@ -65,7 +82,7 @@ export async function reconcileAdmissionRejection(api, repository, observation)
|
|
|
65
82
|
|
|
66
83
|
export function admissionRetryRequest(observation, parent) {
|
|
67
84
|
const { request } = observation.dispatch;
|
|
68
|
-
const recovery = { kind: 'before-admission', rootId: observation.rootId, previousComment: observation.dispatch.commentId, attempt: 1 };
|
|
85
|
+
const recovery = { kind: 'before-admission', rootId: observation.rootId, previousComment: observation.dispatch.commentId, attempt: 1, ...(observation.wake ? { wake: observation.wake } : {}) };
|
|
69
86
|
const next = { ...request, id: digest(`${request.repository}:${recovery.rootId}:retry:1`), sourceRevision: observation.revision, workflowRevision: observation.revision, routerRunId: String(parent.id), routerAttempt: parent.run_attempt, routerRevision: parent.head_sha, routerRef: parent.head_branch, routerEventName: parent.event, recovery };
|
|
70
87
|
next.intent = dispatchIntent(next);
|
|
71
88
|
return next;
|
|
@@ -82,7 +99,12 @@ export async function verifyAdmissionRecovery(api, repository, owner, dispatch,
|
|
|
82
99
|
catch (error) { rejection = error.rejection; }
|
|
83
100
|
if (!rejection || rejection.dispatch.request.recovery || retry.rootId !== rejection.dispatch.request.id || run.path !== stagePath('review')) throw Error('Invalid original admission rejection');
|
|
84
101
|
if (!await rejectedJobs(api, rejection)) throw Error('Original admission rejection effects are unconfirmed');
|
|
85
|
-
|
|
102
|
+
let wake;
|
|
103
|
+
if (parent.event === 'workflow_run') {
|
|
104
|
+
wake = { issue: request.issue, runId: String(run.id), attempt: run.run_attempt, revision: run.head_sha, commentId: Number(comment.id) };
|
|
105
|
+
if (![owner, 'github-actions[bot]'].includes(parent.actor?.login) || parent.triggering_actor?.login !== parent.actor?.login || !same(retry.wake, wake)) throw Error('Invalid admission completion wake');
|
|
106
|
+
} else if (retry.wake !== undefined) throw Error('Unexpected admission completion wake');
|
|
107
|
+
const expected = admissionRetryRequest({ dispatch: rejection.dispatch, rootId: retry.rootId, revision: request.sourceRevision, wake }, parent);
|
|
86
108
|
if (!same(request, expected)) throw Error('Before-admission recovery authorization changed');
|
|
87
109
|
if (!revalidate) return;
|
|
88
110
|
const issue = await api(`issues/${request.issue}`);
|
|
@@ -90,5 +112,6 @@ export async function verifyAdmissionRecovery(api, repository, owner, dispatch,
|
|
|
90
112
|
// The current retry is allowed; any other newer dispatch supersedes the original request.
|
|
91
113
|
const originalComments = comments.filter(item => item.id !== dispatch.commentId);
|
|
92
114
|
const observation = await observeAdmissionRejection(api, repository, owner, rejection, issue, originalComments);
|
|
115
|
+
observation.wake = wake;
|
|
93
116
|
if (observation.state !== 'retryable' || !same(request, admissionRetryRequest(observation, parent))) throw Error('Before-admission recovery authority changed');
|
|
94
117
|
}
|
package/src/stage-dispatch.mjs
CHANGED
|
@@ -163,7 +163,7 @@ export function verifyDispatchOrigin(request, receipt, parent, worker, repositor
|
|
|
163
163
|
const epicRefinement = !recovery && isBotEpicRefinement(request.event, parent.event, parent.actor?.login, parent.triggering_actor?.login) && request.stage === 'refine' && !request.handoff && !request.worker && Number(request.event.inputs.issue) === issue && Number(request.event.inputs.epic_parent) === request.epic?.parent;
|
|
164
164
|
const expectedEpicKey = epicTriage ? epicTriageKey(repository, request.epic.parent, issue, request.epic.planDigest) : epicRefinement ? epicRefinementKey(repository, request.epic.parent, issue, request.epic.planDigest, request.event.inputs.epic_run) : undefined;
|
|
165
165
|
if (expectedEpicKey ? request.epicKey !== expectedEpicKey || receipt.epicKey !== expectedEpicKey : request.epicKey !== undefined || receipt.epicKey !== undefined) throw Error('Epic dispatch identity is invalid');
|
|
166
|
-
if (String(parent.id) !== String(receipt.routerRunId) || parent.run_attempt !== receipt.routerAttempt || request.routerRunId !== receipt.routerRunId || request.routerAttempt !== receipt.routerAttempt || parent.path !== originPath || (parent.event !== 'workflow_run' && !continuation && !epicTriage && !epicRefinement && (parent.actor?.login !== owner || parent.triggering_actor?.login !== owner)) || !(recovery ? ['schedule', 'workflow_dispatch'] : events).includes(parent.event) || parent.event !== originEvent || parent.head_sha !== (request.routerRevision ?? request.workflowRevision) || parent.head_branch !== (request.routerRef ?? request.ref) || parent.repository?.full_name !== repository) throw Error('Dispatch origin is not an authorized router execution');
|
|
166
|
+
if (String(parent.id) !== String(receipt.routerRunId) || parent.run_attempt !== receipt.routerAttempt || request.routerRunId !== receipt.routerRunId || request.routerAttempt !== receipt.routerAttempt || parent.path !== originPath || (parent.event !== 'workflow_run' && !continuation && !epicTriage && !epicRefinement && (parent.actor?.login !== owner || parent.triggering_actor?.login !== owner)) || !(recovery ? ['schedule', 'workflow_dispatch', ...(request.recovery.kind === 'before-admission' ? ['workflow_run'] : [])] : events).includes(parent.event) || parent.event !== originEvent || parent.head_sha !== (request.routerRevision ?? request.workflowRevision) || parent.head_branch !== (request.routerRef ?? request.ref) || parent.repository?.full_name !== repository) throw Error('Dispatch origin is not an authorized router execution');
|
|
167
167
|
if (request.client?.key !== receipt.clientKey || request.client?.payloadDigest !== receipt.clientPayloadDigest) throw Error('Client dispatch receipt binding mismatch');
|
|
168
168
|
if (request.intent !== receipt.intent || request.intent !== undefined && request.intent !== dispatchIntent(request)) throw Error('Dispatch intent binding mismatch');
|
|
169
169
|
executionModelSelection(request);
|
|
@@ -4,6 +4,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
4
4
|
import { dispatchArtifact, sendDispatch, readDispatchReceipt } from './stage-dispatch.mjs';
|
|
5
5
|
import { maintenancePath, prepareRecovery, observeRecovery, recoveryIssues } from './worker-recovery.mjs';
|
|
6
6
|
import { githubAppCiTrigger } from './github-app-ci.mjs';
|
|
7
|
+
import { admissionCompletion } from './admission-recovery.mjs';
|
|
7
8
|
import { publishReports } from './worker-reports.mjs';
|
|
8
9
|
|
|
9
10
|
export async function ownerIssues(api, owner) {
|
|
@@ -57,9 +58,11 @@ async function main(command) {
|
|
|
57
58
|
};
|
|
58
59
|
const output = async (name, value) => { if (env.GITHUB_OUTPUT) await appendFile(env.GITHUB_OUTPUT, `${name}=${value}\n`); };
|
|
59
60
|
const parent = await api(`actions/runs/${env.GITHUB_RUN_ID}/attempts/${env.GITHUB_RUN_ATTEMPT}`);
|
|
60
|
-
if (parent.path !== maintenancePath || parent.repository?.full_name !== repository || !['schedule', 'workflow_dispatch'].includes(parent.event) || parent.actor?.login
|
|
61
|
+
if (parent.path !== maintenancePath || parent.repository?.full_name !== repository || !['schedule', 'workflow_dispatch', 'workflow_run'].includes(parent.event) || ![owner, ...(parent.event === 'workflow_run' ? ['github-actions[bot]'] : [])].includes(parent.actor?.login) || parent.triggering_actor?.login !== parent.actor?.login) throw Error('Maintenance is not an authorized execution');
|
|
61
62
|
if (env.LIGHTHOUSE_MAINTENANCE_ENABLED !== 'true') throw Error('Maintenance is not enabled');
|
|
62
63
|
const scope = recoveryIssues(env.LIGHTHOUSE_MAINTENANCE_ISSUES);
|
|
64
|
+
const event = parent.event === 'workflow_run' || command === 'scan' ? JSON.parse(await readFile(env.GITHUB_EVENT_PATH, 'utf8')) : null;
|
|
65
|
+
const admissionWake = parent.event === 'workflow_run' ? await admissionCompletion(api, repository, owner, event) : null;
|
|
63
66
|
if (command === 'report') {
|
|
64
67
|
const root = join(env.RUNNER_TEMP, 'worker-observations'), observations = [], seen = [];
|
|
65
68
|
const directories = await readdir(root);
|
|
@@ -80,7 +83,11 @@ async function main(command) {
|
|
|
80
83
|
return;
|
|
81
84
|
}
|
|
82
85
|
if (command === 'scan') {
|
|
83
|
-
|
|
86
|
+
if (parent.event === 'workflow_run') {
|
|
87
|
+
const issues = admissionWake && (!scope || scope.includes(admissionWake.issue)) ? [admissionWake.issue] : [];
|
|
88
|
+
await writeFile(join(env.RUNNER_TEMP, 'maintenance-wake.json'), JSON.stringify({ schemaVersion: 1, parent: { id: parent.id, attempt: parent.run_attempt, event: parent.event, revision: parent.head_sha }, signal: { id: event.workflow_run?.id, attempt: event.workflow_run?.run_attempt, revision: event.workflow_run?.head_sha }, wake: admissionWake, issues }));
|
|
89
|
+
await output('issues', JSON.stringify(issues)); return;
|
|
90
|
+
}
|
|
84
91
|
const requested = event.inputs?.issue;
|
|
85
92
|
if (requested && !/^[1-9][0-9]*$/.test(requested)) throw Error('Issue must be a canonical positive integer');
|
|
86
93
|
if (requested && scope && !scope.includes(Number(requested))) throw Error('Issue is outside the configured maintenance scope');
|
|
@@ -89,6 +96,7 @@ async function main(command) {
|
|
|
89
96
|
}
|
|
90
97
|
const issue = Number(env.LIGHTHOUSE_ISSUE);
|
|
91
98
|
if (!Number.isSafeInteger(issue) || issue < 1) throw Error('Invalid issue');
|
|
99
|
+
if (parent.event === 'workflow_run' && admissionWake?.issue !== issue) throw Error('Completion wake differs from this issue');
|
|
92
100
|
if (scope && !scope.includes(issue)) throw Error('Issue is outside the configured maintenance scope');
|
|
93
101
|
const dir = join(env.RUNNER_TEMP, `lighthouse-maintenance-${env.GITHUB_RUN_ID}-${issue}`);
|
|
94
102
|
if (command === 'observe') {
|
|
@@ -118,7 +126,7 @@ async function main(command) {
|
|
|
118
126
|
if (command !== 'prepare') throw Error('Unknown maintenance command');
|
|
119
127
|
await mkdir(dir, { recursive: true });
|
|
120
128
|
try {
|
|
121
|
-
const result = await prepareRecovery(api, repository, owner, issue, parent, env.LIGHTHOUSE_RECOVERY_ENABLED === 'true', Date.now(), undefined, { ciTrigger: githubAppCiTrigger(env), saveCiRecovery: value => writeFile(join(dir, 'ci-recovery.json'), JSON.stringify(value)), saveCompletionRecovery: value => writeFile(join(dir, 'completion-recovery.json'), JSON.stringify(value)) });
|
|
129
|
+
const result = await prepareRecovery(api, repository, owner, issue, parent, env.LIGHTHOUSE_RECOVERY_ENABLED === 'true', Date.now(), undefined, { admissionWake, ciTrigger: githubAppCiTrigger(env), saveCiRecovery: value => writeFile(join(dir, 'ci-recovery.json'), JSON.stringify(value)), saveCompletionRecovery: value => writeFile(join(dir, 'completion-recovery.json'), JSON.stringify(value)) });
|
|
122
130
|
await writeFile(join(dir, 'observations.json'), JSON.stringify(result.observations));
|
|
123
131
|
if (env.GITHUB_STEP_SUMMARY) await appendFile(env.GITHUB_STEP_SUMMARY, result.observations.map(o => `- Issue #${o.issue}, ${o.worker}: ${o.state}. ${o.nextAction}`).join('\n') + '\n');
|
|
124
132
|
await output('send', String(!!result.request));
|
package/src/worker-recovery.mjs
CHANGED
|
@@ -318,9 +318,10 @@ export async function verifyRecoveryOrigin(api, repository, owner, dispatch, par
|
|
|
318
318
|
if (decision.state !== 'retryable') throw Error(`Recovery no longer authorized: ${decision.code}`);
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
export async function prepareRecovery(api, repository, owner, issueNumber, parent, enabled, now = Date.now(), readArtifact = readActionsJson, { saveCiRecovery, saveCompletionRecovery, ciTrigger = null } = {}) {
|
|
321
|
+
export async function prepareRecovery(api, repository, owner, issueNumber, parent, enabled, now = Date.now(), readArtifact = readActionsJson, { saveCiRecovery, saveCompletionRecovery, ciTrigger = null, admissionWake } = {}) {
|
|
322
|
+
if (parent.event === 'workflow_run' && admissionWake?.issue !== issueNumber) return { observations: [] };
|
|
322
323
|
const issue = await api(`issues/${issueNumber}`), comments = await issueComments(api, issueNumber);
|
|
323
|
-
await reconcileUnattendedStop(api, repository, owner, issue, comments);
|
|
324
|
+
if (parent.event !== 'workflow_run') await reconcileUnattendedStop(api, repository, owner, issue, comments);
|
|
324
325
|
const entries = comments.filter(c => c.user?.login === 'github-actions[bot]' && c.body.includes('<!-- lighthouse-dispatch:')).map(comment => ({ comment, receipt: readDispatchReceipt(comment, repository, issueNumber) }));
|
|
325
326
|
const unattended = comments.filter(c => c.user?.login === 'github-actions[bot]' && c.user.type === 'Bot' && c.body?.includes('<!-- lighthouse-unattended:')).at(-1);
|
|
326
327
|
if (unattended && (!entries.length || unattended.id > entries.at(-1).comment.id)) return { observations: [] };
|
|
@@ -331,6 +332,7 @@ export async function prepareRecovery(api, repository, owner, issueNumber, paren
|
|
|
331
332
|
for (const { comment } of latest.values()) {
|
|
332
333
|
const observation = await observeDispatch(api, repository, owner, comment, issue, comments, now, readArtifact);
|
|
333
334
|
const { dispatch, stop, run, jobs, revision, workflowRevision, ...publicObservation } = observation;
|
|
335
|
+
if (parent.event === 'workflow_run' && (!observation.admissionRejected || admissionWake.runId !== String(run.id) || admissionWake.attempt !== run.run_attempt || admissionWake.revision !== run.head_sha || admissionWake.commentId !== comment.id)) continue;
|
|
334
336
|
if (observation.admissionRejected) {
|
|
335
337
|
const { admissionRejected, confirmed, ...visible } = publicObservation;
|
|
336
338
|
observations.push(visible);
|
|
@@ -340,7 +342,7 @@ export async function prepareRecovery(api, repository, owner, issueNumber, paren
|
|
|
340
342
|
const freshIssue = await api(`issues/${issueNumber}`), freshComments = await issueComments(api, issueNumber);
|
|
341
343
|
const fresh = await observeDispatch(api, repository, owner, await api(`issues/comments/${comment.id}`), freshIssue, freshComments, now, readArtifact);
|
|
342
344
|
if (fresh.state !== 'retryable') continue;
|
|
343
|
-
const request = admissionRetryRequest(fresh, parent);
|
|
345
|
+
const request = admissionRetryRequest({ ...fresh, ...(parent.event === 'workflow_run' ? { wake: admissionWake } : {}) }, parent);
|
|
344
346
|
const recorded = await recordDispatch(api, repository, request);
|
|
345
347
|
return { observations, ...(recorded.send ? { request, commentId: recorded.comment.id } : {}) };
|
|
346
348
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
name: Lighthouse worker maintenance
|
|
2
2
|
on:
|
|
3
|
+
workflow_run:
|
|
4
|
+
workflows: [review]
|
|
5
|
+
types: [completed]
|
|
3
6
|
schedule:
|
|
4
7
|
- cron: '17,47 * * * *'
|
|
5
8
|
workflow_dispatch:
|
|
@@ -16,7 +19,7 @@ env:
|
|
|
16
19
|
LIGHTHOUSE_MAINTENANCE_ISSUES: ${{ vars.LIGHTHOUSE_MAINTENANCE_ISSUES }}
|
|
17
20
|
jobs:
|
|
18
21
|
scan:
|
|
19
|
-
if: vars.LIGHTHOUSE_AUTOMATION_ENABLED == 'true' && vars.LIGHTHOUSE_MAINTENANCE_ENABLED == 'true' && github.actor == github.repository_owner
|
|
22
|
+
if: vars.LIGHTHOUSE_AUTOMATION_ENABLED == 'true' && vars.LIGHTHOUSE_MAINTENANCE_ENABLED == 'true' && (github.actor == github.repository_owner || (github.event_name == 'workflow_run' && github.actor == 'github-actions[bot]'))
|
|
20
23
|
runs-on: ubuntu-24.04
|
|
21
24
|
permissions:
|
|
22
25
|
contents: read
|
|
@@ -37,6 +40,14 @@ jobs:
|
|
|
37
40
|
env:
|
|
38
41
|
GH_TOKEN: ${{ github.token }}
|
|
39
42
|
run: node src/packages/sdlc/src/worker-maintenance.mjs scan
|
|
43
|
+
- name: Preserve completion wake
|
|
44
|
+
if: always() && github.event_name == 'workflow_run'
|
|
45
|
+
uses: actions/upload-artifact@v7
|
|
46
|
+
with:
|
|
47
|
+
name: lighthouse-maintenance-wake-${{ github.run_attempt }}
|
|
48
|
+
path: ${{ runner.temp }}/maintenance-wake.json
|
|
49
|
+
if-no-files-found: error
|
|
50
|
+
retention-days: 14
|
|
40
51
|
- name: Observe workflow telemetry
|
|
41
52
|
if: always()
|
|
42
53
|
continue-on-error: true
|