Skip to content

Commit ff1eb58

Browse files
sean-parentclaude
andcommitted
fix(property-model): document TypeMismatch convention, reserve adj fields, polish docs
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 62529b3 commit ff1eb58

6 files changed

Lines changed: 32 additions & 6 deletions

File tree

property-model/src/cell.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ new_key_type! {
1414
}
1515

1616
/// Internal storage for a single value cell; fields are used by `Sheet` (added in a later task).
17-
#[allow(dead_code)]
1817
pub(crate) struct CellData {
1918
/// The type-erased current value.
2019
pub(crate) value: Box<dyn Any>,

property-model/src/error.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,14 @@ use std::any::TypeId;
66
#[derive(Debug)]
77
#[non_exhaustive]
88
pub enum Error {
9-
/// A value's `TypeId` did not match the cell's registered `TypeId`.
9+
/// A value's TypeId did not match the cell's registered TypeId.
10+
///
11+
/// - `expected`: the TypeId registered when the cell was created.
12+
/// - `found`: the TypeId of the value or declaration supplied by the caller.
1013
TypeMismatch {
11-
/// The expected type ID.
14+
/// The TypeId registered when the cell was created.
1215
expected: TypeId,
13-
/// The actual type ID found.
16+
/// The TypeId of the value or declaration supplied by the caller.
1417
found: TypeId,
1518
},
1619

@@ -61,6 +64,24 @@ impl std::error::Error for Error {
6164
mod tests {
6265
use super::*;
6366

67+
#[test]
68+
fn type_mismatch_fields_convention() {
69+
use std::any::TypeId;
70+
let expected = TypeId::of::<i32>();
71+
let found = TypeId::of::<f64>();
72+
let e = Error::TypeMismatch { expected, found };
73+
match e {
74+
Error::TypeMismatch {
75+
expected: e,
76+
found: f,
77+
} => {
78+
assert_eq!(e, TypeId::of::<i32>());
79+
assert_eq!(f, TypeId::of::<f64>());
80+
}
81+
_ => panic!("wrong variant"),
82+
}
83+
}
84+
6485
#[test]
6586
fn type_mismatch_display_contains_type_mismatch() {
6687
let err = Error::TypeMismatch {

property-model/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
//!
1111
//! # Example
1212
//!
13-
//! ```rust,ignore
13+
//! ```rust
1414
//! use property_model::{Sheet, Method};
1515
//!
1616
//! let mut sheet = Sheet::new();

property-model/src/planner.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@
44
//! strength (write-recency clock value) of the method's output cells — preferring to
55
//! derive cells that were written least recently. Phase 2 runs Kahn's algorithm to
66
//! produce a dependency-ordered execution sequence.
7+
//!
8+
//! The greedy Phase 1 selection is per-relationship with no global optimality guarantee;
9+
//! it minimises the minimum output-cell strength locally but does not guarantee that the
10+
//! globally strongest cell is preserved across the whole sheet. A future model checker
11+
//! will verify solvability.
712
813
use std::collections::{HashMap, HashSet, VecDeque};
914

property-model/src/relationship.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@ impl Method {
111111
}
112112

113113
/// Internal storage for a relationship; fields are used by `Sheet` (added in a later task).
114-
#[allow(dead_code)]
115114
pub(crate) struct RelationshipData {
116115
pub(crate) methods: Vec<Method>,
117116
/// Union of all cell IDs referenced by any method in this relationship.
117+
#[expect(dead_code, reason = "adj is reserved for the future model checker")]
118118
pub(crate) adj: Vec<CellId>,
119119
}
120120

property-model/src/sheet.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ impl Sheet {
221221

222222
/// Runs the planning pass and executes the selected methods.
223223
///
224+
/// Clears the changed-cell set from the previous `propagate()` call before planning.
224225
/// After propagation, call [`Sheet::changed`] to inspect which cells were updated,
225226
/// and [`Sheet::clear_changed`] when done.
226227
///

0 commit comments

Comments
 (0)