Skip to content

Evidence-based failure classification and reported-cost budget input - #67

Open
MarouaBoud wants to merge 3 commits into
mainfrom
claude/recovery-inputs
Open

MarouaBoud wants to merge 3 commits into
mainfrom
claude/recovery-inputs

Conversation

@MarouaBoud

Copy link
Copy Markdown
Member

What changed

Failure evidence. Every failure is recorded with its source:

Source Trigger Caller Checked on-chain
HEARTBEAT_TIMEOUT heartbeat missed by more than 2× the interval anyone (detectFailure) yes
DEADLINE_EXPIRED block time past the task deadline anyone (detectFailure) yes
AGENT_REPORT current agent declares a failure type with an evidence CID current agent (reportFailure) no (attested)
  • The failure class is derived from the evidence (libraries/FailureTaxonomy.sol). Checkpoint count no longer sets the class (previously 0 → LIVENESS, 1–2 → RESOURCE, ≥3 → LIVENESS, which scored early progress lower than none). LOGIC is reachable through an agent report.
  • detectFailure succeeds when the deadline has passed, even while the agent keeps sending heartbeats. Before, such a task could neither complete (completeTask reverts past the deadline) nor be failed (TaskNotStale).
  • HEARTBEAT_MISS and DEADLINE_EXCEEDED cannot be self-reported.

Budget input B. reportCost(taskId, cumulativeCost) (current agent, monotone, clamped to the escrow) stores costAccrued. Both routers compute B = (escrow − costAccrued) / escrow; B was previously 1 for every funded task. Settlement does not use costAccrued. Reported cost reaching the escrow classifies a heartbeat timeout as RESOURCE / BUDGET_EXHAUSTED.

Interface. IRecoveryRouter.classifyAndScore(bytes32, FailureEvidence) replaces the five-argument version. FailureType gains BUDGET_EXHAUSTED and DEADLINE_EXCEEDED (appended; existing ordinals unchanged). Task gains costAccrued, failureEvidenceSource, failureEvidenceCID (appended). New events CostReported, FailureEvidenceRecorded; new errors CostNotMonotonic, InvalidFailureReport. CairnCoreUpgradeable, RecoveryRouter and RecoveryRouterUpgradeable carry the same changes.

Consumer ABIs (frontend, SDK, subgraph, pipeline) move with the redeploy.

Verification

  • forge test: 443 passing (408 existing, updated where they asserted the checkpoint-count classification; 35 new in FailureEvidence.t.sol and upgrades/CairnCoreUpgrade.t.sol).
  • Coverage (lines): CairnCore 95.29%, RecoveryRouter 100%, RecoveryRouterV2 100%, FailureTaxonomy 100%.
  • CairnCore 17.3 KB (limit 24 KB).
  • Gas (median): detectFailure 185,465 (was 171,985; stores evidence source and CID, one more event); RecoveryRouterV2.classifyAndScore 52,401 (was 51,764); reportCost 42,697; reportFailure 179,679.

MarouaBoud and others added 3 commits September 28, 2026 21:35
Co-Authored-By: Lagartha <ionanova22@gmail.com>
…ted cost

detectFailure records heartbeat-timeout or deadline-expiry evidence;
reportFailure records agent-attested evidence; reportCost feeds
B = (escrow - costAccrued) / escrow into both routers. Checkpoint count
no longer sets the failure class.

Co-Authored-By: Lagartha <ionanova22@gmail.com>
…detection

Co-Authored-By: Lagartha <ionanova22@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant