@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.
@@ -4,6 +4,25 @@ import { randomUUID } from "crypto";
4
4
  import path from "path";
5
5
  import { fileURLToPath } from "url";
6
6
  var WORKFLOW_STAGE_ORDER = ["setup", "recon", "author", "implement", "verify", "ship"];
7
+ function normalizedMode(value) {
8
+ return typeof value === "string" ? value.trim().toLowerCase() : "";
9
+ }
10
+ function previewModeFromWorkflowMode(value) {
11
+ const mode = normalizedMode(value);
12
+ return mode === "server" || mode === "static" ? mode : void 0;
13
+ }
14
+ function noImplementationModeInput(value) {
15
+ return value && typeof value === "object" ? value : {};
16
+ }
17
+ function noImplementationModeFor(params, state) {
18
+ const input = noImplementationModeInput(params);
19
+ const stateInput = noImplementationModeInput(state);
20
+ const mode = normalizedMode(input.mode ?? input.workflow_mode ?? stateInput.mode ?? stateInput.workflow_mode);
21
+ const implementationMode = normalizedMode(input.implementation_mode ?? stateInput.implementation_mode);
22
+ const requireDiff = input.require_diff ?? stateInput.require_diff;
23
+ const allowCodeChanges = input.allow_code_changes ?? stateInput.allow_code_changes;
24
+ return mode === "audit" || mode === "profile" || implementationMode === "none" || requireDiff === false || allowCodeChanges === false;
25
+ }
7
26
  var CHECKPOINT_CONTRACT_VERSION = "riddle-proof-run.checkpoint.v1";
8
27
  function currentDistDir() {
9
28
  const meta = typeof import.meta === "object" ? import.meta : {};
@@ -96,7 +115,7 @@ function buildSetupArgs(params, config) {
96
115
  allow_static_preview_fallback: params.allow_static_preview_fallback ? "true" : "",
97
116
  context: params.context || "",
98
117
  reviewer: params.reviewer || config.defaultReviewer,
99
- mode: params.mode || "",
118
+ mode: previewModeFromWorkflowMode(params.mode) || "",
100
119
  build_command: params.build_command || "npm run build",
101
120
  build_output: params.build_output || "build",
102
121
  server_image: params.server_image || "node:20-slim",
@@ -699,7 +718,8 @@ function mergeStateFromParams(statePath, params) {
699
718
  "auth_cookies_json",
700
719
  "auth_headers_json",
701
720
  "proof_plan",
702
- "implementation_notes"
721
+ "implementation_notes",
722
+ "implementation_mode"
703
723
  ];
704
724
  for (const field of stringFields) {
705
725
  if (params[field] !== void 0) {
@@ -714,7 +734,17 @@ function mergeStateFromParams(statePath, params) {
714
734
  if (issues.length) state.implementation_environment_issues = issues;
715
735
  }
716
736
  if (params.reference !== void 0) state.reference = params.reference;
717
- if (params.mode !== void 0) state.mode = params.mode;
737
+ if (params.mode !== void 0) {
738
+ const previewMode = previewModeFromWorkflowMode(params.mode);
739
+ if (previewMode) {
740
+ state.mode = previewMode;
741
+ } else {
742
+ state.workflow_mode = normalizeOptionalString(params.mode);
743
+ }
744
+ }
745
+ if (params.implementation_mode !== void 0) state.implementation_mode = normalizeOptionalString(params.implementation_mode);
746
+ if (params.require_diff !== void 0) state.require_diff = params.require_diff;
747
+ if (params.allow_code_changes !== void 0) state.allow_code_changes = params.allow_code_changes;
718
748
  if (params.allow_static_preview_fallback !== void 0) {
719
749
  state.allow_static_preview_fallback = params.allow_static_preview_fallback;
720
750
  }
@@ -859,6 +889,11 @@ function summarizeState(state) {
859
889
  repo: state.repo || null,
860
890
  branch: state.branch || null,
861
891
  mode: state.mode || null,
892
+ workflow_mode: state.workflow_mode || null,
893
+ implementation_mode: state.implementation_mode || null,
894
+ require_diff: state.require_diff ?? null,
895
+ allow_code_changes: state.allow_code_changes ?? null,
896
+ no_implementation_mode: noImplementationModeFor(state),
862
897
  reference: state.reference || null,
863
898
  before_ref: state.before_ref || null,
864
899
  allow_static_preview_fallback: Boolean(state.allow_static_preview_fallback),
@@ -945,6 +980,8 @@ function summarizeState(state) {
945
980
 
946
981
  export {
947
982
  WORKFLOW_STAGE_ORDER,
983
+ previewModeFromWorkflowMode,
984
+ noImplementationModeFor,
948
985
  CHECKPOINT_CONTRACT_VERSION,
949
986
  BUNDLED_RIDDLE_PROOF_DIR,
950
987
  RIDDLE_PROOF_DIR_CANDIDATES,
@@ -3,7 +3,10 @@ import {
3
3
  appendStageHeartbeat,
4
4
  createRunState,
5
5
  setRunStatus
6
- } from "./chunk-MO24D3PY.js";
6
+ } from "./chunk-4DM3OTWH.js";
7
+ import {
8
+ noImplementationModeFor
9
+ } from "./chunk-FPD2RF3Q.js";
7
10
  import {
8
11
  createRunResult
9
12
  } from "./chunk-DUFDZJOF.js";
@@ -208,6 +211,7 @@ async function runRiddleProof(input) {
208
211
  }
209
212
  }
210
213
  const changeRequest = state.request.change_request?.trim();
214
+ const noImplementationMode = noImplementationModeFor(state.request);
211
215
  if (!changeRequest) {
212
216
  return blockRun({
213
217
  state,
@@ -215,14 +219,14 @@ async function runRiddleProof(input) {
215
219
  blocker: adapterBlocker("change_request_required", "A change request is required before implementation.", "request_invalid")
216
220
  });
217
221
  }
218
- if (!workdir) {
222
+ if (!noImplementationMode && !workdir) {
219
223
  return blockRun({
220
224
  state,
221
225
  stage: "setup",
222
226
  blocker: adapterBlocker("workdir_not_configured", "A workdir or setup adapter result is required before implementation.", "setup_required")
223
227
  });
224
228
  }
225
- if (!adapters.implementation) {
229
+ if (!noImplementationMode && !adapters.implementation) {
226
230
  return blockRun({
227
231
  state,
228
232
  stage: "implement",
@@ -248,57 +252,68 @@ async function runRiddleProof(input) {
248
252
  let assessment;
249
253
  for (let attempt = 0; attempt < maxIterations; attempt += 1) {
250
254
  state.iterations += 1;
251
- appendStageHeartbeat(state, {
252
- stage: "implement",
253
- summary: "Implementation stage is active.",
254
- details: { iteration: state.iterations }
255
- });
256
- appendRunEvent(state, {
257
- kind: "implementation.started",
258
- checkpoint: "implementation_started",
259
- stage: "implement",
260
- summary: "Implementation adapter started.",
261
- details: { iteration: state.iterations }
262
- });
263
- try {
264
- implementation = await adapters.implementation.implement({
265
- workdir,
266
- change_request: changeRequest,
267
- evidence_context: evidenceContext,
268
- state
255
+ if (noImplementationMode) {
256
+ state.implementation_status = "not_required";
257
+ appendRunEvent(state, {
258
+ kind: "implementation.skipped",
259
+ checkpoint: "implementation_not_required",
260
+ stage: "implement",
261
+ summary: "Implementation stage skipped because audit/no-diff mode disables code changes.",
262
+ details: { iteration: state.iterations }
269
263
  });
270
- } catch (error) {
271
- return blockRun({
272
- state,
264
+ } else {
265
+ appendStageHeartbeat(state, {
273
266
  stage: "implement",
274
- blocker: adapterBlocker("implementation_exception", "The implementation adapter threw an exception.", "implementation_failed", errorDetails(error)),
275
- evidence_bundle: evidenceBundle
267
+ summary: "Implementation stage is active.",
268
+ details: { iteration: state.iterations }
276
269
  });
277
- }
278
- if (!implementation.ok) {
279
- return blockRun({
280
- state,
270
+ appendRunEvent(state, {
271
+ kind: "implementation.started",
272
+ checkpoint: "implementation_started",
281
273
  stage: "implement",
282
- blocker: adapterBlocker(
283
- "implementation_failed",
284
- "The implementation adapter did not complete successfully.",
285
- "implementation_failed",
286
- { blockers: implementation.blockers }
287
- ),
288
- evidence_bundle: evidenceBundle,
289
- raw: { implementation }
274
+ summary: "Implementation adapter started.",
275
+ details: { iteration: state.iterations }
290
276
  });
291
- }
292
- appendRunEvent(state, {
293
- kind: "implementation.completed",
294
- checkpoint: "implementation_completed",
295
- stage: "implement",
296
- summary: "Implementation adapter completed.",
297
- details: {
298
- changed_files: implementation.changed_files,
299
- tests_run: implementation.tests_run
277
+ try {
278
+ implementation = await adapters.implementation.implement({
279
+ workdir,
280
+ change_request: changeRequest,
281
+ evidence_context: evidenceContext,
282
+ state
283
+ });
284
+ } catch (error) {
285
+ return blockRun({
286
+ state,
287
+ stage: "implement",
288
+ blocker: adapterBlocker("implementation_exception", "The implementation adapter threw an exception.", "implementation_failed", errorDetails(error)),
289
+ evidence_bundle: evidenceBundle
290
+ });
300
291
  }
301
- });
292
+ if (!implementation.ok) {
293
+ return blockRun({
294
+ state,
295
+ stage: "implement",
296
+ blocker: adapterBlocker(
297
+ "implementation_failed",
298
+ "The implementation adapter did not complete successfully.",
299
+ "implementation_failed",
300
+ { blockers: implementation.blockers }
301
+ ),
302
+ evidence_bundle: evidenceBundle,
303
+ raw: { implementation }
304
+ });
305
+ }
306
+ appendRunEvent(state, {
307
+ kind: "implementation.completed",
308
+ checkpoint: "implementation_completed",
309
+ stage: "implement",
310
+ summary: "Implementation adapter completed.",
311
+ details: {
312
+ changed_files: implementation.changed_files,
313
+ tests_run: implementation.tests_run
314
+ }
315
+ });
316
+ }
302
317
  appendStageHeartbeat(state, {
303
318
  stage: "prove",
304
319
  summary: "Proof capture stage is active.",
@@ -5,15 +5,16 @@ import {
5
5
  createRunStatusSnapshot,
6
6
  normalizeRunParams,
7
7
  setRunStatus
8
- } from "./chunk-MO24D3PY.js";
8
+ } from "./chunk-4DM3OTWH.js";
9
9
  import {
10
+ createRiddleProofRunCard
11
+ } from "./chunk-3UHWI3FO.js";
12
+ import {
13
+ noImplementationModeFor,
10
14
  visualDeltaForState,
11
15
  visualDeltaRequiredForState,
12
16
  visualDeltaShipGateReason
13
- } from "./chunk-RFJ5BQF6.js";
14
- import {
15
- createRiddleProofRunCard
16
- } from "./chunk-3UHWI3FO.js";
17
+ } from "./chunk-FPD2RF3Q.js";
17
18
  import {
18
19
  authorPacketPayloadFromCheckpointResponse,
19
20
  buildCheckpointPacketForEngineResult,
@@ -223,7 +224,7 @@ function stageFromWorkflowParams(params) {
223
224
  if (params.ship_after_verify) return "ship";
224
225
  if (params.proof_assessment_json) return "verify";
225
226
  if (params.implementation_notes) return "verify";
226
- if (params.author_packet_json) return "implement";
227
+ if (params.author_packet_json) return noImplementationModeFor(params) ? "verify" : "implement";
227
228
  if (params.recon_assessment_json) return "author";
228
229
  return "setup";
229
230
  }
@@ -253,6 +254,9 @@ function initialRunParams(request, input, state) {
253
254
  context: request.context,
254
255
  reviewer: request.reviewer,
255
256
  mode: request.mode,
257
+ implementation_mode: request.implementation_mode,
258
+ require_diff: request.require_diff,
259
+ allow_code_changes: request.allow_code_changes,
256
260
  build_command: request.build_command,
257
261
  build_output: request.build_output,
258
262
  server_image: request.server_image,