Skip to content

feat: publish per-chain inventory and USDC corridor liq_ series [RAI-3087] - #1679

Open
JuaniRios wants to merge 1 commit into
rai-2998-liq-metrics-inventoryfrom
rai-2998-liq-metrics-chains
Open

JuaniRios wants to merge 1 commit into
rai-2998-liq-metrics-inventoryfrom
rai-2998-liq-metrics-chains

Conversation

@JuaniRios

@JuaniRios JuaniRios commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Part of RAI-3087.

Adds per-chain inventory series and the USDC corridor bands. Item 2 of the RAI-2998 stack, part 2 of 3.

Live effect: new series liq_equity_chain_available{symbol,chain}, liq_usdc_chain_{available,inflight,ratio}{chain} and liq_usdc_corridor_{target,deviation}{chain} on the bot's /metrics; no existing name changes · Risk: low (inventory view logic for a new read path; no trading decision reads it) · Ships: on the next bot release

Why

The exporter names only show the primary chain. Robinhood equity rebalancing is on, so the probe undercounts. These new names give each hedged chain's vault on its own, and Stage 4 moves the probe to them.

Decisions

  • Ports the logic from feat: per-chain balances, corridor bands, and trade price in the dashboard DTO #1657, not its DTO or WebSocket fields: the unpolled_onchain marker, polled_onchain(), the carried-slot reset plumbing, hedged_chains and UsdcCorridors::configured(). feat: per-chain balances, corridor bands, and trade price in the dashboard DTO #1657 will need to drop these parts when it rebases.
  • A chain is listed only after a vault snapshot read it. A slot that only a fill, transfer or inflight created holds a delta from 0, not a balance. A chain the config no longer hedges is left out too.
  • liq_usdc_chain_ratio is that vault's available USDC over itself plus the gross broker cash. It is absent until the gross broker cash is read, and while both are 0 (no 0 or 1 default, per the SPEC Values rule). It is not the rebalancer's trigger ratio. inventory.rs
  • Corridor bands come from config at boot, for every configured corridor whatever the USDC mode. A value that doesn't convert is skipped and logged, with no 0.5 default.

Risks

  • liq_equity_chain_available is in that chain's wrapped vault shares, and each chain's wrapper has its own underlying per share. Do not sum it across chains or add it to broker shares. The HELP text and the docs say so. liquidity.rs

Proof

Merge conditions

None new beyond the stack below.

@linear-code

linear-code Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

RAI-2998

RAI-3059

RAI-3087

JuaniRios commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


How to use the Graphite Merge Queue

Add the label add-to-gt-merge-queue to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@JuaniRios

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full review

@JuaniRios

Copy link
Copy Markdown
Collaborator Author

@rain-marvin review

@rain-marvin

rain-marvin Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

🔎 Reviewing 83ae01e, started by @JuaniRios. The review will appear here when it's done.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Team
  • Run ID: 1de551da-b452-41c7-8f8f-a3f623c6d249

📥 Commits

Reviewing files that changed from the base of the PR and between f764048 and 937fae0.


📒 Files selected for processing (5)
  • SPEC.md
  • docs/observability.md
  • src/inventory/view.rs
  • src/metrics/liquidity.rs
  • src/metrics/liquidity/inventory.rs

Included review availability: This review used your included allowance. 3 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 8 reviews per hour.



Walkthrough

The change adds metrics for every configured USDC corridor and for polled balances on configured hedged chains. It tracks poll status across inventory updates and resets. It publishes per-chain equity availability, USDC availability, inflight, and ratio metrics. Documentation, metric catalogs, parity comparison names, and fixtures are updated.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to 937fa

The configured chains are wired into the published inventory metrics. No actionable merge blocker remains after normal checks.

Pre-merge checks | Passed 4 | Failed 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 72.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 91 functions across 7 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description clearly explains the new per-chain inventory and USDC corridor metrics, their behavior, risks, testing, and release status.
Title check Passed The title clearly identifies the main change: publishing per-chain inventory and USDC corridor liquidity metrics.

Full details: Docstring Coverage

Explanation

Docstring coverage is 72.53% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 91 functions across 7 files. (2 skipped: 2 unsupported.)



  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR

🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR


  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@rain-marvin rain-marvin Bot 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.

Adds per-chain inventory metrics to the bot's /metrics: equity available per chain and symbol, USDC available, in flight and vault ratio per chain, and the USDC corridor target and deviation bands from config. To do this, the inventory view now marks which onchain slots a vault snapshot has read (unpolled_onchain), carries that marker through resets, and stores the set of hedged chains so a chain dropped from config stops showing.

Overall read: the change looks correct and contained. Trading readers of the view keep the same balances. The new marker survives hydration and the reset paths, and the ratio, label and unit handling match SPEC.md and docs/observability.md. No lane found a blocker. Two minor points: per-chain equity has no in-flight series, which matters before Stage 4 moves the probe to these names, and hedged_chains is boot config held in the mutable trading view, where its doc comments also say the dashboard reads it.

Panel note: Cursor was out of usage and flash 3.7 was unavailable, so the specialist lanes ran on sol 6.1. Rust tests were not run in the read-only checkout.

claude-opus-5-5 · high · 11 min

Comment thread src/metrics/liquidity/inventory.rs Outdated
Comment thread src/inventory/view.rs
@JuaniRios
JuaniRios force-pushed the rai-2998-liq-metrics-chains branch from 48e0cdb to 937fae0 Compare October 9, 2026 22:27
@JuaniRios
JuaniRios force-pushed the rai-2998-liq-metrics-inventory branch from bf6bb73 to 252fae1 Compare October 9, 2026 22:27
@JuaniRios JuaniRios changed the title [RAI-2998] Publish per-chain inventory and USDC corridor liq_ series feat: publish per-chain inventory and USDC corridor liq_ series [RAI-3087] Oct 9, 2026
@JuaniRios

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@JuaniRios

Copy link
Copy Markdown
Collaborator Author

@rain-marvin review

@rain-marvin

rain-marvin Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

🔎 Reviewing 937fae0, started by @JuaniRios. The review will appear here when it's done.

@coderabbitai

coderabbitai Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@rain-marvin rain-marvin Bot 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.

This PR publishes each hedged chain's vault balances as new liq_ series (liq_equity_chain_available, liq_usdc_chain_{available,inflight,ratio}) and the band of every configured USDC corridor (liq_usdc_corridor_{target,deviation}). To do that it ports the poll marker from #1657: an onchain slot counts as a reading only after a vault snapshot set it, and both reset paths carry that marker.

Overall read: sound. The snapshot paths all clear the marker, a slot that a fill, transfer or inflight created first stays marked, and the resets carry it. The view is not persisted, so the new serde(default) fields carry no upgrade risk. The ratio is absent until the broker cash is read, and the unit warning is in the HELP text and docs, so the earlier threads hold. A claim that /metrics now leaks business data was checked and dismissed: the same kinds of values were already on that route, and the PR adds no real values to the repository. Two small comments below. Separately, the Decisions section says #1657 will drop these parts when it rebases, but #1657 was closed on 2026-10-09 without a merge, so that line is out of date.

claude-opus-5-5 · high · 42 min

Comment thread docs/observability.md
Comment thread src/metrics/liquidity/settings.rs
@JuaniRios

Copy link
Copy Markdown
Collaborator Author

@coderabbitai approve

@coderabbitai

coderabbitai Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Comments resolved and changes approved.

This was referenced Oct 10, 2026
@rain-marvin

rain-marvin Bot commented Oct 11, 2026

Copy link
Copy Markdown
Contributor

@JuaniRios 🔔 Follow-up: a day after my review

@JuaniRios, #1679 hasn't moved since my review. The bots are done: every review thread is resolved, and CodeRabbit and I both approved 937fae0. CI is green apart from a cancelled ${{ matrix.partition }} placeholder job, and all four real test partitions passed.

It's waiting on two human approvals:

  • This PR: human/reviewed fails because @rouzwelt approved 83ae01e, and the two fix rounds since then removed that approval. They need to re-approve 937fae0.
  • The bottom of the stack: #1673 also needs a human approval of its head 5d21383, and it's behind master.

Next step: ask @rouzwelt to re-approve #1679 and to review #1673, then sync the stack so #1673 is up to date with master.

claude-opus-5-5 · high · 1 h 1 min

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.

2 participants