@riddledc/riddle-proof 0.8.29 → 0.8.31

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 (46) hide show
  1. package/dist/advanced/engine-harness.cjs +188 -11
  2. package/dist/advanced/engine-harness.js +2 -2
  3. package/dist/advanced/index.cjs +188 -11
  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 +136 -2
  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-YC77HZVF.js → chunk-IOI6QR3B.js} +134 -2
  18. package/dist/{chunk-FJPZZ4JO.js → chunk-U73JPBZW.js} +1 -1
  19. package/dist/{chunk-K6HZUSHH.js → chunk-X7SQTCIQ.js} +3 -1
  20. package/dist/{chunk-AM3K5FPW.js → chunk-ZREWMTFA.js} +53 -10
  21. package/dist/cli/index.js +3 -3
  22. package/dist/cli.cjs +188 -11
  23. package/dist/cli.js +3 -3
  24. package/dist/engine-harness.cjs +188 -11
  25. package/dist/engine-harness.js +2 -2
  26. package/dist/index.cjs +188 -11
  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-D80hVFMf.d.cts → proof-run-engine-4dM37pEx.d.cts} +1 -1
  35. package/dist/{proof-run-engine-By7oLsF-.d.ts → proof-run-engine-BqaeqAze.d.ts} +1 -1
  36. package/dist/proof-run-engine.cjs +136 -2
  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/util.py +117 -40
  45. package/runtime/lib/verify.py +17 -4
  46. package/runtime/tests/recon_verify_smoke.py +137 -1
@@ -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.29",
3
+ "version": "0.8.31",
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/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
  }