-
Notifications
You must be signed in to change notification settings - Fork 13
Add to_yaml_string function to OrderbookYaml and DotrainYaml
#2334
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: yaml-context-improvement
Are you sure you want to change the base?
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughAdds YAML serialization (to_yaml_value/to_yaml_array) across many settings types, introduces profile-aware context (ContextProfile) and profile plumbing in DotrainYaml/OrderbookYaml, and updates callers (DotrainOrder, js_api) to create orders with an explicit profile; also extends YAML traits and error handling. Changes
Sequence Diagram(s)sequenceDiagram
participant GUI as js_api / UI
participant RainDoc as RainDocument (frontmatter)
participant DotrainYaml as DotrainYaml
participant DotrainOrder as DotrainOrder
participant Settings as Settings readers (Yaml parsers)
GUI->>RainDoc: extract frontmatter
RainDoc->>DotrainYaml: build with frontmatter
DotrainYaml->>DotrainYaml: build_context(profile) (Gui with order/deployment)
GUI->>DotrainOrder: call create_with_profile(dotrain, settings, profile)
DotrainOrder->>DotrainYaml: DotrainYaml::new_with_profile(...)
DotrainOrder->>Settings: parse/expand using ContextProfile
Settings->>DotrainOrder: resolved orders/deployments/etc.
DotrainOrder-->>GUI: initialized order (profile-aware)
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/settings/src/yaml/mod.rs (1)
240-298: AddTraitFnNotImplementedtoYamlError’sPartialEqimplementation
YamlErrorgained aTraitFnNotImplementedvariant, butPartialEqdoesn’t have a branch for it. Currently twoYamlError::TraitFnNotImplementedvalues compare as not equal, which is surprising and could break future tests or logic that assert on this variant.You can fix this by adding a dedicated match arm:
impl PartialEq for YamlError { fn eq(&self, other: &Self) -> bool { match (self, other) { @@ (Self::EmptyFile, Self::EmptyFile) => true, (Self::ConvertError, Self::ConvertError) => true, - (Self::InvalidTraitFunction, Self::InvalidTraitFunction) => true, + (Self::InvalidTraitFunction, Self::InvalidTraitFunction) => true, + (Self::TraitFnNotImplemented, Self::TraitFnNotImplemented) => true, @@ (Self::ContextError(e1), Self::ContextError(e2)) => e1.to_string() == e2.to_string(), (Self::NotFound(s1), Self::NotFound(s2)) => s1 == s2, _ => false, } } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (19)
crates/settings/src/accounts.rs(2 hunks)crates/settings/src/chart.rs(3 hunks)crates/settings/src/deployer.rs(3 hunks)crates/settings/src/deployment.rs(4 hunks)crates/settings/src/gui.rs(2 hunks)crates/settings/src/local_db_remotes.rs(3 hunks)crates/settings/src/local_db_sync.rs(4 hunks)crates/settings/src/metaboard.rs(2 hunks)crates/settings/src/network.rs(5 hunks)crates/settings/src/order.rs(3 hunks)crates/settings/src/orderbook.rs(4 hunks)crates/settings/src/remote_networks.rs(3 hunks)crates/settings/src/remote_tokens.rs(2 hunks)crates/settings/src/scenario.rs(2 hunks)crates/settings/src/subgraph.rs(2 hunks)crates/settings/src/token.rs(2 hunks)crates/settings/src/yaml/dotrain.rs(5 hunks)crates/settings/src/yaml/mod.rs(6 hunks)crates/settings/src/yaml/orderbook.rs(4 hunks)
🧰 Additional context used
🧠 Learnings (49)
📓 Common learnings
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1897
File: crates/settings/src/yaml/orderbook.rs:311-311
Timestamp: 2025-05-27T10:19:38.011Z
Learning: The rainlanguage/rain.orderbook project uses strict YAML parsing (StrictYaml library), so concerns about inconsistent parsing between integer and string values in YAML (like `spec-version: 1` vs `spec-version: "1"`) are not relevant to this codebase.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2270
File: crates/settings/src/local_db_remotes.rs:107-212
Timestamp: 2025-10-27T09:17:38.145Z
Learning: In the rain.orderbook codebase using strict_yaml_rust, all YAML keys are treated as strings, including numeric literals. Numeric keys like `123` are automatically coerced to strings and are valid, so they don't need error-case testing for non-string keys.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:26:31.566Z
Learning: For PR #1884 and future PRs in rainlanguage/rain.orderbook repository, provide PR size reports in a separate comment with ONLY the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number", without any additional text or explanation. Reports should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the format: "TOTAL=number ADDITIONS=number DELETIONS=number". This report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).
📚 Learning: 2025-07-11T06:40:49.511Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1983
File: crates/js_api/src/gui/mod.rs:964-1199
Timestamp: 2025-07-11T06:40:49.511Z
Learning: In crates/js_api/src/gui/mod.rs tests, findolor prefers to keep large hardcoded YAML strings (like the validation test YAML) inline in the test file rather than extracting them to separate external files for maintainability purposes.
Applied to files:
crates/settings/src/local_db_remotes.rscrates/settings/src/metaboard.rscrates/settings/src/scenario.rscrates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/deployer.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/accounts.rscrates/settings/src/gui.rscrates/settings/src/yaml/mod.rscrates/settings/src/orderbook.rscrates/settings/src/network.rscrates/settings/src/token.rscrates/settings/src/remote_networks.rscrates/settings/src/remote_tokens.rscrates/settings/src/local_db_sync.rscrates/settings/src/subgraph.rs
📚 Learning: 2025-10-06T11:13:29.956Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2123
File: crates/common/src/raindex_client/local_db/mod.rs:23-29
Timestamp: 2025-10-06T11:13:29.956Z
Learning: In `crates/common/src/raindex_client/local_db/mod.rs`, the `Default` implementation for `LocalDb` that creates an RPC client pointing to `http://localhost:4444` is acceptable because the RPC client must be explicitly configured before actual usage in production scenarios.
Applied to files:
crates/settings/src/local_db_remotes.rs
📚 Learning: 2025-05-13T20:06:22.602Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1713
File: crates/settings/src/remote/chains/mod.rs:43-226
Timestamp: 2025-05-13T20:06:22.602Z
Learning: When writing tests for collections of complex objects in Rust, prefer item-by-item comparison over direct vector comparison to get more specific error messages that pinpoint exactly which item and field has a mismatch.
Applied to files:
crates/settings/src/local_db_remotes.rscrates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/network.rscrates/settings/src/local_db_sync.rs
📚 Learning: 2025-06-18T19:23:33.747Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/mod.rs:176-178
Timestamp: 2025-06-18T19:23:33.747Z
Learning: In crates/settings/src/yaml/mod.rs, the YamlError enum has two distinct error variants: `KeyNotFound(String)` for when a specific YAML key is not found in a hash/map, and `NotFound(String)` for when other types of entities (like networks, orderbooks, etc.) are not found in the configuration. These serve different purposes and should not be consolidated.
Applied to files:
crates/settings/src/local_db_remotes.rscrates/settings/src/metaboard.rscrates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/deployer.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/accounts.rscrates/settings/src/yaml/mod.rscrates/settings/src/orderbook.rscrates/settings/src/network.rscrates/settings/src/token.rscrates/settings/src/remote_networks.rscrates/settings/src/local_db_sync.rscrates/settings/src/subgraph.rs
📚 Learning: 2025-04-07T09:50:54.715Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1483
File: crates/settings/src/yaml/cache.rs:23-25
Timestamp: 2025-04-07T09:50:54.715Z
Learning: The Cache implementation in crates/settings/src/yaml/cache.rs returns cloned HashMaps in getter methods (like get_remote_networks) rather than references. This design choice was explicitly accepted by the maintainer.
Applied to files:
crates/settings/src/local_db_remotes.rscrates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/remote_networks.rscrates/settings/src/local_db_sync.rs
📚 Learning: 2025-06-17T16:21:24.384Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.
Applied to files:
crates/settings/src/local_db_remotes.rscrates/settings/src/metaboard.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/orderbook.rscrates/settings/src/network.rscrates/settings/src/remote_tokens.rscrates/settings/src/local_db_sync.rs
📚 Learning: 2025-09-01T13:35:33.688Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2116
File: crates/settings/src/orderbook.rs:569-0
Timestamp: 2025-09-01T13:35:33.688Z
Learning: In crates/settings/src/orderbook.rs, the deployment-block field is required in orderbook YAML configuration and should cause a parsing error when missing, not default to any value.
Applied to files:
crates/settings/src/scenario.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/deployer.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/orderbook.rs
📚 Learning: 2025-03-31T14:36:11.049Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1474
File: crates/js_api/src/yaml/mod.rs:37-44
Timestamp: 2025-03-31T14:36:11.049Z
Learning: The OrderbookYaml implementation in crates/js_api/src/yaml/mod.rs intentionally parses YAML on demand without caching results. This is a deliberate design choice by the author to process YAML only when needed rather than optimizing for repeated calls.
Applied to files:
crates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/deployer.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/yaml/mod.rscrates/settings/src/orderbook.rscrates/settings/src/network.rscrates/settings/src/remote_networks.rscrates/settings/src/local_db_sync.rs
📚 Learning: 2025-05-19T13:40:56.080Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1858
File: crates/subgraph/src/orderbook_client/mod.rs:54-58
Timestamp: 2025-05-19T13:40:56.080Z
Learning: The `wasm_bindgen_utils` crate in the Rain Orderbook project handles conditional compilation for `JsValue` and `JsError` internally, allowing `impl From<Error> for JsValue` to work on non-WASM targets without explicit cfg guards.
Applied to files:
crates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/deployer.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/network.rs
📚 Learning: 2025-05-14T05:13:59.713Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1744
File: crates/subgraph/src/orderbook_client.rs:44-46
Timestamp: 2025-05-14T05:13:59.713Z
Learning: In the rain.orderbook project, WASM dependencies are intentionally made available in non-WASM targets to facilitate testing of WASM-related functionality, so conditional compilation guards like `#[cfg(target_family = "wasm")]` should not be added to imports or implementations that may be needed for tests.
Applied to files:
crates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-06-24T13:30:02.968Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1950
File: crates/common/src/raindex_client/transactions.rs:34-38
Timestamp: 2025-06-24T13:30:02.968Z
Learning: When using #[wasm_bindgen] on an impl block, all methods within that block must have wasm_bindgen attributes, even if they are conditionally compiled for non-WASM targets using #[cfg(not(target_family = "wasm"))]. Removing these attributes causes compiler errors because the wasm_bindgen macro expansion processes the entire impl block and expects consistent attribute usage across all methods.
Applied to files:
crates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/deployer.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/local_db_sync.rs
📚 Learning: 2025-08-01T09:07:20.383Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: packages/orderbook/README.md:186-189
Timestamp: 2025-08-01T09:07:20.383Z
Learning: In the rainlanguage/rain.orderbook project, Rust methods on structs like RaindexVaultsList are exported as JavaScript getters in WASM bindings using #[wasm_bindgen(getter)]. This means while the Rust code uses method calls like items(), the JavaScript/WASM API exposes them as property access like .items. The README.md correctly documents the JavaScript API surface, not the Rust implementation details.
Applied to files:
crates/settings/src/chart.rscrates/settings/src/deployment.rs
📚 Learning: 2025-10-27T09:17:38.145Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2270
File: crates/settings/src/local_db_remotes.rs:107-212
Timestamp: 2025-10-27T09:17:38.145Z
Learning: In the rain.orderbook codebase using strict_yaml_rust, all YAML keys are treated as strings, including numeric literals. Numeric keys like `123` are automatically coerced to strings and are valid, so they don't need error-case testing for non-string keys.
Applied to files:
crates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/deployer.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/yaml/mod.rscrates/settings/src/orderbook.rscrates/settings/src/network.rscrates/settings/src/remote_networks.rs
📚 Learning: 2025-03-31T13:57:59.660Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1474
File: crates/js_api/src/yaml/mod.rs:31-34
Timestamp: 2025-03-31T13:57:59.660Z
Learning: The OrderbookYaml constructor in crates/js_api/src/yaml/mod.rs does not need early YAML validation. The author prefers to validate YAML only when it's actually used rather than during initialization.
Applied to files:
crates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/order.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/gui.rscrates/settings/src/orderbook.rscrates/settings/src/remote_networks.rs
📚 Learning: 2025-10-21T05:16:07.124Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2256
File: crates/common/src/raindex_client/local_db/query/fetch_tables.rs:46-52
Timestamp: 2025-10-21T05:16:07.124Z
Learning: In Rust projects using wasm_bindgen_utils, the glob import `use wasm_bindgen_utils::prelude::*;` re-exports `Closure` from wasm_bindgen, so `Closure::wrap` can be used without explicitly importing `use wasm_bindgen::prelude::Closure;`.
Applied to files:
crates/settings/src/chart.rscrates/settings/src/deployment.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-09-24T10:54:42.060Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/cli/src/commands/order/calldata.rs:47-48
Timestamp: 2025-09-24T10:54:42.060Z
Learning: In crates/cli/src/commands/order/calldata.rs, the config_deployment variable is used both as a parameter to AddOrderArgs::new_from_deployment() and later to extract RPC information, requiring the clone() to maintain access after ownership transfer.
Applied to files:
crates/settings/src/deployment.rscrates/settings/src/order.rs
📚 Learning: 2025-05-16T17:24:34.724Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1844
File: tauri-app/src-tauri/src/commands/wallet.rs:27-28
Timestamp: 2025-05-16T17:24:34.724Z
Learning: In Rust projects, dependencies listed in the [dependencies] section of Cargo.toml are available for both application code and tests. The tokio crate with the "full" feature set includes the "test" feature needed for `#[tokio::test]` to work properly.
Applied to files:
crates/settings/src/deployment.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/network.rscrates/settings/src/local_db_sync.rs
📚 Learning: 2025-05-20T10:20:08.206Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1859
File: crates/quote/src/quote_debug.rs:472-492
Timestamp: 2025-05-20T10:20:08.206Z
Learning: In the Rain Orderbook codebase, the `#[tokio::test(flavor = "multi_thread")]` annotation is specifically needed for tests that use `LocalEvm`, not just for consistency across all async tests.
Applied to files:
crates/settings/src/deployment.rscrates/settings/src/yaml/orderbook.rs
📚 Learning: 2025-07-18T10:31:05.498Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2008
File: crates/common/src/raindex_client/add_orders.rs:85-86
Timestamp: 2025-07-18T10:31:05.498Z
Learning: In the rainlanguage/rain.orderbook codebase, cfg-guarded imports like `#[cfg(not(target_family = "wasm"))] use super::*;` in test modules are sometimes needed to fix compiler warnings, even when similar imports exist in nested sub-modules. These should not be removed as they serve a specific purpose in the compilation process.
Applied to files:
crates/settings/src/deployment.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/orderbook.rs
📚 Learning: 2025-04-30T09:28:36.960Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1715
File: crates/js_api/src/common/mod.rs:111-118
Timestamp: 2025-04-30T09:28:36.960Z
Learning: In the rain.orderbook repository, the WASM tests are already properly configured with conditional compilation using `#[cfg(target_family = "wasm")]` and `#[cfg(not(target_family = "wasm"))]`, and don't require additional `wasm_bindgen_test_configure!(run_in_browser)` directives.
Applied to files:
crates/settings/src/deployment.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-08-02T02:34:32.237Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2036
File: crates/js_api/src/filters/raindex_filter_store.rs:446-533
Timestamp: 2025-08-02T02:34:32.237Z
Learning: In the rainlanguage/rain.orderbook project's RaindexFilterStore WASM tests (crates/js_api/src/filters/raindex_filter_store.rs), brusherru decided to focus on testing only methods without side effects (that don't use web_sys) due to difficulties with mocking localStorage and window APIs in the WASM test environment. This pragmatic approach tests pure logic separately from browser integration.
Applied to files:
crates/settings/src/deployment.rs
📚 Learning: 2025-07-21T16:34:04.947Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/raindex_client/orders.rs:720-720
Timestamp: 2025-07-21T16:34:04.947Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers using `.unwrap()` in test code rather than `.expect()` with descriptive messages, considering the direct unwrap approach acceptable for test contexts where failures should be fast and clear.
Applied to files:
crates/settings/src/deployment.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/orderbook.rs
📚 Learning: 2025-07-31T19:34:11.716Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 2044
File: crates/common/src/raindex_client/vaults_list.rs:363-423
Timestamp: 2025-07-31T19:34:11.716Z
Learning: In the rainlanguage/rain.orderbook project, for WASM-exposed functionality like VaultsList, the team prefers to keep comprehensive tests in the non-WASM environment due to the complexity of recreating objects like RaindexVaults in WASM. WASM tests focus on basic functionality and error cases since the WASM code reuses the already-tested non-WASM implementation.
Applied to files:
crates/settings/src/deployment.rs
📚 Learning: 2025-05-27T10:19:38.011Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1897
File: crates/settings/src/yaml/orderbook.rs:311-311
Timestamp: 2025-05-27T10:19:38.011Z
Learning: The rainlanguage/rain.orderbook project uses strict YAML parsing (StrictYaml library), so concerns about inconsistent parsing between integer and string values in YAML (like `spec-version: 1` vs `spec-version: "1"`) are not relevant to this codebase.
Applied to files:
crates/settings/src/order.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/orderbook.rs
📚 Learning: 2025-06-16T10:49:47.770Z
Learnt from: thedavidmeister
Repo: rainlanguage/rain.orderbook PR: 1926
File: test/concrete/ob/OrderBook.clear.zeroAmount.t.sol:24-32
Timestamp: 2025-06-16T10:49:47.770Z
Learning: LibTestAddOrder.conformConfig() in test/util/lib/LibTestAddOrder.sol automatically constrains OrderConfigV3 to prevent common test failures by ensuring validInputs[0].token != validOutputs[0].token, setting them to address(0) and address(1) respectively if they're equal. This prevents TokenSelfTrade errors in fuzz tests.
Applied to files:
crates/settings/src/order.rs
📚 Learning: 2025-05-17T15:32:28.733Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1790
File: tauri-app/src-tauri/src/commands/vault.rs:67-67
Timestamp: 2025-05-17T15:32:28.733Z
Learning: For the PR focused on testing Tauri commands::order module, the generic type parameter R: Runtime was selectively added where needed for the PR scope, applying the changes primarily to order.rs and related files while leaving other modules like vault.rs for potential future refactoring.
Applied to files:
crates/settings/src/order.rs
📚 Learning: 2025-06-18T19:24:40.518Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:185-199
Timestamp: 2025-06-18T19:24:40.518Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers not to refactor get_orderbook_by_network_key to handle multiple orderbooks per network key since their current architecture maintains a one-to-one mapping between orderbooks and networks. They would consider the refactoring if the system evolves to support multiple orderbooks per network in the future.
Applied to files:
crates/settings/src/order.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/orderbook.rs
📚 Learning: 2025-04-07T09:54:21.782Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1483
File: crates/settings/src/yaml/orderbook.rs:45-45
Timestamp: 2025-04-07T09:54:21.782Z
Learning: The validation in OrderbookYaml's new method that includes RemoteNetworksCfg::parse_all_from_yaml is intentional and should remain as is, without conditional handling for users that only have local networks.
Applied to files:
crates/settings/src/order.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/orderbook.rscrates/settings/src/network.rscrates/settings/src/remote_networks.rs
📚 Learning: 2025-06-18T18:24:32.049Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/orderbook.rs:180-199
Timestamp: 2025-06-18T18:24:32.049Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to avoid refactoring duplicate search logic between get_orderbook_by_address and get_orderbook_by_network_key when there are only 2 functions, indicating they would consider it if more similar functions are added in the future.
Applied to files:
crates/settings/src/order.rscrates/settings/src/yaml/orderbook.rscrates/settings/src/yaml/dotrain.rscrates/settings/src/orderbook.rs
📚 Learning: 2025-04-22T12:50:39.581Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1687
File: crates/js_api/src/gui/mod.rs:258-259
Timestamp: 2025-04-22T12:50:39.581Z
Learning: In `DotrainOrderGui::generate_dotrain_text()`, the call to `.to_string()` on `self.dotrain_order.dotrain()` is necessary because there are two different implementations of the `dotrain()` method - one for WASM targets returning a String and one for non-WASM targets returning a &str. The `.to_string()` ensures type compatibility across different compilation targets.
Applied to files:
crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-04-07T09:52:30.960Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1483
File: crates/settings/src/yaml/dotrain.rs:20-20
Timestamp: 2025-04-07T09:52:30.960Z
Learning: In the DotrainYaml struct, the newly added `cache` field is kept public without documentation, which the maintainer confirmed is acceptable for now.
Applied to files:
crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-03-31T18:53:12.208Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1477
File: crates/settings/src/yaml/dotrain.rs:20-20
Timestamp: 2025-03-31T18:53:12.208Z
Learning: In the DotrainYaml struct, the cache field is kept public (`pub cache: Cache`) without additional getter methods, which is consistent with the existing design pattern in the codebase where other fields like `documents` are also public.
Applied to files:
crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-07-04T10:24:29.750Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: crates/common/src/raindex_client/add_orders.rs:132-132
Timestamp: 2025-07-04T10:24:29.750Z
Learning: In the rain.orderbook codebase, findolor prefers to use `unwrap_or("")` for optional frontmatter in dotrain parsing, allowing empty strings to be handled by downstream validation in `NewConfig::try_from_yaml()` rather than adding explicit early validation checks at the extraction point.
Applied to files:
crates/settings/src/yaml/dotrain.rscrates/settings/src/orderbook.rs
📚 Learning: 2025-06-20T07:26:50.488Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1941
File: crates/settings/src/yaml/orderbook.rs:112-123
Timestamp: 2025-06-20T07:26:50.488Z
Learning: In crates/settings/src/yaml/orderbook.rs, the user prefers to keep the get_network_by_chain_id implementation simple with O(n) lookup rather than adding caching complexity for performance optimization, even if the method might be called frequently.
Applied to files:
crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-07-11T06:41:11.924Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1983
File: crates/js_api/src/gui/deposits.rs:147-156
Timestamp: 2025-07-11T06:41:11.924Z
Learning: In the Rain OrderBook project, token info is already cached in the YAML file which serves as the source of truth, so the `get_token_info()` async method in the GUI SDK retrieves from pre-loaded/parsed data rather than making expensive network calls.
Applied to files:
crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-06-10T12:04:54.107Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1916
File: packages/ui-components/src/lib/__fixtures__/settings-12-11-24.json:182-195
Timestamp: 2025-06-10T12:04:54.107Z
Learning: In test fixture files like `packages/ui-components/src/lib/__fixtures__/settings-12-11-24.json`, network configuration inconsistencies (such as matchain using Polygon's RPC, chainId, and currency while having its own network key) are acceptable since they are used for testing purposes only.
Applied to files:
crates/settings/src/yaml/dotrain.rscrates/settings/src/network.rscrates/settings/src/token.rs
📚 Learning: 2025-10-13T12:57:05.900Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2198
File: crates/common/src/raindex_client/local_db/query/fetch_store_addresses/mod.rs:7-8
Timestamp: 2025-10-13T12:57:05.900Z
Learning: In the rain.orderbook repository, using unqualified serde helper names (e.g., `#[serde(with = "serde_address")]`) that rely on glob imports is acceptable and does not need to be changed to fully qualified paths.
Applied to files:
crates/settings/src/orderbook.rs
📚 Learning: 2025-04-07T09:55:44.798Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1483
File: crates/settings/src/yaml/cache.rs:20-22
Timestamp: 2025-04-07T09:55:44.798Z
Learning: The Cache implementation in crates/settings/src/yaml/cache.rs is designed to overwrite existing entries without warning when using update methods like update_remote_network. This behavior is an intentional design choice.
Applied to files:
crates/settings/src/network.rscrates/settings/src/remote_networks.rscrates/settings/src/local_db_sync.rs
📚 Learning: 2025-06-17T16:57:25.456Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/settings/src/config.rs:287-288
Timestamp: 2025-06-17T16:57:25.456Z
Learning: In the rain.orderbook repository, validation for empty `rpcs` vectors in `NetworkConfigSource` is not required, as indicated by the maintainer findolor.
Applied to files:
crates/settings/src/network.rs
📚 Learning: 2025-04-03T09:45:04.200Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1477
File: crates/settings/src/remote_networks.rs:40-75
Timestamp: 2025-04-03T09:45:04.200Z
Learning: The RemoteNetworksCfg implementation in crates/settings/src/remote_networks.rs intentionally fetches remote networks sequentially rather than in parallel.
Applied to files:
crates/settings/src/network.rscrates/settings/src/remote_networks.rs
📚 Learning: 2025-04-08T12:53:12.526Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1588
File: packages/orderbook/test/js_api/gui.test.ts:2037-2057
Timestamp: 2025-04-08T12:53:12.526Z
Learning: In the remote network test for gui.test.ts, asserting that getCurrentDeployment() succeeds is sufficient validation that remote networks were properly fetched, as this operation would fail if the networks weren't correctly processed.
Applied to files:
crates/settings/src/remote_networks.rs
📚 Learning: 2025-06-17T16:28:19.664Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: tauri-app/src/routes/orders/[network]-[orderHash]/page.test.ts:68-69
Timestamp: 2025-06-17T16:28:19.664Z
Learning: In the tauri-app test files, the team is comfortable using single URLs in rpcs arrays for test mocks rather than multiple URLs, even when testing multi-RPC functionality. They don't consider this a coverage gap that needs to be addressed.
Applied to files:
crates/settings/src/remote_tokens.rs
📚 Learning: 2025-10-06T14:41:41.909Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2159
File: crates/cli/src/commands/local_db/sync/runner/mod.rs:52-113
Timestamp: 2025-10-06T14:41:41.909Z
Learning: The local DB sync CLI command (crates/cli/src/commands/local_db/sync/) is designed for CI-only usage, and simple println! statements are preferred over structured logging for status messages.
Applied to files:
crates/settings/src/local_db_sync.rs
📚 Learning: 2025-10-14T07:51:55.148Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2202
File: crates/common/src/raindex_client/local_db/sync.rs:33-34
Timestamp: 2025-10-14T07:51:55.148Z
Learning: In `crates/common/src/raindex_client/local_db/sync.rs`, the hard-coded `DEFAULT_SYNC_CHAIN_ID` constant (set to `SUPPORTED_LOCAL_DB_CHAINS[0]`) will be replaced with proper chain ID handling in downstream PRs as part of the multi-network/orderbook implementation.
Applied to files:
crates/settings/src/local_db_sync.rs
📚 Learning: 2025-11-04T09:20:06.368Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2292
File: crates/settings/src/remote/manifest.rs:35-44
Timestamp: 2025-11-04T09:20:06.368Z
Learning: In the rain.orderbook codebase, manifest version validation happens during parsing in crates/settings/src/local_db_manifest.rs. The parse_manifest_header function validates both manifest_version against MANIFEST_VERSION and db_schema_version against DB_SCHEMA_VERSION constants, failing with YamlError if either doesn't match. This means fetch_manifest calls will fail before returning if versions are incompatible, making cross-URL version consistency checks unnecessary in fetch_multiple_manifests.
Applied to files:
crates/settings/src/local_db_sync.rs
📚 Learning: 2025-06-11T11:49:05.862Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1917
File: packages/webapp/src/routes/+layout.ts:73-79
Timestamp: 2025-06-11T11:49:05.862Z
Learning: In this codebase it is intentional to have both `subgraph` (holding a `SubgraphCfg` object) and `subgraphUrl` (holding just the URL string). Wherever only the URL is needed as a prop, the `subgraphUrl` variable is retained, and no renaming to `subgraph` is expected.
Applied to files:
crates/settings/src/subgraph.rs
📚 Learning: 2025-06-11T11:15:15.006Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1917
File: tauri-app/src/lib/services/order.ts:34-35
Timestamp: 2025-06-11T11:15:15.006Z
Learning: In the settings schema, `SubgraphCfg` always includes a mandatory `url` field, so additional runtime checks for its presence are unnecessary.
Applied to files:
crates/settings/src/subgraph.rs
📚 Learning: 2025-06-18T18:18:44.330Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/mod.rs:92-99
Timestamp: 2025-06-18T18:18:44.330Z
Learning: In crates/js_api/src/raindex/mod.rs, the get_subgraph_url_for_chain method and get_multi_subgraph_args method intentionally duplicate lookup logic because they serve different purposes: get_subgraph_url_for_chain returns only the URL string, while get_multi_subgraph_args returns MultiSubgraphArgs structures containing both URL and network information (name/label). This duplication is acceptable and by design.
Applied to files:
crates/settings/src/subgraph.rs
🧬 Code graph analysis (14)
crates/settings/src/metaboard.rs (7)
crates/settings/src/orderbook.rs (1)
to_yaml_value(202-238)crates/settings/src/token.rs (1)
to_yaml_value(326-360)crates/settings/src/local_db_remotes.rs (1)
to_yaml_value(88-90)crates/settings/src/local_db_sync.rs (1)
to_yaml_value(139-172)crates/settings/src/remote_networks.rs (1)
to_yaml_value(133-145)crates/settings/src/subgraph.rs (1)
to_yaml_value(144-146)crates/settings/src/yaml/mod.rs (1)
default_document(524-526)
crates/settings/src/scenario.rs (8)
crates/settings/src/yaml/mod.rs (4)
to_yaml_value(82-82)new(43-43)to_yaml_hash(84-95)to_yaml_hash(125-127)crates/settings/src/deployer.rs (1)
to_yaml_value(179-195)crates/settings/src/token.rs (1)
to_yaml_value(326-360)crates/settings/src/order.rs (2)
to_yaml_value(830-905)to_yaml_value_serializes_strings_and_optionals(1210-1374)crates/settings/src/network.rs (1)
to_yaml_value(260-300)crates/settings/src/yaml/dotrain.rs (1)
new(86-114)crates/settings/src/yaml/orderbook.rs (1)
new(106-155)crates/settings/src/test.rs (1)
mock_deployer(22-29)
crates/settings/src/chart.rs (1)
crates/settings/src/yaml/mod.rs (4)
to_yaml_value(82-82)new(43-43)to_yaml_hash(84-95)to_yaml_hash(125-127)
crates/settings/src/deployment.rs (5)
crates/settings/src/yaml/mod.rs (4)
to_yaml_value(82-82)new(43-43)to_yaml_hash(84-95)to_yaml_hash(125-127)crates/settings/src/deployer.rs (1)
to_yaml_value(179-195)crates/settings/src/token.rs (2)
to_yaml_value(326-360)value(43-44)crates/settings/src/scenario.rs (2)
to_yaml_value(404-439)value(42-43)crates/settings/src/order.rs (1)
to_yaml_value(830-905)
crates/settings/src/order.rs (3)
crates/settings/src/yaml/mod.rs (4)
to_yaml_value(82-82)new(43-43)to_yaml_hash(84-95)to_yaml_hash(125-127)crates/settings/src/orderbook.rs (1)
to_yaml_value(202-238)crates/settings/src/yaml/orderbook.rs (1)
new(106-155)
crates/settings/src/yaml/orderbook.rs (1)
crates/settings/src/yaml/mod.rs (5)
to_yaml_string_missing_check(511-522)to_yaml_string_missing_check(563-563)to_yaml_hash(84-95)to_yaml_hash(125-127)get_yaml_string(49-62)
crates/settings/src/yaml/dotrain.rs (2)
crates/settings/src/yaml/orderbook.rs (2)
to_yaml_string(407-523)new(106-155)crates/settings/src/yaml/mod.rs (6)
new(43-43)to_yaml_string_missing_check(511-522)to_yaml_string_missing_check(563-563)to_yaml_hash(84-95)to_yaml_hash(125-127)get_yaml_string(49-62)
crates/settings/src/accounts.rs (4)
crates/settings/src/deployer.rs (1)
to_yaml_value(179-195)crates/settings/src/orderbook.rs (1)
to_yaml_value(202-238)crates/settings/src/token.rs (1)
to_yaml_value(326-360)crates/settings/src/yaml/mod.rs (1)
default_document(524-526)
crates/settings/src/gui.rs (1)
crates/settings/src/test.rs (2)
mock_network(9-19)mock_deployer(22-29)
crates/settings/src/network.rs (1)
crates/settings/src/token.rs (1)
to_yaml_value(326-360)
crates/settings/src/token.rs (4)
crates/settings/src/accounts.rs (1)
to_yaml_value(78-82)crates/settings/src/deployer.rs (1)
to_yaml_value(179-195)crates/settings/src/orderbook.rs (1)
to_yaml_value(202-238)crates/settings/src/network.rs (1)
to_yaml_value(260-300)
crates/settings/src/remote_networks.rs (8)
crates/settings/src/deployer.rs (1)
to_yaml_value(179-195)crates/settings/src/orderbook.rs (2)
to_yaml_value(202-238)test_to_yaml_hash_serializes_all_fields(941-1053)crates/settings/src/token.rs (1)
to_yaml_value(326-360)crates/settings/src/local_db_remotes.rs (1)
to_yaml_value(88-90)crates/settings/src/local_db_sync.rs (2)
to_yaml_value(139-172)test_to_yaml_hash_serializes_all_fields(505-613)crates/settings/src/metaboard.rs (1)
to_yaml_value(136-138)crates/settings/src/subgraph.rs (1)
to_yaml_value(144-146)crates/settings/src/gui.rs (2)
to_yaml_hash(892-915)to_yaml_hash(1030-1204)
crates/settings/src/remote_tokens.rs (1)
crates/settings/src/yaml/mod.rs (1)
default_document(524-526)
crates/settings/src/subgraph.rs (3)
crates/settings/src/local_db_remotes.rs (1)
to_yaml_value(88-90)crates/settings/src/metaboard.rs (1)
to_yaml_value(136-138)crates/settings/src/remote_networks.rs (1)
to_yaml_value(133-145)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (17)
- GitHub Check: test
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
- GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
- GitHub Check: git-clean
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
- GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
- GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
- GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
- GitHub Check: test
- GitHub Check: test
- GitHub Check: Deploy-Docs-Preview
- GitHub Check: build-tauri (ubuntu-22.04, true)
- GitHub Check: Deploy-Preview-Push
crates/settings/src/scenario.rs
Outdated
| fn to_yaml_value(&self) -> Result<StrictYaml, YamlError> { | ||
| let mut scenario_yaml = Hash::new(); | ||
|
|
||
| let bindings_yaml = self | ||
| .bindings | ||
| .iter() | ||
| .map(|(k, v)| (StrictYaml::String(k.clone()), StrictYaml::String(v.clone()))) | ||
| .collect(); | ||
| scenario_yaml.insert( | ||
| StrictYaml::String("bindings".to_string()), | ||
| StrictYaml::Hash(bindings_yaml), | ||
| ); | ||
|
|
||
| if let Some(runs) = self.runs { | ||
| scenario_yaml.insert( | ||
| StrictYaml::String("runs".to_string()), | ||
| StrictYaml::String(runs.to_string()), | ||
| ); | ||
| } | ||
|
|
||
| if let Some(blocks) = &self.blocks { | ||
| let blocks_yaml = serde_yaml::to_string(blocks) | ||
| .map_err(|err| YamlError::ParseError(err.to_string()))?; | ||
| scenario_yaml.insert( | ||
| StrictYaml::String("blocks".to_string()), | ||
| StrictYaml::String(blocks_yaml.trim().to_string()), | ||
| ); | ||
| } | ||
|
|
||
| scenario_yaml.insert( | ||
| StrictYaml::String("deployer".to_string()), | ||
| StrictYaml::String(self.deployer.key.clone()), | ||
| ); | ||
|
|
||
| Ok(StrictYaml::Hash(scenario_yaml)) | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick | 🔵 Trivial
ScenarioCfg::to_yaml_value correctly handles bindings and optionals
The serialization matches the parsing model: bindings go into a nested map, runs and blocks are emitted only when present (with blocks using the same serde representation the parser expects), and deployer is serialized by key. The test covers both presence and absence of the optional fields and asserts exact values, which is good.
If you want fully deterministic YAML output across runs, consider sorting self.bindings keys before collecting into the bindings hash, since HashMap iteration order is unspecified and might cause noisy diffs between runs.
- let bindings_yaml = self
- .bindings
- .iter()
- .map(|(k, v)| (StrictYaml::String(k.clone()), StrictYaml::String(v.clone())))
- .collect();
+ let mut bindings_entries: Vec<_> = self.bindings.iter().collect();
+ bindings_entries.sort_by(|(a, _), (b, _)| a.cmp(b));
+ let bindings_yaml = bindings_entries
+ .into_iter()
+ .map(|(k, v)| (StrictYaml::String(k.clone()), StrictYaml::String(v.clone())))
+ .collect();Also applies to: 795-897
🤖 Prompt for AI Agents
In crates/settings/src/scenario.rs around lines 404 to 439 (also applies to
795-897), the function builds the "bindings" StrictYaml.Hash from a HashMap
which yields non-deterministic key order; to make YAML output deterministic and
avoid noisy diffs, iterate over self.bindings in a sorted order (e.g., collect
keys, sort them, then map each key to its value) before creating the Hash for
insertion so the bindings map is emitted with stable key ordering.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't see this happening now. let's see if this is problem for us
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@findolor, sounds good! That's a reasonable approach—if the non-deterministic ordering causes issues in practice (like noisy diffs or unexpected behavior), you can revisit sorting at that time. For now, keeping it simple makes sense. 👍
🧠 Learnings used
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1983
File: crates/js_api/src/gui/mod.rs:964-1199
Timestamp: 2025-07-11T06:40:49.511Z
Learning: In crates/js_api/src/gui/mod.rs tests, findolor prefers to keep large hardcoded YAML strings (like the validation test YAML) inline in the test file rather than extracting them to separate external files for maintainability purposes.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/settings/src/yaml/orderbook.rs:371-377
Timestamp: 2025-06-17T16:21:24.384Z
Learning: In crates/settings/src/yaml/orderbook.rs tests, the user findolor considers RPC ordering in Vec<Url> assertions to be intentional and not a test brittleness issue. The ordering of RPCs in tests should be preserved as specified.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2116
File: crates/settings/src/orderbook.rs:569-0
Timestamp: 2025-09-01T13:35:33.688Z
Learning: In crates/settings/src/orderbook.rs, the deployment-block field is required in orderbook YAML configuration and should cause a parsing error when missing, not default to any value.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/settings/src/yaml/mod.rs:176-178
Timestamp: 2025-06-18T19:23:33.747Z
Learning: In crates/settings/src/yaml/mod.rs, the YamlError enum has two distinct error variants: `KeyNotFound(String)` for when a specific YAML key is not found in a hash/map, and `NotFound(String)` for when other types of entities (like networks, orderbooks, etc.) are not found in the configuration. These serve different purposes and should not be consolidated.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1897
File: crates/settings/src/yaml/orderbook.rs:311-311
Timestamp: 2025-05-27T10:19:38.011Z
Learning: The rainlanguage/rain.orderbook project uses strict YAML parsing (StrictYaml library), so concerns about inconsistent parsing between integer and string values in YAML (like `spec-version: 1` vs `spec-version: "1"`) are not relevant to this codebase.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1474
File: crates/js_api/src/yaml/mod.rs:31-34
Timestamp: 2025-03-31T13:57:59.660Z
Learning: The OrderbookYaml constructor in crates/js_api/src/yaml/mod.rs does not need early YAML validation. The author prefers to validate YAML only when it's actually used rather than during initialization.
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2270
File: crates/settings/src/local_db_remotes.rs:107-212
Timestamp: 2025-10-27T09:17:38.145Z
Learning: In the rain.orderbook codebase using strict_yaml_rust, all YAML keys are treated as strings, including numeric literals. Numeric keys like `123` are automatically coerced to strings and are valid, so they don't need error-case testing for non-string keys.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T22:14:22.646Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, I must consistently report the PR size after EVERY new commit in the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number" without any additional text or formatting blocks. The report must exclude lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock) and can be included either as part of the review or as a separate comment.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:26:31.566Z
Learning: For PR #1884 and future PRs in rainlanguage/rain.orderbook repository, provide PR size reports in a separate comment with ONLY the exact format "TOTAL=number\nADDITIONS=number\nDELETIONS=number", without any additional text or explanation. Reports should exclude irrelevant files such as lock files (package-lock.json, yarn.lock, pnpm-lock.yaml, cargo.lock).
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:24:53.708Z
Learning: For PR #1884 in rainlanguage/rain.orderbook, provide a separate comment after each review with PR size statistics in the format: `TOTAL=number ADDITIONS=number DELETIONS=number`, excluding lock files like package-lock.json and cargo.lock.
Learnt from: rouzwelt
Repo: rainlanguage/rain.orderbook PR: 0
File: :0-0
Timestamp: 2025-05-21T21:25:47.873Z
Learning: After each new commit review for rainlanguage/rain.orderbook repository, generate a PR size report in a separate comment with the format: "TOTAL=number ADDITIONS=number DELETIONS=number". This report should exclude irrelevant files such as lock files (e.g., package-lock.json, cargo.lock).
New UpdateInstead of going from configuration structs to strict yaml and to yaml string, we have introduced a new flow. We now sanitize the given yaml strings to make sure we don't have any extra fields in our yaml. This means when we try to convert all the documents into a yaml string, we don't have to recreate the strict yaml hash structure and we can just dump what is in our documents |
Chained PR
Motivation
See issues:
When we take additional YAML settings during the GUI construction (#2119) we also need to think about the hash logic for the serialization and deserialization.
Normally we were using the dotrain hash directly but with these additional settings we have to include them in the hash. that is why we need the
to_yaml_stringfunctions in order to make everything work properly.Also it's nice to be able to go from the yaml objects into yaml strings when we need to.
Solution
Checks
By submitting this for review, I'm confirming I've done the following:
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.