@juangcarmona/lighthouse-sdlc 0.22.3 → 0.22.5
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/README.md +2 -0
- package/github-actions.md +2 -0
- package/package.json +1 -1
- package/src/implementation-plan.mjs +60 -2
- package/src/worker-recovery.mjs +17 -1
- package/src/worker-reports.mjs +1 -0
package/README.md
CHANGED
|
@@ -27,6 +27,8 @@ These actions require installed workers, enabled automation and the repository o
|
|
|
27
27
|
|
|
28
28
|
For direct implementation, the host scaffolds OpenSpec metadata before the agent starts. The agent preserves those fields and declares `skip_specs: true` only for a plan without specification changes. Before independent checks, the host materializes the final metadata while preserving existing provider bytes and completed implementation tasks.
|
|
29
29
|
|
|
30
|
+
When the admitted source already contains one completed, issue-bound archived implementation plan, the host validates its provider metadata, planning artifacts and task completion without recreating an active change. Incomplete evidence, multiple matching archives, active/archive conflicts or candidate rewrites stop requalification with a repair reason. The archive is planning evidence, not a completion receipt: independent checks, required review, forge checks and the original correction/deadline limits still apply. Adopters need the released SDLC correction and an updated workflow source/package-mode installation before retrying a real candidate; a source fix alone does not establish installed adoption.
|
|
31
|
+
|
|
30
32
|
An owner correction can revalidate an existing implementation PR without editing source. The host runs independent checks, rechecks the current head, intent, policy and feedback, and publishes fresh completion evidence for that same head. Initial implementations still require source changes; failed checks and pending decisions remain blockers.
|
|
31
33
|
|
|
32
34
|
When GitHub retains a test merge against an older base, a successful correction can publish a verification commit with the exact checked tree. The host waits for GitHub to recompute the merge subject and requests its normal CI. Integration requires approval of the resulting head; source files and the completed product apply remain unchanged.
|
package/github-actions.md
CHANGED
|
@@ -140,6 +140,8 @@ For a scoped acceptance, set `LIGHTHOUSE_MAINTENANCE_ISSUES` to a JSON array of
|
|
|
140
140
|
|
|
141
141
|
A confirmed automatic final-review rejection before admission has a separate limit of one linked retry. The trusted callback uses `workflow_dispatch` with the native worker ID, so recovery does not depend on delivery of a separate completion event. Both completion signals retain 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
142
|
|
|
143
|
+
When an authenticated worker's workflow ref no longer resolves, maintenance confirms its absence from GitHub branch and tag inventories and retains a `workflow-ref-missing` blocker with the original request and run. Historical provenance remains valid; no retry, handoff restoration or automatic ref recreation follows. Other observation entries continue. Permission failures, unavailable inventories and ambiguous lookups remain errors rather than proof of deletion.
|
|
144
|
+
|
|
143
145
|
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.
|
|
144
146
|
|
|
145
147
|
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.
|
package/package.json
CHANGED
|
@@ -1,9 +1,54 @@
|
|
|
1
|
-
import { mkdtemp, readFile, rm } from 'node:fs/promises';
|
|
2
|
-
import { join } from 'node:path';
|
|
1
|
+
import { mkdtemp, mkdir, readFile, writeFile, rm } from 'node:fs/promises';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
3
|
import { tmpdir } from 'node:os';
|
|
4
4
|
import { proposalRoot, changeName } from './proposal-files.mjs';
|
|
5
5
|
import { openSpec } from './openspec-provider.mjs';
|
|
6
6
|
|
|
7
|
+
function archivedPlanRoot(source, issue) {
|
|
8
|
+
const name = changeName(issue), prefix = 'openspec/changes/archive/';
|
|
9
|
+
const matches = new Set();
|
|
10
|
+
for (const path of source.keys()) {
|
|
11
|
+
if (!path.startsWith(prefix)) continue;
|
|
12
|
+
const directory = path.slice(prefix.length).split('/')[0];
|
|
13
|
+
if (directory === name || new RegExp(`^\\d{4}-\\d{2}-\\d{2}-${name}$`).test(directory)) matches.add(`${prefix}${directory}`);
|
|
14
|
+
}
|
|
15
|
+
if (matches.size > 1) throw Error(`Ambiguous archived implementation plan for issue #${issue}: ${[...matches].join(', ')}; reconcile the archives before requalification`);
|
|
16
|
+
const archived = [...matches][0];
|
|
17
|
+
if (archived && [...source.keys()].some(path => path.startsWith(`${proposalRoot(issue)}/`))) throw Error(`Conflicting active and archived implementation plans for issue #${issue}; reconcile them before requalification`);
|
|
18
|
+
return archived;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
async function validateArchivedPlan(source, archived, issue, provider, signal) {
|
|
22
|
+
for (const name of ['.openspec.yaml', 'proposal.md', 'design.md', 'tasks.md']) {
|
|
23
|
+
const file = source.get(`${archived}/${name}`);
|
|
24
|
+
if (!file?.content?.toString('utf8').trim()) throw Error(`Archived implementation plan ${archived} is missing ${name}; restore the complete provider-owned plan before requalification`);
|
|
25
|
+
}
|
|
26
|
+
signal?.throwIfAborted();
|
|
27
|
+
const directory = await mkdtemp(join(tmpdir(), 'lighthouse-archived-plan-'));
|
|
28
|
+
try {
|
|
29
|
+
// Resolve the archive under its original identity only in the disposable
|
|
30
|
+
// provider workspace. Never scaffold or rewrite the admitted candidate.
|
|
31
|
+
for (const [path, file] of source) {
|
|
32
|
+
const plan = path.startsWith(`${archived}/`);
|
|
33
|
+
if (!plan && path !== 'openspec/config.yaml' && !path.startsWith('openspec/specs/') && !path.startsWith('openspec/schemas/')) continue;
|
|
34
|
+
if (path.includes('\\') || path.split('/').some(part => !part || part === '.' || part === '..') || !['100644', '100755'].includes(file.mode) || !Buffer.isBuffer(file.content)) throw Error(`Invalid archived OpenSpec source member: ${path}`);
|
|
35
|
+
const target = join(directory, plan ? `${proposalRoot(issue)}/${path.slice(archived.length + 1)}` : path);
|
|
36
|
+
await mkdir(dirname(target), { recursive: true }); await writeFile(target, file.content);
|
|
37
|
+
}
|
|
38
|
+
const name = changeName(issue), options = { signal };
|
|
39
|
+
const validation = JSON.parse(await provider(directory, ['validate', name, '--strict', '--no-interactive', '--json'], options));
|
|
40
|
+
if (validation.items?.length !== 1 || validation.items[0].id !== name || validation.items[0].type !== 'change' || validation.items[0].valid !== true || validation.summary?.totals?.failed !== 0) throw Error('strict provider validation did not pass for the issue-bound plan');
|
|
41
|
+
const status = JSON.parse(await provider(directory, ['status', '--change', name, '--json'], options));
|
|
42
|
+
if (status.changeName !== name || status.schemaName !== 'spec-driven' || status.isPlanningComplete !== true) throw Error('provider planning artifacts are incomplete or use an unexpected schema');
|
|
43
|
+
const apply = JSON.parse(await provider(directory, ['instructions', 'apply', '--change', name, '--json'], options));
|
|
44
|
+
if (apply.changeName !== name || apply.state !== 'all_done' || !Number.isSafeInteger(apply.progress?.total) || apply.progress.total < 1 || apply.progress.complete !== apply.progress.total || apply.progress.remaining !== 0) throw Error('provider reports incomplete or missing implementation tasks');
|
|
45
|
+
signal?.throwIfAborted();
|
|
46
|
+
} catch (error) {
|
|
47
|
+
if (signal?.aborted) throw error;
|
|
48
|
+
throw Error(`Archived implementation plan ${archived} cannot be requalified: ${error.message}; repair the archived evidence through its owning provider before retrying`, { cause: error });
|
|
49
|
+
} finally { await rm(directory, { recursive: true, force: true }); }
|
|
50
|
+
}
|
|
51
|
+
|
|
7
52
|
async function scaffoldMetadata(issue, provider, signal) {
|
|
8
53
|
const directory = await mkdtemp(join(tmpdir(), 'lighthouse-implementation-plan-'));
|
|
9
54
|
try {
|
|
@@ -16,6 +61,8 @@ export async function prepareImplementationPlanMetadata(source, request, provide
|
|
|
16
61
|
if (!request.implementation?.proposal) return null;
|
|
17
62
|
const root = proposalRoot(request.issue);
|
|
18
63
|
if (request.implementation.proposal.root !== root) throw Error('Invalid implementation proposal root');
|
|
64
|
+
const archived = archivedPlanRoot(source, request.issue);
|
|
65
|
+
if (archived) { await validateArchivedPlan(source, archived, request.issue, provider, signal); return null; }
|
|
19
66
|
const path = `${root}/.openspec.yaml`, current = source.get(path);
|
|
20
67
|
if (current && current.content.toString('utf8').trim() !== 'skip_specs: true') return null;
|
|
21
68
|
signal?.throwIfAborted();
|
|
@@ -29,6 +76,17 @@ export async function implementationPlanMetadata(candidate, baseline, request, p
|
|
|
29
76
|
if (!request.implementation?.proposal) return null;
|
|
30
77
|
const root = proposalRoot(request.issue);
|
|
31
78
|
if (request.implementation.proposal.root !== root) throw Error('Invalid implementation proposal root');
|
|
79
|
+
const archived = archivedPlanRoot(baseline, request.issue), currentArchive = archivedPlanRoot(candidate, request.issue);
|
|
80
|
+
if (archived || currentArchive) {
|
|
81
|
+
if (archived !== currentArchive) throw Error('Implementation cannot replace or remove the source-bound archived plan');
|
|
82
|
+
const paths = new Set([...baseline.keys(), ...candidate.keys()].filter(path => path.startsWith(`${archived}/`)));
|
|
83
|
+
for (const path of paths) {
|
|
84
|
+
const before = baseline.get(path), after = candidate.get(path);
|
|
85
|
+
if (!before || !after || before.mode !== after.mode || !before.content.equals(after.content)) throw Error(`Implementation cannot rewrite provider-owned archived plan: ${path}`);
|
|
86
|
+
}
|
|
87
|
+
await validateArchivedPlan(candidate, archived, request.issue, provider, signal);
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
32
90
|
if (!['proposal.md', 'design.md', 'tasks.md'].every(name => candidate.has(`${root}/${name}`))) return null;
|
|
33
91
|
const path = `${root}/.openspec.yaml`, current = candidate.get(path), previous = baseline.get(path);
|
|
34
92
|
const skip = file => file?.content.toString('utf8').trim() === 'skip_specs: true';
|
package/src/worker-recovery.mjs
CHANGED
|
@@ -97,6 +97,17 @@ export function recoveryDecision({ request, receipt, run, jobs, issue, comments,
|
|
|
97
97
|
return result('retryable', 'worker-technical-failure', 'Record one linked retry under the adopted policy.', { retryAt });
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
+
async function workflowRefMissing(api, ref, error) {
|
|
101
|
+
if (![404, 422].includes(error.status)) return false;
|
|
102
|
+
// A lookup failure alone cannot prove absence; require successful, bounded inventories.
|
|
103
|
+
for (const kind of ['heads', 'tags']) {
|
|
104
|
+
const prefix = `refs/${kind}/${ref}`;
|
|
105
|
+
const refs = await api(`git/matching-refs/${kind}/${encodeURIComponent(ref)}?per_page=100`);
|
|
106
|
+
if (!Array.isArray(refs) || refs.length >= 100 || refs.some(item => typeof item?.ref !== 'string' || !item.ref.startsWith(prefix) || item.ref === prefix)) return false;
|
|
107
|
+
}
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
|
|
100
111
|
export async function observeDispatch(api, repository, owner, comment, issue, comments, now = Date.now(), readArtifact = readActionsJson) {
|
|
101
112
|
const receipt = readDispatchReceipt(comment, repository, issue.number);
|
|
102
113
|
const missingOrigin = () => ({ issue: issue.number, worker: workerFor(receipt), outcome: 'unknown', rootId: receipt.recovery?.rootId ?? receipt.id, attempt: receipt.recovery?.attempt ?? 0, state: 'uncertain', code: 'dispatch-origin-unavailable', nextAction: `Inspect original router https://github.com/${repository}/actions/runs/${receipt.routerRunId}/attempts/${receipt.routerAttempt} and request digest ${receipt.digest}. Restore only retained authenticated bytes with that digest and origin; otherwise preserve the candidate and reconcile effects before a new owner request. Never resend the unconfirmed dispatch.` });
|
|
@@ -119,8 +130,13 @@ export async function observeDispatch(api, repository, owner, comment, issue, co
|
|
|
119
130
|
if (!Array.isArray(jobs.jobs) || !Number.isSafeInteger(jobs.total_count) || jobs.total_count !== jobs.jobs.length || jobs.total_count > 100) throw Error('Execution job inventory is incomplete or exceeds recovery bounds');
|
|
120
131
|
const repo = await api('');
|
|
121
132
|
const revision = (await api(`commits/${encodeURIComponent(repo.default_branch)}`)).sha;
|
|
122
|
-
const workflowRevision = (await api(`commits/${encodeURIComponent(dispatch.request.ref)}`)).sha;
|
|
123
133
|
const execution = workerExecutionObservation({ run, jobs: jobs.jobs, receipt, worker: workerFor(dispatch.request) });
|
|
134
|
+
let workflowRevision;
|
|
135
|
+
try { workflowRevision = (await api(`commits/${encodeURIComponent(dispatch.request.ref)}`)).sha; }
|
|
136
|
+
catch (error) {
|
|
137
|
+
if (!await workflowRefMissing(api, dispatch.request.ref, error)) throw error;
|
|
138
|
+
return { ...identity({ request: dispatch.request, run }), outcome: execution.outcome, state: 'blocked', code: 'workflow-ref-missing', workflowRef: dispatch.request.ref, expectedWorkflowRevision: dispatch.request.workflowRevision, requestDigest: receipt.digest, requestCommentId: comment.id, refLookupStatus: error.status, nextAction: `Maintainer: reconcile the retained execution https://github.com/${repository}/actions/runs/${run.id} and select an existing workflow ref under a fresh owner request. Historical provenance remains authenticated; never resend this request or recreate its ref automatically.` };
|
|
139
|
+
}
|
|
124
140
|
const observation = workerFor(dispatch.request) === 'apply-product-change'
|
|
125
141
|
? ['completed', 'waiting', 'blocked'].includes(receipt.status) ? null : productApplyObservation({ prepare: jobs.jobs.find(job => job.name === 'Recheck product approval')?.conclusion, apply: jobs.jobs.find(job => job.name === 'Apply with the pinned ProductShape provider')?.conclusion, publish: jobs.jobs.find(job => job.name === 'Recheck and publish provider output')?.conclusion })
|
|
126
142
|
: execution.observation;
|
package/src/worker-reports.mjs
CHANGED
|
@@ -7,6 +7,7 @@ export const causes = Object.freeze({
|
|
|
7
7
|
'dispatch-unconfirmed': ['Dispatch confirmation is missing', 'Reconcile the recorded request with Actions before requesting more work.'],
|
|
8
8
|
'execution-rerun': ['Execution was rerun outside recovery', 'Inspect all attempts and the original claim.'],
|
|
9
9
|
'authority-changed': ['Source or owner intent changed', 'Request fresh work against the current source and intent.'],
|
|
10
|
+
'workflow-ref-missing': ['Workflow reference no longer exists', 'Maintainer: reconcile the original execution and select an existing workflow ref under a fresh owner request; never resend or recreate its ref automatically.'],
|
|
10
11
|
'manual-recovery': ['Outcome requires operator recovery', 'Inspect actual effects and make a new owner decision.'],
|
|
11
12
|
'publication-uncertain': ['Publication effects are uncertain', 'Inspect the PR, issue and publication job before another request.'],
|
|
12
13
|
'execution-time-unknown': ['Execution timestamp is unavailable', 'Inspect the Actions execution timestamps.'],
|