@riddledc/riddle-proof 0.8.13 → 0.8.15

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/index.cjs CHANGED
@@ -1139,6 +1139,12 @@ function snapshotFor(statePath) {
1139
1139
  function authorReady(state) {
1140
1140
  return state?.author_status === "ready" || state?.proof_plan_status === "ready";
1141
1141
  }
1142
+ function hasAuthoredProofPlan2(state = {}) {
1143
+ return Boolean((state?.proof_plan || "").trim()) && Boolean((state?.capture_script || "").trim());
1144
+ }
1145
+ function hasExplicitCaptureScript(state = {}) {
1146
+ return Boolean((state?.capture_script || "").trim());
1147
+ }
1142
1148
  function implementationReady(state) {
1143
1149
  return ["changes_detected", "completed"].includes(state?.implementation_status || "");
1144
1150
  }
@@ -1169,6 +1175,45 @@ function latestReconHasRequiredBaselines(state) {
1169
1175
  const baselines = latestReconCapturedBaselines(state);
1170
1176
  return requiredReconBaselineLabels(state).every((label) => Boolean((baselines?.[label]?.url || "").trim()));
1171
1177
  }
1178
+ function canAutoAcceptExplicitCaptureRecon(params, state) {
1179
+ const labels = requiredReconBaselineLabels(state);
1180
+ return Boolean(
1181
+ !implementationRequired(params, state) && hasExplicitCaptureScript(state) && ["needs_agent_decision", "needs_supervisor_judgment"].includes(state?.recon_status || "") && labels.length > 0 && latestReconHasRequiredBaselines(state)
1182
+ );
1183
+ }
1184
+ function applyExplicitCaptureReconAcceptance(state) {
1185
+ const baselines = promoteLatestReconBaselines(state);
1186
+ const labels = requiredReconBaselineLabels(state);
1187
+ const selected = latestReconAttempt(state) || {};
1188
+ state.recon_status = "ready_for_proof_plan";
1189
+ state.recon_results = state.recon_results || {};
1190
+ state.recon_results.status = "ready_for_proof_plan";
1191
+ state.recon_results.baselines = baselines;
1192
+ state.recon_assessment_request = {};
1193
+ state.recon_decision_request = {};
1194
+ state.recon_assessment = {
1195
+ decision: "ready_for_author",
1196
+ continue_with_stage: "author",
1197
+ source: "runner_auto_accept",
1198
+ summary: "Runner accepted recon automatically because this audit/no-diff run already supplied an explicit capture script, and the required baseline capture exists.",
1199
+ baseline_labels: labels
1200
+ };
1201
+ state.recon_assessment_source = "runner_auto_accept";
1202
+ state.recon_baseline_understanding = state.recon_baseline_understanding || {
1203
+ reference: state?.reference || state?.requested_reference || "before",
1204
+ target_route: selected?.plan?.target_path || state?.server_path || "/",
1205
+ proof_focus: state?.proof_plan || state?.change_request || "",
1206
+ stop_condition: "Verify must judge the authored capture evidence against the explicit proof packet."
1207
+ };
1208
+ if (hasAuthoredProofPlan2(state)) {
1209
+ state.author_status = "ready";
1210
+ state.proof_plan_status = "ready";
1211
+ } else {
1212
+ state.author_status = "needs_authoring";
1213
+ state.proof_plan_status = "needs_authoring";
1214
+ }
1215
+ return { baselines, labels };
1216
+ }
1172
1217
  function hasReconBaselineUnderstanding(state) {
1173
1218
  const understanding = state?.recon_assessment?.baseline_understanding || state?.recon_baseline_understanding || {};
1174
1219
  return Boolean(
@@ -2195,6 +2240,7 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
2195
2240
  state = readState(config.statePath);
2196
2241
  }
2197
2242
  }
2243
+ let reconAutoAcceptedExplicitCapture = false;
2198
2244
  if (!state?.recon_results || state?.stage === "setup" || state?.stage === "preflight" || ["needs_agent_decision", "needs_supervisor_judgment"].includes(state?.recon_status || "") || requestedStage === "recon") {
2199
2245
  const reconRes = runOne("recon");
2200
2246
  executed.push(executedStep(reconRes));
@@ -2207,40 +2253,64 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
2207
2253
  }
2208
2254
  state = readState(config.statePath);
2209
2255
  if (["needs_agent_decision", "needs_supervisor_judgment"].includes(state?.recon_status || "")) {
2210
- const reconAssessmentRequest = state?.recon_assessment_request || state?.recon_decision_request || null;
2211
- const summary = "Recon gathered route hints, candidate paths, baseline captures, and observations. The supervising agent should now judge whether the latest baseline is trustworthy, whether recon should retry/reframe, and whether recon is done.";
2212
- const reconDetails = {
2213
- executed,
2214
- latestAttempt: latestReconAttempt(state),
2215
- latestCapturedBaselines: latestReconCapturedBaselines(state),
2216
- reconAssessmentRequest
2217
- };
2218
- recordAttempt("recon", "checkpoint", summary, {
2256
+ if (canAutoAcceptExplicitCaptureRecon(params, state)) {
2257
+ const promoted = updateState(config.statePath, (currentState) => {
2258
+ applyExplicitCaptureReconAcceptance(currentState);
2259
+ });
2260
+ state = promoted;
2261
+ reconAutoAcceptedExplicitCapture = true;
2262
+ effectiveAdvanceStage = stageAfterAuthor(state, params);
2263
+ requestedStage = normalizeStageRequest(state, effectiveAdvanceStage);
2264
+ updateState(config.statePath, (currentState) => {
2265
+ currentState.last_requested_advance_stage = effectiveAdvanceStage;
2266
+ });
2267
+ recordAttempt("recon", "completed", "Recon baseline was captured and auto-accepted for an explicit audit/no-diff proof packet.", {
2268
+ autoApproved: true,
2269
+ checkpoint: "recon_auto_accept_explicit_capture",
2270
+ details: {
2271
+ executed,
2272
+ promotedBaselines: latestReconCapturedBaselines(state),
2273
+ baselineLabels: requiredReconBaselineLabels(state)
2274
+ }
2275
+ });
2276
+ } else {
2277
+ const reconAssessmentRequest = state?.recon_assessment_request || state?.recon_decision_request || null;
2278
+ const summary = "Recon gathered route hints, candidate paths, baseline captures, and observations. The supervising agent should now judge whether the latest baseline is trustworthy, whether recon should retry/reframe, and whether recon is done.";
2279
+ const reconDetails = {
2280
+ executed,
2281
+ latestAttempt: latestReconAttempt(state),
2282
+ latestCapturedBaselines: latestReconCapturedBaselines(state),
2283
+ reconAssessmentRequest
2284
+ };
2285
+ recordAttempt("recon", "checkpoint", summary, {
2286
+ autoApproved: reconRes.autoApproved || false,
2287
+ checkpoint: "recon_supervisor_judgment",
2288
+ details: reconDetails
2289
+ });
2290
+ return checkpoint(
2291
+ "recon",
2292
+ "recon_supervisor_judgment",
2293
+ summary,
2294
+ {
2295
+ nextActions: ["inspect_recon_packet", "supply_recon_assessment_json", "continue_internal_loop_with_checkpoint"],
2296
+ advanceOptions: ["recon", "author"],
2297
+ recommendedAdvanceStage: "recon",
2298
+ continueWithStage: "recon",
2299
+ blocking: false,
2300
+ details: reconDetails,
2301
+ reconAssessmentRequest,
2302
+ reconDecisionRequest: state?.recon_decision_request || null,
2303
+ executed
2304
+ }
2305
+ );
2306
+ }
2307
+ }
2308
+ if (!reconAutoAcceptedExplicitCapture) {
2309
+ recordAttempt("recon", "completed", "Recon completed and promoted an approved baseline context.", {
2219
2310
  autoApproved: reconRes.autoApproved || false,
2220
- checkpoint: "recon_supervisor_judgment",
2221
- details: reconDetails
2311
+ details: { executed }
2222
2312
  });
2223
- return checkpoint(
2224
- "recon",
2225
- "recon_supervisor_judgment",
2226
- summary,
2227
- {
2228
- nextActions: ["inspect_recon_packet", "supply_recon_assessment_json", "continue_internal_loop_with_checkpoint"],
2229
- advanceOptions: ["recon", "author"],
2230
- recommendedAdvanceStage: "recon",
2231
- continueWithStage: "recon",
2232
- blocking: false,
2233
- details: reconDetails,
2234
- reconAssessmentRequest,
2235
- reconDecisionRequest: state?.recon_decision_request || null,
2236
- executed
2237
- }
2238
- );
2239
2313
  }
2240
- recordAttempt("recon", "completed", "Recon completed and promoted an approved baseline context.", {
2241
- autoApproved: reconRes.autoApproved || false,
2242
- details: { executed }
2243
- });
2244
2314
  }
2245
2315
  state = readState(config.statePath);
2246
2316
  if (!authorReady(state) || effectiveAdvanceStage === "author") {
@@ -5882,6 +5952,40 @@ function checkpointResponseContinuation(state, value) {
5882
5952
  }
5883
5953
  };
5884
5954
  }
5955
+ function finalizedCheckpointResponseWithoutPacketResult(state, value) {
5956
+ if (!value || state.checkpoint_packet || !state.finalized || !isProtectedFinalStatus(state.status)) return null;
5957
+ const response = normalizeCheckpointResponse(value);
5958
+ if (!response) return null;
5959
+ if (isDuplicateCheckpointResponse(state, response)) return null;
5960
+ const at = timestamp3();
5961
+ state.checkpoint_history = [
5962
+ ...state.checkpoint_history || [],
5963
+ { ts: at, response }
5964
+ ].slice(-25);
5965
+ appendRunEvent(state, {
5966
+ ts: at,
5967
+ kind: "checkpoint.response.ignored",
5968
+ checkpoint: response.checkpoint,
5969
+ stage: state.current_stage || "verify",
5970
+ summary: "Late checkpoint response ignored because the run is already finalized.",
5971
+ details: compactRecord({
5972
+ status: state.status,
5973
+ decision: response.decision,
5974
+ resume_token: response.resume_token,
5975
+ source: response.source
5976
+ })
5977
+ });
5978
+ persist(state);
5979
+ return createRunResult({
5980
+ state,
5981
+ status: state.status,
5982
+ last_summary: "Late checkpoint response ignored because the run is already finalized.",
5983
+ raw: {
5984
+ ignored_checkpoint_response: true,
5985
+ response
5986
+ }
5987
+ });
5988
+ }
5885
5989
  function disabledAdapterPayload(action, context) {
5886
5990
  return {
5887
5991
  ok: false,
@@ -6452,6 +6556,8 @@ async function runRiddleProofEngineHarness(input) {
6452
6556
  const state = loadRunState(input);
6453
6557
  state.request = normalizeRunParams({ ...state.request, ...input.request });
6454
6558
  state.request.engine_state_path = nonEmptyString(input.resume_params?.state_path) || nonEmptyString(state.request.engine_state_path) || createEngineStatePath(state, input.config);
6559
+ const finalizedCheckpointResponse = finalizedCheckpointResponseWithoutPacketResult(state, input.checkpoint_response);
6560
+ if (finalizedCheckpointResponse) return finalizedCheckpointResponse;
6455
6561
  const checkpointContinuation = checkpointResponseContinuation(state, input.checkpoint_response);
6456
6562
  if (checkpointContinuation.blocker) {
6457
6563
  return blockerResult(state, null, checkpointContinuation.blocker);
package/dist/index.js CHANGED
@@ -95,7 +95,7 @@ import {
95
95
  createDisabledRiddleProofAgentAdapter,
96
96
  readRiddleProofRunStatus,
97
97
  runRiddleProofEngineHarness
98
- } from "./chunk-RTLA6CPP.js";
98
+ } from "./chunk-RW4OUHN4.js";
99
99
  import {
100
100
  RIDDLE_PROOF_RUN_STATE_VERSION,
101
101
  appendRunEvent,
@@ -1136,6 +1136,12 @@ function snapshotFor(statePath) {
1136
1136
  function authorReady(state) {
1137
1137
  return state?.author_status === "ready" || state?.proof_plan_status === "ready";
1138
1138
  }
1139
+ function hasAuthoredProofPlan2(state = {}) {
1140
+ return Boolean((state?.proof_plan || "").trim()) && Boolean((state?.capture_script || "").trim());
1141
+ }
1142
+ function hasExplicitCaptureScript(state = {}) {
1143
+ return Boolean((state?.capture_script || "").trim());
1144
+ }
1139
1145
  function implementationReady(state) {
1140
1146
  return ["changes_detected", "completed"].includes(state?.implementation_status || "");
1141
1147
  }
@@ -1166,6 +1172,45 @@ function latestReconHasRequiredBaselines(state) {
1166
1172
  const baselines = latestReconCapturedBaselines(state);
1167
1173
  return requiredReconBaselineLabels(state).every((label) => Boolean((baselines?.[label]?.url || "").trim()));
1168
1174
  }
1175
+ function canAutoAcceptExplicitCaptureRecon(params, state) {
1176
+ const labels = requiredReconBaselineLabels(state);
1177
+ return Boolean(
1178
+ !implementationRequired(params, state) && hasExplicitCaptureScript(state) && ["needs_agent_decision", "needs_supervisor_judgment"].includes(state?.recon_status || "") && labels.length > 0 && latestReconHasRequiredBaselines(state)
1179
+ );
1180
+ }
1181
+ function applyExplicitCaptureReconAcceptance(state) {
1182
+ const baselines = promoteLatestReconBaselines(state);
1183
+ const labels = requiredReconBaselineLabels(state);
1184
+ const selected = latestReconAttempt(state) || {};
1185
+ state.recon_status = "ready_for_proof_plan";
1186
+ state.recon_results = state.recon_results || {};
1187
+ state.recon_results.status = "ready_for_proof_plan";
1188
+ state.recon_results.baselines = baselines;
1189
+ state.recon_assessment_request = {};
1190
+ state.recon_decision_request = {};
1191
+ state.recon_assessment = {
1192
+ decision: "ready_for_author",
1193
+ continue_with_stage: "author",
1194
+ source: "runner_auto_accept",
1195
+ summary: "Runner accepted recon automatically because this audit/no-diff run already supplied an explicit capture script, and the required baseline capture exists.",
1196
+ baseline_labels: labels
1197
+ };
1198
+ state.recon_assessment_source = "runner_auto_accept";
1199
+ state.recon_baseline_understanding = state.recon_baseline_understanding || {
1200
+ reference: state?.reference || state?.requested_reference || "before",
1201
+ target_route: selected?.plan?.target_path || state?.server_path || "/",
1202
+ proof_focus: state?.proof_plan || state?.change_request || "",
1203
+ stop_condition: "Verify must judge the authored capture evidence against the explicit proof packet."
1204
+ };
1205
+ if (hasAuthoredProofPlan2(state)) {
1206
+ state.author_status = "ready";
1207
+ state.proof_plan_status = "ready";
1208
+ } else {
1209
+ state.author_status = "needs_authoring";
1210
+ state.proof_plan_status = "needs_authoring";
1211
+ }
1212
+ return { baselines, labels };
1213
+ }
1169
1214
  function hasReconBaselineUnderstanding(state) {
1170
1215
  const understanding = state?.recon_assessment?.baseline_understanding || state?.recon_baseline_understanding || {};
1171
1216
  return Boolean(
@@ -2193,6 +2238,7 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
2193
2238
  state = readState(config.statePath);
2194
2239
  }
2195
2240
  }
2241
+ let reconAutoAcceptedExplicitCapture = false;
2196
2242
  if (!state?.recon_results || state?.stage === "setup" || state?.stage === "preflight" || ["needs_agent_decision", "needs_supervisor_judgment"].includes(state?.recon_status || "") || requestedStage === "recon") {
2197
2243
  const reconRes = runOne("recon");
2198
2244
  executed.push(executedStep(reconRes));
@@ -2205,40 +2251,64 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
2205
2251
  }
2206
2252
  state = readState(config.statePath);
2207
2253
  if (["needs_agent_decision", "needs_supervisor_judgment"].includes(state?.recon_status || "")) {
2208
- const reconAssessmentRequest = state?.recon_assessment_request || state?.recon_decision_request || null;
2209
- const summary = "Recon gathered route hints, candidate paths, baseline captures, and observations. The supervising agent should now judge whether the latest baseline is trustworthy, whether recon should retry/reframe, and whether recon is done.";
2210
- const reconDetails = {
2211
- executed,
2212
- latestAttempt: latestReconAttempt(state),
2213
- latestCapturedBaselines: latestReconCapturedBaselines(state),
2214
- reconAssessmentRequest
2215
- };
2216
- recordAttempt("recon", "checkpoint", summary, {
2254
+ if (canAutoAcceptExplicitCaptureRecon(params, state)) {
2255
+ const promoted = updateState(config.statePath, (currentState) => {
2256
+ applyExplicitCaptureReconAcceptance(currentState);
2257
+ });
2258
+ state = promoted;
2259
+ reconAutoAcceptedExplicitCapture = true;
2260
+ effectiveAdvanceStage = stageAfterAuthor(state, params);
2261
+ requestedStage = normalizeStageRequest(state, effectiveAdvanceStage);
2262
+ updateState(config.statePath, (currentState) => {
2263
+ currentState.last_requested_advance_stage = effectiveAdvanceStage;
2264
+ });
2265
+ recordAttempt("recon", "completed", "Recon baseline was captured and auto-accepted for an explicit audit/no-diff proof packet.", {
2266
+ autoApproved: true,
2267
+ checkpoint: "recon_auto_accept_explicit_capture",
2268
+ details: {
2269
+ executed,
2270
+ promotedBaselines: latestReconCapturedBaselines(state),
2271
+ baselineLabels: requiredReconBaselineLabels(state)
2272
+ }
2273
+ });
2274
+ } else {
2275
+ const reconAssessmentRequest = state?.recon_assessment_request || state?.recon_decision_request || null;
2276
+ const summary = "Recon gathered route hints, candidate paths, baseline captures, and observations. The supervising agent should now judge whether the latest baseline is trustworthy, whether recon should retry/reframe, and whether recon is done.";
2277
+ const reconDetails = {
2278
+ executed,
2279
+ latestAttempt: latestReconAttempt(state),
2280
+ latestCapturedBaselines: latestReconCapturedBaselines(state),
2281
+ reconAssessmentRequest
2282
+ };
2283
+ recordAttempt("recon", "checkpoint", summary, {
2284
+ autoApproved: reconRes.autoApproved || false,
2285
+ checkpoint: "recon_supervisor_judgment",
2286
+ details: reconDetails
2287
+ });
2288
+ return checkpoint(
2289
+ "recon",
2290
+ "recon_supervisor_judgment",
2291
+ summary,
2292
+ {
2293
+ nextActions: ["inspect_recon_packet", "supply_recon_assessment_json", "continue_internal_loop_with_checkpoint"],
2294
+ advanceOptions: ["recon", "author"],
2295
+ recommendedAdvanceStage: "recon",
2296
+ continueWithStage: "recon",
2297
+ blocking: false,
2298
+ details: reconDetails,
2299
+ reconAssessmentRequest,
2300
+ reconDecisionRequest: state?.recon_decision_request || null,
2301
+ executed
2302
+ }
2303
+ );
2304
+ }
2305
+ }
2306
+ if (!reconAutoAcceptedExplicitCapture) {
2307
+ recordAttempt("recon", "completed", "Recon completed and promoted an approved baseline context.", {
2217
2308
  autoApproved: reconRes.autoApproved || false,
2218
- checkpoint: "recon_supervisor_judgment",
2219
- details: reconDetails
2309
+ details: { executed }
2220
2310
  });
2221
- return checkpoint(
2222
- "recon",
2223
- "recon_supervisor_judgment",
2224
- summary,
2225
- {
2226
- nextActions: ["inspect_recon_packet", "supply_recon_assessment_json", "continue_internal_loop_with_checkpoint"],
2227
- advanceOptions: ["recon", "author"],
2228
- recommendedAdvanceStage: "recon",
2229
- continueWithStage: "recon",
2230
- blocking: false,
2231
- details: reconDetails,
2232
- reconAssessmentRequest,
2233
- reconDecisionRequest: state?.recon_decision_request || null,
2234
- executed
2235
- }
2236
- );
2237
2311
  }
2238
- recordAttempt("recon", "completed", "Recon completed and promoted an approved baseline context.", {
2239
- autoApproved: reconRes.autoApproved || false,
2240
- details: { executed }
2241
- });
2242
2312
  }
2243
2313
  state = readState(config.statePath);
2244
2314
  if (!authorReady(state) || effectiveAdvanceStage === "author") {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  createRiddleProofEngine,
3
3
  executeWorkflow
4
- } from "./chunk-JBY2SU5U.js";
4
+ } from "./chunk-WJZYRUNV.js";
5
5
  import "./chunk-7GZY5PLT.js";
6
6
  import "./chunk-MLKGABMK.js";
7
7
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riddledc/riddle-proof",
3
- "version": "0.8.13",
3
+ "version": "0.8.15",
4
4
  "description": "Reusable Riddle Proof contracts and helpers for evidence-backed agent changes.",
5
5
  "license": "MIT",
6
6
  "author": "RiddleDC",
@@ -3900,6 +3900,16 @@ has_judgable_failed_interaction_evidence = (
3900
3900
  and not proof_evidence_blocker
3901
3901
  and not visual_delta_recovery
3902
3902
  )
3903
+ route_expectation = s.get('route_expectation') if isinstance(s.get('route_expectation'), dict) else {}
3904
+ authored_terminal_route_mismatch = (
3905
+ verification_mode in INTERACTION_MODES
3906
+ and 'wrong route' in str(after_observation.get('reason') or '')
3907
+ and bool(route_expectation.get('terminal_path'))
3908
+ and str(route_expectation.get('source') or '') != 'recon_start_path'
3909
+ )
3910
+ if authored_terminal_route_mismatch:
3911
+ has_judgable_failed_interaction_evidence = False
3912
+ summary_lines.append('Structured interaction route gate: authored terminal route mismatch is a terminal capture blocker.')
3903
3913
  has_good_evidence = (
3904
3914
  required_baseline_present
3905
3915
  and (after_observation.get('valid') or has_judgable_failed_interaction_evidence)
@@ -365,13 +365,18 @@ class FakeRiddle:
365
365
  'hash': '',
366
366
  },
367
367
  'assertions': {
368
- 'expectedUrlPreserved': True,
369
368
  'expectedUrlReachedBeforeDrop': True,
369
+ 'expectedUrlStillPresentAtTerminal': False,
370
+ 'queryDropped': True,
371
+ 'hashDropped': True,
370
372
  'routeExpectationSourceIsCaptureScriptExpectedUrl': True,
371
- 'terminalIntentionallyDroppedQueryHash': True,
372
- 'terminalUrlMismatchIsIntentional': True,
373
+ 'shouldTerminalizeAsFailedInteractionCapture': True,
373
374
  'terminalMainVisible': True,
374
375
  },
376
+ 'checks': {
377
+ 'routeMatches': False,
378
+ 'specificMismatchDetected': True,
379
+ },
375
380
  'errors': [],
376
381
  }
377
382
  return {
@@ -109,6 +109,7 @@ CASES = [
109
109
  GENERIC_FAILURE_MARKERS = (
110
110
  'codex_invalid_json',
111
111
  'codex_no_final_response',
112
+ 'codex_timeout',
112
113
  'max_iterations_reached',
113
114
  'stage_iteration_limit_reached',
114
115
  'unhandled_checkpoint',