Repository navigation
feat(server): typed provider errors and guarded cross-provider failover - #184
Conversation
|
Independent source review — changes required. Keep this draft on hold. The Critical replay finding and four Important findings are open. Full CLO-1134 review {
"reviewed_head": "1feb64dd2329fee44ce6e9011e3c9e6d7f7a5258",
"reviewer": "Codex gpt-6.2-sol via T3 independent review child",
"findings": [
{
"id": "F1",
"severity": "critical",
"summary": "A child-thread launch is treated as effect-free during replay admission.",
"outcome": "open"
},
{
"id": "F2",
"severity": "important",
"summary": "Structured refusal fields are lost over RPC and on same-command retry.",
"outcome": "open"
},
{
"id": "F3",
"severity": "important",
"summary": "Readback and admission can target different runs, and recovery can lose task ownership.",
"outcome": "open"
},
{
"id": "F4",
"severity": "important",
"summary": "An unusable candidate can block later candidates, and eligibility does not bind the full route.",
"outcome": "open"
},
{
"id": "F5",
"severity": "important",
"summary": "Failure classification and model attribution can overstate observed provider evidence.",
"outcome": "open"
}
]
} |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
CHECKPOINTCLO-694 bounded closeout — BLOCKED. This reconciles the existing single independent review; no second full pass was performed. The original review record and its reviewer attribution are carried forward unchanged below. Current exact head is unchanged at Focused F1 reconciliation: Required aggregator is red in run 45140479949/job 137583040492; the web job has two Default-branch workflow audit: {
"reviewed_head": "1feb64dd2329fee44ce6e9011e3c9e6d7f7a5258",
"reviewer": "Codex gpt-6.2-sol via T3 independent review child",
"findings": [
{
"id": "F1",
"severity": "critical",
"summary": "A child-thread launch is treated as effect-free during replay admission.",
"outcome": "open"
},
{
"id": "F2",
"severity": "important",
"summary": "Structured refusal fields are lost over RPC and on same-command retry.",
"outcome": "open"
},
{
"id": "F3",
"severity": "important",
"summary": "Readback and admission can target different runs, and recovery can lose task ownership.",
"outcome": "open"
},
{
"id": "F4",
"severity": "important",
"summary": "An unusable candidate can block later candidates, and eligibility does not bind the full route.",
"outcome": "open"
},
{
"id": "F5",
"severity": "important",
"summary": "Failure classification and model attribution can overstate observed provider evidence.",
"outcome": "open"
}
]
}Reconciliation: Codex gpt-6.1-sol via T3. No merge, deployment, new spend, nested child or watch. |
1feb64d to
485e912
Compare
Failed runs now keep the provider's HTTP status, and readback classes the failure as payment, rate_limit, auth, quota or other. A message.dispatch can continue a failed run on the first eligible candidate of an ordered list, admitted atomically in dispatchMessage only for those classes, with no open request, no item that may have acted, an included and enabled target not yet tried in the lineage, and a bounded lineage. Repeats are accepted once. The Closura providerFailover setting ships off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
485e912 to
df9bf1b
Compare
Problem
Bot runs on the fleet keep failing on provider HTTP 402 (Infra runs 67–74), and nothing can move them to another provider safely. Two gaps in T3 block it, as the Home handoff for ordered model failover (CLO-1134) found:
dispatchMessagehad no atomic cross-provider continuation that could prove replaying the prompt repeats nothing.Behavior
Typed provider error.
OrchestrationV2ProviderFailuregains an optionalhttpStatus. Codex sets it fromcodexErrorInfo. Claude'sapi_error_<status>codes fill it inmakeProviderFailure.providerFailoverClasssorts a failure intopayment(402),rate_limit(429 or a rate-limit code),auth(401 or an unauthorized code),quota(other usage limits) orother. Policy or safety codes, validation errors, sign-out prompts and anything unrecognised stayother, so they never fail over.Readback.
t3_thread_readputsfailureon a failed latest run, andtask_statusreturnslatestTerminalFailure: provider instance, model, HTTP status, failover class, code and retryable. The message text is left out because it can quote the prompt. Provider failures are already credential-redacted.Guarded failover.
message.dispatchtakesproviderFailover: { ofRunId, candidates }, with 1 to 8ModelSelections in order.dispatchMessageadmits it in the same command transaction only when all of these hold:providerFailoversetting is onproviderFailoverOfRunIdchain) is shorter thanmaxAttemptsThe target is the first candidate that is in
includedProviderInstanceIds, configured and enabled for the project, and not already tried in the lineage (same instance and model). The new run recordsproviderFailoverOfRunId, and the provider switch hands context over through the existing handoff path. A repeat request for a run that already has a failover continuation is accepted as a no-op, the same way stale restart deliveries are. Command-ID replays are already deduplicated by command receipts.Structured refusal. Anything else fails the command with
OrchestrationV2ProviderFailoverRefused { runId, reason, failure, candidates }.reasonis one ofdisabled,not_latest_failed_run,not_failover_class,pending_request,side_effectsorexhausted. Each candidate passed over is listed withalready_tried,not_includedorunavailable. The dispatch RPC error'sdetailreadsProvider failover refused (<reason>) for run <runId>.Setting, off by default.
providerFailover: { enabled: false, includedProviderInstanceIds: [], maxAttempts: 3 }ships as a fork default inpackages/contracts/src/settings.ts, with aClosura:comment.No new service, reactor, timer or orchestration layer. The caller drives each failover with one command.
Prior art reused (at base
1f8a0720d5)apps/server/src/orchestration-v2/Orchestrator.ts:7143: the manual continuation guard (latest executed run, not archived, no pending runtime request). The failover guard sits beside it indispatchMessage.apps/server/src/orchestration-v2/Orchestrator.ts:7163and:7207: the usage-limit and restart continuation guards. Their*ContinuationOfRunIdrun fields and keep-run-ids plumbing are mirrored byproviderFailoverOfRunId.:7227is the accepted no-op for stale duplicate deliveries.apps/server/src/orchestration-v2/Orchestrator.ts:2720: the queue-resume instance-enabled check. The failover guard reusesresolveProjectProviderInstanceEnabledfrom it.apps/server/src/orchestration-v2/Orchestrator.ts:1876:readCommandProjectionkeeps only user and error items. That is why the effects check reads the failed run's full items (turnItemRunId).packages/shared/src/orchestrationV2ThreadError.ts:14:latestRootProviderFailurepicks the run's terminal failure for both admission and readback.apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts:1195:codexErrorHttpStatusalready extracted the status, and:5198(terminal notification) now keeps it.packages/provider-core/src/server/failure.ts:277:makeProviderFailurecarries it.apps/server/src/mcp/OrchestratorMcpService.ts:1044(threadRun) and:1803(task status terminal run): the readback builders that were extended.Exact-head test output
Base
1f8a0720d55c8768d7a8aa55f9a1eebc50438f08, head1feb64dd2329fee44ce6e9011e3c9e6d7f7a5258, ASUS, Node 26.13.1.Every case asserts that the typed error survives the event store and projection read (
orchestrationV2RunFailureon the stored error item), and every refusal assertsreason,runId,failure.httpStatusand the skipped-candidate list. One defect was caught by these tests during the work: the first draft read effects from the command projection, which holds only user and error items, so a run that had rungit pushwas admitted. The guard now reads the failed run's full items.node scripts/check-changed.ts 1f8a0720d5 --concurrency 2reported failures that also fail on the base commit with this change absent (each re-run on1f8a0720d5):--no-verify.evalstypecheck: 4ProviderRegistrycontext errors inevals/mcp-tool-use/run*.ts.AgentContextBudget.test.ts:mcpToolListJsonBytes56852 against a committed 55827. The MCP tool list is byte-identical on base and head. This PR adds nothing to tool inputs, only optional output fields.Orchestrator.control-reads.test.ts"drops a stale question wake", andruntimeLayer.test.ts"starts a fresh scheduled delivery on a new provider thread after a provider switch".reactCompilerCoverage.test.tsin web (3) and mobile (1).One touched file had two existing lint errors that
check:changedwould flag: a five-line comment and a?? {}spread fallback inorchestrationV2.ts. Both are fixed here, with no behavior change.Home integration contract (for closura-agent-config PR pingdotgg#1195)
settings.jsonunder the T3 home):{ "providerFailover": { "enabled": true, "includedProviderInstanceIds": ["<included instance ids>"], "maxAttempts": 3 } }task_status.latestTerminalFailureort3_thread_read.recentRuns[0].failure. Fail over only whenclassispayment,rate_limit,authorquota. T3 re-checks this itself.dispatchCommand:{ "type": "message.dispatch", "commandId": "failover:<runId>", "threadId": "<thread>", "messageId": "failover:<runId>", "providerFailover": { "ofRunId": "<failed runId>", "candidates": [{ "instanceId": "...", "model": "..." }, "..."] }, "text": "Continue the task.", "attachments": [], "dispatchMode": { "type": "start_immediately" }, "createdBy": "agent", "creationSource": "mcp" }candidates. LeavemodelSelectionunset. A stablecommandIdderived from the run makes a retry a receipt replay. A different id for the same run is accepted as a no-op.providerFailoverOfRunId = <failed runId>on the chosen candidate. Refusal is a dispatch error whosedetailisProvider failover refused (<reason>) for run <runId>., with the fullOrchestrationV2ProviderFailoverRefusedincause. Write the per-run Linear note fromreasonandcandidates.exhaustedandside_effectsare stop-and-report states, never something to retry on another route.Not covered here
latestTerminalFailureyet.readRemoteTaskreads the peer's summary, not its turn items.quota) or recognised auth/rate-limit codes.orchestrationV2RunFailure, not by an MCP integration test.Deploy: none
Model: claude-opus-5-5 · Harness: Claude Code (T3 child, ASUS) · Requirement: CLO-1134
🤖 Generated with Claude Code