@juangcarmona/lighthouse-sdlc 0.24.0 → 0.24.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/README.md CHANGED
@@ -109,6 +109,12 @@ The shared maintenance workflow includes daily deterministic inspection at `23 3
109
109
 
110
110
  Configure `LIGHTHOUSE_REPORT_INDEX_ISSUE` as an open owner-authored issue and explicitly enable `LIGHTHOUSE_AUTOMATION_ENABLED` and `LIGHTHOUSE_MAINTENANCE_ENABLED`. Leave `LIGHTHOUSE_MAINTENANCE_ISSUES` unset for repository-wide coverage; a selected issue subset is reported separately and cannot advance repository freshness. The inventory covers open owner issues and retained final-review recovery subjects within the existing 100-issue bound, their published PRs, native blockers and child tracking. Missing or inaccessible relationship or execution evidence makes coverage incomplete. Other authors and older closed issues outside that inventory are not claimed as inspected.
111
111
 
112
+ To inspect the whole repository while keeping recovery restricted to `LIGHTHOUSE_MAINTENANCE_ISSUES`, explicitly set `LIGHTHOUSE_HOUSEKEEPING_REPOSITORY=true`. This affects only the daily inspection; the existing recovery scope remains in force.
113
+
114
+ An operator may retire monitoring of a terminal historical execution after inspecting every attempt and its possible publication effects. Record an unedited owner comment on the report index with one `<!-- lighthouse-housekeeping-reconciliation:{...} -->` marker per request. The JSON requires `schemaVersion: 1`, `repository`, `issue`, `requestCommentId`, `requestId`, `requestDigest`, `workerRunId`, `runAttempt`, `disposition: "retire"`, a nonempty `reason` and an `evidence` array of same-repository issue, PR or execution URLs. IDs and attempt numbers are positive integers; request ID and digest must match the original bot receipt. The native execution must still be terminal at the recorded attempt and predate the owner comment. Edited comments, changed attempts and mismatched bindings cannot reconcile coverage.
115
+
116
+ Retirement records `owner-retired` alongside the original observation and owner decision in the scan artifact. Unknown outcomes remain unknown. It authorizes no retry, reservation release, publication, merge or lifecycle completion; existing issue blockers and candidate PRs remain actionable. Missing relationships and other unreconciled observations still make coverage incomplete. Deleting or editing the decision makes that historical monitoring incomplete again.
117
+
112
118
  For a manual dry-run, dispatch maintenance with `housekeeping: true` and `dry_run: true`. It retains `lighthouse-daily-housekeeping-<attempt>/daily-housekeeping.json` without tracker, reservation or continuation effects; it is not scheduled-operation evidence. Set `dry_run: false` only after activation to update the existing report index. The index preserves owner notes, newer observations and the last complete repository scan. Existing issue-serialized maintenance remains responsible for legal reservation cleanup, bounded recovery and lifecycle completion; resolved dependencies and merged PRs grant no new authority. A daily inspection does not claim those effects succeeded.
113
119
 
114
120
  The Lighthouse operator can run `node scripts/reconcile-worker-maintenance.mjs --report-index <issue>` to assess actual complete daily coverage independently of half-hour recovery freshness. The daily pointer must match a native run, attempt and complete inspection artifact. Missing, disabled, skipped, partial, inaccessible and overdue coverage remain unhealthy or unconfirmed. A cron expression is not a latency guarantee. Installation, activation, package publication, complete native scans and verified effects require separate evidence; no fleet registration or named pilot is required.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juangcarmona/lighthouse-sdlc",
3
- "version": "0.24.0",
3
+ "version": "0.24.1",
4
4
  "type": "module",
5
5
  "description": "Provider-neutral SDLC skills, commands and route contracts for Lighthouse adopters",
6
6
  "repository": {
@@ -3,7 +3,7 @@ import { registryWorkflow } from './workflow-distribution.mjs';
3
3
 
4
4
  export const housekeepingRequirements = Object.freeze({
5
5
  workflow: '.github/workflows/lighthouse-worker-maintenance.yml',
6
- configuration: ['LIGHTHOUSE_REPORT_INDEX_ISSUE: open owner-authored report index', 'LIGHTHOUSE_MAINTENANCE_ISSUES: leave unset for repository coverage; a selected subset is not complete repository coverage'],
6
+ configuration: ['LIGHTHOUSE_REPORT_INDEX_ISSUE: open owner-authored report index', 'LIGHTHOUSE_MAINTENANCE_ISSUES: leave unset for repository coverage; a selected subset is not complete repository coverage', 'LIGHTHOUSE_HOUSEKEEPING_REPOSITORY=true: inspect the repository while preserving a restricted recovery scope'],
7
7
  explicitActivation: ['LIGHTHOUSE_AUTOMATION_ENABLED=true', 'LIGHTHOUSE_MAINTENANCE_ENABLED=true'],
8
8
  runtimeEvidence: 'Not established by installation; inspect lighthouse-daily-housekeeping-<attempt>/daily-housekeeping.json and the report index.',
9
9
  publication: 'Package publication is required before package-mode execution; source generation is not publication.',
@@ -1,5 +1,5 @@
1
1
  import { observeRecovery } from './worker-recovery.mjs';
2
- import { issueComments } from './stage-dispatch.mjs';
2
+ import { issueComments, readDispatchReceipt, stagePath, workerFor } from './stage-dispatch.mjs';
3
3
  import { readActionsJson } from './actions-artifact.mjs';
4
4
 
5
5
  const start = '<!-- lighthouse-housekeeping:start -->';
@@ -8,6 +8,46 @@ const marker = /<!-- lighthouse-housekeeping:(\{[^\n]*\}) -->/g;
8
8
  const positive = value => Number.isSafeInteger(value) && value > 0;
9
9
  const timestamp = value => typeof value === 'string' && Number.isFinite(Date.parse(value)) && new Date(value).toISOString() === value;
10
10
  const incompleteCodes = new Set(['evidence-unavailable', 'dispatch-origin-unavailable', 'dispatch-unconfirmed', 'execution-rerun', 'publication-uncertain']);
11
+ const uncertainItem = (workers, dependencies) => workers.some(item => item.state === 'uncertain' || incompleteCodes.has(item.code)) || dependencies.some(item => item.state === 'unknown');
12
+
13
+ // An owner can retire historical monitoring without rewriting receipts or granting recovery.
14
+ export function housekeepingReconciler(api, repository, owner, indexNumber) {
15
+ let decisions;
16
+ const read = async () => {
17
+ if (!positive(Number(indexNumber))) return [];
18
+ const index = await api(`issues/${indexNumber}`);
19
+ if (index.number !== Number(indexNumber) || index.pull_request || index.state !== 'open' || index.user?.login !== owner) throw Error('Invalid reconciliation index');
20
+ const result = [];
21
+ for (const comment of await issueComments(api, Number(indexNumber))) {
22
+ if (comment.user?.login !== owner || comment.user.type !== 'User' || comment.created_at !== comment.updated_at || !Number.isFinite(Date.parse(comment.created_at)) || comment.issue_url !== `https://api.github.com/repos/${repository}/issues/${indexNumber}`) continue;
23
+ for (const match of (comment.body ?? '').matchAll(/<!-- lighthouse-housekeeping-reconciliation:(\{[^\n]*\}) -->/g)) {
24
+ const value = JSON.parse(match[1]);
25
+ const localEvidence = url => typeof url === 'string' && url.startsWith(`https://github.com/${repository}/`) && /^(?:issues\/[1-9][0-9]*(?:#issuecomment-[1-9][0-9]*)?|pull\/[1-9][0-9]*|actions\/runs\/[1-9][0-9]*(?:\/attempts\/[1-9][0-9]*)?)$/.test(url.slice(`https://github.com/${repository}/`.length));
26
+ if (value.schemaVersion !== 1 || value.repository !== repository || value.disposition !== 'retire' || ![value.issue, value.requestCommentId, value.workerRunId, value.runAttempt].every(positive) || !/^[a-f0-9]{64}$/.test(value.requestId ?? '') || !/^[a-f0-9]{64}$/.test(value.requestDigest ?? '') || typeof value.reason !== 'string' || !value.reason.trim() || value.reason.length > 2000 || !Array.isArray(value.evidence) || !value.evidence.length || value.evidence.length > 20 || !value.evidence.every(localEvidence)) throw Error('Invalid owner reconciliation');
27
+ result.push({ value, comment });
28
+ }
29
+ }
30
+ return result;
31
+ };
32
+ return async item => {
33
+ if (!item.workers?.some(worker => worker.state === 'uncertain' || incompleteCodes.has(worker.code))) return item;
34
+ decisions ??= read();
35
+ const retained = await decisions, workers = [];
36
+ for (const worker of item.workers) {
37
+ const decision = retained.filter(({ value }) => value.issue === item.issue && String(value.workerRunId) === String(worker.runId ?? worker.observedRunId)).at(-1);
38
+ if (!decision || !(worker.state === 'uncertain' || incompleteCodes.has(worker.code))) { workers.push(worker); continue; }
39
+ const { value, comment } = decision;
40
+ const receiptComment = await api(`issues/comments/${value.requestCommentId}`);
41
+ const receipt = readDispatchReceipt(receiptComment, repository, item.issue);
42
+ const run = await api(`actions/runs/${value.workerRunId}`);
43
+ if (receipt.id !== value.requestId || receipt.digest !== value.requestDigest || String(receipt.workerRunId) !== String(value.workerRunId) || (receipt.recovery?.rootId ?? receipt.id) !== worker.rootId || Number(comment.id) <= Number(receiptComment.id) || run.id !== value.workerRunId || run.run_attempt !== value.runAttempt || run.repository?.full_name !== repository || run.path !== stagePath(workerFor(receipt)) || run.status !== 'completed' || !Number.isFinite(Date.parse(run.updated_at)) || Date.parse(run.updated_at) > Date.parse(comment.created_at)) throw Error('Owner reconciliation no longer matches the terminal execution');
44
+ const url = `https://github.com/${repository}/issues/${indexNumber}#issuecomment-${comment.id}`;
45
+ workers.push({ ...worker, state: 'reconciled', code: 'owner-retired', original: worker, reconciliation: { ...value, commentId: comment.id, url }, nextAction: `Historical monitoring retired by the owner: ${url}. Preserve the original outcome and existing candidates; no retry or lifecycle transition is authorized.` });
46
+ }
47
+ const replaced = item.workers.filter((worker, i) => workers[i] !== worker).map(worker => worker.nextAction);
48
+ return { ...item, workers, status: uncertainItem(workers, item.dependencies) ? 'incomplete' : 'inspected', nextActions: [...new Set([...item.nextActions.filter(action => !replaced.includes(action)), ...workers.filter(worker => worker.code === 'owner-retired').map(worker => worker.nextAction)])] };
49
+ };
50
+ }
11
51
 
12
52
  function boundedRows(rows) {
13
53
  if (!Array.isArray(rows) || rows.length >= 100 || rows.some(row => !positive(row?.number) || !['open', 'closed'].includes(row.state))) throw Error('Incomplete relationship inventory');
@@ -31,7 +71,7 @@ export async function inspectHousekeepingItem(api, repository, owner, number, no
31
71
  published.push({ number: pr.number, url: pr.html_url, state: pr.merged === true ? 'merged' : pr.state, authority: 'requires-retained-publication', nextAction: 'Reconcile the original publication through existing maintenance before considering another implementation; merge is not lifecycle acceptance.' });
32
72
  }
33
73
  }
34
- const uncertain = workers.some(item => item.state === 'uncertain' || incompleteCodes.has(item.code)) || dependencies.some(item => item.state === 'unknown');
74
+ const uncertain = uncertainItem(workers, dependencies);
35
75
  const nextActions = workers.filter(item => !['worker-completed', 'ci-observed'].includes(item.code)).map(item => item.nextAction);
36
76
  if (dependencies.length && dependencies.every(item => item.state === 'resolved')) nextActions.push('Owner: blockers appear resolved; continuation still requires current authority, pause/reservation checks and bounded admission.');
37
77
  if (children.length && children.every(item => item.state === 'closed')) nextActions.push('Owner: evaluate aggregate lifecycle acceptance; closed children alone do not complete this parent.');
@@ -41,7 +81,7 @@ export async function inspectHousekeepingItem(api, repository, owner, number, no
41
81
  }
42
82
 
43
83
  // Discovery and item failures stay distinct. A genuinely empty inventory can complete.
44
- export async function scanHousekeeping({ api, repository, owner, run, discover, scope = 'repository', dryRun = true, now = () => Date.now(), inspect = inspectHousekeepingItem }) {
84
+ export async function scanHousekeeping({ api, repository, owner, run, discover, scope = 'repository', dryRun = true, now = () => Date.now(), inspect = inspectHousekeepingItem, reconcile = async item => item }) {
45
85
  if (!/^[\w.-]+\/[\w.-]+$/.test(repository) || !positive(run.id) || !positive(run.attempt)) throw Error('Invalid housekeeping identity');
46
86
  const startedAt = new Date(now()).toISOString(), items = [], failures = [];
47
87
  let issues = [];
@@ -50,8 +90,9 @@ export async function scanHousekeeping({ api, repository, owner, run, discover,
50
90
  if (!Array.isArray(issues) || issues.length > 100 || issues.some(number => !positive(number)) || new Set(issues).size !== issues.length) throw Error('Invalid or incomplete issue inventory');
51
91
  } catch { failures.push({ code: 'discovery-unavailable', nextAction: 'Maintainer: restore complete repository inventory before claiming daily coverage.' }); }
52
92
  for (const number of issues.toSorted((a, b) => a - b)) {
53
- try { items.push(await inspect(api, repository, owner, number, now())); }
54
- catch { items.push({ issue: number, url: `https://github.com/${repository}/issues/${number}`, status: 'incomplete', nextActions: ['Maintainer: inspect unavailable issue, relationship or original execution evidence; preserve reservations and uncertain effects.'] }); }
93
+ let item;
94
+ try { item = await inspect(api, repository, owner, number, now()); items.push(await reconcile(item)); }
95
+ catch { items.push({ ...(item ?? { issue: number, url: `https://github.com/${repository}/issues/${number}` }), status: 'incomplete', nextActions: [...(item?.nextActions ?? []), 'Maintainer: inspect unavailable issue, relationship, execution or owner reconciliation evidence; preserve reservations and uncertain effects.'] }); }
55
96
  }
56
97
  const complete = failures.length === 0 && items.every(item => item.status === 'inspected');
57
98
  return { schemaVersion: 1, repository, run, mode: dryRun ? 'dry-run' : 'inspection', scope, startedAt, observedAt: new Date(now()).toISOString(), completedAt: complete ? new Date(now()).toISOString() : null, complete, issues, items, failures, effects: 'none; existing maintenance owns recovery and lifecycle transitions' };
@@ -7,7 +7,9 @@ import { githubAppCiTrigger } from './github-app-ci.mjs';
7
7
  import { admissionCompletion, completedAdmission } from './admission-recovery.mjs';
8
8
  import { publishReports } from './worker-reports.mjs';
9
9
  import { createIssueApi } from './github-rest.mjs';
10
- import { scanHousekeeping, publishHousekeepingSummary } from './repository-housekeeping.mjs';
10
+ import { scanHousekeeping, publishHousekeepingSummary, housekeepingReconciler } from './repository-housekeeping.mjs';
11
+
12
+ export const housekeepingScope = (env, recoveryScope) => env.LIGHTHOUSE_HOUSEKEEPING_REPOSITORY === 'true' ? null : recoveryScope;
11
13
 
12
14
  export async function ownerIssues(api, owner) {
13
15
  const issues = [];
@@ -37,7 +39,15 @@ export async function maintenanceIssues(api, owner, repository) {
37
39
  if (run.status !== 'completed' || !['success', 'failure', 'timed_out'].includes(run.conclusion)) continue;
38
40
  const issue = await api(`issues/${number}`);
39
41
  if (issue.number !== number || issue.state !== 'closed' || issue.user?.login !== owner || issue.pull_request) continue;
40
- const receipt = readDispatchReceipt(await api(`issues/comments/${match[2]}`), repository, number);
42
+ const comment = await api(`issues/comments/${match[2]}`);
43
+ // Terminal summaries only prune closed inventory; they never authenticate recovery.
44
+ // This also leaves completed receipts from a previous repository name in history.
45
+ const markers = [...(comment.body ?? '').matchAll(/<!-- lighthouse-dispatch:(\{[^\n]*\}) -->/g)];
46
+ if (run.conclusion === 'success' && comment.user?.login === 'github-actions[bot]' && comment.user.type === 'Bot' && comment.issue_url === `https://api.github.com/repos/${repository}/issues/${number}` && markers.length === 1) {
47
+ const summary = JSON.parse(markers[0][1]);
48
+ if (summary.schemaVersion === 1 && summary.stage === 'review' && summary.status === 'completed' && String(summary.workerRunId) === String(run.id)) continue;
49
+ }
50
+ const receipt = readDispatchReceipt(comment, repository, number);
41
51
  if (receipt.stage === 'review' && String(receipt.workerRunId) === String(run.id) && ['requested', 'running', 'unknown', 'failed'].includes(receipt.status)) issues.add(number);
42
52
  }
43
53
  if (issues.size > 100) throw Error('Maintenance exceeds 100 owner issues');
@@ -60,9 +70,10 @@ async function main(command) {
60
70
  if (command === 'housekeeping') {
61
71
  if (completionWake) throw Error('A completion wake cannot claim daily coverage');
62
72
  const requested = event?.inputs?.issue;
73
+ const dailyScope = housekeepingScope(env, scope);
63
74
  if (requested && !/^[1-9][0-9]*$/.test(requested)) throw Error('Issue must be a canonical positive integer');
64
- if (requested && scope && !scope.includes(Number(requested))) throw Error('Issue is outside the configured maintenance scope');
65
- const scan = await scanHousekeeping({ api, repository, owner, run: { id: Number(parent.id), attempt: Number(parent.run_attempt), revision: parent.head_sha }, scope: requested || scope ? 'selected-issues' : 'repository', dryRun: housekeepingDryRun, discover: () => requested ? [Number(requested)] : scope ?? maintenanceIssues(api, owner, repository) });
75
+ if (requested && dailyScope && !dailyScope.includes(Number(requested))) throw Error('Issue is outside the configured maintenance scope');
76
+ const scan = await scanHousekeeping({ api, repository, owner, run: { id: Number(parent.id), attempt: Number(parent.run_attempt), revision: parent.head_sha }, scope: requested || dailyScope ? 'selected-issues' : 'repository', dryRun: housekeepingDryRun, discover: () => requested ? [Number(requested)] : dailyScope ?? maintenanceIssues(api, owner, repository), reconcile: housekeepingReconciler(api, repository, owner, env.LIGHTHOUSE_REPORT_INDEX_ISSUE) });
66
77
  await writeFile(join(env.RUNNER_TEMP, 'daily-housekeeping.json'), JSON.stringify(scan, null, 2));
67
78
  if (env.GITHUB_STEP_SUMMARY) await appendFile(env.GITHUB_STEP_SUMMARY, `Daily housekeeping: ${scan.complete ? 'complete' : 'incomplete'} ${scan.mode}, scope ${scan.scope}; ${scan.items.length} item(s). Installation, explicit activation and verified effects are separate.\n`);
68
79
  if (!housekeepingDryRun) await publishHousekeepingSummary(api, repository, owner, env.LIGHTHOUSE_REPORT_INDEX_ISSUE, scan);
@@ -48,6 +48,7 @@ jobs:
48
48
  pull-requests: read
49
49
  env:
50
50
  LIGHTHOUSE_REPORT_INDEX_ISSUE: ${{ vars.LIGHTHOUSE_REPORT_INDEX_ISSUE }}
51
+ LIGHTHOUSE_HOUSEKEEPING_REPOSITORY: ${{ vars.LIGHTHOUSE_HOUSEKEEPING_REPOSITORY }}
51
52
  steps:
52
53
  - uses: actions/checkout@v5
53
54
  with: