@riddledc/riddle-proof 0.5.47 → 0.5.49
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/{chunk-ALP5KOS2.js → chunk-722PW3X3.js} +185 -23
- package/dist/{chunk-PLSGW2GI.js → chunk-CI2F66EE.js} +63 -0
- package/dist/{chunk-JOXTKWX6.js → chunk-U7Q3RB5D.js} +1 -1
- package/dist/{chunk-N3ZNBRIG.js → chunk-YJPQOAZG.js} +1 -1
- package/dist/{chunk-NOBFZDZG.js → chunk-YW77WDTR.js} +104 -10
- package/dist/cli.cjs +369 -35
- package/dist/cli.js +4 -4
- package/dist/codex-exec-agent.cjs +107 -10
- package/dist/codex-exec-agent.d.cts +1 -0
- package/dist/codex-exec-agent.d.ts +1 -0
- package/dist/codex-exec-agent.js +2 -1
- package/dist/engine-harness.cjs +269 -25
- package/dist/engine-harness.js +3 -3
- package/dist/index.cjs +371 -37
- package/dist/index.js +5 -5
- package/dist/local-agent.cjs +107 -10
- package/dist/local-agent.js +2 -1
- package/dist/openclaw.js +2 -2
- package/dist/proof-run-core.d.cts +1 -1
- package/dist/proof-run-core.d.ts +1 -1
- package/dist/proof-run-engine.cjs +23 -4
- package/dist/proof-run-engine.d.cts +3 -3
- package/dist/proof-run-engine.d.ts +3 -3
- package/dist/proof-run-engine.js +23 -4
- package/dist/run-card.cjs +63 -0
- package/dist/run-card.js +1 -1
- package/dist/runner.js +3 -3
- package/dist/state.cjs +63 -0
- package/dist/state.js +2 -2
- package/dist/types.d.cts +12 -0
- package/dist/types.d.ts +12 -0
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1747,9 +1747,27 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
|
|
|
1747
1747
|
}
|
|
1748
1748
|
return "inspect the ship gate details, repair the missing invariant, then resume the run";
|
|
1749
1749
|
};
|
|
1750
|
+
const shipGateRecoveryStage = (shipGate) => {
|
|
1751
|
+
const reasons = shipGate.reasons || [];
|
|
1752
|
+
if (reasons.some((reason) => reason.includes("before_cdn") || reason.includes("prod_cdn") || reason.includes("prod_url"))) {
|
|
1753
|
+
return "recon";
|
|
1754
|
+
}
|
|
1755
|
+
if (reasons.some((reason) => reason.includes("implementation"))) {
|
|
1756
|
+
return "implement";
|
|
1757
|
+
}
|
|
1758
|
+
if (reasons.some((reason) => reason.includes("after_cdn") || reason.includes("verify_status") || reason.includes("visual_delta"))) {
|
|
1759
|
+
return "verify";
|
|
1760
|
+
}
|
|
1761
|
+
if (reasons.some((reason) => reason.includes("proof_assessment"))) {
|
|
1762
|
+
return "verify";
|
|
1763
|
+
}
|
|
1764
|
+
return "verify";
|
|
1765
|
+
};
|
|
1750
1766
|
const shipGateBlocked = (state, executed, details = {}) => {
|
|
1751
1767
|
const shipGate = validateShipGate(state);
|
|
1752
1768
|
const nextAction = primaryShipGateNextAction(shipGate);
|
|
1769
|
+
const recoveryStage = shipGateRecoveryStage(shipGate);
|
|
1770
|
+
const advanceOptions = Array.from(/* @__PURE__ */ new Set([recoveryStage, "verify", "author", "implement", "recon", "ship"]));
|
|
1753
1771
|
return checkpoint(
|
|
1754
1772
|
"verify",
|
|
1755
1773
|
"ship_gate_blocked",
|
|
@@ -1757,12 +1775,13 @@ async function executeWorkflow(params, pluginConfig, resolvedConfig) {
|
|
|
1757
1775
|
{
|
|
1758
1776
|
ok: false,
|
|
1759
1777
|
nextActions: ["inspect_ship_gate", "advance_run_to_verify", "supply_proof_assessment_json", "return_to_recon_if_baseline_is_missing"],
|
|
1760
|
-
advanceOptions
|
|
1761
|
-
recommendedAdvanceStage:
|
|
1762
|
-
continueWithStage:
|
|
1778
|
+
advanceOptions,
|
|
1779
|
+
recommendedAdvanceStage: recoveryStage,
|
|
1780
|
+
continueWithStage: recoveryStage,
|
|
1763
1781
|
blocking: true,
|
|
1764
|
-
details: { ...details, shipGate, next_action: nextAction, executed },
|
|
1782
|
+
details: { ...details, shipGate, next_action: nextAction, recovery_stage: recoveryStage, executed },
|
|
1765
1783
|
nextAction,
|
|
1784
|
+
recoveryStage,
|
|
1766
1785
|
shipGate,
|
|
1767
1786
|
verifyStatus: state?.verify_status || null,
|
|
1768
1787
|
mergeRecommendation: state?.merge_recommendation || null,
|
|
@@ -3631,6 +3650,68 @@ function compactText2(value, limit = 600) {
|
|
|
3631
3650
|
if (!text) return void 0;
|
|
3632
3651
|
return text.length <= limit ? text : `${text.slice(0, limit - 20).trimEnd()}...`;
|
|
3633
3652
|
}
|
|
3653
|
+
function numericValue(value) {
|
|
3654
|
+
const number = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
|
|
3655
|
+
return Number.isFinite(number) ? number : void 0;
|
|
3656
|
+
}
|
|
3657
|
+
function eventDetails(event) {
|
|
3658
|
+
return recordValue(recordValue(event)?.details) || {};
|
|
3659
|
+
}
|
|
3660
|
+
function collectRunnerMetrics(details) {
|
|
3661
|
+
const metrics = [];
|
|
3662
|
+
const adapterDetails = recordValue(details.adapter_details);
|
|
3663
|
+
const direct = recordValue(adapterDetails?.runner_metrics);
|
|
3664
|
+
if (direct) metrics.push(direct);
|
|
3665
|
+
const attempts = Array.isArray(adapterDetails?.attempt_summaries) ? adapterDetails.attempt_summaries : [];
|
|
3666
|
+
for (const attempt of attempts) {
|
|
3667
|
+
const attemptMetrics = recordValue(recordValue(attempt)?.runner_metrics);
|
|
3668
|
+
if (attemptMetrics) metrics.push(attemptMetrics);
|
|
3669
|
+
}
|
|
3670
|
+
return metrics;
|
|
3671
|
+
}
|
|
3672
|
+
function observabilityFrom(state) {
|
|
3673
|
+
const engineEvents = state.events.filter((event) => event.kind === "engine.result").map((event) => ({ event, details: eventDetails(event) }));
|
|
3674
|
+
const agentEvents = state.events.filter((event) => event.kind.startsWith("agent.")).map((event) => ({ event, details: eventDetails(event) })).filter(({ details }) => numericValue(details.duration_ms) !== void 0);
|
|
3675
|
+
const retryEvents = state.events.filter((event) => /retry|recovery/i.test(event.kind) || /retry|recovery/i.test(event.summary || "")).slice(-8);
|
|
3676
|
+
const runnerMetrics2 = agentEvents.flatMap(({ details }) => collectRunnerMetrics(details));
|
|
3677
|
+
const promptChars = runnerMetrics2.map((metrics) => numericValue(metrics.prompt_chars)).filter((value) => value !== void 0);
|
|
3678
|
+
const sum = (values) => values.reduce((total, value) => total + (value ?? 0), 0);
|
|
3679
|
+
const recentEngineTimings = engineEvents.slice(-8).map(({ event, details }) => compactRecord({
|
|
3680
|
+
checkpoint: event.checkpoint || null,
|
|
3681
|
+
stage: event.stage || null,
|
|
3682
|
+
duration_ms: numericValue(details.duration_ms),
|
|
3683
|
+
ok: details.ok ?? null
|
|
3684
|
+
}));
|
|
3685
|
+
const recentAgentTimings = agentEvents.slice(-8).map(({ event, details }) => {
|
|
3686
|
+
const metrics = collectRunnerMetrics(details);
|
|
3687
|
+
const localPromptChars = metrics.map((item) => numericValue(item.prompt_chars)).filter((value) => value !== void 0);
|
|
3688
|
+
return compactRecord({
|
|
3689
|
+
kind: event.kind,
|
|
3690
|
+
checkpoint: event.checkpoint || null,
|
|
3691
|
+
stage: event.stage || null,
|
|
3692
|
+
duration_ms: numericValue(details.duration_ms),
|
|
3693
|
+
prompt_chars: localPromptChars.length ? Math.max(...localPromptChars) : void 0,
|
|
3694
|
+
attempt_count: numericValue(recordValue(details.adapter_details)?.attempt_count)
|
|
3695
|
+
});
|
|
3696
|
+
});
|
|
3697
|
+
return compactRecord({
|
|
3698
|
+
engine_call_count: engineEvents.length,
|
|
3699
|
+
agent_call_count: agentEvents.length,
|
|
3700
|
+
engine_total_ms: sum(engineEvents.map(({ details }) => numericValue(details.duration_ms))),
|
|
3701
|
+
agent_total_ms: sum(agentEvents.map(({ details }) => numericValue(details.duration_ms))),
|
|
3702
|
+
max_agent_prompt_chars: promptChars.length ? Math.max(...promptChars) : void 0,
|
|
3703
|
+
total_agent_prompt_chars: promptChars.length ? sum(promptChars) : void 0,
|
|
3704
|
+
recent_engine_timings: recentEngineTimings.length ? recentEngineTimings : void 0,
|
|
3705
|
+
recent_agent_timings: recentAgentTimings.length ? recentAgentTimings : void 0,
|
|
3706
|
+
retry_event_count: retryEvents.length,
|
|
3707
|
+
recent_retry_reasons: retryEvents.length ? retryEvents.map((event) => compactRecord({
|
|
3708
|
+
kind: event.kind,
|
|
3709
|
+
checkpoint: event.checkpoint || null,
|
|
3710
|
+
stage: event.stage || null,
|
|
3711
|
+
summary: compactText2(event.summary, 240)
|
|
3712
|
+
})) : void 0
|
|
3713
|
+
});
|
|
3714
|
+
}
|
|
3634
3715
|
function visualDeltaFrom(input) {
|
|
3635
3716
|
const fullState = input.fullRiddleState || {};
|
|
3636
3717
|
const bundle = recordValue(fullState.evidence_bundle);
|
|
@@ -3743,6 +3824,7 @@ function createRiddleProofRunCard(state, input = {}) {
|
|
|
3743
3824
|
proof_evidence_present: fullState.proof_evidence_present === true || Boolean(bundle?.proof_evidence || bundle?.proof_evidence_sample),
|
|
3744
3825
|
artifacts
|
|
3745
3826
|
}),
|
|
3827
|
+
observability: observabilityFrom(state),
|
|
3746
3828
|
stop_condition: compactRecord({
|
|
3747
3829
|
status: state.status,
|
|
3748
3830
|
terminal: isTerminalStatus(state.status),
|
|
@@ -4180,6 +4262,20 @@ function checkpointContinueStage2(result) {
|
|
|
4180
4262
|
const resume = recordValue(result.checkpointContract?.resume);
|
|
4181
4263
|
return nonEmptyString(resume?.continue_with_stage);
|
|
4182
4264
|
}
|
|
4265
|
+
function checkpointRecommendedStage(result) {
|
|
4266
|
+
const resumeStage = checkpointContinueStage2(result);
|
|
4267
|
+
if (resumeStage) return resumeStage;
|
|
4268
|
+
return nonEmptyString(result.checkpointContract?.recommended_advance_stage) || nonEmptyString(result.decisionRequest?.continue_with_stage) || nonEmptyString(result.decisionRequest?.recommended_advance_stage) || nonEmptyString(recordValue(result.decisionRequest)?.continueWithStage) || nonEmptyString(recordValue(result.decisionRequest)?.recommendedAdvanceStage);
|
|
4269
|
+
}
|
|
4270
|
+
function stageCheckpointContinuation(result) {
|
|
4271
|
+
const stage = checkpointRecommendedStage(result);
|
|
4272
|
+
if (!stage) return null;
|
|
4273
|
+
return {
|
|
4274
|
+
action: "run",
|
|
4275
|
+
state_path: String(result.state_path || ""),
|
|
4276
|
+
advance_stage: stage
|
|
4277
|
+
};
|
|
4278
|
+
}
|
|
4183
4279
|
function recommendedContinuation(result) {
|
|
4184
4280
|
const continueStage = checkpointContinueStage2(result);
|
|
4185
4281
|
if (!continueStage) return null;
|
|
@@ -4222,6 +4318,18 @@ function defaultStageForProofCheckpointDecision(decision) {
|
|
|
4222
4318
|
if (decision === "needs_richer_proof") return "author";
|
|
4223
4319
|
return null;
|
|
4224
4320
|
}
|
|
4321
|
+
function checkpointContractFromPacket(packet) {
|
|
4322
|
+
return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
|
|
4323
|
+
}
|
|
4324
|
+
function stageFromCheckpointResponse(response, packet) {
|
|
4325
|
+
if (response.decision === "needs_recon") return "recon";
|
|
4326
|
+
if (response.decision === "needs_implementation") return "implement";
|
|
4327
|
+
const payload = recordValue(response.payload) || {};
|
|
4328
|
+
const contract = checkpointContractFromPacket(packet);
|
|
4329
|
+
const resume = recordValue(contract?.resume);
|
|
4330
|
+
const stage = response.continue_with_stage || nonEmptyString(payload.continue_with_stage) || nonEmptyString(payload.recommended_stage) || nonEmptyString(resume?.continue_with_stage) || (response.decision === "retry_stage" ? packet.stage : "");
|
|
4331
|
+
return stage ? stage : null;
|
|
4332
|
+
}
|
|
4225
4333
|
function proofAssessmentPayloadFromCheckpointResponse(response) {
|
|
4226
4334
|
if (![
|
|
4227
4335
|
"ready_to_ship",
|
|
@@ -4324,6 +4432,13 @@ function visualDeltaEvidenceRecoveryAssessment(state, payload, blocker) {
|
|
|
4324
4432
|
blockers: [...blockers, blocker]
|
|
4325
4433
|
};
|
|
4326
4434
|
}
|
|
4435
|
+
function isRecoverableStageCheckpoint(checkpoint) {
|
|
4436
|
+
return [
|
|
4437
|
+
"ship_gate_blocked",
|
|
4438
|
+
"verify_required",
|
|
4439
|
+
"verify_supervisor_judgment_required"
|
|
4440
|
+
].includes(checkpoint);
|
|
4441
|
+
}
|
|
4327
4442
|
function contextFor(request, state, result) {
|
|
4328
4443
|
return {
|
|
4329
4444
|
request,
|
|
@@ -4670,6 +4785,18 @@ function checkpointResponseContinuation(state, value) {
|
|
|
4670
4785
|
};
|
|
4671
4786
|
}
|
|
4672
4787
|
}
|
|
4788
|
+
if (response.decision === "continue_stage" || response.decision === "retry_stage" || response.decision === "needs_implementation") {
|
|
4789
|
+
const stage = stageFromCheckpointResponse(response, packet);
|
|
4790
|
+
if (stage) {
|
|
4791
|
+
appendCheckpointResponse(state, response);
|
|
4792
|
+
return {
|
|
4793
|
+
next: {
|
|
4794
|
+
...base,
|
|
4795
|
+
advance_stage: stage
|
|
4796
|
+
}
|
|
4797
|
+
};
|
|
4798
|
+
}
|
|
4799
|
+
}
|
|
4673
4800
|
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
4674
4801
|
return {
|
|
4675
4802
|
blocker: {
|
|
@@ -4752,7 +4879,10 @@ async function handleImplementation(request, state, result, agent) {
|
|
|
4752
4879
|
worktree_path: workdir || null
|
|
4753
4880
|
}
|
|
4754
4881
|
});
|
|
4882
|
+
const implementationStartedAt = timestamp3();
|
|
4883
|
+
const implementationStartedMs = Date.now();
|
|
4755
4884
|
const implementation = await agent.implementChange({ ...context, workdir });
|
|
4885
|
+
const implementationDurationMs = Date.now() - implementationStartedMs;
|
|
4756
4886
|
if (implementation.blocker || implementation.ok === false) {
|
|
4757
4887
|
recordEvent(state, {
|
|
4758
4888
|
kind: "agent.implementation.blocked",
|
|
@@ -4761,6 +4891,8 @@ async function handleImplementation(request, state, result, agent) {
|
|
|
4761
4891
|
summary: implementation.summary || implementation.blocker?.message || "Implementation adapter reported a blocker.",
|
|
4762
4892
|
details: compactRecord({
|
|
4763
4893
|
worktree_path: workdir || null,
|
|
4894
|
+
started_at: implementationStartedAt,
|
|
4895
|
+
duration_ms: implementationDurationMs,
|
|
4764
4896
|
changed_files: implementation.changedFiles || [],
|
|
4765
4897
|
tests_run: implementation.testsRun || [],
|
|
4766
4898
|
implementation_notes: implementation.implementationNotes || null,
|
|
@@ -4786,24 +4918,32 @@ async function handleImplementation(request, state, result, agent) {
|
|
|
4786
4918
|
summary: implementation.summary || "Implementation adapter returned without leaving a detectable git diff.",
|
|
4787
4919
|
details: compactRecord({
|
|
4788
4920
|
worktree_path: workdir || null,
|
|
4921
|
+
started_at: implementationStartedAt,
|
|
4922
|
+
duration_ms: implementationDurationMs,
|
|
4789
4923
|
changed_files: implementation.changedFiles || [],
|
|
4790
4924
|
tests_run: implementation.testsRun || [],
|
|
4791
4925
|
implementation_notes: implementation.implementationNotes || null,
|
|
4792
4926
|
adapter_details: implementation.details || null
|
|
4793
4927
|
})
|
|
4794
4928
|
});
|
|
4795
|
-
|
|
4796
|
-
|
|
4797
|
-
|
|
4929
|
+
recordEvent(state, {
|
|
4930
|
+
kind: "agent.implementation.retry_requested",
|
|
4931
|
+
checkpoint: result.checkpoint || null,
|
|
4932
|
+
stage: "implement",
|
|
4933
|
+
summary: "Implementation adapter left no detectable diff; retrying the implement checkpoint inside the bounded loop.",
|
|
4934
|
+
details: compactRecord({
|
|
4935
|
+
worktree_path: workdir || null,
|
|
4798
4936
|
checkpoint: result.checkpoint || null,
|
|
4799
|
-
|
|
4800
|
-
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
|
|
4937
|
+
next_stage: "implement",
|
|
4938
|
+
previous_duration_ms: implementationDurationMs
|
|
4939
|
+
})
|
|
4940
|
+
});
|
|
4941
|
+
return {
|
|
4942
|
+
next: {
|
|
4943
|
+
action: "run",
|
|
4944
|
+
state_path: String(result.state_path || ""),
|
|
4945
|
+
advance_stage: "implement",
|
|
4946
|
+
implementation_notes: implementation.implementationNotes || implementation.summary || "Implementation adapter returned without a detectable git diff; retry the implement checkpoint."
|
|
4807
4947
|
}
|
|
4808
4948
|
};
|
|
4809
4949
|
}
|
|
@@ -4814,6 +4954,8 @@ async function handleImplementation(request, state, result, agent) {
|
|
|
4814
4954
|
summary: implementation.summary || "Implementation adapter reported code changes.",
|
|
4815
4955
|
details: {
|
|
4816
4956
|
worktree_path: workdir || null,
|
|
4957
|
+
started_at: implementationStartedAt,
|
|
4958
|
+
duration_ms: implementationDurationMs,
|
|
4817
4959
|
diffDetected,
|
|
4818
4960
|
changed_files: implementation.changedFiles || [],
|
|
4819
4961
|
tests_run: implementation.testsRun || [],
|
|
@@ -4839,16 +4981,32 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
4839
4981
|
terminal: terminalResult(state, "completed", result, result.summary || "Riddle Proof engine completed.")
|
|
4840
4982
|
};
|
|
4841
4983
|
}
|
|
4984
|
+
if (isRecoverableStageCheckpoint(checkpoint) && !input.dry_run && !request.dry_run) {
|
|
4985
|
+
if (input.checkpoint_mode === "yield") {
|
|
4986
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
4987
|
+
}
|
|
4988
|
+
const next = stageCheckpointContinuation(result);
|
|
4989
|
+
if (next) {
|
|
4990
|
+
recordEvent(state, {
|
|
4991
|
+
kind: "checkpoint.recovery_continuation",
|
|
4992
|
+
checkpoint,
|
|
4993
|
+
stage: stageFromCheckpoint2(result),
|
|
4994
|
+
summary: `Routing recoverable checkpoint ${checkpoint} back to ${next.advance_stage}.`,
|
|
4995
|
+
details: {
|
|
4996
|
+
next,
|
|
4997
|
+
checkpointContract: result.checkpointContract || null
|
|
4998
|
+
}
|
|
4999
|
+
});
|
|
5000
|
+
return { next };
|
|
5001
|
+
}
|
|
5002
|
+
}
|
|
4842
5003
|
const failureBlocker = engineFailureBlocker(result, checkpoint);
|
|
4843
5004
|
if (failureBlocker) {
|
|
4844
5005
|
return { blocker: failureBlocker };
|
|
4845
5006
|
}
|
|
4846
5007
|
if ([
|
|
4847
5008
|
"recon_human_escalation",
|
|
4848
|
-
"verify_human_escalation"
|
|
4849
|
-
"ship_gate_blocked",
|
|
4850
|
-
"verify_required",
|
|
4851
|
-
"verify_supervisor_judgment_required"
|
|
5009
|
+
"verify_human_escalation"
|
|
4852
5010
|
].includes(checkpoint) && result.ok === false) {
|
|
4853
5011
|
return {
|
|
4854
5012
|
blocker: {
|
|
@@ -4914,15 +5072,44 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
4914
5072
|
if (input.checkpoint_mode === "yield") {
|
|
4915
5073
|
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
4916
5074
|
}
|
|
5075
|
+
const startedAt = timestamp3();
|
|
5076
|
+
const startedMs = Date.now();
|
|
5077
|
+
recordEvent(state, {
|
|
5078
|
+
kind: "agent.recon_assessment.started",
|
|
5079
|
+
checkpoint,
|
|
5080
|
+
stage: "recon",
|
|
5081
|
+
summary: "Recon assessment agent started.",
|
|
5082
|
+
details: { started_at: startedAt }
|
|
5083
|
+
});
|
|
4917
5084
|
const assessment = await agent.assessRecon(context);
|
|
5085
|
+
const durationMs = Date.now() - startedMs;
|
|
4918
5086
|
const blocker = requirePayload("recon_assessment", assessment, state, result);
|
|
4919
|
-
if (blocker)
|
|
5087
|
+
if (blocker) {
|
|
5088
|
+
recordEvent(state, {
|
|
5089
|
+
kind: "agent.recon_assessment.blocked",
|
|
5090
|
+
checkpoint,
|
|
5091
|
+
stage: "recon",
|
|
5092
|
+
summary: blocker.message,
|
|
5093
|
+
details: compactRecord({
|
|
5094
|
+
started_at: startedAt,
|
|
5095
|
+
duration_ms: durationMs,
|
|
5096
|
+
blocker,
|
|
5097
|
+
adapter_details: assessment.details || null
|
|
5098
|
+
})
|
|
5099
|
+
});
|
|
5100
|
+
return { blocker };
|
|
5101
|
+
}
|
|
4920
5102
|
recordEvent(state, {
|
|
4921
5103
|
kind: "agent.recon_assessment.completed",
|
|
4922
5104
|
checkpoint,
|
|
4923
5105
|
stage: "recon",
|
|
4924
5106
|
summary: assessment.summary,
|
|
4925
|
-
details: {
|
|
5107
|
+
details: compactRecord({
|
|
5108
|
+
payload: assessment.payload,
|
|
5109
|
+
started_at: startedAt,
|
|
5110
|
+
duration_ms: durationMs,
|
|
5111
|
+
adapter_details: assessment.details || null
|
|
5112
|
+
})
|
|
4926
5113
|
});
|
|
4927
5114
|
return {
|
|
4928
5115
|
next: { ...baseContinuation(result), recon_assessment_json: jsonParam(assessment.payload) }
|
|
@@ -4934,15 +5121,44 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
4934
5121
|
if (input.checkpoint_mode === "yield") {
|
|
4935
5122
|
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
4936
5123
|
}
|
|
5124
|
+
const startedAt = timestamp3();
|
|
5125
|
+
const startedMs = Date.now();
|
|
5126
|
+
recordEvent(state, {
|
|
5127
|
+
kind: "agent.author_packet.started",
|
|
5128
|
+
checkpoint,
|
|
5129
|
+
stage: "author",
|
|
5130
|
+
summary: "Proof authoring agent started.",
|
|
5131
|
+
details: { started_at: startedAt }
|
|
5132
|
+
});
|
|
4937
5133
|
const packet = await agent.authorProofPacket(context);
|
|
5134
|
+
const durationMs = Date.now() - startedMs;
|
|
4938
5135
|
const blocker = requirePayload("author_packet", packet, state, result);
|
|
4939
|
-
if (blocker)
|
|
5136
|
+
if (blocker) {
|
|
5137
|
+
recordEvent(state, {
|
|
5138
|
+
kind: "agent.author_packet.blocked",
|
|
5139
|
+
checkpoint,
|
|
5140
|
+
stage: "author",
|
|
5141
|
+
summary: blocker.message,
|
|
5142
|
+
details: compactRecord({
|
|
5143
|
+
started_at: startedAt,
|
|
5144
|
+
duration_ms: durationMs,
|
|
5145
|
+
blocker,
|
|
5146
|
+
adapter_details: packet.details || null
|
|
5147
|
+
})
|
|
5148
|
+
});
|
|
5149
|
+
return { blocker };
|
|
5150
|
+
}
|
|
4940
5151
|
recordEvent(state, {
|
|
4941
5152
|
kind: "agent.author_packet.completed",
|
|
4942
5153
|
checkpoint,
|
|
4943
5154
|
stage: "author",
|
|
4944
5155
|
summary: packet.summary,
|
|
4945
|
-
details: {
|
|
5156
|
+
details: compactRecord({
|
|
5157
|
+
payload: packet.payload,
|
|
5158
|
+
started_at: startedAt,
|
|
5159
|
+
duration_ms: durationMs,
|
|
5160
|
+
adapter_details: packet.details || null
|
|
5161
|
+
})
|
|
4946
5162
|
});
|
|
4947
5163
|
return {
|
|
4948
5164
|
next: { ...baseContinuation(result), author_packet_json: jsonParam(packet.payload) }
|
|
@@ -4965,9 +5181,31 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
4965
5181
|
if (input.checkpoint_mode === "yield") {
|
|
4966
5182
|
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
4967
5183
|
}
|
|
5184
|
+
const startedAt = timestamp3();
|
|
5185
|
+
const startedMs = Date.now();
|
|
5186
|
+
recordEvent(state, {
|
|
5187
|
+
kind: "agent.proof_assessment.started",
|
|
5188
|
+
checkpoint,
|
|
5189
|
+
stage: "verify",
|
|
5190
|
+
summary: "Proof assessment agent started.",
|
|
5191
|
+
details: { started_at: startedAt }
|
|
5192
|
+
});
|
|
4968
5193
|
const assessment = await agent.assessProof(context);
|
|
5194
|
+
const durationMs = Date.now() - startedMs;
|
|
4969
5195
|
const blocker = requirePayload("proof_assessment", assessment, state, result);
|
|
4970
5196
|
if (blocker) {
|
|
5197
|
+
recordEvent(state, {
|
|
5198
|
+
kind: "agent.proof_assessment.blocked",
|
|
5199
|
+
checkpoint,
|
|
5200
|
+
stage: "verify",
|
|
5201
|
+
summary: blocker.message,
|
|
5202
|
+
details: compactRecord({
|
|
5203
|
+
started_at: startedAt,
|
|
5204
|
+
duration_ms: durationMs,
|
|
5205
|
+
blocker,
|
|
5206
|
+
adapter_details: assessment.details || null
|
|
5207
|
+
})
|
|
5208
|
+
});
|
|
4971
5209
|
if (blocker.code === "main_agent_proof_review_required") {
|
|
4972
5210
|
recordEvent(state, {
|
|
4973
5211
|
kind: "checkpoint.packet.requested",
|
|
@@ -4986,7 +5224,12 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
4986
5224
|
checkpoint,
|
|
4987
5225
|
stage: "verify",
|
|
4988
5226
|
summary: assessment.summary,
|
|
4989
|
-
details: {
|
|
5227
|
+
details: compactRecord({
|
|
5228
|
+
payload,
|
|
5229
|
+
started_at: startedAt,
|
|
5230
|
+
duration_ms: durationMs,
|
|
5231
|
+
adapter_details: assessment.details || null
|
|
5232
|
+
})
|
|
4990
5233
|
});
|
|
4991
5234
|
const visualBlocker = proofAssessmentVisualBlocker({
|
|
4992
5235
|
...context.fullRiddleState || {},
|
|
@@ -5007,7 +5250,8 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
5007
5250
|
recovery_stage: "verify",
|
|
5008
5251
|
evidence_issue_code: recoveryAssessment.evidence_issue_code || null,
|
|
5009
5252
|
visual_delta: recoveryAssessment.visual_delta || null,
|
|
5010
|
-
proof_assessment: recoveryAssessment
|
|
5253
|
+
proof_assessment: recoveryAssessment,
|
|
5254
|
+
agent_duration_ms: durationMs
|
|
5011
5255
|
})
|
|
5012
5256
|
});
|
|
5013
5257
|
return { next: proofAssessmentContinuation(result, recoveryAssessment) };
|
|
@@ -5365,10 +5609,10 @@ var PROOF_SCHEMA = {
|
|
|
5365
5609
|
source: { type: "string", enum: ["supervising_agent"] }
|
|
5366
5610
|
}
|
|
5367
5611
|
};
|
|
5368
|
-
var PROMPT_STRING_LIMIT =
|
|
5369
|
-
var PROMPT_ARRAY_LIMIT =
|
|
5370
|
-
var PROMPT_OBJECT_KEY_LIMIT =
|
|
5371
|
-
var PROMPT_BLOCK_LIMIT =
|
|
5612
|
+
var PROMPT_STRING_LIMIT = 1400;
|
|
5613
|
+
var PROMPT_ARRAY_LIMIT = 8;
|
|
5614
|
+
var PROMPT_OBJECT_KEY_LIMIT = 50;
|
|
5615
|
+
var PROMPT_BLOCK_LIMIT = 7e4;
|
|
5372
5616
|
var PROMPT_KEY_PRIORITY = [
|
|
5373
5617
|
"ok",
|
|
5374
5618
|
"status",
|
|
@@ -5390,6 +5634,16 @@ var PROMPT_KEY_PRIORITY = [
|
|
|
5390
5634
|
"after_cdn",
|
|
5391
5635
|
"before_baseline",
|
|
5392
5636
|
"prod_baseline",
|
|
5637
|
+
"route_hints",
|
|
5638
|
+
"route_candidates",
|
|
5639
|
+
"keyword_hits",
|
|
5640
|
+
"observations",
|
|
5641
|
+
"latest_attempt",
|
|
5642
|
+
"attempt_history",
|
|
5643
|
+
"current_plan",
|
|
5644
|
+
"plan_history",
|
|
5645
|
+
"decision_history",
|
|
5646
|
+
"refined_inputs",
|
|
5393
5647
|
"recon_assessment",
|
|
5394
5648
|
"baseline_understanding",
|
|
5395
5649
|
"supervisor_author_packet",
|
|
@@ -5413,6 +5667,7 @@ var PROMPT_KEY_PRIORITY = [
|
|
|
5413
5667
|
"shipGate",
|
|
5414
5668
|
"last_error",
|
|
5415
5669
|
"errors",
|
|
5670
|
+
"runtime_events",
|
|
5416
5671
|
"events"
|
|
5417
5672
|
];
|
|
5418
5673
|
var PROMPT_PRIORITY_INDEX = new Map(PROMPT_KEY_PRIORITY.map((key, index) => [key, index]));
|
|
@@ -5429,7 +5684,7 @@ function compactPromptValue(value, depth = 0, key = "") {
|
|
|
5429
5684
|
if (!looksLikeUrl && (lowerKey.includes("base64") || lowerKey.includes("data_url") || lowerKey.includes("screenshot_blob"))) {
|
|
5430
5685
|
return `[omitted ${value.length} chars from ${key || "large artifact"}]`;
|
|
5431
5686
|
}
|
|
5432
|
-
const limit = looksLikeUrl ? 1e3 : depth <= 1 ? PROMPT_STRING_LIMIT :
|
|
5687
|
+
const limit = looksLikeUrl ? 1e3 : depth <= 1 ? PROMPT_STRING_LIMIT : 900;
|
|
5433
5688
|
return truncatePromptString(value, limit);
|
|
5434
5689
|
}
|
|
5435
5690
|
if (Array.isArray(value)) {
|
|
@@ -5560,11 +5815,39 @@ function isHarnessVerificationOnlyBlocker(blocker) {
|
|
|
5560
5815
|
const text = blocker.toLowerCase();
|
|
5561
5816
|
return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
|
|
5562
5817
|
}
|
|
5818
|
+
function runnerMetrics(input) {
|
|
5819
|
+
const schemaText = JSON.stringify(input.request.schema);
|
|
5820
|
+
const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5821
|
+
return compactRecord({
|
|
5822
|
+
purpose: input.request.purpose,
|
|
5823
|
+
workdir: input.request.workdir,
|
|
5824
|
+
started_at: input.startedAt,
|
|
5825
|
+
finished_at: finishedAt,
|
|
5826
|
+
duration_ms: Date.now() - input.startedMs,
|
|
5827
|
+
prompt_chars: input.request.prompt.length,
|
|
5828
|
+
prompt_lines: input.request.prompt.split(/\r?\n/).length,
|
|
5829
|
+
schema_chars: schemaText.length,
|
|
5830
|
+
stdout_chars: (input.stdout || "").length,
|
|
5831
|
+
stderr_chars: (input.stderr || "").length,
|
|
5832
|
+
final_message_chars: (input.finalText || "").length,
|
|
5833
|
+
exit_status: input.status ?? null,
|
|
5834
|
+
timed_out: input.timedOut || false,
|
|
5835
|
+
error_code: input.errorCode,
|
|
5836
|
+
codex_command: input.config.codexCommand || "codex",
|
|
5837
|
+
codex_model: input.config.codexModel,
|
|
5838
|
+
codex_sandbox: input.config.codexSandbox || "workspace-write",
|
|
5839
|
+
codex_full_auto: input.config.codexFullAuto !== false,
|
|
5840
|
+
timeout_ms: Number(input.config.codexTimeoutMs || 6e5)
|
|
5841
|
+
});
|
|
5842
|
+
}
|
|
5563
5843
|
function createCodexExecJsonRunner(config = {}) {
|
|
5564
5844
|
return (request) => {
|
|
5845
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
5846
|
+
const startedMs = Date.now();
|
|
5565
5847
|
if (!request.workdir || !(0, import_node_fs4.existsSync)(request.workdir)) {
|
|
5566
5848
|
return {
|
|
5567
5849
|
ok: false,
|
|
5850
|
+
metrics: runnerMetrics({ request, config, startedAt, startedMs, errorCode: "workdir_missing" }),
|
|
5568
5851
|
blocker: {
|
|
5569
5852
|
code: "codex_workdir_missing",
|
|
5570
5853
|
message: `Codex workdir does not exist for ${request.purpose}.`,
|
|
@@ -5609,6 +5892,17 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
5609
5892
|
ok: false,
|
|
5610
5893
|
stdout: proc.stdout || "",
|
|
5611
5894
|
stderr: proc.stderr || "",
|
|
5895
|
+
metrics: runnerMetrics({
|
|
5896
|
+
request,
|
|
5897
|
+
config,
|
|
5898
|
+
startedAt,
|
|
5899
|
+
startedMs,
|
|
5900
|
+
stdout: proc.stdout || "",
|
|
5901
|
+
stderr: proc.stderr || "",
|
|
5902
|
+
status: proc.status,
|
|
5903
|
+
timedOut,
|
|
5904
|
+
errorCode: proc.error.code || "spawn_error"
|
|
5905
|
+
}),
|
|
5612
5906
|
blocker: {
|
|
5613
5907
|
code: timedOut ? "codex_timeout" : "codex_exec_error",
|
|
5614
5908
|
message: timedOut ? `Codex timed out during ${request.purpose}.` : `Codex failed to start or complete ${request.purpose}.`,
|
|
@@ -5621,6 +5915,16 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
5621
5915
|
ok: false,
|
|
5622
5916
|
stdout: proc.stdout || "",
|
|
5623
5917
|
stderr: proc.stderr || "",
|
|
5918
|
+
metrics: runnerMetrics({
|
|
5919
|
+
request,
|
|
5920
|
+
config,
|
|
5921
|
+
startedAt,
|
|
5922
|
+
startedMs,
|
|
5923
|
+
stdout: proc.stdout || "",
|
|
5924
|
+
stderr: proc.stderr || "",
|
|
5925
|
+
status: proc.status,
|
|
5926
|
+
errorCode: "nonzero_exit"
|
|
5927
|
+
}),
|
|
5624
5928
|
blocker: {
|
|
5625
5929
|
code: "codex_nonzero_exit",
|
|
5626
5930
|
message: `Codex exited with status ${proc.status} during ${request.purpose}.`,
|
|
@@ -5635,6 +5939,17 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
5635
5939
|
ok: false,
|
|
5636
5940
|
stdout: proc.stdout || "",
|
|
5637
5941
|
stderr: proc.stderr || "",
|
|
5942
|
+
metrics: runnerMetrics({
|
|
5943
|
+
request,
|
|
5944
|
+
config,
|
|
5945
|
+
startedAt,
|
|
5946
|
+
startedMs,
|
|
5947
|
+
stdout: proc.stdout || "",
|
|
5948
|
+
stderr: proc.stderr || "",
|
|
5949
|
+
finalText,
|
|
5950
|
+
status: proc.status,
|
|
5951
|
+
errorCode: "invalid_json"
|
|
5952
|
+
}),
|
|
5638
5953
|
blocker: {
|
|
5639
5954
|
code: "codex_invalid_json",
|
|
5640
5955
|
message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
@@ -5646,7 +5961,17 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
5646
5961
|
ok: true,
|
|
5647
5962
|
json: parsed,
|
|
5648
5963
|
stdout: proc.stdout || "",
|
|
5649
|
-
stderr: proc.stderr || ""
|
|
5964
|
+
stderr: proc.stderr || "",
|
|
5965
|
+
metrics: runnerMetrics({
|
|
5966
|
+
request,
|
|
5967
|
+
config,
|
|
5968
|
+
startedAt,
|
|
5969
|
+
startedMs,
|
|
5970
|
+
stdout: proc.stdout || "",
|
|
5971
|
+
stderr: proc.stderr || "",
|
|
5972
|
+
finalText,
|
|
5973
|
+
status: proc.status
|
|
5974
|
+
})
|
|
5650
5975
|
};
|
|
5651
5976
|
} finally {
|
|
5652
5977
|
(0, import_node_fs4.rmSync)(tmpDir, { recursive: true, force: true });
|
|
@@ -5667,14 +5992,21 @@ function payloadOrBlocker(raw, checkpoint) {
|
|
|
5667
5992
|
ok: false,
|
|
5668
5993
|
blocker: {
|
|
5669
5994
|
...blocker,
|
|
5670
|
-
checkpoint
|
|
5995
|
+
checkpoint,
|
|
5996
|
+
details: {
|
|
5997
|
+
...blocker.details || {},
|
|
5998
|
+
runner_metrics: raw.metrics || null
|
|
5999
|
+
}
|
|
5671
6000
|
}
|
|
5672
6001
|
};
|
|
5673
6002
|
}
|
|
5674
6003
|
return {
|
|
5675
6004
|
ok: true,
|
|
5676
6005
|
payload: raw.json,
|
|
5677
|
-
summary: typeof raw.json.summary === "string" ? raw.json.summary : void 0
|
|
6006
|
+
summary: typeof raw.json.summary === "string" ? raw.json.summary : void 0,
|
|
6007
|
+
details: compactRecord({
|
|
6008
|
+
runner_metrics: raw.metrics || null
|
|
6009
|
+
})
|
|
5678
6010
|
};
|
|
5679
6011
|
}
|
|
5680
6012
|
function stringArray(value) {
|
|
@@ -5810,14 +6142,16 @@ function createCodexExecAgentAdapter(config = {}, runner = createCodexExecJsonRu
|
|
|
5810
6142
|
agent_summary: summary,
|
|
5811
6143
|
agent_changed_files: changedFiles,
|
|
5812
6144
|
agent_tests_run: testsRun,
|
|
5813
|
-
agent_blockers: blockers
|
|
6145
|
+
agent_blockers: blockers,
|
|
6146
|
+
runner_metrics: raw.metrics || null
|
|
5814
6147
|
};
|
|
5815
6148
|
attemptSummaries.push({
|
|
5816
6149
|
purpose,
|
|
5817
6150
|
summary,
|
|
5818
6151
|
changed_files: changedFiles,
|
|
5819
6152
|
tests_run: testsRun,
|
|
5820
|
-
blockers
|
|
6153
|
+
blockers,
|
|
6154
|
+
runner_metrics: raw.metrics || null
|
|
5821
6155
|
});
|
|
5822
6156
|
if (hardBlockers.length) {
|
|
5823
6157
|
return {
|
package/dist/cli.js
CHANGED
|
@@ -3,15 +3,15 @@ import {
|
|
|
3
3
|
createDisabledRiddleProofAgentAdapter,
|
|
4
4
|
readRiddleProofRunStatus,
|
|
5
5
|
runRiddleProofEngineHarness
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-722PW3X3.js";
|
|
7
7
|
import "./chunk-4ASMX4R6.js";
|
|
8
8
|
import "./chunk-JFQXAJH2.js";
|
|
9
9
|
import {
|
|
10
10
|
createCodexExecAgentAdapter,
|
|
11
11
|
runCodexExecAgentDoctor
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
12
|
+
} from "./chunk-YW77WDTR.js";
|
|
13
|
+
import "./chunk-U7Q3RB5D.js";
|
|
14
|
+
import "./chunk-CI2F66EE.js";
|
|
15
15
|
import "./chunk-R6SCWJCI.js";
|
|
16
16
|
import "./chunk-DUFDZJOF.js";
|
|
17
17
|
|