@riddledc/riddle-proof 0.6.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.
package/dist/cli.js CHANGED
@@ -1,4 +1,15 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ assessRiddleProofProfileEvidence,
4
+ buildRiddleProofProfileScript,
5
+ collectRiddleProfileArtifactRefs,
6
+ createRiddleProofProfileEnvironmentBlockedResult,
7
+ createRiddleProofProfileInsufficientResult,
8
+ extractRiddleProofProfileResult,
9
+ normalizeRiddleProofProfile,
10
+ profileStatusExitCode,
11
+ resolveRiddleProofProfileTargetUrl
12
+ } from "./chunk-7NMAU4DP.js";
2
13
  import {
3
14
  createRiddleApiClient,
4
15
  parseRiddleViewport
@@ -7,10 +18,10 @@ import {
7
18
  createDisabledRiddleProofAgentAdapter,
8
19
  readRiddleProofRunStatus,
9
20
  runRiddleProofEngineHarness
10
- } from "./chunk-2FBF2UDZ.js";
11
- import "./chunk-MO24D3PY.js";
12
- import "./chunk-RFJ5BQF6.js";
21
+ } from "./chunk-N5BVCRKI.js";
22
+ import "./chunk-4DM3OTWH.js";
13
23
  import "./chunk-3UHWI3FO.js";
24
+ import "./chunk-FPD2RF3Q.js";
14
25
  import {
15
26
  createCheckpointResponseTemplate
16
27
  } from "./chunk-33XO42CY.js";
@@ -22,7 +33,8 @@ import {
22
33
  import "./chunk-DUFDZJOF.js";
23
34
 
24
35
  // src/cli.ts
25
- import { existsSync, readFileSync } from "fs";
36
+ import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
37
+ import path from "path";
26
38
  function usage() {
27
39
  return [
28
40
  "Usage:",
@@ -31,6 +43,7 @@ function usage() {
31
43
  " riddle-proof-loop respond --state-path <path> --response-json <file|json|->",
32
44
  " riddle-proof-loop respond --state-path <path> --decision <decision> --summary <text> [--payload-json <file|json|->]",
33
45
  " riddle-proof-loop status --state-path <path>",
46
+ " riddle-proof-loop run-profile --profile <file|json|-> --url <base-url> [--runner riddle] [--output <dir>]",
34
47
  " riddle-proof-loop riddle-preview-deploy <build-dir> <label>",
35
48
  " riddle-proof-loop riddle-server-preview <directory> --script-file <file> [--path /route] [--wait-for-selector selector]",
36
49
  " riddle-proof-loop riddle-run-script --url <url> --script-file <file> [--viewport 1280x720]",
@@ -222,6 +235,173 @@ function riddleClientConfig(options) {
222
235
  apiBaseUrl: optionString(options, "apiBaseUrl")
223
236
  };
224
237
  }
238
+ function parseProfileViewports(value) {
239
+ if (!value) return void 0;
240
+ return value.split(",").map((part, index) => {
241
+ const trimmed = part.trim();
242
+ const named = /^([a-zA-Z0-9_-]+)=(\d+x\d+)$/.exec(trimmed);
243
+ const viewport = parseRiddleViewport(named ? named[2] : trimmed);
244
+ if (!viewport) throw new Error(`Invalid viewport ${trimmed}.`);
245
+ return {
246
+ name: named ? named[1] : `viewport-${index + 1}`,
247
+ width: viewport.width,
248
+ height: viewport.height
249
+ };
250
+ });
251
+ }
252
+ function normalizeProfileForCli(options) {
253
+ const rawProfile = readJsonValue(optionString(options, "profile"), "--profile");
254
+ return normalizeRiddleProofProfile(rawProfile, {
255
+ url: optionString(options, "url"),
256
+ route: optionString(options, "route"),
257
+ viewports: parseProfileViewports(optionString(options, "viewports") || optionString(options, "viewport"))
258
+ });
259
+ }
260
+ function profileResultMarkdown(result) {
261
+ const lines = [
262
+ `# Riddle Proof Profile: ${result.profile_name}`,
263
+ "",
264
+ `Status: ${result.status}`,
265
+ `Runner: ${result.runner}`,
266
+ `Captured: ${result.captured_at}`,
267
+ "",
268
+ result.summary,
269
+ "",
270
+ "## Checks",
271
+ ""
272
+ ];
273
+ for (const check of result.checks) {
274
+ lines.push(`- ${check.status}: ${check.label || check.type}`);
275
+ if (check.message) lines.push(` ${check.message}`);
276
+ }
277
+ if (result.artifacts.riddle_artifacts?.length) {
278
+ lines.push("", "## Riddle Artifacts", "");
279
+ for (const artifact of result.artifacts.riddle_artifacts.slice(0, 40)) {
280
+ lines.push(`- ${artifact.name || artifact.kind || "artifact"}${artifact.url ? `: ${artifact.url}` : ""}`);
281
+ }
282
+ }
283
+ return `${lines.join("\n")}
284
+ `;
285
+ }
286
+ function writeProfileOutput(outputDir, result) {
287
+ if (!outputDir) return;
288
+ mkdirSync(outputDir, { recursive: true });
289
+ writeFileSync(path.join(outputDir, "profile-result.json"), `${JSON.stringify(result, null, 2)}
290
+ `);
291
+ writeFileSync(path.join(outputDir, "summary.md"), profileResultMarkdown(result));
292
+ if (result.evidence) writeFileSync(path.join(outputDir, "proof.json"), `${JSON.stringify(result, null, 2)}
293
+ `);
294
+ if (result.evidence?.console) writeFileSync(path.join(outputDir, "console.json"), `${JSON.stringify(result.evidence.console, null, 2)}
295
+ `);
296
+ if (result.evidence?.dom_summary) writeFileSync(path.join(outputDir, "dom-summary.json"), `${JSON.stringify(result.evidence.dom_summary, null, 2)}
297
+ `);
298
+ }
299
+ async function readArtifactJson(artifact) {
300
+ const target = artifact.url || artifact.path;
301
+ if (!target) return void 0;
302
+ try {
303
+ const raw = artifact.url ? await (await fetch(artifact.url)).text() : existsSync(target) ? readFileSync(target, "utf-8") : "";
304
+ if (!raw.trim()) return void 0;
305
+ const parsed = JSON.parse(raw);
306
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
307
+ } catch {
308
+ return void 0;
309
+ }
310
+ }
311
+ async function profileResultFromRiddleArtifacts(profile, artifacts, fallbackInputs) {
312
+ for (const input of fallbackInputs) {
313
+ const result = extractRiddleProofProfileResult(input);
314
+ if (result) return result;
315
+ }
316
+ const proofArtifacts = artifacts.filter((artifact) => /(^|\/)proof\.json(?:\.json)?$/i.test(artifact.name || artifact.url || artifact.path || "")).sort((left, right) => {
317
+ const leftName = left.name || left.url || left.path || "";
318
+ const rightName = right.name || right.url || right.path || "";
319
+ return Number(/proof\.json\.json$/i.test(rightName)) - Number(/proof\.json\.json$/i.test(leftName));
320
+ });
321
+ for (const artifact of proofArtifacts) {
322
+ const parsed = await readArtifactJson(artifact);
323
+ const result = extractRiddleProofProfileResult(parsed);
324
+ if (result) return result;
325
+ }
326
+ const evidenceArtifacts = artifacts.filter((artifact) => /profile-evidence|evidence\.json/i.test(artifact.name || artifact.url || artifact.path || ""));
327
+ for (const artifact of evidenceArtifacts) {
328
+ const parsed = await readArtifactJson(artifact);
329
+ if (parsed?.version === "riddle-proof.profile-evidence.v1") {
330
+ return assessRiddleProofProfileEvidence(profile, parsed, { artifacts });
331
+ }
332
+ }
333
+ return void 0;
334
+ }
335
+ function withRiddleMetadata(result, input) {
336
+ return {
337
+ ...result,
338
+ riddle: {
339
+ ...result.riddle || {},
340
+ job_id: input.job_id || result.riddle?.job_id,
341
+ status: input.status ?? result.riddle?.status,
342
+ terminal: input.terminal ?? result.riddle?.terminal
343
+ },
344
+ artifacts: {
345
+ ...result.artifacts,
346
+ riddle_artifacts: input.artifacts || result.artifacts.riddle_artifacts
347
+ }
348
+ };
349
+ }
350
+ async function runProfileForCli(profile, options) {
351
+ const runner = optionString(options, "runner") || "riddle";
352
+ if (runner !== "riddle") {
353
+ throw new Error(`Unsupported --runner ${runner}. The current CLI supports --runner riddle.`);
354
+ }
355
+ const targetUrl = resolveRiddleProofProfileTargetUrl(profile);
356
+ const client = createRiddleApiClient(riddleClientConfig(options));
357
+ let created;
358
+ try {
359
+ created = await client.runScript({
360
+ url: targetUrl,
361
+ script: buildRiddleProofProfileScript(profile),
362
+ viewport: profile.target.viewports[0],
363
+ timeoutSec: optionString(options, "timeout") ? Number(optionString(options, "timeout")) : void 0,
364
+ sync: options.sync === true ? true : void 0
365
+ });
366
+ } catch (error) {
367
+ return createRiddleProofProfileEnvironmentBlockedResult({ profile, runner, error });
368
+ }
369
+ const jobId = typeof created.job_id === "string" ? created.job_id : typeof created.id === "string" ? created.id : "";
370
+ if (!jobId) {
371
+ const directResult = extractRiddleProofProfileResult(created);
372
+ return directResult ? withRiddleMetadata(directResult, { artifacts: collectRiddleProfileArtifactRefs(created) }) : createRiddleProofProfileInsufficientResult({ profile, runner, error: "Riddle run response was missing job_id.", artifacts: collectRiddleProfileArtifactRefs(created) });
373
+ }
374
+ const poll = await client.pollJob(jobId, {
375
+ wait: true,
376
+ attempts: optionString(options, "attempts") ? Number(optionString(options, "attempts")) : void 0,
377
+ intervalMs: optionString(options, "intervalMs") ? Number(optionString(options, "intervalMs")) : void 0
378
+ });
379
+ const artifacts = collectRiddleProfileArtifactRefs(poll.artifacts);
380
+ if (!poll.ok || !poll.terminal) {
381
+ return createRiddleProofProfileEnvironmentBlockedResult({
382
+ profile,
383
+ runner,
384
+ error: `Riddle job ${jobId} ended with status ${poll.status || "unknown"}.`,
385
+ riddle: { job_id: jobId, status: poll.status, terminal: poll.terminal },
386
+ artifacts
387
+ });
388
+ }
389
+ const artifactResult = await profileResultFromRiddleArtifacts(profile, artifacts, [poll.job, poll.artifacts, created]);
390
+ if (!artifactResult) {
391
+ return createRiddleProofProfileInsufficientResult({
392
+ profile,
393
+ runner,
394
+ riddle: { job_id: jobId, status: poll.status, terminal: poll.terminal },
395
+ artifacts
396
+ });
397
+ }
398
+ return withRiddleMetadata(artifactResult, {
399
+ job_id: jobId,
400
+ status: poll.status,
401
+ terminal: poll.terminal,
402
+ artifacts
403
+ });
404
+ }
225
405
  function requestForRun(options) {
226
406
  const statePath = optionString(options, "statePath");
227
407
  const withEngineModuleUrl = (request) => {
@@ -268,6 +448,15 @@ async function main() {
268
448
  `);
269
449
  return;
270
450
  }
451
+ if (command === "run-profile") {
452
+ const profile = normalizeProfileForCli(options);
453
+ const result = await runProfileForCli(profile, options);
454
+ writeProfileOutput(optionString(options, "output"), result);
455
+ process.stdout.write(`${JSON.stringify(result, null, 2)}
456
+ `);
457
+ process.exitCode = profileStatusExitCode(profile, result.status);
458
+ return;
459
+ }
271
460
  if (command === "riddle-preview-deploy") {
272
461
  const buildDir = positional[1];
273
462
  const label = positional[2];
@@ -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-2FBF2UDZ.js";
6
- import "./chunk-MO24D3PY.js";
7
- import "./chunk-RFJ5BQF6.js";
5
+ } from "./chunk-N5BVCRKI.js";
6
+ import "./chunk-4DM3OTWH.js";
8
7
  import "./chunk-3UHWI3FO.js";
8
+ import "./chunk-FPD2RF3Q.js";
9
9
  import "./chunk-33XO42CY.js";
10
10
  import "./chunk-DUFDZJOF.js";
11
11
  export {