Learning

AI Field Guide

CS-07 · Use the Representation That Carries the Relationship

Downloads

Aliases: ZST; sized state; Sized; PhantomData; private field; consuming transition; affine; sealing; constructor.

State carriers may own validated input, resource borrows, transactions, observations or prepared outcomes. Encapsulate that data when it is part of the guarantee. Use a zero-sized marker for a data-free distinction; do not externalize required data merely to meet a zero-size target. ZSTs also implement Rust's Sized; size is not the doctrine's criterion.

Data-bearing reference state (private fields retain this actual workshop and subject):

pub struct Verified<'a, P, E> {
    workshop: &'a mut Workshop<Google<P>, WithoutPassword, E>,
    subject: String,
}

Control construction and mutation where a value permits protected progression. A public unchecked constructor, conversion, Default, deserializer or clone can undermine that boundary. Consuming non-copyable values restricts local reuse; Rust permits dropping values and does not thereby guarantee that a business obligation finishes.

Seal a capability surface when arbitrary implementations would forge the relationship. Keep intended trusted adapter or substitution ports open when that is their job. Orphan rules are not sealing. Privacy protects the chosen source boundary, not a repository from someone authorized to change it. Do not wrap harmless getters or incidental algorithm steps in ceremonial stages.

Related: CS-06, CS-08, CS-12.

Your Reflection

Navigation