Repository navigation
S1: view envelope, dataQuality views, producer - #22
Merged
neuromechanist merged 21 commits intoNov 23, 2026
Merged
neuromechanist merged 21 commits into
neuromechanist merged 21 commits into
Conversation
CI and the typo check now also run on pull requests into feature/** branches, so PRs into an integration branch get the gates. Not tested locally (workflow trigger only).
The digest of a view declaration: SHA-256 of its RFC 8785 canonical JSON. Normative text in docs/views/view-digest.md, the Python reference neuroschema.views.view_digest, and 8 cases plus 4 refusals in views/vectors/view-digest.v1.json, whose canonical texts were computed with ECMAScript JSON.stringify. Tested: pytest (432 passed in 0.99s).
schema/definitions/view.schema.json defines $defs/view: the envelope every view meets, with registered kinds also checked against their own schema and unknown kinds passing on the envelope. Adds kind.nemar.table.v1, views/registry.json (kinds, algorithms, formats, reserved dimensions, caps), the registry reader and renderer rule, and the view name types and recipe producer in processingTypes. The anchor and folder-ref tests now cover schema/views/. Tested: pytest (546 passed in 1.56s).
Breaking: a record-level dataQuality entry requires views (at most 32 view declarations) in place of figures, and $defs/figure is removed. figures leaves the checkpointName examples. The record example declares a nemar.table view, which is also the table_view digest vector. Tested: pytest (558 passed in 1.67s).
qualityMetric names exactly one producer, plugin or recipe (oneOf), so a recipe's own metric names its recipe. Previously valid metrics stay valid. The record example's floor metrics are recipe metrics. Tested: pytest (563 passed in 1.70s).
Breaking: a dataset-level dataQuality distribution requires unit and may carry description, so a dataset summary prints the producer's own text. The dataset example states both. Tested: pytest (568 passed in 1.72s).
New docs/views.md (vocabulary, renderer rule, data roles, dimensions, inputs, scope, formats, caps, versioning, what digests prove); processing-extensions.md drops figures and the figures checkpoint and lists the writer's metric-name and view rules; README tree and CHANGELOG Unreleased. Tested: typos clean.
draw_as draws an unknown kind by its base only when its data meet the base's role contract from the registry (each listed role once, a listed format, only listed dims); otherwise, and for a base without a base version, it falls back to a table instead of raising. docs/views.md states the contract and adds the rule for writers and renderers. Tested: pytest.
roles.<role>.dims in the registry are the dimensions a role may carry, empty meaning none; docs/views.md says so. nemar.table v1 now refuses dims on its role, so the schema agrees with the registry. New tests derive each kind's roles, formats and dims from its schema and compare them with the registry, and tie reserved_dims.time.unit to the schema's const s. Dimension tests move to an unknown kind. Tested: pytest.
qualityMetric and processing-extensions.md now say that a plugin manifest's metric outputs name the producer with plugin, and that recipe is for a metric a recipe writes into its own records. Description text only; nemar-cli N1b narrows the manifest itself. Tested: pytest.
view-digest.md: a JavaScript implementation checks strings and member names with isWellFormed and numbers with Number.isFinite before writing, because JSON.stringify escapes a lone surrogate and prints a non-finite number as null instead of failing. Doc only.
load_registry raises a FileNotFoundError that names views/registry.json and says neuroschema reads it from a checkout, like schema/; the registry is not shipped as package data because schema/ is not either and consumers vendor both from the repository. Tested: pytest.
The digest input is I-JSON (RFC 7493). neuroschema.views.parse_declaration reads a declaration from text with an object_pairs_hook that refuses a repeated name at any depth, and refuses the NaN and Infinity literals Python accepts. view-digest.md states the rule and that JavaScript needs its own check, since JSON.parse keeps the last member. Vectors gain the refusals duplicate_member_name and nan_literal; the 8 cases are unchanged. Tested: pytest.
Unreleased now names the table kind's no-dimensions rule, I-JSON input and parse_declaration for the digest, and the base role contract in draw_as. Doc only.
The NaN and Infinity literals are refused by parse_declaration itself; through view_digest a NaN would also fail at canonicalization, so the parse rule needed its own test. Tested: pytest.
meets_role_contract now validates each base-role entry with jsonschema against the base kind schema's data.items, or the oneOf/anyOf branch for that role (new role_schemas), so formats, dims and required fields such as a table's columns come from the one schema. A view declaring base nemar.table without columns now falls back to a table. Tests: a no-columns breach, a throwaway base kind that requires a freq dim (a preset without it falls back), and a two-role oneOf base. docs/views.md states the contract, and that a TypeScript renderer validates with ajv. Tested: pytest.
docs/views.md: a view drawn by its base also offers every other file in its data for download, and no view hides data however it is drawn. Doc only.
parse_declaration accepts a str, or bytes that decode as strict UTF-8; it refuses a byte order mark, UTF-16 and UTF-32 (which json.loads would detect and accept), other input types and text that is not JSON, all as CanonicalizationError. view-digest.md states the I-JSON encoding rule. Tested: pytest.
Unreleased names the schema-based role contract and strict UTF-8 declaration text. Doc only.
docs/views.md: a TypeScript renderer validates a base-role entry against the base kind's schema with ajv, or with guards held to neuroschema's verdict corpus, since the website cannot run ajv everywhere. Doc only.
Throwaway fixture kinds cover the three untested guards in registry.py: an enum role branch (in an anyOf base, both enum roles map to one branch and each must be present), a role that is neither const nor enum (refused), and a role in two branches (refused, for a const and an overlapping enum). registry.py is at 100% line coverage. Tested: pytest (616 passed).
Contributor
Author
|
Review: r1 code+tests+types+comments, 1 Important, 2 Moderate, 1 Suggestion, 2 residuals, all fixed; r2 delta: base contract tightened to validate against the base kind schema, required dims, no hidden files, strict UTF-8, all fixed (abb007d..6b44ef0); follow-up c96067f, 4ebfcdf (ajv-or-guards wording, guard tests, registry.py 100%). Verified on 4ebfcdf: full pytest passes locally, CI green on all five jobs. Merging into the 0.6.0 integration branch. |
This was referenced Nov 23, 2026
Merged
neuromechanist
added a commit
to nemarOrg/nemar-cli
that referenced
this pull request
Nov 24, 2026
* ADR 0137: amend for neuroschema 0.6.0 review Records what the neuroschema 0.6.0 adversarial pass settled (nemarOrg/neuroschema#22-#30): scalp map rules, placement words, position bounds, labels, sensors_mismatch and envelope rules. Index line updated. Tested: adr-index unit test and lint pass. * ADR 0137: address round-1 review Corrects decisions 1 and 3 in place (bad-segment rule, 8 sensors, parity bound, nine label reasons) and reworks the 2026-11-24 amendment per the review: placement words with frame_unknown and unused_positions, cap_model and reference carrier, reference scope, eegprep differences, full I-JSON, location, size and format rules, scoped table_location_mismatch, exact sensors_mismatch conditions and the other review rulings. Index lines updated. Tested: adr-index unit test and lint pass. * ADR 0137: address round-2 review Scopes no_shaded_rows to activation views and corrects which label reason is new. Tested: adr-index unit test and lint pass.
6 of 9 tasks
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.
S1 of the neuroschema 0.6.0 view vocabulary (#21), part of epic nemarOrg/nemar-cli#2324.
Quality views replace stored figures: a view is data a browser draws, declared with a namespaced, versioned kind.
This PR merges into the integration branch
feature/issue-21-views-0.6.0; the version bump and the[0.6.0]changelog heading wait for S5.What changes
ci.ymlandtypos.ymlalso run on pull requests intofeature/**.docs/views/view-digest.md(normative),neuroschema.views.view_digest(Python reference),views/vectors/view-digest.v1.json(8 cases, 4 refusals).schema/definitions/view.schema.json($defs/view, closed),schema/views/kind.nemar.table.v1.schema.json,views/registry.json(neuroschema.views-registry.v1),neuroschema.views(registry reader, renderer ruledraw_as), andviewKey,kindName,transformName,roleName,dimName,formatName,recipeinprocessingTypes.views(at most 32);$defs/figureis removed;figuresleaves thecheckpointNameexamples.qualityMetricnames exactly one producer,pluginorrecipe(oneOf). Previously valid metrics stay valid.unitand may carrydescription.docs/views.md,docs/processing-extensions.md, README tree, CHANGELOG[Unreleased].The envelope's open/closed balance: every declaration meets the closed envelope; a
(kind, kind_version)the registry lists is also checked against its own schema through anif/then$ref; any other kind or version passes on the envelope alone, and a renderer draws it by its base or as a table.Gates
uv run ruff check .anduv run ruff format --check .uv run pytest tests/ --cov: 568 passed (401 before);neuroschema.viewsat 100% line coveragetypos .: cleanschema-validateloop, extended locally toviews/)build-vendor.mjsdoes and compiled with ajv 2020 (strict: false, as nemar-cli); both examples validate and all 15 probes (unknown kind accepted, wrong table role, no data or inputs, reserved scope withoutsources, recording scope withsources, serving store with a null digest, trailing newline in a key, TAB in a column name,timein ms,.jsonlocation fortsv, metric producers) agree with the Python validatorJSON.stringify(default UTF-16 key sort), and the Python reference reproduces all 8 cases and refuses all 4 refusals; number printing also matches all 24 RFC 8785 Appendix B valuesNot run, and why:
uv run --extra views pytest tests/test_views_reference.pyandgenerate_view_vectors.py --check: they start with S2 (theviewsextra, the reference renderer and the eegprep vectors do not exist yet).rfc8785package: its install was not permitted in my sandbox. The ECMAScript cross-check covers the same ground.Revert checks
Each rule below was removed or weakened in a scratch copy of the final tree, and the named test failed; the unmutated test passed first.
kindclosed to an enum of known kindsTestEnvelope::test_unknown_kind_passes_on_the_envelopeif/thendroppedTestEnvelope::test_known_kind_with_a_wrong_role_failsdata-or-inputsanyOfdroppedTestEnvelope::test_neither_data_nor_inputs_failssources(then) droppedTestEnvelope::test_reserved_scope_needs_sourcessources(else) droppedTestEnvelope::test_recording_view_has_no_sourcesbase/base_versiondependentRequireddroppedTestEnvelope::test_base_and_base_version_come_togethersourceoneOftoanyOfTestEnvelope::test_source_names_exactly_one_producerkindNamemaxLengthdroppedTestEnvelope::test_kind_name_lengthtransformNameversion suffix droppedTestInputs::test_transform_name_is_versionedtsv/jsonextension rule droppedTestViewData::test_known_format_matches_extensionTestViewData::test_column_name_has_no_tab_or_newlinetimein seconds droppedTestViewData::test_time_is_in_secondsTestInputs::test_serving_run_needs_the_store_digestfile/storeoneOftoanyOfTestInputs::test_input_is_exactly_one_of_file_and_storenemar.tableallows a baseTestTableKind::test_table_has_no_base_or_transformnemar.tableallows parametersTestTableKind::test_table_takes_no_parametersviewsnot requiredTestDataQualityViews::test_record_without_views_failsfiguresaccepted againTestDataQualityViews::test_record_with_figures_failsviewscap of 32 droppedTestDataQualityViews::test_at_most_32_viewsoneOftoanyOfTestMetricProducer::test_both_producers_failoneOfdroppedTestMetricProducer::test_no_producer_failsunitnot requiredTestDistributionUnit::test_distribution_without_unit_failsTestRegistry::test_kind_files_and_registry_match_one_to_oneTestRegistry::test_view_schema_checks_exactly_the_registered_kinds$pattern inschema/views/test_anchored_patterns_close_the_newline_gap$refinschema/views/test_refs_are_folder_qualifiedtest_digest_vectors_replay(5 of 8 cases)test_digest_vectors_replay(key_order_utf16)ensure_ascii)test_digest_vectors_replay(2 cases)reprtest_digest_vectors_replay(7 cases)test_digest_refusalsTestRendererRule::test_unknown_kind_draws_as_a_tableTestRendererRule::test_unknown_kind_with_a_known_base_draws_as_its_baseDeviations from the S1 plan
examples/dataset-ds002718-processing.json(each distribution statesunitanddescription, or the example fails);tests/test_processing_extensions.py(figure fixtures become views, the floor metrics a recipe producer, the folder-ref regex and the anchor glob coverschema/views/, the reachability set and the trailing-newline table gain the new files and types);README.mdand theextensionsContainerdescription (drop "figures");.github/workflows/typos.yml(the typo gate also runs onfeature/**).view.schema.json(621 lines).nemar-flooras producer (they were pluginnemar-dataqual), following C6.JSON.stringifyplus a key sort) is not committed, since a Python generator would check the reference against itself. The vectors file says how to replay them.Choices the plan left open (please confirm)
roleNameanddimNameare^[a-z][a-z0-9_]{0,63}$,formatNameis^[a-z][a-z0-9]{0,15}$, andtransformNameis a kind-style name plus.v1to.v999.kindNameandtransformNamealso getmaxLength: 128(C1 gave no length).sources(C1 only requires them for reserved scopes). Relaxing this later is a PATCH; adding it later would be breaking.nemar.tableversion 1 is exactly one TSV file in roletable, withcolumnsrequired, no base, inputs or transform, and emptyparameters.timedimension has units(C5), and atsvorjsonfile's location ends in.tsvor.json(carried over from the old figure rule). The caps stay in the registry only; the schema has nomaximumonsize.pathis described as the store's path when it is not the recording path, andgroupfollows^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$.content_sha256may benullonly withprofile: archive, per the owner's answer to open question 1.kindsis a list of{kind, kind_version, base, base_version, schema, roles: {role: {formats, dims}}};transformsandalgorithmsare lists of{name, spec, vectors};formatsmaps a name to{extension, media_type, grammar};reserved_dimsmaps a name to{unit, meaning};capshas the three C2 numbers. S2 to S4 add entries.JSON.parsereads it, rather than refusing it, so the Python and TypeScript implementations agree. Theintegers_beyond_binary64vector pins this.view.schema.json's root is a$defslibrary that constrains nothing, likeprocessingTypes; consumers validate against#/$defs/view.Update (review round 1)
The lead accepted the 8 open choices above as decisions. Head is now
a906ab7, with 8 new commits and no force-push.draw_asdraws an unknown kind by its base only when the view meets the base's role contract: each role the registry lists for the base appears exactly once indata, in a listed format, carrying only listed dims; extra roles are allowed. Otherwise it falls back to a table. Abasewithoutbase_version, or the reverse, now falls back instead of raisingKeyError. Newmeets_role_contract. Tests: a conforming view draws as its base; the roleframes/npy/no-columns view falls back; each breach (format, role twice, dims, no data) falls back; half a base falls back.docs/views.mdstates the contract in the renderer rule and adds it to the writer list, with the renderer's own check.cbd3091docs/views.md:roles.<role>.dimsare the dims a role may carry, empty meaning none.nemar.tablev1 refusesdimson its role. The dimension tests moved to an unknown kind. New tests derive each kind's roles, formats and dims from its schema (fromdata.items, or eachoneOf/anyOfbranch for multi-role kinds, which must constraindims) and compare them with the registry, and tiereserved_dims.time.unitto the schema's consts.77af283qualityMetricdescription (Moderate)processing-extensions.mdnow say that a plugin manifest's metric outputs name the producer withplugin, and thatrecipeis for metrics a recipe writes into its own records. The schema still accepts either; nemar-cli N1b narrows the plugin manifest toplugin.269c2baview-digest.md(Suggestion)String.prototype.isWellFormedand every number withNumber.isFinitebefore it writes, becauseJSON.stringifyescapes a lone surrogate and prints a non-finite number asnull.cd571e7REPO_ROOT = parents[3](Residual)load_registryraises aFileNotFoundErrorthat namesviews/registry.jsonand says it is read from a checkout. Package data is not simple here:schema/is not packaged either, hatchforce-includecovers wheels but not the editable installs CI uses, and nemar-cli vendorsviews/from the repository root.54f2719JSON.parsekeeps the last member. Newneuroschema.views.parse_declarationreads text with anobject_pairs_hookthat refuses a repeated name, and also refusesNaN/Infinityliterals. New refusal vectors:duplicate_member_name(nested) andnan_literal. The 8 cases are unchanged and still agree with ECMAScriptJSON.stringify.92490dc,a906ab7Also: changelog entries for the above (
dc73de3).Gates (round 1)
pytest --cov: 594 passed (568 before);neuroschema.viewsat 100% line coverageRevert checks (round 1)
test_unknown_kind_missing_its_base_contract_draws_as_a_tabletest_each_breach_of_the_base_contract_draws_as_a_table[format]test_each_breach_of_the_base_contract_draws_as_a_table[twice]test_each_breach_of_the_base_contract_draws_as_a_table[dims]view["base_version"](the oldKeyError)test_half_a_base_draws_as_a_tableTestTableKind::test_table_role_carries_no_dimstest_registry_roles_match_each_kind_schematest_registry_roles_match_each_kind_schematimeunit drifts from the schematest_reserved_dim_units_match_the_schematimeunit drifts from the registrytest_reserved_dim_units_match_the_schematest_missing_registry_is_namedobject_pairs_hook)test_digest_refusals[duplicate_member_name]NaNliteral accepted (noparse_constant)test_parse_declaration_refuses_non_json_literalsItems 3 and 4 change only descriptions and prose, so they have no revert check.
The first
NaNcheck was not caught throughtest_digest_refusals: without the parse hook, Python readsNaNas a float, andcanonicalizerefuses it anyway.a906ab7adds a direct test ofparse_declaration, which catches it. The original 33 revert checks were re-run on the new head, and all are still caught (two were updated for the renamed renderer test).Update (review round 2)
Head is now
ef312db, with 4 new commits pushed once and no force-push.meets_role_contractvalidates each base-role entry with jsonschema against the base kind schema'sdata.items, or theoneOf/anyOfbranch for that role (newrole_schemas). Role, format, dims and required fields now come from the one schema; the registryrolesare no longer read by the check and stay a summary that a test ties to the schema. A view declaring basenemar.tablewith nocolumnsnow falls back to a table; ano-columnscase was added to the breach parametrize.docs/views.mdstates the contract, and that a TypeScript renderer validates the entry against the base kind's schema with ajv.abb007dtest_a_base_requiring_a_dim_refuses_a_preset_without_ituses a throwaway fixture kind whose role requiresdimsthatcontainsafreqdimension. A preset withfreqdraws as the base; one with onlysensor, or with no dims, falls back to a table. A second fixture (a two-roleoneOfbase) checks each role against its own branch.abb007ddatafor download, and that however a view is drawn, every data file is either drawn or offered for download.4f64fbaparse_declaration(Residual)str, orbytes/bytearraythat decode as strict UTF-8. It refuses a UTF-8 byte order mark (as bytes or in astr), UTF-16 and UTF-32 with or without a BOM, invalid UTF-8, non-text input and non-JSON text, all asCanonicalizationError.view-digest.mdstates the I-JSON encoding rule.6b44ef0Also: changelog wording for the above (
ef312db).Gates (round 2)
pytest --cov: 612 passed (594 before)digest.py100%,registry.py94%. The uncovered lines are three refusals for malformed kind schemas that no shipped kind reaches: a role given byenum(and the refusal when a role is neitherconstnorenum) in_admitted, and a role with two branches inrole_schemas. Tests for them can come in a follow-up push or with S3's multi-role kinds; this round was limited to one push.Revert checks (round 2)
test_each_breach_of_the_base_contract_draws_as_a_table(format,dims,no-columns)rolesonly (the round-1 check)test_a_base_requiring_a_dim_refuses_a_preset_without_itoneOf/anyOfbranches ignoredtest_a_base_with_two_roles_checks_each_against_its_branchjson.loadsundecoded (it detects UTF-16, UTF-32 and BOMs)test_parse_declaration_refuses_other_encodings(all 7 byte cases)JSONDecodeErrornot refused asCanonicalizationErrortest_parse_declaration_refuses_non_text_and_non_jsontest_parse_declaration_refuses_non_text_and_non_jsonItem 3 changes only prose, so it has no revert check.
On this head, the original 33 checks and the 9 round-1 checks whose code still exists are still caught; the 4 round-1 checks on the registry-only contract internals target code that the round-2 contract replaced.
Update (follow-up to round 2)
Head is now
4ebfcdf, with 2 new commits pushed once and no force-push.c96067f: indocs/views.md, a TypeScript renderer now validates a base-role entry against the base kind's schema "with ajv, or with guards held to neuroschema's verdict corpus", since the website cannot run ajv everywhere.4ebfcdf: throwaway fixture kinds test the three guards inregistry.pythat were untested:enumrole branch: in ananyOfbase, both enum roles map to one branch, and each must be present;constnorenumis refused;constand for an overlappingenum.Gates
pytest --cov: 616 passed (612 before);registry.py100% anddigest.py100% line coverageRevert checks
enumrole branch in_admittedtest_an_enum_role_admits_each_of_its_valuesconstnorenumtest_a_role_that_is_neither_const_nor_enum_is_refusedtest_a_role_in_two_branches_is_refused(both cases)The doc change has no revert check. On this head, the original 33 checks, the 9 applicable round-1 checks and the 6 round-2 checks are all still caught.