Repository navigation
Description model, canonical writer and section digests (Stage 1, PR 4) - #187
Merged
Merged
Conversation
Stage 1 design PR 4: Description model built from reader-accepted documents, canonical bytes of experiment-v1 section 9.1, round trip and idempotence on every valid and transition fixture, section digests (v18 = v01; v16 and v21 digests equal v01). Not used by any run yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm # Conflicts: # CHANGELOG.md
guijacquemet
pushed a commit
that referenced
this pull request
Nov 7, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Scma6W3LC11s3qjXHZuGDm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Design PR 4 of the Stage 1 design (section 3 modules, section 5 row 4). All additive; no run, notebook or CLI uses it yet.
description.py: theDescriptionmodel (Condition,Channel,Repeat,Member,Unit,Mask), built only from a document the strict reader accepted.description_from_bytes(data)reads withread_description_bytesand raisesDescriptionErrorcarrying every issue of the first failing phase. Arrays whose order is not semantic are held sorted (so model equality is file meaning); unitchannelskeep their order; optional fields stayNonewhen not written, and absent is kept distinct from[].description_write.py:canonical_bytes(model)per Spec experiment-v1 9.1 (UTF-8, LF, final newline, no comments, entries sorted in code point order, fields in the Spec's table order taken fromdescription_rules, bare or basic-quoted keys, minimal escapes, emptymasksomitted). Nothing is defaulted:confirmed_onis written as the model holds it (4.4a).section_digests(model)gives the SHA-256 ofconditions,channels,repeats,maskswith everydisplay_name,target,treatment_keyomitted;used_idsis not a section.purein the code-rules layers; CHANGELOG and AGENTS.md repo map.Why: groundwork for publication (PR 5), which writes the model and re-reads the exact bytes.
Decision for the owner (Spec ambiguity)
Spec 9.3 does not define the byte form of one section alone (the Spec's own
refval.pyflags this as AMBIGUITY and hashes the writer's output for a document holding only that section, with a dummyschema). Here a section digest is the text the file holds for that section (its table blocks, each followed by a blank line), nothing else; an empty section is the empty string. Digest values therefore differ fromrefval's. Nothing consumes them yet; the Spec should state the byte form before a consumer keys a cache on them.Tests (
tests/test_description_write.py, 158 tests)parse(write(parse(F)))equalsparse(F)(model and parsed file, unordered arrays sorted, empty optional table dropped) on all 36 valid and 12 transition fixtures; writing is idempotent; the bytes re-read with no error and the same warnings; layout checks of 9.1.v18model ==v01model and canonical bytes equal;v16andv21differ fromv01as models but have all four section digests ofv01.source_foldermoves onlyconditions; a unit's channel order moves onlyrepeats; dropping areferenceleaveschannelsandrepeats; a longerused_idsmoves none.DescriptionErrorcarries the phase and issues.Result on the old code: the modules do not exist on
main, so the test module fails at collection (ImportError); verified by running it against the tree of PR #186 (collection error).Checks
python tools/check.py: 3679 passed, 4 skipped (case-insensitive file system x3, file-mode permissions x1; none are Spec tests), 2 warnings; Ruff and code rules clean. Branched frommain(93b3c4c), independent of #186 (it only needsv01,v16,v18,v21, present in both pins).Generated by Claude Code