Skip to content

Read '<class>.<field>' from a flat document's top level through the switch window - #599

Merged
jesshaley merged 2 commits into
V2from
claude/class-prefixed-reads
Dec 3, 2026
Merged

jesshaley merged 2 commits into
V2from
claude/class-prefixed-reads

Conversation

@jesshaley

@jesshaley jesshaley commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Draft. Builds one decision for the flat-layout switch (did-schema #414).

Decision built

did-schema docs/plans/did_v2_go_forward_class_audit.md, Decided by Jess Haley, 2026-12-03 [class-prefixed reads through the switch window], tracked in Waltham-Data-Science/DID-schema#414: during the flat-layout switch window, did2.document/get('<class>.<field>') and DID-matlab queries also read a flat document's top-level <field> when <class> is in the document's class chain (its class or a superclass), read-only, as [base.id read through the switch window] does for base.id; removed with the switch (step 10). On a nested document nothing changes.

Every piece of code added is marked with the tag and "removed with the switch (step 10)".

Changes

  • did2.document.classPrefixedRest(doc, path) (Static, Hidden): the path without its first segment when the document is flat (top-level id and document_class, no base, the shape idOf reads as flat), the first segment (no [*]) is the document's class_name or one of its superclasses (the header the document carries; no schema is read), and the document has no top-level field of that name; else ''.
  • did2.document/get: reads that path after the existing base.id and base.session_id aliases. set is unchanged (writes the literal path).
  • did2.query walkPath: the same, for a document (not a hasanyelement element, which has no document_class), after the base.id alias. Every operator reads through walkPath.
  • did2.database.compileQuery ('Flat' only, as the base.id alias is): a positive term whose first segment is a class some stored chain holds (PresentClasses; any first segment when not given) compiles to (path as written) OR (rest AND no base AND no field named <class> AND isa <class>); a negated one to 1=1. Both are counted inexact, so sqlitedb rechecks with the evaluator; neither leads (canLead). The nested compile is unchanged.
  • testBuildFlatLayoutReadBoth/testQueryReadsBaseIdOfAFlatDocument asserted that entity.local_identifier does NOT match a flat entity; that assertion is now the decided match (verifyTrue).

Tests

  • New testClassPrefixedFlatReads (struct documents, no schema): nested document unchanged (its block; still missingField with no block, even with a top-level field of that name); flat read through the class and a superclass (entity.local_identifier, entity.type.node, base.name, statement.variable.name, value.external), in get, query and resolvePath; a class not in the chain is not read (statement.local_identifier); a hasanyelement element is not aliased; a top-level field named like a class (the kind cell term) is read literally; set writes the literal path; compileQuery flat vs nested vs not-a-present-class vs base.id.
  • testSqliteDbFlatLayout: nine class-prefixed queries added to the database-vs-evaluator agreement list, and a search test (demoA.value finds the flat demoA documents only, inexact).

Not covered by the decision (reported, not built)

  • term.value on the flat kind-cell schema. On the nested schema term.value is the term kind block's value cell. On the flat kind-cell schema (did-schema testBatchPassWiring: divergence rows for withMintSource and earliestByContent #469) that cell is the top-level field term, and there is no top-level value. The decision maps <class>.<field> to top-level <field>, i.e. term.value -> value, which does not exist; and because the document has a top-level field named term, term.<x> is read literally inside the cell. So get('term.value') still fails on a flat term statement. Mapping <kind>.value to the kind cell would be a rename, not the decided read; it needs a decision (or the callers move to did2.schema.cache/valueCellIn).
  • A first segment that is both a class in the chain and a top-level field (kind cells term, mass, ...; method on an interaction) is read literally, never through the alias. This follows from "read-only, exactly as base.id" (the base.id alias applies only when there is no base), but it is a choice; flagged.
  • <class>.<field> reads the top-level <field> whatever class declares it (demoA.name reads base's name): the read uses the document's chain, not the schema's per-class field lists.
  • sqlitedb.searchValues / searchJson / jsonById path lists read the paths literally (not get or query); not changed.

Proposed (not decided)

  • The name did2.document.classPrefixedRest (Hidden).

Runs (head ff38bb8)

did-schema main (nested):

  • Test code run 47156394462 (job 144431471876): unit suite 2926 run, 2877 passed, 0 failed, 49 incomplete (the 12 testClassPrefixedFlatReads tests and the new testSqliteDbFlatLayout test pass); did.unittest 709 of 709. Corpus jobs were skipped by the plan job.
  • Push runs (started before the did-schema mirror branch existed, so they read main; logs: "did-schema has no branch 'claude/class-prefixed-reads' -- FALLING BACK to main"): did2.build tests 47156257026, 439 run, 439 passed, 0 failed; Quick migrator tests 47156257024, 2926 run, 2877 passed, 0 failed, 49 incomplete. Fixture corpus and Codespell passed.

Flat kind-cell schema (did-schema mirror branch claude/class-prefixed-reads = claude/flat-readers head 8a944406; logs: "did-schema HAS branch 'claude/class-prefixed-reads' -- using it"). This branch is from V2 (a783e0e), not from #597, so the baseline is V2's own flat run (47128920249: 141 of 438):

https://claude.ai/code/session_01FxKLA8Tbf9cpvDe7fuVeKf


Generated by Claude Code

…witch window

did-schema docs/plans/did_v2_go_forward_class_audit.md, Decided by Jess
Haley, 2026-12-03 [class-prefixed reads through the switch window]
(Waltham-Data-Science/DID-schema#414): during the flat-layout switch
window, did2.document/get('<class>.<field>') and did2.query also read a flat
document's top-level <field> when <class> is in its class chain, read-only,
as [base.id read through the switch window] does for base.id. Removed with
the switch (step 10). A nested document reads as before.

- did2.document.classPrefixedRest (Static, Hidden): the path without its
  class segment, for a flat document (id, document_class, no base) whose
  header's class_name or superclasses holds the segment and which has no
  top-level field of that name; '' otherwise. get() reads it after the
  base.id and base.session_id aliases; set() is unchanged.
- did2.query walkPath reads it for a document (not a hasanyelement element).
- compileQuery 'Flat': a positive term whose first segment is a present
  class compiles to (path as written) OR (rest, no base, no field named
  the class, isa the class); a negated one to 1=1. Both inexact (recheck).
- testBuildFlatLayoutReadBoth: the assertion that
  entity.local_identifier does not match a flat entity is now the decided
  match.
- Tests: testClassPrefixedFlatReads (nested unchanged, chain read, class
  not in chain, kind cell read literally, set unaffected, compileQuery);
  testSqliteDbFlatLayout agreement queries with class-prefixed paths.

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 23:30
@jesshaley
jesshaley merged commit 9e6f85f into V2 Dec 3, 2026
12 checks passed
jesshaley pushed a commit that referenced this pull request Dec 3, 2026
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.

2 participants