refactor: one module per registry convention under src/conventions/ - #70
Merged
Merged
Conversation
Each pipeline re-implemented the registry conventions, and several copies were literals the registry couldn't change: '_other' in the validator, the DDI emitter and the other-pattern detector; OTHER_CODE/OTHER_SUFFIX/ otherLabelFor defined twice; 'cdlvocab-', '_from_file' and 'table-list' written out across pipelines. src/conventions/ now holds other.ts, fromFile.ts, exclusive.ts (moved from src/xlsform/), grid.ts and metadata.ts. Each reads src/generated/conventions, and every format module and pipeline imports from there. To make that possible the registry gains two machine-readable fields: - grid composite trigger.appearance = "table-list" (the prose also claimed "name contains 'grid' / label contains 'matrix'", which no code does; corrected) - convention:externalCodeList.limesurveyCssClassPrefix = "cdlvocab-" Behaviour: unchanged, and every TSV/DDI snapshot is identical, with one exception. The other-pattern detector also removed choices named _other/other_option/other_choice, spellings the registry doesn't define and the validator rejects; it now uses the convention's choice code only. tests/ts/unit/conventionLiterals.test.ts fails if a convention literal appears outside src/generated and src/conventions. ARCHITECTURE.md describes the module. The longer-term Instrument model from the issue is split out as #69. Closes #60 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Closes #60 (short-term part). The longer-term
Instrumentmodel is split out as #69.Before: convention values were re-implemented per pipeline, and several were literals the registry couldn't change:
'_other'invalidate.ts,codebook.tsandotherPatternDetector.tsOTHER_CODE/OTHER_SUFFIX/otherLabelFordefined twice'cdlvocab-','select_*_from_file'and'table-list'written out in several placesAfter:
src/conventions/:other.tsotherCompanionBase()fromFile.tscssclassprefixexclusive.tssrc/xlsform/grid.tsmetadata.tsEvery pipeline and format module imports from here, which also removes the pipeline → pipeline imports of these helpers (part of #61).
Registry: two machine-readable fields, so no value needs to be hardcoded:
trigger.appearance. Its prose also claimed "name contains 'grid' / label contains 'matrix'" triggers a grid, which no code does; corrected.externalCodeList.limesurveyCssClassPrefixBehaviour: unchanged. All TSV and DDI snapshots are identical (re-blessed; only
prodDatemoved, reverted). One exception: the other-pattern detector also dropped choices named_other,other_optionandother_choice. The registry doesn't define those spellings and the validator rejects them; it now uses the convention's code only.Guard:
tests/ts/unit/conventionLiterals.test.tsfails on a convention literal outsidesrc/generated/andsrc/conventions/.ARCHITECTURE.mddocuments the module.Tests: vitest 879 passed.
npm run validateis clean. pytest: 37 passed.🤖 Generated with Claude Code