Repository navigation
Description
Timing: Follow-up after trial/3 merges into main; defer implementation until then.
Review baseline: Local trial/3 at a094418baf6388e3eeca23821df481a7f0a8751c. This branch is not yet on the remote. Source locations below refer to that snapshot and should be rechecked after merge.
Problem
account_keys accepts separate object, array, added, and removed booleans. Valid combinations depend on caller knowledge, while the signature permits contradictory combinations. No incorrect current call was established; this is a maintainability and invariant-expression concern.
Evidence
crates/lib/src/data/mutation.rs:190-198: call assembled from several state flags.crates/lib/src/data/mutation.rs:231-288: branching over four booleans and container-transition state.
Acceptance criteria
- Express meaningful container shape and mutation outcome through enums or another representation that makes invalid combinations difficult to construct.
- Preserve accounting, overflow/error precedence, atomic mutation guarantees, and dense/sparse conversion behavior.
- Verify representative insert/remove/no-change and object/array transition cases.
- Keep genuinely independent capability flags as booleans; do not mechanically replace every collection of flags.
Code examples and suggested direction
Possible private state model:
#[derive(Clone, Copy, Debug)]
enum ContainerBefore {
Missing,
Object,
Array,
}
#[derive(Clone, Copy, Debug)]
enum MembershipChange {
Unchanged,
Added,
Removed,
}Then replace the boolean bundle with meaningful inputs:
fn account_keys(
before: ContainerBefore,
membership: MembershipChange,
final_length: usize,
step: &Step,
change: &mut Change,
) -> Result<()> {
// Port the existing accounting rules through an exhaustive match.
// The body must be implemented from the current decision table.
}The signature is a design sketch, not complete compilable replacement code. Scalar traversal must still fail before accounting.
Activity
cblanquera commentedon Oct 26, 2026
Suggested investigation and fix notes
Deferred until
trial/3is merged intomain. Recheck the merged source and tests first. The snippets are examples/proposals, not an approved patch or a change to frozen contracts.Preparation::inspectbefore replacing flags: existing object/array/missing intermediate; membership added/removed/unchanged; final object/array; leaf versus ancestor; root versus nested container.Unchangedmeans: membership can be unchanged even when a payload is replaced. Preserve separate payload accounting.account_keys. Avoid an enum-to-booleans-to-enum round trip or new validation that changes existing error precedence.Observable regression example:
Add boundary/accounting cases to existing
data_contracts; runcargo test -p stackpress-lib --test data_contracts --locked. Independent capability booleans elsewhere are outside this focused refactor.Implementation workflow: After the merge, follow
.agents/workflows/rust-programming.md: prove the affected behavior, complete the three test-verified review rounds, and record relevant formatting/lints/docs, feature/platform scope, and applicable development coverage. Preserve unrelated changes.cblanquera commentedon Oct 26, 2026
Fixed on
trial/3in 644795f (merged as 64a5b70, task 00010 lane 1; not yet onmain, so leaving open).Coordinator-verified: fmt, Clippy -D warnings, Rustdoc -D warnings,
cargo +1.96.0 check, 454 workspace tests, 856 doctests pass; lib production coverage 93.64%.Fix owner review issues #11, #1, #2, #5 and lib parts of #4, #7 (task…