Skip to content

bert#88 polish: protect the mode byte-stability sentinel + document kernel().things dedup #97

Description

@rsthornton

Non-blocking follow-ups from PR #92 review (rounds 3–4):

1. WorldModel.mode is pub but doc says "never access directly."
The field is the serialization sentinel: None ≡ Full and emits no key (byte-stable). A downstream write of model.mode = Some(Mode::Full) would silently break byte-stability. pub(crate) isn't viable as-is (the bert and bert-compose crates construct WorldModel { mode: None, .. } via struct literal, which requires the field to be pub). Options: a constructor / builder that defaults mode to None, or a typestate that makes the sentinel unforgeable. Until then the field-level doc is the only guard.

2. kernel().things can contain duplicate Ids if the model wasn't validated first.
Duplicate entity Ids are caught by validate()'s check_duplicate_ids, not by kernel(). The dep field already documents its multiset semantics; things should get the analogous one-liner: "duplicates are possible on an unvalidated model — call validate() first, or dedup at the consumer if set semantics are needed."

3. (trivial) check_dynamical_face uses .trim().is_empty().
Defensive against whitespace-only slots; if UI strings are always pre-trimmed, plain .is_empty() is cheaper. Leave unless it shows up in a profile.

Refs bert#88, PR #92.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions