Skip to content

checkRules: one_kind_cell (exactly one kind cell per statement, matching its kind) - #596

Merged
jesshaley merged 4 commits into
V2from
claude/one-kind-cell-rule
Dec 3, 2026
Merged

jesshaley merged 4 commits into
V2from
claude/one-kind-cell-rule

Conversation

@jesshaley

@jesshaley jesshaley commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Draft. Siblings first for [a quantity cell is named for its kind] (did-schema #414): did2.build learns the named rule "exactly one kind cell per statement, matching its value-kind superclass" before did-schema declares it (did-schema #469, step 8). It checks nothing until a class declares it, so no output changes on did-schema main.

Decision built

did-schema docs/plans/did_v2_go_forward_class_audit.md, Decided by Jess Haley, 2026-12-02 [a quantity cell is named for its kind]: "... exactly one kind cell per statement, matching its value-kind superclass (a rule) ...". Amended 2026-12-03 by [external is declared on value, not in the kind cell] (the flag is beside the cell, so it is not a cell).

Changes

file change
+build/private/checkRules.m New rule one_kind_cell. A cell is a field named value or named for a value kind (a class descending from value), at the top level of a flat document or directly in a block of a nested one. The document holds at most one, and that one is the cell cache.valueCellField(class, kind) names for its value kind (in that kind's block when nested). A cell embedded in another (a dose ingredient's mass) is part of that cell. checkRules takes a fifth argument, the blocks as built, because ruleView renames the cell to value for the other rules
+build/document.m Passes the blocks as built to checkRules
+build/Contents.m Lists the rule
tests/+did2/+unittest/testBuildOneKindCell.m (new) On the loaded schema and, when it is nested, its flat kind-cell copy (flatLayoutSchema, 'KindCells', true). Each is copied twice: voltage gains a stand-in field named mass (another kind's name), and in one copy value also declares the rule. Checked: its own cell alone builds; value in bodies with no cell builds; own cell plus mass is refused ("exactly one kind cell"); mass alone with the value in bodies is refused ("must match the value kind"); with the rule undeclared both build; a term assertion and a clock_alignment (kind polynomial in its own chain) build. Denominator printed

No existing test is edited.

Needs a decision

  • The rule's name. one_kind_cell is Proposed (not decided). did-schema testBatchPassWiring: divergence rows for withMintSource and earliestByContent #469 must declare it under the name this PR checks; a different name is refused by did2.build (did2:build:unknownRule).
  • "Exactly one" when the value is not inline. A statement whose value is in data bodies (external true) or in a shared value document (value_id) has no cell, since the builder omits absent fields. As built, the rule refuses a second cell or a cell of the wrong kind, and leaves "is the value anywhere" to value_inline_or_body. If "exactly one" should also mean "the cell key is always present" (blank when the value is elsewhere), that is a change to the builder's output and to value_inline_or_body.
  • Where it is declared. The test declares it on value (every value kind, and every statement through its kind). Declaring it on statement instead would leave shared value documents unchecked.

Runs

https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf


Generated by Claude Code

[a quantity cell is named for its kind] (Jess Haley, 2026-12-02, did-schema
docs/plans/did_v2_go_forward_class_audit.md): "exactly one kind cell per
statement, matching its value-kind superclass (a rule)". Siblings first: the
builder learns the rule before did-schema declares it (#469); it checks
nothing until a class declares it. The name one_kind_cell is Proposed.

A cell is a field named `value` or named for a value kind, at the top level
of a flat document or directly in a block of a nested one. At most one, and
that one the cell valueCellField names for the document's kind. An absent
cell (value in bodies, or in a shared value document) is
value_inline_or_body's question, not this rule's. checkRules takes the
document as built (before ruleView renamed the cell to `value`) as a fifth
argument.

testBuildOneKindCell: on the loaded schema and, when it is nested, its flat
kind-cell copy; each copied twice (a stand-in field named for another kind,
with and without the rule declared on `value`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
'this document holds %d: %s.'], expected, named, numel(found), ...
strjoin(strcat('`', found, '`'), ', ')));
end
if numel(found) == 1 && ~strcmp(found{1}, expected)
claude and others added 3 commits December 3, 2026 14:57
The first push failed every build with
MATLAB:functionValidation:MismatchBetweenBlockAndLine (run 47131868427).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf
@jesshaley
jesshaley marked this pull request as ready for review December 3, 2026 21:58
@jesshaley
jesshaley merged commit 07e4606 into V2 Dec 3, 2026
12 checks passed
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.

3 participants