Skip to content

feat(scenarios): add Tessera state preparation - #11

Open
92Infinitus92 wants to merge 3 commits into
feat/bisonfi-supportfrom
feat/tessera-support
Open

feat(scenarios): add Tessera state preparation#11
92Infinitus92 wants to merge 3 commits into
feat/bisonfi-supportfrom
feat/tessera-support

Conversation

@92Infinitus92

@92Infinitus92 92Infinitus92 commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Stacked on #8 — Tessera is the same mechanism class as BisonFi (PMM, no IDL) and reuses the raw-layout engine it introduced.

  • Everything declarative: 6 templates over the market account (fair value, depth, curve, halt, freshness, stale quote) plus a 26-market catalog carrying each market's mints, decimals and freshness limit.
  • One builder (fair value): turns a human price into the two reciprocal atomic-ratio fields using the market's mint decimals, and pairs a persistent freshness override so the prepared quote stays live on the fork.
  • One MCP tool, create_tessera_fair_value_scenario, on the generic scenario path. No protocol HTTP endpoints.
  • 8 live gated tests against the deployed program (staleness boundary 0xffff, halt, ladder scaling), on shared live-test helpers.
  • The three MCP helpers duplicate the pump branch's on purpose — they fold together when the branches converge.
  • monitoring.yaml is documentation only: the program-upgrade fingerprint and the catalog refresh procedure.

Greptile Summary

The PR adds declarative Tessera market-state scenarios, live market discovery, fair-value and depth builders, and MCP tooling for creating those scenarios.

  • Registers six raw-layout Tessera templates and protocol-specific builders.
  • Adds market discovery and live deployment/layout validation tests.
  • Adds MCP tools for listing markets and staging fair-value or depth scenarios against a selected Surfnet.

Confidence Score: 4/5

The PR needs the Tessera MCP parameters to accept the advertised surfnetPort name before merging, otherwise dynamic-Surfnet requests can still target the default RPC.

The Tessera account reads correctly propagate the parsed port, but their new parameter structs expose snake_case while the stated fix and analogous scenario tool use camelCase, leaving the original wrong-target behavior reachable for callers sending surfnetPort.

Files Needing Attention: crates/mcp/src/surfpool/mod.rs

Important Files Changed

Filename Overview
crates/mcp/src/surfpool/mod.rs Adds Tessera MCP tools and threads a selected RPC port through account reads, but the parameter schema does not accept the stated camelCase port name.
crates/core/src/scenarios/protocols/tessera/v1/fair_value.rs Adds validated market parsing and reciprocal atomic-ratio construction for fair-value scenarios.
crates/core/src/scenarios/protocols/tessera/v1/depth.rs Adds deterministic scaling of enabled Tessera ladder capacities with persisted freshness.
crates/core/src/scenarios/protocols/tessera/v1/markets.rs Adds filtered market discovery and mint metadata resolution through the selected RPC client.
crates/core/src/scenarios/protocols/tessera/v1/overrides.yaml Defines guarded raw-layout templates for Tessera price, depth, curve, halt, and freshness state.

Fix all with Greploop Fix All in Claude Code Fix All in Codex Fix All in Cursor

Prompt To Fix All With AI
### Issue 1
crates/mcp/src/surfpool/mod.rs:61-64
**CamelCase port argument ignored**

When an MCP caller sends the documented `surfnetPort` argument for a dynamically allocated Surfnet, this parameter struct expects `surfnet_port` instead, so the request is rejected or the value remains absent and account reads fall back to port 8899. This recreates the wrong-Surfnet failure the new parameter is intended to fix; the Tessera parameter structs should use the same camelCase serde convention as the analogous Pump tool.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (6): Last reviewed commit: "test(tessera): surface all retry errors ..." | Re-trigger Greptile

Greptile also left 1 inline comment on this PR.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
  • P1 – MCP tool ignores the selected surfnet port (mod.rs): fetch_surfnet_accounts always connects to DEFAULT_RPC_PORT. start_surfnet may choose 18899, 28899, etc., and stores that port in self.surfnets; in those cases the Tessera tool fails or reads an unrelated process. Accept a surfnet/RPC parameter or resolve the active port from self.surfnets.

Comment thread crates/mcp/src/surfpool/mod.rs Outdated
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

No actionable findings in the reviewed diff.

The previously reported RPC-target issue is fixed at 8539d42: surfnet_port is caller-selectable and used for both market and mint account reads.

Tests could not run because Rustup attempted to write outside the permitted workspace.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
  • [P2] fair_value.rs:183-190 silently truncates prices with more precision than the atomic ratio supports. The scenario label still reports the requested price although a lower price is applied. Reject non-zero discarded digits or explicitly report the normalized price.

Tessera is a proprietary market maker with no IDL, so its market accounts are
written through the raw byte layout the BisonFi work introduced. Eight templates
cover price, depth, curve, halt, staleness and freshness.

The market catalog lists all 26 live markets with their mints, decimals and
freshness limit, so the UI constrains the choice and a model can resolve one
through search_constant_options.

One builder exists, for the only thing a template cannot express: turning a human
price into the pair of reciprocal atomic ratios, which needs both mints' decimals.
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown

No actionable issues found in the PR changes.

Focused tests could not run because Rustup attempted to write under the read-only /home/runner/.rustup directory. Static review covered the builder, MCP flow, templates, registry, and test gating.

Replace the static market catalog with on-chain discovery and add exact depth preparation with live swap coverage. Accept decimal u64/i64 overrides through the IDL encoder for lossless Studio editing.
@github-actions

github-actions Bot commented Sep 8, 2026

Copy link
Copy Markdown

No concrete bugs found in the specified PR range.

One testing improvement: add a local RPC test for list_tessera_markets covering local overrides and a nondefault Surfnet port. The current discovery test queries mainnet directly, so it doesn’t verify those advertised behaviors.

Tests could not run: the pinned toolchain required a write outside the sandbox, and the installed toolchain’s offline dependency cache lacked bincode.

Comment thread crates/mcp/src/surfpool/mod.rs
The live fetch retry loop discarded each intermediate error and panicked
with only the last one. Collect every attempt and include them in the panic
so a persistent failure is diagnosable.
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
  • [P1] Preserve the selected Surfnet when staging scenariosmod.rs:1142, also line 1181. Both Tessera builders read accounts using surfnet_port, then discard it when calling stage_scenario. Neither the stored scenario nor the editor URL retains that target, so a scenario derived from port 18899 can be played against Studio’s default Surfnet. Carry the target through staging and playback, or reject unsupported ports until routing is implemented. Add a regression test using two Surfnet instances with different market states.

Static review only; live tests were not run.

Comment on lines +61 to +64
#[schemars(
description = "The port of the target running local surfnet instance (e.g., 8899, 18899, 28899, etc.). Omit to use the default port, 8899."
)]
pub surfnet_port: Option<u16>,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 CamelCase port argument ignored

When an MCP caller sends the documented surfnetPort argument for a dynamically allocated Surfnet, this parameter struct expects surfnet_port instead, so the request is rejected or the value remains absent and account reads fall back to port 8899. This recreates the wrong-Surfnet failure the new parameter is intended to fix; the Tessera parameter structs should use the same camelCase serde convention as the analogous Pump tool.

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/mcp/src/surfpool/mod.rs
Line: 61-64

Comment:
**CamelCase port argument ignored**

When an MCP caller sends the documented `surfnetPort` argument for a dynamically allocated Surfnet, this parameter struct expects `surfnet_port` instead, so the request is rejected or the value remains absent and account reads fall back to port 8899. This recreates the wrong-Surfnet failure the new parameter is intended to fix; the Tessera parameter structs should use the same camelCase serde convention as the analogous Pump tool.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Fix in Claude Code Fix in Codex Fix in Cursor

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