@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/index.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,
|
|
@@ -3691,6 +3710,68 @@ function compactText2(value, limit = 600) {
|
|
|
3691
3710
|
if (!text) return void 0;
|
|
3692
3711
|
return text.length <= limit ? text : `${text.slice(0, limit - 20).trimEnd()}...`;
|
|
3693
3712
|
}
|
|
3713
|
+
function numericValue(value) {
|
|
3714
|
+
const number = typeof value === "number" ? value : typeof value === "string" ? Number(value) : NaN;
|
|
3715
|
+
return Number.isFinite(number) ? number : void 0;
|
|
3716
|
+
}
|
|
3717
|
+
function eventDetails(event) {
|
|
3718
|
+
return recordValue(recordValue(event)?.details) || {};
|
|
3719
|
+
}
|
|
3720
|
+
function collectRunnerMetrics(details) {
|
|
3721
|
+
const metrics = [];
|
|
3722
|
+
const adapterDetails = recordValue(details.adapter_details);
|
|
3723
|
+
const direct = recordValue(adapterDetails?.runner_metrics);
|
|
3724
|
+
if (direct) metrics.push(direct);
|
|
3725
|
+
const attempts = Array.isArray(adapterDetails?.attempt_summaries) ? adapterDetails.attempt_summaries : [];
|
|
3726
|
+
for (const attempt of attempts) {
|
|
3727
|
+
const attemptMetrics = recordValue(recordValue(attempt)?.runner_metrics);
|
|
3728
|
+
if (attemptMetrics) metrics.push(attemptMetrics);
|
|
3729
|
+
}
|
|
3730
|
+
return metrics;
|
|
3731
|
+
}
|
|
3732
|
+
function observabilityFrom(state) {
|
|
3733
|
+
const engineEvents = state.events.filter((event) => event.kind === "engine.result").map((event) => ({ event, details: eventDetails(event) }));
|
|
3734
|
+
const agentEvents = state.events.filter((event) => event.kind.startsWith("agent.")).map((event) => ({ event, details: eventDetails(event) })).filter(({ details }) => numericValue(details.duration_ms) !== void 0);
|
|
3735
|
+
const retryEvents = state.events.filter((event) => /retry|recovery/i.test(event.kind) || /retry|recovery/i.test(event.summary || "")).slice(-8);
|
|
3736
|
+
const runnerMetrics2 = agentEvents.flatMap(({ details }) => collectRunnerMetrics(details));
|
|
3737
|
+
const promptChars = runnerMetrics2.map((metrics) => numericValue(metrics.prompt_chars)).filter((value) => value !== void 0);
|
|
3738
|
+
const sum = (values) => values.reduce((total, value) => total + (value ?? 0), 0);
|
|
3739
|
+
const recentEngineTimings = engineEvents.slice(-8).map(({ event, details }) => compactRecord({
|
|
3740
|
+
checkpoint: event.checkpoint || null,
|
|
3741
|
+
stage: event.stage || null,
|
|
3742
|
+
duration_ms: numericValue(details.duration_ms),
|
|
3743
|
+
ok: details.ok ?? null
|
|
3744
|
+
}));
|
|
3745
|
+
const recentAgentTimings = agentEvents.slice(-8).map(({ event, details }) => {
|
|
3746
|
+
const metrics = collectRunnerMetrics(details);
|
|
3747
|
+
const localPromptChars = metrics.map((item) => numericValue(item.prompt_chars)).filter((value) => value !== void 0);
|
|
3748
|
+
return compactRecord({
|
|
3749
|
+
kind: event.kind,
|
|
3750
|
+
checkpoint: event.checkpoint || null,
|
|
3751
|
+
stage: event.stage || null,
|
|
3752
|
+
duration_ms: numericValue(details.duration_ms),
|
|
3753
|
+
prompt_chars: localPromptChars.length ? Math.max(...localPromptChars) : void 0,
|
|
3754
|
+
attempt_count: numericValue(recordValue(details.adapter_details)?.attempt_count)
|
|
3755
|
+
});
|
|
3756
|
+
});
|
|
3757
|
+
return compactRecord({
|
|
3758
|
+
engine_call_count: engineEvents.length,
|
|
3759
|
+
agent_call_count: agentEvents.length,
|
|
3760
|
+
engine_total_ms: sum(engineEvents.map(({ details }) => numericValue(details.duration_ms))),
|
|
3761
|
+
agent_total_ms: sum(agentEvents.map(({ details }) => numericValue(details.duration_ms))),
|
|
3762
|
+
max_agent_prompt_chars: promptChars.length ? Math.max(...promptChars) : void 0,
|
|
3763
|
+
total_agent_prompt_chars: promptChars.length ? sum(promptChars) : void 0,
|
|
3764
|
+
recent_engine_timings: recentEngineTimings.length ? recentEngineTimings : void 0,
|
|
3765
|
+
recent_agent_timings: recentAgentTimings.length ? recentAgentTimings : void 0,
|
|
3766
|
+
retry_event_count: retryEvents.length,
|
|
3767
|
+
recent_retry_reasons: retryEvents.length ? retryEvents.map((event) => compactRecord({
|
|
3768
|
+
kind: event.kind,
|
|
3769
|
+
checkpoint: event.checkpoint || null,
|
|
3770
|
+
stage: event.stage || null,
|
|
3771
|
+
summary: compactText2(event.summary, 240)
|
|
3772
|
+
})) : void 0
|
|
3773
|
+
});
|
|
3774
|
+
}
|
|
3694
3775
|
function visualDeltaFrom(input) {
|
|
3695
3776
|
const fullState = input.fullRiddleState || {};
|
|
3696
3777
|
const bundle = recordValue(fullState.evidence_bundle);
|
|
@@ -3803,6 +3884,7 @@ function createRiddleProofRunCard(state, input = {}) {
|
|
|
3803
3884
|
proof_evidence_present: fullState.proof_evidence_present === true || Boolean(bundle?.proof_evidence || bundle?.proof_evidence_sample),
|
|
3804
3885
|
artifacts
|
|
3805
3886
|
}),
|
|
3887
|
+
observability: observabilityFrom(state),
|
|
3806
3888
|
stop_condition: compactRecord({
|
|
3807
3889
|
status: state.status,
|
|
3808
3890
|
terminal: isTerminalStatus(state.status),
|
|
@@ -4773,6 +4855,20 @@ function checkpointContinueStage2(result) {
|
|
|
4773
4855
|
const resume = recordValue(result.checkpointContract?.resume);
|
|
4774
4856
|
return nonEmptyString(resume?.continue_with_stage);
|
|
4775
4857
|
}
|
|
4858
|
+
function checkpointRecommendedStage(result) {
|
|
4859
|
+
const resumeStage = checkpointContinueStage2(result);
|
|
4860
|
+
if (resumeStage) return resumeStage;
|
|
4861
|
+
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);
|
|
4862
|
+
}
|
|
4863
|
+
function stageCheckpointContinuation(result) {
|
|
4864
|
+
const stage = checkpointRecommendedStage(result);
|
|
4865
|
+
if (!stage) return null;
|
|
4866
|
+
return {
|
|
4867
|
+
action: "run",
|
|
4868
|
+
state_path: String(result.state_path || ""),
|
|
4869
|
+
advance_stage: stage
|
|
4870
|
+
};
|
|
4871
|
+
}
|
|
4776
4872
|
function recommendedContinuation(result) {
|
|
4777
4873
|
const continueStage = checkpointContinueStage2(result);
|
|
4778
4874
|
if (!continueStage) return null;
|
|
@@ -4815,6 +4911,18 @@ function defaultStageForProofCheckpointDecision(decision) {
|
|
|
4815
4911
|
if (decision === "needs_richer_proof") return "author";
|
|
4816
4912
|
return null;
|
|
4817
4913
|
}
|
|
4914
|
+
function checkpointContractFromPacket(packet) {
|
|
4915
|
+
return recordValue(packet.evidence_excerpt?.checkpoint_contract) || recordValue(recordValue(packet.state_excerpt?.stage_decision_request)?.checkpoint_contract) || null;
|
|
4916
|
+
}
|
|
4917
|
+
function stageFromCheckpointResponse(response, packet) {
|
|
4918
|
+
if (response.decision === "needs_recon") return "recon";
|
|
4919
|
+
if (response.decision === "needs_implementation") return "implement";
|
|
4920
|
+
const payload = recordValue(response.payload) || {};
|
|
4921
|
+
const contract = checkpointContractFromPacket(packet);
|
|
4922
|
+
const resume = recordValue(contract?.resume);
|
|
4923
|
+
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 : "");
|
|
4924
|
+
return stage ? stage : null;
|
|
4925
|
+
}
|
|
4818
4926
|
function proofAssessmentPayloadFromCheckpointResponse(response) {
|
|
4819
4927
|
if (![
|
|
4820
4928
|
"ready_to_ship",
|
|
@@ -4917,6 +5025,13 @@ function visualDeltaEvidenceRecoveryAssessment(state, payload, blocker) {
|
|
|
4917
5025
|
blockers: [...blockers, blocker]
|
|
4918
5026
|
};
|
|
4919
5027
|
}
|
|
5028
|
+
function isRecoverableStageCheckpoint(checkpoint) {
|
|
5029
|
+
return [
|
|
5030
|
+
"ship_gate_blocked",
|
|
5031
|
+
"verify_required",
|
|
5032
|
+
"verify_supervisor_judgment_required"
|
|
5033
|
+
].includes(checkpoint);
|
|
5034
|
+
}
|
|
4920
5035
|
function contextFor(request, state, result) {
|
|
4921
5036
|
return {
|
|
4922
5037
|
request,
|
|
@@ -5263,6 +5378,18 @@ function checkpointResponseContinuation(state, value) {
|
|
|
5263
5378
|
};
|
|
5264
5379
|
}
|
|
5265
5380
|
}
|
|
5381
|
+
if (response.decision === "continue_stage" || response.decision === "retry_stage" || response.decision === "needs_implementation") {
|
|
5382
|
+
const stage = stageFromCheckpointResponse(response, packet);
|
|
5383
|
+
if (stage) {
|
|
5384
|
+
appendCheckpointResponse(state, response);
|
|
5385
|
+
return {
|
|
5386
|
+
next: {
|
|
5387
|
+
...base,
|
|
5388
|
+
advance_stage: stage
|
|
5389
|
+
}
|
|
5390
|
+
};
|
|
5391
|
+
}
|
|
5392
|
+
}
|
|
5266
5393
|
appendCheckpointResponse(state, response, { clear_packet: false });
|
|
5267
5394
|
return {
|
|
5268
5395
|
blocker: {
|
|
@@ -5345,7 +5472,10 @@ async function handleImplementation(request, state, result, agent) {
|
|
|
5345
5472
|
worktree_path: workdir || null
|
|
5346
5473
|
}
|
|
5347
5474
|
});
|
|
5475
|
+
const implementationStartedAt = timestamp3();
|
|
5476
|
+
const implementationStartedMs = Date.now();
|
|
5348
5477
|
const implementation = await agent.implementChange({ ...context, workdir });
|
|
5478
|
+
const implementationDurationMs = Date.now() - implementationStartedMs;
|
|
5349
5479
|
if (implementation.blocker || implementation.ok === false) {
|
|
5350
5480
|
recordEvent(state, {
|
|
5351
5481
|
kind: "agent.implementation.blocked",
|
|
@@ -5354,6 +5484,8 @@ async function handleImplementation(request, state, result, agent) {
|
|
|
5354
5484
|
summary: implementation.summary || implementation.blocker?.message || "Implementation adapter reported a blocker.",
|
|
5355
5485
|
details: compactRecord({
|
|
5356
5486
|
worktree_path: workdir || null,
|
|
5487
|
+
started_at: implementationStartedAt,
|
|
5488
|
+
duration_ms: implementationDurationMs,
|
|
5357
5489
|
changed_files: implementation.changedFiles || [],
|
|
5358
5490
|
tests_run: implementation.testsRun || [],
|
|
5359
5491
|
implementation_notes: implementation.implementationNotes || null,
|
|
@@ -5379,24 +5511,32 @@ async function handleImplementation(request, state, result, agent) {
|
|
|
5379
5511
|
summary: implementation.summary || "Implementation adapter returned without leaving a detectable git diff.",
|
|
5380
5512
|
details: compactRecord({
|
|
5381
5513
|
worktree_path: workdir || null,
|
|
5514
|
+
started_at: implementationStartedAt,
|
|
5515
|
+
duration_ms: implementationDurationMs,
|
|
5382
5516
|
changed_files: implementation.changedFiles || [],
|
|
5383
5517
|
tests_run: implementation.testsRun || [],
|
|
5384
5518
|
implementation_notes: implementation.implementationNotes || null,
|
|
5385
5519
|
adapter_details: implementation.details || null
|
|
5386
5520
|
})
|
|
5387
5521
|
});
|
|
5388
|
-
|
|
5389
|
-
|
|
5390
|
-
|
|
5522
|
+
recordEvent(state, {
|
|
5523
|
+
kind: "agent.implementation.retry_requested",
|
|
5524
|
+
checkpoint: result.checkpoint || null,
|
|
5525
|
+
stage: "implement",
|
|
5526
|
+
summary: "Implementation adapter left no detectable diff; retrying the implement checkpoint inside the bounded loop.",
|
|
5527
|
+
details: compactRecord({
|
|
5528
|
+
worktree_path: workdir || null,
|
|
5391
5529
|
checkpoint: result.checkpoint || null,
|
|
5392
|
-
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
|
|
5396
|
-
|
|
5397
|
-
|
|
5398
|
-
|
|
5399
|
-
|
|
5530
|
+
next_stage: "implement",
|
|
5531
|
+
previous_duration_ms: implementationDurationMs
|
|
5532
|
+
})
|
|
5533
|
+
});
|
|
5534
|
+
return {
|
|
5535
|
+
next: {
|
|
5536
|
+
action: "run",
|
|
5537
|
+
state_path: String(result.state_path || ""),
|
|
5538
|
+
advance_stage: "implement",
|
|
5539
|
+
implementation_notes: implementation.implementationNotes || implementation.summary || "Implementation adapter returned without a detectable git diff; retry the implement checkpoint."
|
|
5400
5540
|
}
|
|
5401
5541
|
};
|
|
5402
5542
|
}
|
|
@@ -5407,6 +5547,8 @@ async function handleImplementation(request, state, result, agent) {
|
|
|
5407
5547
|
summary: implementation.summary || "Implementation adapter reported code changes.",
|
|
5408
5548
|
details: {
|
|
5409
5549
|
worktree_path: workdir || null,
|
|
5550
|
+
started_at: implementationStartedAt,
|
|
5551
|
+
duration_ms: implementationDurationMs,
|
|
5410
5552
|
diffDetected,
|
|
5411
5553
|
changed_files: implementation.changedFiles || [],
|
|
5412
5554
|
tests_run: implementation.testsRun || [],
|
|
@@ -5432,16 +5574,32 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
5432
5574
|
terminal: terminalResult(state, "completed", result, result.summary || "Riddle Proof engine completed.")
|
|
5433
5575
|
};
|
|
5434
5576
|
}
|
|
5577
|
+
if (isRecoverableStageCheckpoint(checkpoint) && !input.dry_run && !request.dry_run) {
|
|
5578
|
+
if (input.checkpoint_mode === "yield") {
|
|
5579
|
+
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
5580
|
+
}
|
|
5581
|
+
const next = stageCheckpointContinuation(result);
|
|
5582
|
+
if (next) {
|
|
5583
|
+
recordEvent(state, {
|
|
5584
|
+
kind: "checkpoint.recovery_continuation",
|
|
5585
|
+
checkpoint,
|
|
5586
|
+
stage: stageFromCheckpoint2(result),
|
|
5587
|
+
summary: `Routing recoverable checkpoint ${checkpoint} back to ${next.advance_stage}.`,
|
|
5588
|
+
details: {
|
|
5589
|
+
next,
|
|
5590
|
+
checkpointContract: result.checkpointContract || null
|
|
5591
|
+
}
|
|
5592
|
+
});
|
|
5593
|
+
return { next };
|
|
5594
|
+
}
|
|
5595
|
+
}
|
|
5435
5596
|
const failureBlocker = engineFailureBlocker(result, checkpoint);
|
|
5436
5597
|
if (failureBlocker) {
|
|
5437
5598
|
return { blocker: failureBlocker };
|
|
5438
5599
|
}
|
|
5439
5600
|
if ([
|
|
5440
5601
|
"recon_human_escalation",
|
|
5441
|
-
"verify_human_escalation"
|
|
5442
|
-
"ship_gate_blocked",
|
|
5443
|
-
"verify_required",
|
|
5444
|
-
"verify_supervisor_judgment_required"
|
|
5602
|
+
"verify_human_escalation"
|
|
5445
5603
|
].includes(checkpoint) && result.ok === false) {
|
|
5446
5604
|
return {
|
|
5447
5605
|
blocker: {
|
|
@@ -5507,15 +5665,44 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
5507
5665
|
if (input.checkpoint_mode === "yield") {
|
|
5508
5666
|
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
5509
5667
|
}
|
|
5668
|
+
const startedAt = timestamp3();
|
|
5669
|
+
const startedMs = Date.now();
|
|
5670
|
+
recordEvent(state, {
|
|
5671
|
+
kind: "agent.recon_assessment.started",
|
|
5672
|
+
checkpoint,
|
|
5673
|
+
stage: "recon",
|
|
5674
|
+
summary: "Recon assessment agent started.",
|
|
5675
|
+
details: { started_at: startedAt }
|
|
5676
|
+
});
|
|
5510
5677
|
const assessment = await agent.assessRecon(context);
|
|
5678
|
+
const durationMs = Date.now() - startedMs;
|
|
5511
5679
|
const blocker = requirePayload("recon_assessment", assessment, state, result);
|
|
5512
|
-
if (blocker)
|
|
5680
|
+
if (blocker) {
|
|
5681
|
+
recordEvent(state, {
|
|
5682
|
+
kind: "agent.recon_assessment.blocked",
|
|
5683
|
+
checkpoint,
|
|
5684
|
+
stage: "recon",
|
|
5685
|
+
summary: blocker.message,
|
|
5686
|
+
details: compactRecord({
|
|
5687
|
+
started_at: startedAt,
|
|
5688
|
+
duration_ms: durationMs,
|
|
5689
|
+
blocker,
|
|
5690
|
+
adapter_details: assessment.details || null
|
|
5691
|
+
})
|
|
5692
|
+
});
|
|
5693
|
+
return { blocker };
|
|
5694
|
+
}
|
|
5513
5695
|
recordEvent(state, {
|
|
5514
5696
|
kind: "agent.recon_assessment.completed",
|
|
5515
5697
|
checkpoint,
|
|
5516
5698
|
stage: "recon",
|
|
5517
5699
|
summary: assessment.summary,
|
|
5518
|
-
details: {
|
|
5700
|
+
details: compactRecord({
|
|
5701
|
+
payload: assessment.payload,
|
|
5702
|
+
started_at: startedAt,
|
|
5703
|
+
duration_ms: durationMs,
|
|
5704
|
+
adapter_details: assessment.details || null
|
|
5705
|
+
})
|
|
5519
5706
|
});
|
|
5520
5707
|
return {
|
|
5521
5708
|
next: { ...baseContinuation(result), recon_assessment_json: jsonParam(assessment.payload) }
|
|
@@ -5527,15 +5714,44 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
5527
5714
|
if (input.checkpoint_mode === "yield") {
|
|
5528
5715
|
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
5529
5716
|
}
|
|
5717
|
+
const startedAt = timestamp3();
|
|
5718
|
+
const startedMs = Date.now();
|
|
5719
|
+
recordEvent(state, {
|
|
5720
|
+
kind: "agent.author_packet.started",
|
|
5721
|
+
checkpoint,
|
|
5722
|
+
stage: "author",
|
|
5723
|
+
summary: "Proof authoring agent started.",
|
|
5724
|
+
details: { started_at: startedAt }
|
|
5725
|
+
});
|
|
5530
5726
|
const packet = await agent.authorProofPacket(context);
|
|
5727
|
+
const durationMs = Date.now() - startedMs;
|
|
5531
5728
|
const blocker = requirePayload("author_packet", packet, state, result);
|
|
5532
|
-
if (blocker)
|
|
5729
|
+
if (blocker) {
|
|
5730
|
+
recordEvent(state, {
|
|
5731
|
+
kind: "agent.author_packet.blocked",
|
|
5732
|
+
checkpoint,
|
|
5733
|
+
stage: "author",
|
|
5734
|
+
summary: blocker.message,
|
|
5735
|
+
details: compactRecord({
|
|
5736
|
+
started_at: startedAt,
|
|
5737
|
+
duration_ms: durationMs,
|
|
5738
|
+
blocker,
|
|
5739
|
+
adapter_details: packet.details || null
|
|
5740
|
+
})
|
|
5741
|
+
});
|
|
5742
|
+
return { blocker };
|
|
5743
|
+
}
|
|
5533
5744
|
recordEvent(state, {
|
|
5534
5745
|
kind: "agent.author_packet.completed",
|
|
5535
5746
|
checkpoint,
|
|
5536
5747
|
stage: "author",
|
|
5537
5748
|
summary: packet.summary,
|
|
5538
|
-
details: {
|
|
5749
|
+
details: compactRecord({
|
|
5750
|
+
payload: packet.payload,
|
|
5751
|
+
started_at: startedAt,
|
|
5752
|
+
duration_ms: durationMs,
|
|
5753
|
+
adapter_details: packet.details || null
|
|
5754
|
+
})
|
|
5539
5755
|
});
|
|
5540
5756
|
return {
|
|
5541
5757
|
next: { ...baseContinuation(result), author_packet_json: jsonParam(packet.payload) }
|
|
@@ -5558,9 +5774,31 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
5558
5774
|
if (input.checkpoint_mode === "yield") {
|
|
5559
5775
|
return { terminal: checkpointAwaitingResult(state, result, input.checkpoint_visibility) };
|
|
5560
5776
|
}
|
|
5777
|
+
const startedAt = timestamp3();
|
|
5778
|
+
const startedMs = Date.now();
|
|
5779
|
+
recordEvent(state, {
|
|
5780
|
+
kind: "agent.proof_assessment.started",
|
|
5781
|
+
checkpoint,
|
|
5782
|
+
stage: "verify",
|
|
5783
|
+
summary: "Proof assessment agent started.",
|
|
5784
|
+
details: { started_at: startedAt }
|
|
5785
|
+
});
|
|
5561
5786
|
const assessment = await agent.assessProof(context);
|
|
5787
|
+
const durationMs = Date.now() - startedMs;
|
|
5562
5788
|
const blocker = requirePayload("proof_assessment", assessment, state, result);
|
|
5563
5789
|
if (blocker) {
|
|
5790
|
+
recordEvent(state, {
|
|
5791
|
+
kind: "agent.proof_assessment.blocked",
|
|
5792
|
+
checkpoint,
|
|
5793
|
+
stage: "verify",
|
|
5794
|
+
summary: blocker.message,
|
|
5795
|
+
details: compactRecord({
|
|
5796
|
+
started_at: startedAt,
|
|
5797
|
+
duration_ms: durationMs,
|
|
5798
|
+
blocker,
|
|
5799
|
+
adapter_details: assessment.details || null
|
|
5800
|
+
})
|
|
5801
|
+
});
|
|
5564
5802
|
if (blocker.code === "main_agent_proof_review_required") {
|
|
5565
5803
|
recordEvent(state, {
|
|
5566
5804
|
kind: "checkpoint.packet.requested",
|
|
@@ -5579,7 +5817,12 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
5579
5817
|
checkpoint,
|
|
5580
5818
|
stage: "verify",
|
|
5581
5819
|
summary: assessment.summary,
|
|
5582
|
-
details: {
|
|
5820
|
+
details: compactRecord({
|
|
5821
|
+
payload,
|
|
5822
|
+
started_at: startedAt,
|
|
5823
|
+
duration_ms: durationMs,
|
|
5824
|
+
adapter_details: assessment.details || null
|
|
5825
|
+
})
|
|
5583
5826
|
});
|
|
5584
5827
|
const visualBlocker = proofAssessmentVisualBlocker({
|
|
5585
5828
|
...context.fullRiddleState || {},
|
|
@@ -5600,7 +5843,8 @@ async function routeCheckpoint(request, state, result, agent, input) {
|
|
|
5600
5843
|
recovery_stage: "verify",
|
|
5601
5844
|
evidence_issue_code: recoveryAssessment.evidence_issue_code || null,
|
|
5602
5845
|
visual_delta: recoveryAssessment.visual_delta || null,
|
|
5603
|
-
proof_assessment: recoveryAssessment
|
|
5846
|
+
proof_assessment: recoveryAssessment,
|
|
5847
|
+
agent_duration_ms: durationMs
|
|
5604
5848
|
})
|
|
5605
5849
|
});
|
|
5606
5850
|
return { next: proofAssessmentContinuation(result, recoveryAssessment) };
|
|
@@ -5958,10 +6202,10 @@ var PROOF_SCHEMA = {
|
|
|
5958
6202
|
source: { type: "string", enum: ["supervising_agent"] }
|
|
5959
6203
|
}
|
|
5960
6204
|
};
|
|
5961
|
-
var PROMPT_STRING_LIMIT =
|
|
5962
|
-
var PROMPT_ARRAY_LIMIT =
|
|
5963
|
-
var PROMPT_OBJECT_KEY_LIMIT =
|
|
5964
|
-
var PROMPT_BLOCK_LIMIT =
|
|
6205
|
+
var PROMPT_STRING_LIMIT = 1400;
|
|
6206
|
+
var PROMPT_ARRAY_LIMIT = 8;
|
|
6207
|
+
var PROMPT_OBJECT_KEY_LIMIT = 50;
|
|
6208
|
+
var PROMPT_BLOCK_LIMIT = 7e4;
|
|
5965
6209
|
var PROMPT_KEY_PRIORITY = [
|
|
5966
6210
|
"ok",
|
|
5967
6211
|
"status",
|
|
@@ -5983,6 +6227,16 @@ var PROMPT_KEY_PRIORITY = [
|
|
|
5983
6227
|
"after_cdn",
|
|
5984
6228
|
"before_baseline",
|
|
5985
6229
|
"prod_baseline",
|
|
6230
|
+
"route_hints",
|
|
6231
|
+
"route_candidates",
|
|
6232
|
+
"keyword_hits",
|
|
6233
|
+
"observations",
|
|
6234
|
+
"latest_attempt",
|
|
6235
|
+
"attempt_history",
|
|
6236
|
+
"current_plan",
|
|
6237
|
+
"plan_history",
|
|
6238
|
+
"decision_history",
|
|
6239
|
+
"refined_inputs",
|
|
5986
6240
|
"recon_assessment",
|
|
5987
6241
|
"baseline_understanding",
|
|
5988
6242
|
"supervisor_author_packet",
|
|
@@ -6006,6 +6260,7 @@ var PROMPT_KEY_PRIORITY = [
|
|
|
6006
6260
|
"shipGate",
|
|
6007
6261
|
"last_error",
|
|
6008
6262
|
"errors",
|
|
6263
|
+
"runtime_events",
|
|
6009
6264
|
"events"
|
|
6010
6265
|
];
|
|
6011
6266
|
var PROMPT_PRIORITY_INDEX = new Map(PROMPT_KEY_PRIORITY.map((key, index) => [key, index]));
|
|
@@ -6022,7 +6277,7 @@ function compactPromptValue(value, depth = 0, key = "") {
|
|
|
6022
6277
|
if (!looksLikeUrl && (lowerKey.includes("base64") || lowerKey.includes("data_url") || lowerKey.includes("screenshot_blob"))) {
|
|
6023
6278
|
return `[omitted ${value.length} chars from ${key || "large artifact"}]`;
|
|
6024
6279
|
}
|
|
6025
|
-
const limit = looksLikeUrl ? 1e3 : depth <= 1 ? PROMPT_STRING_LIMIT :
|
|
6280
|
+
const limit = looksLikeUrl ? 1e3 : depth <= 1 ? PROMPT_STRING_LIMIT : 900;
|
|
6026
6281
|
return truncatePromptString(value, limit);
|
|
6027
6282
|
}
|
|
6028
6283
|
if (Array.isArray(value)) {
|
|
@@ -6153,11 +6408,39 @@ function isHarnessVerificationOnlyBlocker(blocker) {
|
|
|
6153
6408
|
const text = blocker.toLowerCase();
|
|
6154
6409
|
return (text.includes("erofs") || text.includes("read-only file system")) && text.includes("node_modules") && (text.includes(".vite-temp") || text.includes("vite.config"));
|
|
6155
6410
|
}
|
|
6411
|
+
function runnerMetrics(input) {
|
|
6412
|
+
const schemaText = JSON.stringify(input.request.schema);
|
|
6413
|
+
const finishedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6414
|
+
return compactRecord({
|
|
6415
|
+
purpose: input.request.purpose,
|
|
6416
|
+
workdir: input.request.workdir,
|
|
6417
|
+
started_at: input.startedAt,
|
|
6418
|
+
finished_at: finishedAt,
|
|
6419
|
+
duration_ms: Date.now() - input.startedMs,
|
|
6420
|
+
prompt_chars: input.request.prompt.length,
|
|
6421
|
+
prompt_lines: input.request.prompt.split(/\r?\n/).length,
|
|
6422
|
+
schema_chars: schemaText.length,
|
|
6423
|
+
stdout_chars: (input.stdout || "").length,
|
|
6424
|
+
stderr_chars: (input.stderr || "").length,
|
|
6425
|
+
final_message_chars: (input.finalText || "").length,
|
|
6426
|
+
exit_status: input.status ?? null,
|
|
6427
|
+
timed_out: input.timedOut || false,
|
|
6428
|
+
error_code: input.errorCode,
|
|
6429
|
+
codex_command: input.config.codexCommand || "codex",
|
|
6430
|
+
codex_model: input.config.codexModel,
|
|
6431
|
+
codex_sandbox: input.config.codexSandbox || "workspace-write",
|
|
6432
|
+
codex_full_auto: input.config.codexFullAuto !== false,
|
|
6433
|
+
timeout_ms: Number(input.config.codexTimeoutMs || 6e5)
|
|
6434
|
+
});
|
|
6435
|
+
}
|
|
6156
6436
|
function createCodexExecJsonRunner(config = {}) {
|
|
6157
6437
|
return (request) => {
|
|
6438
|
+
const startedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
6439
|
+
const startedMs = Date.now();
|
|
6158
6440
|
if (!request.workdir || !(0, import_node_fs4.existsSync)(request.workdir)) {
|
|
6159
6441
|
return {
|
|
6160
6442
|
ok: false,
|
|
6443
|
+
metrics: runnerMetrics({ request, config, startedAt, startedMs, errorCode: "workdir_missing" }),
|
|
6161
6444
|
blocker: {
|
|
6162
6445
|
code: "codex_workdir_missing",
|
|
6163
6446
|
message: `Codex workdir does not exist for ${request.purpose}.`,
|
|
@@ -6202,6 +6485,17 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
6202
6485
|
ok: false,
|
|
6203
6486
|
stdout: proc.stdout || "",
|
|
6204
6487
|
stderr: proc.stderr || "",
|
|
6488
|
+
metrics: runnerMetrics({
|
|
6489
|
+
request,
|
|
6490
|
+
config,
|
|
6491
|
+
startedAt,
|
|
6492
|
+
startedMs,
|
|
6493
|
+
stdout: proc.stdout || "",
|
|
6494
|
+
stderr: proc.stderr || "",
|
|
6495
|
+
status: proc.status,
|
|
6496
|
+
timedOut,
|
|
6497
|
+
errorCode: proc.error.code || "spawn_error"
|
|
6498
|
+
}),
|
|
6205
6499
|
blocker: {
|
|
6206
6500
|
code: timedOut ? "codex_timeout" : "codex_exec_error",
|
|
6207
6501
|
message: timedOut ? `Codex timed out during ${request.purpose}.` : `Codex failed to start or complete ${request.purpose}.`,
|
|
@@ -6214,6 +6508,16 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
6214
6508
|
ok: false,
|
|
6215
6509
|
stdout: proc.stdout || "",
|
|
6216
6510
|
stderr: proc.stderr || "",
|
|
6511
|
+
metrics: runnerMetrics({
|
|
6512
|
+
request,
|
|
6513
|
+
config,
|
|
6514
|
+
startedAt,
|
|
6515
|
+
startedMs,
|
|
6516
|
+
stdout: proc.stdout || "",
|
|
6517
|
+
stderr: proc.stderr || "",
|
|
6518
|
+
status: proc.status,
|
|
6519
|
+
errorCode: "nonzero_exit"
|
|
6520
|
+
}),
|
|
6217
6521
|
blocker: {
|
|
6218
6522
|
code: "codex_nonzero_exit",
|
|
6219
6523
|
message: `Codex exited with status ${proc.status} during ${request.purpose}.`,
|
|
@@ -6228,6 +6532,17 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
6228
6532
|
ok: false,
|
|
6229
6533
|
stdout: proc.stdout || "",
|
|
6230
6534
|
stderr: proc.stderr || "",
|
|
6535
|
+
metrics: runnerMetrics({
|
|
6536
|
+
request,
|
|
6537
|
+
config,
|
|
6538
|
+
startedAt,
|
|
6539
|
+
startedMs,
|
|
6540
|
+
stdout: proc.stdout || "",
|
|
6541
|
+
stderr: proc.stderr || "",
|
|
6542
|
+
finalText,
|
|
6543
|
+
status: proc.status,
|
|
6544
|
+
errorCode: "invalid_json"
|
|
6545
|
+
}),
|
|
6231
6546
|
blocker: {
|
|
6232
6547
|
code: "codex_invalid_json",
|
|
6233
6548
|
message: `Codex completed ${request.purpose}, but did not return valid JSON.`,
|
|
@@ -6239,7 +6554,17 @@ function createCodexExecJsonRunner(config = {}) {
|
|
|
6239
6554
|
ok: true,
|
|
6240
6555
|
json: parsed,
|
|
6241
6556
|
stdout: proc.stdout || "",
|
|
6242
|
-
stderr: proc.stderr || ""
|
|
6557
|
+
stderr: proc.stderr || "",
|
|
6558
|
+
metrics: runnerMetrics({
|
|
6559
|
+
request,
|
|
6560
|
+
config,
|
|
6561
|
+
startedAt,
|
|
6562
|
+
startedMs,
|
|
6563
|
+
stdout: proc.stdout || "",
|
|
6564
|
+
stderr: proc.stderr || "",
|
|
6565
|
+
finalText,
|
|
6566
|
+
status: proc.status
|
|
6567
|
+
})
|
|
6243
6568
|
};
|
|
6244
6569
|
} finally {
|
|
6245
6570
|
(0, import_node_fs4.rmSync)(tmpDir, { recursive: true, force: true });
|
|
@@ -6260,14 +6585,21 @@ function payloadOrBlocker(raw, checkpoint) {
|
|
|
6260
6585
|
ok: false,
|
|
6261
6586
|
blocker: {
|
|
6262
6587
|
...blocker,
|
|
6263
|
-
checkpoint
|
|
6588
|
+
checkpoint,
|
|
6589
|
+
details: {
|
|
6590
|
+
...blocker.details || {},
|
|
6591
|
+
runner_metrics: raw.metrics || null
|
|
6592
|
+
}
|
|
6264
6593
|
}
|
|
6265
6594
|
};
|
|
6266
6595
|
}
|
|
6267
6596
|
return {
|
|
6268
6597
|
ok: true,
|
|
6269
6598
|
payload: raw.json,
|
|
6270
|
-
summary: typeof raw.json.summary === "string" ? raw.json.summary : void 0
|
|
6599
|
+
summary: typeof raw.json.summary === "string" ? raw.json.summary : void 0,
|
|
6600
|
+
details: compactRecord({
|
|
6601
|
+
runner_metrics: raw.metrics || null
|
|
6602
|
+
})
|
|
6271
6603
|
};
|
|
6272
6604
|
}
|
|
6273
6605
|
function stringArray(value) {
|
|
@@ -6403,14 +6735,16 @@ function createCodexExecAgentAdapter(config = {}, runner = createCodexExecJsonRu
|
|
|
6403
6735
|
agent_summary: summary,
|
|
6404
6736
|
agent_changed_files: changedFiles,
|
|
6405
6737
|
agent_tests_run: testsRun,
|
|
6406
|
-
agent_blockers: blockers
|
|
6738
|
+
agent_blockers: blockers,
|
|
6739
|
+
runner_metrics: raw.metrics || null
|
|
6407
6740
|
};
|
|
6408
6741
|
attemptSummaries.push({
|
|
6409
6742
|
purpose,
|
|
6410
6743
|
summary,
|
|
6411
6744
|
changed_files: changedFiles,
|
|
6412
6745
|
tests_run: testsRun,
|
|
6413
|
-
blockers
|
|
6746
|
+
blockers,
|
|
6747
|
+
runner_metrics: raw.metrics || null
|
|
6414
6748
|
});
|
|
6415
6749
|
if (hardBlockers.length) {
|
|
6416
6750
|
return {
|
|
@@ -7153,7 +7487,7 @@ function percentFrom(record) {
|
|
|
7153
7487
|
}
|
|
7154
7488
|
function numericFromAnyKey(record, keys) {
|
|
7155
7489
|
for (const key of keys) {
|
|
7156
|
-
const value =
|
|
7490
|
+
const value = numericValue2(record[key]);
|
|
7157
7491
|
if (value !== null) return value;
|
|
7158
7492
|
}
|
|
7159
7493
|
return null;
|
|
@@ -7164,7 +7498,7 @@ function recordValue2(value) {
|
|
|
7164
7498
|
function listValue(value) {
|
|
7165
7499
|
return Array.isArray(value) ? value : [];
|
|
7166
7500
|
}
|
|
7167
|
-
function
|
|
7501
|
+
function numericValue2(value) {
|
|
7168
7502
|
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
7169
7503
|
if (typeof value === "string" && value.trim()) {
|
|
7170
7504
|
const parsed = Number(value);
|