feat(yaml): add resource declarations - #427
Conversation
1ce4121 to
03b1d6a
Compare
# Description
Allow `ResourceBuilder` to use explicit usage and bounds record names through `with_record_names`. `new` retains the default `{Resource}Usage` and `{Resource}Bounds` naming scheme.
Also expose `Resource::constraint_data` for consistent constraint serialization.
_Written by Codex._
# Related issues
This is useful because in #427 it can be leveraged to provide custom names for these record types.
Authors:
- Johan Peltenburg (https://github.com/johanpel)
Approvers:
- Matthijs Brobbel (https://github.com/mbrobbel)
URL: #432
# Description Simplifies entity event declarations. Events default to once-cardinality and use `multi: true` when repeatable. Entity events and FSM states use `attributes:`, while records retain `fields:`. _Written by Codex._ ## Related Issues This will also make additional syntax introduced by #427 across FSM and entity blocks consistent. Authors: - Johan Peltenburg (https://github.com/johanpel) Approvers: - Matthijs Brobbel (https://github.com/mbrobbel) URL: #437
9923d75 to
6b03fff
Compare
# Description Reject resource usage and bounds records inside list types. This is ambiguous, because which instance of the bounds is the truth? Options are allowed, because I don't want to restrict users from emitting this conditionally to prevent an explosion of event declarations. If the user desires to do something with bounds (e.g. visualize, check for leaks, etc.) then in the case of optional bounds events it is their responsibility to make sure they are conveyed. This is already the case because we can't force client code to emit certain events, so if a resource has multiple events of which only one sets bounds, but doesn't emit that event, you're basically in the same boat. ## Related Issues Surfaced while working on #427 Authors: - Johan Peltenburg (https://github.com/johanpel) Approvers: - Matthijs Brobbel (https://github.com/mbrobbel) URL: #438
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: QUIET Plan: Enterprise Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughChangesThe YAML crate now supports resource declarations, generated usage and bounds records, resource-aware type and event lowering, resource validation, and YAML resource support
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Note
Quiet mode is enabled, so only the most important comments were posted inline. Other review comments are grouped below.
🟡 Other comments (1)
crates/yaml/Cargo.toml-13-13 (1)
13-13: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winMove
quent-resourceto the workspace tableIn
crates/yaml/Cargo.toml, referencequent-resourcewithworkspace = trueand add it once under[workspace.dependencies]in the root manifest.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/yaml/Cargo.toml` at line 13, Update the quent-resource dependency in the YAML crate manifest to use the workspace dependency declaration, then add a single quent-resource entry under the root manifest’s [workspace.dependencies] table using its existing path configuration.Source: Path instructions
🧹 Nitpick comments (1)
crates/yaml/tests/resource.rs (1)
27-49: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winMissing test coverage for
kind: ratecapacities.Every capacity fixture in this suite uses
kind: occupancy; per the PR objective, resources can also declare capacities ofkind: rate, but no test exercises that path (record generation, bounds, or validation forrate). Consider adding at least one test analogous toresource_declaration_generates_records_and_carries_boundswith aratecapacity, and optionally a resource with more than one capacity field, to close this gap.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/yaml/tests/resource.rs` around lines 27 - 49, Add test coverage in the resource declaration tests for a capacity with kind: rate, analogous to resource_declaration_generates_records_and_carries_bounds. Assert record generation, propagated bounds, and validation for the rate capacity; include multiple capacity fields only if needed to exercise the relevant path.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Other comments:
In `@crates/yaml/Cargo.toml`:
- Line 13: Update the quent-resource dependency in the YAML crate manifest to
use the workspace dependency declaration, then add a single quent-resource entry
under the root manifest’s [workspace.dependencies] table using its existing path
configuration.
---
Nitpick comments:
In `@crates/yaml/tests/resource.rs`:
- Around line 27-49: Add test coverage in the resource declaration tests for a
capacity with kind: rate, analogous to
resource_declaration_generates_records_and_carries_bounds. Assert record
generation, propagated bounds, and validation for the rate capacity; include
multiple capacity fields only if needed to exercise the relevant path.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: QUIET
Plan: Enterprise
Run ID: b625d633-07aa-4fda-8835-0a1363589631
⛔ Files ignored due to path filters (2)
Cargo.lockis excluded by!**/*.lock,!Cargo.lockcrates/instrumentation-build/example/Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (6)
crates/resource/src/builder.rscrates/yaml/Cargo.tomlcrates/yaml/src/ast.rscrates/yaml/src/lib.rscrates/yaml/src/lower.rscrates/yaml/tests/resource.rs
Signed-off-by: Johan Peltenburg <johan.peltenburg+code@gmail.com>
|
/merge |
Description
Add YAML syntax and lowering for unit and capacity-based resources.
Resources can declare capacities with or without
known-bounds, expose bounds through events withsets-resource-bounds, and resources can be claimed throughuses. Generated usage and bounds record names can be overridden.Example
kindisoccupancyorrate.known-boundsdefaults tofalse.usage-recordandbounds-recordare optional. Their defaults areMemoryUsageandMemoryBounds.sets-resource-boundsinserts the generated bounds record as the attribute type.usesgenerates a targeted entity reference carrying the usage record.resource: true.Written by Codex.
Related Issues
Solves #196. This is the final constraint necessary to make the YAML DSL capture an application event model at feature parity with PoC Quent as far as the application-agnostic parts are concerned.
Because resources are somewhat involved, I've decided not to add them to the
instrumentation-buildexample, but will follow up later with more gently introduced examples in #419.