@juangcarmona/lighthouse-sdlc 0.22.6 → 0.22.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@juangcarmona/lighthouse-sdlc",
3
- "version": "0.22.6",
3
+ "version": "0.22.8",
4
4
  "type": "module",
5
5
  "description": "Provider-neutral SDLC skills, commands and route contracts for Lighthouse adopters",
6
6
  "repository": {
@@ -7,7 +7,14 @@ function boundedWait(seconds) {
7
7
  return seconds;
8
8
  }
9
9
 
10
- export const engineSlotWaitSeconds = config => boundedWait(config.engineSlotWaitSeconds === undefined ? 240 : config.engineSlotWaitSeconds);
10
+ export function engineSlotWaitSeconds(config, { deadline, now = Date.now() } = {}) {
11
+ const configured = boundedWait(config.engineSlotWaitSeconds === undefined ? 240 : config.engineSlotWaitSeconds);
12
+ if (deadline === undefined) return configured;
13
+ if (!Number.isSafeInteger(deadline)) throw Error('Invalid delivery execution deadline');
14
+ const remaining = Math.floor((deadline - now) / 1000);
15
+ if (remaining <= 0) throw Error('Delivery execution deadline exceeded');
16
+ return Math.min(config.engineSlotWaitSeconds === undefined ? 3600 : configured, remaining);
17
+ }
11
18
 
12
19
  export async function acquireEngineSlot(path, seconds = 240, { signal } = {}) {
13
20
  if (typeof path !== 'string' || !isAbsolute(path)) throw Error('Operator engine lock must be an absolute path');
@@ -103,14 +103,14 @@ export async function runImplementationChecks({ config, request, changes, worksp
103
103
  redact = text => originalRedact(redactEnvironmentLog(runtime, text));
104
104
  try {
105
105
  for (let i = 0; i < request.implementation.policy.checks.length; i++) {
106
- const deadline = Date.now() + 600000;
106
+ const deadline = Date.now() + 15 * 60_000;
107
107
  const command = request.implementation.policy.checks[i];
108
108
  const remaining = deadline - Date.now();
109
109
  if (cancelled() || remaining <= 0) { receipt.checks.push({ command, exitCode: 124 }); continue; }
110
110
  console.log(`Host check ${i + 1}: ${command.join(' ')}`);
111
111
  const checkStarted = Date.now(); telemetry?.emit('check.started', { callId: `check-${i + 1}`, status: 'running' });
112
112
  let log = '', pending = '', logTruncated = false;
113
- const args = ownedDockerArgs(config, ['run', '--rm', '--init', '--name', `${name}-checks`, '--user', `${config.uid}:${config.uid}`, ...resourceArgs(limits), '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--read-only', '--tmpfs', '/tmp:rw,exec,size=1g,mode=1777', '--env', 'HOME=/tmp', '--env', 'CI=true', ...scratchArgs, '--env', 'PLAYWRIGHT_BROWSERS_PATH=/workspace/.cache/ms-playwright', ...environmentArgs(runtime), '--mount', `type=bind,src=${workspace},dst=/workspace`, '--mount', `type=bind,src=${harness},dst=/harness,readonly`, '--mount', `type=bind,src=${output},dst=/diagnostics`, '--workdir', '/workspace', '--entrypoint', 'sh', config.image, '-c', checkOutputCommand, 'lighthouse-check', `check-${i + 1}`, '--', ...command]);
113
+ const args = ownedDockerArgs(config, ['run', '--rm', '--init', '--name', `${name}-checks`, '--user', `${config.uid}:${config.uid}`, ...resourceArgs(limits), '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--read-only', '--tmpfs', '/tmp:rw,exec,size=2g,mode=1777', '--env', 'HOME=/tmp', '--env', 'CI=true', ...scratchArgs, '--env', 'PLAYWRIGHT_BROWSERS_PATH=/workspace/.cache/ms-playwright', ...environmentArgs(runtime), '--mount', `type=bind,src=${workspace},dst=/workspace`, '--mount', `type=bind,src=${harness},dst=/harness,readonly`, '--mount', `type=bind,src=${output},dst=/diagnostics`, '--workdir', '/workspace', '--entrypoint', 'sh', config.image, '-c', checkOutputCommand, 'lighthouse-check', `check-${i + 1}`, '--', ...command]);
114
114
  let reason = null;
115
115
  const exit = await new Promise(resolve => {
116
116
  const child = spawn('docker', args, { stdio: ['ignore', 'pipe', 'pipe'] });
@@ -161,7 +161,8 @@ async function main() {
161
161
  try {
162
162
  console.log('Waiting for the operator host engine slot');
163
163
  const waitStarted = Date.now(); telemetry.emit('execution.host-wait.started', { status: 'waiting' });
164
- slot = await acquireEngineSlot(config.lock, engineSlotWaitSeconds(config), { signal: preparation.signal });
164
+ const deliveryDeadline = env.LIGHTHOUSE_DELIVERY_DEADLINE === undefined ? undefined : Number(env.LIGHTHOUSE_DELIVERY_DEADLINE);
165
+ slot = await acquireEngineSlot(config.lock, engineSlotWaitSeconds(config, { deadline: deliveryDeadline }), { signal: preparation.signal });
165
166
  telemetry.emit('execution.host-wait.ended', { status: 'acquired', durationMs: Date.now() - waitStarted });
166
167
  const ownershipDirectory = `${config.lock}.resources`;
167
168
  runtimeReceipt.recoveredCleanup = recoverExecutionOwners(ownershipDirectory);
@@ -244,7 +245,7 @@ async function main() {
244
245
  nativeTimer = setInterval(nativeCollect, 1000);
245
246
  phase = 'execution'; await recordPhase('running');
246
247
  const args = ownedDockerArgs(config, ['run', '--rm', '--init', '--name', name, '--user', `${config.uid}:${config.uid}`, ...resourceArgs(limits), '--cap-drop', 'ALL', '--security-opt', 'no-new-privileges', '--read-only',
247
- '--tmpfs', '/tmp:rw,exec,size=1g,mode=1777', '--tmpfs', `/home/engine/.cache:rw,size=1g,uid=${config.uid},gid=${config.uid}`, '--tmpfs', `/home/engine/.config:rw,size=16m,uid=${config.uid},gid=${config.uid}`, '--tmpfs', `/home/engine/.local/state:rw,size=64m,uid=${config.uid},gid=${config.uid}`,
248
+ '--tmpfs', '/tmp:rw,exec,size=2g,mode=1777', '--tmpfs', `/home/engine/.cache:rw,size=1g,uid=${config.uid},gid=${config.uid}`, '--tmpfs', `/home/engine/.config:rw,size=16m,uid=${config.uid},gid=${config.uid}`, '--tmpfs', `/home/engine/.local/state:rw,size=64m,uid=${config.uid},gid=${config.uid}`,
248
249
  '--mount', `type=bind,src=${source},dst=/workspace${implementing ? '' : ',readonly'}`, '--mount', `type=bind,src=${output},dst=/output`, '--mount', `type=bind,src=${context},dst=/input/context.json,readonly`, '--mount', `type=bind,src=${prompt},dst=/input/prompt.txt,readonly`, '--mount', `type=bind,src=${harness},dst=/harness,readonly`,
249
250
  ...(codegraph.status === 'available' ? ['--mount', `type=bind,src=${codegraph.state},dst=/codegraph,readonly`] : []),
250
251
  ...(workerConfigPath ? ['--mount', `type=bind,src=${workerConfigPath},dst=/etc/opencode/opencode.json,readonly`, '--env', 'LIGHTHOUSE_NATIVE_TELEMETRY_FILE=/output/execution/native-events.jsonl'] : []),
@@ -149,7 +149,7 @@ export async function runGithubUnattended({ env = process.env, api = (...args) =
149
149
  const context = { ...stageContext(request, issueContext), unattended: { route, eligibility: refined?.eligibility, scope: policy.paths, implementationChecks: selectedPolicy.checks }, ...extra };
150
150
  if (Buffer.byteLength(JSON.stringify(context)) > 2 * 1024 * 1024) throw Error('Review or execution context exceeds its 2 MiB bound');
151
151
  const result = await execute({ env, root, request, source: working, context,
152
- prompt: 'Use context.unattended.implementationChecks to plan verification; this admitted inventory is not an execution receipt. Keep additional agent observations and later forge CI explicit. ' + text, ...(worker === 'independent-review' ? { modelProfile: policy.reviewerProfile } : {}), signal: controller.signal });
152
+ prompt: 'Use context.unattended.implementationChecks to plan verification; this admitted inventory is not an execution receipt. Keep additional agent observations and later forge CI explicit. ' + text, ...(worker === 'independent-review' ? { modelProfile: policy.reviewerProfile } : {}), signal: controller.signal, deadline });
153
153
  if (result.runtime.execution?.status !== 'passed') throw Error('Host cannot verify completed model execution');
154
154
  if (stage === 'implement' && (!Array.isArray(result.receipt?.checks) || result.receipt.checks.length !== selectedPolicy.checks.length || result.receipt.checks.some((check, index) => JSON.stringify(check.command) !== JSON.stringify(selectedPolicy.checks[index]) || !Number.isInteger(check.exitCode) || check.exitCode === 0 && check.execution?.status !== 'passed'))) throw Error('Required host check inventory is unavailable or differs from the admitted policy');
155
155
  if (worker === 'independent-review' && result.runtime.model !== reviewer.model || stage === 'implement' && result.runtime.model !== producer.model) throw Error('Operator model selection changed during delivery');
@@ -83,7 +83,7 @@ export function stageContext(request, issue) {
83
83
  }
84
84
 
85
85
  // Uses the existing credential-free Docker engine; GitHub credentials stay in this host.
86
- export async function executeUnattendedStage({ env, root, request, source, context, prompt, modelProfile, signal }) {
86
+ export async function executeUnattendedStage({ env, root, request, source, context, prompt, modelProfile, signal, deadline }) {
87
87
  const serializedContext = JSON.stringify(context, null, 2);
88
88
  if (Buffer.byteLength(serializedContext) > 2 * 1024 * 1024) throw Error('Execution context exceeds its 2 MiB bound');
89
89
  const step = join(root, request.runId), workspace = join(step, 'workspace'), runnerTemp = join(step, 'tmp');
@@ -99,6 +99,7 @@ export async function executeUnattendedStage({ env, root, request, source, conte
99
99
  for (const key of ['PATH', 'HOME', 'TMPDIR', 'LIGHTHOUSE_ENGINE_CONFIG', 'GITHUB_RUN_ID', 'GITHUB_RUN_ATTEMPT']) if (env[key]) childEnv[key] = env[key];
100
100
  Object.assign(childEnv, { RUNNER_TEMP: runnerTemp, GITHUB_WORKSPACE: workspace, GH_AW_PROMPT: promptPath, GH_AW_SAFE_OUTPUTS: join(step, 'safe-outputs.json'), LIGHTHOUSE_WORKER: request.worker ?? request.stage });
101
101
  if (modelProfile) childEnv.LIGHTHOUSE_MODEL_PROFILE = modelProfile;
102
+ if (deadline !== undefined) childEnv.LIGHTHOUSE_DELIVERY_DEADLINE = String(deadline);
102
103
  await new Promise((resolve, reject) => {
103
104
  const child = spawn(process.execPath, [fileURLToPath(new URL('./opencode-execute.mjs', import.meta.url))], { env: childEnv, stdio: 'inherit', signal });
104
105
  child.once('error', reject);