Skip to content

refactor: one module per registry convention under src/conventions/ - #70

Merged
jstet merged 1 commit into
mainfrom
refactor/60-conventions
Sep 25, 2026
Merged

jstet merged 1 commit into
mainfrom
refactor/60-conventions

Conversation

@jstet

@jstet jstet commented Sep 25, 2026

Copy link
Copy Markdown
Member

Closes #60 (short-term part). The longer-term Instrument model is split out as #69.

Before: convention values were re-implemented per pipeline, and several were literals the registry couldn't change:

  • '_other' in validate.ts, codebook.ts and otherPatternDetector.ts
  • OTHER_CODE/OTHER_SUFFIX/otherLabelFor defined twice
  • 'cdlvocab-', 'select_*_from_file' and 'table-list' written out in several places

After: src/conventions/:

Module Convention
other.ts code, suffix, labels, companion type, applies-to, otherCompanionBase()
fromFile.ts from-file ↔ base type, vocab from filename, the cssclass prefix
exclusive.ts moved from src/xlsform/
grid.ts the grid appearance
metadata.ts metadata row types

Every 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:

  • grid trigger.appearance. Its prose also claimed "name contains 'grid' / label contains 'matrix'" triggers a grid, which no code does; corrected.
  • externalCodeList.limesurveyCssClassPrefix

Behaviour: unchanged. All TSV and DDI snapshots are identical (re-blessed; only prodDate moved, reverted). One exception: the other-pattern detector also dropped choices named _other, other_option and other_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.ts fails on a convention literal outside src/generated/ and src/conventions/. ARCHITECTURE.md documents the module.

Tests: vitest 879 passed. npm run validate is clean. pytest: 37 passed.

🤖 Generated with Claude Code

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>
@jstet
jstet merged commit dc00a70 into main Sep 25, 2026
4 checks passed
@jstet
jstet deleted the refactor/60-conventions branch September 25, 2026 10:57
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.

refactor: centralize registry conventions instead of re-implementing them per pipeline

1 participant