Skip to content

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

Open
92Infinitus92 wants to merge 9 commits into
feat/scenarios/raw-layoutfrom
feat/tessera-support
Open

92Infinitus92 wants to merge 9 commits into
feat/scenarios/raw-layoutfrom
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.

RetriggerConfidence Score: 5/5

The PR appears safe to merge.

Summary

The PR adds declarative Tessera state preparation, including raw-layout templates, market discovery, fair-value and depth builders, MCP tooling, and live protocol tests.

  • Registers six Tessera templates for price, depth, curve, halt, freshness, and stale-quote preparation.
  • Adds market validation and discovery through the caller-selected Surfnet RPC.
  • Adds MCP tools for listing markets and creating fair-value or depth scenarios.
  • Extends raw layouts with strided u8 writes for ladder-wide flags.
  • Adds gated live tests for the pinned Tessera deployment and quote behavior.
Diagram
sequenceDiagram
    participant Client as MCP Client
    participant MCP as Surfpool MCP
    participant RPC as Selected Surfnet RPC
    participant Builder as Tessera Builder
    participant Studio as Scenario Studio
    Client->>MCP: Tessera tool call (surfnetPort)
    MCP->>RPC: Read market and mint accounts
    RPC-->>MCP: Current account state
    MCP->>Builder: Validate and build overrides
    Builder-->>MCP: Scenario
    MCP->>Studio: Stage scenario
    Studio-->>Client: Editor URL
Loading

Reviews (13) · Last reviewed commit: "docs(tessera): say that the freshness ov..."

@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.

@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.

@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 Outdated
@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 thread crates/mcp/src/surfpool/mod.rs
@92Infinitus92
92Infinitus92 changed the base branch from feat/bisonfi-support to feat/scenarios/raw-layout September 14, 2026 13:38
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.
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.
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.
The Tessera, HumidiFi and GoonFi parameter structs deserialized their fields as snake_case, so a
client sending surfnetPort the way the pump, get_template and search_constant_options tools expect
it was ignored and the read fell back to port 8899. Scenario tools now share one convention.
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