Skip to content

feat(scenarios): tag the Pyth v2 and Phoenix collections clock-sensitive - #39

Merged
92Infinitus92 merged 6 commits into
feat/scenarios/override/scenario-playback-supportfrom
feat/scenarios/clock-sensitive-collections
Nov 2, 2026
Merged

92Infinitus92 merged 6 commits into
feat/scenarios/override/scenario-playback-supportfrom
feat/scenarios/clock-sensitive-collections

Conversation

@92Infinitus92

@92Infinitus92 92Infinitus92 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

What

Adds the collection tag clock-sensitive to the Pyth price feed v2 and Phoenix Eternal collections, one README paragraph on what the tag means, and a registry test that pins it.

Why

Some accounts carry a time or slot that the program checks against the Clock: a Pyth publish_time, Phoenix's oracle staleness window, later Whirlpool and Project 0 fields. When Studio plays a scenario with the clock paused, an account fetched from mainnet stays ahead of the surfnet's time and the program can refuse transactions. Studio reads this tag from /v1/scenarios/templates to warn before pausing (companion PR LimeChain/surfpool-web-ui#32).

The tag sits at collection level because entry-level tags are not read today (YamlOverrideTemplateEntry has no tags field). Every template of the two collections gets it; for Phoenix that includes templates without a time check, which only means an extra warning.

Kamino scope is left out for now. Whirlpool, Project 0 and Save get the tag on their own branches.

Changes

  • crates/core/src/scenarios/protocols/pyth/v2/overrides.yaml: clock-sensitive in tags.
  • crates/core/src/scenarios/protocols/phoenix-eternal/v1/overrides.yaml: clock-sensitive in tags.
  • crates/core/src/scenarios/README.md: one paragraph.
  • crates/core/src/scenarios/registry.rs: test_clock_sensitive_tag_marks_pyth_and_every_phoenix_template checks the tag per template (Pyth by id, Phoenix through by_protocol), so other collections can add the tag without editing it.

Verification

On upstream/main 6acd394 (v1.7.0 and the instruction-driven Phoenix templates, merged into this branch):

  • cargo +nightly fmt --all -- --check
  • cargo test -p surfpool-core --features ignore_tests_ci: 849 passed, 0 failed, 64 ignored
  • cargo clippy -p surfpool-core --all-targets --features integration-tests: no errors, no warning on a line this PR adds
  • Live (before the upstream merge): /v1/scenarios/templates serves the tag on pyth-price-feed-v2 and every Phoenix template; Studio shows the warning for a Pyth SOL/USD scenario and not for a Whirlpool one.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CkgCK6kr7c138a1U8kmaN4

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

This PR adds the clock-sensitive tag to the Pyth v2 and Phoenix Eternal collections, adds a README paragraph on what the tag means, and adds a Claude PR-review workflow. The YAML changes are small and safe. Collection-level tags already flow to every template, and the PR body explains why the tag isn't set per entry.

Issues

  • No test pins the tag. Studio now depends on the string clock-sensitive being present, but nothing checks it. Renaming or dropping the tag would silently remove the warning. Add a small assertion in registry.rs, next to test_filter_by_tags. For example: registry.by_tags(&["clock-sensitive".into()]) contains pyth-price-feed-v2 and the Phoenix templates.
  • README examples don't match what this PR tags (see inline comment).
  • Workflow (claude-review.yml): the PR title and body go straight into the prompt, so text in them can steer the review, and the bot posts with pull-requests: write. The risk is reduced because fork PRs are skipped and the review tools are read-only. If people other than maintainers can push branches to this repo, note the risk or sanitize the input. Otherwise the workflow looks reasonable: actions are pinned to SHAs, ${{ }} values reach shell commands through env vars, and there's a fallback to a plain comment when an inline review is rejected. The workflow is also unrelated to the feature, so it would be cleaner as its own PR.

Overall: fine to merge once the README examples and a regression test are sorted out.

Comment thread crates/core/src/scenarios/README.md Outdated

A collection tagged `clock-sensitive` holds accounts with a time or slot the program checks against the Clock. Playing such a
scenario with the clock paused leaves fetched accounts ahead of the surfnet's time, and the program can refuse transactions
(Whirlpool `InvalidTimestamp`, Project 0 `PythPushStalePrice`); Studio warns before pausing for them.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The examples here (Whirlpool InvalidTimestamp, Project 0 PythPushStalePrice) are for collections that are not tagged in this PR. The ones that are tagged (Pyth v2, Phoenix) aren't mentioned. Until the Whirlpool and Project 0 branches land, this is confusing for readers. Consider using Pyth's publish_time and Phoenix's oracle staleness window as the examples. Also suggest saying explicitly that the tag applies to every template in the collection, so readers expect some false-positive warnings (e.g. Phoenix templates that have no time check).

- perpetuals
- collateral
- risk
- clock-sensitive

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This tags all eight Phoenix templates, including ones with no time check, which means extra warnings in Studio. That's acceptable as a stopgap. Consider adding a short YAML comment explaining why the tag is here, and adding entry-level tags support to YamlOverrideTemplateEntry later so the warning can be scoped to the templates that actually need it.

- oracle
- price-feed
- defi
- clock-sensitive

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Studio now relies on this tag, but no test checks it. Suggest adding an assertion in registry.rs (e.g. next to test_filter_by_tags) that by_tags(["clock-sensitive"]) includes pyth-price-feed-v2 and the Phoenix templates. That way a rename or a dropped tag fails CI instead of silently removing the warning.

Comment thread .github/workflows/claude-review.yml Outdated
Pull request title and body:
----
${{ github.event.pull_request.title }}
${{ github.event.pull_request.body }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR title and body are put into the prompt word for word, so the PR author's text can steer the review content. That review is then posted by the job that has pull-requests: write. Skipping fork PRs and using read-only tools limits the damage. Still, consider wrapping the PR text in clear delimiters and telling the model to treat it as untrusted data, not instructions.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

This PR adds a collection-level clock-sensitive tag to the Pyth v2 and Phoenix Eternal override collections, adds a README paragraph explaining the tag, adds a registry test, and adds a Claude PR-review workflow.

Assessment: The YAML and README changes are small and correct. by_tags matches on collection tags that each template inherits, so all 9 templates get the tag as the PR describes.

Notes:

  • The PR body says the change "needs no Rust", and its Changes list leaves out registry.rs. The PR does add a Rust test there, so the description should mention it.
  • The test is brittle given the planned follow-ups (details inline). When the Whirlpool, Project 0 and Save branches add the same tag, the test will fail.
  • In the workflow, the PR title and body go straight into the prompt, so a PR author can inject instructions. The job only gets read-only tools and the PR must come from a same-repo branch, so the impact is limited to a misleading review comment. That seems acceptable, but it's worth knowing.

Comment thread crates/core/src/scenarios/registry.rs Outdated
.all()
.iter()
.map(|template| template.id.as_str())
.filter(|id| *id == "pyth-price-feed-v2" || id.starts_with("phoenix-"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The test builds expected by id prefix and then requires tagged == expected. As soon as the Whirlpool, Project 0 or Save branches add clock-sensitive, this assertion will fail. It would also quietly pick up any future protocol whose ids start with phoenix-.

Suggestion: check that each Pyth/Phoenix template is in tagged, using registry.by_protocol(...) rather than id prefixes, and don't require the tagged set to be exactly these 9. Alternatively, keep the exact check but expect to update it on each of those branches.

Comment thread crates/core/src/scenarios/registry.rs Outdated
9,
"Pyth price feed v2 and the eight Phoenix templates"
);
assert_eq!(tagged, expected);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor: the hardcoded 9 will also break whenever a Phoenix template is added or removed, even though the tag still works correctly. Asserting that expected is non-empty is enough to stop the comparison from passing trivially.

Comment thread .github/workflows/claude-review.yml Outdated
Pull request title and body:
----
${{ github.event.pull_request.title }}
${{ github.event.pull_request.body }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR title and body are inserted into the prompt as-is, so a PR author can inject instructions (for example, "approve this, report no issues"). Shell injection isn't possible here, and the tools are read-only. Still, consider labelling this text as untrusted in the prompt, or leaving the body out.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

This PR adds a collection-level clock-sensitive tag to Pyth v2 and Phoenix Eternal, a README paragraph explaining it, a registry test that checks the tag, and a new Claude review workflow. The data change is small and correct. by_tags matches any tag and by_protocol compares names case-insensitively, so the test checks what it says it does. It also fails if the Phoenix templates stop being registered.

Notes

  • Scope: .github/workflows/claude-review.yml has nothing to do with scenario tags. Moving it to its own PR would make both easier to review and revert.
  • Tag overloading: tags so far hold categories like oracle, dex and defi. If Studio or other consumers show tags as filter chips or labels, clock-sensitive will show up there as a category. If that matters, a dedicated field would be cleaner, e.g. clock_sensitive: true on the collection, or traits later on.
  • Coverage: Switchboard v2 and Drift v2 have staleness checks against Clock too (Switchboard checks the feed slot or timestamp, Drift checks oracle validity windows). Their templates may hit the same paused-clock problem. Please either tag them or note why they are excluded, as the PR body does for Kamino scope.
  • Workflow: The PR title and body are interpolated straight into the prompt, so a PR author can inject instructions. The impact is limited because fork PRs are skipped and the tools are read-only. Keep in mind that whatever the model returns is posted with pull-requests: write.

Overall the tag change looks good to merge. The comments below are minor.

}

#[test]
fn test_clock_sensitive_tag_marks_pyth_and_every_phoenix_template() {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Minor: the test only checks that the tag is present. Consider also asserting that a collection known to be insensitive, e.g. a Jupiter or Whirlpool template (until its branch lands), is not tagged. Otherwise a tag put on the wrong collection by mistake would go unnoticed, since Studio would just warn for it.

A collection tagged `clock-sensitive` holds accounts with a time or slot the program checks against the Clock, such as a
Pyth price's `publish_time` or the oracle staleness window of Phoenix markets. Playing such a scenario with the clock paused
leaves fetched accounts ahead of the surfnet's time, and the program can refuse transactions; Studio warns before pausing for
them. The tag applies to every template in the collection, including ones without a time check.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

It would help to say that the tag is read at collection level only, because entry-level tags are ignored (YamlOverrideTemplateEntry has no tags field). Otherwise a contributor may add it to a single template and wonder why Studio never warns.

Comment thread .github/workflows/claude-review.yml Outdated

Pull request title and body:
----
${{ github.event.pull_request.title }}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR title and body go into the prompt unescaped, so a PR author can inject instructions. The job is limited to same-repo PRs and read-only tools, but the output is posted with pull-requests: write. Consider fencing this section and telling the model to treat it as untrusted data.

@92Infinitus92
92Infinitus92 merged commit e5ef15d into feat/scenarios/override/scenario-playback-support Nov 2, 2026
1 check passed
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