@riddledc/riddle-proof 0.8.30 → 0.8.32

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.
Files changed (49) hide show
  1. package/dist/advanced/engine-harness.cjs +132 -10
  2. package/dist/advanced/engine-harness.js +2 -2
  3. package/dist/advanced/index.cjs +132 -10
  4. package/dist/advanced/index.d.cts +2 -2
  5. package/dist/advanced/index.d.ts +2 -2
  6. package/dist/advanced/index.js +4 -4
  7. package/dist/advanced/proof-run-core.cjs +3 -1
  8. package/dist/advanced/proof-run-core.d.cts +1 -1
  9. package/dist/advanced/proof-run-core.d.ts +1 -1
  10. package/dist/advanced/proof-run-core.js +1 -1
  11. package/dist/advanced/proof-run-engine.cjs +80 -1
  12. package/dist/advanced/proof-run-engine.d.cts +2 -2
  13. package/dist/advanced/proof-run-engine.d.ts +2 -2
  14. package/dist/advanced/proof-run-engine.js +2 -2
  15. package/dist/advanced/runner.js +2 -2
  16. package/dist/{chunk-3OTO7IDH.js → chunk-C2NHHBFV.js} +1 -1
  17. package/dist/{chunk-32RE64IO.js → chunk-IOI6QR3B.js} +78 -1
  18. package/dist/{chunk-XJA2GDVN.js → chunk-U73JPBZW.js} +1 -1
  19. package/dist/{chunk-K6HZUSHH.js → chunk-X7SQTCIQ.js} +3 -1
  20. package/dist/{chunk-UWO4YR7I.js → chunk-ZREWMTFA.js} +53 -10
  21. package/dist/cli/index.js +3 -3
  22. package/dist/cli.cjs +132 -10
  23. package/dist/cli.js +3 -3
  24. package/dist/engine-harness.cjs +132 -10
  25. package/dist/engine-harness.js +2 -2
  26. package/dist/index.cjs +132 -10
  27. package/dist/index.js +3 -3
  28. package/dist/{proof-run-core-C8FDUhle.d.cts → proof-run-core-B1GeqkR8.d.cts} +2 -0
  29. package/dist/{proof-run-core-C8FDUhle.d.ts → proof-run-core-B1GeqkR8.d.ts} +2 -0
  30. package/dist/proof-run-core.cjs +3 -1
  31. package/dist/proof-run-core.d.cts +1 -1
  32. package/dist/proof-run-core.d.ts +1 -1
  33. package/dist/proof-run-core.js +1 -1
  34. package/dist/{proof-run-engine-By7oLsF-.d.ts → proof-run-engine-DYfmd8d7.d.ts} +4 -4
  35. package/dist/{proof-run-engine-D80hVFMf.d.cts → proof-run-engine-DeHxtGnW.d.cts} +4 -4
  36. package/dist/proof-run-engine.cjs +80 -1
  37. package/dist/proof-run-engine.d.cts +2 -2
  38. package/dist/proof-run-engine.d.ts +2 -2
  39. package/dist/proof-run-engine.js +2 -2
  40. package/dist/runner.js +2 -2
  41. package/lib/workspace-core.mjs +62 -7
  42. package/package.json +2 -2
  43. package/runtime/lib/riddle_core_call.mjs +662 -40
  44. package/runtime/lib/ship.py +363 -16
  45. package/runtime/lib/util.py +117 -40
  46. package/runtime/lib/verify.py +4 -3
  47. package/runtime/pipelines/riddle-proof-ship.lobster +11 -1
  48. package/runtime/tests/recon_verify_smoke.py +132 -0
  49. package/runtime/tests/ship_artifact_publication.py +185 -0
@@ -180,6 +180,7 @@ function buildSetupArgs(params, config) {
180
180
  discord_thread_id: params.discord_thread_id || "",
181
181
  discord_message_id: params.discord_message_id || "",
182
182
  discord_source_url: params.discord_source_url || "",
183
+ ship_mode: params.ship_mode || "",
183
184
  leave_draft: params.leave_draft ? "true" : ""
184
185
  };
185
186
  }
@@ -951,7 +952,8 @@ function mergeStateFromParams(statePath, params) {
951
952
  "auth_headers_json",
952
953
  "proof_plan",
953
954
  "implementation_notes",
954
- "implementation_mode"
955
+ "implementation_mode",
956
+ "ship_mode"
955
957
  ];
956
958
  for (const field of stringFields) {
957
959
  if (params[field] !== void 0) {
@@ -1363,6 +1365,72 @@ var RUNTIME_EVENT_LIMIT = 100;
1363
1365
  function nowIso() {
1364
1366
  return (/* @__PURE__ */ new Date()).toISOString();
1365
1367
  }
1368
+ function missingExecutableError(error) {
1369
+ return error?.code === "ENOENT" || /\bENOENT\b/.test(String(error?.message || error || ""));
1370
+ }
1371
+ function pythonScriptsForBundledStage(step) {
1372
+ if (step === "setup") return ["preflight.py", "setup.py"];
1373
+ if (step === "recon") return ["recon.py"];
1374
+ if (step === "author") return ["author.py"];
1375
+ if (step === "implement") return ["implement.py"];
1376
+ if (step === "verify") return ["verify.py"];
1377
+ if (step === "ship") return ["ship.py"];
1378
+ return [];
1379
+ }
1380
+ function runBundledPythonStage(step, runtimeDir, env) {
1381
+ const scripts = pythonScriptsForBundledStage(step);
1382
+ if (!scripts.length) {
1383
+ return {
1384
+ ok: false,
1385
+ error: `No bundled Python fallback is defined for ${step}.`
1386
+ };
1387
+ }
1388
+ const pythonCommand = process.env.RIDDLE_PROOF_PYTHON_COMMAND || "python3";
1389
+ const libDir = import_node_path2.default.join(runtimeDir, "lib");
1390
+ const stdout = [];
1391
+ const stderr = [];
1392
+ const executed = [];
1393
+ try {
1394
+ for (const script of scripts) {
1395
+ const scriptPath = import_node_path2.default.join(libDir, script);
1396
+ if (!(0, import_node_fs2.existsSync)(scriptPath)) {
1397
+ return {
1398
+ ok: false,
1399
+ stdout: stdout.join(""),
1400
+ stderr: stderr.join(""),
1401
+ error: `Riddle Proof bundled Python fallback missing ${scriptPath}`
1402
+ };
1403
+ }
1404
+ executed.push(script);
1405
+ stdout.push((0, import_node_child_process.execFileSync)(pythonCommand, [scriptPath], {
1406
+ encoding: "utf-8",
1407
+ env,
1408
+ stdio: ["ignore", "pipe", "pipe"]
1409
+ }));
1410
+ }
1411
+ } catch (error) {
1412
+ return {
1413
+ ok: false,
1414
+ stdout: `${stdout.join("")}${String(error?.stdout || "")}`,
1415
+ stderr: `${stderr.join("")}${String(error?.stderr || "")}`,
1416
+ error: error?.message || String(error),
1417
+ raw: {
1418
+ runner: "bundled_python_fallback",
1419
+ scripts: executed
1420
+ }
1421
+ };
1422
+ }
1423
+ return {
1424
+ ok: true,
1425
+ stdout: stdout.join(""),
1426
+ stderr: stderr.join(""),
1427
+ raw: {
1428
+ ok: true,
1429
+ runner: "bundled_python_fallback",
1430
+ scripts: executed
1431
+ }
1432
+ };
1433
+ }
1366
1434
  function appendRuntimeEventToState(state, event) {
1367
1435
  const events = Array.isArray(state.runtime_events) ? state.runtime_events : [];
1368
1436
  state.runtime_events = [...events, event].slice(-RUNTIME_EVENT_LIMIT);
@@ -1929,6 +1997,17 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
1929
1997
  })
1930
1998
  );
1931
1999
  } catch (error) {
2000
+ if (!process.env.RIDDLE_PROOF_LOBSTER_SCRIPT && missingExecutableError(error)) {
2001
+ const fallback = runBundledPythonStage(step, config.riddleProofDir, env);
2002
+ return finishRuntimeStep(config.statePath, action, {
2003
+ ok: fallback.ok,
2004
+ step,
2005
+ raw: fallback.raw,
2006
+ stdout: fallback.stdout,
2007
+ stderr: fallback.stderr,
2008
+ error: fallback.error
2009
+ }, timer);
2010
+ }
1932
2011
  return finishRuntimeStep(config.statePath, action, {
1933
2012
  ok: false,
1934
2013
  step,
@@ -1,2 +1,2 @@
1
- import './proof-run-core-C8FDUhle.cjs';
2
- export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from './proof-run-engine-D80hVFMf.cjs';
1
+ import './proof-run-core-B1GeqkR8.cjs';
2
+ export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from './proof-run-engine-DeHxtGnW.cjs';
@@ -1,2 +1,2 @@
1
- import './proof-run-core-C8FDUhle.js';
2
- export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from './proof-run-engine-By7oLsF-.js';
1
+ import './proof-run-core-B1GeqkR8.js';
2
+ export { R as RiddleProofEngine, c as createRiddleProofEngine, e as executeWorkflow } from './proof-run-engine-DYfmd8d7.js';
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  createRiddleProofEngine,
3
3
  executeWorkflow
4
- } from "./chunk-32RE64IO.js";
5
- import "./chunk-K6HZUSHH.js";
4
+ } from "./chunk-IOI6QR3B.js";
5
+ import "./chunk-X7SQTCIQ.js";
6
6
  import "./chunk-MLKGABMK.js";
7
7
  export {
8
8
  createRiddleProofEngine,
package/dist/runner.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  runRiddleProof
3
- } from "./chunk-3OTO7IDH.js";
3
+ } from "./chunk-C2NHHBFV.js";
4
4
  import "./chunk-ZQWVXQKJ.js";
5
5
  import "./chunk-RDPG554T.js";
6
- import "./chunk-K6HZUSHH.js";
6
+ import "./chunk-X7SQTCIQ.js";
7
7
  import "./chunk-OILKSY5J.js";
8
8
  import "./chunk-VY4Y5U57.js";
9
9
  import "./chunk-MLKGABMK.js";
@@ -5,6 +5,7 @@ import {
5
5
  copyFileSync,
6
6
  lstatSync,
7
7
  mkdirSync,
8
+ readdirSync,
8
9
  readFileSync,
9
10
  renameSync,
10
11
  realpathSync,
@@ -18,7 +19,7 @@ import { fileURLToPath } from "node:url";
18
19
  const DEFAULT_RIDDLE_PROOF_SCRATCH_ROOT = "/var/tmp/riddle-proof";
19
20
 
20
21
  function commandEnv() {
21
- return { ...process.env, HOME: "/root" };
22
+ return { ...process.env, HOME: process.env.HOME || "/root" };
22
23
  }
23
24
 
24
25
  export function shellQuote(value) {
@@ -373,6 +374,53 @@ function writeDepsManifest(projectDir, fingerprint, installCmd) {
373
374
  writeFileSync(manifestPath, JSON.stringify({ fingerprint, install_cmd: installCmd }, null, 2));
374
375
  }
375
376
 
377
+ function hasOwnProperties(value) {
378
+ return Boolean(value && typeof value === "object" && Object.keys(value).length);
379
+ }
380
+
381
+ function installExpectsPackages(projectDir) {
382
+ try {
383
+ const packageJsonPath = path.join(projectDir, "package.json");
384
+ if (existsSync(packageJsonPath)) {
385
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
386
+ for (const key of ["dependencies", "devDependencies", "optionalDependencies", "bundleDependencies", "bundledDependencies"]) {
387
+ if (hasOwnProperties(packageJson[key])) return true;
388
+ }
389
+ }
390
+ } catch {
391
+ return true;
392
+ }
393
+
394
+ try {
395
+ const packageLockPath = path.join(projectDir, "package-lock.json");
396
+ if (existsSync(packageLockPath)) {
397
+ const packageLock = JSON.parse(readFileSync(packageLockPath, "utf-8"));
398
+ if (hasOwnProperties(packageLock.packages)) {
399
+ return Object.keys(packageLock.packages).some((key) => key.startsWith("node_modules/"));
400
+ }
401
+ if (hasOwnProperties(packageLock.dependencies)) return true;
402
+ }
403
+ } catch {
404
+ return true;
405
+ }
406
+
407
+ return false;
408
+ }
409
+
410
+ function nodeModulesUsable(projectDir) {
411
+ const projectModules = path.join(projectDir, "node_modules");
412
+ if (!existsSync(projectModules)) return !installExpectsPackages(projectDir);
413
+ try {
414
+ const hasInstalledEntries = readdirSync(projectModules).some((entry) => {
415
+ if (!entry || entry === DEPS_MANIFEST || entry === ".package-lock.json") return false;
416
+ return true;
417
+ });
418
+ return hasInstalledEntries || !installExpectsPackages(projectDir);
419
+ } catch {
420
+ return false;
421
+ }
422
+ }
423
+
376
424
  function dependencyCacheRoot(projectDir) {
377
425
  if (process.env.RIDDLE_PROOF_DISABLE_DEPS_CACHE === "1") return "";
378
426
  const configured = (process.env.RIDDLE_PROOF_DEPS_CACHE_ROOT || "").trim();
@@ -438,7 +486,7 @@ function tryEnsureCachedDeps({ projectDir, fingerprint, installCmd }) {
438
486
  const cacheDir = path.join(cacheRoot, dependencyCacheKey(fingerprint, installCmd));
439
487
  const cacheModules = path.join(cacheDir, "node_modules");
440
488
  const cacheManifest = readDepsManifest(cacheDir);
441
- if (cacheManifest.fingerprint === fingerprint && cacheManifest.install_cmd === installCmd && existsSync(cacheModules)) {
489
+ if (cacheManifest.fingerprint === fingerprint && cacheManifest.install_cmd === installCmd && nodeModulesUsable(cacheDir)) {
442
490
  materializeNodeModules(projectDir, cacheModules);
443
491
  return `reused_cache:${cacheDir}`;
444
492
  }
@@ -449,11 +497,15 @@ function tryEnsureCachedDeps({ projectDir, fingerprint, installCmd }) {
449
497
  removePath(tempCacheDir);
450
498
  copyDependencyInputs(projectDir, tempCacheDir);
451
499
 
452
- const installResult = runSafe(`${installCmd} 2>&1 | tail -5`, tempCacheDir, dependencyInstallTimeoutMs());
500
+ const installResult = runSafe(installCmd, tempCacheDir, dependencyInstallTimeoutMs());
453
501
  if (!installResult.ok) {
454
502
  removePath(tempCacheDir);
455
503
  return "";
456
504
  }
505
+ if (!nodeModulesUsable(tempCacheDir)) {
506
+ removePath(tempCacheDir);
507
+ return "";
508
+ }
457
509
  writeDepsManifest(tempCacheDir, fingerprint, installCmd);
458
510
 
459
511
  if (!existsSync(cacheDir)) {
@@ -467,7 +519,7 @@ function tryEnsureCachedDeps({ projectDir, fingerprint, installCmd }) {
467
519
  }
468
520
 
469
521
  const finalManifest = readDepsManifest(cacheDir);
470
- if (finalManifest.fingerprint === fingerprint && finalManifest.install_cmd === installCmd && existsSync(cacheModules)) {
522
+ if (finalManifest.fingerprint === fingerprint && finalManifest.install_cmd === installCmd && nodeModulesUsable(cacheDir)) {
471
523
  materializeNodeModules(projectDir, cacheModules);
472
524
  return `cached:${installCmd}`;
473
525
  }
@@ -487,7 +539,7 @@ export function ensureDeps({ projectDir, reuseFrom = "" } = {}) {
487
539
  if (!fingerprint) return "no_package_json";
488
540
 
489
541
  const existingManifest = readDepsManifest(projectDir);
490
- if (existingManifest.fingerprint === fingerprint && existsSync(path.join(projectDir, "node_modules"))) {
542
+ if (existingManifest.fingerprint === fingerprint && nodeModulesUsable(projectDir)) {
491
543
  return "already_installed";
492
544
  }
493
545
 
@@ -495,7 +547,7 @@ export function ensureDeps({ projectDir, reuseFrom = "" } = {}) {
495
547
  const sourceFingerprint = computeDependencyFingerprint(reuseFrom);
496
548
  const sourceManifest = readDepsManifest(reuseFrom);
497
549
  const sourceModules = path.join(reuseFrom, "node_modules");
498
- if (sourceFingerprint === fingerprint && sourceManifest.fingerprint === fingerprint && existsSync(sourceModules)) {
550
+ if (sourceFingerprint === fingerprint && sourceManifest.fingerprint === fingerprint && nodeModulesUsable(reuseFrom)) {
499
551
  materializeNodeModules(projectDir, sourceModules);
500
552
  return `reused_from:${reuseFrom}`;
501
553
  }
@@ -507,10 +559,13 @@ export function ensureDeps({ projectDir, reuseFrom = "" } = {}) {
507
559
  if (cachedStatus) return cachedStatus;
508
560
 
509
561
  removePath(path.join(projectDir, "node_modules"));
510
- const installResult = runSafe(`${installCmd} 2>&1 | tail -5`, projectDir, dependencyInstallTimeoutMs());
562
+ const installResult = runSafe(installCmd, projectDir, dependencyInstallTimeoutMs());
511
563
  if (!installResult.ok) {
512
564
  throw new Error(`dependency install failed in ${projectDir}: ${installResult.output.slice(0, 300)}`);
513
565
  }
566
+ if (!nodeModulesUsable(projectDir)) {
567
+ throw new Error(`dependency install produced no usable node_modules in ${projectDir}`);
568
+ }
514
569
  writeDepsManifest(projectDir, fingerprint, installCmd);
515
570
  return installCmd;
516
571
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.8.30",
3
+ "version": "0.8.32",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",
@@ -227,6 +227,6 @@
227
227
  "build": "npm --workspace @riddledc/riddle-proof-app-contract run build --if-present && tsup src/index.ts src/types.ts src/result.ts src/state.ts src/checkpoint.ts src/run-card.ts src/runner.ts src/engine-harness.ts src/codex-exec-agent.ts src/local-agent.ts src/cli.ts src/cli/index.ts src/diagnostics.ts src/proof-session.ts src/playability.ts src/basic-gameplay.ts src/profile.ts src/profile/index.ts src/openclaw.ts src/proof-run-core.ts src/proof-run-engine.ts src/riddle-client.ts src/runtime/riddle-client.ts src/spec/index.ts src/spec/types.ts src/spec/result.ts src/spec/state.ts src/spec/checkpoint.ts src/spec/run-card.ts src/runtime/index.ts src/app-contract/index.ts src/advanced/index.ts src/advanced/runner.ts src/advanced/engine-harness.ts src/advanced/proof-run-core.ts src/advanced/proof-run-engine.ts src/adapters/openclaw.ts src/adapters/local-agent.ts src/adapters/codex-exec-agent.ts src/adapters/codex.ts --format cjs,esm --dts --out-dir dist --clean",
228
228
  "clean": "rm -rf dist",
229
229
  "lint": "echo 'lint: (not configured)'",
230
- "test": "npm run build && node test.js && node proof-run.test.js && node trust-boundary.test.js && node regression-packs.test.js && python3 runtime/tests/trust_boundary_regression.py"
230
+ "test": "npm run build && node test.js && node proof-run.test.js && node trust-boundary.test.js && node regression-packs.test.js && python3 runtime/tests/trust_boundary_regression.py && python3 runtime/tests/ship_artifact_publication.py && (python3 runtime/tests/recon_verify_smoke.py >/tmp/riddle-proof-recon-verify-smoke.json || (tail -120 /tmp/riddle-proof-recon-verify-smoke.json; exit 1))"
231
231
  }
232
232
  }