Skip to content

feat(minter): report the age of the oldest in-flight deposit - #237

Merged
gregorydemay merged 8 commits into
mainfrom
feat/deposit-age-metrics
Oct 8, 2026
Merged

gregorydemay merged 8 commits into
mainfrom
feat/deposit-age-metrics

Conversation

@gregorydemay

@gregorydemay gregorydemay commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Adds the metrics suggested in the reviews of #222 and #220:

  • oldest_in_flight_deposit_age_seconds: the age of the oldest deposit between being queued and being minted, dropped or quarantined, whatever sweep stage it is stuck in. One alert on this gauge covers a deposit stuck at any stage, while the existing per-stage count gauges tell which stage. The age is derived from the QueuedDeposit event timestamp, so it survives an event replay.
  • oldest_pending_mint_age_seconds: the age of the oldest pending mint from the created_at_time the ledger deduplicates it by, so an alert can fire hours before the deduplication window quarantines the deposit.
  • failed_credit_attempts{reason}: counts failed attempts to credit a finalized sweep by reason (not_found, rpc_error, invalid_response, unreadable, mismatch), showing why credits fail without reading the logs. Transient fetch failures (rpc_error) are kept apart from responses the providers agreed on but that do not belong to the queried transaction (invalid_response), so alerts can ignore the former. Failures that should never happen for a finalized sweep are logged as errors.
  • failed_mint_attempts{reason}: counts failed attempts to mint a pending deposit by reason (expired, rejected, ledger_error, created_in_future, call_error, unknown_outcome). unknown_outcome counts deposits quarantined because the outcome of the ledger call is unknown.

The counters are observability-only and reset on upgrade.

🤖 Generated with Claude Code

Base automatically changed from feat/deposit-sol-credit-sweep to main October 2, 2026 09:40
@gregorydemay
gregorydemay force-pushed the feat/deposit-age-metrics branch from 59be724 to 790aedb Compare October 2, 2026 09:51
gregorydemay and others added 2 commits October 6, 2026 07:47
Add an oldest_in_flight_deposit_age_seconds gauge covering every stage
from queued to pending mint, deriving each deposit's queued_at from the
QueuedDeposit event timestamp so that it survives an event replay, and
a failed_credit_attempts counter labelled by reason.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…nt attempts

An oldest_pending_mint_age_seconds gauge computed from the created_at_time
the ledger deduplicates each mint by, so an alert can fire hours before the
deduplication window quarantines the deposit, and a failed_mint_attempts
counter by reason, mirroring failed_credit_attempts.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 07:50
@gregorydemay
gregorydemay force-pushed the feat/deposit-age-metrics branch from 790aedb to cda0221 Compare October 6, 2026 07:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

Static review found no blocking issues in timestamp replay, lifecycle cleanup, or failure counters; tests were not run.

Review effort: Balanced
Findings: None

What changed in this PR

Adds observability for stalled deposits in the minter’s sweep-to-mint pipeline.

Changes:

  • Tracks deposit and pending-mint ages using replayable timestamps.
  • Counts credit and mint failures by reason, resetting counters on upgrade.
  • Adds lifecycle, replay, counter, and metric-output assertions.
File Description
minter/​src/​storage/​mod.rs Defines failure counters and reason labels.
minter/​src/​state/​tests.rs Verifies queued timestamps survive replay.
minter/​src/​state/​mod.rs Passes queued timestamps into deposit state.
minter/​src/​state/​deposits/​tests.rs Tests age tracking across lifecycle transitions.
minter/​src/​state/​deposits/​mod.rs Tracks timestamps and exposes oldest-deposit lookups.
minter/​src/​state/​audit.rs Applies event timestamps when queuing deposits.
minter/​src/​metrics.rs Exports age gauges and failure counters.
minter/​src/​deposit/​sweep/​mint/​tests.rs Checks mint failure classifications and counts.
minter/​src/​deposit/​sweep/​mint/​mod.rs Records mint failures by reason.
minter/​src/​deposit/​sweep/​finalize/​tests.rs Checks credit failure classifications and counts.
minter/​src/​deposit/​sweep/​finalize/​mod.rs Records credit failures by reason.
integration_tests/​tests/​tests.rs Checks initial metric values and labels.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@gregorydemay
gregorydemay marked this pull request as ready for review October 6, 2026 13:17
@gregorydemay
gregorydemay requested a review from a team as a code owner October 6, 2026 13:17
@zeropath-ai

zeropath-ai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

✅ No security or compliance issues detected. Reviewed everything up to f479ce9.

Security Overview
Detected Code Changes
Change Type Relevant files
Enhancement ► minter/src/deposit/sweep/finalize/mod.rs
    Emit error priority and record NotFound/InvalidResponse/RpcError on missing finalized sweeps
► minter/src/deposit/sweep/finalize/tests.rs
    Add tests for FailedCreditReason handling and counts
► minter/src/deposit/sweep/mint/mod.rs
    Record and handle additional FailedMintReason cases (Expired, CreatedInFuture, CallError, UnknownOutcome)
Enhancement ► minter/src/deposit/sweep/mint/tests.rs
    Extend tests to cover new FailedMintReason variants and assertion of failure counts
► minter/src/metrics.rs
    Integrate FailedCreditReason and FailedMintReason counters into metrics
► minter/src/storage/mod.rs
    Add storage for per-reason failure counters (FailedCreditReason, FailedMintReason) and related helpers
► minter/src/state/deposits/mod.rs
    Expose oldest_in_flight_queued_at and oldest_pending_mint_created_at, and track queued_at timestamps
► minter/src/state/audit.rs
    Pass timestamp to process_queued_deposit call

@mbjorkqvist mbjorkqvist left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gregorydemay!

Comment thread minter/src/deposit/sweep/finalize/mod.rs
Comment thread minter/src/deposit/sweep/finalize/mod.rs
Comment thread minter/src/deposit/sweep/mint/mod.rs
Comment thread minter/src/deposit/sweep/mint/mod.rs
Copilot AI balanced review requested due to automatic review settings October 8, 2026 07:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No blocking issues were identified; remaining feedback concerns minor metric help-text clarifications.

2 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Comment thread minter/src/metrics.rs Outdated
Comment thread minter/src/metrics.rs Outdated
gregorydemay and others added 4 commits October 8, 2026 09:29
…RPC errors

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…errors

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The quarantine guard now only fires when the outcome of the ledger call is unknown, so it can record its own reason without double counting the deliberate quarantines of rejected and expired mints.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 09:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The observability changes have no identified functional blockers; the remaining description update is nonblocking.

2 open findings

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings October 8, 2026 13:13
@gregorydemay
gregorydemay enabled auto-merge October 8, 2026 13:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

Timestamp tracking follows the deposit lifecycle and event replay, while failure counters align with retry and quarantine paths without unresolved blocking issues.

0 open findings

2 resolved since last review

🧠 Review effort: Balanced


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@gregorydemay
gregorydemay added this pull request to the merge queue Oct 8, 2026
Merged via the queue into main with commit eaaa031 Oct 8, 2026
14 checks passed
@gregorydemay
gregorydemay deleted the feat/deposit-age-metrics branch October 8, 2026 13:36
@github-actions github-actions Bot mentioned this pull request Oct 9, 2026
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.

3 participants