Skip to content

Preliminary implementation of loading unmerged schemas#680

Open
VisLab wants to merge 1 commit intohed-standard:mainfrom
VisLab:try_unmerged
Open

Preliminary implementation of loading unmerged schemas#680
VisLab wants to merge 1 commit intohed-standard:mainfrom
VisLab:try_unmerged

Conversation

@VisLab
Copy link
Member

@VisLab VisLab commented Mar 19, 2026

@claude please review also

@VisLab VisLab requested a review from Copilot March 19, 2026 19:00
@VisLab VisLab added schema Schema parsing javascript Pull requests that update Javascript code labels Mar 19, 2026
@VisLab VisLab requested a review from happy5214 March 19, 2026 19:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds initial support for loading and merging unmerged HED library schemas (those that rely on withStandard and rooted rather than inLibrary) into the schema-building pipeline, along with expanded tests and some formatting-only file normalizations.

Changes:

  • Introduces an UnmergedLibrarySchemaParser to parse unmerged library tags using definitions borrowed from the standard partner schema.
  • Introduces an UnmergedLibrarySchemaMerger and updates schema initialization to auto-resolve standard partners and validate withStandard compatibility early.
  • Expands Jest coverage for prefixed/unprefixed multi-schema version strings and compatibility failures.

Reviewed changes

Copilot reviewed 4 out of 9 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
src/schema/init.js Adds unmerged-library detection, standard partner auto-resolution, and header-level compatibility validation before parsing/merging.
src/schema/parser.js Adds a parser variant that reuses standard schema entries for non-tag definitions when parsing unmerged libraries.
src/schema/schemaMerger.js Adds a merger variant that can merge unmerged-library tags (no inLibrary) using rooted for top-level attachment.
tests/otherTests/schema.spec.js Adds test coverage for loading/merging unmerged libraries across prefixes and for withStandard incompatibilities.
tests/bidsDemoData/README.md Line-ending/format normalization (also exposes a few documentation typos/inconsistencies in the modified lines).
tests/bidsDemoData/dataset_description.json Line-ending/format normalization only.
lychee.toml Line-ending/format normalization only.

Comment on lines +131 to +132
"(Experiment-participant, ID/sub-001),Age/3,Male,Healthy,Rested,Novide-level"
```
Comment on lines +124 to +142
const result = []
for (const xmlData of xmlDataArray) {
if (isUnmergedLibrary(xmlData)) {
const standardVersion = xmlData.HED.$.withStandard
if (!standardVersion) {
IssueError.generateAndThrow('invalidSchemaSpecification', {
spec: `${xmlData.HED.$.library}_${xmlData.HED.$.version}`,
})
}
// Only load the standard partner if it is not already in the result.
const standardAlreadyPresent = result.some((d) => !d.HED?.$?.library && d.HED?.$?.version === standardVersion)
if (!standardAlreadyPresent) {
const standardSpec = new SchemaSpec('', standardVersion, '')
const standardXmlData = await loadSchema(standardSpec)
result.push(standardXmlData)
}
}
result.push(xmlData)
}
Comment on lines +217 to +220
if (this.destinationTags.hasEntry(shortName.toLowerCase())) {
// Standard-schema tag that was also embedded in a merged library XML — skip it.
return
}
Comment on lines +271 to +278
const destinationParentTag = parentName ? this.destinationTags.getEntry(parentName) : undefined
if (destinationParentTag) {
newTag.parent = destinationParentTag
if (newTag instanceof SchemaValueTag) {
newTag.parent.valueTag = newTag
}
}

Comment on lines +91 to +92
The `participant_id` and `age` column are annotated as value columns,
while `sex` is annotated as a value column.
Comment on lines +98 to +102
| sub-002 | 31 | M | Healthy,Rested,Novice-level |

At validator or analysis time, the annotations for the columns of a `.tsv`
file are concatenated for a row in a comma-separated string.
The HED annotation for the first row of the demo `participants.tsv` file is:
Comment on lines +105 to +106
"(Experiment-participant, ID/sub-001),Age/3,Male,Healthy,Rested,Novide-level"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

javascript Pull requests that update Javascript code schema Schema parsing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants