@juangcarmona/lighthouse-sdlc 0.23.5 → 0.23.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juangcarmona/lighthouse-sdlc",
3
- "version": "0.23.5",
3
+ "version": "0.23.7",
4
4
  "type": "module",
5
5
  "description": "Provider-neutral SDLC skills, commands and route contracts for Lighthouse adopters",
6
6
  "repository": {
@@ -162,7 +162,7 @@ export function recoverExecutionOwners(directory, { run = docker, isStopped = st
162
162
  return receipts;
163
163
  }
164
164
  export const ownedDockerArgs = (config, args) => config.resourceOwner?.prepare(args) ?? args;
165
- export async function recoverExecutionWorkspaces(directory, { isStopped = stopped } = {}) {
165
+ export async function recoverExecutionWorkspaces(directory, { isStopped = stopped, restoreOwnership } = {}) {
166
166
  for (const name of readdirSync(directory).filter(name => name.endsWith('.json'))) {
167
167
  const path = join(directory, name), stat = lstatSync(path);
168
168
  if (!stat.isFile() || stat.isSymbolicLink() || stat.size > 1024 * 1024) throw Error('Unsafe execution ownership journal');
@@ -171,7 +171,7 @@ export async function recoverExecutionWorkspaces(directory, { isStopped = stoppe
171
171
  if (!record.workspace || record.workspace.status === 'clean') continue;
172
172
  if (isStopped(record.process) !== true) throw Error('Workspace owner is active or unknown; retain its state');
173
173
  if (record.cleanup?.status !== 'clean') throw Error('Owned runtime resources must be absent before workspace recovery');
174
- await disposeWorkspace(record, () => persist(path, record), directory);
174
+ await disposeWorkspace(record, () => persist(path, record), directory, { restoreOwnership });
175
175
  }
176
176
  await checkRetentionCapacity(directory);
177
177
  }
@@ -75,7 +75,7 @@ export async function checkpointWorkspace(record, baseline, tracked, policy, per
75
75
  await sync(join(workspace.path, 'recovery.json')); await sync(workspace.path);
76
76
  workspace.checkpoint = hash(content); persist();
77
77
  }
78
- export async function disposeWorkspace(record, persist, directory, { remove = rm } = {}) {
78
+ export async function disposeWorkspace(record, persist, directory, { remove = rm, restoreOwnership } = {}) {
79
79
  if (!record.workspace) return { status: 'not-applicable' };
80
80
  const workspace = record.workspace;
81
81
  if (record.cleanup?.status !== 'clean') throw Error('Owned runtime cleanup must be clean before workspace disposal');
@@ -96,8 +96,10 @@ export async function disposeWorkspace(record, persist, directory, { remove = rm
96
96
  if (error.code !== 'ENOENT' || await lstat(workspace.path).then(() => true, e => { if (e.code === 'ENOENT') return false; throw e; })) throw error;
97
97
  workspace.status = 'clean'; persist(); return { status: 'clean', retained: workspace.retained };
98
98
  }
99
+ await restoreOwnership?.(workspace.path);
99
100
  } else {
100
101
  await verify(record);
102
+ await restoreOwnership?.(workspace.path);
101
103
  const { copyEvidence } = await import('./implementation-runtime.mjs');
102
104
  const { sourceFiles, collectChanges } = await import('./implementation.mjs');
103
105
  let changes = [];
@@ -172,9 +172,9 @@ async function main() {
172
172
  telemetry.emit('execution.host-wait.ended', { status: 'acquired', durationMs: Date.now() - waitStarted });
173
173
  const ownershipDirectory = `${config.lock}.resources`;
174
174
  runtimeReceipt.recoveredCleanup = recoverExecutionOwners(ownershipDirectory);
175
- await recoverExecutionWorkspaces(ownershipDirectory);
176
175
  const command = imageCommand(config.image);
177
176
  config.resourceOwner = createExecutionOwner(ownershipDirectory, { repository: request.repository ?? env.GITHUB_REPOSITORY, runId: request.runId, workflowRunId: String(env.GITHUB_RUN_ID), attempt: Number(env.GITHUB_RUN_ATTEMPT) });
177
+ await recoverExecutionWorkspaces(ownershipDirectory, { restoreOwnership: root => restoreWorkspaceOwnership(root, config) });
178
178
  dir = await config.resourceOwner.allocateWorkspace(env.RUNNER_TEMP);
179
179
  source = join(dir, 'source'); output = join(dir, 'output');
180
180
  await mkdir(source); await mkdir(output); await chmod(output, 0o777);
@@ -409,7 +409,7 @@ async function main() {
409
409
  runtime?.cleanup();
410
410
  try { if (config.resourceOwner) docker(['run', '--rm', '--network', 'none', '--user', `${config.uid}:${config.uid}`, '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--mount', `type=volume,src=${config.authVolume},dst=/home/engine/.local/share/opencode`, config.image, 'cleanup-session', `ses_${request.runId}`]); } catch { console.error('Session cleanup failed; operator inspection required'); }
411
411
  // Read-only stages also create engine-owned command receipt directories.
412
- try { if (config.resourceOwner) restoreWorkspaceOwnership(dir, config); } catch { console.error('Workspace ownership cleanup failed; operator inspection required'); }
412
+ try { if (config.resourceOwner && dir) restoreWorkspaceOwnership(dir, config); } catch { console.error('Workspace ownership cleanup failed; operator inspection required'); }
413
413
  try {
414
414
  if (config.resourceOwner) { runtimeReceipt.cleanup = config.resourceOwner.cleanup(); await writeFile(join(runDir, 'runtime.json'), JSON.stringify(runtimeReceipt)); }
415
415
  try { await mkdir(join(runDir, 'evidence/host'), { recursive: true }); await copyFile(join(output, 'execution/native-events.jsonl'), join(runDir, 'evidence/host/native-events.jsonl')); } catch { telemetry.emit('collection.capability', { capability: 'opencode-native', status: 'unavailable', reasonCode: 'native-file-unavailable' }); }
@@ -434,9 +434,16 @@ async function main() {
434
434
  await writeFile(join(runDir, 'evidence/host/telemetry-usage.json'), JSON.stringify(usageSummary(events, { health: [telemetry.health()] })));
435
435
  runtimeReceipt.telemetry = telemetry.health(); await writeFile(join(runDir, 'runtime.json'), JSON.stringify(runtimeReceipt));
436
436
  } catch { console.error('Telemetry retention incomplete; inspect collector health.'); }
437
- if (workspaceCleanupError) throw workspaceCleanupError;
437
+ if (workspaceCleanupError) {
438
+ console.error(progressText('Cleanup', redactLog(workspaceCleanupError.message)));
439
+ if (!runtimeReceipt.failure) throw workspaceCleanupError;
440
+ }
438
441
  } finally { if (slot !== undefined) closeSync(slot); }
439
- if (runtimeReceipt.cleanup && runtimeReceipt.cleanup.status !== 'clean') throw Object.assign(Error('Execution cleanup is not verified; inspect runtime.json and the operator ownership journal before retrying'), { phase: 'cleanup' });
442
+ if (runtimeReceipt.cleanup && runtimeReceipt.cleanup.status !== 'clean') {
443
+ const cleanupError = Object.assign(Error('Execution cleanup is not verified; inspect runtime.json and the operator ownership journal before retrying'), { phase: 'cleanup' });
444
+ console.error(progressText('Cleanup', cleanupError.message));
445
+ if (!runtimeReceipt.failure) throw cleanupError;
446
+ }
440
447
  }
441
448
  }
442
449
  if (process.argv[1] && resolve(process.argv[1]) === fileURLToPath(import.meta.url)) main().catch(async error => {