Repository navigation
feat(scenarios): tag the Pyth v2 and Phoenix collections clock-sensitive - #39
Conversation
There was a problem hiding this comment.
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-sensitivebeing present, but nothing checks it. Renaming or dropping the tag would silently remove the warning. Add a small assertion inregistry.rs, next totest_filter_by_tags. For example:registry.by_tags(&["clock-sensitive".into()])containspyth-price-feed-v2and 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 withpull-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.
|
|
||
| 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. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
| Pull request title and body: | ||
| ---- | ||
| ${{ github.event.pull_request.title }} | ||
| ${{ github.event.pull_request.body }} |
There was a problem hiding this comment.
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.
…ections in the README
There was a problem hiding this comment.
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.
| .all() | ||
| .iter() | ||
| .map(|template| template.id.as_str()) | ||
| .filter(|id| *id == "pyth-price-feed-v2" || id.starts_with("phoenix-")) |
There was a problem hiding this comment.
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.
| 9, | ||
| "Pyth price feed v2 and the eight Phoenix templates" | ||
| ); | ||
| assert_eq!(tagged, expected); |
There was a problem hiding this comment.
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.
| Pull request title and body: | ||
| ---- | ||
| ${{ github.event.pull_request.title }} | ||
| ${{ github.event.pull_request.body }} |
There was a problem hiding this comment.
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.
…tagged collections can join
There was a problem hiding this comment.
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.ymlhas nothing to do with scenario tags. Moving it to its own PR would make both easier to review and revert. - Tag overloading:
tagsso far hold categories likeoracle,dexanddefi. If Studio or other consumers show tags as filter chips or labels,clock-sensitivewill show up there as a category. If that matters, a dedicated field would be cleaner, e.g.clock_sensitive: trueon the collection, ortraitslater 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() { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
|
|
||
| Pull request title and body: | ||
| ---- | ||
| ${{ github.event.pull_request.title }} |
There was a problem hiding this comment.
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.
e5ef15d
into
feat/scenarios/override/scenario-playback-support
What
Adds the collection tag
clock-sensitiveto 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/templatesto warn before pausing (companion PR LimeChain/surfpool-web-ui#32).The tag sits at collection level because entry-level
tagsare not read today (YamlOverrideTemplateEntryhas notagsfield). 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-sensitiveintags.crates/core/src/scenarios/protocols/phoenix-eternal/v1/overrides.yaml:clock-sensitiveintags.crates/core/src/scenarios/README.md: one paragraph.crates/core/src/scenarios/registry.rs:test_clock_sensitive_tag_marks_pyth_and_every_phoenix_templatechecks the tag per template (Pyth by id, Phoenix throughby_protocol), so other collections can add the tag without editing it.Verification
On
upstream/main6acd394 (v1.7.0 and the instruction-driven Phoenix templates, merged into this branch):cargo +nightly fmt --all -- --checkcargo test -p surfpool-core --features ignore_tests_ci: 849 passed, 0 failed, 64 ignoredcargo clippy -p surfpool-core --all-targets --features integration-tests: no errors, no warning on a line this PR adds/v1/scenarios/templatesserves the tag onpyth-price-feed-v2and 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