@juangcarmona/lighthouse-sdlc 0.22.7 → 0.22.9

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/github-actions.md CHANGED
@@ -132,6 +132,12 @@ The [router](workflows/lighthouse-sdlc-router.yml) and [event handler](src/issue
132
132
 
133
133
  The `apply-review` worker is installed with proposal support. It also handles implementation feedback when implementation is installed, preserving its `implement` result. Verified feedback has a stable dispatch identity across repeated events. Approval retains its separate integration route.
134
134
 
135
+ ## GitHub read recovery
136
+
137
+ Bodyless GitHub GET requests can make up to three total HTTP attempts, including the initial attempt, for responses 429, 500, 502, 503 and 504. All attempts and waits share the original thirty-second request budget; `Retry-After` is respected only when its delay fits the remaining budget. This transport retry does not automatically repeat POST/PATCH/PUT/DELETE, permanent refusals, thrown network errors or uncertain publication effects.
138
+
139
+ This reduces transient-read interruptions during unattended observation, but does not establish publication or delivery success. Exhausted HTTP reads retain their terminal diagnostic, including a safe provider message when available. Unknown publication still requires inspecting and reconciling actual effects through [Worker maintenance](#worker-maintenance) and [Worker error reports](#worker-error-reports) before another request.
140
+
135
141
  ## Worker maintenance
136
142
 
137
143
  Install the optional deterministic workflow with `--with-maintenance`. After reviewing its permissions, set `LIGHTHOUSE_MAINTENANCE_ENABLED=true` and the existing `LIGHTHOUSE_AUTOMATION_ENABLED=true` to observe owner issues every 30 minutes, or dispatch a single issue manually. Failed `review` preparation sends an authenticated callback to maintenance when recovery is enabled. The receiver waits for terminal native jobs before considering a retry. Native `workflow_run` completion also wakes this same reconciler; unrelated or uncertain completions select no issue. Observation alone performs no retry. Set `LIGHTHOUSE_RECOVERY_ENABLED=true` separately to permit bounded recovery; removing it also stops admission of already-requested retries.
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.9",
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; }
@@ -153,15 +153,25 @@ async function main() {
153
153
  const phaseStarted = new Map();
154
154
  const recordPhase = async status => { runtimeReceipt.phases[phase] = status; if (status === 'running') phaseStarted.set(phase, Date.now()); telemetry.emit('execution.phase', { phase, status, durationMs: phaseStarted.has(phase) ? Date.now() - phaseStarted.get(phase) : null }); await writeFile(join(runDir, 'runtime.json'), JSON.stringify(runtimeReceipt)); };
155
155
  const docker = args => runOwnedDocker(config, args, { stdio: 'ignore', timeout: 30000 });
156
- let child, timer, heartbeat, slot, baseline, trackedSource, planningBaseline, runtime, codegraph, eventsPath, cancelled = false, stopReason = null;
156
+ let child, timer, heartbeat, controllerWatch, slot, baseline, trackedSource, planningBaseline, runtime, codegraph, eventsPath, cancelled = false, stopReason = null;
157
157
  const preparation = new AbortController();
158
158
  const cancel = (reason = 'cancelled') => { cancelled = true; preparation.abort(); stopReason ??= reason; try { config.resourceOwner?.observe(); } catch {} child?.kill('SIGTERM'); try { if (name) docker(['rm', '-f', name, `${name}-checks`]); } catch {} };
159
159
  const onSignal = () => cancel();
160
+ const controllerPid = env.LIGHTHOUSE_ENGINE_CONTROLLER_PID === undefined ? (process.ppid > 1 ? process.ppid : null) : Number(env.LIGHTHOUSE_ENGINE_CONTROLLER_PID);
161
+ const checkController = () => {
162
+ if (controllerPid === null || process.ppid === controllerPid) return true;
163
+ cancel('controller-exited'); return false;
164
+ };
160
165
  process.once('SIGTERM', onSignal); process.once('SIGINT', onSignal);
161
166
  try {
167
+ if (controllerPid !== null && (!Number.isSafeInteger(controllerPid) || controllerPid < 1)) throw Error('Invalid engine controller identity');
168
+ if (!checkController()) throw Error('Engine controller is no longer active');
169
+ if (controllerPid !== null) controllerWatch = setInterval(checkController, 500).unref();
162
170
  console.log('Waiting for the operator host engine slot');
163
171
  const waitStarted = Date.now(); telemetry.emit('execution.host-wait.started', { status: 'waiting' });
164
- slot = await acquireEngineSlot(config.lock, engineSlotWaitSeconds(config), { signal: preparation.signal });
172
+ const deliveryDeadline = env.LIGHTHOUSE_DELIVERY_DEADLINE === undefined ? undefined : Number(env.LIGHTHOUSE_DELIVERY_DEADLINE);
173
+ slot = await acquireEngineSlot(config.lock, engineSlotWaitSeconds(config, { deadline: deliveryDeadline }), { signal: preparation.signal });
174
+ if (!checkController()) throw Error('Engine controller is no longer active');
165
175
  telemetry.emit('execution.host-wait.ended', { status: 'acquired', durationMs: Date.now() - waitStarted });
166
176
  const ownershipDirectory = `${config.lock}.resources`;
167
177
  runtimeReceipt.recoveredCleanup = recoverExecutionOwners(ownershipDirectory);
@@ -171,7 +181,7 @@ async function main() {
171
181
  await recordPhase('running');
172
182
  runtime = await startEnvironment({ selected, image: config.image, commands: implementing ? [['git'], ['sh'], ...(request.implementation.policy.checks ?? [])] : [], name: `${name}-agent`, uid: config.uid, run: args => runOwnedDocker(config, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'], timeout: 30000 }) });
173
183
  await recordPhase('passed');
174
- if (cancelled) throw Error('Execution cancelled before agent startup');
184
+ if (cancelled || !checkController()) throw Error('Execution cancelled before agent startup');
175
185
  console.log('Engine slot acquired; starting isolated OpenCode');
176
186
  await snapshotSource(env.GITHUB_WORKSPACE, source);
177
187
  if (request.worker === 'product-change') {
@@ -387,7 +397,7 @@ async function main() {
387
397
  try { await mkdir(join(runDir, 'evidence/host'), { recursive: true }); await copyFile(eventsPath, join(runDir, 'evidence/host/engine-events.jsonl')); }
388
398
  catch { console.error('Engine events could not be retained; inspect the runner diagnostics.'); }
389
399
  }
390
- clearTimeout(timer); clearInterval(heartbeat); process.removeListener('SIGTERM', onSignal); process.removeListener('SIGINT', onSignal);
400
+ clearTimeout(timer); clearInterval(heartbeat); clearInterval(controllerWatch); process.removeListener('SIGTERM', onSignal); process.removeListener('SIGINT', onSignal);
391
401
  try { if (name) docker(['rm', '-f', name, `${name}-checks`]); } catch {}
392
402
  stopCodegraph(codegraph?.sidecar, config);
393
403
  runtime?.cleanup();
@@ -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');
@@ -97,8 +97,9 @@ export async function executeUnattendedStage({ env, root, request, source, conte
97
97
  const promptPath = join(step, 'prompt.md'); await writeFile(promptPath, prompt);
98
98
  const childEnv = {};
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
- 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 });
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, LIGHTHOUSE_ENGINE_CONTROLLER_PID: String(process.pid) });
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);