@juangcarmona/lighthouse-sdlc 0.22.4 → 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 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juangcarmona/lighthouse-sdlc",
3
- "version": "0.22.4",
3
+ "version": "0.22.5",
4
4
  "type": "module",
5
5
  "description": "Provider-neutral SDLC skills, commands and route contracts for Lighthouse adopters",
6
6
  "repository": {
@@ -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';