@juangcarmona/lighthouse-sdlc 0.23.6 → 0.23.8
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
|
@@ -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 = [];
|
package/src/opencode-execute.mjs
CHANGED
|
@@ -172,9 +172,10 @@ 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
|
-
config.resourceOwner
|
|
176
|
+
const ensureOwner = () => 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 => { ensureOwner(); restoreWorkspaceOwnership(root, config); } });
|
|
178
|
+
ensureOwner();
|
|
178
179
|
dir = await config.resourceOwner.allocateWorkspace(env.RUNNER_TEMP);
|
|
179
180
|
source = join(dir, 'source'); output = join(dir, 'output');
|
|
180
181
|
await mkdir(source); await mkdir(output); await chmod(output, 0o777);
|
|
@@ -409,7 +410,7 @@ async function main() {
|
|
|
409
410
|
runtime?.cleanup();
|
|
410
411
|
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
412
|
// 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'); }
|
|
413
|
+
try { if (config.resourceOwner && dir) restoreWorkspaceOwnership(dir, config); } catch { console.error('Workspace ownership cleanup failed; operator inspection required'); }
|
|
413
414
|
try {
|
|
414
415
|
if (config.resourceOwner) { runtimeReceipt.cleanup = config.resourceOwner.cleanup(); await writeFile(join(runDir, 'runtime.json'), JSON.stringify(runtimeReceipt)); }
|
|
415
416
|
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' }); }
|