@riddledc/riddle-proof 0.7.0 → 0.7.1

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.
@@ -31,6 +31,25 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
33
  // src/proof-run-core.ts
34
+ function normalizedMode(value) {
35
+ return typeof value === "string" ? value.trim().toLowerCase() : "";
36
+ }
37
+ function previewModeFromWorkflowMode(value) {
38
+ const mode = normalizedMode(value);
39
+ return mode === "server" || mode === "static" ? mode : void 0;
40
+ }
41
+ function noImplementationModeInput(value) {
42
+ return value && typeof value === "object" ? value : {};
43
+ }
44
+ function noImplementationModeFor(params, state) {
45
+ const input = noImplementationModeInput(params);
46
+ const stateInput = noImplementationModeInput(state);
47
+ const mode = normalizedMode(input.mode ?? input.workflow_mode ?? stateInput.mode ?? stateInput.workflow_mode);
48
+ const implementationMode = normalizedMode(input.implementation_mode ?? stateInput.implementation_mode);
49
+ const requireDiff = input.require_diff ?? stateInput.require_diff;
50
+ const allowCodeChanges = input.allow_code_changes ?? stateInput.allow_code_changes;
51
+ return mode === "audit" || mode === "profile" || implementationMode === "none" || requireDiff === false || allowCodeChanges === false;
52
+ }
34
53
  function currentDistDir() {
35
54
  const meta = typeof import_meta === "object" ? import_meta : {};
36
55
  if (typeof meta.url === "string" && meta.url) {
@@ -114,7 +133,7 @@ function buildSetupArgs(params, config) {
114
133
  allow_static_preview_fallback: params.allow_static_preview_fallback ? "true" : "",
115
134
  context: params.context || "",
116
135
  reviewer: params.reviewer || config.defaultReviewer,
117
- mode: params.mode || "",
136
+ mode: previewModeFromWorkflowMode(params.mode) || "",
118
137
  build_command: params.build_command || "npm run build",
119
138
  build_output: params.build_output || "build",
120
139
  server_image: params.server_image || "node:20-slim",
@@ -539,7 +558,8 @@ function mergeStateFromParams(statePath, params) {
539
558
  "auth_cookies_json",
540
559
  "auth_headers_json",
541
560
  "proof_plan",
542
- "implementation_notes"
561
+ "implementation_notes",
562
+ "implementation_mode"
543
563
  ];
544
564
  for (const field of stringFields) {
545
565
  if (params[field] !== void 0) {
@@ -554,7 +574,17 @@ function mergeStateFromParams(statePath, params) {
554
574
  if (issues.length) state.implementation_environment_issues = issues;
555
575
  }
556
576
  if (params.reference !== void 0) state.reference = params.reference;
557
- if (params.mode !== void 0) state.mode = params.mode;
577
+ if (params.mode !== void 0) {
578
+ const previewMode = previewModeFromWorkflowMode(params.mode);
579
+ if (previewMode) {
580
+ state.mode = previewMode;
581
+ } else {
582
+ state.workflow_mode = normalizeOptionalString(params.mode);
583
+ }
584
+ }
585
+ if (params.implementation_mode !== void 0) state.implementation_mode = normalizeOptionalString(params.implementation_mode);
586
+ if (params.require_diff !== void 0) state.require_diff = params.require_diff;
587
+ if (params.allow_code_changes !== void 0) state.allow_code_changes = params.allow_code_changes;
558
588
  if (params.allow_static_preview_fallback !== void 0) {
559
589
  state.allow_static_preview_fallback = params.allow_static_preview_fallback;
560
590
  }
@@ -699,6 +729,11 @@ function summarizeState(state) {
699
729
  repo: state.repo || null,
700
730
  branch: state.branch || null,
701
731
  mode: state.mode || null,
732
+ workflow_mode: state.workflow_mode || null,
733
+ implementation_mode: state.implementation_mode || null,
734
+ require_diff: state.require_diff ?? null,
735
+ allow_code_changes: state.allow_code_changes ?? null,
736
+ no_implementation_mode: noImplementationModeFor(state),
702
737
  reference: state.reference || null,
703
738
  before_ref: state.before_ref || null,
704
739
  allow_static_preview_fallback: Boolean(state.allow_static_preview_fallback),
@@ -997,8 +1032,11 @@ function authorReady(state) {
997
1032
  function implementationReady(state) {
998
1033
  return ["changes_detected", "completed"].includes(state?.implementation_status || "");
999
1034
  }
1000
- function stageAfterAuthor(state) {
1001
- return implementationReady(state) ? "verify" : "implement";
1035
+ function implementationRequired(params, state) {
1036
+ return !noImplementationModeFor(params, state);
1037
+ }
1038
+ function stageAfterAuthor(state, params) {
1039
+ return implementationReady(state) || !implementationRequired(params, state) ? "verify" : "implement";
1002
1040
  }
1003
1041
  function latestReconAttempt(state) {
1004
1042
  const history = Array.isArray(state?.recon_results?.attempt_history) ? state.recon_results.attempt_history : [];
@@ -1208,7 +1246,7 @@ function recommendedAdvanceStage(state) {
1208
1246
  if (!state?.workspace_ready) return "setup";
1209
1247
  if (!state?.recon_results || ["needs_agent_decision", "needs_supervisor_judgment"].includes(state?.recon_status || "")) return "recon";
1210
1248
  if (!authorReady(state)) return "author";
1211
- if (!implementationReady(state)) return "implement";
1249
+ if (!implementationReady(state) && !noImplementationModeFor(state)) return "implement";
1212
1250
  if (state?.verify_status === "capture_incomplete") return verifyAssessment(state).continueWithStage || verifyAssessment(state).recommendedStage || "author";
1213
1251
  if (state?.verify_status === "evidence_captured") return verifyAssessment(state).continueWithStage || verifyAssessment(state).recommendedStage;
1214
1252
  if (!(state?.after_cdn || "").trim()) return "verify";
@@ -1833,6 +1871,7 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
1833
1871
  checkpoint: params.advance_stage === "setup" ? "setup_review" : null,
1834
1872
  autoApproved: setupRes.autoApproved || false
1835
1873
  });
1874
+ mergeStateFromParams(config.statePath, params);
1836
1875
  state = readState(config.statePath);
1837
1876
  if (params.advance_stage === "setup") {
1838
1877
  return checkpoint(
@@ -2130,7 +2169,8 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
2130
2169
  }
2131
2170
  );
2132
2171
  }
2133
- const authorNextStage = stageAfterAuthor(state);
2172
+ const noImplementationMode = !implementationRequired(params, state);
2173
+ const authorNextStage = stageAfterAuthor(state, params);
2134
2174
  const explicitAuthorDebug = params.advance_stage === "author";
2135
2175
  recordAttempt("author", "completed", "Author applied the supervising agent's proof packet to recon observations.", {
2136
2176
  autoApproved: authorRes.autoApproved || false,
@@ -2148,7 +2188,7 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
2148
2188
  return checkpoint(
2149
2189
  "author",
2150
2190
  "author_review",
2151
- authorNextStage === "verify" ? "Author applied the supervising agent's proof packet. Because implementation is already recorded, you can continue straight into verify." : "Author applied the supervising agent's proof packet. Inspect it if needed, then continue into implement.",
2191
+ authorNextStage === "verify" ? noImplementationMode ? "Author applied the supervising agent's proof packet. Audit/no-diff mode disables implementation, so you can continue straight into verify." : "Author applied the supervising agent's proof packet. Because implementation is already recorded, you can continue straight into verify." : "Author applied the supervising agent's proof packet. Inspect it if needed, then continue into implement.",
2152
2192
  {
2153
2193
  nextActions: authorNextStage === "verify" ? ["inspect_proof_packet", "advance_run_to_verify", "rerun_author"] : ["inspect_proof_packet", "advance_run_to_implement", "rerun_author"],
2154
2194
  advanceOptions: authorNextStage === "verify" ? ["author", "verify", "recon"] : ["author", "implement", "recon"],
@@ -2181,13 +2221,14 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
2181
2221
  }
2182
2222
  if (!effectiveAdvanceStage) {
2183
2223
  const recommended = recommendedAdvanceStage(state);
2224
+ const noImplementationMode = !implementationRequired(params, state);
2184
2225
  return checkpoint(
2185
- recommended || "implement",
2226
+ recommended || (noImplementationMode ? "verify" : "implement"),
2186
2227
  "awaiting_stage_advance",
2187
2228
  "Proof authoring is ready. The wrapper will not guess the next stage from here, explicitly choose whether to revisit recon/author, validate implementation, capture verify evidence, or ship.",
2188
2229
  {
2189
2230
  nextActions: ["inspect_state", "set_advance_stage", "resume_run"],
2190
- advanceOptions: ["recon", "author", "implement", "verify", "ship"],
2231
+ advanceOptions: noImplementationMode ? ["recon", "author", "verify", "ship"] : ["recon", "author", "implement", "verify", "ship"],
2191
2232
  recommendedAdvanceStage: recommended,
2192
2233
  details: { executed },
2193
2234
  executed
@@ -2195,6 +2236,26 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
2195
2236
  );
2196
2237
  }
2197
2238
  if (effectiveAdvanceStage === "implement") {
2239
+ if (!implementationRequired(params, state)) {
2240
+ recordAttempt("implement", "checkpoint", "Implementation stage was skipped because audit/no-diff mode disables code changes.", {
2241
+ checkpoint: "implement_disabled_for_audit",
2242
+ details: { executed }
2243
+ });
2244
+ return checkpoint(
2245
+ "verify",
2246
+ "implement_disabled_for_audit",
2247
+ "Audit/no-diff mode disables implementation. Continue to verify against the existing target; do not launch an implementation agent or require a git diff.",
2248
+ {
2249
+ nextActions: ["advance_run_to_verify", "inspect_author_packet", "rerun_recon_if_target_changed"],
2250
+ advanceOptions: ["verify", "author", "recon"],
2251
+ recommendedAdvanceStage: "verify",
2252
+ continueWithStage: "verify",
2253
+ blocking: false,
2254
+ details: { executed },
2255
+ executed
2256
+ }
2257
+ );
2258
+ }
2198
2259
  const implementRes = runOne("implement");
2199
2260
  executed.push(executedStep(implementRes));
2200
2261
  if (implementRes.haltedForApproval) {
@@ -2285,7 +2346,8 @@ ${implementRes.stderr || ""}`;
2285
2346
  }
2286
2347
  if (effectiveAdvanceStage === "verify") {
2287
2348
  state = readState(config.statePath);
2288
- if (!["changes_detected", "completed"].includes(state?.implementation_status || "")) {
2349
+ const needsImplementation = implementationRequired(params, state);
2350
+ if (needsImplementation && !implementationReady(state)) {
2289
2351
  return checkpoint(
2290
2352
  "implement",
2291
2353
  "implement_required",
@@ -2302,6 +2364,18 @@ ${implementRes.stderr || ""}`;
2302
2364
  }
2303
2365
  );
2304
2366
  }
2367
+ if (!needsImplementation && !implementationReady(state)) {
2368
+ recordAttempt("implement", "completed", "Implementation stage is not required for this audit/no-diff run.", {
2369
+ checkpoint: "implementation_not_required",
2370
+ details: { executed }
2371
+ });
2372
+ state = updateState(config.statePath, (currentState) => {
2373
+ currentState.implementation_status = "not_required";
2374
+ currentState.implementation_mode = currentState.implementation_mode || "none";
2375
+ if (currentState.require_diff === void 0) currentState.require_diff = false;
2376
+ if (currentState.allow_code_changes === void 0) currentState.allow_code_changes = false;
2377
+ });
2378
+ }
2305
2379
  const hasIncomingProofAssessment = typeof params.proof_assessment_json === "string" && params.proof_assessment_json.trim().length > 0;
2306
2380
  const canReuseVerifyEvidence = (params.advance_stage !== "verify" || hasIncomingProofAssessment) && state?.verify_status === "evidence_captured" && Boolean((state?.after_cdn || "").trim()) && (state?.active_checkpoint === "verify_supervisor_judgment" || hasSupervisorProofAssessment(state));
2307
2381
  let verifyRes = { ok: true, step: "verify", reusedEvidence: canReuseVerifyEvidence };
@@ -2324,8 +2398,13 @@ ${implementRes.stderr || ""}`;
2324
2398
  const verifySummary = state?.verify_summary || state?.proof_summary || null;
2325
2399
  const proofAssessment = verifyAssessment(state);
2326
2400
  const convergenceSignals = nonConvergenceSignals(state, proofAssessment);
2327
- const verifyRecommendedStage = proofAssessment.recommendedStage || null;
2328
- const verifyContinueWithStage = shouldEscalateVerifyToHuman(state, proofAssessment) ? null : proofAssessment.continueWithStage || verifyRecommendedStage || null;
2401
+ const rawVerifyRecommendedStage = proofAssessment.recommendedStage || null;
2402
+ const verifyRecommendedStage = !needsImplementation && rawVerifyRecommendedStage === "implement" ? "verify" : rawVerifyRecommendedStage;
2403
+ const rawVerifyContinueWithStage = shouldEscalateVerifyToHuman(state, proofAssessment) ? null : proofAssessment.continueWithStage || verifyRecommendedStage || null;
2404
+ const verifyContinueWithStage = !needsImplementation && rawVerifyContinueWithStage === "implement" ? "verify" : rawVerifyContinueWithStage;
2405
+ const verifyLoopAdvanceOptions = needsImplementation ? ["author", "verify", "implement", "recon"] : ["author", "verify", "recon"];
2406
+ const verifyReviewAdvanceOptions = needsImplementation ? ["verify", "author", "implement", "recon", "ship"] : ["verify", "author", "recon"];
2407
+ const verifyRetryAdvanceOptions = needsImplementation ? ["author", "implement", "ship", "verify", "recon"] : ["author", "verify", "recon"];
2329
2408
  const verifyDetails = {
2330
2409
  executed,
2331
2410
  verifyStatus,
@@ -2363,7 +2442,7 @@ ${implementRes.stderr || ""}`;
2363
2442
  {
2364
2443
  ok: true,
2365
2444
  nextActions: ["inspect_after_capture", "continue_internal_loop_with_checkpoint", "return_to_recon_if_baseline_is_wrong"],
2366
- advanceOptions: ["author", "verify", "implement", "recon"],
2445
+ advanceOptions: verifyLoopAdvanceOptions,
2367
2446
  recommendedAdvanceStage: verifyRecommendedStage || "author",
2368
2447
  continueWithStage: verifyContinueWithStage || "author",
2369
2448
  blocking: false,
@@ -2391,7 +2470,7 @@ ${implementRes.stderr || ""}`;
2391
2470
  summary,
2392
2471
  {
2393
2472
  nextActions: ["inspect_evidence", "author_proof_assessment_json", "continue_internal_loop_with_checkpoint"],
2394
- advanceOptions: ["verify", "author", "implement", "recon", "ship"],
2473
+ advanceOptions: verifyReviewAdvanceOptions,
2395
2474
  recommendedAdvanceStage: "verify",
2396
2475
  continueWithStage: "verify",
2397
2476
  blocking: false,
@@ -2421,7 +2500,7 @@ ${implementRes.stderr || ""}`;
2421
2500
  {
2422
2501
  ok: false,
2423
2502
  nextActions: ["inspect_retry_history", "summarize_internal_loop", "ask_human_for_direction"],
2424
- advanceOptions: ["author", "implement", "ship", "verify", "recon"],
2503
+ advanceOptions: verifyRetryAdvanceOptions,
2425
2504
  recommendedAdvanceStage: null,
2426
2505
  continueWithStage: null,
2427
2506
  blocking: true,
@@ -2436,7 +2515,7 @@ ${implementRes.stderr || ""}`;
2436
2515
  }
2437
2516
  );
2438
2517
  }
2439
- const shouldAutoShip = verifyContinueWithStage === "ship" && (params.ship_after_verify || params.continue_from_checkpoint || params.advance_stage !== "verify");
2518
+ const shouldAutoShip = verifyContinueWithStage === "ship" && needsImplementation && (params.ship_after_verify || params.continue_from_checkpoint || params.advance_stage !== "verify");
2440
2519
  if (shouldAutoShip) {
2441
2520
  const shipGate = validateShipGate(state);
2442
2521
  if (!shipGate.ok) {
@@ -2494,6 +2573,33 @@ ${implementRes.stderr || ""}`;
2494
2573
  };
2495
2574
  }
2496
2575
  if (proofAssessment.decision === "ready_to_ship") {
2576
+ if (!needsImplementation) {
2577
+ recordAttempt("verify", "completed", "Verify captured a proof packet for audit/no-diff mode; shipping remains disabled.", {
2578
+ autoApproved: verifyRes.autoApproved || false,
2579
+ checkpoint: "verify_audit_complete",
2580
+ details: verifyDetails
2581
+ });
2582
+ return checkpoint(
2583
+ "verify",
2584
+ "verify_audit_complete",
2585
+ "The supervising agent judged the audit proof sufficient. Audit/no-diff mode disables ship, PR creation, implementation agents, and git-diff requirements.",
2586
+ {
2587
+ nextActions: ["inspect_evidence", "report_audit_result", "rerun_verify_if_needed"],
2588
+ advanceOptions: ["verify", "author", "recon"],
2589
+ recommendedAdvanceStage: "verify",
2590
+ continueWithStage: null,
2591
+ blocking: false,
2592
+ details: verifyDetails,
2593
+ verifyStatus,
2594
+ verifySummary,
2595
+ afterCdn: state?.after_cdn || null,
2596
+ mergeRecommendation: state?.merge_recommendation || null,
2597
+ verifyDecisionRequest,
2598
+ proofAssessment: proofAssessment.raw,
2599
+ executed
2600
+ }
2601
+ );
2602
+ }
2497
2603
  const shipGate = validateShipGate(state);
2498
2604
  if (!shipGate.ok) {
2499
2605
  recordAttempt("verify", "checkpoint", "Verify cannot mark ship ready because the hard ship gate is missing required evidence or approval.", {
@@ -2550,8 +2656,8 @@ ${implementRes.stderr || ""}`;
2550
2656
  unresolvedSummary,
2551
2657
  {
2552
2658
  ok: true,
2553
- nextActions: convergenceSignals.warning ? ["inspect_retry_history", "decide_whether_to_keep_iterating_or_escalate", "continue_internal_loop_with_checkpoint"] : ["inspect_proof_assessment", "continue_internal_loop_with_checkpoint", "return_to_implement_if_fix_failed"],
2554
- advanceOptions: ["author", "implement", "ship", "verify", "recon"],
2659
+ nextActions: convergenceSignals.warning ? ["inspect_retry_history", "decide_whether_to_keep_iterating_or_escalate", "continue_internal_loop_with_checkpoint"] : needsImplementation ? ["inspect_proof_assessment", "continue_internal_loop_with_checkpoint", "return_to_implement_if_fix_failed"] : ["inspect_proof_assessment", "continue_internal_loop_with_checkpoint", "rerun_author_if_proof_contract_is_wrong"],
2660
+ advanceOptions: verifyRetryAdvanceOptions,
2555
2661
  recommendedAdvanceStage: verifyRecommendedStage,
2556
2662
  continueWithStage: verifyContinueWithStage,
2557
2663
  blocking: false,
@@ -2568,6 +2674,23 @@ ${implementRes.stderr || ""}`;
2568
2674
  }
2569
2675
  if (effectiveAdvanceStage === "ship") {
2570
2676
  state = readState(config.statePath);
2677
+ if (!implementationRequired(params, state)) {
2678
+ return checkpoint(
2679
+ "verify",
2680
+ "ship_disabled_for_audit",
2681
+ "Audit/no-diff mode disables ship and PR creation. Report the audit result from verify evidence instead.",
2682
+ {
2683
+ ok: false,
2684
+ nextActions: ["inspect_verify_state", "report_audit_result"],
2685
+ advanceOptions: ["verify", "author", "recon"],
2686
+ recommendedAdvanceStage: "verify",
2687
+ continueWithStage: "verify",
2688
+ blocking: true,
2689
+ details: { executed },
2690
+ executed
2691
+ }
2692
+ );
2693
+ }
2571
2694
  const shipAssessment = verifyAssessment(state);
2572
2695
  const shipGate = validateShipGate(state);
2573
2696
  if (state?.verify_status !== "evidence_captured") {
@@ -3897,6 +4020,9 @@ function normalizeRunParams(input) {
3897
4020
  context: input.context,
3898
4021
  reviewer: input.reviewer,
3899
4022
  mode: input.mode,
4023
+ implementation_mode: input.implementation_mode,
4024
+ require_diff: input.require_diff,
4025
+ allow_code_changes: input.allow_code_changes,
3900
4026
  build_command: input.build_command,
3901
4027
  build_output: input.build_output,
3902
4028
  server_image: input.server_image,
@@ -4210,7 +4336,7 @@ function stageFromWorkflowParams(params) {
4210
4336
  if (params.ship_after_verify) return "ship";
4211
4337
  if (params.proof_assessment_json) return "verify";
4212
4338
  if (params.implementation_notes) return "verify";
4213
- if (params.author_packet_json) return "implement";
4339
+ if (params.author_packet_json) return noImplementationModeFor(params) ? "verify" : "implement";
4214
4340
  if (params.recon_assessment_json) return "author";
4215
4341
  return "setup";
4216
4342
  }
@@ -4240,6 +4366,9 @@ function initialRunParams(request, input, state) {
4240
4366
  context: request.context,
4241
4367
  reviewer: request.reviewer,
4242
4368
  mode: request.mode,
4369
+ implementation_mode: request.implementation_mode,
4370
+ require_diff: request.require_diff,
4371
+ allow_code_changes: request.allow_code_changes,
4243
4372
  build_command: request.build_command,
4244
4373
  build_output: request.build_output,
4245
4374
  server_image: request.server_image,
@@ -2,10 +2,10 @@ import {
2
2
  createDisabledRiddleProofAgentAdapter,
3
3
  readRiddleProofRunStatus,
4
4
  runRiddleProofEngineHarness
5
- } from "./chunk-D3M2FAYQ.js";
6
- import "./chunk-MO24D3PY.js";
5
+ } from "./chunk-N5BVCRKI.js";
6
+ import "./chunk-4DM3OTWH.js";
7
7
  import "./chunk-3UHWI3FO.js";
8
- import "./chunk-RFJ5BQF6.js";
8
+ import "./chunk-FPD2RF3Q.js";
9
9
  import "./chunk-33XO42CY.js";
10
10
  import "./chunk-DUFDZJOF.js";
11
11
  export {