Skip to content

feat(scenarios): add reusable raw-layout overrides - #15

Open
bakasura980 wants to merge 1 commit into
feat/scenarios/protocols/kaminofrom
feat/scenarios/raw-layout
Open

feat(scenarios): add reusable raw-layout overrides#15
bakasura980 wants to merge 1 commit into
feat/scenarios/protocols/kaminofrom
feat/scenarios/raw-layout

Conversation

@bakasura980

@bakasura980 bakasura980 commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Greptile Summary

The PR introduces optional IDL-free templates backed by guarded raw byte layouts, exact integer encodings, strided writes, and a new materialization path in the SVM.

  • Adds raw-layout metadata and integer/pubkey/slot encodings to shared scenario types.
  • Loads no-IDL override collections and applies them directly to existing account bytes.
  • Updates IDL-dependent tests and documentation for optional template IDLs.

Confidence Score: 4/5

The PR should not merge until the coupled Studio client can select and edit templates whose IDL is intentionally absent.

Raw-layout templates are emitted with idl: null, while Studio’s current action-selection path rejects exactly that shape; loader validation is also deferred until materialization.

Files Needing Attention: crates/types/src/scenarios.rs, crates/core/src/scenarios/registry.rs

Important Files Changed

Filename Overview
crates/types/src/scenarios.rs Adds the raw-layout contract and encoders, but making template IDLs optional is not yet supported by the coupled Studio consumer.
crates/core/src/surfnet/svm.rs Adds guarded raw-byte materialization before IDL lookup and preserves account-level metadata.
crates/core/src/scenarios/registry.rs Adds no-IDL collection loading, but accepts structurally incomplete raw-layout templates without early validation.
crates/core/src/scenarios/README.md Documents raw-layout YAML, guarded writes, little-endian encoding, and large-integer string handling.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Scenario[Scheduled override] --> Resolve[Resolve account]
  Resolve --> Layout{Template has raw layout?}
  Layout -->|Yes| Guard[Check size and magic]
  Guard --> Encode[Encode supplied values]
  Encode --> Write[Write offsets and strides]
  Write --> State[Update local account]
  Layout -->|No| IDL[Existing IDL materialization]
  IDL --> State
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/types/src/scenarios.rs:396-400
**Optional IDL breaks Studio**

When a raw-layout template is returned with `idl: null`, Studio's action-selection handler rejects it as missing an IDL and returns before fetching the account or constructing the override. This makes raw-layout templates unusable in the coupled [scenario editor](https://github.com/limechain/surfpool-web-ui/blob/HEAD/apps/studio/src/components/svm/scenario-editor.tsx#L524-L533), despite exposing them through the same template contract.

### Issue 2
crates/core/src/scenarios/registry.rs:195-198
**Raw-layout invariants remain unvalidated**

`load_raw_layout_overrides` accepts collections without `raw_layout` and writable properties without both `offset` and `encoding`. These invalid templates are inserted successfully and fail only during scheduled materialization, leaving the account unchanged after emitting a warning; validate the required combinations while loading the collection.

---

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

Reviews (1): Last reviewed commit: "feat(scenarios): add reusable raw-layout..." | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

Context used:

Comment on lines +396 to +400
/// IDL for the account structure - defines all available fields and types.
///
/// `None` for programs that publish no IDL and are written through `raw_layout` instead. Those
/// templates cannot use the IDL write path at all, so there is nothing to reconstruct here.
pub idl: Option<Idl>,

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 Optional IDL breaks Studio

When a raw-layout template is returned with idl: null, Studio's action-selection handler rejects it as missing an IDL and returns before fetching the account or constructing the override. This makes raw-layout templates unusable in the coupled scenario editor, despite exposing them through the same template contract.

Knowledge Base Used: Shared data contracts

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/types/src/scenarios.rs
Line: 396-400

Comment:
**Optional IDL breaks Studio**

When a raw-layout template is returned with `idl: null`, Studio's action-selection handler rejects it as missing an IDL and returns before fetching the account or constructing the override. This makes raw-layout templates unusable in the coupled [scenario editor](https://github.com/limechain/surfpool-web-ui/blob/HEAD/apps/studio/src/components/svm/scenario-editor.tsx#L524-L533), despite exposing them through the same template contract.

**Knowledge Base Used:** [Shared data contracts](https://app.greptile.com/limechain/-/custom-context/knowledge-base/limechain/surfpool/-/docs/shared-data-contracts.md)

---

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

Comment on lines +195 to +198
/// For programs that publish no IDL. Their templates must carry a `raw_layout` and spell out
/// every property description, since there is no schema to fall back on.
pub fn load_raw_layout_overrides(&mut self, overrides_content: &str, protocol_name: &str) {
self.load_collection(None, overrides_content, protocol_name);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Raw-layout invariants remain unvalidated

load_raw_layout_overrides accepts collections without raw_layout and writable properties without both offset and encoding. These invalid templates are inserted successfully and fail only during scheduled materialization, leaving the account unchanged after emitting a warning; validate the required combinations while loading the collection.

Knowledge Base Used: Scenario execution

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/core/src/scenarios/registry.rs
Line: 195-198

Comment:
**Raw-layout invariants remain unvalidated**

`load_raw_layout_overrides` accepts collections without `raw_layout` and writable properties without both `offset` and `encoding`. These invalid templates are inserted successfully and fail only during scheduled materialization, leaving the account unchanged after emitting a warning; validate the required combinations while loading the collection.

**Knowledge Base Used:** [Scenario execution](https://app.greptile.com/limechain/-/custom-context/knowledge-base/limechain/surfpool/-/docs/scenario-execution.md)

---

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