[codex] Harden reading artifact posture#319
Conversation
📝 WalkthroughWalkthroughThe PR extends the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Review rate limit: 0/1 reviews remaining, refill in 60 minutes.Comment |
|
Note Docstrings generation - SUCCESS |
Docstrings generation was requested by @flyingrobots. * #319 (comment) The following files were modified: * `crates/warp-core/src/observation.rs`
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/echo-wasm-abi/src/lib.rs`:
- Around line 611-632: The test
test_reading_residual_posture_wire_names_are_distinct currently only asserts
decoded text and round-trip decoding, which won't catch regressions in the
canonical CBOR encoding; update the test to pin the exact canonical CBOR byte
sequence for each ReadingResidualPosture variant by computing or hardcoding the
expected bytes and assert that encode_cbor(&posture).unwrap() == expected_bytes,
while keeping the existing decode_cbor checks for round-trip equality; reference
the functions ReadingResidualPosture, encode_cbor, decode_value, and decode_cbor
to locate where to replace the Value::Text check with a direct bytes equality
assertion.
In `@crates/warp-wasm/src/warp_kernel.rs`:
- Around line 1283-1296: The test currently asserts only observer_plan,
parent_basis_posture, and residual_posture on artifact.reading; add assertions
for the remaining reading-envelope defaults—observer_basis, budget_posture, and
rights_posture—to the same end-to-end ABI test so a WASM-side default drift
fails loudly (use the same expected enum variants as emitted in
crates/warp-wasm/src/lib.rs around the default block). Locate the assertions
around artifact.reading in the test (symbols: artifact.reading,
AbiReadingObserverPlan, AbiObservationBasisPosture, AbiReadingResidualPosture)
and add checks that artifact.reading.observer_basis equals the expected
AbiObservationBasis (default), artifact.reading.budget_posture equals the
expected AbiBudgetPosture (default), and artifact.reading.rights_posture equals
the expected AbiRightsPosture (default).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 46759ffe-9c86-46ca-b754-9f22898bec85
📒 Files selected for processing (7)
crates/echo-wasm-abi/src/kernel_port.rscrates/echo-wasm-abi/src/lib.rscrates/warp-core/src/observation.rscrates/warp-wasm/src/warp_kernel.rsdocs/BEARING.mddocs/spec/SPEC-0004-worldlines-playback-truthbus.mddocs/spec/SPEC-0009-wasm-abi.md
| #[test] | ||
| fn test_reading_residual_posture_wire_names_are_distinct() { | ||
| use crate::kernel_port::ReadingResidualPosture; | ||
| use ciborium::value::Value; | ||
|
|
||
| let cases = [ | ||
| (ReadingResidualPosture::Complete, "complete"), | ||
| (ReadingResidualPosture::Residual, "residual"), | ||
| (ReadingResidualPosture::Plurality, "plurality"), | ||
| (ReadingResidualPosture::Obstructed, "obstructed"), | ||
| ]; | ||
|
|
||
| for (posture, expected_text) in cases { | ||
| let bytes = encode_cbor(&posture).unwrap(); | ||
| assert_eq!( | ||
| decode_value(&bytes).unwrap(), | ||
| Value::Text(expected_text.into()) | ||
| ); | ||
| let decoded: ReadingResidualPosture = decode_cbor(&bytes).unwrap(); | ||
| assert_eq!(decoded, posture); | ||
| } | ||
| } |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
Lock the exact canonical CBOR bytes, not just the decoded text.
These assertions still pass if the encoder regresses to a non-canonical text representation that decodes to the same string. Since ReadingResidualPosture is ABI-visible, pin the exact encoded bytes here as well.
Suggested change
#[test]
fn test_reading_residual_posture_wire_names_are_distinct() {
use crate::kernel_port::ReadingResidualPosture;
use ciborium::value::Value;
let cases = [
- (ReadingResidualPosture::Complete, "complete"),
- (ReadingResidualPosture::Residual, "residual"),
- (ReadingResidualPosture::Plurality, "plurality"),
- (ReadingResidualPosture::Obstructed, "obstructed"),
+ (
+ ReadingResidualPosture::Complete,
+ "complete",
+ "68636f6d706c657465",
+ ),
+ (
+ ReadingResidualPosture::Residual,
+ "residual",
+ "68726573696475616c",
+ ),
+ (
+ ReadingResidualPosture::Plurality,
+ "plurality",
+ "69706c7572616c697479",
+ ),
+ (
+ ReadingResidualPosture::Obstructed,
+ "obstructed",
+ "6a6f627374727563746564",
+ ),
];
- for (posture, expected_text) in cases {
+ for (posture, expected_text, expected_hex) in cases {
let bytes = encode_cbor(&posture).unwrap();
+ assert_eq!(hex_encode(&bytes), expected_hex);
assert_eq!(
decode_value(&bytes).unwrap(),
Value::Text(expected_text.into())
);
let decoded: ReadingResidualPosture = decode_cbor(&bytes).unwrap();
assert_eq!(decoded, posture);
}
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| #[test] | |
| fn test_reading_residual_posture_wire_names_are_distinct() { | |
| use crate::kernel_port::ReadingResidualPosture; | |
| use ciborium::value::Value; | |
| let cases = [ | |
| (ReadingResidualPosture::Complete, "complete"), | |
| (ReadingResidualPosture::Residual, "residual"), | |
| (ReadingResidualPosture::Plurality, "plurality"), | |
| (ReadingResidualPosture::Obstructed, "obstructed"), | |
| ]; | |
| for (posture, expected_text) in cases { | |
| let bytes = encode_cbor(&posture).unwrap(); | |
| assert_eq!( | |
| decode_value(&bytes).unwrap(), | |
| Value::Text(expected_text.into()) | |
| ); | |
| let decoded: ReadingResidualPosture = decode_cbor(&bytes).unwrap(); | |
| assert_eq!(decoded, posture); | |
| } | |
| } | |
| #[test] | |
| fn test_reading_residual_posture_wire_names_are_distinct() { | |
| use crate::kernel_port::ReadingResidualPosture; | |
| use ciborium::value::Value; | |
| let cases = [ | |
| ( | |
| ReadingResidualPosture::Complete, | |
| "complete", | |
| "68636f6d706c657465", | |
| ), | |
| ( | |
| ReadingResidualPosture::Residual, | |
| "residual", | |
| "68726573696475616c", | |
| ), | |
| ( | |
| ReadingResidualPosture::Plurality, | |
| "plurality", | |
| "69706c7572616c697479", | |
| ), | |
| ( | |
| ReadingResidualPosture::Obstructed, | |
| "obstructed", | |
| "6a6f627374727563746564", | |
| ), | |
| ]; | |
| for (posture, expected_text, expected_hex) in cases { | |
| let bytes = encode_cbor(&posture).unwrap(); | |
| assert_eq!(hex_encode(&bytes), expected_hex); | |
| assert_eq!( | |
| decode_value(&bytes).unwrap(), | |
| Value::Text(expected_text.into()) | |
| ); | |
| let decoded: ReadingResidualPosture = decode_cbor(&bytes).unwrap(); | |
| assert_eq!(decoded, posture); | |
| } | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/echo-wasm-abi/src/lib.rs` around lines 611 - 632, The test
test_reading_residual_posture_wire_names_are_distinct currently only asserts
decoded text and round-trip decoding, which won't catch regressions in the
canonical CBOR encoding; update the test to pin the exact canonical CBOR byte
sequence for each ReadingResidualPosture variant by computing or hardcoding the
expected bytes and assert that encode_cbor(&posture).unwrap() == expected_bytes,
while keeping the existing decode_cbor checks for round-trip equality; reference
the functions ReadingResidualPosture, encode_cbor, decode_value, and decode_cbor
to locate where to replace the Value::Text check with a direct bytes equality
assertion.
| assert_eq!( | ||
| artifact.reading.observer_plan, | ||
| AbiReadingObserverPlan::Builtin { | ||
| plan: AbiBuiltinObserverPlan::CommitBoundaryHead, | ||
| } | ||
| ); | ||
| assert_eq!( | ||
| artifact.reading.parent_basis_posture, | ||
| AbiObservationBasisPosture::Worldline | ||
| ); | ||
| assert_eq!( | ||
| artifact.reading.residual_posture, | ||
| AbiReadingResidualPosture::Complete | ||
| ); |
There was a problem hiding this comment.
🧹 Nitpick | 🔵 Trivial | ⚡ Quick win
Cover the rest of the reading-envelope defaults in the end-to-end ABI test.
This locks observer_plan, parent_basis_posture, and residual_posture, but the documented contract also includes observer_basis, budget_posture, and rights_posture. Add those assertions here so a WASM-side default drift fails loudly.
Suggested change
assert_eq!(
artifact.reading.observer_plan,
AbiReadingObserverPlan::Builtin {
plan: AbiBuiltinObserverPlan::CommitBoundaryHead,
}
);
+ assert_eq!(
+ artifact.reading.observer_basis,
+ echo_wasm_abi::kernel_port::ReadingObserverBasis::CommitBoundary
+ );
assert_eq!(
artifact.reading.parent_basis_posture,
AbiObservationBasisPosture::Worldline
);
+ assert_eq!(
+ artifact.reading.budget_posture,
+ echo_wasm_abi::kernel_port::ReadingBudgetPosture::UnboundedOneShot
+ );
+ assert_eq!(
+ artifact.reading.rights_posture,
+ echo_wasm_abi::kernel_port::ReadingRightsPosture::KernelPublic
+ );
assert_eq!(
artifact.reading.residual_posture,
AbiReadingResidualPosture::Complete
);The same defaults are also emitted in crates/warp-wasm/src/lib.rs:653-668.
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| assert_eq!( | |
| artifact.reading.observer_plan, | |
| AbiReadingObserverPlan::Builtin { | |
| plan: AbiBuiltinObserverPlan::CommitBoundaryHead, | |
| } | |
| ); | |
| assert_eq!( | |
| artifact.reading.parent_basis_posture, | |
| AbiObservationBasisPosture::Worldline | |
| ); | |
| assert_eq!( | |
| artifact.reading.residual_posture, | |
| AbiReadingResidualPosture::Complete | |
| ); | |
| assert_eq!( | |
| artifact.reading.observer_plan, | |
| AbiReadingObserverPlan::Builtin { | |
| plan: AbiBuiltinObserverPlan::CommitBoundaryHead, | |
| } | |
| ); | |
| assert_eq!( | |
| artifact.reading.observer_basis, | |
| echo_wasm_abi::kernel_port::ReadingObserverBasis::CommitBoundary | |
| ); | |
| assert_eq!( | |
| artifact.reading.parent_basis_posture, | |
| AbiObservationBasisPosture::Worldline | |
| ); | |
| assert_eq!( | |
| artifact.reading.budget_posture, | |
| echo_wasm_abi::kernel_port::ReadingBudgetPosture::UnboundedOneShot | |
| ); | |
| assert_eq!( | |
| artifact.reading.rights_posture, | |
| echo_wasm_abi::kernel_port::ReadingRightsPosture::KernelPublic | |
| ); | |
| assert_eq!( | |
| artifact.reading.residual_posture, | |
| AbiReadingResidualPosture::Complete | |
| ); |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@crates/warp-wasm/src/warp_kernel.rs` around lines 1283 - 1296, The test
currently asserts only observer_plan, parent_basis_posture, and residual_posture
on artifact.reading; add assertions for the remaining reading-envelope
defaults—observer_basis, budget_posture, and rights_posture—to the same
end-to-end ABI test so a WASM-side default drift fails loudly (use the same
expected enum variants as emitted in crates/warp-wasm/src/lib.rs around the
default block). Locate the assertions around artifact.reading in the test
(symbols: artifact.reading, AbiReadingObserverPlan, AbiObservationBasisPosture,
AbiReadingResidualPosture) and add checks that artifact.reading.observer_basis
equals the expected AbiObservationBasis (default),
artifact.reading.budget_posture equals the expected AbiBudgetPosture (default),
and artifact.reading.rights_posture equals the expected AbiRightsPosture
(default).
Summary
ReadingResidualPosturevalues forresidual,plurality, andobstructedalongside the existingcompleteposture.warp-coreconversion and adds ABI/core/WASM coverage so consumers can distinguish bounded reading posture from generic state payloads.Impact
Built-in observations still emit
complete; this does not add suffix admission or new non-clean emission paths. It makes the ABI vocabulary explicit so external consumers can handle future bounded non-clean readings without guessing from payload shape.Verification
cargo fmt --all -- --checkcargo test -p echo-wasm-abi --libcargo test -p warp-core --lib observationcargo test -p warp-wasm --lib --features enginecargo clippy -p warp-core --all-targets -- -D warnings -D missing_docspnpm docs:buildpnpm docs:buildsucceeds with the existing local Node engine warning (v25.9.0vs requested>=18 <25).Summary by CodeRabbit
New Features
Documentation