Skip to content

[codex] Harden reading artifact posture#319

Open
flyingrobots wants to merge 1 commit intomainfrom
feature/reading-artifact-hardening
Open

[codex] Harden reading artifact posture#319
flyingrobots wants to merge 1 commit intomainfrom
feature/reading-artifact-hardening

Conversation

@flyingrobots
Copy link
Copy Markdown
Owner

@flyingrobots flyingrobots commented Apr 29, 2026

Summary

  • Adds explicit ReadingResidualPosture values for residual, plurality, and obstructed alongside the existing complete posture.
  • Mirrors the posture vocabulary through warp-core conversion and adds ABI/core/WASM coverage so consumers can distinguish bounded reading posture from generic state payloads.
  • Updates the public observation/ABI docs to describe the reading-envelope posture surface and current ABI version.

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 -- --check
  • cargo test -p echo-wasm-abi --lib
  • cargo test -p warp-core --lib observation
  • cargo test -p warp-wasm --lib --features engine
  • cargo clippy -p warp-core --all-targets -- -D warnings -D missing_docs
  • pnpm docs:build
  • pre-commit staged crate verification
  • push-time full local verification lanes: fmt, guards, clippy-core, tests-runtime, tests-warp-core, rustdoc

pnpm docs:build succeeds with the existing local Node engine warning (v25.9.0 vs requested >=18 <25).

Summary by CodeRabbit

  • New Features

    • Observation artifacts now support four reading posture types—complete, residual, plurality, and obstructed—enabling more precise characterization of reading outcomes, bounded readings, and constraint observations.
  • Documentation

    • ABI contract updated from v6 to v7. Specifications clarified to formalize the reading envelope as part of the read contract, documenting observer plans, basis and residual posture tracking.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 29, 2026

📝 Walkthrough

Walkthrough

The PR extends the ReadingResidualPosture enum with three new variants (Residual, Plurality, Obstructed) to classify non-clean reading outcomes. Updates span the ABI definition, core observation model, conversion logic, tests, and documentation. ABI contract version increments from 6 to 7.

Changes

Cohort / File(s) Summary
ABI Enum Extension
crates/echo-wasm-abi/src/kernel_port.rs
Added Residual, Plurality, Obstructed variants to ReadingResidualPosture; updated Complete variant documentation to emphasize "clean" complete reading.
ABI Wire Format Validation
crates/echo-wasm-abi/src/lib.rs
New unit test validating CBOR encoding/decoding round-trip for all four ReadingResidualPosture variants.
Core Observation Model
crates/warp-core/src/observation.rs
Mirrored ReadingResidualPosture enum extension; expanded to_abi() method to convert all variants to ABI equivalents; added test assertions for default artifact posture and conversion coverage.
Kernel Test Coverage
crates/warp-wasm/src/warp_kernel.rs
Extended ABI imports; added equality assertions in observe_frontier_head_matches_current_head test to validate observation artifact reading fields (CommitBoundaryHead plan, Worldline basis posture, Complete residual posture).
Documentation & Specification
docs/BEARING.md, docs/spec/SPEC-0004-worldlines-playback-truthbus.md, docs/spec/SPEC-0009-wasm-abi.md
ABI version bump 6→7; clarified reading envelope structure and semantics; documented new residual posture classifications for bounded/plurality/obstructed readings.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Suggested labels

tooling

Poem

Postured reads in triplicate, clear and bounded,
From ABI contracts, newly founded,
Residual, plurality, obstruction marked—
The observation reading leaves its ark. 📦

🚥 Pre-merge checks | ✅ 5
✅ 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 accurately reflects the primary change: adding explicit posture variants to the ReadingResidualPosture enum to harden reading artifact representation across the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 85.71% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/reading-artifact-hardening

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.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

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

@flyingrobots flyingrobots marked this pull request as ready for review April 30, 2026 01:31
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 30, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #320

coderabbitai Bot added a commit that referenced this pull request Apr 30, 2026
Docstrings generation was requested by @flyingrobots.

* #319 (comment)

The following files were modified:

* `crates/warp-core/src/observation.rs`
Copy link
Copy Markdown
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: 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

📥 Commits

Reviewing files that changed from the base of the PR and between a9dfb0b and 5f5fa67.

📒 Files selected for processing (7)
  • crates/echo-wasm-abi/src/kernel_port.rs
  • crates/echo-wasm-abi/src/lib.rs
  • crates/warp-core/src/observation.rs
  • crates/warp-wasm/src/warp_kernel.rs
  • docs/BEARING.md
  • docs/spec/SPEC-0004-worldlines-playback-truthbus.md
  • docs/spec/SPEC-0009-wasm-abi.md

Comment on lines +611 to +632
#[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);
}
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

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"),
];
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.

Comment on lines +1283 to +1296
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
);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Suggested change
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).

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.

1 participant