@riddledc/riddle-proof 0.8.6 → 0.8.7

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/adapters/codex-exec-agent.cjs +30 -10
  2. package/dist/adapters/codex-exec-agent.js +1 -1
  3. package/dist/adapters/codex.cjs +30 -10
  4. package/dist/adapters/codex.js +1 -1
  5. package/dist/adapters/local-agent.cjs +30 -10
  6. package/dist/adapters/local-agent.js +1 -1
  7. package/dist/advanced/engine-harness.cjs +64 -7
  8. package/dist/advanced/engine-harness.js +2 -2
  9. package/dist/advanced/index.cjs +64 -7
  10. package/dist/advanced/index.d.cts +1 -1
  11. package/dist/advanced/index.d.ts +1 -1
  12. package/dist/advanced/index.js +4 -4
  13. package/dist/advanced/proof-run-core.cjs +63 -6
  14. package/dist/advanced/proof-run-core.js +1 -1
  15. package/dist/advanced/proof-run-engine.cjs +63 -6
  16. package/dist/advanced/proof-run-engine.d.cts +1 -1
  17. package/dist/advanced/proof-run-engine.d.ts +1 -1
  18. package/dist/advanced/proof-run-engine.js +2 -2
  19. package/dist/advanced/runner.js +2 -2
  20. package/dist/{chunk-GMZ57RRY.js → chunk-46DDSZJR.js} +1 -1
  21. package/dist/{chunk-RV6LK7HU.js → chunk-5N5QFI2S.js} +63 -6
  22. package/dist/{chunk-UIJ7X63P.js → chunk-5N6MQCLC.js} +1 -1
  23. package/dist/{chunk-BDFSMWTI.js → chunk-E7ATYSYS.js} +1 -1
  24. package/dist/{chunk-5MILMRQY.js → chunk-PYCQNK66.js} +30 -10
  25. package/dist/{chunk-NAFJ4KSF.js → chunk-V6VZ3CAI.js} +2 -2
  26. package/dist/cli/index.js +4 -4
  27. package/dist/cli.cjs +99 -22
  28. package/dist/cli.js +4 -4
  29. package/dist/codex-exec-agent.cjs +30 -10
  30. package/dist/codex-exec-agent.js +1 -1
  31. package/dist/engine-harness.cjs +64 -7
  32. package/dist/engine-harness.js +2 -2
  33. package/dist/index.cjs +99 -22
  34. package/dist/index.js +4 -4
  35. package/dist/local-agent.cjs +30 -10
  36. package/dist/local-agent.js +1 -1
  37. package/dist/proof-run-core.cjs +63 -6
  38. package/dist/proof-run-core.js +1 -1
  39. package/dist/{proof-run-engine-BO1h0Bmy.d.cts → proof-run-engine-B7DCPzpK.d.cts} +3 -3
  40. package/dist/{proof-run-engine-CIdpWNh6.d.ts → proof-run-engine-BomAcXhA.d.ts} +3 -3
  41. package/dist/proof-run-engine.cjs +63 -6
  42. package/dist/proof-run-engine.d.cts +1 -1
  43. package/dist/proof-run-engine.d.ts +1 -1
  44. package/dist/proof-run-engine.js +2 -2
  45. package/dist/runner.js +2 -2
  46. package/package.json +1 -1
  47. package/runtime/lib/author.py +39 -1
  48. package/runtime/lib/verify.py +37 -1
  49. package/runtime/tests/recon_verify_smoke.py +70 -8
@@ -379,6 +379,18 @@ function parseJsonObject(raw, schema) {
379
379
  }
380
380
  return null;
381
381
  }
382
+ function parseJsonFromRunnerOutputs(outputs, schema) {
383
+ const seen = /* @__PURE__ */ new Set();
384
+ for (const output of outputs) {
385
+ if (!output.text.trim() || seen.has(output.text)) continue;
386
+ seen.add(output.text);
387
+ const parsed = parseJsonObject(output.text, schema);
388
+ if (parsed) return { parsed, source: output.source };
389
+ }
390
+ const combined = outputs.map((output) => output.text).filter((text) => text.trim()).join("\n");
391
+ if (!combined.trim() || seen.has(combined)) return { parsed: null, source: "" };
392
+ return { parsed: parseJsonObject(combined, schema), source: "combined_output" };
393
+ }
382
394
  function isHarnessVerificationOnlyBlocker(blocker) {
383
395
  const text = blocker.toLowerCase();
384
396
  return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
@@ -398,6 +410,7 @@ function runnerMetrics(input) {
398
410
  stdout_chars: (input.stdout || "").length,
399
411
  stderr_chars: (input.stderr || "").length,
400
412
  final_message_chars: (input.finalText || "").length,
413
+ parsed_json_source: input.parsedJsonSource,
401
414
  exit_status: input.status ?? null,
402
415
  timed_out: input.timedOut || false,
403
416
  error_code: input.errorCode,
@@ -501,19 +514,25 @@ function createCodexExecJsonRunner(config = {}) {
501
514
  };
502
515
  }
503
516
  const finalText = (0, import_node_fs.existsSync)(lastMessagePath) ? (0, import_node_fs.readFileSync)(lastMessagePath, "utf-8") : String(proc.stdout || "");
504
- const parsed = parseJsonObject(finalText, request.schema);
517
+ const stdoutText = String(proc.stdout || "");
518
+ const stderrText = String(proc.stderr || "");
519
+ const { parsed, source: parsedJsonSource } = parseJsonFromRunnerOutputs([
520
+ { source: (0, import_node_fs.existsSync)(lastMessagePath) ? "last_message" : "stdout", text: finalText },
521
+ { source: "stdout", text: stdoutText },
522
+ { source: "stderr", text: stderrText }
523
+ ], request.schema);
505
524
  if (!parsed) {
506
525
  return {
507
526
  ok: false,
508
- stdout: proc.stdout || "",
509
- stderr: proc.stderr || "",
527
+ stdout: stdoutText,
528
+ stderr: stderrText,
510
529
  metrics: runnerMetrics({
511
530
  request,
512
531
  config,
513
532
  startedAt,
514
533
  startedMs,
515
- stdout: proc.stdout || "",
516
- stderr: proc.stderr || "",
534
+ stdout: stdoutText,
535
+ stderr: stderrText,
517
536
  finalText,
518
537
  status: proc.status,
519
538
  errorCode: "invalid_json"
@@ -521,23 +540,24 @@ function createCodexExecJsonRunner(config = {}) {
521
540
  blocker: {
522
541
  code: "codex_invalid_json",
523
542
  message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
524
- details: { finalText, stdout: proc.stdout || "", stderr: proc.stderr || "" }
543
+ details: { finalText, stdout: stdoutText, stderr: stderrText }
525
544
  }
526
545
  };
527
546
  }
528
547
  return {
529
548
  ok: true,
530
549
  json: parsed,
531
- stdout: proc.stdout || "",
532
- stderr: proc.stderr || "",
550
+ stdout: stdoutText,
551
+ stderr: stderrText,
533
552
  metrics: runnerMetrics({
534
553
  request,
535
554
  config,
536
555
  startedAt,
537
556
  startedMs,
538
- stdout: proc.stdout || "",
539
- stderr: proc.stderr || "",
557
+ stdout: stdoutText,
558
+ stderr: stderrText,
540
559
  finalText,
560
+ parsedJsonSource,
541
561
  status: proc.status
542
562
  })
543
563
  };
@@ -3,7 +3,7 @@ import {
3
3
  createCodexExecAgentAdapter,
4
4
  createCodexExecJsonRunner,
5
5
  runCodexExecAgentDoctor
6
- } from "../chunk-5MILMRQY.js";
6
+ } from "../chunk-PYCQNK66.js";
7
7
  import "../chunk-VY4Y5U57.js";
8
8
  import "../chunk-MLKGABMK.js";
9
9
  export {
@@ -379,6 +379,18 @@ function parseJsonObject(raw, schema) {
379
379
  }
380
380
  return null;
381
381
  }
382
+ function parseJsonFromRunnerOutputs(outputs, schema) {
383
+ const seen = /* @__PURE__ */ new Set();
384
+ for (const output of outputs) {
385
+ if (!output.text.trim() || seen.has(output.text)) continue;
386
+ seen.add(output.text);
387
+ const parsed = parseJsonObject(output.text, schema);
388
+ if (parsed) return { parsed, source: output.source };
389
+ }
390
+ const combined = outputs.map((output) => output.text).filter((text) => text.trim()).join("\n");
391
+ if (!combined.trim() || seen.has(combined)) return { parsed: null, source: "" };
392
+ return { parsed: parseJsonObject(combined, schema), source: "combined_output" };
393
+ }
382
394
  function isHarnessVerificationOnlyBlocker(blocker) {
383
395
  const text = blocker.toLowerCase();
384
396
  return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
@@ -398,6 +410,7 @@ function runnerMetrics(input) {
398
410
  stdout_chars: (input.stdout || "").length,
399
411
  stderr_chars: (input.stderr || "").length,
400
412
  final_message_chars: (input.finalText || "").length,
413
+ parsed_json_source: input.parsedJsonSource,
401
414
  exit_status: input.status ?? null,
402
415
  timed_out: input.timedOut || false,
403
416
  error_code: input.errorCode,
@@ -501,19 +514,25 @@ function createCodexExecJsonRunner(config = {}) {
501
514
  };
502
515
  }
503
516
  const finalText = (0, import_node_fs.existsSync)(lastMessagePath) ? (0, import_node_fs.readFileSync)(lastMessagePath, "utf-8") : String(proc.stdout || "");
504
- const parsed = parseJsonObject(finalText, request.schema);
517
+ const stdoutText = String(proc.stdout || "");
518
+ const stderrText = String(proc.stderr || "");
519
+ const { parsed, source: parsedJsonSource } = parseJsonFromRunnerOutputs([
520
+ { source: (0, import_node_fs.existsSync)(lastMessagePath) ? "last_message" : "stdout", text: finalText },
521
+ { source: "stdout", text: stdoutText },
522
+ { source: "stderr", text: stderrText }
523
+ ], request.schema);
505
524
  if (!parsed) {
506
525
  return {
507
526
  ok: false,
508
- stdout: proc.stdout || "",
509
- stderr: proc.stderr || "",
527
+ stdout: stdoutText,
528
+ stderr: stderrText,
510
529
  metrics: runnerMetrics({
511
530
  request,
512
531
  config,
513
532
  startedAt,
514
533
  startedMs,
515
- stdout: proc.stdout || "",
516
- stderr: proc.stderr || "",
534
+ stdout: stdoutText,
535
+ stderr: stderrText,
517
536
  finalText,
518
537
  status: proc.status,
519
538
  errorCode: "invalid_json"
@@ -521,23 +540,24 @@ function createCodexExecJsonRunner(config = {}) {
521
540
  blocker: {
522
541
  code: "codex_invalid_json",
523
542
  message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
524
- details: { finalText, stdout: proc.stdout || "", stderr: proc.stderr || "" }
543
+ details: { finalText, stdout: stdoutText, stderr: stderrText }
525
544
  }
526
545
  };
527
546
  }
528
547
  return {
529
548
  ok: true,
530
549
  json: parsed,
531
- stdout: proc.stdout || "",
532
- stderr: proc.stderr || "",
550
+ stdout: stdoutText,
551
+ stderr: stderrText,
533
552
  metrics: runnerMetrics({
534
553
  request,
535
554
  config,
536
555
  startedAt,
537
556
  startedMs,
538
- stdout: proc.stdout || "",
539
- stderr: proc.stderr || "",
557
+ stdout: stdoutText,
558
+ stderr: stderrText,
540
559
  finalText,
560
+ parsedJsonSource,
541
561
  status: proc.status
542
562
  })
543
563
  };
@@ -3,7 +3,7 @@ import {
3
3
  createCodexExecAgentAdapter,
4
4
  createCodexExecJsonRunner,
5
5
  runCodexExecAgentDoctor
6
- } from "../chunk-5MILMRQY.js";
6
+ } from "../chunk-PYCQNK66.js";
7
7
  import "../chunk-VY4Y5U57.js";
8
8
  import "../chunk-MLKGABMK.js";
9
9
  export {
@@ -379,6 +379,18 @@ function parseJsonObject(raw, schema) {
379
379
  }
380
380
  return null;
381
381
  }
382
+ function parseJsonFromRunnerOutputs(outputs, schema) {
383
+ const seen = /* @__PURE__ */ new Set();
384
+ for (const output of outputs) {
385
+ if (!output.text.trim() || seen.has(output.text)) continue;
386
+ seen.add(output.text);
387
+ const parsed = parseJsonObject(output.text, schema);
388
+ if (parsed) return { parsed, source: output.source };
389
+ }
390
+ const combined = outputs.map((output) => output.text).filter((text) => text.trim()).join("\n");
391
+ if (!combined.trim() || seen.has(combined)) return { parsed: null, source: "" };
392
+ return { parsed: parseJsonObject(combined, schema), source: "combined_output" };
393
+ }
382
394
  function isHarnessVerificationOnlyBlocker(blocker) {
383
395
  const text = blocker.toLowerCase();
384
396
  return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
@@ -398,6 +410,7 @@ function runnerMetrics(input) {
398
410
  stdout_chars: (input.stdout || "").length,
399
411
  stderr_chars: (input.stderr || "").length,
400
412
  final_message_chars: (input.finalText || "").length,
413
+ parsed_json_source: input.parsedJsonSource,
401
414
  exit_status: input.status ?? null,
402
415
  timed_out: input.timedOut || false,
403
416
  error_code: input.errorCode,
@@ -501,19 +514,25 @@ function createCodexExecJsonRunner(config = {}) {
501
514
  };
502
515
  }
503
516
  const finalText = (0, import_node_fs.existsSync)(lastMessagePath) ? (0, import_node_fs.readFileSync)(lastMessagePath, "utf-8") : String(proc.stdout || "");
504
- const parsed = parseJsonObject(finalText, request.schema);
517
+ const stdoutText = String(proc.stdout || "");
518
+ const stderrText = String(proc.stderr || "");
519
+ const { parsed, source: parsedJsonSource } = parseJsonFromRunnerOutputs([
520
+ { source: (0, import_node_fs.existsSync)(lastMessagePath) ? "last_message" : "stdout", text: finalText },
521
+ { source: "stdout", text: stdoutText },
522
+ { source: "stderr", text: stderrText }
523
+ ], request.schema);
505
524
  if (!parsed) {
506
525
  return {
507
526
  ok: false,
508
- stdout: proc.stdout || "",
509
- stderr: proc.stderr || "",
527
+ stdout: stdoutText,
528
+ stderr: stderrText,
510
529
  metrics: runnerMetrics({
511
530
  request,
512
531
  config,
513
532
  startedAt,
514
533
  startedMs,
515
- stdout: proc.stdout || "",
516
- stderr: proc.stderr || "",
534
+ stdout: stdoutText,
535
+ stderr: stderrText,
517
536
  finalText,
518
537
  status: proc.status,
519
538
  errorCode: "invalid_json"
@@ -521,23 +540,24 @@ function createCodexExecJsonRunner(config = {}) {
521
540
  blocker: {
522
541
  code: "codex_invalid_json",
523
542
  message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
524
- details: { finalText, stdout: proc.stdout || "", stderr: proc.stderr || "" }
543
+ details: { finalText, stdout: stdoutText, stderr: stderrText }
525
544
  }
526
545
  };
527
546
  }
528
547
  return {
529
548
  ok: true,
530
549
  json: parsed,
531
- stdout: proc.stdout || "",
532
- stderr: proc.stderr || "",
550
+ stdout: stdoutText,
551
+ stderr: stderrText,
533
552
  metrics: runnerMetrics({
534
553
  request,
535
554
  config,
536
555
  startedAt,
537
556
  startedMs,
538
- stdout: proc.stdout || "",
539
- stderr: proc.stderr || "",
557
+ stdout: stdoutText,
558
+ stderr: stderrText,
540
559
  finalText,
560
+ parsedJsonSource,
541
561
  status: proc.status
542
562
  })
543
563
  };
@@ -3,7 +3,7 @@ import {
3
3
  createCodexExecAgentAdapter,
4
4
  createCodexExecJsonRunner,
5
5
  runCodexExecAgentDoctor
6
- } from "../chunk-5MILMRQY.js";
6
+ } from "../chunk-PYCQNK66.js";
7
7
  import "../chunk-VY4Y5U57.js";
8
8
  import "../chunk-MLKGABMK.js";
9
9
  export {
@@ -172,6 +172,55 @@ function writeState(statePath, state) {
172
172
  function normalizeOptionalString(value) {
173
173
  return typeof value === "string" ? value.trim() : void 0;
174
174
  }
175
+ function normalizeRoutePath(value) {
176
+ const raw = typeof value === "string" ? value.trim() : "";
177
+ if (!raw) return "";
178
+ try {
179
+ const url = /^https?:\/\//i.test(raw) ? new URL(raw) : new URL(raw.startsWith("/") || raw.startsWith("?") || raw.startsWith("#") ? raw : `/${raw}`, "https://riddle-proof.local");
180
+ const pathname = url.pathname.replace(/\/+$/, "") || "/";
181
+ return `${pathname}${url.search}${url.hash}`;
182
+ } catch {
183
+ const hashSplit = raw.split("#");
184
+ const beforeHash = hashSplit.shift() || "";
185
+ const hash = hashSplit.length ? `#${hashSplit.join("#")}` : "";
186
+ const querySplit = beforeHash.split("?");
187
+ const rawPath = querySplit.shift() || "";
188
+ const query = querySplit.length ? `?${querySplit.join("?")}` : "";
189
+ const pathname = `/${rawPath}`.replace(/\/+/g, "/").replace(/\/+$/, "") || "/";
190
+ return `${pathname}${query}${hash}`;
191
+ }
192
+ }
193
+ function isInteractionVerificationMode(value) {
194
+ return INTERACTION_VERIFICATION_MODES.has(typeof value === "string" ? value.trim().toLowerCase() : "");
195
+ }
196
+ function stringRecordValue(record, key) {
197
+ if (!record || typeof record !== "object") return "";
198
+ const value = record[key];
199
+ return typeof value === "string" ? value.trim() : "";
200
+ }
201
+ function appendStateWarning(state, key, warning) {
202
+ const existing = Array.isArray(state[key]) ? state[key].filter((item) => typeof item === "string") : [];
203
+ if (!existing.includes(warning)) state[key] = [...existing, warning];
204
+ }
205
+ function interactionStartPathForAuthorPacket(state, parsed, refined) {
206
+ return normalizeRoutePath(
207
+ stringRecordValue(state, "expected_start_path") || stringRecordValue(refined, "expected_start_path") || stringRecordValue(parsed.interaction_contract, "start_path") || stringRecordValue(parsed.proof_contract, "start_path") || stringRecordValue(state, "server_path") || "/"
208
+ ) || "/";
209
+ }
210
+ function authorPacketServerPath(state, parsed, refined, serverPath, expectedTerminalPath) {
211
+ if (!isInteractionVerificationMode(state.verification_mode)) return serverPath;
212
+ const startPath = interactionStartPathForAuthorPacket(state, parsed, refined);
213
+ state.expected_start_path = startPath;
214
+ if (expectedTerminalPath && normalizeRoutePath(serverPath) === normalizeRoutePath(expectedTerminalPath) && normalizeRoutePath(serverPath) !== startPath) {
215
+ appendStateWarning(
216
+ state,
217
+ "author_warnings",
218
+ "Supervisor packet refined_inputs.server_path matched the terminal interaction route; kept the recon start route for capture."
219
+ );
220
+ return startPath;
221
+ }
222
+ return serverPath;
223
+ }
175
224
  function knownEnvironmentIssuesFromNotes(notes) {
176
225
  const text = notes.toLowerCase();
177
226
  const issues = [];
@@ -652,17 +701,24 @@ function mergeStateFromParams(statePath, params) {
652
701
  state.proof_contract = parsed.proof_contract;
653
702
  }
654
703
  const refined = parsed?.refined_inputs || {};
704
+ const expectedTerminalPath = normalizeOptionalString(
705
+ typeof refined?.expected_terminal_path === "string" ? refined.expected_terminal_path : typeof parsed?.expected_terminal_path === "string" ? parsed.expected_terminal_path : ""
706
+ ) || "";
655
707
  if (typeof refined?.server_path === "string") {
656
- state.server_path = normalizeOptionalString(refined.server_path) || "";
708
+ const refinedServerPath = normalizeOptionalString(refined.server_path) || "";
709
+ state.server_path = authorPacketServerPath(
710
+ state,
711
+ parsed,
712
+ refined,
713
+ refinedServerPath,
714
+ expectedTerminalPath
715
+ );
657
716
  state.server_path_source = "supervising_agent";
658
717
  }
659
718
  if (typeof refined?.wait_for_selector === "string") state.wait_for_selector = normalizeOptionalString(refined.wait_for_selector) || "";
660
719
  if (typeof refined?.reference === "string" && refined.reference.trim()) state.reference = refined.reference.trim();
661
- if (typeof refined?.expected_terminal_path === "string") {
662
- state.expected_terminal_path = normalizeOptionalString(refined.expected_terminal_path) || "";
663
- }
664
- if (typeof parsed?.expected_terminal_path === "string") {
665
- state.expected_terminal_path = normalizeOptionalString(parsed.expected_terminal_path) || "";
720
+ if (expectedTerminalPath) {
721
+ state.expected_terminal_path = expectedTerminalPath;
666
722
  }
667
723
  if (typeof parsed?.confidence === "string") state.supervisor_author_confidence = normalizeOptionalString(parsed.confidence) || null;
668
724
  if (parsed?.rationale !== void 0) state.supervisor_author_rationale = parsed.rationale;
@@ -842,7 +898,7 @@ function summarizeState(state) {
842
898
  state: selected
843
899
  };
844
900
  }
845
- var import_node_fs, import_node_crypto2, import_node_path, import_node_url, import_meta, WORKFLOW_STAGE_ORDER, CHECKPOINT_CONTRACT_VERSION, BUNDLED_RIDDLE_PROOF_DIR, RIDDLE_PROOF_DIR_CANDIDATES, VISUAL_FIRST_MODES, CHECKPOINT_CONTRACT_SPECS;
901
+ var import_node_fs, import_node_crypto2, import_node_path, import_node_url, import_meta, WORKFLOW_STAGE_ORDER, CHECKPOINT_CONTRACT_VERSION, BUNDLED_RIDDLE_PROOF_DIR, RIDDLE_PROOF_DIR_CANDIDATES, INTERACTION_VERIFICATION_MODES, VISUAL_FIRST_MODES, CHECKPOINT_CONTRACT_SPECS;
846
902
  var init_proof_run_core = __esm({
847
903
  "src/proof-run-core.ts"() {
848
904
  "use strict";
@@ -861,6 +917,7 @@ var init_proof_run_core = __esm({
861
917
  RIDDLE_PROOF_DIR_CANDIDATES = [
862
918
  BUNDLED_RIDDLE_PROOF_DIR
863
919
  ];
920
+ INTERACTION_VERIFICATION_MODES = /* @__PURE__ */ new Set(["interaction", "interactive", "user_flow", "user-flow", "workflow"]);
864
921
  VISUAL_FIRST_MODES = /* @__PURE__ */ new Set([
865
922
  "visual",
866
923
  "render",
@@ -2,10 +2,10 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "../chunk-BDFSMWTI.js";
5
+ } from "../chunk-E7ATYSYS.js";
6
6
  import "../chunk-YZUVEJ5B.js";
7
7
  import "../chunk-FMOYUYH2.js";
8
- import "../chunk-RV6LK7HU.js";
8
+ import "../chunk-5N5QFI2S.js";
9
9
  import "../chunk-4FOHZ7JG.js";
10
10
  import "../chunk-VY4Y5U57.js";
11
11
  import "../chunk-MLKGABMK.js";
@@ -202,6 +202,55 @@ function writeState(statePath, state) {
202
202
  function normalizeOptionalString(value) {
203
203
  return typeof value === "string" ? value.trim() : void 0;
204
204
  }
205
+ function normalizeRoutePath(value) {
206
+ const raw = typeof value === "string" ? value.trim() : "";
207
+ if (!raw) return "";
208
+ try {
209
+ const url = /^https?:\/\//i.test(raw) ? new URL(raw) : new URL(raw.startsWith("/") || raw.startsWith("?") || raw.startsWith("#") ? raw : `/${raw}`, "https://riddle-proof.local");
210
+ const pathname = url.pathname.replace(/\/+$/, "") || "/";
211
+ return `${pathname}${url.search}${url.hash}`;
212
+ } catch {
213
+ const hashSplit = raw.split("#");
214
+ const beforeHash = hashSplit.shift() || "";
215
+ const hash = hashSplit.length ? `#${hashSplit.join("#")}` : "";
216
+ const querySplit = beforeHash.split("?");
217
+ const rawPath = querySplit.shift() || "";
218
+ const query = querySplit.length ? `?${querySplit.join("?")}` : "";
219
+ const pathname = `/${rawPath}`.replace(/\/+/g, "/").replace(/\/+$/, "") || "/";
220
+ return `${pathname}${query}${hash}`;
221
+ }
222
+ }
223
+ function isInteractionVerificationMode(value) {
224
+ return INTERACTION_VERIFICATION_MODES.has(typeof value === "string" ? value.trim().toLowerCase() : "");
225
+ }
226
+ function stringRecordValue(record, key) {
227
+ if (!record || typeof record !== "object") return "";
228
+ const value = record[key];
229
+ return typeof value === "string" ? value.trim() : "";
230
+ }
231
+ function appendStateWarning(state, key, warning) {
232
+ const existing = Array.isArray(state[key]) ? state[key].filter((item) => typeof item === "string") : [];
233
+ if (!existing.includes(warning)) state[key] = [...existing, warning];
234
+ }
235
+ function interactionStartPathForAuthorPacket(state, parsed, refined) {
236
+ return normalizeRoutePath(
237
+ stringRecordValue(state, "expected_start_path") || stringRecordValue(refined, "expected_start_path") || stringRecordValue(parsed.interaction_contract, "start_path") || stringRecordValue(parsed.proof_contract, "start_path") || stringRecordValue(state, "server_path") || "/"
238
+ ) || "/";
239
+ }
240
+ function authorPacketServerPath(state, parsed, refined, serverPath, expectedTerminalPath) {
241
+ if (!isInteractionVerificationMode(state.verification_mode)) return serverPath;
242
+ const startPath = interactionStartPathForAuthorPacket(state, parsed, refined);
243
+ state.expected_start_path = startPath;
244
+ if (expectedTerminalPath && normalizeRoutePath(serverPath) === normalizeRoutePath(expectedTerminalPath) && normalizeRoutePath(serverPath) !== startPath) {
245
+ appendStateWarning(
246
+ state,
247
+ "author_warnings",
248
+ "Supervisor packet refined_inputs.server_path matched the terminal interaction route; kept the recon start route for capture."
249
+ );
250
+ return startPath;
251
+ }
252
+ return serverPath;
253
+ }
205
254
  function knownEnvironmentIssuesFromNotes(notes) {
206
255
  const text = notes.toLowerCase();
207
256
  const issues = [];
@@ -682,17 +731,24 @@ function mergeStateFromParams(statePath, params) {
682
731
  state.proof_contract = parsed.proof_contract;
683
732
  }
684
733
  const refined = parsed?.refined_inputs || {};
734
+ const expectedTerminalPath = normalizeOptionalString(
735
+ typeof refined?.expected_terminal_path === "string" ? refined.expected_terminal_path : typeof parsed?.expected_terminal_path === "string" ? parsed.expected_terminal_path : ""
736
+ ) || "";
685
737
  if (typeof refined?.server_path === "string") {
686
- state.server_path = normalizeOptionalString(refined.server_path) || "";
738
+ const refinedServerPath = normalizeOptionalString(refined.server_path) || "";
739
+ state.server_path = authorPacketServerPath(
740
+ state,
741
+ parsed,
742
+ refined,
743
+ refinedServerPath,
744
+ expectedTerminalPath
745
+ );
687
746
  state.server_path_source = "supervising_agent";
688
747
  }
689
748
  if (typeof refined?.wait_for_selector === "string") state.wait_for_selector = normalizeOptionalString(refined.wait_for_selector) || "";
690
749
  if (typeof refined?.reference === "string" && refined.reference.trim()) state.reference = refined.reference.trim();
691
- if (typeof refined?.expected_terminal_path === "string") {
692
- state.expected_terminal_path = normalizeOptionalString(refined.expected_terminal_path) || "";
693
- }
694
- if (typeof parsed?.expected_terminal_path === "string") {
695
- state.expected_terminal_path = normalizeOptionalString(parsed.expected_terminal_path) || "";
750
+ if (expectedTerminalPath) {
751
+ state.expected_terminal_path = expectedTerminalPath;
696
752
  }
697
753
  if (typeof parsed?.confidence === "string") state.supervisor_author_confidence = normalizeOptionalString(parsed.confidence) || null;
698
754
  if (parsed?.rationale !== void 0) state.supervisor_author_rationale = parsed.rationale;
@@ -872,7 +928,7 @@ function summarizeState(state) {
872
928
  state: selected
873
929
  };
874
930
  }
875
- var import_node_fs, import_node_crypto2, import_node_path, import_node_url, import_meta, WORKFLOW_STAGE_ORDER, CHECKPOINT_CONTRACT_VERSION, BUNDLED_RIDDLE_PROOF_DIR, RIDDLE_PROOF_DIR_CANDIDATES, VISUAL_FIRST_MODES, CHECKPOINT_CONTRACT_SPECS;
931
+ var import_node_fs, import_node_crypto2, import_node_path, import_node_url, import_meta, WORKFLOW_STAGE_ORDER, CHECKPOINT_CONTRACT_VERSION, BUNDLED_RIDDLE_PROOF_DIR, RIDDLE_PROOF_DIR_CANDIDATES, INTERACTION_VERIFICATION_MODES, VISUAL_FIRST_MODES, CHECKPOINT_CONTRACT_SPECS;
876
932
  var init_proof_run_core = __esm({
877
933
  "src/proof-run-core.ts"() {
878
934
  "use strict";
@@ -891,6 +947,7 @@ var init_proof_run_core = __esm({
891
947
  RIDDLE_PROOF_DIR_CANDIDATES = [
892
948
  BUNDLED_RIDDLE_PROOF_DIR
893
949
  ];
950
+ INTERACTION_VERIFICATION_MODES = /* @__PURE__ */ new Set(["interaction", "interactive", "user_flow", "user-flow", "workflow"]);
894
951
  VISUAL_FIRST_MODES = /* @__PURE__ */ new Set([
895
952
  "visual",
896
953
  "render",
@@ -1,5 +1,5 @@
1
1
  export { b as runner } from '../runner-4LJ5z0D-.cjs';
2
2
  export { l as engineHarness } from '../engine-harness-LBfqbFSe.cjs';
3
3
  export { p as proofRunCore } from '../proof-run-core-CE0jx7wL.cjs';
4
- export { p as proofRunEngine } from '../proof-run-engine-BO1h0Bmy.cjs';
4
+ export { p as proofRunEngine } from '../proof-run-engine-B7DCPzpK.cjs';
5
5
  import '../types.cjs';
@@ -1,5 +1,5 @@
1
1
  export { b as runner } from '../runner-BdQpOkZD.js';
2
2
  export { l as engineHarness } from '../engine-harness-CMACHP6A.js';
3
3
  export { p as proofRunCore } from '../proof-run-core-CE0jx7wL.js';
4
- export { p as proofRunEngine } from '../proof-run-engine-CIdpWNh6.js';
4
+ export { p as proofRunEngine } from '../proof-run-engine-BomAcXhA.js';
5
5
  import '../types.js';
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  proof_run_engine_exports
3
- } from "../chunk-GMZ57RRY.js";
3
+ } from "../chunk-46DDSZJR.js";
4
4
  import {
5
5
  runner_exports
6
- } from "../chunk-UIJ7X63P.js";
6
+ } from "../chunk-5N6MQCLC.js";
7
7
  import {
8
8
  engine_harness_exports
9
- } from "../chunk-BDFSMWTI.js";
9
+ } from "../chunk-E7ATYSYS.js";
10
10
  import "../chunk-YZUVEJ5B.js";
11
11
  import "../chunk-FMOYUYH2.js";
12
12
  import {
13
13
  proof_run_core_exports
14
- } from "../chunk-RV6LK7HU.js";
14
+ } from "../chunk-5N5QFI2S.js";
15
15
  import "../chunk-4FOHZ7JG.js";
16
16
  import "../chunk-VY4Y5U57.js";
17
17
  import "../chunk-MLKGABMK.js";
@@ -217,6 +217,56 @@ function writeState(statePath, state) {
217
217
  function normalizeOptionalString(value) {
218
218
  return typeof value === "string" ? value.trim() : void 0;
219
219
  }
220
+ var INTERACTION_VERIFICATION_MODES = /* @__PURE__ */ new Set(["interaction", "interactive", "user_flow", "user-flow", "workflow"]);
221
+ function normalizeRoutePath(value) {
222
+ const raw = typeof value === "string" ? value.trim() : "";
223
+ if (!raw) return "";
224
+ try {
225
+ const url = /^https?:\/\//i.test(raw) ? new URL(raw) : new URL(raw.startsWith("/") || raw.startsWith("?") || raw.startsWith("#") ? raw : `/${raw}`, "https://riddle-proof.local");
226
+ const pathname = url.pathname.replace(/\/+$/, "") || "/";
227
+ return `${pathname}${url.search}${url.hash}`;
228
+ } catch {
229
+ const hashSplit = raw.split("#");
230
+ const beforeHash = hashSplit.shift() || "";
231
+ const hash = hashSplit.length ? `#${hashSplit.join("#")}` : "";
232
+ const querySplit = beforeHash.split("?");
233
+ const rawPath = querySplit.shift() || "";
234
+ const query = querySplit.length ? `?${querySplit.join("?")}` : "";
235
+ const pathname = `/${rawPath}`.replace(/\/+/g, "/").replace(/\/+$/, "") || "/";
236
+ return `${pathname}${query}${hash}`;
237
+ }
238
+ }
239
+ function isInteractionVerificationMode(value) {
240
+ return INTERACTION_VERIFICATION_MODES.has(typeof value === "string" ? value.trim().toLowerCase() : "");
241
+ }
242
+ function stringRecordValue(record, key) {
243
+ if (!record || typeof record !== "object") return "";
244
+ const value = record[key];
245
+ return typeof value === "string" ? value.trim() : "";
246
+ }
247
+ function appendStateWarning(state, key, warning) {
248
+ const existing = Array.isArray(state[key]) ? state[key].filter((item) => typeof item === "string") : [];
249
+ if (!existing.includes(warning)) state[key] = [...existing, warning];
250
+ }
251
+ function interactionStartPathForAuthorPacket(state, parsed, refined) {
252
+ return normalizeRoutePath(
253
+ stringRecordValue(state, "expected_start_path") || stringRecordValue(refined, "expected_start_path") || stringRecordValue(parsed.interaction_contract, "start_path") || stringRecordValue(parsed.proof_contract, "start_path") || stringRecordValue(state, "server_path") || "/"
254
+ ) || "/";
255
+ }
256
+ function authorPacketServerPath(state, parsed, refined, serverPath, expectedTerminalPath) {
257
+ if (!isInteractionVerificationMode(state.verification_mode)) return serverPath;
258
+ const startPath = interactionStartPathForAuthorPacket(state, parsed, refined);
259
+ state.expected_start_path = startPath;
260
+ if (expectedTerminalPath && normalizeRoutePath(serverPath) === normalizeRoutePath(expectedTerminalPath) && normalizeRoutePath(serverPath) !== startPath) {
261
+ appendStateWarning(
262
+ state,
263
+ "author_warnings",
264
+ "Supervisor packet refined_inputs.server_path matched the terminal interaction route; kept the recon start route for capture."
265
+ );
266
+ return startPath;
267
+ }
268
+ return serverPath;
269
+ }
220
270
  function knownEnvironmentIssuesFromNotes(notes) {
221
271
  const text = notes.toLowerCase();
222
272
  const issues = [];
@@ -875,17 +925,24 @@ function mergeStateFromParams(statePath, params) {
875
925
  state.proof_contract = parsed.proof_contract;
876
926
  }
877
927
  const refined = parsed?.refined_inputs || {};
928
+ const expectedTerminalPath = normalizeOptionalString(
929
+ typeof refined?.expected_terminal_path === "string" ? refined.expected_terminal_path : typeof parsed?.expected_terminal_path === "string" ? parsed.expected_terminal_path : ""
930
+ ) || "";
878
931
  if (typeof refined?.server_path === "string") {
879
- state.server_path = normalizeOptionalString(refined.server_path) || "";
932
+ const refinedServerPath = normalizeOptionalString(refined.server_path) || "";
933
+ state.server_path = authorPacketServerPath(
934
+ state,
935
+ parsed,
936
+ refined,
937
+ refinedServerPath,
938
+ expectedTerminalPath
939
+ );
880
940
  state.server_path_source = "supervising_agent";
881
941
  }
882
942
  if (typeof refined?.wait_for_selector === "string") state.wait_for_selector = normalizeOptionalString(refined.wait_for_selector) || "";
883
943
  if (typeof refined?.reference === "string" && refined.reference.trim()) state.reference = refined.reference.trim();
884
- if (typeof refined?.expected_terminal_path === "string") {
885
- state.expected_terminal_path = normalizeOptionalString(refined.expected_terminal_path) || "";
886
- }
887
- if (typeof parsed?.expected_terminal_path === "string") {
888
- state.expected_terminal_path = normalizeOptionalString(parsed.expected_terminal_path) || "";
944
+ if (expectedTerminalPath) {
945
+ state.expected_terminal_path = expectedTerminalPath;
889
946
  }
890
947
  if (typeof parsed?.confidence === "string") state.supervisor_author_confidence = normalizeOptionalString(parsed.confidence) || null;
891
948
  if (parsed?.rationale !== void 0) state.supervisor_author_rationale = parsed.rationale;
@@ -26,7 +26,7 @@ import {
26
26
  visualDeltaShipGateReason,
27
27
  workflowFile,
28
28
  writeState
29
- } from "../chunk-RV6LK7HU.js";
29
+ } from "../chunk-5N5QFI2S.js";
30
30
  import "../chunk-MLKGABMK.js";
31
31
  export {
32
32
  BUNDLED_RIDDLE_PROOF_DIR,