@juangcarmona/lighthouse-sdlc 0.22.7 → 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.7",
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,7 +103,7 @@ 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; }
@@ -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);
@@ -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);