Skip to content

Conversation

@findolor
Copy link
Collaborator

@findolor findolor commented Nov 27, 2025

Motivation

See issues:

In the previous implementation, the context needed to be manually added to YAML parsing functions. If not careful, this could have led to missing contexts and in return incorrect parsing.

This PR aims to improve the context management by defining profiles for different kind of environments where we can specify context based on that environment. Meaning if we are using the parsing functions inside our GUI SDK, we could use the GUI profile to properly inject context.

Solution

  • Introduce context profiles that can enable different context injections
  • Refactor yaml parsing implementations to work with a default profile
  • Update YAML parsing implementation constructors to take in profile if needed
  • Update GUI SDK logic to use GUI profile during parsing operations
  • Add and update tests

Checks

By submitting this for review, I'm confirming I've done the following:

  • made this PR as small as possible
  • unit-tested any new functionality
  • linked any relevant issues or PRs
  • included screenshots (if this involves a front-end change)

fix #1940

Summary by CodeRabbit

  • New Features

    • Profile-aware configuration added (Strict / Gui) persisted in YAML; GUI and tools use it to build context-aware behavior and respect the selected deployment.
  • Bug Fixes

    • Improved YAML error reporting to show more accurate missing-field locations for invalid YAML.
  • Tests

    • Updated GUI tests and serialized-state expectations (including vault IDs and serialized state) to match profile/context changes.

✏️ Tip: You can customize this high-level summary in your review settings.

@findolor findolor requested review from 0xgleb and hardyjosh November 27, 2025 11:57
@findolor findolor self-assigned this Nov 27, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 27, 2025

Walkthrough

Threads a new ContextProfile through YAML types and order creation: adds profile-aware constructors (new_with_profile / create_with_profile), updates JS GUI/state paths to use GUI profiles, and adjusts YAML (de)serialization and tests to reflect profile-aware behavior and changed error expectations.

Changes

Cohort / File(s) Summary
ContextProfile definition
crates/settings/src/yaml/context.rs
New public ContextProfile enum (Strict, Gui { current_deployment: String }) with serde/wasm wiring, strict/gui constructors, Default impl, and a unit test.
DotrainYaml profile integration
crates/settings/src/yaml/dotrain.rs
Added profile: ContextProfile field; new_with_profile() / with_profile() / build_context() APIs; (de)serialization updated to include profile (map form) with legacy sequence fallback; public getters now use build_context(self.profile).
OrderbookYaml profile integration
crates/settings/src/yaml/orderbook.rs
Added profile: ContextProfile; new_with_profile() / with_profile() / build_context(); (de)serialization updated to carry profile with legacy fallback; context construction switched to build_context.
DotrainOrder profile support
crates/common/src/dotrain_order.rs
Added pub async fn create_with_profile(..., profile: ContextProfile) and refactored create() to delegate to it (defaults to Strict); uses DotrainYaml::new_with_profile.
JS GUI initialization & state
crates/js_api/src/gui/mod.rs, crates/js_api/src/gui/state_management.rs
GUI flows extract frontmatter, construct DotrainYaml with a ContextProfile::gui(...), validate deployment via that YAML, and call DotrainOrder::create_with_profile; state restoration uses profile-aware creation; helper get_yaml_documents adjusted.
Settings module surface
crates/settings/src/yaml/mod.rs
Imported ContextProfile; changed ContextProvider::expand_context_with_current_deployment to take deployment: &str (required) and always add it.
CLI and JS tests / expectations
crates/cli/src/commands/order/calldata.rs, packages/orderbook/test/js_api/gui.test.ts
Updated YAML parsing test expectation (changed reported missing-field/location) and updated JS GUI test serialized-state string and expected vault IDs.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant GUI as JS GUI
    participant FM as Frontmatter extractor
    participant DY as DotrainYaml
    participant CTX as Context (build_context)
    participant DO as DotrainOrder

    GUI->>FM: extract frontmatter from dotrain content
    FM->>DY: DotrainYaml::new_with_profile(sources, validate, ContextProfile::gui(...))
    DY->>CTX: build_context(profile)
    CTX-->>DY: Context (orders/deployments expanded per profile)
    DY->>DO: DotrainOrder::create_with_profile(dotrain, settings, profile)
    DO-->>GUI: initialized DotrainOrder (profile-aware)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Focus review on:
    • (De)serialization changes in crates/settings/src/yaml/dotrain.rs and crates/settings/src/yaml/orderbook.rs (map vs sequence fallback).
    • build_context() correctness and profile propagation across conversions (from_documents, from_orderbook_yaml, from_dotrain_yaml).
    • DotrainOrder::create_with_profile usage and defaulting behavior in existing call sites.
    • JS GUI changes: frontmatter extraction, deployment validation, and correct ContextProfile::gui propagation.
    • Updated tests reflecting changed YAML error reporting and GUI serialized state/vault IDs.

Possibly related PRs

Suggested labels

rust, test

Suggested reviewers

  • 0xgleb
  • hardyjosh

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Refactor context logic for YAML parsing' accurately reflects the main objective of the PR, which is to refactor the context injection architecture for YAML parsing by introducing context profiles and updating parsing implementations.
Linked Issues check ✅ Passed The PR successfully addresses issue #1940 by introducing context profiles (ContextProfile enum) and refactoring YAML parsing to support first-class context handling through new_with_profile constructors and build_context methods across DotrainYaml, OrderbookYaml, and related infrastructure.
Out of Scope Changes check ✅ Passed All changes are within scope of the refactoring objective. The PR introduces ContextProfile, updates YAML parsing constructors, modifies GUI SDK logic, and updates test expectations—all directly supporting the context injection refactoring goal without introducing unrelated functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch yaml-context-improvement

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37b521d and e74f6dc.

📒 Files selected for processing (1)
  • crates/settings/src/yaml/orderbook.rs (12 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

crates/**/*.rs: For Rust crates in crates/*, run lints using nix develop -c cargo clippy --workspace --all-targets --all-features -D warnings
For Rust crates in crates/*, run tests using nix develop -c cargo test --workspace or --package <crate>

Files:

  • crates/settings/src/yaml/orderbook.rs
**/crates/**

📄 CodeRabbit inference engine (AGENTS.md)

Rust workspace organized as crates/* with subdirectories: cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests

Files:

  • crates/settings/src/yaml/orderbook.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Rust: format code with nix develop -c cargo fmt --all
Rust: lint with nix develop -c rainix-rs-static (preconfigured flags included)
Rust: crates and modules use snake_case; types use PascalCase

Files:

  • crates/settings/src/yaml/orderbook.rs
🧠 Learnings (21)
📓 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.
📚 Learning: 2025-11-25T14:56:29.762Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2334
File: crates/settings/src/yaml/orderbook.rs:18-18
Timestamp: 2025-11-25T14:56:29.762Z
Learning: In crates/settings/src/yaml/orderbook.rs, the `accounts` section is optional in orderbook YAML. The `AccountCfg::parse_all_from_yaml` method returns an empty HashMap when the `accounts` section is missing rather than throwing a Field(Missing(...)) error, so it doesn't need to be wrapped with `to_yaml_string_missing_check` in the `to_yaml_string` method.

Applied to files:

  • crates/settings/src/yaml/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/yaml/orderbook.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/yaml/orderbook.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/yaml/orderbook.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/yaml/orderbook.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/yaml/orderbook.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/yaml/orderbook.rs
📚 Learning: 2025-07-21T16:32:19.576Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/add_order.rs:297-300
Timestamp: 2025-07-21T16:32:19.576Z
Learning: User 0xgleb prefers explicit destructuring patterns like `let (_, Address(FixedBytes(address))) = ...` over intermediate variables when extracting nested data structures, as they believe it makes clearer what is being unwrapped from complex types.

Applied to files:

  • crates/settings/src/yaml/orderbook.rs
📚 Learning: 2025-04-07T09:53:18.442Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1483
File: crates/settings/src/yaml/orderbook.rs:62-67
Timestamp: 2025-04-07T09:53:18.442Z
Learning: The OrderbookYaml design intentionally creates a fresh Cache in the from_documents method to isolate each instance's cache data. This isolation is a deliberate architectural choice.

Applied to files:

  • crates/settings/src/yaml/orderbook.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/yaml/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/yaml/orderbook.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/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/yaml/orderbook.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/yaml/orderbook.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/yaml/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/orderbook.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/yaml/orderbook.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/yaml/orderbook.rs
📚 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/yaml/orderbook.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/yaml/orderbook.rs
⏰ 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). (18)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
  • GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-browser-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
  • GitHub Check: test
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: Deploy-Preview-Push
  • GitHub Check: Deploy-Docs-Preview
  • GitHub Check: build-tauri (ubuntu-22.04, true)
🔇 Additional comments (8)
crates/settings/src/yaml/orderbook.rs (8)

10-11: LGTM: Necessary imports for custom serialization.

The additional serde imports support the custom Serialize and Deserialize implementations that handle the profile field.


27-27: LGTM: Profile field added for context management.

The addition of the profile field enables environment-specific context injection as outlined in the PR objectives. This is a public API change, but it's intentional and necessary for the refactoring.


154-178: LGTM: Profile initialization maintains backward compatibility.

All constructors properly initialize the profile field:

  • Default constructors (new, from_documents) use ContextProfile::Strict for backward compatibility
  • Copy constructors (from_orderbook_yaml, from_dotrain_yaml) preserve the profile from the source instance

194-207: LGTM: Well-designed profile configuration methods.

  • new_with_profile: Properly delegates to Self::new() for validation before setting the profile
  • with_profile: Follows standard Rust builder pattern for fluent configuration

209-214: LGTM: Centralized context building logic.

The build_context method consolidates context creation and expansion logic that was previously duplicated across all get_* methods. Note that while the profile field is not directly used in this method, it's part of the struct and may be used by create_context() or other components in the architecture.


449-533: LGTM: Robust deserialization with backward compatibility.

The custom deserialization implementation correctly handles:

  • New format (visit_map): Struct with "documents" and "profile" fields
  • Legacy format (visit_seq): Array of document strings defaulting to ContextProfile::Strict

The implementation properly validates empty documents and missing required fields. While complex, this complexity is justified to maintain backward compatibility during the migration.


542-590: LGTM: Comprehensive test coverage for profile functionality.

The three new tests effectively cover:

  • Profile configuration methods (new_with_profile, with_profile)
  • Serialization/deserialization round-trip with profile preservation
  • Legacy format deserialization with proper default profile

431-447: Remove serialization format compatibility concern—backward compatibility is properly implemented.

The serialization format change from a sequence to a struct with documents and profile fields is intentionally designed with dual deserialization support. The Deserialize implementation includes both visit_seq (for legacy sequence format) and visit_map (for new struct format), using deserialize_any to handle both automatically. The profile field defaults to ContextProfile::Strict when deserializing old format data. This design is explicitly tested in test_orderbook_yaml_legacy_sequence_deserialization_defaults_profile, confirming that old serialized data deserializes correctly with appropriate defaults.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/js_api/src/gui/mod.rs (1)

15-19: GUI now correctly initializes via a GUI-specific context profile

The updated new_with_deployment and get_yaml_documents flows:

  • Use RainDocument::get_front_matter + DotrainYaml::new to operate only on YAML frontmatter.
  • Validate the deployment key via GuiCfg::parse_deployment_keys.
  • Derive order_key with DeploymentCfg::parse_order_key.
  • Create the underlying DotrainOrder with DotrainOrder::create_with_profile(..., ContextProfile::gui(Some(order_key), Some(selected_deployment.clone()))).

This cleanly hooks the GUI into the profile-aware YAML/context pipeline and avoids treating the Rainlang body as YAML. Only tiny nits are the unnecessary clone()s on dotrain and frontmatter, but they’re harmless on this path.

Also applies to: 169-189, 614-619

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8d10e18 and d805ce5.

📒 Files selected for processing (9)
  • crates/cli/src/commands/order/calldata.rs (1 hunks)
  • crates/common/src/dotrain_order.rs (3 hunks)
  • crates/js_api/src/gui/mod.rs (2 hunks)
  • crates/js_api/src/gui/state_management.rs (1 hunks)
  • crates/settings/src/yaml/context.rs (2 hunks)
  • crates/settings/src/yaml/dotrain.rs (7 hunks)
  • crates/settings/src/yaml/mod.rs (1 hunks)
  • crates/settings/src/yaml/orderbook.rs (9 hunks)
  • packages/orderbook/test/js_api/gui.test.ts (2 hunks)
🧰 Additional context used
📓 Path-based instructions (7)
crates/**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

crates/**/*.rs: For Rust crates in crates/*, run lints using nix develop -c cargo clippy --workspace --all-targets --all-features -D warnings
For Rust crates in crates/*, run tests using nix develop -c cargo test --workspace or --package <crate>

Files:

  • crates/js_api/src/gui/state_management.rs
  • crates/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/context.rs
  • crates/settings/src/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/dotrain.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/common/src/dotrain_order.rs
**/crates/**

📄 CodeRabbit inference engine (AGENTS.md)

Rust workspace organized as crates/* with subdirectories: cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests

Files:

  • crates/js_api/src/gui/state_management.rs
  • crates/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/context.rs
  • crates/settings/src/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/dotrain.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/common/src/dotrain_order.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Rust: format code with nix develop -c cargo fmt --all
Rust: lint with nix develop -c rainix-rs-static (preconfigured flags included)
Rust: crates and modules use snake_case; types use PascalCase

Files:

  • crates/js_api/src/gui/state_management.rs
  • crates/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/context.rs
  • crates/settings/src/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/dotrain.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/common/src/dotrain_order.rs
packages/orderbook/**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

packages/orderbook/**/*.{ts,tsx,js,jsx}: For Orderbook TypeScript (packages/orderbook), run lints using nix develop -c npm run check -w @rainlanguage/orderbook
For Orderbook TypeScript (packages/orderbook), run tests using nix develop -c npm run test -w @rainlanguage/orderbook

Files:

  • packages/orderbook/test/js_api/gui.test.ts
packages/**/*.{js,ts,svelte}

📄 CodeRabbit inference engine (AGENTS.md)

JavaScript/Svelte organized as packages/* including webapp, ui-components, and orderbook (wasm wrapper published to npm)

Files:

  • packages/orderbook/test/js_api/gui.test.ts
**/*.{ts,tsx,svelte}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,svelte}: TypeScript/Svelte: format with nix develop -c npm run format
TypeScript/Svelte: lint with nix develop -c npm run lint
TypeScript/Svelte: type-check with nix develop -c npm run check

Files:

  • packages/orderbook/test/js_api/gui.test.ts
**/*.{test,spec}.ts

📄 CodeRabbit inference engine (AGENTS.md)

TypeScript/Svelte: run tests with nix develop -c npm run test (Vitest). Name test files *.test.ts or *.spec.ts

Files:

  • packages/orderbook/test/js_api/gui.test.ts
🧠 Learnings (55)
📓 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.
📚 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/js_api/src/gui/state_management.rs
  • crates/cli/src/commands/order/calldata.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/js_api/src/gui/state_management.rs
📚 Learning: 2025-09-24T10:59:25.666Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/js_api/src/gui/state_management.rs:196-203
Timestamp: 2025-09-24T10:59:25.666Z
Learning: In crates/js_api/src/gui/state_management.rs, the RainMetaDocumentV1Item::hash(false) method returns a slice, so wrapping the result with FixedBytes() is necessary to convert it to the expected FixedBytes type for DotrainGuiStateV1.dotrain_hash field.

Applied to files:

  • crates/js_api/src/gui/state_management.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/js_api/src/gui/state_management.rs
  • crates/common/src/dotrain_order.rs
📚 Learning: 2025-04-02T08:11:19.742Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1566
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/+page.svelte:26-31
Timestamp: 2025-04-02T08:11:19.742Z
Learning: In the Rain Orderbook deployment page component, the conditional check `if (dotrain && deployment)` inside `onMount` is necessary to prevent GUI initialization with null values, even though there's already a redirect logic outside the function and conditional rendering for the UI message. These serve different purposes in the component's error handling strategy.

Applied to files:

  • crates/js_api/src/gui/state_management.rs
  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-06-11T11:39:15.239Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1917
File: tauri-app/src/routes/orders/add/+page.svelte:45-47
Timestamp: 2025-06-11T11:39:15.239Z
Learning: In the rain.orderbook codebase, every instance of `Config` (returned by helpers such as `parseDotrainAndYaml`) is guaranteed to include the `dotrainOrder` property; it is never `undefined`.

Applied to files:

  • crates/js_api/src/gui/state_management.rs
  • crates/common/src/dotrain_order.rs
📚 Learning: 2025-03-26T16:22:50.224Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1515
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/layout.test.ts:0-0
Timestamp: 2025-03-26T16:22:50.224Z
Learning: In the Rain Orderbook project, the DotrainOrderGui.getDeploymentDetail method resolves promises with objects that may contain either a value property or an error property, rather than rejecting promises on errors.

Applied to files:

  • crates/js_api/src/gui/state_management.rs
  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-06-17T16:46:19.035Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1903
File: crates/cli/src/commands/order/calldata.rs:47-57
Timestamp: 2025-06-17T16:46:19.035Z
Learning: In the CLI command `crates/cli/src/commands/order/calldata.rs`, the user prefers to let lower-level errors from `try_into_call()` bubble up when the RPCs list is empty, rather than adding early validation checks with custom error messages.

Applied to files:

  • crates/cli/src/commands/order/calldata.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/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/common/src/dotrain_order.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/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/context.rs
  • crates/settings/src/yaml/dotrain.rs
  • crates/settings/src/yaml/orderbook.rs
📚 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/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/context.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/dotrain.rs
  • crates/settings/src/yaml/orderbook.rs
📚 Learning: 2025-11-25T14:56:29.762Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2334
File: crates/settings/src/yaml/orderbook.rs:18-18
Timestamp: 2025-11-25T14:56:29.762Z
Learning: In crates/settings/src/yaml/orderbook.rs, the `accounts` section is optional in orderbook YAML. The `AccountCfg::parse_all_from_yaml` method returns an empty HashMap when the `accounts` section is missing rather than throwing a Field(Missing(...)) error, so it doesn't need to be wrapped with `to_yaml_string_missing_check` in the `to_yaml_string` method.

Applied to files:

  • crates/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/orderbook.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/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/orderbook.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/cli/src/commands/order/calldata.rs
  • crates/settings/src/yaml/dotrain.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/common/src/dotrain_order.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/yaml/context.rs
📚 Learning: 2025-03-28T10:09:10.696Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1463
File: crates/settings/src/yaml/context.rs:298-304
Timestamp: 2025-03-28T10:09:10.696Z
Learning: In the `resolve_token_path` method of the Context implementation in `crates/settings/src/yaml/context.rs`, when an unknown property is accessed on a token, it returns a `ContextError::InvalidPath` error, not a `ContextError::PropertyNotFound` error.

Applied to files:

  • crates/settings/src/yaml/mod.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
  • crates/settings/src/yaml/orderbook.rs
📚 Learning: 2025-04-07T09:53:18.442Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1483
File: crates/settings/src/yaml/orderbook.rs:62-67
Timestamp: 2025-04-07T09:53:18.442Z
Learning: The OrderbookYaml design intentionally creates a fresh Cache in the from_documents method to isolate each instance's cache data. This isolation is a deliberate architectural choice.

Applied to files:

  • crates/settings/src/yaml/dotrain.rs
  • crates/settings/src/yaml/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/yaml/dotrain.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/common/src/dotrain_order.rs
📚 Learning: 2025-11-25T16:50:31.752Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T16:50:31.752Z
Learning: Applies to crates/integration_tests/**/*.rs : Rust: write tests using `cargo test`; integration tests live in `crates/integration_tests`. Prefer `insta` snapshots and `proptest` where helpful

Applied to files:

  • crates/settings/src/yaml/dotrain.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/yaml/dotrain.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/yaml/dotrain.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/yaml/dotrain.rs
  • crates/settings/src/yaml/orderbook.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/yaml/dotrain.rs
  • crates/settings/src/yaml/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/yaml/dotrain.rs
  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-04-29T11:17:46.178Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1687
File: crates/js_api/src/gui/order_operations.rs:470-489
Timestamp: 2025-04-29T11:17:46.178Z
Learning: In the `get_deployment_transaction_args` method of `DotrainOrderGui`, approvals are intentionally only checked against output tokens as per the design requirements.

Applied to files:

  • crates/settings/src/yaml/dotrain.rs
  • packages/orderbook/test/js_api/gui.test.ts
📚 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/yaml/orderbook.rs
  • crates/common/src/dotrain_order.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/yaml/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/yaml/orderbook.rs
  • crates/common/src/dotrain_order.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/yaml/orderbook.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/yaml/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/orderbook.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/yaml/orderbook.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/yaml/orderbook.rs
  • crates/common/src/dotrain_order.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/yaml/orderbook.rs
  • crates/common/src/dotrain_order.rs
📚 Learning: 2025-06-04T10:21:01.388Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1907
File: packages/orderbook/test/common/test.test.ts:75-77
Timestamp: 2025-06-04T10:21:01.388Z
Learning: The DotrainOrder.create API in packages/orderbook/test/common/test.test.ts is internal and not used directly in consumer applications, so API changes here don't require external breaking change documentation.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-09-02T08:04:44.814Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2117
File: packages/ui-components/src/__tests__/VaultIdInformation.test.ts:9-13
Timestamp: 2025-09-02T08:04:44.814Z
Learning: In packages/ui-components/src/__tests__/VaultIdInformation.test.ts and similar test files in the rain.orderbook project, the passthrough vi.mock('rainlanguage/orderbook', async (importOriginal) => { return { ...(await importOriginal()) }; }); block is required for tests to run properly, even when not overriding any exports. This is needed due to the specific Vitest configuration or test environment setup in the project.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-03-31T10:16:53.544Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1469
File: packages/ui-components/src/__tests__/CodeMirrorDotrain.test.ts:75-98
Timestamp: 2025-03-31T10:16:53.544Z
Learning: In the rainlanguage/rain.orderbook project, direct manipulation of Svelte's internal state (component.$$.ctx) in tests is an acceptable approach for testing component behavior, as demonstrated in the CodeMirrorDotrain tests.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-04-04T11:25:21.518Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1559
File: packages/ui-components/src/__tests__/OrderOrVaultHash.test.ts:94-94
Timestamp: 2025-04-04T11:25:21.518Z
Learning: In the rain.orderbook project, minimal test fixtures are preferred over complete mocks that implement the entire interface. Type casting (e.g., `as unknown as SgVault`) is an acceptable approach to maintain both minimal fixtures and TypeScript type compatibility.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-07-04T09:14:35.748Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1956
File: packages/ui-components/src/__tests__/VaultDetail.test.ts:177-181
Timestamp: 2025-07-04T09:14:35.748Z
Learning: In the rain.orderbook project, maintainer findolor is fine with mutating mock data directly in test files using ts-expect-error comments, preferring this pragmatic approach over immutable patterns like spread operators for test data updates.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-08-15T20:56:15.592Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 1978
File: packages/webapp/src/routes/deploy/[orderName]/[deploymentKey]/fullDeployment.test.ts:22-29
Timestamp: 2025-08-15T20:56:15.592Z
Learning: In packages/webapp/src/routes/deploy/[orderName]/[deploymentKey]/fullDeployment.test.ts, brusherru prefers fail-fast testing approaches where type mismatches cause immediate test failures to alert developers about interface changes, rather than using defensive programming with type guards that might mask API evolution.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-11-25T16:50:11.197Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T16:50:11.197Z
Learning: Applies to packages/orderbook/**/*.{ts,tsx,js,jsx} : For Orderbook TypeScript (`packages/orderbook`), run tests using `nix develop -c npm run test -w rainlanguage/orderbook`

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-07-09T14:00:09.618Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1975
File: packages/orderbook/test/js_api/gui.test.ts:958-960
Timestamp: 2025-07-09T14:00:09.618Z
Learning: In test files for the rain.orderbook project, maintainer findolor prefers to keep hard-coded serialized state strings (like gzip/base64 blobs) rather than replacing them with semantic assertions or round-trip testing, even when the hard-coded approach may be more brittle to changes.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-05-03T10:29:04.009Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1724
File: packages/ui-components/src/__tests__/ButtonDarkMode.test.ts:1-54
Timestamp: 2025-05-03T10:29:04.009Z
Learning: JSDoc comments are not considered necessary for test files in the rainlanguage/rain.orderbook repository. Test descriptions and assertions are sufficient documentation.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-07-09T12:35:45.699Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1974
File: packages/ui-components/src/__tests__/DeploymentSteps.test.ts:123-126
Timestamp: 2025-07-09T12:35:45.699Z
Learning: In packages/ui-components/src/__tests__/DeploymentSteps.test.ts, findolor prefers to keep mock initializations (like setSelectToken) in individual test cases rather than consolidating them into shared beforeEach blocks, even when it results in duplication.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-07-11T08:46:07.606Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1925
File: packages/ui-components/src/__tests__/DeploymentSteps.test.ts:519-554
Timestamp: 2025-07-11T08:46:07.606Z
Learning: In packages/ui-components/src/__tests__/DeploymentSteps.test.ts, findolor prefers to keep hardcoded timeout values (like 50ms and 100ms) inline in test cases rather than extracting them to named constants, viewing such refactoring as unnecessary for test maintainability.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-07-09T14:00:12.206Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1975
File: crates/js_api/src/gui/state_management.rs:412-412
Timestamp: 2025-07-09T14:00:12.206Z
Learning: In crates/js_api/src/gui/state_management.rs tests, findolor prefers to keep hard-coded serialized state constants (like SERIALIZED_STATE) rather than dynamically generating them, even when it may make tests more brittle to maintain.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 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:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-07-17T10:35:53.182Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1996
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/fullDeployment.test.ts:172-172
Timestamp: 2025-07-17T10:35:53.182Z
Learning: In packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/fullDeployment.test.ts, findolor is comfortable with hardcoded 2-second delays using setTimeout after token selection elements appear, preferring this approach over deterministic waiting patterns with waitFor.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-07-17T10:35:09.329Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1996
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/fullDeployment.test.ts:303-303
Timestamp: 2025-07-17T10:35:09.329Z
Learning: In packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/fullDeployment.test.ts, findolor is fine with hardcoded 2-second delays using setTimeout in test cases for waiting after token selection, preferring this approach over deterministic waiting patterns.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 Learning: 2025-06-06T16:39:13.240Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1913
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/fullDeployment.test.ts:170-171
Timestamp: 2025-06-06T16:39:13.240Z
Learning: In test files for packages/webapp, the user prefers not to add explicit error checking for factory method calls like DotrainOrderGui.chooseDeployment() when there's already higher-level error handling with try-catch blocks, as errors would be visible anyway and detailed error handling within test helper functions is not of interest.

Applied to files:

  • packages/orderbook/test/js_api/gui.test.ts
📚 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/common/src/dotrain_order.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/common/src/dotrain_order.rs
🧬 Code graph analysis (5)
crates/js_api/src/gui/state_management.rs (5)
crates/common/src/dotrain_order.rs (3)
  • dotrain (374-376)
  • dotrain_yaml (494-496)
  • create_with_profile (303-354)
crates/settings/src/yaml/dotrain.rs (1)
  • new (86-115)
crates/common/src/fuzz/impls.rs (2)
  • new (124-156)
  • new (161-169)
crates/settings/src/deployment.rs (1)
  • parse_order_key (30-57)
crates/settings/src/yaml/context.rs (1)
  • gui (26-31)
crates/js_api/src/gui/mod.rs (6)
crates/common/src/dotrain_order.rs (3)
  • dotrain (374-376)
  • dotrain_yaml (494-496)
  • create_with_profile (303-354)
crates/settings/src/yaml/dotrain.rs (1)
  • new (86-115)
crates/common/src/fuzz/impls.rs (2)
  • new (124-156)
  • new (161-169)
crates/settings/src/deployment.rs (2)
  • default (149-156)
  • parse_order_key (30-57)
crates/settings/src/gui.rs (1)
  • parse_deployment_keys (356-391)
crates/settings/src/yaml/context.rs (1)
  • gui (26-31)
crates/settings/src/yaml/dotrain.rs (2)
crates/settings/src/yaml/orderbook.rs (6)
  • from_documents (158-164)
  • from_dotrain_yaml (174-180)
  • new_with_profile (194-202)
  • new (106-156)
  • with_profile (204-207)
  • build_context (209-220)
crates/settings/src/yaml/context.rs (5)
  • default (35-37)
  • new (227-234)
  • order (88-88)
  • order (120-122)
  • gui (26-31)
crates/settings/src/yaml/orderbook.rs (1)
crates/settings/src/yaml/dotrain.rs (7)
  • from_documents (117-123)
  • from_orderbook_yaml (133-139)
  • from_dotrain_yaml (125-131)
  • new_with_profile (153-161)
  • new (86-115)
  • with_profile (163-166)
  • build_context (168-209)
crates/common/src/dotrain_order.rs (1)
crates/settings/src/yaml/orderbook.rs (1)
  • new_with_profile (194-202)
⏰ 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). (15)
  • GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
  • GitHub Check: test
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-artifacts)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-artifacts, true)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-static)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, ob-rs-test, true)
  • GitHub Check: test
  • GitHub Check: git-clean
  • GitHub Check: test
  • GitHub Check: build-tauri (ubuntu-22.04, true)
🔇 Additional comments (16)
crates/cli/src/commands/order/calldata.rs (1)

382-385: Updated YAML error expectation is consistent with new missing-field semantics

For an invalid dotrain file that lacks the required deployments section at the root, expecting YamlError::Field { kind: FieldErrorKind::Missing("deployments"), location: "root" } matches the stricter, field-based validation and makes the failure mode clearer and more precise than a missing-deployment-key error.

packages/orderbook/test/js_api/gui.test.ts (1)

970-972: State fixture and vault‑id expectations look consistent with new behavior

The updated serializedState blob and the expected vaultId values (0x29a / 0x14d) match the setup in the beforeAll (vault IDs 666 and 333) and the new profile‑aware serialization. No issues spotted; just ensure this blob was regenerated from the current serializeState() implementation.

Also applies to: 1039-1040

crates/settings/src/yaml/context.rs (2)

8-38: Well-structured ContextProfile enum with sensible defaults.

The implementation follows existing patterns in the codebase with proper WASM support, serde configuration, and a Default implementation that returns Strict for backward compatibility.


347-363: Test coverage is adequate.

The test covers the essential cases for the helper constructors and default behavior.

crates/settings/src/yaml/orderbook.rs (5)

209-220: build_context treats Strict and Gui identically — verify this is intentional.

Unlike DotrainYaml::build_context (which adds GUI-specific context like current_order, current_deployment, and select_tokens for the Gui profile), OrderbookYaml::build_context performs the same operations for both profiles. This appears intentional since OrderbookYaml doesn't handle orders/deployments/GUI config, but please confirm this design choice.


194-207: Profile helper methods are consistent with DotrainYaml.

The new_with_profile and with_profile methods follow the same pattern as their counterparts in DotrainYaml, maintaining API consistency.


158-180: Profile propagation in from_* methods is correct.

  • from_documents defaults to Strict (appropriate for fresh documents)
  • from_orderbook_yaml preserves the source profile
  • from_dotrain_yaml preserves the source profile

481-485: Deserialization correctly defaults profile to Strict.

This is appropriate since the profile is a runtime context concern, not a persisted value.


500-519: Test coverage for profile helpers is adequate.

The test verifies new_with_profile, default behavior, and the with_profile fluent setter.

crates/settings/src/yaml/dotrain.rs (7)

133-139: from_orderbook_yaml sets profile to Strict instead of preserving orderbook_yaml.profile.

In contrast to from_dotrain_yaml which preserves the source profile, from_orderbook_yaml hardcodes Strict. This differs from OrderbookYaml::from_dotrain_yaml which preserves the profile. Is this asymmetry intentional?

 fn from_orderbook_yaml(orderbook_yaml: OrderbookYaml) -> Self {
     DotrainYaml {
         documents: orderbook_yaml.documents,
         cache: orderbook_yaml.cache,
-        profile: ContextProfile::Strict,
+        profile: orderbook_yaml.profile,
     }
 }

168-209: build_context implementation is thorough for GUI profile handling.

The method correctly:

  1. Sets GUI context fields (current_order, current_deployment)
  2. Expands remote networks/tokens
  3. Parses select_tokens when deployment is present
  4. Parses the order into context when order key is present

The Result return type is appropriate since parsing operations can fail.


223-233: get_order_for_gui_deployment correctly creates a custom GUI context.

This method appropriately creates a ContextProfile::gui with both order and deployment keys, enabling proper interpolation for GUI-specific order retrieval.


259-262: get_gui creates context with None for current_order.

This is appropriate since get_gui is retrieving GUI configuration, not a specific order. The deployment context is passed through for select_tokens resolution.


818-911: Comprehensive test coverage for build_context profiles.

The test verifies:

  • Strict profile expands remote networks/tokens without GUI context
  • GUI profile sets current_order, current_deployment, and parses order into context
  • Profile propagation through from_dotrain_yaml

913-967: Test demonstrates profile-dependent parsing behavior.

This test effectively shows that:

  • Strict profile fails when tokens are undefined (required validation)
  • Gui profile allows orders with select-tokens to have None token references

This is valuable for understanding the behavioral difference between profiles.


335-344: Test imports correctly updated for new profile functionality.

Comment on lines 12 to 15
use rain_orderbook_app_settings::yaml::{
dotrain::DotrainYaml, orderbook::OrderbookYaml, YamlError, YamlParsable,
context::ContextProfile, dotrain::DotrainYaml, orderbook::OrderbookYaml, YamlError,
YamlParsable,
};
Copy link
Contributor

@coderabbitai coderabbitai bot Nov 27, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Expose create_with_profile cleanly, but drop unused YamlParsable import

The refactor that makes create delegate to create_with_profile(..., ContextProfile::Strict) and routes dotrain parsing through DotrainYaml::new_with_profile looks correct and preserves existing behavior while enabling profile-specific flows (e.g. GUI).

One small fix: YamlParsable is imported but never used in this file, which will raise an unused import warning and can fail CI.

-use rain_orderbook_app_settings::yaml::{
-    context::ContextProfile, dotrain::DotrainYaml, orderbook::OrderbookYaml, YamlError,
-    YamlParsable,
-};
+use rain_orderbook_app_settings::yaml::{
+    context::ContextProfile, dotrain::DotrainYaml, orderbook::OrderbookYaml, YamlError,
+};

Also applies to: 289-354

🤖 Prompt for AI Agents
In crates/common/src/dotrain_order.rs around lines 12 to 15 (and also apply the
same change for lines 289 to 354), remove the unused import YamlParsable from
the use statement; ensure create delegates to
create_with_profile(ContextProfile::Strict) and uses
DotrainYaml::new_with_profile as already refactored, then update the use list to
only include ContextProfile, DotrainYaml, OrderbookYaml, and YamlError so there
are no unused-import warnings.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i don't see any warnings from clippy about an unused import

Copy link
Contributor

Choose a reason for hiding this comment

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

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Search for any usage of YamlParsable in the dotrain_order.rs file
echo "=== Searching for YamlParsable usage in dotrain_order.rs ==="
rg -n 'YamlParsable' crates/common/src/dotrain_order.rs

echo -e "\n=== Checking if YamlParsable is a trait bound or used in any way ==="
# Look for patterns where YamlParsable might be used as a trait bound
rg -n -C2 'YamlParsable|impl.*YamlParsable|where.*YamlParsable|dyn.*YamlParsable' crates/common/src/dotrain_order.rs

echo -e "\n=== Running clippy on the specific file to check for warnings ==="
cd crates/common && cargo clippy --message-format=short 2>&1 | grep -i "unused\|YamlParsable" || echo "No unused import warnings found for YamlParsable"

Length of output: 467


@findolor You're absolutely right—my apologies for the false positive! I've confirmed that clippy produces no warnings about the YamlParsable import. While it doesn't appear to be explicitly used in the visible code, if clippy is satisfied, there's no issue here. The import can stay as is.

Thank you for checking and correcting this! 🐰

(\__/)
(•ᴗ•)
/>📋 Verified!

🧬 Code Graph Analysis Results

[crates/common/src/rainlang.rs:8-24]

pub fn compose_to_rainlang(
    dotrain: String,
    bindings: HashMap<String, String>,
    entrypoints: &[&str],
) -> Result<String, ComposeError> {
    let meta_store = LANG_SERVICES.meta_store();

    let rebinds = (!bindings.is_empty()).then_some(
        bindings
            .iter()
            .map(|(k, v)| Rebind(k.clone(), v.clone()))
            .collect(),
    );

    // compose a new RainDocument with final injected bindings
    RainDocument::create(dotrain, Some(meta_store), None, rebinds).compose(entrypoints)
}

[crates/common/src/add_order.rs:179-186]

pub fn compose_to_rainlang(&self) -> Result<String, AddOrderArgsError> {
        let res = compose_to_rainlang(
            self.dotrain.clone(),
            self.bindings.clone(),
            &ORDERBOOK_ORDER_ENTRYPOINTS,
        )?;
        Ok(res)
    }

🧠 Learnings used
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.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1917
File: tauri-app/src/routes/orders/add/+page.svelte:45-47
Timestamp: 2025-06-11T11:39:15.239Z
Learning: In the rain.orderbook codebase, every instance of `Config` (returned by helpers such as `parseDotrainAndYaml`) is guaranteed to include the `dotrainOrder` property; it is never `undefined`.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/common/src/raindex_client/orders.rs:738-741
Timestamp: 2025-10-02T19:17:20.332Z
Learning: In crates/common/src/raindex_client/orders.rs, fetch_dotrain_source() is intentionally called in try_from_sg_order for every order conversion because the dotrain source information is needed immediately. A future optimization with local DB logic is planned to eliminate the network round-trip concern.

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.

Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2012
File: crates/js_api/src/registry.rs:485-512
Timestamp: 2025-07-30T07:41:39.271Z
Learning: In crates/js_api/src/registry.rs, findolor considers the current concurrent fetching of order files using futures::future::join_all without concurrency limits to be acceptable, preferring the simple approach over adding concurrency limiting mechanisms for the DotrainRegistry implementation.

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

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

Comment on lines 240 to 253
let frontmatter = RainDocument::get_front_matter(&dotrain)
.unwrap_or("")
.to_string();
let dotrain_yaml =
DotrainYaml::new(vec![frontmatter.clone()], DotrainYamlValidation::default())?;

let order_key =
DeploymentCfg::parse_order_key(dotrain_yaml.documents, &state.selected_deployment)?;
let dotrain_order = DotrainOrder::create_with_profile(
dotrain.clone(),
None,
ContextProfile::gui(Some(order_key), Some(state.selected_deployment.clone())),
)
.await?;
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Profile-aware new_from_state path is wired correctly

Using RainDocument::get_front_matterDotrainYaml::newDeploymentCfg::parse_order_key and then DotrainOrder::create_with_profile with ContextProfile::gui(Some(order_key), Some(state.selected_deployment.clone())) correctly reconstructs state under the GUI profile and binds the current order/deployment. The extra YAML parse here mirrors other call sites and is acceptable on this initialization path.

🤖 Prompt for AI Agents
In crates/js_api/src/gui/state_management.rs around lines 240 to 253, the
profile-aware new_from_state path is implemented correctly (using
RainDocument::get_front_matter → DotrainYaml::new →
DeploymentCfg::parse_order_key → DotrainOrder::create_with_profile with
ContextProfile::gui(Some(order_key), Some(state.selected_deployment.clone())))
and mirrors other call sites; no code changes are required here—leave this
initialization path as-is.

dotrain_order: DotrainOrder::create_with_profile(
dotrain.clone(),
None,
ContextProfile::gui(Some(order_key), Some(selected_deployment.clone())),
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need to pass in an order_key if it's deterministic based on the selected_deployment? what happens if i get it wrong and pass in an order that isn't associated with that deployment?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are right actually, we don't need to pass order_key. This might lead to bugs if we forget to pass the correct order. I'm going to refactor the logic to only take deployment_key and handle the order logic internally.

Copy link
Contributor

@hardyjosh hardyjosh Dec 13, 2025

Choose a reason for hiding this comment

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

this could use some documentation - what is a "Strict" profile?

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between beef328 and 37b521d.

📒 Files selected for processing (6)
  • crates/js_api/src/gui/mod.rs (4 hunks)
  • crates/js_api/src/gui/state_management.rs (1 hunks)
  • crates/settings/src/yaml/context.rs (2 hunks)
  • crates/settings/src/yaml/dotrain.rs (13 hunks)
  • crates/settings/src/yaml/mod.rs (2 hunks)
  • crates/settings/src/yaml/orderbook.rs (12 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
crates/**/*.rs

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

crates/**/*.rs: For Rust crates in crates/*, run lints using nix develop -c cargo clippy --workspace --all-targets --all-features -D warnings
For Rust crates in crates/*, run tests using nix develop -c cargo test --workspace or --package <crate>

Files:

  • crates/js_api/src/gui/state_management.rs
  • crates/settings/src/yaml/context.rs
  • crates/settings/src/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.rs
**/crates/**

📄 CodeRabbit inference engine (AGENTS.md)

Rust workspace organized as crates/* with subdirectories: cli, common, bindings, js_api, quote, subgraph, settings, math, integration_tests

Files:

  • crates/js_api/src/gui/state_management.rs
  • crates/settings/src/yaml/context.rs
  • crates/settings/src/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.rs
**/*.rs

📄 CodeRabbit inference engine (AGENTS.md)

**/*.rs: Rust: format code with nix develop -c cargo fmt --all
Rust: lint with nix develop -c rainix-rs-static (preconfigured flags included)
Rust: crates and modules use snake_case; types use PascalCase

Files:

  • crates/js_api/src/gui/state_management.rs
  • crates/settings/src/yaml/context.rs
  • crates/settings/src/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.rs
🧠 Learnings (40)
📚 Learning: 2025-07-09T14:00:12.206Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1975
File: crates/js_api/src/gui/state_management.rs:412-412
Timestamp: 2025-07-09T14:00:12.206Z
Learning: In crates/js_api/src/gui/state_management.rs tests, findolor prefers to keep hard-coded serialized state constants (like SERIALIZED_STATE) rather than dynamically generating them, even when it may make tests more brittle to maintain.

Applied to files:

  • crates/js_api/src/gui/state_management.rs
📚 Learning: 2025-09-24T10:59:25.666Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2163
File: crates/js_api/src/gui/state_management.rs:196-203
Timestamp: 2025-09-24T10:59:25.666Z
Learning: In crates/js_api/src/gui/state_management.rs, the RainMetaDocumentV1Item::hash(false) method returns a slice, so wrapping the result with FixedBytes() is necessary to convert it to the expected FixedBytes type for DotrainGuiStateV1.dotrain_hash field.

Applied to files:

  • crates/js_api/src/gui/state_management.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/js_api/src/gui/state_management.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/dotrain.rs
📚 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/yaml/context.rs
  • crates/settings/src/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-11-25T16:50:31.752Z
Learnt from: CR
Repo: rainlanguage/rain.orderbook PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-25T16:50:31.752Z
Learning: Applies to crates/integration_tests/**/*.rs : Rust: write tests using `cargo test`; integration tests live in `crates/integration_tests`. Prefer `insta` snapshots and `proptest` where helpful

Applied to files:

  • crates/settings/src/yaml/context.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/yaml/mod.rs
  • crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-03-28T10:09:10.696Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1463
File: crates/settings/src/yaml/context.rs:298-304
Timestamp: 2025-03-28T10:09:10.696Z
Learning: In the `resolve_token_path` method of the Context implementation in `crates/settings/src/yaml/context.rs`, when an unknown property is accessed on a token, it returns a `ContextError::InvalidPath` error, not a `ContextError::PropertyNotFound` error.

Applied to files:

  • crates/settings/src/yaml/mod.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/mod.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/yaml/mod.rs
  • crates/settings/src/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.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/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/orderbook.rs
📚 Learning: 2025-07-16T10:40:05.717Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2000
File: crates/common/src/raindex_client/vaults.rs:183-183
Timestamp: 2025-07-16T10:40:05.717Z
Learning: In the rainlanguage/rain.orderbook codebase, user findolor considers breaking changes from Option<U256> to U256 for required fields like decimals in RaindexVaultToken to be acceptable and safe, even when they affect multiple usage sites across the codebase.

Applied to files:

  • crates/settings/src/yaml/mod.rs
📚 Learning: 2025-06-18T12:54:47.807Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/orders.rs:1-11
Timestamp: 2025-06-18T12:54:47.807Z
Learning: In the rain.orderbook repository, findolor prefers to keep unused imports in place when they will be used in upcoming follow-up PRs, rather than removing and re-adding them during incremental development.

Applied to files:

  • crates/settings/src/yaml/mod.rs
📚 Learning: 2025-06-18T12:56:44.290Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1938
File: crates/js_api/src/raindex/mod.rs:102-118
Timestamp: 2025-06-18T12:56:44.290Z
Learning: In the rainlanguage/rain.orderbook codebase, it's acceptable to scaffold unused enum variants in initial implementation PRs when they will be implemented in future PRs, as confirmed by findolor.

Applied to files:

  • crates/settings/src/yaml/mod.rs
📚 Learning: 2025-07-21T16:37:20.599Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/subgraph/src/utils/mod.rs:1-1
Timestamp: 2025-07-21T16:37:20.599Z
Learning: In the rainlanguage/rain.orderbook codebase, user 0xgleb prefers explicit module imports over re-exporting symbols at higher levels. Specifically for the float constants in crates/subgraph/src/utils/float.rs, they prefer using `utils::float::*` rather than re-exporting with `pub use float::*` in the utils module, as the explicit import makes it clearer what is being imported and why it's needed.

Applied to files:

  • crates/settings/src/yaml/mod.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/yaml/mod.rs
  • crates/js_api/src/gui/mod.rs
📚 Learning: 2025-08-15T20:56:15.592Z
Learnt from: brusherru
Repo: rainlanguage/rain.orderbook PR: 1978
File: packages/webapp/src/routes/deploy/[orderName]/[deploymentKey]/fullDeployment.test.ts:22-29
Timestamp: 2025-08-15T20:56:15.592Z
Learning: In packages/webapp/src/routes/deploy/[orderName]/[deploymentKey]/fullDeployment.test.ts, brusherru prefers fail-fast testing approaches where type mismatches cause immediate test failures to alert developers about interface changes, rather than using defensive programming with type guards that might mask API evolution.

Applied to files:

  • crates/js_api/src/gui/mod.rs
📚 Learning: 2025-08-20T06:59:32.191Z
Learnt from: hardyjosh
Repo: rainlanguage/rain.orderbook PR: 2087
File: .github/workflows/rainix.yaml:94-106
Timestamp: 2025-08-20T06:59:32.191Z
Learning: In the rain.orderbook repository, the ephemeral deployment key generated in .github/workflows/rainix.yaml is intentionally designed to be non-sensitive and doesn't require security hardening measures like key masking or leak prevention, as explicitly confirmed by hardyjosh.

Applied to files:

  • crates/js_api/src/gui/mod.rs
📚 Learning: 2025-03-26T16:22:50.224Z
Learnt from: hardingjam
Repo: rainlanguage/rain.orderbook PR: 1515
File: packages/webapp/src/routes/deploy/[strategyName]/[deploymentKey]/layout.test.ts:0-0
Timestamp: 2025-03-26T16:22:50.224Z
Learning: In the Rain Orderbook project, the DotrainOrderGui.getDeploymentDetail method resolves promises with objects that may contain either a value property or an error property, rather than rejecting promises on errors.

Applied to files:

  • crates/js_api/src/gui/mod.rs
  • crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-11-25T14:56:29.762Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 2334
File: crates/settings/src/yaml/orderbook.rs:18-18
Timestamp: 2025-11-25T14:56:29.762Z
Learning: In crates/settings/src/yaml/orderbook.rs, the `accounts` section is optional in orderbook YAML. The `AccountCfg::parse_all_from_yaml` method returns an empty HashMap when the `accounts` section is missing rather than throwing a Field(Missing(...)) error, so it doesn't need to be wrapped with `to_yaml_string_missing_check` in the `to_yaml_string` method.

Applied to files:

  • crates/settings/src/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.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/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.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/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.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/yaml/orderbook.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/yaml/orderbook.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/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.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/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.rs
📚 Learning: 2025-07-21T16:32:19.576Z
Learnt from: 0xgleb
Repo: rainlanguage/rain.orderbook PR: 1911
File: crates/common/src/add_order.rs:297-300
Timestamp: 2025-07-21T16:32:19.576Z
Learning: User 0xgleb prefers explicit destructuring patterns like `let (_, Address(FixedBytes(address))) = ...` over intermediate variables when extracting nested data structures, as they believe it makes clearer what is being unwrapped from complex types.

Applied to files:

  • crates/settings/src/yaml/orderbook.rs
📚 Learning: 2025-04-07T09:53:18.442Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1483
File: crates/settings/src/yaml/orderbook.rs:62-67
Timestamp: 2025-04-07T09:53:18.442Z
Learning: The OrderbookYaml design intentionally creates a fresh Cache in the from_documents method to isolate each instance's cache data. This isolation is a deliberate architectural choice.

Applied to files:

  • crates/settings/src/yaml/orderbook.rs
  • crates/settings/src/yaml/dotrain.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/yaml/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/yaml/orderbook.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/orderbook.rs
  • crates/settings/src/yaml/dotrain.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/yaml/orderbook.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/yaml/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/orderbook.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/yaml/orderbook.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/yaml/orderbook.rs
  • 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-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/yaml/dotrain.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/yaml/dotrain.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/yaml/dotrain.rs
📚 Learning: 2025-04-29T11:17:46.178Z
Learnt from: findolor
Repo: rainlanguage/rain.orderbook PR: 1687
File: crates/js_api/src/gui/order_operations.rs:470-489
Timestamp: 2025-04-29T11:17:46.178Z
Learning: In the `get_deployment_transaction_args` method of `DotrainOrderGui`, approvals are intentionally only checked against output tokens as per the design requirements.

Applied to files:

  • crates/settings/src/yaml/dotrain.rs
🧬 Code graph analysis (4)
crates/js_api/src/gui/state_management.rs (2)
crates/common/src/dotrain_order.rs (2)
  • create_with_profile (303-354)
  • dotrain (374-376)
crates/settings/src/yaml/context.rs (1)
  • gui (31-33)
crates/js_api/src/gui/mod.rs (2)
crates/settings/src/yaml/context.rs (2)
  • new (229-236)
  • gui (31-33)
crates/settings/src/gui.rs (1)
  • parse_deployment_keys (356-391)
crates/settings/src/yaml/orderbook.rs (2)
crates/settings/src/yaml/dotrain.rs (6)
  • from_documents (117-123)
  • documents (320-330)
  • from_orderbook_yaml (133-139)
  • from_dotrain_yaml (125-131)
  • map (302-302)
  • map (314-314)
crates/settings/src/yaml/context.rs (1)
  • default (37-39)
crates/settings/src/yaml/dotrain.rs (4)
crates/settings/src/yaml/mod.rs (4)
  • from_documents (45-45)
  • from_dotrain_yaml (47-47)
  • from_orderbook_yaml (46-46)
  • new (43-43)
crates/settings/src/yaml/context.rs (4)
  • default (37-39)
  • new (229-236)
  • order (90-90)
  • order (122-124)
crates/common/src/dotrain_order.rs (2)
  • dotrain_yaml (494-496)
  • orderbook_yaml (498-500)
crates/settings/src/test.rs (2)
  • mock_network (9-19)
  • mock_token (50-60)
⏰ 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). (15)
  • GitHub Check: git-clean
  • GitHub Check: standard-tests (ubuntu-latest, rainix-wasm-test)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-legal)
  • GitHub Check: standard-tests (ubuntu-latest, rainix-rs-static)
  • GitHub Check: standard-tests (ubuntu-latest, test-js-bindings)
  • 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-rs-artifacts, true)
  • GitHub Check: test
  • GitHub Check: standard-tests (ubuntu-latest, rainix-sol-artifacts)
  • GitHub Check: test
  • GitHub Check: test
  • GitHub Check: build-tauri (ubuntu-22.04, true)
  • GitHub Check: Deploy-Docs-Preview
  • GitHub Check: Deploy-Preview-Push
🔇 Additional comments (25)
crates/js_api/src/gui/state_management.rs (1)

240-245: Profile-aware state restoration is correctly implemented.

The new_from_state method now properly uses DotrainOrder::create_with_profile with ContextProfile::gui(state.selected_deployment.clone()), ensuring the GUI context profile is applied during state restoration. This aligns with the PR's objective of first-class context support.

crates/settings/src/yaml/context.rs (2)

8-40: Well-documented ContextProfile enum with appropriate defaults.

The documentation clearly explains the two profiles:

  • Strict: Full validation mode for CLI/batch flows
  • Gui: UI-scoped mode for single-deployment GUI/WASM flows

The default to Strict is appropriate since it provides the safest fallback for non-GUI contexts. The constructor helpers (strict() and gui()) provide a clean API.


349-361: Test coverage for ContextProfile helpers is adequate.

The test validates all three constructor paths: strict(), default(), and gui(), ensuring the enum variants are created correctly.

crates/settings/src/yaml/orderbook.rs (2)

437-539: Serialization/deserialization correctly handles profile with backward compatibility.

The implementation:

  • Serializes profile alongside documents in a struct format
  • Deserializes new map-based format preserving the profile
  • Falls back to legacy sequence format with default Strict profile for backward compatibility

This ensures existing serialized state can still be deserialized while new state includes the profile.


548-596: Test coverage for profile functionality is comprehensive.

The tests verify:

  1. new_with_profile and with_profile helpers work correctly
  2. Round-trip serialization preserves the profile
  3. Legacy sequence format correctly defaults to Strict profile
crates/settings/src/yaml/mod.rs (2)

122-124: Signature change enforces explicit deployment specification.

The change from Option<String> to &str removes the conditional handling and ensures deployment is always explicitly provided when expanding context. This aligns with the PR's goal of robust, first-class context support.


12-12: Import confirmed as needed.

The ContextProfile import is used for module-level access. As confirmed in previous review discussion, no clippy warning is raised.

crates/js_api/src/gui/mod.rs (4)

169-191: Profile-aware initialization correctly implemented.

The new_with_deployment method:

  1. Extracts frontmatter and validates deployment keys via DotrainYaml
  2. Uses DotrainOrder::create_with_profile with ContextProfile::gui(selected_deployment)

This ensures the GUI context profile is properly set during initialization, scoping parsing to the selected deployment.


215-225: GUI config retrieval correctly scoped to current deployment.

The get_gui_config method now uses get_gui(&self.selected_deployment) to retrieve only the relevant deployment's configuration, consistent with the deployment-scoped context approach.


599-613: Rainlang composition uses profile-aware context.

The get_composed_rainlang method creates a fresh DotrainOrder with ContextProfile::gui(deployment.deployment.key), ensuring the composed Rainlang is generated with proper deployment-scoped context. The deployment key is correctly derived from the configuration.


616-623: Helper method cleanly extracts YAML documents.

The get_yaml_documents helper provides a consistent way to extract frontmatter and create DotrainYaml documents for static methods that don't have access to a DotrainOrder instance.

crates/settings/src/yaml/dotrain.rs (14)

3-6: LGTM!

The new serde imports (IgnoredAny, MapAccess, SerializeStruct) are correctly added to support the updated serialization and deserialization implementations.


15-22: LGTM!

The new profile field follows the existing pattern of public fields in this struct. The Default derive will correctly initialize it to ContextProfile::Strict based on the Default implementation in context.rs.


125-139: LGTM!

The asymmetric profile handling is intentional and correct:

  • from_dotrain_yaml preserves the source profile (line 129).
  • from_orderbook_yaml defaults to Strict (line 137) since OrderbookYaml doesn't carry a profile.

168-198: LGTM!

The build_context method correctly handles both profile types:

  • Strict: Expands remote networks and tokens only.
  • Gui: Additionally sets up GUI-specific context (current deployment, select tokens, current order, and the parsed order).

The design of accepting a &ContextProfile parameter (rather than always using self.profile) provides flexibility for methods like get_gui and get_order_for_gui_deployment that need a specific profile regardless of the instance's default.


203-260: LGTM!

The getter methods follow a consistent pattern:

  • Standard getters (get_orders, get_scenarios, etc.) use self.profile.
  • GUI-specific getters (get_order_for_gui_deployment, get_gui) explicitly construct a Gui profile with the deployment key.

This refactoring aligns with the PR objective of providing first-class context support.


263-279: LGTM!

The serialization now outputs a struct format { "documents": [...], "profile": {...} } to persist the profile. This is a breaking change in the serialized format, but the deserialization correctly handles both the new struct format and the legacy sequence format for backward compatibility.


295-337: LGTM!

The visit_map implementation correctly:

  • Defaults profile to Strict when absent (line 300), ensuring backward compatibility.
  • Validates that documents is a required field (line 319).
  • Ignores unknown fields for forward compatibility (lines 313-315).
  • Resets cache to default (line 334), which is correct since cache is transient state.

339-364: LGTM!

Excellent backward compatibility support:

  • visit_seq handles legacy sequence format with Strict profile default.
  • deserialize_any allows the deserializer to determine the format at runtime.

369-382: LGTM!

Test imports correctly include the new types needed for testing context profiles (ContextProfile, YamlCacheTrait).


755-765: LGTM!

The new assertions properly verify that build_context with a Gui profile correctly populates:

  • gui_context.current_deployment with the deployment key.
  • select_tokens from the deployment's select-tokens configuration.

852-946: LGTM!

Comprehensive test that validates:

  • Strict profile expands remote networks/tokens but doesn't set GUI context or order.
  • Gui profile additionally sets current_order, current_deployment, and parses the order.
  • Profile and cache are correctly propagated through from_dotrain_yaml.

948-1002: LGTM!

This test effectively demonstrates the profile-driven behavior difference:

  • Strict profile requires all referenced tokens to exist → fails with Missing("tokens").
  • Gui profile with select-tokens allows deferred token resolution → order parses with None tokens.

This validates the core value proposition of context profiles.


1004-1032: LGTM!

Serialization tests provide good coverage:

  • test_dotrain_yaml_serialization_preserves_profile: Verifies round-trip preserves Gui profile.
  • test_dotrain_yaml_legacy_sequence_deserialization_defaults_profile: Confirms backward compatibility with legacy sequence format defaulting to Strict.

1279-1279: LGTM!

Test correctly updated for the new get_gui signature.

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.

Rethink about the context injection in yaml parsing logic and refactor the parsing architecture to have first class context support

4 participants