Skip to content

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

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

feat(scenarios): add Tessera state preparation#11
92Infinitus92 wants to merge 2 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 Tessera market discovery and scenario preparation for fair-value and depth overrides, including raw layouts, freshness handling, MCP tools, and live tests. The dynamic Surfnet targeting fix remains incomplete because scenario playback is still associated with the main Studio Surfnet.

  • Adds Tessera market validation, discovery, pricing, and depth-scaling builders.
  • Registers Tessera templates and exposes discovery and scenario-creation MCP tools.
  • Adds deployment-pinned integration tests and supporting runtime dependencies.

Confidence Score: 4/5

The PR is not yet safe to merge because scenarios derived from a dynamically selected Surfnet can be applied to the main/default Surfnet instead.

The account-read fix honors surfnet_port, but staging and Studio playback retain no corresponding Surfnet identity, allowing a scenario derived from one network's state to modify another network.

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

Important Files Changed

Filename Overview
crates/mcp/src/surfpool/mod.rs Adds Tessera MCP discovery and scenario tools and routes account reads to an optional Surfnet port, but staged scenarios do not retain that target for playback.
crates/core/src/scenarios/protocols/tessera/v1/fair_value.rs Adds validated Tessera market metadata and reciprocal fair-value scenario construction with persistent freshness.
crates/core/src/scenarios/protocols/tessera/v1/depth.rs Adds bounded integer scaling of enabled Tessera ladder capacities and pairs it with persistent freshness.
crates/core/src/scenarios/protocols/tessera/v1/markets.rs Discovers guarded Tessera market accounts and resolves their mint metadata through the supplied RPC client.
crates/core/src/scenarios/protocols/tessera/v1/overrides.yaml Defines the deployed Tessera raw account layout and fair-value, depth, curve, halt, stale-quote, and freshness templates.

Sequence Diagram

sequenceDiagram
    participant Caller
    participant MCP
    participant Selected as Selected Surfnet :18899
    participant Studio as Main Studio :18488
    participant Main as Main Surfnet :8899
    Caller->>MCP: "create Tessera scenario(surfnet_port=18899)"
    MCP->>Selected: Read market and mint accounts
    Selected-->>MCP: Selected Surfnet state
    MCP->>Studio: POST /v1/scenarios
    Studio-->>Caller: Editor URL without Surfnet identity
    Caller->>Studio: Play scenario
    Studio->>Main: surfnet_registerScenario
    Note over Selected,Main: Scenario is derived from Selected state but applied to Main
Loading

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:1098
**Scenario targets the wrong Surfnet**

When `surfnet_port` selects a dynamically allocated Surfnet, the tool derives the scenario from that Surfnet but stages an editor URL with no Surfnet association. Playing it registers the scenario against Studio's main Surfnet, causing overrides calculated from one network's account state to be applied to another network.

---

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

Reviews (5): Last reviewed commit: "feat(tessera): discover live markets and..." | 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.

};

let accounts = match self
.fetch_surfnet_accounts(params.surfnet_port, &[market_address])

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 Scenario targets the wrong Surfnet

When surfnet_port selects a dynamically allocated Surfnet, the tool derives the scenario from that Surfnet but stages an editor URL with no Surfnet association. Playing it registers the scenario against Studio's main Surfnet, causing overrides calculated from one network's account state to be applied to another network.

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

Comment:
**Scenario targets the wrong Surfnet**

When `surfnet_port` selects a dynamically allocated Surfnet, the tool derives the scenario from that Surfnet but stages an editor URL with no Surfnet association. Playing it registers the scenario against Studio's main Surfnet, causing overrides calculated from one network's account state to be applied to another network.

---

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