@riddledc/riddle-proof 0.5.3 → 0.5.4

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.
@@ -296,6 +296,20 @@ function requirePayload(action, payload, state, result) {
296
296
  }
297
297
  return null;
298
298
  }
299
+ function engineFailureBlocker(result, checkpoint) {
300
+ if (result.ok !== false) return null;
301
+ if (!checkpoint.endsWith("_failed") && !checkpoint.endsWith("_blocked")) return null;
302
+ return {
303
+ code: checkpoint,
304
+ checkpoint,
305
+ message: result.summary || `Riddle Proof engine stopped at ${checkpoint}.`,
306
+ details: compactRecord({
307
+ error: result.error,
308
+ approval: result.approval,
309
+ checkpointContract: result.checkpointContract || null
310
+ })
311
+ };
312
+ }
299
313
  function terminalResult(state, status, result, summary, raw = {}) {
300
314
  setRunStatus(state, status);
301
315
  const metadata = normalizeTerminalMetadata({
@@ -453,6 +467,10 @@ async function routeCheckpoint(request, state, result, agent, input) {
453
467
  terminal: terminalResult(state, "completed", result, result.summary || "Riddle Proof engine completed.")
454
468
  };
455
469
  }
470
+ const failureBlocker = engineFailureBlocker(result, checkpoint);
471
+ if (failureBlocker) {
472
+ return { blocker: failureBlocker };
473
+ }
456
474
  if ([
457
475
  "recon_human_escalation",
458
476
  "verify_human_escalation",
@@ -3266,6 +3266,20 @@ function requirePayload(action, payload, state, result) {
3266
3266
  }
3267
3267
  return null;
3268
3268
  }
3269
+ function engineFailureBlocker(result, checkpoint) {
3270
+ if (result.ok !== false) return null;
3271
+ if (!checkpoint.endsWith("_failed") && !checkpoint.endsWith("_blocked")) return null;
3272
+ return {
3273
+ code: checkpoint,
3274
+ checkpoint,
3275
+ message: result.summary || `Riddle Proof engine stopped at ${checkpoint}.`,
3276
+ details: compactRecord({
3277
+ error: result.error,
3278
+ approval: result.approval,
3279
+ checkpointContract: result.checkpointContract || null
3280
+ })
3281
+ };
3282
+ }
3269
3283
  function terminalResult(state, status, result, summary, raw = {}) {
3270
3284
  setRunStatus(state, status);
3271
3285
  const metadata = normalizeTerminalMetadata({
@@ -3423,6 +3437,10 @@ async function routeCheckpoint(request, state, result, agent, input) {
3423
3437
  terminal: terminalResult(state, "completed", result, result.summary || "Riddle Proof engine completed.")
3424
3438
  };
3425
3439
  }
3440
+ const failureBlocker = engineFailureBlocker(result, checkpoint);
3441
+ if (failureBlocker) {
3442
+ return { blocker: failureBlocker };
3443
+ }
3426
3444
  if ([
3427
3445
  "recon_human_escalation",
3428
3446
  "verify_human_escalation",
@@ -2,7 +2,7 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-MLJJIKTP.js";
5
+ } from "./chunk-GC7C2NRA.js";
6
6
  import "./chunk-GVPCSXN7.js";
7
7
  import "./chunk-TMMKRKY5.js";
8
8
  export {
package/dist/index.cjs CHANGED
@@ -3825,6 +3825,20 @@ function requirePayload(action, payload, state, result) {
3825
3825
  }
3826
3826
  return null;
3827
3827
  }
3828
+ function engineFailureBlocker(result, checkpoint) {
3829
+ if (result.ok !== false) return null;
3830
+ if (!checkpoint.endsWith("_failed") && !checkpoint.endsWith("_blocked")) return null;
3831
+ return {
3832
+ code: checkpoint,
3833
+ checkpoint,
3834
+ message: result.summary || `Riddle Proof engine stopped at ${checkpoint}.`,
3835
+ details: compactRecord({
3836
+ error: result.error,
3837
+ approval: result.approval,
3838
+ checkpointContract: result.checkpointContract || null
3839
+ })
3840
+ };
3841
+ }
3828
3842
  function terminalResult(state, status, result, summary, raw = {}) {
3829
3843
  setRunStatus(state, status);
3830
3844
  const metadata = normalizeTerminalMetadata({
@@ -3982,6 +3996,10 @@ async function routeCheckpoint(request, state, result, agent, input) {
3982
3996
  terminal: terminalResult(state, "completed", result, result.summary || "Riddle Proof engine completed.")
3983
3997
  };
3984
3998
  }
3999
+ const failureBlocker = engineFailureBlocker(result, checkpoint);
4000
+ if (failureBlocker) {
4001
+ return { blocker: failureBlocker };
4002
+ }
3985
4003
  if ([
3986
4004
  "recon_human_escalation",
3987
4005
  "verify_human_escalation",
package/dist/index.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  createDisabledRiddleProofAgentAdapter,
14
14
  readRiddleProofRunStatus,
15
15
  runRiddleProofEngineHarness
16
- } from "./chunk-MLJJIKTP.js";
16
+ } from "./chunk-GC7C2NRA.js";
17
17
  import {
18
18
  runRiddleProof
19
19
  } from "./chunk-VSEKLCNU.js";
@@ -318,6 +318,11 @@ function writeDepsManifest(projectDir, fingerprint, installCmd) {
318
318
  writeFileSync(manifestPath, JSON.stringify({ fingerprint, install_cmd: installCmd }, null, 2));
319
319
  }
320
320
 
321
+ function dependencyInstallTimeoutMs() {
322
+ const parsed = Number.parseInt(process.env.RIDDLE_PROOF_INSTALL_TIMEOUT_MS || "", 10);
323
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : 600000;
324
+ }
325
+
321
326
  export function ensureDeps({ projectDir, reuseFrom = "" } = {}) {
322
327
  const fingerprint = computeDependencyFingerprint(projectDir);
323
328
  if (!fingerprint) return "no_package_json";
@@ -341,7 +346,7 @@ export function ensureDeps({ projectDir, reuseFrom = "" } = {}) {
341
346
 
342
347
  const installCmd = detectInstallCommand(projectDir);
343
348
  if (!installCmd) return "no_install_command";
344
- const installResult = runSafe(`${installCmd} 2>&1 | tail -5`, projectDir, 300000);
349
+ const installResult = runSafe(`${installCmd} 2>&1 | tail -5`, projectDir, dependencyInstallTimeoutMs());
345
350
  if (!installResult.ok) {
346
351
  throw new Error(`dependency install failed in ${projectDir}: ${installResult.output.slice(0, 300)}`);
347
352
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",
@@ -6,7 +6,7 @@ workspace root by default:
6
6
  <workspace>/.riddle-proof-worktrees/riddle-proof-<run_id>-after
7
7
  """
8
8
 
9
- import json, subprocess as sp, os, sys, shutil
9
+ import json, subprocess as sp, os, sys, shutil, time
10
10
  sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
11
11
  from util import load_state, save_state, git, shell_quote
12
12
 
@@ -37,6 +37,15 @@ SKILLS_ROOT = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__fil
37
37
  WORKSPACE_CORE = os.path.join(SKILLS_ROOT, 'lib', 'workspace-core.mjs')
38
38
 
39
39
 
40
+ def dependency_timeout_seconds():
41
+ raw = os.environ.get('RIDDLE_PROOF_INSTALL_TIMEOUT_MS', '').strip()
42
+ try:
43
+ millis = int(raw)
44
+ except Exception:
45
+ millis = 600000
46
+ return max(660, int((millis + 999) / 1000) + 30)
47
+
48
+
40
49
  def workspace_core(command, payload, timeout=180):
41
50
  if not os.path.exists(WORKSPACE_CORE):
42
51
  raise SystemExit('workspace core helper missing: ' + WORKSPACE_CORE)
@@ -64,10 +73,64 @@ def ensure_deps(project_dir, reuse_from=''):
64
73
  payload = {'projectDir': project_dir}
65
74
  if reuse_from:
66
75
  payload['reuseFrom'] = reuse_from
67
- result = workspace_core('ensure-deps', payload, timeout=300)
76
+ result = workspace_core('ensure-deps', payload, timeout=dependency_timeout_seconds())
68
77
  return result.get('status', '')
69
78
 
70
79
 
80
+ def record_setup_phase(phase, status='running', summary=''):
81
+ global s
82
+ ts = time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime())
83
+ try:
84
+ current = load_state()
85
+ except Exception:
86
+ current = dict(s)
87
+ runtime_step = current.get('current_runtime_step') if isinstance(current.get('current_runtime_step'), dict) else {}
88
+ if not runtime_step:
89
+ runtime_step = {
90
+ 'step': 'setup',
91
+ 'action': 'run',
92
+ 'status': 'running',
93
+ 'started_at': ts,
94
+ 'workflow_file': 'riddle-proof-setup.lobster',
95
+ }
96
+ runtime_step['phase'] = phase
97
+ runtime_step['phase_status'] = status
98
+ if status == 'running':
99
+ runtime_step['phase_started_at'] = ts
100
+ runtime_step.pop('phase_finished_at', None)
101
+ else:
102
+ runtime_step['phase_finished_at'] = ts
103
+ if summary:
104
+ runtime_step['summary'] = summary
105
+ current['current_runtime_step'] = runtime_step
106
+ events = current.get('runtime_events') if isinstance(current.get('runtime_events'), list) else []
107
+ events.append({
108
+ 'ts': ts,
109
+ 'kind': 'workflow.phase.' + ('started' if status == 'running' else 'finished'),
110
+ 'step': 'setup',
111
+ 'phase': phase,
112
+ 'summary': summary or (phase + ' ' + status),
113
+ 'details': {'status': status},
114
+ })
115
+ current['runtime_events'] = events[-100:]
116
+ current['runtime_updated_at'] = ts
117
+ save_state(current)
118
+ for key in ('current_runtime_step', 'runtime_events', 'runtime_updated_at'):
119
+ if key in current:
120
+ s[key] = current[key]
121
+
122
+
123
+ def ensure_deps_phase(phase, project_dir, reuse_from='', summary=''):
124
+ record_setup_phase(phase, 'running', summary)
125
+ try:
126
+ status = ensure_deps(project_dir, reuse_from=reuse_from)
127
+ except BaseException as exc:
128
+ record_setup_phase(phase, 'failed', str(exc)[:300])
129
+ raise
130
+ record_setup_phase(phase, 'completed', status or 'no dependency install needed')
131
+ return status
132
+
133
+
71
134
  def resolve_worktree_root(repo_dir):
72
135
  configured = (s.get('worktree_root') or os.environ.get('RIDDLE_PROOF_WORKTREE_ROOT') or '').strip()
73
136
  if configured:
@@ -339,16 +402,16 @@ apply_repo_profile(AFTER_DIR)
339
402
  save_state(s)
340
403
 
341
404
  reuse_source = repo_dir if os.path.exists(os.path.join(repo_dir, 'package.json')) else ''
342
- shared_status = ensure_deps(reuse_source) if reuse_source else ''
405
+ shared_status = ensure_deps_phase('shared_deps', reuse_source, summary='Ensuring shared repository dependencies.') if reuse_source else ''
343
406
  if shared_status:
344
407
  print('Shared deps status: ' + shared_status)
345
408
 
346
409
  before_dep_status = ''
347
410
  if reference in ('before', 'both'):
348
- before_dep_status = ensure_deps(BEFORE_DIR, reuse_from=reuse_source)
411
+ before_dep_status = ensure_deps_phase('before_deps', BEFORE_DIR, reuse_from=reuse_source, summary='Ensuring before-worktree dependencies.')
349
412
  print('Before deps status: ' + before_dep_status)
350
413
 
351
- after_dep_status = ensure_deps(AFTER_DIR, reuse_from=reuse_source)
414
+ after_dep_status = ensure_deps_phase('after_deps', AFTER_DIR, reuse_from=reuse_source, summary='Ensuring after-worktree dependencies.')
352
415
  print('After deps status: ' + after_dep_status)
353
416
 
354
417
  # Patch Next.js config in after worktree if needed