@juangcarmona/lighthouse-sdlc 0.26.0 → 0.27.0
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 +4 -0
- package/commands/delivery-acceptance.md +5 -0
- package/contract.json +1 -1
- package/delivery-acceptance.md +64 -0
- package/package.json +5 -3
- package/src/delivery-acceptance-cli.mjs +25 -0
- package/src/delivery-acceptance.mjs +191 -0
- package/src/install-workflows.mjs +2 -1
- package/src/sdlc.mjs +6 -3
- package/workflows/lighthouse-delivery-acceptance.yml +38 -0
package/README.md
CHANGED
|
@@ -14,6 +14,10 @@ The policy includes reviewed immutable [source pins](skills/audience-guidance/so
|
|
|
14
14
|
|
|
15
15
|
When repository instructions explicitly authorize it, the [code and architecture fallback](skills/audience-guidance/SKILL.md#code-and-architecture-review) lets an isolated worker complete its required review without a missing global helper. Record the fallback method, reviewed source, findings and missing evidence. Packaging that guidance does not prove a native worker used it or change any approval gate.
|
|
16
16
|
|
|
17
|
+
## Delivery acceptance
|
|
18
|
+
|
|
19
|
+
Use the optional [owner delivery-decision producer and source verifier](delivery-acceptance.md) to record acceptance of an exact candidate. It requires separate adoption and a new explicit owner decision.
|
|
20
|
+
|
|
17
21
|
## GitHub Actions
|
|
18
22
|
|
|
19
23
|
These actions require installed workers, enabled automation and the repository owner as actor. Opening an issue alone starts no agent. Every result links to its execution; an Actions success can contain a blocked assessment.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Delivery acceptance
|
|
2
|
+
|
|
3
|
+
Read the [source and adoption contract](../delivery-acceptance.md). Prepare the exact binding with `lighthouse-sdlc delivery-acceptance prepare`; the repository owner authors the resulting decision comment. Record it through the adopted non-agent workflow, then run `verify` with independently readable sources and all retained receipts for that binding.
|
|
4
|
+
|
|
5
|
+
Report the observed status and source limitations. Product approval, engineering results and lifecycle events retain their existing meanings. Acceptance grants no mutation authority. An undeclared route, expired source or incomplete correction history is unavailable; a healthy route without a decision is pending.
|
package/contract.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
{ "name": "integrate", "skill": "skills/integrate/SKILL.md", "command": "commands/integrate.md", "gate": "done" },
|
|
11
11
|
{ "name": "review", "skill": "skills/review/SKILL.md", "command": "commands/review.md", "gate": null }
|
|
12
12
|
],
|
|
13
|
-
"utilities": ["status", "aliases", "route", "state", "stage-result", "control-plane", "memory", "launch", "decompose", "stacked", "browser-e2e", "evidence", "github-triage", "github-decompose", "reconcile-labels", "github-labels", "practices"],
|
|
13
|
+
"utilities": ["status", "aliases", "route", "state", "stage-result", "control-plane", "memory", "launch", "decompose", "stacked", "browser-e2e", "evidence", "github-triage", "github-decompose", "reconcile-labels", "github-labels", "practices", "delivery-acceptance"],
|
|
14
14
|
"routes": ["supervised", "plan-only", "unattended", "hotfix", "stacked"],
|
|
15
15
|
"metaCommands": ["ff", "hotfix", "decompose", "stacked"],
|
|
16
16
|
"gates": ["triaged", "ready", "planned", "done"],
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Delivery acceptance
|
|
2
|
+
|
|
3
|
+
The `repository-owner` route records a new owner decision about an exact PR candidate. `prepare` reads sources and prints a comment for the owner to review and post. The non-agent producer authenticates that comment and retains `receipt.json` in its Actions artifact. `verify` independently reads GitHub sources, the adopted workflow and its retained artifact. All three operations use read-only GitHub permissions. Artifact retention is 90 days; deletion or expiry makes current verification unavailable.
|
|
4
|
+
|
|
5
|
+
## Adopt the producer
|
|
6
|
+
|
|
7
|
+
Install workflows with `--with-delivery-acceptance` and an immutable Lighthouse source revision or an exact published package containing this feature. Review `.github/workflows/lighthouse-delivery-acceptance.yml`, then commit an explicit `.lighthouse/delivery-acceptance.json` policy:
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"schemaVersion": 1,
|
|
12
|
+
"enabled": true,
|
|
13
|
+
"route": "repository-owner",
|
|
14
|
+
"repositoryId": 123,
|
|
15
|
+
"ownerId": 456,
|
|
16
|
+
"producer": {
|
|
17
|
+
"workflow": ".github/workflows/lighthouse-delivery-acceptance.yml",
|
|
18
|
+
"workflowBlob": "REPLACE_WITH_REVIEWED_GIT_BLOB_SHA",
|
|
19
|
+
"operator": "repository-owner"
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Use GitHub's numeric repository and owner IDs. Obtain the reviewed workflow blob with `git hash-object .github/workflows/lighthouse-delivery-acceptance.yml`. The policy and workflow must be on the default branch, with the workflow active. Changing either requires reviewed adoption and a fresh decision bound to the new policy. The adopting repository owner operates the producer and retains its source permissions: Contents/read, Issues/read, Pull requests/read and Actions/read. Receipt upload uses Actions' native artifact credentials; the job has no repository write permission. Personal repositories are supported first; organization, delegated and artifact-candidate routes remain unavailable.
|
|
25
|
+
|
|
26
|
+
## Prepare and record a decision
|
|
27
|
+
|
|
28
|
+
Create `candidate.json` with the issue and PR numbers, the full policy commit SHA and immutable text files defining the scope and criteria:
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"issue": 12,
|
|
33
|
+
"pullRequest": 34,
|
|
34
|
+
"policyRevision": "FULL_40_CHARACTER_COMMIT_SHA",
|
|
35
|
+
"scope": { "path": "openspec/changes/example/proposal.md", "revision": "FULL_40_CHARACTER_COMMIT_SHA" },
|
|
36
|
+
"criteria": { "path": "openspec/changes/example/tasks.md", "revision": "FULL_40_CHARACTER_COMMIT_SHA" }
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
lighthouse-sdlc delivery-acceptance prepare --repo owner/repo --input candidate.json --output prepared.json
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Review the complete `binding` and comment. The owner posts a new comment on that issue with the prepared marker and JSON, supplies a specific reason and chooses `accepted` or `rejected`. Preparing a comment creates no decision. Product approval, merge authorization and delivery acceptance remain separate decisions.
|
|
45
|
+
|
|
46
|
+
Dispatch **Lighthouse delivery acceptance** with that numeric comment ID. Only owner dispatches and owner reruns can produce receipts. Download the resulting `receipt.json`. Keep the original bytes and source URLs; a digest or producer name by itself proves no authority.
|
|
47
|
+
|
|
48
|
+
To withdraw a decision, post a new comment with the same binding, outcome `revoked`, a reason and `corrects` containing the original logical ID (`github:REPOSITORY_ID:issue-comment:COMMENT_ID`). `superseded` also requires a `replacement` decision ID. A replacement is verified separately against its own candidate. A new accepted or rejected decision after an earlier decision must explicitly correct it. Sources are immutable: editing or deleting a source makes verification unavailable. Producer retries retain the same logical decision ID and separate run attempts; they never add accepted deliveries.
|
|
49
|
+
|
|
50
|
+
## Verify independently
|
|
51
|
+
|
|
52
|
+
Create a JSON input containing the prepared `binding` and an array of all retained `receipts` for that binding, then run:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
lighthouse-sdlc delivery-acceptance verify --repo owner/repo --input verification.json --output verified.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The verifier reports `accepted`, `rejected`, `revoked`, `superseded`, `pending` or `unavailable`, with observation time, history coverage and source links. A healthy adopted route without a decision is pending. Missing adoption, inaccessible or edited sources, stale candidates, missing receipts, expired artifacts, wrong actors or conflicting history are unavailable and name the repository owner as recovery owner. The verifier enumerates retained producer artifacts independently, including decisions whose source comments were later deleted. Supply every retained receipt for the requested binding. History is bounded to 1,000 issue comments, 1,000 producer runs and 100 input receipts. Expired producer history makes current verification unavailable, including when that history might contain an omitted correction. Verification cannot establish unobserved future revocations. A historical source remains historical when the PR head changes.
|
|
59
|
+
|
|
60
|
+
Receipts contain schema version, stable source-derived decision ID, route, exact binding, retained source bytes and digest, authenticated actor, creation/update time, and producer run/attempt/revision/workflow blob. Identity comparisons use numeric provider IDs and full Git hashes; locators aid navigation. Scope, criteria and policy retain Git blob and SHA-256 identities. JSON object keys are canonically sorted for binding comparison. Unsupported versions fail closed. The SDK exports `prepareAcceptance`, `produceAcceptance` and `verifyAcceptance` from `@juangcarmona/lighthouse-sdlc/delivery-acceptance`; supplying fixture observations to tests does not establish live authenticity.
|
|
61
|
+
|
|
62
|
+
## Consumer handoff
|
|
63
|
+
|
|
64
|
+
Consumers must retain the source records and report current verification separately from execution, integration, release, deployment and closure. The producer's accountable owner is the adopting repository owner. No real delivery acceptance is asserted by shipping this contract. Until adoption and an independently verifiable owner source exist, consumer acceptance is explicitly unavailable; this is the handoff contract for consumers awaiting their first qualifying example. A verified acceptance authorizes no lifecycle mutation.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@juangcarmona/lighthouse-sdlc",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Provider-neutral SDLC skills, commands and route contracts for Lighthouse adopters",
|
|
6
6
|
"repository": {
|
|
@@ -48,7 +48,8 @@
|
|
|
48
48
|
"NOTICE",
|
|
49
49
|
"telemetry.md",
|
|
50
50
|
"issue-control.md",
|
|
51
|
-
"practice-evidence.md"
|
|
51
|
+
"practice-evidence.md",
|
|
52
|
+
"delivery-acceptance.md"
|
|
52
53
|
],
|
|
53
54
|
"bin": {
|
|
54
55
|
"lighthouse-sdlc": "./src/sdlc.mjs"
|
|
@@ -108,7 +109,8 @@
|
|
|
108
109
|
"./practice-observation": "./src/practice-observation.mjs",
|
|
109
110
|
"./practice-evaluator": "./src/practice-evaluator.mjs",
|
|
110
111
|
"./practice-github": "./src/practice-github.mjs",
|
|
111
|
-
"./practice-history": "./src/practice-history.mjs"
|
|
112
|
+
"./practice-history": "./src/practice-history.mjs",
|
|
113
|
+
"./delivery-acceptance": "./src/delivery-acceptance.mjs"
|
|
112
114
|
},
|
|
113
115
|
"license": "Apache-2.0"
|
|
114
116
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { createIssueApi } from './github-rest.mjs';
|
|
3
|
+
import { prepareAcceptance, produceAcceptance, verifyAcceptance } from './delivery-acceptance.mjs';
|
|
4
|
+
|
|
5
|
+
export async function acceptanceCli(args, env = process.env) {
|
|
6
|
+
const operation = args[0], option = name => args[args.indexOf(name) + 1];
|
|
7
|
+
const repository = args.includes('--repo') ? option('--repo') : env.GITHUB_REPOSITORY;
|
|
8
|
+
if (!['prepare', 'produce', 'verify'].includes(operation) || !/^[\w.-]+\/[\w.-]+$/.test(repository ?? '') || !env.GH_TOKEN) throw Error('Usage: lighthouse-sdlc delivery-acceptance <prepare|produce|verify> --repo owner/name --input file [--output file]; requires GH_TOKEN with read-only source permissions');
|
|
9
|
+
const api = createIssueApi(repository, env);
|
|
10
|
+
let result;
|
|
11
|
+
if (operation === 'produce') {
|
|
12
|
+
result = await produceAcceptance(api, repository, Number(env.LIGHTHOUSE_DECISION_COMMENT), { runId: Number(env.GITHUB_RUN_ID), attempt: Number(env.GITHUB_RUN_ATTEMPT), revision: env.GITHUB_SHA });
|
|
13
|
+
} else {
|
|
14
|
+
if (!args.includes('--input')) throw Error('A bounded input JSON file is required');
|
|
15
|
+
const bytes = await readFile(option('--input'));
|
|
16
|
+
if (bytes.length > 1024 * 1024) throw Error('Acceptance input exceeds 1 MiB');
|
|
17
|
+
const input = JSON.parse(bytes);
|
|
18
|
+
result = operation === 'prepare' ? await prepareAcceptance(api, repository, input) : await verifyAcceptance(api, repository, input);
|
|
19
|
+
}
|
|
20
|
+
const text = JSON.stringify(result, null, 2) + '\n';
|
|
21
|
+
if (args.includes('--output')) await writeFile(option('--output'), text, { flag: 'wx', mode: 0o600 });
|
|
22
|
+
else process.stdout.write(text);
|
|
23
|
+
if (operation === 'verify' && result.status === 'unavailable') process.exitCode = 1;
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { validatePublishable } from './process-publication.mjs';
|
|
3
|
+
import { readActionsJson } from './actions-artifact.mjs';
|
|
4
|
+
|
|
5
|
+
const sha = value => createHash('sha256').update(value).digest('hex');
|
|
6
|
+
export const canonical = value => JSON.stringify(value, (_key, item) => item && typeof item === 'object' && !Array.isArray(item) ? Object.fromEntries(Object.keys(item).sort().map(key => [key, item[key]])) : item);
|
|
7
|
+
export const acceptanceDigest = value => sha(canonical(value));
|
|
8
|
+
const revision = value => /^[a-f0-9]{40}$/.test(value ?? '');
|
|
9
|
+
const positive = value => Number.isSafeInteger(value) && value > 0;
|
|
10
|
+
function parseJson(text) { try { return JSON.parse(text); } catch { throw Error('Invalid source JSON'); } }
|
|
11
|
+
const marker = '<!-- lighthouse-delivery-decision:v1 -->';
|
|
12
|
+
const policyPath = '.lighthouse/delivery-acceptance.json';
|
|
13
|
+
function requireThat(condition, reason) { if (!condition) throw Error(reason); }
|
|
14
|
+
|
|
15
|
+
async function sourceFile(api, path, ref) {
|
|
16
|
+
requireThat(revision(ref) && typeof path === 'string' && /^[\w./-]+$/.test(path) && !path.split('/').some(part => !part || part === '.' || part === '..'), 'Invalid immutable source reference');
|
|
17
|
+
const file = await api(`contents/${path}?ref=${ref}`);
|
|
18
|
+
requireThat(file.type === 'file' && file.encoding === 'base64' && file.size <= 65536, 'Source file unavailable or exceeds 64 KiB');
|
|
19
|
+
const bytes = Buffer.from(file.content, 'base64');
|
|
20
|
+
requireThat(bytes.length === file.size && createHash('sha1').update(Buffer.concat([Buffer.from(`blob ${bytes.length}\0`), bytes])).digest('hex') === file.sha, 'Source file content identity mismatch');
|
|
21
|
+
return { path, revision: ref, blob: file.sha, sha256: sha(bytes), content: bytes.toString('utf8') };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function acceptancePolicy(api, repository, ref) {
|
|
25
|
+
const repo = await api('');
|
|
26
|
+
requireThat(repo.full_name === repository && positive(repo.id) && repo.owner?.type === 'User' && positive(repo.owner.id), 'First acceptance route requires an identified personal repository owner');
|
|
27
|
+
const file = await sourceFile(api, policyPath, ref);
|
|
28
|
+
const policy = parseJson(file.content);
|
|
29
|
+
requireThat(policy.schemaVersion === 1 && policy.enabled === true && policy.route === 'repository-owner' && policy.repositoryId === repo.id && policy.ownerId === repo.owner.id && policy.producer?.workflow === '.github/workflows/lighthouse-delivery-acceptance.yml' && revision(policy.producer.workflowBlob) && typeof policy.producer.operator === 'string' && policy.producer.operator.length > 0, 'Acceptance route or producer not explicitly adopted');
|
|
30
|
+
const tip = await api(`commits/${encodeURIComponent(repo.default_branch)}`);
|
|
31
|
+
const current = await sourceFile(api, policyPath, tip.sha);
|
|
32
|
+
requireThat(current.blob === file.blob, 'Acceptance policy is no longer current; a new decision is required');
|
|
33
|
+
const workflow = await sourceFile(api, policy.producer.workflow, tip.sha);
|
|
34
|
+
requireThat(workflow.blob === policy.producer.workflowBlob, 'Adopted producer workflow changed');
|
|
35
|
+
const installed = await api('actions/workflows/lighthouse-delivery-acceptance.yml');
|
|
36
|
+
requireThat(installed.state === 'active' && installed.path === policy.producer.workflow, 'Adopted producer is unavailable');
|
|
37
|
+
return { repo, policy, reference: { path: policyPath, revision: ref, blob: file.blob, sha256: file.sha256 } };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async function retainedSubject(api, item) {
|
|
41
|
+
const source = await sourceFile(api, item?.path, item?.revision);
|
|
42
|
+
if (item.sha256) requireThat(item.sha256 === source.sha256, 'Scope or criteria digest changed');
|
|
43
|
+
return { path: source.path, revision: source.revision, blob: source.blob, sha256: source.sha256 };
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function prepareAcceptance(api, repository, input) {
|
|
47
|
+
const { repo, reference } = await acceptancePolicy(api, repository, input.policyRevision);
|
|
48
|
+
requireThat(positive(input.issue) && positive(input.pullRequest), 'An exact issue and PR are required');
|
|
49
|
+
const issue = await api(`issues/${input.issue}`), pr = await api(`pulls/${input.pullRequest}`);
|
|
50
|
+
requireThat(!issue.pull_request && positive(issue.id) && positive(pr.id) && pr.base.repo.id === repo.id && pr.head.repo?.id === repo.id && revision(pr.head.sha), 'Candidate identity does not match the adopted repository');
|
|
51
|
+
const binding = { repository: { id: repo.id, fullName: repository }, workItem: { id: issue.id, number: issue.number, url: issue.html_url }, candidate: { kind: 'pull-request', id: pr.id, number: pr.number, head: pr.head.sha, url: pr.html_url }, scope: await retainedSubject(api, input.scope), criteria: await retainedSubject(api, input.criteria), policy: reference };
|
|
52
|
+
const decision = { schemaVersion: 1, route: 'repository-owner', binding, outcome: 'accepted', corrects: [], replacement: null, reason: 'Replace with the owner delivery decision reason.' };
|
|
53
|
+
return { schemaVersion: 1, binding, bindingDigest: acceptanceDigest(binding), comment: decisionComment(decision), effect: 'Prepared only; the repository owner must author a new explicit decision. No source decision or remote mutation was created.' };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function decisionComment(decision) { return `${marker}\n\`\`\`json\n${JSON.stringify(decision, null, 2)}\n\`\`\``; }
|
|
57
|
+
export function parseAcceptanceDecision(body) {
|
|
58
|
+
requireThat(typeof body === 'string' && Buffer.byteLength(body) <= 65536 && body.startsWith(marker), 'Not a bounded delivery-decision source');
|
|
59
|
+
const match = body.match(/^<!-- lighthouse-delivery-decision:v1 -->\n```json\n([\s\S]+)\n```\s*$/);
|
|
60
|
+
requireThat(match, 'Malformed delivery-decision source');
|
|
61
|
+
const decision = parseJson(match[1]);
|
|
62
|
+
requireThat(decision.schemaVersion === 1 && decision.route === 'repository-owner' && ['accepted', 'rejected', 'revoked', 'superseded'].includes(decision.outcome), 'Unsupported delivery decision');
|
|
63
|
+
requireThat(Array.isArray(decision.corrects) && decision.corrects.length <= 32 && decision.corrects.every(id => /^github:[1-9][0-9]*:issue-comment:[1-9][0-9]*$/.test(id)) && new Set(decision.corrects).size === decision.corrects.length && typeof decision.reason === 'string' && decision.reason.trim().length > 0 && decision.reason.length <= 4096, 'Invalid correction references or decision reason');
|
|
64
|
+
requireThat(['accepted', 'rejected'].includes(decision.outcome) || decision.corrects.length > 0, 'Withdrawal requires explicit predecessor decisions');
|
|
65
|
+
requireThat(decision.outcome === 'superseded' ? /^github:[1-9][0-9]*:issue-comment:[1-9][0-9]*$/.test(decision.replacement) : decision.replacement === null, 'Invalid replacement decision');
|
|
66
|
+
return decision;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async function authenticateSource(api, repository, commentId) {
|
|
70
|
+
requireThat(positive(commentId), 'Invalid source comment ID');
|
|
71
|
+
const comment = await api(`issues/comments/${commentId}`);
|
|
72
|
+
const decision = parseAcceptanceDecision(comment.body), binding = decision.binding;
|
|
73
|
+
const adopted = await acceptancePolicy(api, repository, binding?.policy?.revision);
|
|
74
|
+
const { repo } = adopted;
|
|
75
|
+
requireThat(canonical(binding.policy) === canonical(adopted.reference), 'Policy binding changed');
|
|
76
|
+
requireThat(comment.id === commentId && comment.user?.id === repo.owner.id && comment.user.type === 'User' && comment.created_at === comment.updated_at, 'Source must be an unedited explicit owner decision');
|
|
77
|
+
requireThat(binding.repository?.id === repo.id && binding.repository.fullName === repository && positive(binding.workItem?.number) && comment.issue_url === `https://api.github.com/repos/${repository}/issues/${binding.workItem.number}`, 'Source repository or work item mismatch');
|
|
78
|
+
const issue = await api(`issues/${binding.workItem.number}`), pr = await api(`pulls/${binding.candidate?.number}`);
|
|
79
|
+
requireThat(!issue.pull_request && issue.id === binding.workItem.id && issue.html_url === binding.workItem.url && binding.candidate.kind === 'pull-request' && pr.id === binding.candidate.id && pr.html_url === binding.candidate.url && pr.base.repo.id === repo.id && pr.head.repo?.id === repo.id && pr.head.sha === binding.candidate.head, 'Candidate or work item changed');
|
|
80
|
+
requireThat(canonical(await retainedSubject(api, binding.scope)) === canonical(binding.scope) && canonical(await retainedSubject(api, binding.criteria)) === canonical(binding.criteria), 'Retained scope or criteria mismatch');
|
|
81
|
+
return { ...adopted, decision, source: { id: comment.id, url: comment.html_url, createdAt: comment.created_at, updatedAt: comment.updated_at, body: comment.body, sha256: sha(comment.body), actor: { id: comment.user.id, login: comment.user.login } }, id: `github:${repo.id}:issue-comment:${comment.id}` };
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function authenticateProducer(api, adopted, producer, { producing = false } = {}) {
|
|
85
|
+
requireThat(producer?.kind === 'github-actions' && positive(producer.runId) && positive(producer.attempt), 'Eligible producer execution is required');
|
|
86
|
+
const run = await api(`actions/runs/${producer.runId}/attempts/${producer.attempt}`);
|
|
87
|
+
requireThat(run.id === producer.runId && run.run_attempt === producer.attempt && run.repository?.id === adopted.repo.id && run.event === 'workflow_dispatch' && run.actor?.id === adopted.repo.owner.id && run.triggering_actor?.id === adopted.repo.owner.id && run.path === adopted.policy.producer.workflow && run.head_sha === producer.revision && revision(run.head_sha), 'Producer execution is not the adopted owner-dispatched workflow');
|
|
88
|
+
requireThat(producing ? ['queued', 'in_progress'].includes(run.status) : run.status === 'completed' && run.conclusion === 'success', 'Producer execution is not usable');
|
|
89
|
+
const workflow = await sourceFile(api, run.path, run.head_sha);
|
|
90
|
+
requireThat(workflow.blob === adopted.policy.producer.workflowBlob && producer.workflowBlob === workflow.blob, 'Producer workflow content is not adopted');
|
|
91
|
+
return run;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function produceAcceptance(api, repository, commentId, execution) {
|
|
95
|
+
const authenticated = await authenticateSource(api, repository, commentId);
|
|
96
|
+
const workflow = await sourceFile(api, authenticated.policy.producer.workflow, execution.revision);
|
|
97
|
+
const producer = { kind: 'github-actions', runId: execution.runId, attempt: execution.attempt, revision: execution.revision, workflowBlob: workflow.blob, observedAt: new Date().toISOString() };
|
|
98
|
+
await authenticateProducer(api, authenticated, producer, { producing: true });
|
|
99
|
+
const receipt = { schemaVersion: 1, id: authenticated.id, route: 'repository-owner', decision: authenticated.decision, source: authenticated.source, producer };
|
|
100
|
+
validatePublishable({ 'receipt.json': JSON.stringify(receipt) });
|
|
101
|
+
return receipt;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async function sourceHistory(api, issue) {
|
|
105
|
+
const comments = [];
|
|
106
|
+
for (let page = 1; page <= 10; page++) {
|
|
107
|
+
const batch = await api(`issues/${issue}/comments?per_page=100&page=${page}`);
|
|
108
|
+
requireThat(Array.isArray(batch), 'Source history unavailable'); comments.push(...batch);
|
|
109
|
+
if (batch.length < 100) return comments;
|
|
110
|
+
}
|
|
111
|
+
throw Error('Source history exceeds 1000-comment bound; completeness unavailable');
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function retainedHistory(api, repository, readArtifact) {
|
|
115
|
+
const receipts = [], seenRuns = new Set();
|
|
116
|
+
let expectedRuns;
|
|
117
|
+
for (let page = 1; page <= 10; page++) {
|
|
118
|
+
const result = await api(`actions/workflows/lighthouse-delivery-acceptance.yml/runs?event=workflow_dispatch&per_page=100&page=${page}`);
|
|
119
|
+
requireThat(Array.isArray(result.workflow_runs) && result.total_count <= 1000, 'Producer history exceeds bound or is incomplete');
|
|
120
|
+
expectedRuns ??= result.total_count;
|
|
121
|
+
requireThat(expectedRuns === result.total_count, 'Producer history changed during collection; retry verification');
|
|
122
|
+
for (const run of result.workflow_runs) {
|
|
123
|
+
requireThat(!seenRuns.has(run.id), 'Producer history pagination contains duplicates'); seenRuns.add(run.id);
|
|
124
|
+
const artifacts = await api(`actions/runs/${run.id}/artifacts?per_page=100`);
|
|
125
|
+
requireThat(Array.isArray(artifacts.artifacts) && artifacts.total_count === artifacts.artifacts.length && artifacts.total_count <= 100, 'Producer artifact history incomplete');
|
|
126
|
+
const retained = artifacts.artifacts.filter(a => /^lighthouse-delivery-acceptance-[1-9][0-9]*-[1-9][0-9]*$/.test(a.name));
|
|
127
|
+
requireThat((run.conclusion !== 'success' || retained.length > 0) && retained.every(a => !a.expired), 'Producer receipt expired or missing; historical corrections cannot be excluded');
|
|
128
|
+
for (const artifact of retained) receipts.push(await readArtifact(api, repository, run.id, artifact.name, 'receipt.json'));
|
|
129
|
+
requireThat(receipts.length <= 1000, 'Retained decision history exceeds bound');
|
|
130
|
+
}
|
|
131
|
+
if (result.workflow_runs.length < 100) { requireThat(seenRuns.size === expectedRuns, 'Producer history pagination incomplete'); return receipts; }
|
|
132
|
+
}
|
|
133
|
+
throw Error('Producer history exceeds pagination bound');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export async function verifyAcceptance(api, repository, { binding, receipts = [] }, { readArtifact = readActionsJson, now = () => new Date().toISOString() } = {}) {
|
|
137
|
+
const observedAt = now(), unavailable = reason => ({ schemaVersion: 1, status: 'unavailable', reason, recoveryOwner: 'repository-owner', observedAt, bindingDigest: acceptanceDigest(binding ?? null), historyCoverage: 'incomplete' });
|
|
138
|
+
try {
|
|
139
|
+
const adopted = await acceptancePolicy(api, repository, binding?.policy?.revision);
|
|
140
|
+
requireThat(binding.repository?.id === adopted.repo.id && binding.repository.fullName === repository && positive(binding.workItem?.number), 'Requested repository or work item mismatch');
|
|
141
|
+
const refreshed = await prepareAcceptance(api, repository, { policyRevision: binding.policy.revision, issue: binding.workItem.number, pullRequest: binding.candidate?.number, scope: binding.scope, criteria: binding.criteria });
|
|
142
|
+
requireThat(canonical(refreshed.binding) === canonical(binding), 'Requested candidate binding is stale or invalid');
|
|
143
|
+
requireThat(Array.isArray(receipts) && receipts.length <= 100, 'Receipt collection exceeds bound');
|
|
144
|
+
const retained = await retainedHistory(api, repository, readArtifact);
|
|
145
|
+
const history = await sourceHistory(api, binding.workItem.number);
|
|
146
|
+
const sources = [];
|
|
147
|
+
for (const comment of history.filter(c => c.user?.id === adopted.repo.owner.id && c.body?.startsWith(marker))) {
|
|
148
|
+
const decision = parseAcceptanceDecision(comment.body);
|
|
149
|
+
if (acceptanceDigest(decision.binding) === acceptanceDigest(binding)) sources.push(comment);
|
|
150
|
+
}
|
|
151
|
+
const relevant = retained.filter(r => acceptanceDigest(r.decision?.binding ?? null) === acceptanceDigest(binding));
|
|
152
|
+
requireThat(relevant.every(r => receipts.some(s => canonical(s) === canonical(r))), 'Required retained history omitted from consumer input');
|
|
153
|
+
const verified = new Map();
|
|
154
|
+
for (const receipt of receipts) {
|
|
155
|
+
requireThat(receipt.schemaVersion === 1 && receipt.route === 'repository-owner', 'Unsupported receipt version or route');
|
|
156
|
+
if (acceptanceDigest(receipt.decision?.binding) !== acceptanceDigest(binding)) continue;
|
|
157
|
+
validatePublishable({ 'receipt.json': JSON.stringify(receipt) });
|
|
158
|
+
const source = await authenticateSource(api, repository, receipt.source?.id);
|
|
159
|
+
requireThat(receipt.id === source.id && canonical(receipt.decision) === canonical(source.decision) && canonical(receipt.source) === canonical(source.source), 'Retained receipt and authenticated source differ');
|
|
160
|
+
await authenticateProducer(api, source, receipt.producer);
|
|
161
|
+
const artifact = await readArtifact(api, repository, receipt.producer.runId, `lighthouse-delivery-acceptance-${receipt.source.id}-${receipt.producer.attempt}`, 'receipt.json');
|
|
162
|
+
requireThat(canonical(artifact) === canonical(receipt), 'Receipt was not retained by the adopted producer execution');
|
|
163
|
+
if (verified.has(receipt.id)) requireThat(canonical(verified.get(receipt.id).decision) === canonical(receipt.decision) && canonical(verified.get(receipt.id).source) === canonical(receipt.source), 'Conflicting retry at one logical decision');
|
|
164
|
+
else verified.set(receipt.id, receipt);
|
|
165
|
+
}
|
|
166
|
+
requireThat(sources.length === verified.size && sources.every(c => verified.has(`github:${adopted.repo.id}:issue-comment:${c.id}`)), 'Decision history has missing producer receipts');
|
|
167
|
+
for (const receipt of verified.values()) if (receipt.decision.replacement) {
|
|
168
|
+
const match = receipt.decision.replacement.match(/^github:([1-9][0-9]*):issue-comment:([1-9][0-9]*)$/);
|
|
169
|
+
requireThat(Number(match[1]) === adopted.repo.id, 'Replacement belongs to another repository');
|
|
170
|
+
const replacement = await authenticateSource(api, repository, Number(match[2]));
|
|
171
|
+
requireThat(replacement.id !== receipt.id && replacement.decision.outcome === 'accepted', 'Supersession must name a separate owner acceptance source; replacement qualification remains independent');
|
|
172
|
+
}
|
|
173
|
+
const corrected = new Set();
|
|
174
|
+
for (const receipt of verified.values()) for (const id of receipt.decision.corrects) {
|
|
175
|
+
requireThat(id !== receipt.id && verified.has(id), 'Correction predecessor missing or self-referential'); corrected.add(id);
|
|
176
|
+
}
|
|
177
|
+
const visited = new Set(), visiting = new Set();
|
|
178
|
+
const visit = id => {
|
|
179
|
+
requireThat(!visiting.has(id), 'Cyclic correction history');
|
|
180
|
+
if (visited.has(id)) return;
|
|
181
|
+
visiting.add(id);
|
|
182
|
+
for (const prior of verified.get(id).decision.corrects) visit(prior);
|
|
183
|
+
visiting.delete(id); visited.add(id);
|
|
184
|
+
};
|
|
185
|
+
for (const id of verified.keys()) visit(id);
|
|
186
|
+
const active = [...verified.values()].filter(r => !corrected.has(r.id));
|
|
187
|
+
requireThat(active.length <= 1, 'Conflicting decisions require an explicit owner correction');
|
|
188
|
+
const current = active[0];
|
|
189
|
+
return { schemaVersion: 1, status: current?.decision.outcome ?? 'pending', decisionId: current?.id ?? null, reason: current ? 'Authenticated owner decision for this exact binding' : 'Adopted healthy route has no owner decision for this binding', observedAt, bindingDigest: acceptanceDigest(binding), historyCoverage: 'complete-at-observation', decisionIds: [...verified.keys()].sort(), sourceUrls: sources.map(s => s.html_url).sort(), limitations: ['Current only as of observation; artifact expiry, edited sources or inaccessible history make acceptance unavailable.', 'PR candidates only; artifact and delegated routes are unavailable.'] };
|
|
190
|
+
} catch (error) { return unavailable(error.message); }
|
|
191
|
+
}
|
|
@@ -7,7 +7,7 @@ import { createIssueControlManifest } from './issue-control-contract.mjs';
|
|
|
7
7
|
import { housekeepingFiles } from './housekeeping-assets.mjs';
|
|
8
8
|
|
|
9
9
|
const [target, revision, ...flags] = process.argv.slice(2);
|
|
10
|
-
if (!target || revision !== 'package' && !/^[a-f0-9]{40}$/.test(revision ?? '') || flags.some(x => !['--apply', '--replace-reviewed', '--with-propose', '--with-implement', '--with-completion', '--with-maintenance', '--with-product-change', '--with-unattended', '--with-epic', '--with-issue-control'].includes(x))) throw Error('Usage: install-workflows <repository> <immutable-lighthouse-commit|package> [--apply] [--replace-reviewed] [--with-propose] [--with-implement] [--with-completion] [--with-maintenance] [--with-product-change] [--with-unattended] [--with-epic] [--with-issue-control]');
|
|
10
|
+
if (!target || revision !== 'package' && !/^[a-f0-9]{40}$/.test(revision ?? '') || flags.some(x => !['--apply', '--replace-reviewed', '--with-propose', '--with-implement', '--with-completion', '--with-maintenance', '--with-product-change', '--with-unattended', '--with-epic', '--with-issue-control', '--with-delivery-acceptance'].includes(x))) throw Error('Usage: install-workflows <repository> <immutable-lighthouse-commit|package> [--apply] [--replace-reviewed] [--with-propose] [--with-implement] [--with-completion] [--with-maintenance] [--with-product-change] [--with-unattended] [--with-epic] [--with-issue-control] [--with-delivery-acceptance]');
|
|
11
11
|
const packageVersion = revision === 'package' ? JSON.parse(await readFile(new URL('../package.json', import.meta.url), 'utf8')).version : null;
|
|
12
12
|
const apply = flags.includes('--apply'), replace = flags.includes('--replace-reviewed');
|
|
13
13
|
const compilerCommand = process.env.LIGHTHOUSE_GH_AW_EXECUTABLE ?? 'gh';
|
|
@@ -29,6 +29,7 @@ if (flags.includes('--with-maintenance')) {
|
|
|
29
29
|
planned.push({ path, content });
|
|
30
30
|
console.log(`${apply ? 'Write' : 'Would write'} ${path}; configure the report index and explicitly activate maintenance separately.`);
|
|
31
31
|
}
|
|
32
|
+
if (flags.includes('--with-delivery-acceptance')) files.push('lighthouse-delivery-acceptance.yml');
|
|
32
33
|
if (unattended) files.push('lighthouse-sdlc-unattended.yml');
|
|
33
34
|
if (epic) files.push('lighthouse-sdlc-epic.yml');
|
|
34
35
|
for (const name of files) {
|
package/src/sdlc.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { acceptanceCli } from './delivery-acceptance-cli.mjs';
|
|
2
3
|
import { practiceCli } from './practice-cli.mjs';
|
|
3
4
|
import { access, mkdir, readFile, writeFile } from 'node:fs/promises';
|
|
4
5
|
import { constants } from 'node:fs';
|
|
@@ -395,11 +396,13 @@ async function runGithubLabels(args) {
|
|
|
395
396
|
}
|
|
396
397
|
|
|
397
398
|
const command = process.argv[2] ?? 'verify';
|
|
398
|
-
if (!['practices', 'telemetry', 'contract', 'verify', 'aliases', 'triage', 'state', 'stage-result', 'browser-e2e', 'evidence', 'control-plane', 'memory', 'launch', 'decompose', 'stacked', 'route', 'github-triage', 'github-decompose', 'reconcile-labels', 'github-labels'].includes(command)) {
|
|
399
|
-
console.error('Usage: lighthouse-sdlc <practices|telemetry|contract|verify|aliases|triage|state|stage-result|browser-e2e|evidence|control-plane|memory|launch|decompose|stacked|route|github-triage|github-decompose|reconcile-labels|github-labels>');
|
|
399
|
+
if (!['delivery-acceptance', 'practices', 'telemetry', 'contract', 'verify', 'aliases', 'triage', 'state', 'stage-result', 'browser-e2e', 'evidence', 'control-plane', 'memory', 'launch', 'decompose', 'stacked', 'route', 'github-triage', 'github-decompose', 'reconcile-labels', 'github-labels'].includes(command)) {
|
|
400
|
+
console.error('Usage: lighthouse-sdlc <delivery-acceptance|practices|telemetry|contract|verify|aliases|triage|state|stage-result|browser-e2e|evidence|control-plane|memory|launch|decompose|stacked|route|github-triage|github-decompose|reconcile-labels|github-labels>');
|
|
400
401
|
process.exit(2);
|
|
401
402
|
}
|
|
402
|
-
if (command === '
|
|
403
|
+
if (command === 'delivery-acceptance') {
|
|
404
|
+
await acceptanceCli(process.argv.slice(3));
|
|
405
|
+
} else if (command === 'practices') {
|
|
403
406
|
console.log(JSON.stringify(await practiceCli(process.argv.slice(3)), null, 2));
|
|
404
407
|
} else if (command === 'telemetry') {
|
|
405
408
|
await telemetryCli(process.argv.slice(3));
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: Lighthouse delivery acceptance
|
|
2
|
+
on:
|
|
3
|
+
workflow_dispatch:
|
|
4
|
+
inputs:
|
|
5
|
+
decision_comment:
|
|
6
|
+
description: Numeric ID of the owner's unedited delivery-decision issue comment
|
|
7
|
+
type: string
|
|
8
|
+
required: true
|
|
9
|
+
permissions: {}
|
|
10
|
+
jobs:
|
|
11
|
+
record:
|
|
12
|
+
if: github.actor == github.repository_owner && github.triggering_actor == github.repository_owner
|
|
13
|
+
runs-on: ubuntu-24.04
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
issues: read
|
|
17
|
+
pull-requests: read
|
|
18
|
+
actions: read
|
|
19
|
+
steps:
|
|
20
|
+
- uses: actions/checkout@v5
|
|
21
|
+
with:
|
|
22
|
+
repository: juangcarmona/lighthouse
|
|
23
|
+
ref: __LIGHTHOUSE_REF__
|
|
24
|
+
persist-credentials: false
|
|
25
|
+
- uses: actions/setup-node@v5
|
|
26
|
+
with:
|
|
27
|
+
node-version: 24
|
|
28
|
+
- name: Authenticate and retain the explicit owner decision
|
|
29
|
+
env:
|
|
30
|
+
GH_TOKEN: ${{ github.token }}
|
|
31
|
+
LIGHTHOUSE_DECISION_COMMENT: ${{ inputs.decision_comment }}
|
|
32
|
+
run: node src/packages/sdlc/src/sdlc.mjs delivery-acceptance produce --output receipt.json
|
|
33
|
+
- uses: actions/upload-artifact@v7
|
|
34
|
+
with:
|
|
35
|
+
name: lighthouse-delivery-acceptance-${{ inputs.decision_comment }}-${{ github.run_attempt }}
|
|
36
|
+
path: receipt.json
|
|
37
|
+
if-no-files-found: error
|
|
38
|
+
retention-days: 90
|