diff --git a/.gitignore b/.gitignore index 14be5a23f..fbe5e469b 100644 --- a/.gitignore +++ b/.gitignore @@ -136,6 +136,7 @@ hed_cache/ spec_tests/hed-specification/tests spec_tests/hed-examples spec_tests/*.json +spec_tests/hed-tests/json_test_data # GitHub Copilot instructions (project-specific) .github/copilot-instructions.md diff --git a/.gitmodules b/.gitmodules index 13904cac9..957c17f53 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ -[submodule "spec_tests/hed-specification"] - path = spec_tests/hed-specification - url = https://github.com/hed-standard/hed-specification/ +[submodule "spec_tests/hed-tests"] + path = spec_tests/hed-tests + url = https://github.com/hed-standard/hed-tests/ branch = main [submodule "spec_tests/hed-examples"] diff --git a/docs/source/_static/images/croppedWideLogo.png b/docs/_static/images/croppedWideLogo.png similarity index 100% rename from docs/source/_static/images/croppedWideLogo.png rename to docs/_static/images/croppedWideLogo.png diff --git a/docs/conf.py b/docs/conf.py index b54038e7b..c060c9497 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -38,7 +38,7 @@ html_js_files = ["gh_icon_fix.js"] # Add logo -html_logo = "source/_static/images/croppedWideLogo.png" +html_logo = "_static/images/croppedWideLogo.png" # Furo theme options html_theme_options = { diff --git a/docs/user_guide.md b/docs/user_guide.md index 1d18228e2..f2a0f2949 100644 --- a/docs/user_guide.md +++ b/docs/user_guide.md @@ -283,6 +283,9 @@ HEDTools provides a unified command-line interface (CLI) using a **git-style com | ----------------------------- | ----------------------------------------------------------- | | **Annotation management** | | | `hedpy validate bids-dataset` | Validate HED annotations in BIDS datasets | +| `hedpy validate string` | Validate HED annotations in a string | +| `hedpy validate sidecar` | Validate HED annotations in a JSON sidecar | +| `hedpy validate tabular` | Validate HED annotations in a tabular file (TSV) | | `hedpy extract bids-sidecar` | Extract JSON sidecar template from tabular (`.tsv`) files | | **Schema management** | | | `hedpy schema validate` | Validate HED schema files | @@ -403,6 +406,62 @@ hedpy validate bids-dataset /path/to/bids/dataset \ ______________________________________________________________________ +### String validation + +Validate a HED string using `hedpy validate string`. + +```bash +# Basic validation +hedpy validate string "Event, Action" -sv 8.3.0 + +# With definitions +hedpy validate string "Event, Def/MyDef" \ + -sv 8.4.0 \ + -d "(Definition/MyDef, (Action, Move))" + +# Check for warnings +hedpy validate string "Event, Action/Button-press" -sv 8.4.0 -w +``` + +______________________________________________________________________ + +### Sidecar validation + +Validate a HED JSON sidecar using `hedpy validate sidecar`. + +```bash +# Basic validation +hedpy validate sidecar task-rest_events.json -sv 8.3.0 + +# With multiple schemas +hedpy validate sidecar task-rest_events.json -sv 8.3.0 -sv score_1.1.0 + +# Check for warnings and save to file +hedpy validate sidecar task-rest_events.json -sv 8.4.0 -w -o results.txt +``` + +______________________________________________________________________ + +### Tabular validation + +Validate a HED tabular file (TSV) using `hedpy validate tabular`. + +```bash +# Basic validation +hedpy validate tabular events.tsv -sv 8.3.0 + +# With a sidecar +hedpy validate tabular events.tsv -s sidecar.json -sv 8.3.0 + +# Limit errors +hedpy validate tabular events.tsv -sv 8.3.0 -el 5 + +# Check for warnings and output JSON +hedpy validate tabular events.tsv -sv 8.3.0 -w -f json -o results.json +``` + +______________________________________________________________________ + ### Sidecar template extraction Extract a JSON sidecar template from BIDS event files using `hedpy extract bids-sidecar`. @@ -534,6 +593,9 @@ For backward compatibility, you can still access scripts directly using Python m ```bash # Validation python -m hed.scripts.validate_bids /path/to/dataset --check-warnings +python -m hed.scripts.validate_hed_string "Event, Action" -sv 8.3.0 +python -m hed.scripts.validate_hed_sidecar sidecar.json -sv 8.3.0 +python -m hed.scripts.validate_hed_tabular events.tsv -sv 8.3.0 # Sidecar extraction python -m hed.scripts.hed_extract_bids_sidecar /path/to/dataset -s events diff --git a/spec_tests/hed-specification b/spec_tests/hed-specification deleted file mode 160000 index a341dab34..000000000 --- a/spec_tests/hed-specification +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a341dab341b0009b4d2b4d931036375d3936ba24 diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_INVALID.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_INVALID.json new file mode 100644 index 000000000..a30d0038c --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_INVALID.json @@ -0,0 +1,126 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_INVALID", + "name": "attribute-invalid-unknown", + "warning": true, + "description": "A schema attribute issue, saying there is an unknown one.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Using undefined schema attributes", + "Applying attributes to wrong element types", + "Typos in attribute names", + "Using attributes from different schema versions", + "Incorrect attribute property assignments" + ], + "explanation": "Schema attributes must be defined in the schema attributes section before use, and must be applied to the correct element types (tags, units, value classes, etc.). Each attribute has specific properties that determine where it can be used.", + "correction_strategy": "Define missing attributes or fix attribute usage", + "correction_examples": [ + { + "wrong": "'''Tag-with-unknown''' {unknownAttribute}", + "correct": "'''Tag-with-unknown''' {extensionAllowed}", + "explanation": "Replaced undefined attribute with valid schema attribute" + }, + { + "wrong": "* mod1 {unitAttribute}[Wrong attribute type]", + "correct": "* mod1 {unitModifierProperty}", + "explanation": "Used correct property type for unit modifier" + } + ], + "correction_patterns": [ + "Define all schema attributes in the Schema attributes section", + "Ensure attribute properties match element types", + "Use correct property types: nodeClassProperty, unitProperty, etc.", + "Check attribute names for typos", + "Verify attribute compatibility with schema version" + ], + "fix_instructions": [ + "1. Check if the attribute is defined in Schema attributes section", + "2. Verify the attribute property type matches the element", + "3. Correct spelling of attribute names", + "4. Add missing attribute definitions if needed", + "5. Ensure proper property assignment" + ], + "validation_hints": [ + "Review schema attributes section for all used attributes", + "Check property types match element usage", + "Verify attribute names are spelled correctly", + "Ensure attributes exist in current schema version" + ], + "specification_reference": "A.1.4. Schema attributes", + "related_errors": [ + "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "SCHEMA_SECTION_MISSING" + ], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {unknownAttribute}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {unitAttribute}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes''' {unitProperty}", + "* unitAttribute {unitProperty}", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers''' ", + "* mod1 {unitAttribute}[Wrong attribute type]", + "'''Value classes'''", + "'''Schema attributes''' {unitProperty}", + "* unitAttribute {unitProperty}", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {suggestedTag=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_ALLOWED_CHARACTER.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_ALLOWED_CHARACTER.json new file mode 100644 index 000000000..e1b10e5f3 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_ALLOWED_CHARACTER.json @@ -0,0 +1,95 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-invalid-allowed-character", + "warning": true, + "description": "A schema unit has an invalid conversion factor", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Using invalid characters in allowedCharacter attribute values", + "Incorrect character specification format", + "Including forbidden characters in allowed character sets", + "Malformed character range specifications", + "Using deprecated character specification syntax" + ], + "explanation": "The allowedCharacter attribute defines valid characters for specific schema elements. Invalid character specifications can cause parsing errors and validation failures.", + "correction_strategy": "Use valid character specifications according to HED schema format", + "correction_examples": [ + { + "wrong": "allowedCharacter=\"[invalid]\"", + "correct": "allowedCharacter=\"letters,digits\"", + "explanation": "Replaced invalid character specification with valid format" + } + ], + "correction_patterns": [ + "Use standard character class names (letters, digits, etc.)", + "Avoid invalid character specifications", + "Follow HED character specification format" + ], + "fix_instructions": [ + "1. Identify invalid allowedCharacter specifications", + "2. Replace with valid character class names", + "3. Verify character specification syntax", + "4. Test schema validation with corrected attributes" + ], + "validation_hints": [ + "Check character specification format", + "Verify against HED allowed character classes", + "Test schema loading after character corrections" + ], + "specification_reference": "3.1.2.3. Schema attributes and character specifications", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "CHARACTER_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "'''Unit modifiers'''", + "'''Value classes'''", + "* testValueClass {allowedCharacter=?d}", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "'''Unit modifiers'''", + "'''Value classes'''", + "* testValueClass {allowedCharacter=?, allowedCharacter=letters}", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "'''Unit modifiers'''", + "'''Value classes'''", + "* testValueClass {allowedCharacter=letters}", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_CONVERSION_FACTOR.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_CONVERSION_FACTOR.json new file mode 100644 index 000000000..a3efa319b --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_CONVERSION_FACTOR.json @@ -0,0 +1,218 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-conversion-factor-invalid", + "warning": true, + "description": "A schema unit has an invalid conversion factor", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Invalid numeric format in conversionFactor attribute", + "Non-numeric values in conversion factor specifications", + "Missing or zero conversion factors where required", + "Incorrect scientific notation in conversion factors", + "Using text instead of numeric values for conversions" + ], + "explanation": "Conversion factors must be valid numeric values that specify how to convert between different units. Invalid conversion factors prevent proper unit validation and conversion.", + "correction_strategy": "Use valid numeric values for conversion factors", + "correction_examples": [ + { + "wrong": "conversionFactor=\"invalid\"", + "correct": "conversionFactor=\"1000\"", + "explanation": "Replaced invalid text with proper numeric conversion factor" + }, + { + "wrong": "conversionFactor=\"1.0e+abc\"", + "correct": "conversionFactor=\"1.0e+3\"", + "explanation": "Fixed invalid scientific notation format" + } + ], + "correction_patterns": [ + "Use valid numeric values (integers or decimals)", + "Ensure proper scientific notation format", + "Remove non-numeric characters from conversion factors", + "Verify conversion factors are positive and non-zero" + ], + "fix_instructions": [ + "1. Identify invalid conversion factor values", + "2. Replace with proper numeric formats", + "3. Verify conversion factors are logical for the units", + "4. Test unit conversion functionality" + ], + "validation_hints": [ + "Check numeric format of conversion factors", + "Verify conversion factors are positive numbers", + "Test unit conversion calculations", + "Ensure scientific notation is properly formatted" + ], + "specification_reference": "3.1.2.4. Unit classes and conversion factors", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "SCHEMA_ATTRIBUTE_VALUE_INVALID", "UNITS_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "* testUnitClass ", + "** testUnit1{SIUnit, conversionFactor=-1.0}", + "** testUnit2", + "** testUnit3", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "* testUnitClass ", + "** testUnit1{SIUnit, conversionFactor=word}", + "** testUnit2", + "** testUnit3", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "* testUnitClass ", + "** testUnit1{SIUnit, conversionFactor=None}", + "** testUnit2", + "** testUnit3", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "* testUnitClass ", + "** testUnit1{SIUnit, conversionFactor}", + "** testUnit2", + "** testUnit3", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "* testUnitClass {defaultUnits=testUnit1}", + "** testUnit1", + "** testUnit2", + "** testUnit3", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "WIKI_DELIMITERS_INVALID", + "name": "attribute-conversion-format", + "warning": true, + "description": "A schema unit has an invalid conversion factor due to bad formatting", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Missing conversionFactor value after attribute name", + "Incomplete conversionFactor specification", + "Malformed attribute syntax in schema definition", + "Missing equals sign or value in conversionFactor attribute" + ], + "explanation": "Conversion factor attributes must include both the attribute name and a valid numeric value. Missing values or incomplete syntax cause schema parsing failures.", + "correction_strategy": "Complete the conversionFactor attribute with proper value", + "correction_examples": [ + { + "wrong": "conversionFactor}", + "correct": "conversionFactor=1000}", + "explanation": "Added missing value to conversionFactor attribute" + }, + { + "wrong": "conversionFactor", + "correct": "conversionFactor=1.0", + "explanation": "Added equals sign and value to complete attribute" + } + ], + "correction_patterns": [ + "Ensure conversionFactor includes =value", + "Use proper attribute=value syntax", + "Complete incomplete attribute specifications", + "Check for missing closing braces" + ], + "fix_instructions": [ + "1. Identify incomplete conversionFactor attributes", + "2. Add missing equals sign and numeric value", + "3. Verify proper attribute syntax", + "4. Test schema parsing after completion" + ], + "validation_hints": [ + "Check for complete attribute=value pairs", + "Verify proper brace closure", + "Ensure numeric values are provided" + ], + "specification_reference": "3.1.2.4. Unit class conversion factor syntax", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "SCHEMA_ATTRIBUTE_VALUE_INVALID", "SCHEMA_LOAD_FAILED"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' ", + "* testUnitClass ", + "** testUnit1{SIUnit, conversionFactor=}", + "** testUnit2", + "** testUnit3", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_DEFAULT_UNIT.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_DEFAULT_UNIT.json new file mode 100644 index 000000000..3ed52ccf4 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_DEFAULT_UNIT.json @@ -0,0 +1,87 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-default-unit-invalid", + "warning": true, + "description": "A schema unit class has an invalid default value", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Specifying default units that don't exist in the unit class", + "Referencing undefined or misspelled unit names", + "Using default units incompatible with the unit class", + "Missing unit class definition for default unit", + "Invalid unit name format in default unit specification" + ], + "explanation": "Default units must reference valid units defined within the associated unit class. Invalid default unit references cause validation errors and prevent proper unit handling.", + "correction_strategy": "Use valid unit names that exist in the corresponding unit class", + "correction_examples": [ + { + "wrong": "defaultUnits=\"invalidUnit\"", + "correct": "defaultUnits=\"m\"", + "explanation": "Replaced invalid unit with valid meter unit" + } + ], + "correction_patterns": [ + "Verify unit exists in the associated unit class", + "Use correct unit symbols or names", + "Check unit class definitions for available units" + ], + "fix_instructions": [ + "1. Check the unit class for available units", + "2. Verify default unit name spelling and format", + "3. Ensure unit exists in the specified unit class", + "4. Update default unit to valid unit reference" + ], + "validation_hints": [ + "Cross-reference with unit class definitions", + "Check unit name spelling and case sensitivity", + "Verify unit symbols match schema specification" + ], + "specification_reference": "3.1.2.5. Unit classes and default units", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "UNITS_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' [Unit classes and the units for the nodes.]", + "* testUnitClass {defaultUnits=testUnit0}", + "** testUnit1", + "** testUnit2", + "** testUnit3", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes''' [Unit classes and the units for the nodes.]", + "* testUnitClass {defaultUnits=testUnit1}", + "** testUnit1", + "** testUnit2", + "** testUnit3", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_HED_ID.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_HED_ID.json new file mode 100644 index 000000000..68d989e90 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_HED_ID.json @@ -0,0 +1,254 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-invalid-hed-id-changed", + "warning": true, + "description": "A schema value class issue, saying there is an unknown one.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Using non-unique HED IDs that conflict with existing IDs", + "Invalid HED ID format (non-numeric or incorrect structure)", + "Missing HED IDs where required", + "Changing HED IDs that should remain stable", + "Duplicate HED IDs across different schema elements" + ], + "explanation": "HED IDs must be unique numeric identifiers that follow specific format requirements and remain stable across schema versions. Invalid or changed HED IDs cause schema validation failures.", + "correction_strategy": "Use stable, properly formatted HED IDs according to specification", + "correction_examples": [ + { + "wrong": "hedId=\"invalid\"", + "correct": "hedId=\"HED_0012345\"", + "explanation": "Replaced invalid ID with proper HED ID format" + } + ], + "correction_patterns": [ + "Maintain HED ID stability across versions", + "Use proper HED ID format", + "Ensure HED IDs are unique" + ], + "fix_instructions": [ + "1. Check HED ID format compliance", + "2. Verify HED ID stability requirements", + "3. Replace invalid HED IDs with proper format", + "4. Ensure uniqueness across schema" + ], + "validation_hints": [ + "Check HED ID format matches specification", + "Verify HED ID stability across versions", + "Ensure no duplicate HED IDs exist" + ], + "specification_reference": "3.1.2.6. HED IDs and stability requirements", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "SCHEMA_DUPLICATE_NODE"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.4.0\"", + "'''Prologue'''", + "!# start schema", + "'''Event'''{hedId=HED_0015001}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* hedId {elementDomain}", + "'''Properties'''", + "* elementDomain", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.4.0\"", + "'''Prologue'''", + "!# start schema", + "'''Event'''{hedId=HED_0012001}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* hedId {elementDomain}", + "'''Properties'''", + "* elementDomain", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-invalid-hed-id-out-range", + "warning": true, + "description": "A schema value class issue, saying there is an unknown one.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Using HED IDs outside the allocated ranges", + "Creating HED IDs in reserved number ranges", + "Using experimental or unofficial HED ID ranges", + "Assigning HED IDs without proper allocation" + ], + "explanation": "HED IDs must be within specific allocated ranges to ensure compatibility and prevent conflicts. Using out-of-range IDs causes schema validation failures.", + "correction_strategy": "Use HED IDs within the allocated range for your schema", + "correction_examples": [ + { + "wrong": "hedId=HED_0055000", + "correct": "hedId=HED_0015001", + "explanation": "Changed out-of-range ID to allocated range" + } + ], + "correction_patterns": [ + "Check HED ID range allocations", + "Use proper HED ID ranges for schema type", + "Avoid reserved or experimental ranges" + ], + "fix_instructions": [ + "1. Check HED ID range allocation guidelines", + "2. Identify proper range for your schema", + "3. Replace out-of-range HED IDs", + "4. Verify all HED IDs are within allocated ranges" + ], + "validation_hints": [ + "Check HED ID range documentation", + "Verify HED ID is within allocated bounds", + "Ensure proper schema-specific ranges" + ], + "specification_reference": "3.1.2.6. HED ID ranges and allocation", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "SCHEMA_ATTRIBUTE_VALUE_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.4.0\"", + "'''Prologue'''", + "!# start schema", + "'''NewTagWithNewID'''{hedId=HED_0055000}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* hedId {elementDomain}", + "'''Properties'''", + "* elementDomain", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.4.0\"", + "'''Prologue'''", + "!# start schema", + "'''NewTagWithNewID'''{hedId=HED_0015001}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* hedId {elementDomain}", + "'''Properties'''", + "* elementDomain", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-invalid-hed-id-invalid", + "warning": true, + "description": "A schema value class issue, saying there is an unknown one.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Using non-numeric characters in HED ID values", + "Invalid HED ID format (not following HED_NNNNNNN pattern)", + "Using placeholder or invalid characters like 'XXXXXXX'", + "Malformed HED ID syntax" + ], + "explanation": "HED IDs must follow the exact format 'HED_' followed by a 7-digit number. Invalid characters or formats cause schema parsing failures.", + "correction_strategy": "Use proper HED ID format with numeric values only", + "correction_examples": [ + { + "wrong": "hedId=HED_XXXXXXX", + "correct": "hedId=HED_0015001", + "explanation": "Replaced invalid characters with proper numeric ID" + }, + { + "wrong": "hedId=HED_ABC1234", + "correct": "hedId=HED_0015002", + "explanation": "Replaced alphabetic characters with numbers" + } + ], + "correction_patterns": [ + "Use HED_NNNNNNN format exactly", + "Replace invalid characters with numbers", + "Ensure 7-digit numeric portion" + ], + "fix_instructions": [ + "1. Identify HED IDs with invalid format", + "2. Replace with proper HED_NNNNNNN format", + "3. Use allocated numeric ranges", + "4. Verify format compliance" + ], + "validation_hints": [ + "Check for HED_NNNNNNN format", + "Verify only numeric characters after HED_", + "Ensure exactly 7 digits" + ], + "specification_reference": "3.1.2.6. HED ID format requirements", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "SCHEMA_ATTRIBUTE_VALUE_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.4.0\"", + "'''Prologue'''", + "!# start schema", + "'''NewTagWithNewID'''{hedId=HED_XXXXXXX}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* hedId {elementDomain}", + "'''Properties'''", + "* elementDomain", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.4.0\"", + "'''Prologue'''", + "!# start schema", + "'''NewTagWithNewID'''{hedId=HED_0015001}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* hedId {elementDomain}", + "'''Properties'''", + "* elementDomain", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_IN_LIBRARY.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_IN_LIBRARY.json new file mode 100644 index 000000000..f36be3ec8 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_IN_LIBRARY.json @@ -0,0 +1,85 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-invalid-in-library", + "warning": true, + "description": "A schema unit has an invalid in library attribute(most other library errors are SCHEMA_LIBRARY_INVALID", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Using inLibrary attribute in non-library schema contexts", + "Invalid library name specification in inLibrary attribute", + "Referencing non-existent library schemas", + "Incorrect inLibrary attribute syntax or format", + "Missing library schema dependencies for inLibrary references" + ], + "explanation": "The inLibrary attribute specifies which library schema contains an element. Invalid inLibrary specifications cause schema loading failures and prevent proper library schema integration.", + "correction_strategy": "Use valid library names and proper inLibrary attribute syntax", + "correction_examples": [ + { + "wrong": "inLibrary=\"nonexistent\"", + "correct": "inLibrary=\"score\"", + "explanation": "Referenced valid existing library schema" + } + ], + "correction_patterns": [ + "Reference only existing library schemas", + "Use correct case-sensitive library names", + "Verify library schema availability" + ], + "fix_instructions": [ + "1. Verify referenced library schema exists", + "2. Check library name spelling and case", + "3. Ensure library schema is available for loading", + "4. Remove inLibrary attributes where inappropriate" + ], + "validation_hints": [ + "Check available library schema names", + "Verify library schema loading prerequisites", + "Ensure case-sensitive name matching" + ], + "specification_reference": "3.1.3. Library schemas and inLibrary attributes", + "related_errors": ["SCHEMA_LIBRARY_INVALID", "SCHEMA_LOAD_FAILED"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"right\"", + "'''Prologue'''", + "!# start schema", + "'''Tag''' {inLibrary=wrong}", + "!# end schema", + "'''Unit classes''' ", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* inLibrary {elementProperty}", + "'''Properties'''", + "* elementProperty", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"right\"", + "'''Prologue'''", + "!# start schema", + "'''Tag''' {inLibrary=right}", + "!# end schema", + "'''Unit classes''' ", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* inLibrary {elementProperty}", + "'''Properties'''", + "* elementProperty", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_NON_PLACEHOLDER_HAS_CLASS.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_NON_PLACEHOLDER_HAS_CLASS.json new file mode 100644 index 000000000..9a95ee103 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_NON_PLACEHOLDER_HAS_CLASS.json @@ -0,0 +1,116 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-on-nonplaceholder-invalid", + "warning": true, + "description": "A non placeholder tag has takes value, unit class, or value class", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Adding valueClass or unitClass attributes to non-placeholder tags", + "Misunderstanding placeholder vs. non-placeholder tag attributes", + "Copy-paste errors from placeholder tag definitions", + "Incorrect schema attribute assignments", + "Using takesValue attribute on inappropriate tags" + ], + "explanation": "Only placeholder tags (#) should have valueClass, unitClass, or takesValue attributes. Non-placeholder tags with these attributes violate schema structure rules.", + "correction_strategy": "Remove value/unit class attributes from non-placeholder tags", + "correction_examples": [ + { + "wrong": "* RegularTag {valueClass=numericClass}", + "correct": "* RegularTag", + "explanation": "Removed valueClass from non-placeholder tag" + }, + { + "wrong": "* Tag {takesValue=true}", + "correct": "* Tag", + "explanation": "Removed takesValue from non-placeholder tag" + } + ], + "correction_patterns": [ + "Remove valueClass attributes from non-placeholder tags", + "Remove unitClass attributes from non-placeholder tags", + "Remove takesValue attributes from non-placeholder tags", + "Keep class attributes only on placeholder tags" + ], + "fix_instructions": [ + "1. Identify non-placeholder tags with class or value attributes", + "2. Remove valueClass, unitClass, or takesValue attributes", + "3. Verify only placeholder tags have these attributes", + "4. Check schema validation after cleanup" + ], + "validation_hints": [ + "Check that only # tags have valueClass/unitClass/takesValue", + "Verify schema structure follows placeholder rules", + "Ensure attribute usage matches tag type" + ], + "specification_reference": "3.1.2.7. Placeholder tags and class attributes", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "PLACEHOLDER_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag''' {takesValue}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag''' {valueClass=numericClass}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag''' {unitClass=timeUnits}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag''' {relatedTag=Event}", + "* # {takesValue, unitClass=timeUnits, valueClass=numericClass}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_RELATED_TAG.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_RELATED_TAG.json new file mode 100644 index 000000000..23b18c868 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_RELATED_TAG.json @@ -0,0 +1,111 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-relatedTag-invalid", + "warning": true, + "description": "A related tag points to an unknown tag", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Referencing non-existent tags in relatedTag attributes", + "Incorrect tag path specifications in relatedTag", + "Circular relatedTag references", + "Misspelled tag names in relatedTag attributes", + "Using deprecated tags in relatedTag references" + ], + "explanation": "RelatedTag attributes must reference valid, existing tags in the schema. Invalid references cause schema validation failures and break tag relationship mappings.", + "correction_strategy": "Use valid tag references in relatedTag attributes", + "correction_examples": [ + { + "wrong": "relatedTag=\"NonExistent/Tag\"", + "correct": "relatedTag=\"Event/Sensory-event\"", + "explanation": "Replaced non-existent tag with valid schema tag" + } + ], + "correction_patterns": [ + "Verify tag exists in current schema", + "Use complete tag paths for relatedTag references", + "Check tag spelling and case sensitivity", + "Avoid circular tag references" + ], + "fix_instructions": [ + "1. Verify referenced tags exist in schema", + "2. Check tag path spelling and format", + "3. Remove or update invalid tag references", + "4. Test tag relationship functionality" + ], + "validation_hints": [ + "Cross-reference with available schema tags", + "Verify complete tag paths", + "Check for circular references" + ], + "specification_reference": "3.1.2.8. Tag relationships and relatedTag attributes", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "TAG_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {relatedTag=invalid}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {relatedTag=Event, relatedTag=invalid}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {relatedTag=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {relatedTag=Event}", + "* ExtendedTag {relatedTag=Tag-with-unknown, relatedTag=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_SUGGESTED_TAG.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_SUGGESTED_TAG.json new file mode 100644 index 000000000..f5beda7f8 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_SUGGESTED_TAG.json @@ -0,0 +1,111 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-suggestedTag-invalid", + "warning": true, + "description": "A suggested tag points to an unknown tag", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Referencing non-existent tags in suggestedTag attributes", + "Incorrect tag path specifications in suggestedTag", + "Misspelled tag names in suggestedTag attributes", + "Using deprecated tags in suggestedTag references", + "Self-referencing suggestedTag attributes" + ], + "explanation": "SuggestedTag attributes must reference valid, existing tags in the schema. Invalid references cause schema validation failures and break tag suggestion functionality.", + "correction_strategy": "Use valid tag references in suggestedTag attributes", + "correction_examples": [ + { + "wrong": "suggestedTag=\"InvalidTag\"", + "correct": "suggestedTag=\"Event\"", + "explanation": "Replaced invalid tag with valid schema tag" + } + ], + "correction_patterns": [ + "Verify tag exists in current schema", + "Use complete tag paths for suggestedTag references", + "Check tag spelling and case sensitivity", + "Avoid self-references in suggestedTag" + ], + "fix_instructions": [ + "1. Verify referenced tags exist in schema", + "2. Check tag path spelling and format", + "3. Remove or update invalid tag references", + "4. Test tag suggestion functionality" + ], + "validation_hints": [ + "Cross-reference with available schema tags", + "Verify complete tag paths", + "Check that suggestedTag doesn't reference itself" + ], + "specification_reference": "3.1.2.9. Tag suggestions and suggestedTag attributes", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "TAG_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {suggestedTag=invalid}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {suggestedTag=Event, suggestedTag=invalid}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {suggestedTag=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {suggestedTag=Event}", + "* ExtendedTag {suggestedTag=Tag-with-unknown, suggestedTag=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_UNIT_CLASS.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_UNIT_CLASS.json new file mode 100644 index 000000000..4c136a9ee --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_UNIT_CLASS.json @@ -0,0 +1,84 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-invalid-unit-class", + "warning": true, + "description": "A schema unit class issue, saying there is an unknown one.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Referencing non-existent unit classes in unitClass attributes", + "Misspelled unit class names", + "Using deprecated or removed unit classes", + "Incorrect unit class name format", + "Missing unit class definitions in schema" + ], + "explanation": "UnitClass attributes must reference valid unit classes defined in the schema. Invalid unit class references cause validation failures and prevent proper unit validation.", + "correction_strategy": "Use valid unit class names that exist in the schema", + "correction_examples": [ + { + "wrong": "unitClass=\"unknownUnitClass\"", + "correct": "unitClass=\"accelerationUnits\"", + "explanation": "Replaced unknown unit class with valid one" + } + ], + "correction_patterns": [ + "Verify unit class exists in schema", + "Check unit class name spelling and case", + "Use defined unit class names only", + "Remove references to non-existent unit classes" + ], + "fix_instructions": [ + "1. Check available unit classes in schema", + "2. Verify unit class name spelling", + "3. Replace invalid unit class references", + "4. Test unit validation functionality" + ], + "validation_hints": [ + "Cross-reference with schema unit class definitions", + "Check unit class name case sensitivity", + "Verify unit class exists before referencing" + ], + "specification_reference": "3.1.2.10. Unit classes and unitClass attributes", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "UNITS_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown'''", + "* # {unitClass=unknown}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown'''", + "* # {unitClass=timeUnits}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_VALUE_CLASS.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_VALUE_CLASS.json new file mode 100644 index 000000000..b8270619d --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_ATTRIBUTE_VALUE_INVALID_VALUE_CLASS.json @@ -0,0 +1,84 @@ +[ + { + "error_code": "SCHEMA_ATTRIBUTE_VALUE_INVALID", + "name": "attribute-invalid-value-class", + "warning": true, + "description": "A schema value class issue, saying there is an unknown one.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Referencing non-existent value classes in valueClass attributes", + "Misspelled value class names", + "Using deprecated or removed value classes", + "Incorrect value class name format", + "Missing value class definitions in schema" + ], + "explanation": "ValueClass attributes must reference valid value classes defined in the schema. Invalid value class references cause validation failures and prevent proper value validation.", + "correction_strategy": "Use valid value class names that exist in the schema", + "correction_examples": [ + { + "wrong": "valueClass=\"unknownValueClass\"", + "correct": "valueClass=\"numericClass\"", + "explanation": "Replaced unknown value class with valid one" + } + ], + "correction_patterns": [ + "Verify value class exists in schema", + "Check value class name spelling and case", + "Use defined value class names only", + "Remove references to non-existent value classes" + ], + "fix_instructions": [ + "1. Check available value classes in schema", + "2. Verify value class name spelling", + "3. Replace invalid value class references", + "4. Test value validation functionality" + ], + "validation_hints": [ + "Cross-reference with schema value class definitions", + "Check value class name case sensitivity", + "Verify value class exists before referencing" + ], + "specification_reference": "3.1.2.11. Value classes and valueClass attributes", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "VALUE_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown'''", + "* # {valueClass=unknown}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown'''", + "* # {valueClass=numericClass}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_CHARACTER_INVALID.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_CHARACTER_INVALID.json new file mode 100644 index 000000000..ce1f970ed --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_CHARACTER_INVALID.json @@ -0,0 +1,497 @@ +[ + { + "error_code": "SCHEMA_CHARACTER_INVALID", + "name": "schema-character-invalid-prologue", + "warning": true, + "description": "Invalid character in prologue or epilogue.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Including tab characters or other control characters in schema text", + "Using non-printable characters in prologue or epilogue sections", + "Copy-paste errors that introduce invisible characters", + "Encoding issues when saving schema files", + "Invalid characters in schema tag names or descriptions" + ], + "explanation": "Schema files must use only valid characters as defined in the HED specification. Control characters and non-printable characters can cause parsing errors and schema validation failures.", + "correction_strategy": "Remove or replace invalid characters with valid alternatives", + "correction_examples": [ + { + "wrong": "'''Prologue'''\n\t", + "correct": "'''Prologue'''", + "explanation": "Removed tab character from prologue section" + }, + { + "wrong": "Tag-name\u0000", + "correct": "Tag-name", + "explanation": "Removed null character from tag name" + } + ], + "correction_patterns": [ + "Remove tab characters and control characters", + "Replace non-printable characters with spaces or remove them", + "Ensure proper text encoding (UTF-8)", + "Check for invisible characters in copy-paste operations" + ], + "fix_instructions": [ + "1. Scan schema file for control characters and non-printable characters", + "2. Remove or replace invalid characters", + "3. Verify text encoding is UTF-8", + "4. Check prologue and epilogue sections specifically", + "5. Validate schema parses correctly after character cleanup" + ], + "validation_hints": [ + "Use text editor that shows invisible characters", + "Check file encoding and ensure UTF-8", + "Look for parsing errors in prologue/epilogue sections", + "Verify no control characters remain in schema text" + ], + "specification_reference": "2.2. Character sets and schema formatting", + "related_errors": ["SCHEMA_LOAD_FAILED", "CHARACTER_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "\t", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "InvalidCharAfterThis\b", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "This is a valid prologue.", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "This is a valid prologue.\n", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_CHARACTER_INVALID", + "name": "schema-character-invalid-tag", + "warning": true, + "description": "Invalid character in a tag term.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag$'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag('''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_CHARACTER_INVALID", + "name": "schema-character-invalid-other-term", + "warning": true, + "description": "Invalid character in a tag term.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* unitClassNew$", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* unitClassNew", + "** unitInvalid$", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "* newModifier$", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "* invalidValue$Class", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* newAttribute$new", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "* newProperty\tmore", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_CHARACTER_INVALID", + "name": "schema-character-invalid-utf8-other-term", + "warning": true, + "description": "UTF8 characters (valid) in term.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension&", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTagÄ'''", + "* ExtensionÄ", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''ÄBaseTag'''", + "* ÄExtension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_CHARACTER_INVALID", + "name": "schema-character-allowed-character-unit", + "warning": true, + "description": "Allowed character properly works on units.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* unitClassNew", + "** $", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* unitClassNew", + "** $ {allowedCharacter=dollar}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* allowedCharacter {unitDomain}", + "'''Properties'''", + "* unitDomain", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* unitClassNew {defaultUnit=$}", + "** $ {allowedCharacter=dollar}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* allowedCharacter {unitDomain}", + "* defaultUnit {unitClassDomain}", + "'''Properties'''", + "* unitDomain", + "* unitClassDomain", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_CHARACTER_INVALID", + "name": "schema-character-invalid-description", + "warning": true, + "description": "Description does not contain banned characters.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* unitClassNew [Description goes here with invalid \t character]", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag''' [Description goes here with invalid { character }]", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* unitClassNew ", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"8.3.0\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* unitClassNew [Description goes here with valid characters]", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_DEPRECATION_ERROR.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_DEPRECATION_ERROR.json new file mode 100644 index 000000000..cb3f7e607 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_DEPRECATION_ERROR.json @@ -0,0 +1,684 @@ +[ + { + "error_code": "SCHEMA_DEPRECATION_ERROR", + "name": "schema-deprecated-attribute-invalid", + "warning": true, + "description": "A schema attribute issue, saying there is an unhandled deprecated attribute.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Using deprecated attributes that are no longer supported", + "Incorrect deprecation attribute syntax or values", + "Missing or malformed deprecatedFrom attribute", + "Invalid version specification in deprecation", + "Attempting to deprecate non-existent elements" + ], + "explanation": "Schema deprecation attributes must follow specific format and reference valid schema versions. Incorrect deprecation handling can cause schema validation failures.", + "correction_strategy": "Fix deprecation attribute syntax and ensure proper version references", + "correction_examples": [ + { + "wrong": "* Tag {deprecated}", + "correct": "* Tag {deprecatedFrom=\"8.2.0\"}", + "explanation": "Added proper deprecation version specification" + }, + { + "wrong": "* Tag {deprecatedFrom=\"invalid\"}", + "correct": "* Tag {deprecatedFrom=\"8.1.0\"}", + "explanation": "Used valid version format for deprecation" + } + ], + "correction_patterns": [ + "Use proper deprecatedFrom attribute with valid version", + "Remove invalid deprecation attributes", + "Ensure deprecation version exists in schema history", + "Follow semantic versioning for deprecation references" + ], + "fix_instructions": [ + "1. Identify invalid deprecation attributes", + "2. Check deprecation version format and validity", + "3. Update or remove incorrect deprecation attributes", + "4. Verify deprecation references point to valid versions", + "5. Test schema validation after deprecation fixes" + ], + "validation_hints": [ + "Check deprecation attribute syntax", + "Verify version references are valid", + "Ensure deprecation follows schema evolution rules", + "Test with different schema version combinations" + ], + "specification_reference": "3.1.4. Schema versioning and deprecation", + "related_errors": ["SCHEMA_ATTRIBUTE_INVALID", "SCHEMA_VERSION_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension {deprecatedFrom=0.5.0}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension {deprecatedFrom=1.0.0}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension {deprecatedFrom=1.0.0}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_DEPRECATION_ERROR", + "name": "schema-deprecated-invalid-child", + "warning": true, + "description": "A schema deprecation issue, saying there is an invalid child of a deprecated node", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag''' {deprecatedFrom=1.0.0}", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* testUnitClass {deprecatedFrom=1.0.0}", + "** testUnit", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag''' {deprecatedFrom=1.0.0}", + "* Extension {deprecatedFrom=1.0.0}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_DEPRECATION_ERROR", + "name": "schema-deprecated-default-unit", + "warning": true, + "description": "A schema deprecation issue, deprecated default units", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* testUnitClass {defaultUnits=testUnit}", + "** testUnit {deprecatedFrom=1.0.0}", + "** testUnit2", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* testUnitClass {defaultUnits=testUnit2}", + "** testUnit {deprecatedFrom=1.0.0}", + "** testUnit2", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "!# end schema", + "'''Unit classes'''", + "* testUnitClass {defaultUnits=testUnit, deprecatedFrom=1.0.0}", + "** testUnit {deprecatedFrom=1.0.0}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_DEPRECATION_ERROR", + "name": "schema-deprecated-unit-class", + "warning": true, + "description": "A schema deprecation issue, deprecated value or unit class", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "** #{takesValue, unitClass=testUnitClass}", + "!# end schema", + "'''Unit classes'''", + "* testUnitClass{deprecatedFrom=1.0.0}", + "** testUnit{deprecatedFrom=1.0.0}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "** #{takesValue, unitClass=testUnitClass, deprecatedFrom=1.0.0}", + "!# end schema", + "'''Unit classes'''", + "* testUnitClass{deprecatedFrom=1.0.0}", + "** testUnit{deprecatedFrom=1.0.0}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_DEPRECATION_ERROR", + "name": "schema-deprecated-value-class", + "warning": true, + "description": "A schema deprecation issue, deprecated value or unit class", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "** #{takesValue, valueClass=testValueClass}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "* testValueClass{deprecatedFrom=1.0.0}", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension", + "** #{takesValue, valueClass=testValueClass, deprecatedFrom=1.0.0}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "* testValueClass{deprecatedFrom=1.0.0}", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_DEPRECATION_ERROR", + "name": "schema-deprecated-invalid-suggested-related-tag", + "warning": true, + "description": "A schema deprecation issue, saying a related or suggested tag points to a deprecated tag", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Tag1 {deprecatedFrom=1.0.0}", + "* Tag2", + "* Tag3{suggestedTag=Tag1}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Tag1 {deprecatedFrom=1.0.0}", + "* Tag2", + "* Tag3{relatedTag=Tag1}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Tag1 {deprecatedFrom=1.0.0}", + "* Tag2", + "* Tag3{suggestedTag=Tag2}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Tag1 {deprecatedFrom=1.0.0}", + "* Tag2", + "* Tag3{relatedTag=Tag2}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Tag1 {deprecatedFrom=1.0.0}", + "* Tag2", + "* Tag3{suggestedTag=Tag1, deprecatedFrom=1.0.0}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Tag1 {deprecatedFrom=1.0.0}", + "* Tag2", + "* Tag3{relatedTag=Tag1, deprecatedFrom=1.0.0}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_DEPRECATION_ERROR", + "name": "schema-deprecated-deprecated-attribute", + "warning": true, + "description": "A schema deprecation issue, an attribute of an element is deprecated", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension{deprecatedAttribute}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "* deprecatedUnitClass{deprecatedAttribute}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "* deprecatedUnitClass", + "** deprecatedUnit{deprecatedAttribute}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "* deprecatedUnitModifier {deprecatedAttribute}", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "* deprecatedValueClass {deprecatedAttribute}", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "* Extension{deprecatedAttribute, deprecatedFrom=1.0.0}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "* deprecatedUnitClass{deprecatedAttribute, deprecatedFrom=1.0.0}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "* deprecatedUnitClass", + "** deprecatedUnit{deprecatedAttribute, deprecatedFrom=1.0.0}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "* deprecatedUnitModifier {deprecatedAttribute, deprecatedFrom=1.0.0}", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "* deprecatedValueClass {deprecatedAttribute, deprecatedFrom=1.0.0}", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedFrom=1.0.0, elementProperty}", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_DEPRECATION_ERROR", + "name": "schema-deprecated-deprecated-property", + "warning": true, + "description": "A schema deprecation issue, a property of an attribute is is deprecated", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedProperty}", + "'''Properties'''", + "* deprecatedProperty {deprecatedFrom=1.0.0}", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.1.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''BaseTag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* deprecatedAttribute {deprecatedProperty, deprecatedFrom=1.0.0}", + "'''Properties'''", + "* deprecatedProperty {deprecatedFrom=1.0.0}", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_DUPLICATE_NODE.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_DUPLICATE_NODE.json new file mode 100644 index 000000000..bbb487258 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_DUPLICATE_NODE.json @@ -0,0 +1,240 @@ +[ + { + "error_code": "SCHEMA_DUPLICATE_NODE", + "name": "attribute-duplicate-node", + "warning": true, + "description": "A schema attribute issue, saying there is a duplicate node.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Defining the same tag or attribute multiple times in schema", + "Copy-paste errors leading to duplicate entries", + "Conflicting tag definitions in merged schemas", + "Case-insensitive duplicate tag names", + "Duplicate attribute definitions within same tag" + ], + "explanation": "Schema nodes (tags, attributes, etc.) must be unique within their scope. Duplicate nodes create ambiguity and can cause validation errors or unexpected behavior.", + "correction_strategy": "Remove duplicate entries and ensure unique node definitions", + "correction_examples": [ + { + "wrong": "* Tag1\n* Tag1", + "correct": "* Tag1", + "explanation": "Removed duplicate tag definition" + }, + { + "wrong": "* Tag {attribute1, attribute1}", + "correct": "* Tag {attribute1}", + "explanation": "Removed duplicate attribute from tag definition" + } + ], + "correction_patterns": [ + "Remove exact duplicate entries", + "Merge conflicting definitions if appropriate", + "Check for case-insensitive duplicates", + "Verify uniqueness within tag hierarchies" + ], + "fix_instructions": [ + "1. Identify duplicate node definitions in schema", + "2. Determine which definition to keep", + "3. Remove or merge duplicate entries", + "4. Check for case-insensitive conflicts", + "5. Validate schema structure after cleanup" + ], + "validation_hints": [ + "Search for exact name matches in schema", + "Check case-insensitive duplicates", + "Verify tag hierarchy uniqueness", + "Test schema loading after duplicate removal" + ], + "specification_reference": "3.1.2. Schema structure and uniqueness", + "related_errors": ["SCHEMA_LOAD_FAILED", "SCHEMA_ATTRIBUTE_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "* Tag", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers''' ", + "* mod1 ", + "'''Value classes'''", + "'''Schema attributes''' ", + "* unitAttribute ", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers''' ", + "* mod1 ", + "* mod1 ", + "'''Value classes'''", + "'''Schema attributes''' ", + "* unitAttribute ", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes''' ", + "* unitClass1 ", + "** unit1 ", + "** unit1 ", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes''' ", + "* unitAttribute ", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes''' ", + "* unitClass1 ", + "** unit1 ", + "* unitClass2 ", + "** unit1 ", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes''' ", + "* unitAttribute ", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes''' ", + "* unitAttribute ", + "* unitAttribute ", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes''' ", + "* unitAttribute ", + "'''Properties''' ", + "* unitProperty ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {suggestedTag=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_DUPLICATE_NODE", + "name": "attribute-duplicate-node-unit", + "warning": true, + "description": "A schema attribute issue, saying there is an unknown one.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes''' ", + "* unitClass1 ", + "** volt {SIUnit} ", + "** Volt {SIUnit} ", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes''' ", + "* unitSymbol {unitProperty}", + "* SIUnit {unitProperty}", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes''' ", + "* unitClass1 ", + "** v {unitSymbol} ", + "** V {unitSymbol} ", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes''' ", + "* unitSymbol {unitProperty}", + "* SIUnit {unitProperty}", + "'''Properties''' ", + "* unitProperty ", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_HEADER_INVALID.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_HEADER_INVALID.json new file mode 100644 index 000000000..e0741415d --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_HEADER_INVALID.json @@ -0,0 +1,134 @@ +[ + { + "error_code": "SCHEMA_HEADER_INVALID", + "name": "schema-header-malformed-attribute", + "warning": true, + "description": "A schema attribute issue, saying there is an unknown one.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Using unknown or invalid attributes in schema header", + "Misspelling required header attributes", + "Missing required header attributes for library schemas", + "Invalid version format specification", + "Incorrect library schema attribute combinations" + ], + "explanation": "Schema headers must contain only valid attributes as defined in the HED specification. Unknown attributes indicate potential schema structure problems or specification violations.", + "correction_strategy": "Remove unknown attributes and ensure proper header format", + "correction_examples": [ + { + "wrong": "HED version=\"1.0.0\" unknownAttribute=other", + "correct": "HED version=\"1.0.0\"", + "explanation": "Removed unknown attribute from header" + }, + { + "wrong": "HED version=\"1.0.0\" library=\"test\" missingStandard=\"8.2.0\"", + "correct": "HED version=\"1.0.0\" library=\"test\" withStandard=\"8.2.0\"", + "explanation": "Fixed attribute name from 'missingStandard' to 'withStandard'" + } + ], + "correction_patterns": [ + "Remove unrecognized header attributes", + "Use semantic versioning format", + "Check library schema attribute requirements", + "Verify header syntax matches format specification", + "Ensure version compatibility" + ], + "fix_instructions": [ + "1. Identify unknown or invalid attributes in header", + "2. Remove unrecognized attributes", + "3. Verify required attributes are present", + "4. Check attribute value formats", + "5. Ensure library schema requirements are met" + ], + "validation_hints": [ + "Check against valid HED header attribute list", + "Verify attribute spelling and case sensitivity", + "Ensure library schemas include required attributes", + "Validate version format compliance" + ], + "specification_reference": "3.1.2.1. The header", + "related_errors": ["SCHEMA_VERSION_INVALID", "SCHEMA_LIBRARY_INVALID"], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" unknownAttribute=other", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {suggestedTag=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_HEADER_INVALID", + "name": "schema-header-unknown-attribute", + "warning": true, + "description": "A schema attribute issue, saying there is an unknown one.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" unknownAttribute=\"other\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag-with-unknown''' {suggestedTag=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_LIBRARY_INVALID.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_LIBRARY_INVALID.json new file mode 100644 index 000000000..88962a1a2 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_LIBRARY_INVALID.json @@ -0,0 +1,493 @@ +[ + { + "error_code": "SCHEMA_LIBRARY_INVALID", + "name": "library-invalid-bad-name", + "warning": true, + "description": "A schema library issue, indicating the name is invalid.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Library name contains invalid characters (non-alphabetic)", + "Library name not in lowercase", + "Missing withStandard attribute when library attribute present", + "Invalid withStandard version specification", + "Incorrect rooted attribute usage", + "Mismatched library schema structure" + ], + "explanation": "Library schemas have specific naming and structural requirements. Library names must be alphabetic and lowercase, must specify compatible standard schema versions, and follow strict rules for rooted elements and attribute usage.", + "correction_strategy": "Fix library naming and structural requirements", + "correction_examples": [ + { + "wrong": "library=\"score_invalidchar\"", + "correct": "library=\"score\"", + "explanation": "Removed invalid characters from library name" + }, + { + "wrong": "library=\"SCORE\"", + "correct": "library=\"score\"", + "explanation": "Converted to lowercase as required" + }, + { + "wrong": "library=\"score\"", + "correct": "library=\"score\" withStandard=\"8.2.0\"", + "explanation": "Added required withStandard attribute" + } + ], + "correction_patterns": [ + "Use only lowercase alphabetic characters in library names", + "Include withStandard attribute with library attribute", + "Ensure rooted attribute only in unmerged libraries", + "Match rooted elements to standard schema", + "Remove inLibrary from unmerged schemas" + ], + "fix_instructions": [ + "1. Check library name follows naming rules (lowercase, alphabetic)", + "2. Ensure withStandard attribute present with valid version", + "3. Verify rooted attribute usage matches requirements", + "4. Check library structure matches partnered standard", + "5. Remove inappropriate attributes for library type" + ], + "validation_hints": [ + "Verify library name is lowercase and alphabetic only", + "Check withStandard version exists and is compatible", + "Ensure rooted elements match standard schema", + "Validate library-specific attribute usage" + ], + "specification_reference": "7. Library schemas", + "related_errors": [ + "SCHEMA_HEADER_INVALID", + "SCHEMA_ATTRIBUTE_INVALID" + ], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score_invalidchar\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score1\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"Score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_LIBRARY_INVALID", + "name": "library-invalid-bad_with-standard", + "warning": true, + "description": "A schema library issue, the with-standard attribute is present without the library attribute.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" withStandard=\"8.2.0\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_LIBRARY_INVALID", + "name": "library-invalid-bad_with-standard-version", + "warning": true, + "description": "A schema library issue, indicating it references a version of the standard that can't be found.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.9.9\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"7.9.9\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_LIBRARY_INVALID", + "name": "library-invalid-rooted-present", + "warning": true, + "description": "A schema library issue, indicating the rooted property appears in a file it shouldn't.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\"", + "'''Prologue'''", + "!# start schema", + "'''Event''' {rooted=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Event''' {rooted=Property}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "* rooted {nodeProperty} ", + "'''Properties'''", + "* nodeProperty", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''NewThing''' {rooted=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_LIBRARY_INVALID", + "name": "library-invalid-rooted-not-top-level", + "warning": true, + "description": "A schema library issue, indicating a node is being rooted that is not a top level node.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''NewNode'''", + "* NewExtension {rooted=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''NewNode''' {rooted=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_LIBRARY_INVALID", + "name": "library-invalid-rooted-not-in-base", + "warning": true, + "description": "A schema library issue, rooted tag does not exist.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''DummyTag'''", + "'''NewTag'''{rooted=DummyTag}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''DummyTag'''{rooted=NotRealTag}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''NewTag''' {rooted=Event}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_LIBRARY_INVALID", + "name": "library-invalid-rooted-in-library-present", + "warning": true, + "description": "A schema library issue, indicating the InLibrary attribute appears when it shouldn't.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''NewTag''' {rooted=Event}", + "* ExtendedEvent {inLibrary=score}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''NewTag''' {rooted=Event}", + "* ExtendedEvent", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + }, + { + "error_code": "SCHEMA_LIBRARY_INVALID", + "name": "library-invalid-rooted-in-duplicate-other", + "warning": true, + "description": "A schema library issue, indicating the InLibrary attribute appears when it shouldn't.", + "schema": "", + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''NewTag''' {rooted=Event}", + "* ExtendedEvent", + "!# end schema", + "'''Unit classes'''", + "* weightUnits", + "** g {SIUnit, unitSymbol, conversionFactor=1.0}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"score\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''NewTag''' {rooted=Event}", + "* ExtendedEvent", + "!# end schema", + "'''Unit classes'''", + "* weightUnits", + "** testNewUnit {conversionFactor=10.0}", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_SECTION_MISSING.json b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_SECTION_MISSING.json new file mode 100644 index 000000000..0a7da3edf --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/schema_tests/SCHEMA_SECTION_MISSING.json @@ -0,0 +1,196 @@ +[ + { + "error_code": "SCHEMA_SECTION_MISSING", + "name": "schema-section-missing", + "warning": true, + "description": "A schema attribute issue, saying there is an unknown one.", + "schema": "", + "error_category": "schema_development", + "common_causes": [ + "Missing required schema sections", + "Sections not in correct order", + "Incorrect section markers or delimiters", + "Incomplete schema template usage", + "Copy-paste errors in schema creation" + ], + "explanation": "HED schemas must contain all required sections in the correct order: Prologue, Schema, Unit classes, Unit modifiers, Value classes, Schema attributes, Properties, and Epilogue. Missing or misplaced sections prevent proper schema validation.", + "correction_strategy": "Add missing sections in correct order with proper delimiters", + "correction_examples": [ + { + "wrong": "Missing '''Unit classes''' section", + "correct": "Add '''Unit classes''' after schema section", + "explanation": "Added required section with proper MediaWiki formatting" + }, + { + "wrong": "Sections in wrong order", + "correct": "Reorder to: Prologue, Schema, Unit classes, Unit modifiers, Value classes, Schema attributes, Properties, Epilogue", + "explanation": "Arranged sections in required sequence" + } + ], + "correction_patterns": [ + "Include all required sections even if empty", + "Use proper section delimiters (''' for MediaWiki)", + "Follow exact section ordering requirements", + "Check section names match required format", + "Ensure proper start/end schema markers" + ], + "fix_instructions": [ + "1. Check for all required sections", + "2. Verify sections are in correct order", + "3. Add missing sections with proper delimiters", + "4. Ensure section names match requirements exactly", + "5. Validate schema structure completeness" + ], + "validation_hints": [ + "Empty sections are allowed but must be present", + "Section order is strictly enforced", + "Use exact section names and formatting", + "Check both start and end markers" + ], + "specification_reference": "3.1.2. Schema layout overview", + "related_errors": [ + "SCHEMA_HEADER_INVALID", + "WIKI_SEPARATOR_INVALID" + ], + "definitions": [], + "tests": { + "schema_tests": { + "fails": [ + [ + "HED version=\"1.0.0\"", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Epilogue'''", + "!# end hed" + ], + [ + "HED version=\"1.0.0\"", + "'''Prologue'''", + "!# start schema", + "'''Tag'''", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''" + ] + ], + "passes": [ + [ + "HED version=\"1.0.0\" library=\"testlib\" withStandard=\"8.2.0\" unmerged=\"True\"", + "'''Prologue'''", + "!# start schema", + "'''Tag''' {suggestedTag=Tag}", + "!# end schema", + "'''Unit classes'''", + "'''Unit modifiers'''", + "'''Value classes'''", + "'''Schema attributes'''", + "'''Properties'''", + "'''Epilogue'''", + "!# end hed" + ] + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/CHARACTER_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/CHARACTER_INVALID.json new file mode 100644 index 000000000..0ca038202 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/CHARACTER_INVALID.json @@ -0,0 +1,472 @@ +[ + { + "error_code": "CHARACTER_INVALID", + "alt_codes": ["TAG_INVALID", "UNITS_INVALID", "VALUE_INVALID"], + "name": "character-invalid-non-printing-appears", + "description": "The HED string contains a UTF-8 character.", + "warning": false, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "Copy-pasting text from documents with invisible control characters", + "Including non-printable characters like backspace (\\b), tab, newline in tag values", + "Control characters with codes <= 31 or 127-159", + "Using curly braces {} within tag names or values (not column references)", + "Character encoding issues when importing from other tools" + ], + "explanation": "HED has strict character restrictions that are part of its specification. The name classes in the HED schemas encapsulate these restrictions.", + "correction_strategy": "Remove or replace forbidden characters with allowed alternatives", + "correction_examples": [ + { + "wrong": "Item/Bl\b", + "correct": "Item/Bl", + "explanation": "Removed backspace control character (\\b)" + }, + { + "wrong": "Item/{abc}", + "correct": "Item/abc", + "explanation": "Removed curly braces (only allowed in sidecars)" + }, + { + "wrong": "Label/[value]", + "correct": "Label/value", + "explanation": "Removed square brackets" + }, + { + "wrong": "Label/A test", + "correct": "Label/A-test", + "explanation": "Label has the name class property so it can only contain letters, numbers, hyphens, and underscores. Use the Parameter-value tag instead of Label if you have values with other characters. Parameter-value has text name class which has the fewest restrictions on values." + } + ], + "correction_patterns": [ + "Remove control characters (codes <= 31 or 127-159)", + "Replace square brackets [] with parentheses () or remove", + "Replace tildes ~ with commas for grouping", + "Remove double quotes or replace with single quotes in descriptions", + "Remove curly braces {} unless in sidecar column references", + "Replace tags with restrictive name classes such as Label with less restrictive tags such as Parameter-value when necessary" + ], + "fix_instructions": [ + "1. Scan the HED string for forbidden characters", + "2. Identify the type of forbidden character", + "3. Remove or replace with appropriate alternatives", + "4. For control characters: simply remove them", + "5. For brackets/braces: use appropriate HED syntax instead" + ], + "validation_hints": [ + "Check for invisible characters by examining string length vs visible content", + "Verify UTF-8 encoding compliance (HED 8.3.0+)", + "Ensure no square brackets, tildes, or double quotes remain", + "Confirm curly braces only appear in sidecar column references" + ], + "specification_reference": "2.2. Character sets and restrictions", + "related_errors": ["TAG_INVALID", "SIDECAR_BRACES_INVALID", "VALUE_INVALID"], + "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "Item/Bl\b", + "Item/ABC\u009E" + ], + "passes": [ + "Red, Blue, Description/Red", + "Description/This is a ʰ good character" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "show": "Red, Item/Bl\b" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "show": "Red, Label/a-ʰ-good" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Item/Bl\b"] + ], + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Item/{abc}"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/Temp, Label/a-ʰ-good"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "show": "Red, Item/Bl\b", + "ball": "Def/Acc/4.5" + } + } + }, + "events": + [ + ["onset", "duration", "event_code", "HED"], + [ 4.5, 0, "show", "Description/a ʰ good"], + [ 5.0, 0, "ball", "Blue"] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "show": "Red, Label/a, Description/a ʰ good" + } + } + }, + "events": + [ + ["onset", "duration", "event_code", "HED"], + [ 4.5, 0, "show", "Description/goodness"] + ] + } + ] + } + } + }, + { + "error_code": "CHARACTER_INVALID", + "alt_codes": ["TAG_INVALID", "UNITS_INVALID", "VALUE_INVALID"], + "name": "curly-braces-not-in-sidecar", + "description": "The curly brace notation is used outside a sidecar.", + "warning": false, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "Using curly braces {} in HED strings outside of sidecar column references", + "Mistaking column reference syntax for general HED grouping syntax", + "Copy-pasting sidecar HED content directly into event HED strings" + ], + "explanation": "Curly braces {} are reserved syntax for column references in sidecars only. They cannot be used in direct HED strings or event annotations.", + "correction_strategy": "Remove curly braces or replace with appropriate HED grouping syntax", + "correction_examples": [ + { + "wrong": "{col_1}, Red", + "correct": "Red", + "explanation": "Removed invalid curly brace column reference from direct HED string" + }, + { + "wrong": "Action/{response}", + "correct": "Action/Response", + "explanation": "Replace curly brace placeholder with actual tag value" + } + ], + "correction_patterns": [ + "Remove {column_name} references from direct HED strings", + "Use parentheses () for grouping instead of curly braces", + "Replace placeholder syntax with actual tag values" + ], + "fix_instructions": [ + "1. Identify curly brace usage in HED strings", + "2. Determine if it's intended as a column reference or grouping", + "3. For column references: move to sidecar or replace with actual values", + "4. For grouping: use parentheses instead", + "5. Remove any remaining curly braces" + ], + "validation_hints": [ + "Curly braces are only valid in sidecar HED column definitions", + "Use parentheses for grouping tags together", + "Column references must reference actual sidecar columns" + ], + "specification_reference": "3.4. Sidecar files and column references", + "related_errors": ["SIDECAR_BRACES_INVALID", "TAG_INVALID"], + "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": ["{col_1}, Red"], + "passes": ["Red, Blue, Description/Red"] + }, + "sidecar_tests": { + "fails": [], + "passes": [ + { + "event_code": { + "HED": { + "face": "Statistical-accuracy/0.677, {response}" + } + }, + "response": { + "HED": "Label/#" + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "{who_knows}, Red"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/Temp"] + ] + ] + }, + "combo_tests": { + "fails": [], + "passes": [] + } + } + }, + { + "error_code": "CHARACTER_INVALID", + "alt_codes": ["TAG_INVALID", "VALUE_INVALID"], + "name": "invalid-character-name-value-class", + "description": "An invalid character was used in an 8.3.0 or greater style name value class.", + "warning": false, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "Using special characters (*$%[]) in tags with restrictive name classes", + "Including spaces in label values without using Parameter-value", + "Using symbols not allowed by specific tag name class restrictions", + "Attempting to use characters valid in text class with more restrictive classes" + ], + "explanation": "Different HED tags have different name class restrictions. Label tags can only contain letters, numbers, hyphens and underscores, while Parameter-value has fewer restrictions.", + "correction_strategy": "Replace restricted tags with less restrictive ones or fix the character usage", + "correction_examples": [ + { + "wrong": "Label/30$", + "correct": "Parameter-value/30$", + "explanation": "Use Parameter-value for values with special characters" + }, + { + "wrong": "Parameter-label/[", + "correct": "Parameter-label/bracket", + "explanation": "Replace invalid character with descriptive text" + }, + { + "wrong": "Label/30db kg", + "correct": "Label/30db-kg", + "explanation": "Replace spaces with hyphens in Label values" + } + ], + "correction_patterns": [ + "Replace Label with Parameter-value for values containing special characters", + "Use hyphens instead of spaces in restrictive name classes", + "Remove or replace invalid characters (*$%[]) with valid alternatives" + ], + "fix_instructions": [ + "1. Identify the tag with invalid characters", + "2. Check the tag's name class restrictions", + "3. Either replace invalid characters or use a less restrictive tag", + "4. For Label: use only letters, numbers, hyphens, underscores", + "5. For complex values: consider using Parameter-value instead" + ], + "validation_hints": [ + "Label tags have strict character restrictions", + "Parameter-value allows most characters including spaces and symbols", + "Check HED schema for specific tag name class properties" + ], + "specification_reference": "2.2. Character sets and name classes", + "related_errors": ["TAG_INVALID", "VALUE_INVALID"], + "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "Parameter-label/[", + "Parameter-label/Taco*", + "Label/30$", + "Label/30db kg", + "Item/new*" + ], + "passes": [ + "Parameter-label/Words", + "Label/30e10", + "Label/3e10asdf" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "show": "Parameter-label/[" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": "Parameter-label/#" + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/%max1"] + ], + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/$30"] + ], + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/30db kg"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/3e10asdf"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "response": { + "HED": "Label/#" + } + }, + "events": [ + ["onset", "duration", "response"], + [4.5, 0.0, "A test"] + ] + } + ], + "passes": [] + } + } + }, + { + "error_code": "CHARACTER_INVALID", + "alt_codes": ["TAG_INVALID", "VALUE_INVALID"], + "name": "invalid-character-name-value-class-early-schema", + "description": "An invalid character was as a value in a placeholder or as a tag extension.", + "warning": false, + "schema": "8.2.0", + "error_category": "validation", + "common_causes": [ + "Using special characters in older HED schema versions with stricter character restrictions", + "Including characters not supported in early HED 8.x versions", + "Using modern character sets with legacy schema versions" + ], + "explanation": "Earlier HED schema versions (before 8.3.0) had more restrictive character sets and didn't support some modern characters.", + "correction_strategy": "Upgrade to newer schema version or use only characters supported in the target schema version", + "correction_examples": [ + { + "wrong": "Label/30$ (in schema 8.2.0)", + "correct": "Parameter-value/30$ (upgrade to 8.3.0+) or Label/30-dollars", + "explanation": "Either upgrade schema or use text description instead of symbol" + }, + { + "wrong": "Parameter-label/[ (in schema 8.2.0)", + "correct": "Parameter-label/bracket", + "explanation": "Replace special character with descriptive text" + } + ], + "correction_patterns": [ + "Upgrade to HED schema version 8.3.0 or later for better character support", + "Replace special characters with descriptive text alternatives", + "Use basic ASCII characters for maximum compatibility" + ], + "fix_instructions": [ + "1. Check the HED schema version being used", + "2. Identify characters not supported in that version", + "3. Either upgrade to a newer schema version or replace unsupported characters", + "4. Use descriptive text instead of symbols when possible", + "5. Test with the target schema version" + ], + "validation_hints": [ + "Early HED versions had stricter character restrictions", + "Consider upgrading to HED 8.3.0+ for better character support", + "Use only basic ASCII characters for maximum compatibility" + ], + "specification_reference": "2.2. Character sets and schema versioning", + "related_errors": ["TAG_INVALID", "VALUE_INVALID", "SCHEMA_VERSION_INVALID"], + "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "Parameter-label/[", + "Parameter-label/Taco*", + "Label/30$", + "Label/30db kg" + ], + "passes": [ + "Parameter-label/Words", + "Label/30e10", + "Label/3e10asdf" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "show": "Parameter-label/[" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": "Parameter-label/#" + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/%max1"] + ], + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/$30"] + ], + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/30db kg"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label/3e10asdf"] + ] + ] + }, + "combo_tests": { + "fails": [], + "passes": [] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/COMMA_MISSING.json b/spec_tests/hed-tests/json_test_data/validation_tests/COMMA_MISSING.json new file mode 100644 index 000000000..a6b434c98 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/COMMA_MISSING.json @@ -0,0 +1,392 @@ +[ + { + "error_code": "COMMA_MISSING", + "alt_codes": [], + "name": "comma-missing-tag-groups", + "description": "Two tag groups are not separated by commas: (A, B)(C, D).", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Forgetting to add comma between tag groups", + "Copy-paste errors when combining multiple tag groups", + "Misunderstanding of tag group separation syntax" + ], + "explanation": "HED requires that all tag groups and tags be separated by commas. When two parenthesized tag groups appear consecutively without a comma, the parser cannot determine where one group ends and the next begins.", + "correction_strategy": "Add commas between all tag groups and tags", + "correction_examples": [ + { + "wrong": "(Red, Blue)(Green, Yellow)", + "correct": "(Red, Blue), (Green, Yellow), (((Black)))", + "explanation": "Added comma between the two tag groups" + }, + { + "wrong": "Red(Def/Acc/3.5)", + "correct": "Red, (Def/Acc/3.5)", + "explanation": "Added comma between tag group and a tag" + } + ], + "correction_patterns": [ + "Insert comma between ')(' patterns", + "Insert comma between tag and '(' or ')' if tag is not inside the parentheses", + "Ensure all top-level elements are comma-separated" + ], + "fix_instructions": [ + "1. Ensure each element (whether tag or group) is separated from other elements by commas" + ], + "validation_hints": [ + "Count opening and closing parentheses to ensure they match", + "Verify no ')(' patterns exist without commas", + "Check that the corrected string parses without syntax errors" + ], + "specification_reference": "3.2.7.1. Parentheses and order", + "related_errors": [ + "PARENTHESES_MISMATCH", + "TAG_EMPTY" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Red, Blue)(Green, (Yellow))", + "(Def/MyColor, Onset)(Def/Acc/3.5)" + ], + "passes": [ + "(Red, Blue), (Green, (Yellow))", + "(Def/MyColor, Onset),(Def/Acc/3.5)" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue)(Green, (Yellow))", + "ball": "(Def/MyColor, Onset)(Def/Acc/3.5)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, ( Yellow))", + "ball": "(Def/MyColor, Onset),(Def/Acc/3.5)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Red, Blue)(Green, (Yellow))" + ], + [ + 5.5, + 0, + "(Def/MyColor, Onset)(Def/Acc/3.5)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Red, Blue), (Green, (Yellow))" + ], + [ + 5.5, + 0, + "(Def/MyColor, Onset),(Def/Acc/3.5)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue)(Green, (Yellow))", + "ball": "(Def/MyColor, Onset)(Def/Acc/3.5)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ], + [ + 6.0, + 0, + "n/a", + "(Blue, Green)(Blue, Red)" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, ( Yellow))", + "ball": "(Def/MyColor, Onset),(Def/Acc/3.5)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "(Green, Def/MyColor),(Red)" + ] + ] + } + ] + } + } + }, + { + "error_code": "COMMA_MISSING", + "alt_codes": [], + "name": "comma-missing-tag-and-group", + "description": "A tag and a tag group are not separated by commas: A(B,D).", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Forgetting to add comma between a tag and a tag group", + "Typing errors when combining tags and groups", + "Misunderstanding that commas are required between all top-level elements" + ], + "explanation": "HED requires commas separating all elements, including between individual tags and tag groups. When a tag appears directly before a tag group without a comma, it creates parsing ambiguity.", + "correction_strategy": "Add comma between tag and tag group", + "correction_examples": [ + { + "wrong": "Red(Green, Yellow)", + "correct": "Red, (Green, Yellow)", + "explanation": "Added comma between the tag 'Red' and the tag group" + }, + { + "wrong": "(Def/MyColor, Onset)Def/Acc/3.5", + "correct": "(Def/MyColor, Onset), Def/Acc/3.5", + "explanation": "Added comma between the tag group and the following tag" + } + ], + "correction_patterns": [ + "Insert comma between tag and '(' when tag is at top level", + "Insert comma between ')' and tag when both are at top level", + "Ensure all top-level elements are comma-separated" + ], + "fix_instructions": [ + "1. Identify tags that appear before '(' without commas", + "2. Identify tags that appear after ')' without commas", + "3. Insert commas between these elements", + "4. Verify proper spacing around commas" + ], + "validation_hints": [ + "Check for patterns like 'tag(' or ')tag'", + "Ensure commas separate all top-level elements", + "Verify the string parses correctly after correction" + ], + "specification_reference": "3.2.7.1. Parentheses and order", + "related_errors": [ + "PARENTHESES_MISMATCH", + "TAG_EMPTY" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Red, Blue(Green, (Yellow))", + "(Def/MyColor, Onset)Def/Acc/3.5" + ], + "passes": [ + "Red, (Green, (Yellow))", + "(Def/MyColor, Onset),Def/Acc/3.5" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Red(Green, (Yellow))", + "ball": "(Def/MyColor, Onset)Def/Acc/3.5" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Red, (Green, (Yellow))", + "ball": "(Def/MyColor, Onset),Def/Acc/3.5" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red(Green, (Yellow))" + ], + [ + 5.5, + 0, + "(Def/MyColor, Onset)Def/Acc/3.5" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, (Green, (Yellow))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red(Green, (Yellow))", + "ball": "(Def/MyColor, Onset)Def/Acc/3.5" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ], + [ + 6.0, + 0, + "n/a", + "(Green, Yellow)Red" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red, (Green, (Yellow))", + "ball": "(Def/MyColor, Onset),Def/Acc/3.5" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/DEFINITION_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/DEFINITION_INVALID.json new file mode 100644 index 000000000..55e35d2de --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/DEFINITION_INVALID.json @@ -0,0 +1,1455 @@ +[ + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [ + "TAG_GROUP_ERROR", + "TAG_INVALID" + ], + "name": "definition-invalid-tag-group", + "description": "A Definition tag does not appear in a tag group at the top level in an annotation.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Definition tag not enclosed in parentheses", + "Definition appearing in nested groups instead of top-level", + "Multiple definitions in the same group", + "Definition mixed with other content improperly", + "Using curly braces in definitions" + ], + "explanation": "Definitions must appear in their own top-level tag group containing only the Definition tag and a single inner group with the definition's content. They cannot be nested or mixed with other tags at the top level.", + "correction_strategy": "Ensure definitions are properly structured in top-level groups", + "correction_examples": [ + { + "wrong": "Definition/Apple, (Blue)", + "correct": "(Definition/Apple, (Blue))", + "explanation": "Enclosed definition in required parentheses" + }, + { + "wrong": "(Definition/Apple, (Blue)), ((Definition/Blech, (Red)))", + "correct": "(Definition/Apple, (Blue)), (Definition/Blech, (Red))", + "explanation": "Removed extra nesting from second definition" + }, + { + "wrong": "(Definition/Test, Red, (Blue))", + "correct": "(Definition/Test, (Red, Blue))", + "explanation": "Moved all content into the single inner group" + } + ], + "correction_patterns": [ + "Enclose Definition tag and content in top-level parentheses", + "Ensure only Definition tag and one inner group in definition group", + "Remove extra nesting levels", + "Separate multiple definitions into different top-level groups", + "Replace curly braces with proper HED syntax" + ], + "fix_instructions": [ + "1. Identify Definition tags in the annotation", + "2. Ensure each Definition is in its own top-level group", + "3. Verify group contains only Definition tag and one inner group", + "4. Check that Definition doesn't appear in nested groups", + "5. Separate multiple definitions appropriately" + ], + "validation_hints": [ + "Count parentheses levels to ensure proper nesting", + "Verify no extra tags alongside Definition in same group", + "Check that definitions appear only at top level", + "Ensure inner content is properly grouped" + ], + "specification_reference": "3.2.8.1. The Definition tag", + "related_errors": [ + "TAG_GROUP_ERROR", + "PARENTHESES_MISMATCH", + "DEF_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Definition/Apple, (Blue)), ((Definition/Blech, (Red)))", + "Definition/Blech, (Red)" + ], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Blue)), ((Definition/Blech, (Red)))", + "def2": "Definition/Blech, (Red)" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "def1": "(Definition/Blech, (Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Blue)), ((Definition/Blech, (Red)))", + "def2": "Definition/Blech, (Red)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/MyColor, Def/Apple" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Blue))", + "def2": "(Definition/Blech, (Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/MyColor, Def/Apple" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [ + "TAG_EMPTY" + ], + "name": "definition-invalid-empty-inner-group", + "description": "A definition's enclosing tag group has an empty inner group (i.e., the definition's contents).", + "warning": false, + "schema": "8.4.0", + "error_category": "content", + "common_causes": [ + "Empty parentheses in definition content", + "Missing definition body content", + "Syntax errors creating empty groups", + "Incomplete definition specification" + ], + "explanation": "Definitions must contain meaningful content within their inner groups. Empty inner groups indicate incomplete or malformed definitions.", + "correction_strategy": "Add proper content to definition inner groups", + "correction_examples": [ + { + "wrong": "(Definition/MyEvent, ())", + "correct": "(Definition/MyEvent, (Red, Blue))", + "explanation": "Added actual content to empty definition group" + }, + { + "wrong": "(Definition/Action/#, (,))", + "correct": "(Definition/Action/#, (Motion/# m-per-s^2))", + "explanation": "Replaced malformed content with proper definition" + } + ], + "correction_patterns": [ + "Add meaningful tags to definition content", + "Remove empty parentheses groups", + "Ensure definition content is complete" + ], + "fix_instructions": [ + "1. Identify empty inner groups in definitions", + "2. Add appropriate content tags", + "3. Verify definition completeness", + "4. Remove empty or malformed groups" + ], + "validation_hints": [ + "Check for empty parentheses in definitions", + "Ensure definition content is meaningful", + "Verify no missing content" + ], + "specification_reference": "3.2.8.1. Definition content requirements", + "related_errors": ["TAG_EMPTY", "PARENTHESES_MISMATCH"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def2": "(Definition/Blech/#, ())" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple)" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def2": "(Definition/Blech/#, ())" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/MyColor, Def/Apple" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple)", + "def2": "(Definition/Blech, (Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/MyColor, Def/Apple" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "definition-invalid-multiple-definition-tags", + "description": "A definition's enclosing tag group contains more than a `Definition` tag and an inner group.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Adding extra Definition tags in the same group", + "Misunderstanding that definitions should contain only one Definition tag", + "Attempting to define multiple things in one group", + "Confusion about definition group structure" + ], + "explanation": "Each definition group should contain exactly one Definition tag and its content group. Multiple Definition tags in the same group create structural ambiguity.", + "correction_strategy": "Use separate definition groups for each Definition tag", + "correction_examples": [ + { + "wrong": "(Definition/Event1, Definition/Event2, (Red, Blue))", + "correct": "(Definition/Event1, (Red)), (Definition/Event2, (Blue))", + "explanation": "Separated multiple definitions into individual groups" + }, + { + "wrong": "(Definition/Action, Definition/Response, (Movement))", + "correct": "(Definition/Action, (Movement)), (Definition/Response, (Movement))", + "explanation": "Created separate definition groups with appropriate content" + } + ], + "correction_patterns": [ + "Create separate groups for each Definition tag", + "Ensure each definition has its own content group", + "Remove extra Definition tags from single groups" + ], + "fix_instructions": [ + "1. Identify groups with multiple Definition tags", + "2. Separate each Definition into its own group", + "3. Distribute content appropriately between definitions", + "4. Verify each definition group structure" + ], + "validation_hints": [ + "Count Definition tags per group", + "Ensure one Definition per group maximum", + "Check definition content distribution" + ], + "specification_reference": "3.2.8.1. Definition group structure", + "related_errors": ["TAG_GROUP_ERROR", "DEFINITION_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, Definition/Banana, (Blue))", + "def2": "(Definition/Blech, (Red), Definition/Banana1)", + "def3": "(Definition/Blech1, (Red), Blue)" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Blue))", + "def2": "((Red), Definition/Blech)" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, Definition/Banana, (Blue))", + "def2": "(Definition/Blech, (Red), Definition/Banana1)", + "def3": "(Definition/Blech1, (Red), Blue)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Apple, Def/Banana" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Blue))", + "def2": "((Red), Definition/Blech)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Blech, Def/Apple" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "definition-invalid-inner-group-defs", + "description": "A definition's inner tag group contains `Definition`, `Def` or `Def-expand` tags.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Nested Definition tags within definition content", + "Including Def or Def-expand tags inside definition inner groups", + "Attempting to define definitions within definitions", + "Confusion about definition content structure" + ], + "explanation": "Definition inner groups should contain only the content being defined, not other definition-related tags. Nested definitions create circular reference issues.", + "correction_strategy": "Remove definition-related tags from inner groups or restructure", + "correction_examples": [ + { + "wrong": "(Definition/Event, (Red, Definition/Action, Blue))", + "correct": "(Definition/Event, (Red, Blue)), (Definition/Action, (Movement))", + "explanation": "Moved nested Definition to separate top-level definition" + }, + { + "wrong": "(Definition/Response, (Def/Action, Green))", + "correct": "(Definition/Response, (Green))", + "explanation": "Removed Def tag from definition content" + } + ], + "correction_patterns": [ + "Move nested definitions to top level", + "Remove Def/Def-expand tags from definition content", + "Keep definition content simple and non-recursive" + ], + "fix_instructions": [ + "1. Identify definition-related tags in inner groups", + "2. Remove or move them to appropriate locations", + "3. Ensure definition content contains only descriptive tags", + "4. Verify no circular references exist" + ], + "validation_hints": [ + "Check inner groups for Definition/Def/Def-expand tags", + "Ensure definition content is purely descriptive", + "Verify no recursive definition structures" + ], + "specification_reference": "3.2.8.1. Definition content restrictions", + "related_errors": ["TAG_GROUP_ERROR", "DEFINITION_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Definition/Banana, Blue))", + "def2": "(Definition/Blech, (Red, Def/Apple))" + } + } + } + ], + "passes": [] + }, + "event_tests": { + "fails": [], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Label/a" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Definition/Banana, (Blue)))", + "def2": "(Definition/Blech, ((Red), Def/MyColor))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Apple, Def/Banana" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Blue))", + "def2": "((Red), Definition/Blech)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Blech, Def/Apple" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [], + "name": "definition-invalid-bad-number-of-placeholders", + "description": "A definition that includes a placeholder (`#`) does not have exactly two `#` characters.", + "warning": false, + "schema": "8.4.0", + "error_category": "placeholder", + "common_causes": [ + "Unequal number of placeholders in definition and content", + "Missing placeholder in definition name or content", + "Extra placeholders beyond the required pair", + "Misunderstanding placeholder pairing requirements", + "Incomplete placeholder implementation" + ], + "explanation": "Definitions with placeholders must have exactly two # characters: one in the definition name and one in the content. This creates a proper placeholder substitution pattern.", + "correction_strategy": "Ensure exactly two # characters in definition", + "correction_examples": [ + { + "wrong": "(Definition/Apple/#, (Label/#, Description/#))", + "correct": "(Definition/Apple/#, (Label/#))", + "explanation": "Removed extra placeholder to have exactly two" + }, + { + "wrong": "(Definition/Blech/#, (Red))", + "correct": "(Definition/Blech/#, (Red, Label/#))", + "explanation": "Added missing placeholder in content" + } + ], + "correction_patterns": [ + "Count # characters and ensure exactly two total", + "Add missing # in content if definition name has #", + "Remove extra # characters beyond the required pair", + "Verify placeholder pairing consistency" + ], + "fix_instructions": [ + "1. Count total # characters in definition", + "2. Ensure definition name has # if using placeholders", + "3. Add exactly one # in definition content", + "4. Remove any extra # characters", + "5. Verify placeholder substitution pattern" + ], + "validation_hints": [ + "Count # characters - should be exactly 2", + "One # in definition name, one # in content", + "Remove extra placeholders", + "Add missing placeholder pairs" + ], + "specification_reference": "3.2.8.1. Definition placeholder requirements", + "related_errors": [ + "PLACEHOLDER_INVALID", + "DEFINITION_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#, Description/#))", + "def2": "(Definition/Blech/#, (Red))" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#))", + "def2": "(Definition/Blech/#, (Red, Label/#))" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#, Description/#))", + "def2": "(Definition/Blech/#, (Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Apple/3, Def/Blech/might" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#))", + "def2": "(Definition/Blech/#, (Red, Label/#))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Blech/5, Def/Apple/4" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [ + "TAG_INVALID", + "PLACEHOLDER_INVALID" + ], + "name": "definition-invalid-placeholder-incorrect-of-positions", + "description": "A definition has placeholders (`#`) in incorrect positions.", + "warning": false, + "schema": "8.4.0", + "error_category": "placeholder", + "common_causes": [ + "Placeholder in content without corresponding definition placeholder", + "Standalone # character not properly positioned", + "Mismatched placeholder positions in definition structure", + "Incorrect placeholder syntax usage", + "Misunderstanding of placeholder positioning rules" + ], + "explanation": "Placeholders must be properly positioned: in definition names they appear as suffix (/Name/#), in content they replace specific values. Incorrect positioning breaks substitution logic.", + "correction_strategy": "Position placeholders correctly in definition structure", + "correction_examples": [ + { + "wrong": "(Definition/Apple, (Label/#))", + "correct": "(Definition/Apple/#, (Label/#))", + "explanation": "Added placeholder to definition name to match content" + }, + { + "wrong": "(Definition/Blech/#, (Red, #))", + "correct": "(Definition/Blech/#, (Red, Label/#))", + "explanation": "Placed placeholder in proper tag position" + } + ], + "correction_patterns": [ + "Add # to definition name when content has placeholders", + "Replace standalone # with proper tag/# format", + "Ensure placeholders appear in valid tag positions", + "Match definition name and content placeholder usage" + ], + "fix_instructions": [ + "1. Check if content has # but definition name lacks #", + "2. Add # suffix to definition name if needed", + "3. Replace standalone # with proper tag/# format", + "4. Verify placeholder positioning rules", + "5. Test placeholder substitution logic" + ], + "validation_hints": [ + "Definition names with placeholders end in /#", + "Content placeholders appear in tag/# format", + "No standalone # characters", + "Match definition and content placeholder usage" + ], + "specification_reference": "3.2.8.1. Placeholder positioning requirements", + "related_errors": [ + "PLACEHOLDER_INVALID", + "TAG_INVALID", + "DEFINITION_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Label/#))", + "def2": "(Definition/Blech/#, (Red, #))" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Label/Blue))", + "def2": "(Definition/Blech/#, (Label/#, Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Label/#))", + "def2": "(Definition/Blech/#, (Red, #))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Apple, Def/Blech/might" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#))", + "def2": "(Definition/Blech/#, (Red, Label/#))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Blech/5, Def/Apple/4" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [ + "TAG_INVALID", + "PLACEHOLDER_INVALID" + ], + "name": "definition-invalid-placeholder-conflict", + "description": "Definitions of the same name appear with and without a `#`.", + "warning": false, + "schema": "8.4.0", + "error_category": "consistency", + "common_causes": [ + "Mixing placeholder and non-placeholder versions of same definition", + "Inconsistent definition naming across files", + "Confusion about when to use placeholders", + "Copy-paste errors with different placeholder usage", + "Misunderstanding definition uniqueness requirements" + ], + "explanation": "Each definition name must be used consistently either with or without placeholders. Mixed usage creates ambiguity about which definition applies and breaks substitution logic.", + "correction_strategy": "Use consistent placeholder approach for each definition name", + "correction_examples": [ + { + "wrong": "(Definition/Apple, (Label/#)) and (Definition/Apple/#, (Red, #))", + "correct": "(Definition/Apple/#, (Label/#)) and (Definition/Other/#, (Red, #))", + "explanation": "Made placeholder usage consistent or used different names" + }, + { + "wrong": "Definition/Event with and without # in same file", + "correct": "Definition/Event consistently without # or Definition/Event/# consistently with #", + "explanation": "Chose one approach and applied consistently" + } + ], + "correction_patterns": [ + "Choose placeholder or non-placeholder approach per definition", + "Rename definitions to avoid conflicts", + "Update all instances to use consistent placeholder usage", + "Verify definition name uniqueness" + ], + "fix_instructions": [ + "1. Identify conflicting definition names", + "2. Decide on placeholder vs non-placeholder approach", + "3. Update all instances to use consistent approach", + "4. Or rename one definition to avoid conflict", + "5. Verify definition consistency across files" + ], + "validation_hints": [ + "Each definition name must be consistently used", + "Check for same name with/without # conflicts", + "Verify placeholder usage consistency", + "Ensure definition name uniqueness" + ], + "specification_reference": "3.2.8.1. Definition consistency requirements", + "related_errors": [ + "DEFINITION_INVALID", + "PLACEHOLDER_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Label/#))", + "def2": "(Definition/Apple/#, (Red, #))" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "def1": "(Definition/Blech/#, (Label/#))", + "def2": "(Definition/Apple, (Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Label/#))", + "def2": "(Definition/Apple/#, (Red, #))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Apple/3, Def/Apple" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#))", + "def2": "(Definition/Blech, (Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Blech, Def/Apple/4" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [], + "name": "definition-invalid-multiple-definitions", + "description": "Multiple `Definition` tags with same name are encountered.", + "warning": false, + "schema": "8.4.0", + "error_category": "uniqueness", + "common_causes": [ + "Duplicate definition names across different definition groups", + "Copy-paste errors creating multiple definitions with same name", + "Misunderstanding that definition names must be unique", + "Attempting to override or extend existing definitions", + "Inconsistent definition management across files" + ], + "explanation": "Each definition name must be unique within the annotation context. Multiple definitions with the same name create ambiguity about which definition to use for expansion.", + "correction_strategy": "Ensure unique names for all definitions", + "correction_examples": [ + { + "wrong": "(Definition/Apple/#, (Label/#)) and (Definition/Apple/#, (Color/#))", + "correct": "(Definition/Apple/#, (Label/#)) and (Definition/AppleColor/#, (Color/#))", + "explanation": "Renamed second definition to make it unique" + }, + { + "wrong": "Multiple Definition/Event with different content", + "correct": "Definition/Event1, Definition/Event2 with distinct names", + "explanation": "Used numbered or descriptive suffixes for uniqueness" + } + ], + "correction_patterns": [ + "Rename duplicate definitions with descriptive suffixes", + "Use numbered variations (Event1, Event2)", + "Combine definitions if content is compatible", + "Remove truly duplicate definitions" + ], + "fix_instructions": [ + "1. Identify definitions with identical names", + "2. Examine content to determine if truly different", + "3. Rename definitions with descriptive unique names", + "4. Update all references to use new names", + "5. Verify definition name uniqueness" + ], + "validation_hints": [ + "Scan for duplicate definition names", + "Ensure each definition has unique name", + "Check references match renamed definitions", + "Verify no name conflicts across files" + ], + "specification_reference": "3.2.8.1. Definition uniqueness requirements", + "related_errors": [ + "DEFINITION_INVALID", + "DEF_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#, Description/#))", + "def2": "(Definition/Apple/#, (Label/#))", + "def3": "(Definition/MyColor, (Blue))" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/ThisIsALabel, Description/#))", + "def2": "(Definition/Apple2/#, (Label/#))", + "def3": "(Definition/MyColor2, (Blue))" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#, Description/#))", + "def2": "(Definition/Apple/#, (Label/#))", + "def3": "(Definition/MyColor, (Blue))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Apple/3, Def/Blech/might" + ], + [ + 5.0, + 0, + "Def/MyColor" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#))", + "def2": "(Definition/Blech/#, (Red, Label/#))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Blech/5, Def/Apple/4" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "definition-invalid-content-has-top-level-tag", + "description": "A tag with a required or unique attribute appears in a definition.", + "warning": false, + "schema": "8.4.0", + "error_category": "content", + "common_causes": [ + "Using top-level or unique tags within definition content", + "Including Event-context or other required tags in definitions", + "Misunderstanding that definitions should contain reusable content", + "Adding context-specific tags to generic definitions", + "Confusion about what content is appropriate in definitions" + ], + "explanation": "Definition content should contain reusable, generic tags without required or unique attributes. Top-level tags violate definition reusability principles.", + "correction_strategy": "Remove required/unique tags from definition content", + "correction_examples": [ + { + "wrong": "(Definition/Apple, (Event-context, Red))", + "correct": "(Definition/Apple, (Red))", + "explanation": "Removed Event-context which is a required/unique tag" + }, + { + "wrong": "(Definition/Action, (Task-context, Movement))", + "correct": "(Definition/Action, (Movement))", + "explanation": "Kept only generic content without context requirements" + } + ], + "correction_patterns": [ + "Remove Event-context and similar required tags", + "Keep only generic, reusable content in definitions", + "Avoid context-specific or unique tags in definitions", + "Focus on core descriptive content" + ], + "fix_instructions": [ + "1. Identify required/unique tags in definition content", + "2. Remove Event-context and similar tags", + "3. Keep only generic, reusable tags", + "4. Verify definition contains appropriate content", + "5. Test definition reusability" + ], + "validation_hints": [ + "Check for Event-context in definitions", + "Remove required or unique attribute tags", + "Keep definition content generic and reusable", + "Verify appropriate definition content" + ], + "specification_reference": "3.2.8.1. Definition content restrictions", + "related_errors": [ + "TAG_GROUP_ERROR", + "TAG_INVALID", + "DEFINITION_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Event-context, Red))", + "def2": "(Definition/Banana/#, (Label/#))" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Red))", + "def2": "(Definition/Banana/#, (Label/#))" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Event-context, Red))", + "def2": "(Definition/Banana/#, (Label/#))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Apple, Def/Banana/might" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple, (Red))", + "def2": "(Definition/Banana/#, (Label/#))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Apple, Def/Banana/might" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEFINITION_INVALID", + "alt_codes": [ + "TAG_INVALID" + ], + "name": "definition-not-allowed-here", + "description": "A definition appears in an unexpected place such as an events file or sidecar.", + "warning": false, + "schema": "8.4.0", + "error_category": "context", + "common_causes": [ + "Placing definitions in event annotations instead of definition section", + "Including definitions in regular HED strings", + "Misunderstanding that definitions belong in specific sections", + "Confusion about definition vs definition usage (Def/Name)", + "Incorrect file structure for definition placement" + ], + "explanation": "Definitions should only appear in designated definition sections or files, not mixed with regular event annotations. Use Def/Name to reference definitions, not Definition tags.", + "correction_strategy": "Move definitions to appropriate sections or use Def references", + "correction_examples": [ + { + "wrong": "Red, Blue, (Definition/myDef, (Label/Red, Blue))", + "correct": "Red, Blue, Def/myDef", + "explanation": "Replaced definition declaration with definition reference" + }, + { + "wrong": "Event HED with embedded definition", + "correct": "Move definition to defs section, use Def/Name in events", + "explanation": "Separated definition declaration from usage" + } + ], + "correction_patterns": [ + "Move Definition tags to defs section of sidecar", + "Replace Definition with Def/Name in event annotations", + "Separate definition declaration from usage", + "Use proper file structure for definitions" + ], + "fix_instructions": [ + "1. Identify misplaced Definition tags", + "2. Move definitions to appropriate defs section", + "3. Replace Definition usage with Def/Name references", + "4. Verify proper file structure", + "5. Test definition references work correctly" + ], + "validation_hints": [ + "Definitions belong in defs sections only", + "Use Def/Name to reference definitions", + "Check file structure for proper definition placement", + "Separate definition declaration from usage" + ], + "specification_reference": "3.2.8.1. Definition placement requirements", + "related_errors": [ + "TAG_INVALID", + "SIDECAR_INVALID", + "DEF_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Item, (Label/Pie)))" + ], + "tests": { + "string_tests": { + "fails": [ + "Red, Blue, (Definition/myDef, (Label/Red, Blue))" + ], + "passes": [ + "Red, Blue" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Red, Blue, (Definition/myDef, (Label/Red, Blue))", + "ball": "Def/Acc/4.5" + } + } + } + ], + "passes": [ + { + "defs": { + "HED": { + "face": "(Definition/myDef, (Label/Red, Blue)), (Definition/myDef2, (Label/Red, Blue))", + "ball": "(Definition/myDef1, (Label/Red, Blue))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Definition/myDef, (Label/Red, Green))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, Blue, Def/MyColor" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red, Blue, (Definition/myDef, (Label/Red, Blue))", + "ball": "Def/Acc/4.5" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/myDef, Red" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "defs": { + "HED": { + "def1": "(Definition/Apple/#, (Label/#))", + "def2": "(Definition/Blech/#, (Red, Label/#))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def/Blech/5, Def/Apple/4" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/DEF_EXPAND_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/DEF_EXPAND_INVALID.json new file mode 100644 index 000000000..a28e98d39 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/DEF_EXPAND_INVALID.json @@ -0,0 +1,1219 @@ +[ + { + "error_code": "DEF_EXPAND_INVALID", + "alt_codes": [], + "name": "def-expand-invalid-name-not-definition", + "description": "A `Def-expand` tag's name does not correspond to a definition.", + "warning": false, + "schema": "8.4.0", + "error_category": "semantic", + "common_causes": [ + "Referencing undefined definition names", + "Misspelling definition names in Def-expand", + "Using Def-expand before defining the definition", + "Mismatch between placeholder values and definition requirements", + "Incorrect structure of Def-expand groups" + ], + "explanation": "Def-expand tags must reference existing definitions and provide the correct structure and placeholder values. The name must exactly match a previously defined Definition, and any placeholders must be filled with appropriate values.", + "correction_strategy": "Ensure Def-expand references valid definitions with correct structure", + "correction_examples": [ + { + "wrong": "(Def-expand/MyColor2, (Label/Pie))", + "correct": "(Def-expand/MyColor, (Label/Pie))", + "explanation": "Corrected definition name to match existing Definition/MyColor" + }, + { + "wrong": "(Def-expand/Acc, (Acceleration/5 m-per-s^2, Red))", + "correct": "(Def-expand/Acc/5, (Acceleration/5 m-per-s^2, Red))", + "explanation": "Added required placeholder value for parameterized definition" + } + ], + "correction_patterns": [ + "Verify definition name exists and is spelled correctly", + "Provide placeholder values for parameterized definitions", + "Ensure expanded content matches definition structure", + "Check that definition is available in current scope", + "Verify proper tag group structure for Def-expand" + ], + "fix_instructions": [ + "1. Check that referenced definition exists", + "2. Verify spelling of definition name", + "3. Provide required placeholder values if definition is parameterized", + "4. Ensure expanded content matches definition exactly", + "5. Verify proper group structure" + ], + "validation_hints": [ + "Cross-reference with available definitions", + "Check definition parameter requirements", + "Verify expanded content structure", + "Ensure proper tag group formatting" + ], + "specification_reference": "3.2.8.2. The Def and Def-expand tags", + "related_errors": [ + "DEF_INVALID", + "DEFINITION_INVALID", + "TAG_GROUP_ERROR" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def-expand/MyColor2, (Label/Pie))" + ], + "passes": [ + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc2/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/MyColor2, (Label/Pie))" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/MyColor, (Label/Pie))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc2/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ], + [ + 5.5, + 0, + "(Def-expand/MyColor2, (Label/Pie))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ], + [ + 5.5, + 0, + "(Def-expand/MyColor, (Label/Pie))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc2/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/MyColor2, (Label/Pie))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ], + [ + 5.0, + 0, + "ball", + "(Def-expand/Junk, (Label/Red))" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/MyColor, (Label/Pie))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ], + [ + 5.5, + 0, + "(Def-expand/MyColor, (Label/Pie))" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEF_EXPAND_INVALID", + "alt_codes": [ + "VALUE_INVALID" + ], + "name": "def-expand-invalid-missing-placeholder", + "description": "A `Def-expand` is missing an expected placeholder value or has an unexpected placeholder value.", + "warning": false, + "schema": "8.4.0", + "error_category": "content", + "common_causes": [ + "Missing required placeholder values in Def-expand", + "Providing placeholder values when definition doesn't expect them", + "Mismatch between definition placeholder count and Def-expand values", + "Confusion about which definitions require placeholders" + ], + "explanation": "Def-expand tags must provide exactly the placeholder values expected by their referenced definition. Mismatched placeholder counts create expansion errors.", + "correction_strategy": "Match Def-expand placeholder values to definition requirements", + "correction_examples": [ + { + "wrong": "(Def-expand/Acc, (Acceleration, Red))", + "correct": "(Def-expand/Acc/5.0, (Acceleration/5.0 m-per-s^2, Red))", + "explanation": "Added missing placeholder value for definition requiring one" + }, + { + "wrong": "(Def-expand/MyColor/Blue, (Label/Pie))", + "correct": "(Def-expand/MyColor, (Label/Pie))", + "explanation": "Removed unexpected placeholder for definition not requiring one" + } + ], + "correction_patterns": [ + "Check definition for placeholder requirements", + "Provide values for all required placeholders", + "Remove values for definitions without placeholders" + ], + "fix_instructions": [ + "1. Check the referenced definition for placeholder count", + "2. Provide exactly the required number of placeholder values", + "3. Remove extra values or add missing values as needed", + "4. Verify placeholder value types match definition expectations" + ], + "validation_hints": [ + "Count # symbols in definition to determine placeholder needs", + "Verify Def-expand provides correct number of values", + "Check placeholder value types are compatible" + ], + "specification_reference": "3.2.8.2. Def-expand placeholder requirements", + "related_errors": ["VALUE_INVALID", "DEFINITION_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def-expand/Acc, (Acceleration, Red))", + "(Def-expand/MyColor/Blue, (Label/Pie))" + ], + "passes": [ + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc, (Acceleration, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration, Red))" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc, (Acceleration, Red))" + ], + [ + 5.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration, Red))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc, (Acceleration, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration, Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code" + ], + [ + 4.5, + 0, + "face" + ], + [ + 5.5, + 0, + "ball" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ], + [ + 5.2, + 0, + "ball", + "(Def-expand/MyColor, (Label/Pie))" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEF_EXPAND_INVALID", + "alt_codes": [ + "VALUE_INVALID", + "UNITS_INVALID" + ], + "name": "def-expand-invalid-bad-placeholder-value-or-units", + "description": "A `Def-expand` has an incorrect type of placeholder value.", + "warning": false, + "schema": "8.4.0", + "error_category": "value", + "common_causes": [ + "Placeholder values with incorrect data types", + "Missing or incorrect units in placeholder substitutions", + "Non-numeric values where numbers are expected", + "Improper unit formatting in expanded definitions", + "Mismatched value types between definition and expansion" + ], + "explanation": "Def-expand placeholder values must match the expected data type and unit format specified in the definition. Type mismatches create invalid tag structures.", + "correction_strategy": "Ensure placeholder values match definition requirements", + "correction_examples": [ + { + "wrong": "(Def-expand/Acc/Make-me, (Acceleration/Make-me, Red))", + "correct": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "explanation": "Replaced invalid string with proper numeric value" + }, + { + "wrong": "(Def-expand/Acc/4.5, (Acceleration/4.5 m, Red))", + "correct": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "explanation": "Corrected units to match definition requirements" + } + ], + "correction_patterns": [ + "Use numeric values for numeric placeholders", + "Include proper units with space before unit", + "Match value type to definition expectations", + "Verify unit format consistency" + ], + "fix_instructions": [ + "1. Check definition for expected value type", + "2. Replace invalid values with proper type", + "3. Ensure units match definition format exactly", + "4. Add space between value and units", + "5. Verify placeholder consistency" + ], + "validation_hints": [ + "Numeric placeholders need numeric values", + "Units must match definition format exactly", + "Check for proper spacing in unit formatting", + "Verify value type compatibility" + ], + "specification_reference": "3.2.8.2. Def-expand value type requirements", + "related_errors": [ + "VALUE_INVALID", + "UNITS_INVALID", + "DEF_EXPAND_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def-expand/Acc/Make-me, (Acceleration/Make-me, Red))", + "(Def-expand/Acc/4.5, (Acceleration/4.5 m, Red))", + "(Def-expand/Acc/4.5, (Acceleration/4.5m-per-s^2, Red))" + ], + "passes": [ + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/Make-me, (Acceleration/Make-me, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m, Red))", + "square": "(Def-expand/Acc/4.5, (Acceleration/4.5m-per-s^2, Red))" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/Make-me, (Acceleration/Make-me, Red))" + ], + [ + 5.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m, Red))" + ], + [ + 6.3, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5m-per-s^2, Red))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ], + [ + 5.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/Make-me, (Acceleration/Make-me, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m, Red))", + "square": "(Def-expand/Acc/4.5, (Acceleration/4.5m-per-s^2, Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Def-expand/Acc/Make-me, (Acceleration/Make-me, Red))" + ], + [ + 5.5, + 0, + "ball", + "(Def-expand/Acc/4.5, (Acceleration/4.5 m, Red))" + ], + [ + 6.3, + 0, + "square", + "(Def-expand/Acc/4.5, (Acceleration/4.5m-per-s^2, Red))" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Def-expand/Acc/5.5, (Acceleration/5.5 m-per-s^2, Red))" + ], + [ + 5.5, + 0, + "ball", + "(Def-expand/Acc/5.5, (Acceleration/5.5 m-per-s^2, Red))" + ], + [ + 6.5, + 0, + "n/a", + "n/a" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEF_EXPAND_INVALID", + "alt_codes": [], + "name": "def-expand-invalid-tags-not-in-definition", + "description": "The tags within a Def-expand do not match the corresponding definition.", + "warning": false, + "schema": "8.4.0", + "error_category": "content", + "common_causes": [ + "Expanded content doesn't match definition template", + "Incorrect tag values in expansion", + "Modified content that deviates from definition", + "Wrong placeholder value propagation", + "Misunderstanding of definition expansion rules" + ], + "explanation": "Def-expand content must exactly match the definition template with proper placeholder substitution. Any deviation from the defined structure creates invalid expansions.", + "correction_strategy": "Ensure expanded content matches definition exactly", + "correction_examples": [ + { + "wrong": "(Def-expand/Acc/4.5, (Acceleration/6, Red))", + "correct": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "explanation": "Corrected placeholder substitution and added missing units" + }, + { + "wrong": "(Def-expand/MyColor, (Label/Cake))", + "correct": "(Def-expand/MyColor, (Label/Pie))", + "explanation": "Matched content to exact definition specification" + } + ], + "correction_patterns": [ + "Copy definition structure exactly", + "Substitute placeholders consistently", + "Maintain all required tags from definition", + "Verify content matches definition template" + ], + "fix_instructions": [ + "1. Reference the exact definition structure", + "2. Copy all tags from definition", + "3. Substitute placeholder values correctly", + "4. Verify no extra or missing tags", + "5. Check content matches definition exactly" + ], + "validation_hints": [ + "Compare expansion to definition structure", + "Check placeholder substitution accuracy", + "Verify all definition tags are present", + "Ensure no unauthorized modifications" + ], + "specification_reference": "3.2.8.2. Def-expand content matching requirements", + "related_errors": [ + "DEF_EXPAND_INVALID", + "DEFINITION_INVALID", + "VALUE_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def-expand/Acc/4.5, (Acceleration/6, Red))", + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Blue))", + "(Def-expand/MyColor, (Label/Cake))" + ], + "passes": [ + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/6, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Blue))", + "square": "(Def-expand/MyColor, (Label/Cake))" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/6, Red))" + ], + [ + 5.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Blue))" + ], + [ + 6.3, + 0, + "(Def-expand/MyColor, (Label/Cake))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ], + [ + 5.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/6, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Blue))", + "square": "(Def-expand/MyColor, (Label/Cake))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Def-expand/Acc/4.5, (Acceleration/6, Red))" + ], + [ + 5.5, + 0, + "ball", + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Blue))" + ], + [ + 6.3, + 0, + "square", + "(Def-expand/MyColor, (Label/Cake))" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Def-expand/Acc/6.5, (Acceleration/6.5 m-per-s^2, Red))" + ], + [ + 5.5, + 0, + "ball", + "(Def-expand/Acc/8.5, (Acceleration/8.5 m-per-s^2, Red))" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEF_EXPAND_INVALID", + "alt_codes": [], + "name": "def-expand-missing-inner-group", + "description": "A Def-expand is missing its inner group containing the definition.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Incomplete Def-expand structure missing content group", + "Forgetting to include definition expansion content", + "Misunderstanding Def-expand syntax requirements", + "Copy-paste errors omitting definition content", + "Confusion about Def-expand vs Def usage" + ], + "explanation": "Def-expand must include both the definition reference and the complete expanded content in parentheses. Missing content groups make the expansion incomplete and invalid.", + "correction_strategy": "Add required inner group with definition content", + "correction_examples": [ + { + "wrong": "(Def-expand/Acc/5.4)", + "correct": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))", + "explanation": "Added missing inner group with complete definition expansion" + }, + { + "wrong": "Def-expand/MyColor without content", + "correct": "(Def-expand/MyColor, (Item, (Label/Pie)))", + "explanation": "Included full definition content structure" + } + ], + "correction_patterns": [ + "Add parentheses around complete definition content", + "Include all tags from referenced definition", + "Ensure proper expansion structure", + "Verify content group completeness" + ], + "fix_instructions": [ + "1. Identify incomplete Def-expand structures", + "2. Reference the corresponding definition", + "3. Add parentheses with complete expansion", + "4. Include all definition content", + "5. Verify proper Def-expand syntax" + ], + "validation_hints": [ + "Def-expand must have definition reference and content", + "Check for missing parentheses around content", + "Verify complete definition expansion", + "Ensure all definition tags are included" + ], + "specification_reference": "3.2.8.2. Def-expand structure requirements", + "related_errors": [ + "DEF_EXPAND_INVALID", + "PARENTHESES_MISMATCH", + "TAG_GROUP_ERROR" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Item, (Label/Pie)))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def-expand/Acc/5.4)" + ], + "passes": [ + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Orange", + "ball": "(Def-expand/Acc/4.5)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))", + "ball": "Red" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 5.4, + 0, + "(Def-expand/Acc/5.4 )" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5)", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "(Def-expand/Acc/4.5)" + ], + [ + 5.4, + 0, + "n/a", + "Green" + ], + [ + 6.4, + 0, + "face", + "n/a" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))", + "ball": "(Acceleration/4.5, Blue), Def/MyColor" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "n/a" + ], + [ + 6.5, + 0, + "ball", + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))" + ] + ] + } + ] + } + } + }, + { + "error_code": "DEF_EXPAND_INVALID", + "alt_codes": [ + "DEFINITION_INVALID" + ], + "name": "def-expand-has-extras", + "description": "A Def-expand has extra tags or groups.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Adding extra tags beyond definition expansion", + "Including additional content groups with Def-expand", + "Misunderstanding that Def-expand should be self-contained", + "Mixing regular tags with definition expansion", + "Incorrect grouping with extra elements" + ], + "explanation": "Def-expand should contain only the definition reference and its expanded content. Additional tags or groups violate the self-contained expansion principle.", + "correction_strategy": "Remove extra content from Def-expand groups", + "correction_examples": [ + { + "wrong": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), Blue)", + "correct": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))", + "explanation": "Removed extra tag to keep only definition expansion" + }, + { + "wrong": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), (Blue, Green), Black)", + "correct": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))", + "explanation": "Eliminated all extra groups and tags" + } + ], + "correction_patterns": [ + "Keep only definition reference and expansion content", + "Remove extra tags from Def-expand groups", + "Eliminate additional content groups", + "Maintain self-contained expansion structure" + ], + "fix_instructions": [ + "1. Identify extra content in Def-expand groups", + "2. Remove additional tags beyond definition", + "3. Eliminate extra groups or parentheses", + "4. Keep only definition reference and expansion", + "5. Verify clean Def-expand structure" + ], + "validation_hints": [ + "Def-expand should have exactly two parts: reference and content", + "Remove any extra tags or groups", + "Check for proper self-contained structure", + "Verify no additional elements" + ], + "specification_reference": "3.2.8.2. Def-expand self-containment requirements", + "related_errors": [ + "DEFINITION_INVALID", + "TAG_GROUP_ERROR", + "DEF_EXPAND_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Item, (Label/Pie)))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), Blue)", + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), (Blue, Green), Black)" + ], + "passes": [ + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), Blue)", + "ball": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), (Blue, Green), Black)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))", + "ball": "Red" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), Blue)" + ], + [ + 5.4, + 0, + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), (Blue, Green), Black)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), Blue)", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "Def/Acc, (Def-expand/Acc/4.5)" + ], + [ + 5.4, + 0, + "n/a", + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red), Blue)" + ], + [ + 6.4, + 0, + "face", + "n/a" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))", + "ball": "(Acceleration/4.5 m-per-s^2, Blue), Def/MyColor" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "n/a" + ], + [ + 6.5, + 0, + "ball", + "(Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red))" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/DEF_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/DEF_INVALID.json new file mode 100644 index 000000000..057380da5 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/DEF_INVALID.json @@ -0,0 +1,441 @@ +[ + { + "error_code": "DEF_INVALID", + "alt_codes": [], + "name": "def-invalid-name", + "description": "A `Def` tag's name does not correspond to a definition.", + "warning": false, + "schema": "8.4.0", + "error_category": "semantic", + "common_causes": [ + "Using a Def tag name that doesn't match any available definition", + "Misspelling definition names in Def tags", + "Referencing definitions that were removed or renamed", + "Using outdated definition names from previous schema versions", + "Missing definition parameters when required" + ], + "explanation": "Def tags must reference definitions that actually exist in the current schema or have been previously declared. The definition name in the Def tag must exactly match a declared definition name.", + "correction_strategy": "Use only valid definition names that match existing definitions", + "correction_examples": [ + { + "wrong": "Def/Apple2, Green", + "correct": "Def/Acc/4.5, Green", + "explanation": "Replaced non-existent definition 'Apple2' with valid definition 'Acc'" + }, + { + "wrong": "Def/Acc2/4.5", + "correct": "Def/Acc/4.5", + "explanation": "Fixed definition name typo from 'Acc2' to 'Acc'" + }, + { + "wrong": "Def/Acc", + "correct": "Def/Acc/4.5", + "explanation": "Added required parameter for parameterized definition" + } + ], + "correction_patterns": [ + "Cross-reference definition names with available definitions list", + "Check spelling of definition names carefully", + "Ensure required parameters are provided for parameterized definitions", + "Verify definition scope and availability in current context" + ], + "fix_instructions": [ + "1. Check the list of available definitions in the current schema", + "2. Verify the Def tag name matches an existing definition exactly", + "3. Ensure proper case sensitivity in definition names", + "4. Add required parameters for parameterized definitions", + "5. Remove or replace invalid definition references" + ], + "validation_hints": [ + "Cross-reference with available definitions list", + "Check definition parameter requirements", + "Verify spelling matches definition exactly", + "Ensure definition scope availability" + ], + "specification_reference": "3.2.8.2. The Def and Def-expand tags", + "related_errors": ["DEF_EXPAND_INVALID", "DEFINITION_INVALID", "PLACEHOLDER_INVALID"], + "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "Def/Apple2, Green", + "Def/Acc2/4.5", + "Def/Acc" + ], + "passes": [ + "Def/Acc/4.5" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Def/Apple2, Green", + "ball": "Def/Acc2/4.5, Def/Acc/3.2" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Def/Acc/4.5" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Def/Apple2, Green"], + [ 5.5, 0, "Def/Acc2/4.5"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Def/Acc/4.5"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Def/Apple2, Green", + "ball": "Def/Acc2/4.5, Def/Acc/3.2" + } + } + }, + "events": + [ + ["onset", "duration", "event_code", "HED"], + [ 4.5, 0, "ball", "Def/Apple2, Green"], + [ 5.5, 0, "face", "Def/Acc2/4.5"] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Def/Acc/4.5", + "ball": "Item" + } + } + }, + "events": + [ + ["onset", "duration", "event_code","HED"], + [ 4.5, 0, "face", "Blue"], + [ 5.0, 0, "ball", "Green, Def/MyColor"] + ] + } + ] + } + } + }, + { + "error_code": "DEF_INVALID", + "alt_codes": [], + "name": "def-invalid-missing-placeholder", + "description": "A `Def` tag is missing an expected placeholder value or has an unexpected placeholder value.", + "warning": false, + "schema": "8.4.0", + "error_category": "placeholder", + "common_causes": [ + "Using Def with value but definition lacks placeholder", + "Missing # in definition name when content expects it", + "Forgetting to add placeholder to definition", + "Mismatch between definition and usage expectations", + "Incomplete definition creation" + ], + "explanation": "When a definition is used with values (Def/Name/value), the definition must include a placeholder (#) to specify where the value should be substituted.", + "correction_strategy": "Add placeholder to definition or remove value from usage", + "correction_examples": [ + { + "wrong": "Definition: (Definition/Event, (Action)) Usage: Def/Event/5", + "correct": "Definition: (Definition/Event/#, (Action/#)) Usage: Def/Event/5", + "explanation": "Added placeholder to definition to support value usage" + }, + { + "wrong": "Def/Action/Start without placeholder in definition", + "correct": "Def/Action (without value) or add placeholder to definition", + "explanation": "Either remove value or add placeholder support" + } + ], + "correction_patterns": [ + "Add # to definition name when used with values", + "Include placeholder in definition content", + "Match definition structure to usage pattern", + "Remove values from usage if definition doesn't support them" + ], + "fix_instructions": [ + "1. Identify definitions used with values", + "2. Check if definition includes placeholder", + "3. Add # to definition name and content", + "4. Or remove values from Def usage", + "5. Verify definition-usage consistency" + ], + "validation_hints": [ + "Definitions used with Def/Name/value need placeholders", + "Add # to definition name and appropriate content location", + "Check definition-usage pattern matching", + "Verify placeholder substitution works" + ], + "specification_reference": "3.2.8.1. Definition placeholder requirements", + "related_errors": [ + "PLACEHOLDER_INVALID", + "DEF_INVALID", + "VALUE_INVALID" + ], + "definitions":["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "Def/Acc, (Def/Acc/4.5, Red)", + "Def/MyColor/Blue" + ], + "passes": [ + "Def/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Def/Acc, (Def/Acc/4.5, Red)", + "ball": "(Def/MyColor/Blue, Green)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Def/Acc/4.5, Red", + "ball": "(Acceleration/4.5 m-per-s^2, Red), Def/MyColor" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Def/Acc, (Def/Acc/4.5, Red)"], + [ 5.4, 0, "Def/MyColor/Blue, Green"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Def/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Def/Acc, (Def/Acc/4.5, Red)", + "ball": "(Def/MyColor/Blue, Green)" + } + } + }, + "events": + [ + ["onset", "duration", "event_code", "HED"], + [ 4.5, 0, "ball", "Def/Acc, (Def/Acc/4.5, Red)"], + [ 5.4, 0, "n/a", "Def/MyColor/Blue, Green"], + [ 6.4, 0, "face", "n/a"] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Def/Acc/4.5, Red", + "ball": "(Acceleration/4.5 m-per-s^2, Red), Def/MyColor" + } + } + }, + "events": + [ + ["onset", "duration", "event_code", "HED"], + [ 4.5, 0, "face", "Def/Acc/5.5, (Acceleration/4.5 m-per-s^2, Red)"], + [ 6.5, 0, "ball", "n/a"] + ] + } + ] + } + } + }, + { + "error_code": "DEF_INVALID", + "alt_codes": ["VALUE_INVALID", "UNITS_INVALID"], + "name": "def-invalid-bad-placeholder-value", + "description": "A `Def` has a placeholder value of incorrect format or units for definition.", + "warning": false, + "schema": "8.4.0", + "error_category": "value", + "common_causes": [ + "Invalid data type for placeholder value", + "Non-numeric values where numbers expected", + "Invalid string values for placeholder", + "Incorrect value format for definition requirements", + "Type mismatch between value and definition expectations" + ], + "explanation": "Placeholder values in Def tags must match the data type and format expected by the definition. Invalid values break proper definition expansion.", + "correction_strategy": "Use appropriate value types for placeholder", + "correction_examples": [ + { + "wrong": "Def/Acc/baloney (non-numeric for acceleration)", + "correct": "Def/Acc/5.0 (numeric value)", + "explanation": "Used numeric value for acceleration definition" + }, + { + "wrong": "Def/Label/123 (numeric for text label)", + "correct": "Def/Label/Description (text value)", + "explanation": "Used text value for label definition" + } + ], + "correction_patterns": [ + "Use numeric values for numeric placeholders", + "Use text values for text placeholders", + "Match value type to definition expectations", + "Verify value format requirements" + ], + "fix_instructions": [ + "1. Check definition to understand expected value type", + "2. Verify current placeholder value type", + "3. Replace with appropriate value type", + "4. Test definition expansion works correctly", + "5. Verify value meets definition constraints" + ], + "validation_hints": [ + "Check if definition expects numeric or text values", + "Verify value type matches definition requirements", + "Test placeholder substitution results", + "Ensure value format is appropriate" + ], + "specification_reference": "3.2.8.1. Def placeholder value requirements", + "related_errors": [ + "VALUE_INVALID", + "DEF_INVALID", + "PLACEHOLDER_INVALID" + ], + "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "Def/Acc/baloney, (Def/Acc/4.5, Red)", + "Def/Acc/3 m", + "Def/Acc/4m-per-s^2", + "Def/MyColor/Redish" + ], + "passes": [ + "Def/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Def/Acc/baloney, (Def/Acc/4.5, Red)", + "ball": "Def/Acc/3 m", + "square": "Def/Acc/4m-per-s^2", + "triangle": "Def/MyColor/Redish" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def/Acc/4.5, Red)", + "ball": "Def/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Def/Acc/baloney, (Def/Acc/4.5, Red)"], + [ 5.0, 0, "Def/3 m"], + [ 6.3, 0, "Def/Acc/4m-per-s^2"], + [ 7.2, 0, "Def/MyColor/Redish"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Def/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Def/Acc/baloney, (Def/Acc/4.5 m-per-s^2, Red)", + "ball": "Def/Acc/3 m", + "square": "Def/Acc/4m-per-s^2", + "triangle": "Def/MyColor/Redish" + } + } + }, + "events": + [ + ["onset", "duration", "event_code", "HED"], + [ 4.5, 0, "ball", "Def/Acc/baloney, (Def/Acc/4.5, Red)"], + [ 5.0, 0, "face", "Def/Acc/3 m"], + [ 6.3, 0, "n/a", "Def/Acc/4m-per-s^2"], + [ 7.2, 0, "square", "Def/MyColor/Redish"] + + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/Acc/4.5, Red)", + "ball": "Def/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)" + } + } + }, + "events": + [ + ["onset", "duration", "event_code","HED"], + [ 4.5, 0, "face", "Blue"], + [ 5.0, 0, "ball", "Green, Def/MyColor"] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/ELEMENT_DEPRECATED.json b/spec_tests/hed-tests/json_test_data/validation_tests/ELEMENT_DEPRECATED.json new file mode 100644 index 000000000..a51e73d3a --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/ELEMENT_DEPRECATED.json @@ -0,0 +1,197 @@ +[ + { + "error_code": "ELEMENT_DEPRECATED", + "alt_codes": [], + "name": "tag-deprecated", + "description": "A tag is deprecated", + "warning": true, + "schema": "8.2.0", + "error_category": "semantic", + "common_causes": [ + "Using tags from older schema versions", + "Not updating annotations after schema upgrades", + "Copying examples with deprecated elements", + "Using deprecated units or value classes", + "Unaware of deprecation status" + ], + "explanation": "Deprecated elements have been marked for removal in future schema versions. While they may still work, they should be replaced with recommended alternatives to ensure future compatibility.", + "correction_strategy": "Replace deprecated elements with recommended alternatives", + "correction_examples": [ + { + "wrong": "Gentalia", + "correct": "Property/Physical-property/Spatial-property/Position", + "explanation": "Replaced deprecated tag with current equivalent" + }, + { + "wrong": "Sensory-event/Visual/Color", + "correct": "Sensory-event/Visual", + "explanation": "Used current tag hierarchy" + } + ], + "correction_patterns": [ + "Check deprecation notice for recommended replacement", + "Update to current schema tag hierarchy", + "Replace deprecated units with current equivalents", + "Use updated value classes", + "Consult schema documentation for alternatives" + ], + "fix_instructions": [ + "1. Identify the deprecated element", + "2. Check schema documentation for replacement", + "3. Replace with recommended alternative", + "4. Verify functionality is preserved", + "5. Update any related annotations" + ], + "validation_hints": [ + "Check schema documentation for deprecation notices", + "Verify replacement maintains semantic meaning", + "Test with current schema version", + "Update related annotations consistently" + ], + "specification_reference": "A.1.4. Schema attributes", + "related_errors": [ + "TAG_INVALID", + "SCHEMA_DEPRECATION_ERROR" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Def/MyColor, Green, Gentalia", + "Gentalia" + ], + "passes": [ + "Torso" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Def/MyColor, Green, Gentalia", + "ball": "Green, Blue" + } + }, + "other_code": { + "HED": "Label/#, Gentalia" + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Torso" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Gentalia, Green" + ], + [ + 5.5, + 0, + "n/a" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Torso" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Gentalia", + "ball": "Green" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "Blue" + ], + [ + 5.5, + 0, + "face", + "Red" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Torso", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/PARENTHESES_MISMATCH.json b/spec_tests/hed-tests/json_test_data/validation_tests/PARENTHESES_MISMATCH.json new file mode 100644 index 000000000..d84d2a637 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/PARENTHESES_MISMATCH.json @@ -0,0 +1,403 @@ +[ + { + "error_code": "PARENTHESES_MISMATCH", + "alt_codes": [], + "name": "parentheses-mismatch-unmatched-parentheses", + "description": "A HED string does not have the same number of open and closed parentheses.", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Missing opening or closing parentheses", + "Copy-paste errors that cut off parts of tag groups", + "Incorrect nesting when creating complex tag groups", + "Typing errors when manually creating nested groups" + ], + "explanation": "HED tag groups must be properly balanced with matching opening and closing parentheses. Unmatched parentheses prevent the parser from correctly identifying the structure of tag groups and their relationships.", + "correction_strategy": "Balance parentheses by adding missing ones or removing extra ones", + "correction_examples": [ + { + "wrong": "(Red, (Blue, Green), Yellow))", + "correct": "(Red, (Blue, Green), Yellow)", + "explanation": "Removed extra closing parenthesis" + }, + { + "wrong": "((Red, ((Blue, Green), Yellow))", + "correct": "((Red, ((Blue, Green), Yellow)))", + "explanation": "Added missing closing parenthesis" + }, + { + "wrong": "((Red, ((Blue), Green)), (Yellow)", + "correct": "((Red, ((Blue), Green)), (Yellow))", + "explanation": "Added missing closing parenthesis for the last group" + } + ], + "correction_patterns": [ + "Count opening '(' and closing ')' parentheses - they must be equal", + "Ensure each '(' has a corresponding ')'", + "Check nesting levels are properly closed", + "Verify tag groups are completely enclosed" + ], + "fix_instructions": [ + "1. Count all opening parentheses '('", + "2. Count all closing parentheses ')'", + "3. If counts don't match, identify where parentheses are missing", + "4. Add missing parentheses in the correct positions", + "5. Verify proper nesting structure" + ], + "validation_hints": [ + "Use a text editor with parentheses matching to visualize structure", + "Check that each tag group has clear boundaries", + "Ensure nested groups are properly contained", + "Verify the corrected string has equal opening and closing parentheses" + ], + "specification_reference": "3.2.7.1. Parentheses and order", + "related_errors": [ + "COMMA_MISSING", + "TAG_GROUP_ERROR", + "TAG_EMPTY" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def/MyColor, (Blue, (Yellow)), Red))", + "((Red, ((Blue, Green), Yellow))", + "((Red, ((Blue), Green)), (Yellow)" + ], + "passes": [ + "(Def/Acc/5.3, (Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Def/MyColor, (Blue, (Yellow)), Red))", + "ball": "(Red, ((Blue, Green), Yellow))", + "square": "(Red, ((Blue), Green)), (Yellow)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def/Acc/5.3, (Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/MyColor, (Blue, (Yellow)), Red))" + ], + [ + 5.5, + 0, + "(Red, ((Blue, Green), Yellow))" + ], + [ + 6.3, + 0, + "(Red, ((Blue), Green)), (Yellow)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/Acc/5.3, (Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "Def/Acc/6, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "PARENTHESES_MISMATCH", + "alt_codes": [], + "name": "parentheses-mismatch-incorrect-nesting", + "description": "The open and closed parentheses are not correctly nested in the HED string.", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Incorrect interleaving of tag groups", + "Copy-paste errors that disrupt nesting structure", + "Manual editing that breaks proper group boundaries", + "Misunderstanding of nested group requirements" + ], + "explanation": "While parentheses counts may be balanced, their nesting order must be correct. Proper nesting means each opening parenthesis is matched with the closest unopened closing parenthesis.", + "correction_strategy": "Reorganize parentheses to follow proper nesting rules", + "correction_examples": [ + { + "wrong": "(Red, (Blue), (Green))", + "correct": "(Red, (Blue), (Green))", + "explanation": "Corrected improper interleaving to proper nested structure" + }, + { + "wrong": ")(Red, Blue)(", + "correct": "(Red, Blue)", + "explanation": "Fixed reversed opening and closing parentheses" + } + ], + "correction_patterns": [ + "Ensure opening parentheses come before their matching closing ones", + "Verify that nested groups are completely contained within outer groups", + "Check that parentheses don't cross group boundaries", + "Maintain proper sequence: ( content )" + ], + "fix_instructions": [ + "1. Identify improperly nested sections", + "2. Reorganize parentheses to follow proper nesting order", + "3. Ensure each group is completely contained", + "4. Verify no crossing of group boundaries", + "5. Test with nested structure validation" + ], + "validation_hints": [ + "Use editor with bracket matching visualization", + "Check that each opening has a proper closing", + "Verify nested groups don't overlap boundaries", + "Ensure proper sequential ordering" + ], + "specification_reference": "3.2.2. Tag group structure", + "related_errors": [ + "PARENTHESES_MISMATCH", + "TAG_GROUP_ERROR", + "CHARACTER_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def/MyColor)), (Blue, (Yellow)), (Red)", + ")(Def/MyColor)), (Blue, (Yellow)), (Red))" + ], + "passes": [ + "(Def/Acc/5.3, (Red))", + "(((((Def/Acc/5.3, (Red))))))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Def/MyColor)), (Blue, (Yellow)), (Red)", + "ball": ")(Def/MyColor)), (Blue, (Yellow)), (Red))" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def/Acc/5.3, (Red))", + "ball": "(((((Def/Acc/5.3, (Red))))))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/MyColor)), (Blue, (Yellow)), (Red)" + ], + [ + 5.5, + 0, + ")(Def/MyColor)), (Blue, (Yellow)), (Red))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/Acc/5.3, (Red))" + ], + [ + 5.5, + 0, + "(((((Def/Acc/5.3, (Red))))))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor)), (Blue, (Yellow)), (Red)", + "ball": ")(Def/MyColor)), (Blue, (Yellow)), (Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "),Red, (((Def/MyColor)))" + ], + [ + 5.0, + 0, + "ball", + "(Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/Acc/5.3, (Red))", + "ball": "(((((Def/Acc/5.3, (Red))))))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, ((Def/MyColor))" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/PLACEHOLDER_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/PLACEHOLDER_INVALID.json new file mode 100644 index 000000000..35abc3bc6 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/PLACEHOLDER_INVALID.json @@ -0,0 +1,673 @@ +[ + { + "error_code": "PLACEHOLDER_INVALID", + "alt_codes": [ + "VALUE_INVALID" + ], + "name": "placeholder-invalid-misplaced", + "description": "A `#` appears in a place that it should not (such as in the `HED` column of an event file outside a definition).", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Using # in event files instead of actual values", + "Incorrect placeholder usage in sidecars", + "Multiple # symbols in same HED string", + "# not directly following a slash", + "Using # with tags that don't support placeholders" + ], + "explanation": "Placeholders (#) are only valid in specific contexts: sidecar templates for value columns, and definition templates. They cannot appear in event files or be used incorrectly in tag structures.", + "correction_strategy": "Replace placeholders with actual values or fix placement", + "correction_examples": [ + { + "wrong": "Label/#", + "correct": "Label/SomeActualLabel", + "explanation": "Replaced placeholder with actual value in event context" + }, + { + "wrong": "Def/Acc/#", + "correct": "Def/Acc/3.5", + "explanation": "Replaced placeholder with actual numeric value" + }, + { + "wrong": "Distance/# meters", + "correct": "Distance/#", + "explanation": "Moved placeholder to correct position after slash" + } + ], + "correction_patterns": [ + "Replace # with actual values in event files", + "Ensure # appears directly after slash in valid contexts", + "Use only one # per HED string in sidecars", + "Verify parent tag supports placeholders", + "Remove # from categorical column sidecars" + ], + "fix_instructions": [ + "1. Identify context where # appears", + "2. If in event file: replace with actual value", + "3. If in sidecar: verify correct usage pattern", + "4. Ensure # follows proper positioning rules", + "5. Check parent tag supports placeholders" + ], + "validation_hints": [ + "Verify # only in appropriate contexts", + "Check # positioning after slashes", + "Ensure single # per string in value templates", + "Confirm parent tag has placeholder child capability" + ], + "specification_reference": "3.2.4. Tags that take values", + "related_errors": [ + "VALUE_INVALID", + "SIDECAR_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Label/#", + "Def/Acc/#" + ], + "passes": [ + "Label/This-label" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Label/#", + "ball": "Def/Acc/#2" + } + } + } + ], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Label/#" + ], + [ + 5.0, + 0, + "Def/Acc/#" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Label/This-label" + ], + [ + 6.0, + 0, + "(Def/Acc/3.5)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/banana", + "ball": "Def/Acc/apple3, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/Acc/#" + ], + [ + 5.0, + 0, + "ball", + "Label/#" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "PLACEHOLDER_INVALID", + "alt_codes": [], + "name": "placeholder-invalid-#-in-categorical-column", + "description": "A JSON sidecar has a placeholder (`#`) in the HED dictionary for a categorical column.", + "warning": false, + "schema": "8.4.0", + "error_category": "context", + "common_causes": [ + "Using placeholders in categorical (non-value) columns", + "Misunderstanding that # is only for value columns", + "Copy-paste errors from value column definitions", + "Confusion about when to use placeholders", + "Incorrect sidecar column type specification" + ], + "explanation": "Placeholders (#) are only valid for value columns where the placeholder gets replaced with actual values from the data. Categorical columns should not contain placeholders.", + "correction_strategy": "Remove placeholders from categorical column HED strings", + "correction_examples": [ + { + "wrong": "event_code: { 'face': 'Label/#', 'ball': 'Def/Acc/#' }", + "correct": "event_code: { 'face': 'Label/Face', 'ball': 'Sensory-event' }", + "explanation": "Replaced placeholders with specific values for categorical column" + }, + { + "wrong": "Categorical column with HED 'Parameter-value/#'", + "correct": "Categorical column with HED 'Parameter-value/Default'", + "explanation": "Used specific value instead of placeholder" + } + ], + "correction_patterns": [ + "Replace # with specific appropriate values", + "Use descriptive labels instead of placeholders", + "Ensure categorical columns have fixed HED content", + "Verify column type matches HED specification" + ], + "fix_instructions": [ + "1. Identify categorical columns with placeholders", + "2. Determine appropriate fixed values for each category", + "3. Replace # with specific descriptive values", + "4. Verify column type is categorical in specification", + "5. Test with sample data to ensure proper annotation" + ], + "validation_hints": [ + "Categorical columns should not have # placeholders", + "Use specific values for each category", + "Check column type specification", + "Verify HED content is appropriate for categorical data" + ], + "specification_reference": "3.2.9. Categorical vs value columns in sidecars", + "related_errors": [ + "PLACEHOLDER_INVALID", + "SIDECAR_INVALID", + "VALUE_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Label/#", + "ball": "Def/Acc/#" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Label/This-label", + "ball": "(Def/Acc/3.5)" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Label/#", + "ball": "Def/Acc/#" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "PLACEHOLDER_INVALID", + "alt_codes": [], + "name": "placeholder-invalid-json-value-column", + "description": "A JSON sidecar does not have exactly one placeholder (`#`) in each HED string representing a value column.", + "warning": false, + "schema": "8.4.0", + "error_category": "count", + "common_causes": [ + "Multiple placeholders in single value column HED string", + "Missing placeholders in value column specifications", + "Incorrect placeholder count for value substitution", + "Misunderstanding value column placeholder requirements", + "Copy-paste errors creating multiple placeholders" + ], + "explanation": "Value columns in JSON sidecars must have exactly one placeholder (#) in their HED string. Multiple or missing placeholders break proper value substitution.", + "correction_strategy": "Ensure exactly one placeholder per value column", + "correction_examples": [ + { + "wrong": "trial: 'Def/Acc/#, Label/#'", + "correct": "trial: 'Def/Acc/#'", + "explanation": "Removed extra placeholder to have exactly one" + }, + { + "wrong": "memory: 'Blue, Red, Label/#' (with multiple #)", + "correct": "memory: 'Blue, Red, Label/#' (with exactly one #)", + "explanation": "Ensured single placeholder for value substitution" + } + ], + "correction_patterns": [ + "Count # symbols and ensure exactly one per value column", + "Remove extra placeholders from value column HED", + "Add missing placeholder if none exists", + "Separate multiple value needs into different columns" + ], + "fix_instructions": [ + "1. Identify value columns in sidecar", + "2. Count placeholders in each value column HED string", + "3. Remove extra placeholders or add missing ones", + "4. Ensure exactly one # per value column", + "5. Verify value substitution works correctly" + ], + "validation_hints": [ + "Value columns need exactly one # placeholder", + "Count # symbols in value column HED strings", + "Check for missing or extra placeholders", + "Verify proper value substitution behavior" + ], + "specification_reference": "3.2.9. Value column placeholder requirements", + "related_errors": [ + "PLACEHOLDER_INVALID", + "SIDECAR_INVALID", + "VALUE_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "trial": { + "HED": "Def/Acc/#, Label/#" + }, + "memory": { + "HED": "Blue, Red, Label/#" + } + } + ], + "passes": [ + { + "trial": { + "HED": "Def/Acc/#" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "trial": { + "HED": "Def/Acc/#, Label/#" + }, + "memory": { + "HED": "Blue, Red, Label/#" + } + }, + "events": [ + [ + "onset", + "duration", + "trial", + "memory", + "HED" + ], + [ + 4.5, + 0, + "3", + "4", + "Green, Def/MyColor" + ], + [ + 5.0, + 0, + "2", + "6", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "trial": { + "HED": "Def/Acc/#, Label/Trial" + }, + "memory": { + "HED": "Blue, Red, Label/#" + } + }, + "events": [ + [ + "onset", + "duration", + "trial", + "memory", + "HED" + ], + [ + 4.5, + 0, + "5", + "4", + "Green" + ], + [ + 5.0, + 0, + "3", + "2", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "PLACEHOLDER_INVALID", + "alt_codes": [ + "TAG_EXTENSION_INVALID", + "VALUE_INVALID" + ], + "name": "placeholder-invalid-json-#-misplaced", + "description": "A placeholder (`#`) is used in JSON sidecar or definition, but its parent in the schema does not have a placeholder child.", + "warning": false, + "schema": "8.4.0", + "error_category": "schema", + "common_causes": [ + "Using placeholders on tags that don't support them", + "Misunderstanding which tags can take value extensions", + "Schema version mismatches affecting placeholder support", + "Incorrect assumption about tag extensibility", + "Using deprecated or unsupported placeholder positions" + ], + "explanation": "Placeholders can only be used with tags that explicitly support value extensions in the schema. Not all tags can take placeholder values.", + "correction_strategy": "Use placeholders only with schema-supported tags", + "correction_examples": [ + { + "wrong": "Sensory-event/#", + "correct": "Sensory-event, Label/#", + "explanation": "Moved placeholder to supported tag (Label supports #)" + }, + { + "wrong": "Blue/#", + "correct": "Blue, Parameter-value/#", + "explanation": "Used appropriate tag that supports placeholders" + } + ], + "correction_patterns": [ + "Check schema for placeholder-supporting tags", + "Use Label/# for text values", + "Use Parameter-value/# for numeric values", + "Replace unsupported placeholders with supported alternatives" + ], + "fix_instructions": [ + "1. Identify tags with unsupported placeholders", + "2. Check schema for placeholder-supporting alternatives", + "3. Replace with appropriate schema-supported tags", + "4. Verify placeholder usage matches schema requirements", + "5. Test with schema validation" + ], + "validation_hints": [ + "Check schema for tags that support placeholders", + "Use Label/# for text, Parameter-value/# for numbers", + "Verify tag extensibility in current schema version", + "Look for 'takes value' attributes in schema" + ], + "specification_reference": "Schema extensibility and placeholder support", + "related_errors": [ + "TAG_EXTENSION_INVALID", + "VALUE_INVALID", + "PLACEHOLDER_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "trial": { + "HED": "Sensory-event/#" + }, + "defs": { + "def1": "(Definition/Blech/#, (Red, Blue/#))" + } + } + ], + "passes": [ + { + "trial": { + "HED": "Label/#" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "trial": { + "HED": "Sensory-event/#" + }, + "defs": { + "def1": "(Definition/Blech/#, (Red, Blue/#))" + } + }, + "events": [ + [ + "onset", + "duration", + "trial", + "HED" + ], + [ + 4.5, + 0, + "3", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "2", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "trial": { + "HED": "Sensory-event, Label/#" + }, + "defs": { + "def1": "(Definition/Blech/#, (Red, Label/#))" + } + }, + "events": [ + [ + "onset", + "duration", + "trial", + "HED" + ], + [ + 4.5, + 0, + "3", + "Blue" + ], + [ + 5.0, + 0, + "2", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/SCHEMA_LOAD_FAILED.json b/spec_tests/hed-tests/json_test_data/validation_tests/SCHEMA_LOAD_FAILED.json new file mode 100644 index 000000000..18d0f141e --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/SCHEMA_LOAD_FAILED.json @@ -0,0 +1,257 @@ +[ + { + "error_code": "SCHEMA_LOAD_FAILED", + "name": "different-standard-schemas-in-same-merge-group", + "description": "Schemas in a merge group must be associated with the same standard schema.", + "schema": [ + "8.1.0", + "testlib_2.0.0" + ], + "error_category": "schema_development", + "common_causes": [ + "Attempting to merge schemas with different standard schema versions", + "Incompatible library schema combinations", + "Version mismatch between standard and library schemas", + "Invalid schema merge group configuration", + "Missing version compatibility information" + ], + "explanation": "When merging multiple schemas, all schemas in the merge group must be compatible with the same standard schema version. Version mismatches prevent proper schema integration and validation.", + "correction_strategy": "Ensure all schemas in merge group use compatible standard schema versions", + "correction_examples": [ + { + "wrong": "Standard: 8.1.0, Library: testlib_2.0.0 (requires 8.2.0)", + "correct": "Standard: 8.2.0, Library: testlib_2.0.0", + "explanation": "Updated standard schema to match library requirements" + }, + { + "wrong": "Merging schemas with standards 8.1.0 and 8.3.0", + "correct": "All schemas use standard 8.3.0", + "explanation": "Unified all schemas to use same standard version" + } + ], + "correction_patterns": [ + "Check schema version compatibility requirements", + "Update standard schema to compatible version", + "Verify library schema standard requirements", + "Ensure merge group uses consistent versioning" + ], + "fix_instructions": [ + "1. Identify the standard schema versions required by each schema in merge group", + "2. Find a compatible standard schema version that works for all", + "3. Update schema references to use the common standard version", + "4. Verify all schemas load successfully with the unified version", + "5. Test merged schema functionality" + ], + "validation_hints": [ + "Check schema version compatibility matrices", + "Verify library schema withStandard attributes", + "Test schema loading before attempting merge", + "Ensure all required schemas are accessible" + ], + "specification_reference": "3.1.3. Schema merging and compatibility", + "related_errors": ["SCHEMA_LIBRARY_INVALID", "SCHEMA_VERSION_INVALID"], + "definitions": [ + ], + "tests": { + "string_tests": { + "fails": [ + "Red", + "Blue" + ], + "passes": [ + ] + } + } + }, + { + "error_code": "SCHEMA_LOAD_FAILED", + "name": "extra-standard-schemas-in-same-merge-group", + "description": "Standard schema in same group as its partners is okay.", + "schema": [ + "8.2.0", + "testlib_2.0.0", + "testlib_3.0.0", + "sc:8.1.0" + ], + "definitions": [ + ], + "tests": { + "string_tests": { + "fails": [ + ], + "passes": [ + "Red", + "Blue" + ] + } + } + }, + { + "error_code": "SCHEMA_LOAD_FAILED", + "name": "incompatible-merge-schemas ", + "description": "Schemas in a merge group must be associated with the same standard schema].", + "schema": [ + "score_2.0.0", + "lang_1.1.0" + ], + "definitions": [ + ], + "tests": { + "string_tests": { + "fails": [ + "Red", + "Blue" + ], + "passes": [ ] + } + } + }, + { + "error_code": "TAG_NAMESPACE_PREFIX_INVALID", + "alt_codes": [], + "name": "tag-with-namespace-has-no-schema", + "description": "A tag starting with name: does not have an associated schema.", + "warning": false, + "schema": [ + "8.3.0", + "sc:score_1.0.0" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "ts:Red, Blue", + "(ts:Red, (sc:Sleep-modulator))" + ], + "passes": [ + "sc:Sleep-modulator" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "ts:Red, Blue", + "ball": "(ts:Red, (sc:Sleep-modulator))" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "sc:Sleep-modulator" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "ts:Red, Blue" + ], + [ + 5.5, + 0, + "(ts:Red, (sc:Sleep-modulator))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "sc:Sleep-modulator" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "ts:Red, Blue", + "ball": "(ts:Red, (sc:Sleep-modulator))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue, sc:Sleep-modulator" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue, sc:Sleep-modulator" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_BRACES_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_BRACES_INVALID.json new file mode 100644 index 000000000..14b444513 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_BRACES_INVALID.json @@ -0,0 +1,960 @@ +[ + { + "error_code": "SIDECAR_BRACES_INVALID", + "alt_codes": [ + "CHARACTER_INVALID", + "SIDECAR_INVALID" + ], + "name": "sidecar-braces-contents-invalid", + "description": "The item in curly braces is not the word HED or a column name with HED annotations in the sidecar.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Referencing non-existent columns in curly braces", + "Using non-HED column names in braces", + "Nested or unmatched curly braces", + "Column reference without HED annotations", + "Incorrect brace syntax in sidecars" + ], + "explanation": "Curly braces in sidecars are reserved for column references. Only 'HED' or names of columns that have HED annotations can appear in braces. Braces must be properly matched and cannot be nested.", + "correction_strategy": "Fix column references and brace usage in sidecars", + "correction_examples": [ + { + "wrong": "Red, {nonexistent_column}", + "correct": "Red, {event_type}", + "explanation": "Referenced existing HED-annotated column" + }, + { + "wrong": "Label/{invalid{{nested}}}", + "correct": "Label/{event_type}", + "explanation": "Removed nested braces and used valid column reference" + }, + { + "wrong": "{column_without_hed}", + "correct": "Sensory-event", + "explanation": "Replaced invalid column reference with direct HED tag" + } + ], + "correction_patterns": [ + "Ensure referenced columns exist in the data", + "Verify referenced columns have HED annotations", + "Remove nested or unmatched braces", + "Use only 'HED' or valid column names in braces", + "Replace invalid references with direct HED tags" + ], + "fix_instructions": [ + "1. Identify all column references in curly braces", + "2. Verify each referenced column exists", + "3. Ensure referenced columns have HED annotations", + "4. Fix brace matching and nesting issues", + "5. Replace invalid references with appropriate alternatives" + ], + "validation_hints": [ + "Check that all braced columns exist in sidecar", + "Verify referenced columns have HED sections", + "Ensure proper brace matching", + "No nested braces allowed" + ], + "specification_reference": "3.2.9. Sidecars", + "related_errors": [ + "SIDECAR_INVALID", + "SIDECAR_KEY_MISSING" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description but no HED" + } + }, + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_action": { + "Description": "Does not correspond to curly braces" + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Label/#" + } + }, + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{HED}, (Def/Acc/3.5)" + } + }, + "response_action": { + "Description": "Does not correspond to curly braces" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), ({HED})", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Label/#" + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED", + "response_time" + ], + [ + 4.5, + 0, + "face", + "Blue", + 0 + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor", + 1 + ], + [ + 5.5, + 0, + "face", + "", + 2 + ], + [ + 5.7, + 0, + "face", + "n/a", + 3 + ] + ] + } + ] + } + } + }, + { + "error_code": "SIDECAR_BRACES_INVALID", + "alt_codes": [ + "VALUE_INVALID", + "CHARACTER_INVALID", + "UNITS_INVALID", + "DEF_INVALID" + ], + "name": "sidecar-braces-invalid-spot", + "description": "A curly brace reference must only appear where a tag could.", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Curly braces embedded within tag values", + "Column references in inappropriate tag positions", + "Braces inside unit values or tag modifiers", + "Misunderstanding where column substitution is allowed", + "Incorrect placement of dynamic content references" + ], + "explanation": "Curly braces for column references can only appear where complete tags would be valid, not embedded within tag values, units, or other tag components.", + "correction_strategy": "Move curly braces to valid tag positions", + "correction_examples": [ + { + "wrong": "Label/{response_time}", + "correct": "{response_time}, Label/Description", + "explanation": "Moved column reference to separate tag position" + }, + { + "wrong": "Acceleration/{speed} m-per-s^2", + "correct": "{speed}, Acceleration/5.0 m-per-s^2", + "explanation": "Separated column reference from tag value" + } + ], + "correction_patterns": [ + "Use curly braces as complete tag substitutes", + "Move column references outside of tag values", + "Separate dynamic content from static tag components", + "Place braces where full tags would be appropriate" + ], + "fix_instructions": [ + "1. Identify embedded curly brace references", + "2. Extract column references to separate tag positions", + "3. Ensure braces represent complete tag substitutions", + "4. Verify proper tag structure around references", + "5. Test column substitution works correctly" + ], + "validation_hints": [ + "Curly braces must replace entire tags, not parts", + "Column references cannot be embedded in values", + "Check that braces are in valid tag positions", + "Verify proper separation of dynamic and static content" + ], + "specification_reference": "3.2.9. Sidecar column reference positioning", + "related_errors": [ + "VALUE_INVALID", + "CHARACTER_INVALID", + "UNITS_INVALID", + "DEF_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "(Label/{response_time})" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Label/#" + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Label/#" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [], + "passes": [] + } + } + }, + { + "error_code": "SIDECAR_BRACES_INVALID", + "alt_codes": [], + "name": "sidecar-braces-circular-reference", + "description": "The item in curly braces has a HED annotation that contains curly braces.", + "warning": false, + "schema": "8.4.0", + "error_category": "reference", + "common_causes": [ + "Column A references column B which references column A", + "Chain of column references that forms a loop", + "Complex multi-level circular dependencies", + "Inadvertent recursive column referencing", + "Mismanagement of column interdependencies" + ], + "explanation": "Column references cannot form circular dependencies where column A references column B, and column B (directly or indirectly) references column A. This creates infinite substitution loops.", + "correction_strategy": "Break circular reference chains", + "correction_examples": [ + { + "wrong": "Column A: {column_b}, Column B: {column_a}", + "correct": "Column A: {column_b}, Column B: Sensory-event", + "explanation": "Replaced circular reference with direct HED content" + }, + { + "wrong": "Chain: A → B → C → A", + "correct": "Chain: A → B → C (direct content)", + "explanation": "Broke circular chain by making C have direct content" + } + ], + "correction_patterns": [ + "Replace one reference in the chain with direct HED content", + "Restructure column dependencies to be acyclic", + "Use base columns that don't reference others", + "Create hierarchical rather than circular structures" + ], + "fix_instructions": [ + "1. Map all column reference relationships", + "2. Identify circular dependency chains", + "3. Choose one column in each cycle to modify", + "4. Replace circular reference with direct HED content", + "5. Verify all references resolve without loops" + ], + "validation_hints": [ + "Trace column references to detect cycles", + "Ensure at least one column in chain has direct content", + "Check for indirect circular dependencies", + "Verify reference graph is acyclic" + ], + "specification_reference": "3.2.9. Sidecar column reference constraints", + "related_errors": [ + "SIDECAR_BRACES_INVALID", + "SIDECAR_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), {HED}", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "HED": "Label/#, {event_code}" + } + }, + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), {HED}", + "ball": "{response_time}, (Def/Acc/3.5)", + "dog": "Orange, {event_type}" + } + }, + "response_time": { + "HED": "Label/#" + }, + "event_type": { + "HED": { + "banana": "Blue, {response_time}", + "apple": "Green" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Label/#" + }, + "response_count": { + "Description": "A count used to test curly braces in value columns.", + "HED": "(Item-count/#, {response_time})" + } + }, + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{HED}, (Def/Acc/3.5, {response_action})" + } + }, + "response_action": { + "Description": "Does not correspond to curly braces", + "HED": "Label/#" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), ({HED})", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Parameter-value/#" + } + }, + "events": [ + [ + "onset", + "duration", + "response_time", + "event_code", + "HED" + ], + [ + 4.5, + 0, + 3.4, + "face", + "Blue" + ], + [ + 5.0, + 0, + 6.8, + "ball", + "Green, Def/MyColor" + ], + [ + 5.2, + 0, + "n/a", + "face", + "" + ], + [ + 5.5, + 0, + "any", + "face", + "n/a" + ] + ] + } + ] + } + } + }, + { + "error_code": "SIDECAR_BRACES_INVALID", + "alt_codes": [], + "name": "sidecar-braces-self-reference", + "description": "The item in curly braces has a HED annotation that contains itself.", + "warning": false, + "schema": "8.4.0", + "error_category": "reference", + "common_causes": [ + "Column referencing itself directly in HED annotation", + "Copy-paste errors creating self-references", + "Misunderstanding of column reference scope", + "Attempting to create recursive definitions", + "Incorrect use of column names in their own definitions" + ], + "explanation": "A column cannot reference itself in its HED annotation as this creates infinite recursion during substitution. Self-references must be avoided to ensure proper expansion.", + "correction_strategy": "Remove self-references from column definitions", + "correction_examples": [ + { + "wrong": "response_time: 'Parameter-value/#, {response_time}'", + "correct": "response_time: 'Parameter-value/#'", + "explanation": "Removed self-reference to break infinite recursion" + }, + { + "wrong": "event_type: '{event_type}, Action'", + "correct": "event_type: 'Sensory-event, Action'", + "explanation": "Replaced self-reference with direct HED content" + } + ], + "correction_patterns": [ + "Remove self-referencing column names from HED annotations", + "Replace self-references with direct HED content", + "Use other columns or direct tags instead of self-reference", + "Ensure column definitions are self-contained" + ], + "fix_instructions": [ + "1. Identify columns that reference themselves", + "2. Remove self-referencing curly braces", + "3. Replace with appropriate direct HED content", + "4. Verify column definitions don't create recursion", + "5. Test substitution works without infinite loops" + ], + "validation_hints": [ + "Check for column names in their own HED annotations", + "Ensure no {column_name} in column_name's definition", + "Verify column definitions are self-contained", + "Look for direct self-referencing patterns" + ], + "specification_reference": "3.2.9. Sidecar self-reference restrictions", + "related_errors": [ + "SIDECAR_BRACES_INVALID", + "SIDECAR_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), {HED}", + "ball": "{HED}, (Def/Acc/3.5)" + } + }, + "response_time": { + "HED": "Parameter-value/#, {response_time}" + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Parameter-value/#" + }, + "response_count": { + "Description": "A count used to test curly braces in value columns.", + "HED": "(Item-count/#, {response_time})" + } + }, + { + "event_code": { + "HED": { + "face": "{HED}", + "ball": "Red" + } + } + }, + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "{HED}, (Def/Acc/3.5, {response_action})" + } + }, + "response_action": { + "Description": "Does not correspond to curly braces", + "HED": "Parameter-value/#" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), ({HED})", + "ball": "{HED}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Parameter-value/#, {response_time}" + } + }, + "events": [ + [ + "onset", + "duration", + "response_time", + "event_code", + "HED" + ], + [ + 4.5, + 0, + 3.4, + "face", + "Blue" + ], + [ + 5.0, + 0, + 6.8, + "ball", + "Green, Def/MyColor" + ], + [ + 5.2, + 0, + "n/a", + "face", + "" + ], + [ + 5.5, + 0, + "any", + "face", + "n/a" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), ({HED})", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Parameter-value/#" + } + }, + "events": [ + [ + "onset", + "duration", + "response_time", + "event_code", + "HED" + ], + [ + 4.5, + 0, + 3.4, + "face", + "Blue" + ], + [ + 5.0, + 0, + 6.8, + "ball", + "Green, Def/MyColor" + ], + [ + 5.2, + 0, + "n/a", + "face", + "" + ], + [ + 5.5, + 0, + "7,3", + "face", + "n/a" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "{HED}", + "ball": "Red" + } + } + }, + "events": [ + [ + "onset", + "duration", + "response_time", + "event_code" + ], + [ + 4.5, + 0, + 3.4, + "face" + ], + [ + 5.0, + 0, + 6.8, + "ball" + ] + ] + } + ] + } + } + }, + { + "error_code": "SIDECAR_BRACES_INVALID", + "alt_codes": [ + "CHARACTER_INVALID", + "VALUE_INVALID", + "UNITS_INVALID" + ], + "name": "sidecar-braces-appear-as-value-rather-than-tag", + "description": "The curly braces are in a value rather than as a separate tag substitute.", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Embedding column references within tag values", + "Using braces as part of tag content rather than tag replacement", + "Misunderstanding column substitution scope", + "Treating braces as string interpolation rather than tag substitution", + "Incorrect syntax for dynamic content integration" + ], + "explanation": "Curly braces must replace entire tags, not be embedded within tag values. Column references should substitute complete HED tags, not parts of tag values.", + "correction_strategy": "Use curly braces as complete tag substitutes", + "correction_examples": [ + { + "wrong": "Label/{response_time}, Black", + "correct": "{response_time}, Label/Description, Black", + "explanation": "Moved column reference to replace entire tag" + }, + { + "wrong": "Parameter-value/{measurement}", + "correct": "{measurement}, Parameter-value/Default", + "explanation": "Separated column reference from tag value" + } + ], + "correction_patterns": [ + "Extract column references from tag values", + "Use braces to replace complete tags", + "Separate dynamic references from static tag content", + "Place column references as independent tag elements" + ], + "fix_instructions": [ + "1. Identify column references embedded in tag values", + "2. Extract braces to separate tag positions", + "3. Ensure braces replace complete tags", + "4. Add default static content if needed", + "5. Verify proper tag structure and substitution" + ], + "validation_hints": [ + "Column references should not be embedded in values", + "Braces must replace entire tags, not tag parts", + "Check for proper separation of dynamic and static content", + "Verify tag structure remains valid after substitution" + ], + "specification_reference": "3.2.9. Sidecar column substitution syntax", + "related_errors": [ + "CHARACTER_INVALID", + "VALUE_INVALID", + "UNITS_INVALID", + "SIDECAR_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "Label/{response_time}, Black" + } + }, + "response_time": { + "Description": "Has description but no HED", + "HED": "Orange" + } + }, + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "Label/{response_time}, Black" + } + }, + "response_time": { + "Description": "Has description but no HED", + "HED": "Label/#" + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), ({response_time}, (Green, (Yellow)))", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Label/#" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), ({HED})", + "ball": "Label/{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Orange" + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ], + [ + 5.2, + 0, + "face", + "" + ], + [ + 5.5, + 0, + "face", + "n/a" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow)), ({HED})", + "ball": "{response_time}, (Def/Acc/3.5)" + } + }, + "response_time": { + "Description": "Has description with HED", + "HED": "Label/#" + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED", + "response_time" + ], + [ + 4.5, + 0, + "face", + "Blue", + 1 + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor", + 1 + ], + [ + 5.2, + 0, + "face", + "", + 1 + ], + [ + 5.5, + 0, + "face", + "n/a", + 1 + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_INVALID.json new file mode 100644 index 000000000..af9fccd06 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_INVALID.json @@ -0,0 +1,343 @@ +[ + { + "error_code": "SIDECAR_INVALID", + "alt_codes": [], + "name": "sidecar-invalid-key-at-wrong-level", + "description": "The HED key is not a second-level dictionary key.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "HED key at wrong nesting level in sidecar", + "Providing annotations for 'n/a' values", + "Referencing columns in curly braces that have no HED", + "Incorrect JSON structure for sidecars", + "Missing or malformed column references" + ], + "explanation": "Sidecars must follow specific JSON structure with HED annotations at the correct nesting level. The 'HED' key must be properly positioned, and all referenced columns must have appropriate annotations.", + "correction_strategy": "Fix sidecar structure and key positioning", + "correction_examples": [ + { + "wrong": "{'HED': 'Red, Blue'}", + "correct": "{'column_name': {'HED': 'Red, Blue'}}", + "explanation": "Moved HED key to correct second level under column" + }, + { + "wrong": "{'event': {'HED': {'n/a': 'Red'}}}", + "correct": "{'event': {'HED': {'face': 'Red'}}}", + "explanation": "Removed annotation for 'n/a' value" + } + ], + "correction_patterns": [ + "Ensure HED key is at second level: column -> HED -> values", + "Remove annotations for 'n/a' values", + "Verify all referenced columns exist and have HED", + "Check JSON structure follows sidecar requirements", + "Ensure proper nesting of categorical value annotations" + ], + "fix_instructions": [ + "1. Check HED key nesting level in JSON structure", + "2. Move HED key to correct position if needed", + "3. Remove any 'n/a' annotations", + "4. Verify column references are valid", + "5. Ensure JSON structure matches sidecar requirements" + ], + "validation_hints": [ + "Verify HED appears under column names", + "Check no annotations for 'n/a' values", + "Ensure referenced columns exist", + "Validate JSON structure syntax" + ], + "specification_reference": "3.2.9. Sidecars", + "related_errors": [ + "SIDECAR_KEY_MISSING", + "SIDECAR_BRACES_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "temp": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "(Def/MyColor, Onset), (Def/Acc/3.5)" + } + } + } + }, + { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "(Def/MyColor, Onset), (Def/Acc/3.5)" + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "(Def/MyColor, Onset),(Def/Acc/3.5)" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "temp": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "(Def/MyColor, Onset), (Def/Acc/3.5)" + } + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + }, + { + "sidecar": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "(Def/MyColor, Onset), (Def/Acc/3.5)" + } + }, + "events": [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "SIDECAR_INVALID", + "alt_codes": [], + "name": "sidecar-invalid-na-annotated", + "description": "An annotation entry is provided for `n/a`.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Providing HED annotations for n/a values", + "Misunderstanding that n/a should not have annotations", + "Including n/a in annotated categorical columns", + "Confusion about when annotations are appropriate" + ], + "explanation": "The value 'n/a' indicates missing or not applicable data and should not have HED annotations. Annotating n/a creates logical inconsistencies.", + "correction_strategy": "Remove HED annotations for n/a values", + "correction_examples": [ + { + "wrong": "sidecar: {'n/a': {'HED': 'Red, Blue'}}", + "correct": "sidecar: {'value1': {'HED': 'Red, Blue'}}", + "explanation": "Removed annotation for n/a value" + }, + { + "wrong": "event_type: {'n/a': 'Label/NoEvent', 'face': 'Label/Face'}", + "correct": "event_type: {'face': 'Label/Face'}", + "explanation": "Removed n/a from annotated categorical values" + } + ], + "correction_patterns": [ + "Remove all HED annotations for n/a values", + "Exclude n/a from categorical annotation lists", + "Ensure only valid values have annotations" + ], + "fix_instructions": [ + "1. Identify n/a entries in sidecar annotations", + "2. Remove HED content for n/a values", + "3. Keep n/a as unannotated missing value indicator", + "4. Verify only meaningful values have annotations" + ], + "validation_hints": [ + "Check sidecar for n/a annotation entries", + "Ensure n/a values are treated as missing data", + "Verify annotation consistency" + ], + "specification_reference": "3.4. Sidecar annotation rules", + "related_errors": ["SIDECAR_KEY_MISSING", "TAG_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue),(Green, (Yellow))", + "n/a": "(Def/MyColor, Onset), (Def/Acc/3.5)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "(Def/MyColor, Onset),(Def/Acc/3.5)" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, Blue),(Green, (Yellow))", + "n/a": "(Def/MyColor, Onset), (Def/Acc/3.5)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "n/a", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_KEY_MISSING.json b/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_KEY_MISSING.json new file mode 100644 index 000000000..0f9a8f593 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/SIDECAR_KEY_MISSING.json @@ -0,0 +1,287 @@ +[ + { + "error_code": "SIDECAR_KEY_MISSING", + "alt_codes": [], + "name": "sidecar-key-missing", + "description": "A value in a categorical column does not have an expected entry in a sidecar.", + "warning": true, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "New categorical values not added to sidecar", + "Misspelled values in data vs sidecar", + "Column reference to non-existent column", + "Incomplete sidecar annotations", + "Data changes without sidecar updates" + ], + "explanation": "Sidecars should provide HED annotations for all categorical values that appear in the data. Missing entries suggest incomplete annotation or data inconsistencies.", + "correction_strategy": "Add missing sidecar entries or fix value mismatches", + "correction_examples": [ + { + "wrong": "Data has 'target' but sidecar only has 'face' and 'house'", + "correct": "Add 'target': {'HED': 'Sensory-event/Visual'} to sidecar", + "explanation": "Added missing categorical value annotation" + }, + { + "wrong": "Sidecar references {missing_column}", + "correct": "Reference existing column or remove reference", + "explanation": "Fixed column reference" + } + ], + "correction_patterns": [ + "Add HED annotations for all categorical values in data", + "Check spelling consistency between data and sidecar", + "Remove references to non-existent columns", + "Update sidecar when data values change", + "Verify column names match exactly" + ], + "fix_instructions": [ + "1. Identify missing categorical values", + "2. Add appropriate HED annotations for missing values", + "3. Check spelling consistency", + "4. Verify column references exist", + "5. Update sidecar completeness" + ], + "validation_hints": [ + "This is typically a warning, not an error", + "Check all categorical values have sidecar entries", + "Verify column references are valid", + "Ensure sidecar completeness" + ], + "specification_reference": "3.2.9. Sidecars", + "related_errors": [ + "SIDECAR_INVALID", + "SIDECAR_BRACES_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "Black, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "square", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "SIDECAR_KEY_MISSING", + "alt_codes": [], + "name": "sidecar-refers-to-missing-tsv-hed-column", + "description": "(Warning) A sidecar uses a {HED} column which does not appear in the corresponding tsv file.", + "warning": true, + "schema": "8.4.0", + "error_category": "reference", + "common_causes": [ + "Sidecar references HED column not present in TSV", + "Column name mismatch between sidecar and data", + "TSV file missing expected HED column", + "Outdated sidecar referencing removed columns", + "Copy-paste errors in column references" + ], + "explanation": "Sidecars use {HED} placeholders to reference HED columns in TSV files. The referenced column must exist in the actual data file for proper validation and processing.", + "correction_strategy": "Add missing HED column to TSV or remove reference from sidecar", + "correction_examples": [ + { + "wrong": "Sidecar has {HED} but TSV has no HED column", + "correct": "Add HED column to TSV or remove {HED} reference", + "explanation": "Ensured column reference consistency" + }, + { + "wrong": "Reference to {missing_column}", + "correct": "Reference to existing column or remove reference", + "explanation": "Fixed column reference" + } + ], + "correction_patterns": [ + "Add missing HED column to TSV file", + "Remove {HED} references from sidecar if not needed", + "Verify column names match exactly", + "Update sidecar when TSV structure changes", + "Check case sensitivity in column names" + ], + "fix_instructions": [ + "1. Check if HED column exists in TSV file", + "2. Add missing HED column if needed", + "3. Remove {HED} reference if column not required", + "4. Verify column name spelling and case", + "5. Update sidecar to match TSV structure" + ], + "validation_hints": [ + "This is typically a warning, not a critical error", + "Check TSV headers for HED column presence", + "Verify column reference accuracy", + "Consider if HED column is actually needed" + ], + "specification_reference": "3.2.9. Sidecars and HED column references", + "related_errors": [ + "SIDECAR_INVALID", + "SIDECAR_KEY_MISSING", + "SIDECAR_BRACES_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [ + { + "event_code": { + "HED": { + "face": "{HED}", + "ball": "Red" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "{HED}", + "ball": "Red" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code" + ], + [ + 4.5, + 0, + "face" + ], + [ + 5.0, + 0, + "ball" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "{HED}", + "ball": "Red" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Green" + ], + [ + 5.0, + 0, + "ball", + "Black" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EMPTY.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EMPTY.json new file mode 100644 index 000000000..d4f5d6995 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EMPTY.json @@ -0,0 +1,610 @@ +[ + { + "error_code": "TAG_EMPTY", + "alt_codes": [], + "name": "tag-empty-extra-commas-or-parentheses", + "description": "A HED string has extra commas or parentheses separated by only white space.", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Extra commas at beginning or end of strings", + "Double commas creating empty slots", + "Empty parentheses ()", + "Whitespace-only content between commas", + "Copy-paste errors leaving trailing commas" + ], + "explanation": "HED requires all tags to have content. Empty tags occur when commas appear without content between them, or when parentheses contain only whitespace. These create parsing ambiguities.", + "correction_strategy": "Remove extra commas and empty parentheses", + "correction_examples": [ + { + "wrong": "Red, , , Green", + "correct": "Red, Green", + "explanation": "Removed empty tags created by extra commas" + }, + { + "wrong": "(, Red, Green), Blue", + "correct": "(Red, Green), Blue", + "explanation": "Removed leading comma in group" + }, + { + "wrong": "Red, (), Blue", + "correct": "Red, Blue", + "explanation": "Removed empty parentheses" + } + ], + "correction_patterns": [ + "Remove double commas (,,)", + "Remove trailing commas at end of strings", + "Remove leading commas at start of strings", + "Remove empty parentheses ()", + "Remove whitespace-only content between delimiters" + ], + "fix_instructions": [ + "1. Scan for consecutive commas without content", + "2. Remove extra commas at string boundaries", + "3. Remove empty parentheses", + "4. Verify remaining structure is valid" + ], + "validation_hints": [ + "Check for ',,' patterns", + "Verify no trailing or leading commas", + "Ensure all parentheses contain content", + "Confirm no whitespace-only tags" + ], + "specification_reference": "3.2.7.3. Empty tags and groups", + "related_errors": [ + "COMMA_MISSING", + "PARENTHESES_MISMATCH" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Red, , , Green", + "(, Red, Green), Blue", + "(Red, , Green), Blue", + "(Red, Green,), Blue", + "(Red, Green), Blue," + ], + "passes": [ + "(Red, Blue), Green" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "square": "Red, , , Green", + "test": "(, Red, Green), Blue", + "pine": "(Red, , Green), Blue", + "apple": "(Red, Green,), Blue" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Red, Blue", + "ball": "Def/Acc/4.5, Def/Acc/3.2" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 5.5, + 0, + "Red, , , Green" + ], + [ + 7.5, + 0, + "(, Red, Green), Blue" + ], + [ + 8.2, + 0, + "(Red, , Green), Blue" + ], + [ + 9.1, + 0, + "(Red, Green,), Blue" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, (Blue, Green)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "square": "Red, , , Green", + "test": "(, Red, Green), Blue", + "pine": "(Red, , Green), Blue", + "apple": "(Red, Green,), Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "test", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "apple", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red, Green", + "ball": "Def/Acc/4.5, Def/Acc/3.2" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_EMPTY", + "alt_codes": [], + "name": "tag-empty-begin-end-comma", + "description": "A HED string begins or ends with a comma (ignoring white space).", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Extra comma at beginning or end of HED string", + "Copy-paste errors adding trailing/leading commas", + "Incomplete tag removal leaving orphaned commas", + "Formatting errors in HED string construction" + ], + "explanation": "HED strings should not begin or end with commas. Leading/trailing commas indicate structural errors or incomplete content.", + "correction_strategy": "Remove leading and trailing commas from HED strings", + "correction_examples": [ + { + "wrong": ",Red, Blue", + "correct": "Red, Blue", + "explanation": "Removed leading comma" + }, + { + "wrong": "Red, Blue,", + "correct": "Red, Blue", + "explanation": "Removed trailing comma" + }, + { + "wrong": ",Red, Blue,", + "correct": "Red, Blue", + "explanation": "Removed both leading and trailing commas" + } + ], + "correction_patterns": [ + "Trim leading commas from start of strings", + "Remove trailing commas from end of strings", + "Clean up formatting after tag removal" + ], + "fix_instructions": [ + "1. Check beginning of HED string for comma", + "2. Check end of HED string for comma", + "3. Remove any leading/trailing commas", + "4. Verify string structure is valid" + ], + "validation_hints": [ + "Scan for commas at string boundaries", + "Check for empty elements after comma removal", + "Verify proper tag separation after cleanup" + ], + "specification_reference": "3.2.7. HED string syntax rules", + "related_errors": ["COMMA_MISSING", "TAG_EMPTY"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + ", Blue,Def/Acc/3.2 m-per-s^2", + "(Blue, Green),Yellow,", + ",,(Blue, Green),Yellow," + ], + "passes": [ + "(Red, Blue), Green" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": ", Blue,Def/Acc/3.2", + "ball": "(Blue, Green),Yellow,", + "square": ",,(Blue, Green),Yellow," + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Red, Blue", + "ball": "Def/Acc/4.5, Def/Acc/3.2" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + ", (Blue, Green),Yellow," + ], + [ + 5.5, + 0, + ",,(Blue, Green),Yellow," + ], + [ + 6.5, + 0, + ", Blue,Def/Acc/3.2" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, (Blue, Green)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": ", Blue,Def/Acc/3.2", + "ball": "(Blue, Green),Yellow,", + "square": ",,(Blue, Green),Yellow," + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_EMPTY", + "alt_codes": [], + "name": "tag-empty-empty-parentheses", + "description": "A tag group is empty (i.e., empty parentheses are not allowed).", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Empty parentheses () in HED strings", + "Tag removal leaving empty groups behind", + "Copy-paste errors creating empty groups", + "Incomplete tag group construction" + ], + "explanation": "HED does not allow empty parentheses as they serve no semantic purpose and create parsing ambiguities. All groups must contain meaningful content.", + "correction_strategy": "Remove empty parentheses or add appropriate content", + "correction_examples": [ + { + "wrong": "(Red, (), (Blue), ((Green)))", + "correct": "(Red, (Blue), ((Green)))", + "explanation": "Removed empty parentheses group" + }, + { + "wrong": "((( ))), Red", + "correct": "Red", + "explanation": "Removed nested empty parentheses" + }, + { + "wrong": "Red, (), Blue", + "correct": "Red, Blue", + "explanation": "Removed empty group between tags" + } + ], + "correction_patterns": [ + "Remove all empty parentheses groups", + "Clean up after tag removal operations", + "Ensure all groups contain meaningful content" + ], + "fix_instructions": [ + "1. Scan for empty parentheses ()", + "2. Remove empty groups entirely", + "3. Check for nested empty groups", + "4. Verify remaining structure is valid" + ], + "validation_hints": [ + "Look for () patterns in HED strings", + "Check for whitespace-only groups", + "Verify all groups have content" + ], + "specification_reference": "3.2.7.1. Tag group requirements", + "related_errors": ["TAG_EMPTY", "PARENTHESES_MISMATCH"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Red, (), (Blue), ((Green)))", + "((( ))), Red" + ], + "passes": [ + "(Red, ( Blue ), ((Green)))", + "(((Def/Acc/3.5)))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red, (), (Blue), ((Green)))", + "ball": "((( ))), Red" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, ( Blue ), ((Green)))", + "ball": "(((Def/Acc/3.5)))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Red, (), (Blue), ((Green)))" + ], + [ + 5.5, + 0, + "((( ))), Red" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Red, ( Blue ), ((Green)))" + ], + [ + 5.5, + 0, + "(((Def/Acc/3.5)))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, (), (Blue), ((Green)))", + "ball": "((( ))), Red" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red, ( Blue ), ((Green)))", + "ball": "(((Def/Acc/3.5)))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXPRESSION_REPEATED.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXPRESSION_REPEATED.json new file mode 100644 index 000000000..21aaebf07 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXPRESSION_REPEATED.json @@ -0,0 +1,604 @@ +[ + { + "error_code": "TAG_EXPRESSION_REPEATED", + "alt_codes": [], + "name": "tag-expression-repeated-same-level", + "description": "A tag is repeated in the same tag group or level.", + "warning": false, + "schema": "8.4.0", + "error_category": "semantic", + "common_causes": [ + "Copy-paste errors creating duplicates", + "Accidentally adding same tag multiple times", + "Misunderstanding of tag group equivalency", + "Redundant expressions in same scope", + "Not recognizing equivalent tag group orders" + ], + "explanation": "HED treats tag expressions as sets, where order doesn't matter and duplicates are meaningless. Repeated tags or equivalent tag groups at the same level create redundancy and are not allowed.", + "correction_strategy": "Remove duplicate tags and equivalent expressions", + "correction_examples": [ + { + "wrong": "Red, (Blue), Red, Green", + "correct": "Red, (Blue), Green", + "explanation": "Removed duplicate 'Red' tag" + }, + { + "wrong": "(Red, Blue, (Green)), (Red, Blue, (Green))", + "correct": "(Red, Blue, (Green))", + "explanation": "Removed duplicate tag group" + }, + { + "wrong": "(Blue, Green), (Green, Blue)", + "correct": "(Blue, Green)", + "explanation": "Removed equivalent group (order doesn't matter)" + } + ], + "correction_patterns": [ + "Remove identical tags at same level", + "Remove duplicate tag groups", + "Remove groups that are equivalent due to order independence", + "Keep only one instance of repeated expressions", + "Consider merging related content if appropriate" + ], + "fix_instructions": [ + "1. Identify repeated tags at the same level", + "2. Identify equivalent tag groups (same content, different order)", + "3. Remove duplicates keeping only one instance", + "4. Verify remaining structure is meaningful", + "5. Check for nested duplicates at different levels" + ], + "validation_hints": [ + "Compare tags and groups at same nesting level", + "Remember that tag order within groups doesn't matter", + "Check for exact duplicates and order-equivalent groups", + "Verify no repeated expressions remain" + ], + "specification_reference": "3.2.7.4. Repeated expressions", + "related_errors": [ + "TAG_EMPTY", + "COMMA_MISSING" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Red, (Blue), Red, Green", + "(Red, Blue, (Green)), (Red, Blue, (Green))", + "(Red, (Blue, Green, (Yellow)), Red, (Blue, Green, (Yellow)))" + ], + "passes": [ + "Red, (Blue, Red)", + "(Red, Blue, (Green)), (Red, Blue, ((Green)))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Red, (Blue), Red, Green", + "ball": "(Red, Blue, (Green)), (Red, Blue, (Green))", + "square": "(Red, (Blue, Green, (Yellow)), Red, (Blue, Green, (Yellow)))" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Red, (Blue, Red)", + "ball": "(Red, Blue, (Green)), (Red, Blue, ((Green)))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, (Blue), Red, Green" + ], + [ + 5.5, + 0, + "(Red, Blue, (Green)), (Red, Blue, (Green))" + ], + [ + 6.5, + 0, + "(Red, (Blue, Green, (Yellow)), Red, (Blue, Green, (Yellow)))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, (Blue, Red)" + ], + [ + 5.5, + 0, + "(Red, Blue, (Green)), (Red, Blue, ((Green)))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red, (Blue), Red, Green", + "ball": "(Red, Blue, (Green)), (Red, Blue, (Green))", + "square": "(Red, (Blue, Green, (Yellow)), Red, (Blue, Green, (Yellow)))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red, (Blue, Red)", + "ball": "(Red, Blue, (Green)), (Red, Blue, ((Green)))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_EXPRESSION_REPEATED", + "alt_codes": [], + "name": "tags-duplicated-across-multiple-rows", + "description": "Tags are repeated because two rows have the same onset value.", + "warning": false, + "schema": "8.4.0", + "error_category": "duplication", + "common_causes": [ + "Same tag appearing in multiple columns for single event", + "Tag duplication during sidecar assembly", + "Overlapping column content creating repeats", + "Copy-paste errors in event annotations", + "Unintentional tag repetition across data sources" + ], + "explanation": "When assembling HED annotations from multiple sources (columns, sidecars, direct annotations), the same tag should not appear multiple times in the final annotation for a single event.", + "correction_strategy": "Remove duplicate tags from assembled annotations", + "correction_examples": [ + { + "wrong": "Red (from column 1) + Red (from column 2) = Red, Red", + "correct": "Red (from column 1) + Blue (from column 2) = Red, Blue", + "explanation": "Used different tags or removed duplicate" + }, + { + "wrong": "Event with Sensory-event in multiple columns", + "correct": "Event with Sensory-event in one column, other content in other columns", + "explanation": "Eliminated duplication across columns" + } + ], + "correction_patterns": [ + "Check for tag repetition across columns", + "Remove duplicate tags from one source", + "Use different but related tags when appropriate", + "Consolidate related information to avoid duplication" + ], + "fix_instructions": [ + "1. Identify duplicate tags in assembled annotation", + "2. Trace back to source columns causing duplication", + "3. Remove duplicate from one of the sources", + "4. Verify final assembled annotation has no duplicates", + "5. Test with multiple rows to ensure consistency" + ], + "validation_hints": [ + "Check final assembled annotations for duplicates", + "Trace tag sources to identify duplication points", + "Verify column content doesn't overlap inappropriately", + "Test annotation assembly across multiple events" + ], + "specification_reference": "3.2.9. Tag duplication in assembled annotations", + "related_errors": [ + "TAG_EXPRESSION_REPEATED", + "SIDECAR_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Red, Blue, Green)" + ], + [ + 5.5, + 0, + "(Red, Blue, Green)" + ], + [ + 4.5, + 0, + "(Blue, Red, Green)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Red, Blue, Green)" + ], + [ + 5.5, + 0, + "(Red, Blue, Green)" + ], + [ + 4.5, + 0, + "(Blue, (Red, Green))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "ball": "(Green, ((Blue, Orange, (Black, Purple))), White), Blue, Orange" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "(Red, Blue, Green)" + ], + [ + 5.5, + 0, + "ball", + "(Red, Blue, Green)" + ], + [ + 4.5, + 0, + "n/a", + "(Blue, Red, Green)" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "ball": "(Green, ((Blue, Orange, (Black, Purple))), White), Blue, Orange" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "(Red, Blue, Green)" + ], + [ + 5.5, + 0, + "ball", + "(Red, Blue, Green)" + ], + [ + 4.5, + 0, + "n/a", + "(Blue, (Red, Green))" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_EXPRESSION_REPEATED", + "alt_codes": [], + "name": "tags-with-duplicated-onsets-across-multiple-rows", + "description": "Tags are repeated because two rows have the same onset value.", + "warning": false, + "schema": "8.4.0", + "error_category": "temporal_logic", + "common_causes": [ + "Multiple Onset tags for same definition across events", + "Temporal boundary violations with repeated onsets", + "Missing Offset tags between repeated Onsets", + "Incorrect temporal sequence management", + "Overlapping temporal events without proper boundaries" + ], + "explanation": "Temporal logic requires that Onset tags for the same definition be properly paired with Offset tags. Multiple Onsets without intervening Offsets violate temporal sequencing rules.", + "correction_strategy": "Ensure proper Onset/Offset pairing across events", + "correction_examples": [ + { + "wrong": "Event 1: Onset, Def/Action\\nEvent 3: Onset, Def/Action (no Offset between)", + "correct": "Event 1: Onset, Def/Action\\nEvent 2: Offset, Def/Action\\nEvent 3: Onset, Def/Action", + "explanation": "Added required Offset between repeated Onsets" + }, + { + "wrong": "Multiple Onsets for same definition without boundaries", + "correct": "Proper Onset/Offset alternation for temporal boundaries", + "explanation": "Maintained temporal logic consistency" + } + ], + "correction_patterns": [ + "Add missing Offset tags between repeated Onsets", + "Ensure Onset/Offset alternation for same definitions", + "Verify temporal boundary consistency across events", + "Check temporal logic across entire event sequence" + ], + "fix_instructions": [ + "1. Identify repeated Onset tags for same definition", + "2. Check for missing Offset tags between them", + "3. Add required Offset tags to maintain proper sequence", + "4. Verify temporal logic across all events", + "5. Test temporal boundary consistency" + ], + "validation_hints": [ + "Onset tags for same definition need Offset between repetitions", + "Check temporal sequence: Onset → Offset → Onset", + "Verify temporal logic across entire event sequence", + "Look for missing temporal boundaries" + ], + "specification_reference": "3.2.8.3. Temporal tag sequencing requirements", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "TAG_EXPRESSION_REPEATED", + "DEFINITION_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, Def/MyColor)" + ], + [ + 5.5, + 0, + "(Onset, Def/MyColor)" + ], + [ + 4.5, + 0, + "(Def/MyColor, Onset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, Def/MyColor)" + ], + [ + 5.5, + 0, + "(Onset, Def/MyColor)" + ], + [ + 4.5, + 0, + "(Blue, (Red, Green))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "ball": "(Green, ((Blue, Orange, (Black, Purple))), White), Blue, Orange" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "(Onset, Def/MyColor)" + ], + [ + 5.5, + 0, + "ball", + "(Red, Blue, Green)" + ], + [ + 4.5, + 0, + "n/a", + "(Def/MyColor, Onset)" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "ball": "(Green, ((Blue, Orange, (Black, Purple))), White), Blue, Orange" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "(Onset, Def/MyColor)" + ], + [ + 5.5, + 0, + "ball", + "(Def/MyColor, Onset)" + ], + [ + 4.5, + 0, + "n/a", + "Red" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXTENDED.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXTENDED.json new file mode 100644 index 000000000..061bfccac --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXTENDED.json @@ -0,0 +1,202 @@ +[ + { + "error_code": "TAG_EXTENDED", + "alt_codes": [], + "name": "tag-extended-extension", + "description": "A tag represents an extension from the schema.", + "warning": true, + "schema": "8.4.0", + "error_category": "semantic", + "common_causes": [ + "Creating new tags not in schema", + "Misspelling existing tags", + "Using concepts not yet in schema", + "Extending schema for domain-specific needs", + "Working with older schema versions" + ], + "explanation": "Tag extensions allow adding new terms to extend the schema vocabulary. While valid, extensions should be used sparingly and only when necessary concepts don't exist in the current schema. Consider proposing additions to the official schema.", + "correction_strategy": "Verify extension is necessary or use existing schema tags", + "correction_examples": [ + { + "wrong": "Item/MyCustomDevice", + "correct": "Item/Object/Device", + "explanation": "Used existing schema tag instead of extension" + }, + { + "wrong": "Sensory-event/CustomModality", + "correct": "Sensory-event/Auditory", + "explanation": "Found appropriate existing modality" + } + ], + "correction_patterns": [ + "Search schema thoroughly for existing alternatives", + "Consider more general existing tags", + "Verify extension is semantically necessary", + "Ensure parent tag allows extensions", + "Consider proposing schema addition" + ], + "fix_instructions": [ + "1. Check if concept exists in current schema", + "2. Search for similar or more general terms", + "3. If extension needed, verify it's semantically appropriate", + "4. Ensure parent tag has extensionAllowed attribute", + "5. Consider proposing addition to official schema" + ], + "validation_hints": [ + "This is a warning, not an error", + "Extensions are valid but discouraged", + "Consider schema completeness before extending", + "Document extensions for team consistency" + ], + "specification_reference": "3.2.5. Tag extensions", + "related_errors": [ + "TAG_EXTENSION_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Red-color/Red/Big-red, Blue/Nice-blue),(Green, (Yellow))", + "Sensory-presentation/Visual-presentation/Nice-yellow", + "Red-color/Red/Redish", + "Red-color/Red/Redish/More-redish", + "((Green/Greenish))", + "Red/1red", + "Red/Red--2red" + ], + "passes": [ + "Red-color/Red" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Red-color/Red/Big-red, Blue/Nice-blue),(Green, (Yellow))", + "ball": "Sensory-presentation/Visual-presentation/Nice-yellow", + "square": "((Green/Greenish))", + "triangle": "Red/1red", + "catwalk": "Red/Red--2red" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Red-color/Red" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Red-color/Red/Big-red, Blue/Nice-blue),(Green, (Yellow))" + ], + [ + 5.5, + 0, + "Sensory-presentation/Visual-presentation/Nice-yellow" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red-color/Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Red-color/Red/Big-red/Bigger-red, Blue/Nice-blue),(Green, (Yellow))", + "ball": "Sensory-presentation/Visual-presentation/Nice-yellow" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXTENSION_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXTENSION_INVALID.json new file mode 100644 index 000000000..475ef34a1 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_EXTENSION_INVALID.json @@ -0,0 +1,423 @@ +[ + { + "error_code": "TAG_EXTENSION_INVALID", + "alt_codes": [], + "name": "tag-extension-invalid-duplicate", + "description": "A tag extension term is already in the schema.", + "warning": false, + "schema": "8.4.0", + "error_category": "semantic", + "common_causes": [ + "The extending tag already exists in schema", + "Attempting to extend with a term that duplicates existing schema tags", + "Misunderstanding extension vs. existing tag usage", + "Not checking schema before creating extensions", + "Using extensions when appropriate schema tags already exist" + ], + "explanation": "Tag extensions allow adding new terms to the schema hierarchy, but extension terms cannot duplicate existing schema tags. Extensions should only be used when the needed concept doesn't exist in the schema.", + "correction_strategy": "Use existing schema tags instead of creating duplicate extensions", + "correction_examples": [ + { + "wrong": "Red-color/Red/DarkRed", + "correct": "Red-color/Red", + "explanation": "Used existing schema tag instead of creating extension" + }, + { + "wrong": "Sensory-presentation/Red/Redish", + "correct": "Sensory-presentation/Red-color", + "explanation": "Used proper schema hierarchy instead of invalid extension" + } + ], + "correction_patterns": [ + "Check if desired concept already exists in schema", + "Use existing schema tags instead of extensions when possible", + "Search schema thoroughly before creating extensions", + "Use schema browser to verify tag availability" + ], + "fix_instructions": [ + "1. Check if the extension concept already exists in schema", + "2. Use existing schema tag if available", + "3. If extension needed, verify parent tag allows extensions", + "4. Ensure extension follows naming conventions", + "5. Consider proposing schema addition instead of extension" + ], + "validation_hints": [ + "Search schema for existing tags before extending", + "Verify extensionAllowed attribute on parent tags", + "Check extension naming follows schema conventions", + "Consider semantic appropriateness of extensions" + ], + "specification_reference": "3.2.5. Tag extensions", + "related_errors": [ + "TAG_EXTENDED", + "TAG_INVALID", + "CHARACTER_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Red-color/Red/DarkRed, Sensory-presentation/Red", + "Sensory-presentation/Red/Redish" + ], + "passes": [ + "Red-color/Red/Redish", + "((Green/Greenish))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Red-color/Red/DarkRed, Sensory-presentation/Red", + "ball": "Sensory-presentation/Red/Redish" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Red-color/Red/Redish", + "ball": "((Green/Greenish))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red-color/Red/DarkRed, Sensory-presentation/Red" + ], + [ + 5.5, + 0, + "Sensory-presentation/Red/Redish" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red-color/Red" + ], + [ + 5.5, + 0, + "((Green))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red-color/Red/DarkRed, Sensory-presentation/Red", + "ball": "Sensory-presentation/Red/Redish" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red-color/Red", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_EXTENSION_INVALID", + "alt_codes": [ + "CHARACTER_INVALID", + "PLACEHOLDER_INVALID" + ], + "name": "tag-extension-invalid-bad-node-name", + "description": "A tag extension term does not comply with rules for schema nodes.", + "warning": false, + "schema": "8.4.0", + "error_category": "semantic", + "common_causes": [ + "Creating extensions that violate naming rules", + "Using invalid characters in extensions (e.g., $, #, special symbols)", + "Including numbers inappropriately in extension names", + "Using characters not allowed in HED tag names", + "Violating schema node naming conventions" + ], + "explanation": "Tag extensions must follow the same naming rules as regular schema tags. Invalid characters or naming patterns make extensions unparsable and violate HED syntax rules.", + "correction_strategy": "Use only valid characters and naming patterns in tag extensions", + "correction_examples": [ + { + "wrong": "Red/Red$2", + "correct": "Red/Red-variant", + "explanation": "Removed invalid $ character and used proper naming" + }, + { + "wrong": "Red/R#d", + "correct": "Red/Red-type", + "explanation": "Removed invalid # character and used descriptive name" + } + ], + "correction_patterns": [ + "Use only letters, numbers, hyphens, and underscores in extension names", + "Avoid special characters like $, #, @, %, etc.", + "Follow CamelCase or kebab-case naming conventions", + "Ensure extension names are descriptive and meaningful", + "Check schema naming rules before creating extensions" + ], + "fix_instructions": [ + "1. Identify invalid characters in extension name", + "2. Replace invalid characters with valid alternatives", + "3. Ensure name follows schema naming conventions", + "4. Verify extension name is descriptive and meaningful", + "5. Test extension parsing and validation" + ], + "validation_hints": [ + "Check extension names against character restrictions", + "Verify extension follows schema naming patterns", + "Ensure extension can be parsed correctly", + "Test extension in HED validation tools" + ], + "specification_reference": "3.2.2. Tag forms and naming conventions", + "related_errors": [ + "CHARACTER_INVALID", + "TAG_INVALID", + "PLACEHOLDER_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Red/Red$2", + "Red/R#d" + ], + "passes": [ + "Red-color/Red", + "((Green))", + "Red" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Red/Red$2", + "ball": "Red/R#d" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Red-color/Red/Redish", + "ball": "Red-color/Red/Redish/More-redish", + "square": "((Green/Greenish))", + "triangle": "Red/1red", + "catwalk": "Red/Red--2red" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red/Red$2" + ], + [ + 5.5, + 0, + "Red/R#d" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red-color/Red/Redish" + ], + [ + 5.5, + 0, + "Red-color/Red/Redish/More-redish" + ], + [ + 6.5, + 0, + "((Green/Greenish))" + ], + [ + 7.5, + 0, + "Red/1red" + ], + [ + 8.2, + 0, + "Red/Red--2red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red/Red$2", + "ball": "Red/R#d" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red/Redish-like", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_GROUP_ERROR.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_GROUP_ERROR.json new file mode 100644 index 000000000..0f31a3e45 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_GROUP_ERROR.json @@ -0,0 +1,860 @@ +[ + { + "error_code": "TAG_GROUP_ERROR", + "alt_codes": [ + "TEMPORAL_TAG_ERROR", + "TAG_INVALID", + "DEFINITION_INVALID" + ], + "name": "tag-group-error-missing", + "description": "A tag has tagGroup or topLevelTagGroup attribute, but is not enclosed in parentheses.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Tags requiring groups not enclosed in parentheses", + "topLevelTagGroup tags not at top level", + "Multiple topLevelTagGroup tags in same group", + "Temporal tags not properly grouped", + "Definition tags not in required group structure" + ], + "explanation": "Certain HED tags have schema attributes requiring them to appear in tag groups. Tags with 'tagGroup' must be in parentheses, 'topLevelTagGroup' tags must be in top-level groups, and only specific combinations are allowed.", + "correction_strategy": "Ensure required tags are properly grouped according to their attributes", + "correction_examples": [ + { + "wrong": "Definition/Blech, (Red)", + "correct": "(Definition/Blech, (Red))", + "explanation": "Enclosed Definition tag in required parentheses" + }, + { + "wrong": "Onset", + "correct": "(Onset, (Def/SomeDef))", + "explanation": "Put Onset in group with required definition" + }, + { + "wrong": "Duration/5 s, Delay/2 s, Onset", + "correct": "(Duration/5 s, Delay/2 s), (Onset, (Def/SomeDef))", + "explanation": "Properly grouped temporal tags according to their requirements" + } + ], + "correction_patterns": [ + "Enclose tagGroup tags in parentheses", + "Ensure topLevelTagGroup tags are at top level", + "Limit to one topLevelTagGroup per group (except Duration+Delay)", + "Group temporal tags with required companions", + "Structure Definition tags properly" + ], + "fix_instructions": [ + "1. Identify tags with grouping requirements from schema", + "2. Check if tag is properly enclosed in parentheses", + "3. Verify top-level tags are at correct level", + "4. Ensure proper companions for temporal tags", + "5. Check for multiple topLevelTagGroup violations" + ], + "validation_hints": [ + "Consult schema for tag grouping attributes", + "Check parentheses around required tags", + "Verify top-level tag positioning", + "Ensure temporal tag companions are present" + ], + "specification_reference": "3.2.7.2. Tag group attributes", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "DEFINITION_INVALID", + "PARENTHESES_MISMATCH" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Definition/Blech, (Red)", + "Def-expand/Acc/4.5 m-per-s^2, (Acceleration/4.5, Red)", + "Onset", + "Duration/3.0 s", + "Delay/3.0 s" + ], + "passes": [ + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "((Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)), Onset)", + "(Duration/3.0 s, (Event))", + "(Duration/3.0 s, Delay/2.0 s, (Event))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)), Onset" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))", + "ball": "((Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)), Onset)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)" + ], + [ + 5.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)), Onset" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red))" + ], + [ + 5.5, + 0, + "((Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)), Onset)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)", + "ball": "(Def-expand/Acc/4.5, (Acceleration/4.5 m-per-s^2, Red)), Onset" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_GROUP_ERROR", + "alt_codes": [ + "TEMPORAL_TAG_ERROR" + ], + "name": "tag-group-error-not-top-level", + "description": "A tag with the topLevelTagGroup does not appear at a HED tag group at the top level in an assembled HED annotation.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Top-level tags nested too deeply in groups", + "Temporal tags incorrectly grouped below top level", + "Extra parentheses around top-level tags", + "Misunderstanding of top-level tag requirements", + "Incorrect nesting of temporal or context tags" + ], + "explanation": "Tags with topLevelTagGroup attribute (like Duration, Onset, Offset, Event-context) must appear at the top level of tag groups, not nested within other groups.", + "correction_strategy": "Move top-level tags to proper group depth", + "correction_examples": [ + { + "wrong": "((Duration/5 s, (Red)))", + "correct": "(Duration/5 s, (Red))", + "explanation": "Removed extra parentheses to make Duration top-level" + }, + { + "wrong": "((Def/Acc/3.0, Onset))", + "correct": "(Def/Acc/3.0, Onset)", + "explanation": "Moved Onset to top-level of group" + } + ], + "correction_patterns": [ + "Remove extra parentheses around top-level tags", + "Ensure temporal tags are at top group level", + "Move Event-context to top-level position", + "Verify proper tag group hierarchy" + ], + "fix_instructions": [ + "1. Identify tags with topLevelTagGroup attribute", + "2. Check their current nesting level", + "3. Remove extra parentheses to make them top-level", + "4. Verify proper group structure", + "5. Test tag hierarchy compliance" + ], + "validation_hints": [ + "Check nesting depth of temporal tags", + "Ensure Event-context is at top level", + "Look for extra parentheses around top-level tags", + "Verify proper tag group hierarchy" + ], + "specification_reference": "3.2.8. Top-level tag group requirements", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "PARENTHESES_MISMATCH", + "TAG_GROUP_ERROR" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor, ((Duration/5 s, (Red)))" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor, (Duration/5 s, (Red))" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/banana", + "ball": "((Def/Acc/3.0, Onset))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "(Def/Acc/3.0, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_GROUP_ERROR", + "alt_codes": [ + "TEMPORAL_TAG_ERROR" + ], + "name": "tag-group-error-deferred-in-splice", + "description": "A tag with the topLevelTagGroup does not appear at a HED tag group at the top level in an assembled HED annotation.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Top-level tags nested in column splice operations", + "Deferred evaluation causing incorrect tag positioning", + "Column references creating improper nesting", + "Sidecar substitution breaking top-level requirements", + "Complex column dependencies affecting tag hierarchy" + ], + "explanation": "When columns are spliced together in sidecar processing, tags with topLevelTagGroup attribute must still end up at the top level of the final assembled annotation.", + "correction_strategy": "Restructure sidecar to maintain top-level positioning", + "correction_examples": [ + { + "wrong": "duration: 'Duration/#, (Red, Blue)' in splice context", + "correct": "duration: 'Parameter-value/#' with proper grouping", + "explanation": "Prevented Duration from being nested during splice" + }, + { + "wrong": "Column causing ((Duration/5 s, content))", + "correct": "Column structured for (Duration/5 s, content)", + "explanation": "Maintained top-level Duration positioning" + } + ], + "correction_patterns": [ + "Restructure column HED to avoid nesting top-level tags", + "Use proper grouping in sidecar column definitions", + "Ensure column substitution maintains tag hierarchy", + "Verify final assembled annotation structure" + ], + "fix_instructions": [ + "1. Identify problematic column splice operations", + "2. Examine how columns combine in final annotation", + "3. Restructure sidecar to prevent top-level tag nesting", + "4. Test assembled annotation structure", + "5. Verify top-level tag positioning" + ], + "validation_hints": [ + "Check final assembled annotation structure", + "Trace column substitution effects on nesting", + "Verify top-level tags remain at top level", + "Test sidecar processing results" + ], + "specification_reference": "3.2.9. Sidecar processing and tag hierarchy", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "SIDECAR_INVALID", + "TAG_GROUP_ERROR" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "duration": { + "HED": "Duration/#, (Red, Blue)" + }, + "event_code": { + "HED": { + "face": "(Red, Blue)", + "ball": "Black" + } + }, + "ball_type": { + "Description": "Has description with HED", + "HED": "Label/#" + } + }, + { + "duration": { + "HED": "Duration/#, (Red, Blue)" + }, + "event_code": { + "HED": { + "face": "(Red, Blue)", + "ball": "{ball_type}, Black" + } + }, + "ball_type": { + "Description": "Has description with HED", + "HED": "Label/#" + } + } + ], + "passes": [ + { + "duration": { + "HED": "Parameter-value/#" + }, + "event_code": { + "HED": { + "face": "({duration}, ((Red, Blue), {ball_type}))", + "ball": "{ball_type}, Black" + } + }, + "ball_type": { + "Description": "Has description with HED", + "HED": "Label/#" + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor, ((Duration/5 s, (Red)))" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor, (Duration/5 s, (Red))" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "duration": { + "HED": "Duration/#, (Red, Blue)" + }, + "event_code": { + "HED": { + "face": "{duration}, ((Red, Blue), {ball_type})", + "ball": "{ball_type}, Black" + } + }, + "ball_type": { + "Description": "Has description with HED", + "HED": "Label/#" + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "duration": { + "HED": "Duration/#" + }, + "event_code": { + "HED": { + "face": "({duration}, ((Red, Blue), {ball_type}))", + "ball": "{ball_type}, Black" + } + }, + "ball_type": { + "Description": "Has description with HED", + "HED": "Label/#" + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_GROUP_ERROR", + "alt_codes": [ + "TEMPORAL_TAG_ERROR" + ], + "name": "multiple-top-level-tags-in-same-group", + "description": "Multiple tags with the topLevelTagGroup attribute appear in the same top-level tag group. (Delay and Duration are allowed to be in the same topLevelTagGroup).", + "warning": false, + "schema": "8.4.0", + "error_category": "cardinality", + "common_causes": [ + "Multiple context tags in single group", + "Combining incompatible temporal tags", + "Multiple top-level tags where only one allowed", + "Misunderstanding top-level tag exclusivity rules", + "Incorrect grouping of Event-context with temporal tags" + ], + "explanation": "Most top-level tags are mutually exclusive within a group. Only Delay and Duration can coexist in the same top-level group. Other combinations violate cardinality constraints.", + "correction_strategy": "Separate incompatible top-level tags into different groups", + "correction_examples": [ + { + "wrong": "(Def/MyColor, Onset, Event-context)", + "correct": "(Def/MyColor, Onset), (Event-context, (Label/Description))", + "explanation": "Separated Onset and Event-context into different groups" + }, + { + "wrong": "(Event-context, Duration/3.0 s, Offset)", + "correct": "(Event-context, (Label/Context)), (Duration/3.0 s, Offset)", + "explanation": "Moved Event-context to separate group from temporal tags" + } + ], + "correction_patterns": [ + "Separate Event-context from temporal tags", + "Allow only Delay/Duration combinations", + "Create separate groups for incompatible top-level tags", + "Verify top-level tag cardinality rules" + ], + "fix_instructions": [ + "1. Identify groups with multiple top-level tags", + "2. Check if combination is allowed (only Delay+Duration)", + "3. Separate incompatible tags into different groups", + "4. Verify proper group structure", + "5. Test cardinality compliance" + ], + "validation_hints": [ + "Only one top-level tag per group (except Delay+Duration)", + "Separate Event-context from temporal tags", + "Check for multiple temporal tags in same group", + "Verify cardinality constraints" + ], + "specification_reference": "3.2.8. Top-level tag cardinality constraints", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "TAG_GROUP_ERROR", + "DEFINITION_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def/MyColor, Onset, Event-context)", + "(Event-context, Red, Offset)", + "(Event-context, Duration/3.0 s, Offset)", + "(Delay/3.0 s, Duration/2.0 s, Offset)" + ], + "passes": [ + "(Def/MyColor, Onset)", + "((Event), Duration/3.0 s, Delay/2.0 s)" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Acceleration/banana", + "ball": "(Def/Acc/3.0, Onset, Event-context)" + } + } + }, + { + "event_code": { + "HED": { + "face": "Acceleration/5.0", + "ball": "Red" + } + }, + "val_col": { + "HED": "Time-interval/# s, (Duration/5.0 s, ({event_code}), Duration/6.0)" + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Acceleration/5.0)", + "ball": "(Delay/5.0 s, (Acceleration/5.0))" + } + }, + "val_col": { + "HED": "Time-interval/# s, (Duration/5.0 s, (Red)), {event_code}" + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, (Event-context, Def/MyColor, Onset)" + ], + [ + 5.0, + 0, + "Green" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Red, (Event-context, (Def/MyColor))" + ], + [ + 5.0, + 0, + "Green" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/banana", + "ball": "(Def/Acc/3.0, Onset, Event-context)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, (Def/MyColor, Event-context, Event-context)" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "(Def/Acc/3.02, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue, (Event-context, (Label/Red))" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_INVALID.json new file mode 100644 index 000000000..e85dad660 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_INVALID.json @@ -0,0 +1,545 @@ +[ + { + "error_code": "TAG_INVALID", + "alt_codes": ["PLACEHOLDER_INVALID"], + "name": "tag-invalid-in-schema", + "description": "The tag is not valid in the schema it is associated with.", + "warning": false, + "schema": "8.4.0", + "error_category": "semantic", + "common_causes": [ + "Misspelling tag names", + "Using tags that don't exist in the specified schema version", + "Creating extensions without proper parent tags", + "Using placeholder (#) in wrong context", + "Including extra whitespace or incorrect formatting" + ], + "explanation": "HED tags must exist in the specified schema or be valid extensions of existing tags. Invalid tags often result from spelling errors, using outdated tag names, or attempting to extend non-extensible tags.", + "correction_strategy": "Use valid schema tags or create proper extensions", + "correction_examples": [ + { + "wrong": "ReallyInvalid/Extension", + "correct": "Item/Object/Man-made-object/Device", + "explanation": "Replaced non-existent tag with valid schema tag" + }, + { + "wrong": "Label #", + "correct": "Label/SomeLabel", + "explanation": "Replaced invalid placeholder usage with proper tag value" + }, + { + "wrong": "Sensory-event/Baloney", + "correct": "Sensory-event/Auditory", + "explanation": "Replaced invalid extension with valid schema tag" + } + ], + "correction_patterns": [ + "Check spelling against current schema version", + "Use schema browser to find correct tag paths", + "Replace invalid extensions with valid schema tags", + "Remove extra whitespace and fix formatting", + "Use proper tag hierarchy (parent/child relationships)" + ], + "fix_instructions": [ + "1. Verify tag exists in the specified schema version", + "2. Check for spelling errors in tag names", + "3. Ensure proper tag hierarchy and path", + "4. Remove invalid characters or formatting", + "5. Replace with valid schema tags or proper extensions" + ], + "validation_hints": [ + "Use HED schema browser to verify tag existence", + "Check that tag follows proper naming conventions", + "Ensure tag hierarchy is maintained", + "Verify schema version compatibility" + ], + "specification_reference": "3.2.2. Tag forms", + "related_errors": ["TAG_EXTENSION_INVALID", "PLACEHOLDER_INVALID", "CHARACTER_INVALID"], + "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "Label #", + "ReallyInvalid/Extension", + "ReallyInvalid" + ], + "passes": [ + "Brown-color/Brown" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Label #", + "ball": "ReallyInvalid/Extension", + "square": "ReallyInvalid" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Brown-color/Brown" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Label #"], + [ 5.5, 0, "Property/Sensory-event"], + [ 5.5, 0, "Sensory-event/Baloney"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [4.5, 0, "Brown-color/Brown"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "ReallyInvalid", + "ball": "Property/Sensory-event", + "square": "Sensory-event/Baloney" + } + } + }, + "events": + [ + ["onset", "duration", "event_code","HED"], + [ 4.5, 0, "face", "Red, Def/MyColor"], + [ 5.0, 0, "ball", "Green"] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue/Apples" + } + } + }, + "events": + [ + ["onset", "duration", "event_code","HED"], + [ 4.5, 0, "face", "Blue"], + [ 5.0, 0, "ball", "Green, Def/MyColor"] + ] + } + ] + } + } + }, + { + "error_code": "TAG_INVALID", + "alt_codes": [], + "name": "tag-has-extra-white space", + "description": "A HED tag has extra internal whitespace, including directly before or after slashes.", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Extra spaces within tag names", + "Spaces before or after forward slashes", + "Copy-paste errors introducing whitespace", + "Formatting inconsistencies in tag construction", + "Manual typing errors with extra spaces" + ], + "explanation": "HED tags must follow strict formatting rules without extra internal whitespace. Spaces before/after slashes or within tag names break tag parsing and schema validation.", + "correction_strategy": "Remove all extra whitespace from tag names", + "correction_examples": [ + { + "wrong": "Sensory- event", + "correct": "Sensory-event", + "explanation": "Removed space before 'event'" + }, + { + "wrong": "Event /Sensory-event", + "correct": "Event/Sensory-event", + "explanation": "Removed space before forward slash" + }, + { + "wrong": "Event/ Sensory-event", + "correct": "Event/Sensory-event", + "explanation": "Removed space after forward slash" + } + ], + "correction_patterns": [ + "Remove spaces within tag names", + "Remove spaces before forward slashes", + "Remove spaces after forward slashes", + "Maintain proper hyphenation without spaces" + ], + "fix_instructions": [ + "1. Identify tags with internal whitespace", + "2. Remove spaces before/after slashes", + "3. Remove extra spaces within tag names", + "4. Verify proper tag formatting", + "5. Test tag validation with schema" + ], + "validation_hints": [ + "Tags should have no internal spaces", + "No spaces around forward slashes", + "Check for trailing/leading spaces in tag names", + "Verify proper hyphenation formatting" + ], + "specification_reference": "3.2.7.1. Tag formatting requirements", + "related_errors": [ + "CHARACTER_INVALID", + "TAG_INVALID", + "COMMA_MISSING" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Sensory- event,Green", + "Sensory -event,Blue", + "Event /Sensory-event, Black", + "Event/ Sensory-event,White" + ], + "passes": [ + "Sensory-event, Green" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "square": "Sensory- event,Green", + "test": "Sensory -event,Blue", + "pine": "Event /Sensory-event, Black", + "apple": "Event/ Sensory-event,White" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Sensory-event, Green", + "ball": "Def/Acc/4.5, Def/Acc/3.2" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 5.5, + 0, + "Sensory- event,Green" + ], + [ + 7.5, + 0, + "Sensory -event,Blue" + ], + [ + 8.2, + 0, + "Event /Sensory-event, Black" + ], + [ + 9.1, + 0, + "Event/ Sensory-event,White" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Sensory-event, Green" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "square": "Sensory- event,Green", + "test": "Sensory -event,Blue", + "pine": "Event /Sensory-event, Black", + "apple": "Event/ Sensory-event,White" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "test", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "apple", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": " Red, Green", + "ball": "Def/Acc/4.5, Def/Acc/3.2" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TAG_INVALID", + "alt_codes": [], + "name": "tag-has-leading-trailing-or-consecutive-slashes", + "description": "A HED tag has leading, trailing or consecutive slashes.", + "warning": false, + "schema": "8.4.0", + "error_category": "syntax", + "common_causes": [ + "Leading slashes at beginning of tags", + "Trailing slashes at end of tags", + "Double slashes within tag paths", + "Copy-paste errors introducing extra slashes", + "Incorrect path construction in tag hierarchies" + ], + "explanation": "HED tags must use forward slashes only to separate hierarchy levels. Leading, trailing, or consecutive slashes break tag parsing and create invalid tag structures.", + "correction_strategy": "Remove improper slashes and fix tag hierarchy", + "correction_examples": [ + { + "wrong": "/Event", + "correct": "Event", + "explanation": "Removed leading slash" + }, + { + "wrong": "Red/", + "correct": "Red", + "explanation": "Removed trailing slash" + }, + { + "wrong": "Event//Sensory-event", + "correct": "Event/Sensory-event", + "explanation": "Removed consecutive slashes" + }, + { + "wrong": "Body-part/Head-part//Brain", + "correct": "Body-part/Head-part/Brain", + "explanation": "Fixed double slash in hierarchy" + } + ], + "correction_patterns": [ + "Remove leading slashes from tag beginnings", + "Remove trailing slashes from tag endings", + "Replace consecutive slashes with single slashes", + "Verify proper hierarchy separation" + ], + "fix_instructions": [ + "1. Identify tags with improper slashes", + "2. Remove leading slashes at tag start", + "3. Remove trailing slashes at tag end", + "4. Replace consecutive slashes with single slashes", + "5. Verify proper tag hierarchy structure" + ], + "validation_hints": [ + "Tags should not start or end with slashes", + "Use single slashes to separate hierarchy levels", + "Check for double slashes within tag paths", + "Verify proper tag structure and hierarchy" + ], + "specification_reference": "3.2.7.1. Tag slash usage requirements", + "related_errors": [ + "CHARACTER_INVALID", + "TAG_INVALID", + "TAG_EXTENSION_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "/Event", + "Red/", + "Event//Sensory-event", + "//Event", + "Body-part/Head-part//Brain", + "Def/Acc/4.5//", + "Def/Acc/4.5/", + "/ /Def/Acc/4.5 ms/" + ], + "passes": [ + "Body-part/Head-part/Brain", + "Label/Red, Informational-property/Label/Blue" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Event//Sensory-event", + "ball": "/Event", + "square": "Red/", + "test": "/ /Def/Acc/4.5/" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Body-part/Head-part/Brain", + "ball": "Def/Acc/4.5, Def/Acc/3.2" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ "onset", "duration", "HED"], + [ 4.5, 0, "/Event,"], + [5.5, 0, "Body-part/Head-part//Brain"], + [6.5, 0, "Event/Sensory-event/"], + [ 7.2, 0, "/ /Def/Acc/4.5/"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [4.5, 0, "Event/Sensory-event"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Event//Sensory-event", + "ball": "//Event", + "square": "Body-part/Head-part//Brain", + "test": "/ /Def/Acc/4.5" + } + } + }, + "events": [ + ["onset", "duration", "event_code", "HED"], + [4.5, 0, "face", "Red/, Def/MyColor"], + [5.0, 0, "ball", "Green"], + [ 7.2, 0, "n/a", "/ /Def/Acc/4.5"] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Event/Sensory-event" + ] + ] + } + ] + } + } + } +] diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_NAMESPACE_PREFIX_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_NAMESPACE_PREFIX_INVALID.json new file mode 100644 index 000000000..a1495e1c4 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_NAMESPACE_PREFIX_INVALID.json @@ -0,0 +1,273 @@ +[ + { + "error_code": "TAG_NAMESPACE_PREFIX_INVALID", + "alt_codes": [], + "name": "tag-namespace_prefix-invalid-characters", + "description": "A tag prefix has invalid characters.", + "warning": false, + "schema": ["8.3.0", "sc:score_1.0.0"], + "error_category": "syntax", + "common_causes": [ + "Invalid characters in namespace prefix", + "Incorrect namespace prefix format", + "Using undefined namespace prefixes", + "Mixing library schemas incorrectly", + "Misunderstanding namespace syntax" + ], + "explanation": "Namespace prefixes allow using multiple HED schemas (standard + library schemas) in the same annotation. Prefixes must follow naming rules and correspond to valid schema namespaces.", + "correction_strategy": "Use valid namespace prefixes with correct syntax", + "correction_examples": [ + { + "wrong": "sc2:Sleep-modulator", + "correct": "sc:Sleep-modulator", + "explanation": "Used valid library schema prefix without invalid characters" + }, + { + "wrong": "sca:Sleep-modulator", + "correct": "sc:Sleep-modulator", + "explanation": "Corrected to match loaded schema namespace prefix" + } + ], + "correction_patterns": [ + "Use only valid characters in namespace prefixes", + "Ensure prefix corresponds to loaded schema", + "Follow namespace prefix naming conventions", + "Check library schema availability", + "Use proper prefix:tag syntax" + ], + "fix_instructions": [ + "1. Check namespace prefix follows naming rules", + "2. Verify prefix corresponds to available schema", + "3. Fix invalid characters in prefix", + "4. Ensure proper prefix:tag syntax", + "5. Validate library schema is properly loaded" + ], + "validation_hints": [ + "Check schema loading includes referenced libraries", + "Verify prefix naming follows conventions", + "Ensure colon separator is used correctly", + "Confirm library schema availability" + ], + "specification_reference": "3.2.6. Tag namespace prefixes", + "related_errors": ["SCHEMA_LOAD_FAILED", "TAG_INVALID"], + "definitions": ["(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", "(Definition/MyColor, (Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "sc2:Sleep-modulator, Red", + "sca:Sleep-modulator, Red" + ], + "passes": [ + "Blue", + "sc:Sleep-modulator, Red" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "sc1:Sleep-modulator, Red", + "ball": "(Def/MyColor, Onset)(Def/Acc/3.5)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Red, Blue), (Green, (Yellow))", + "ball": "(Def/MyColor, Onset),(Def/Acc/3.5)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "sc1:Sleep-modulator, Red"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [4.5, 0, "(Red, Blue), (Green, (Yellow))"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "sc1:Sleep-modulator, Red", + "ball": "(Def/MyColor, Onset)(Def/Acc/3.5)" + } + } + }, + "events": + [ + ["onset", "duration", "event_code","HED"], + [ 4.5, 0, "face", "Red, Def/MyColor"], + [ 5.0, 0, "ball", "Green"] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2, sc:Sleep-modulator", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": + [ + ["onset", "duration", "event_code","HED"], + [ 4.5, 0, "face", "Blue"], + [ 5.0, 0, "ball", "Green, Def/MyColor"] + ] + } + ] + } + } + }, + { + "error_code": "TAG_NAMESPACE_PREFIX_INVALID", + "alt_codes": [], + "name": "tag-namespace_prefix-with-colon-values", + "description": "A tag prefix has invalid characters.", + "warning": false, + "schema": ["ts:8.3.0"], + "error_category": "validation", + "common_causes": [ + "Missing namespace prefix for schema-specific tags", + "Using tags without proper namespace qualification", + "Confusion about when namespace prefixes are required", + "Incorrect tag format for multi-schema contexts" + ], + "explanation": "When using multiple schemas or library schemas, tags must be properly prefixed with their namespace to avoid ambiguity.", + "correction_strategy": "Add appropriate namespace prefix to tags", + "correction_examples": [ + { + "wrong": "Creation-date/2009-04-09T12:04:14", + "correct": "ts:Creation-date/2009-04-09T12:04:14", + "explanation": "Added required 'ts:' namespace prefix for test schema tag" + }, + { + "wrong": "Label/TestValue", + "correct": "ts:Label/TestValue", + "explanation": "Added namespace prefix for library schema tag" + } + ], + "correction_patterns": [ + "Add namespace prefix (e.g., 'ts:') to schema-specific tags", + "Check schema requirements for namespace usage", + "Ensure consistent namespace prefixing" + ], + "fix_instructions": [ + "1. Identify tags that require namespace prefixes", + "2. Determine the correct namespace for each tag", + "3. Add prefix in format 'namespace:TagName'", + "4. Verify all schema-specific tags are properly prefixed" + ], + "validation_hints": [ + "Check schema documentation for namespace requirements", + "Ensure all library tags have appropriate prefixes", + "Verify namespace consistency across HED strings" + ], + "specification_reference": "3.3. Library schemas and namespaces", + "related_errors": ["TAG_INVALID", "SCHEMA_LIBRARY_INVALID"], + "definitions": ["(ts:Definition/Acc/#, (ts:Acceleration/# m-per-s^2, ts:Red))", "(ts:Definition/MyColor, (ts:Label/Pie))"], + "tests": { + "string_tests": { + "fails": [ + "Creation-date/2009-04-09T12:04:14" + ], + "passes": [ + "ts:Creation-date/2009-04-09T12:04:14" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Creation-date/2009-04-09T12:04:14", + "ball": "Red" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "ts:Creation-date/2009-04-09T12:04:14", + "ball": "ts:Blue" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + ["onset", "duration", "HED"], + [ 4.5, 0, "Creation-date/2009-04-09T12:04:14"] + ] + ], + "passes": [ + [ + ["onset", "duration", "HED"], + [4.5, 0, "ts:Creation-date/2009-04-09T12:04:14"] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Creation-date/2009-04-09T12:04:14", + "ball": "Blue" + } + } + }, + "events": + [ + ["onset", "duration", "event_code","HED"], + [ 4.5, 0, "ball", "Creation-date/2009-04-09T12:04:14"], + [ 5.0, 0, "ball", "Green"] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "ts:Creation-date/2009-04-09T12:04:14", + "ball": "ts:Def/Acc/7, ts:Blue" + } + } + }, + "events": + [ + ["onset", "duration", "event_code","HED"], + [ 4.5, 0, "face", "ts:Blue"], + [ 5.0, 0, "ball", "ts:Green, ts:Def/MyColor"] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_NOT_UNIQUE.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_NOT_UNIQUE.json new file mode 100644 index 000000000..0611b9bfe --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_NOT_UNIQUE.json @@ -0,0 +1,186 @@ +[ + { + "error_code": "TAG_NOT_UNIQUE", + "alt_codes": [], + "name": "tag-not-unique", + "description": "A tag with unique attribute appears more than once in an event-level HED string.", + "warning": false, + "schema": "8.4.0", + "error_category": "semantic", + "common_causes": [ + "Using unique tags multiple times in same event", + "Duplicate unique tags in different tag groups", + "Not understanding unique tag constraints", + "Copy-paste errors with unique tags", + "Conflicting annotations from different sources" + ], + "explanation": "Tags marked with the 'unique' schema attribute can only appear once per event-level annotation. This ensures that certain concepts (like experimental context) are not contradictory or duplicated within a single event.", + "correction_strategy": "Remove duplicate instances of unique tags or merge into single occurrence", + "correction_examples": [ + { + "wrong": "(Event-context, (Red, Blue)), (Event-context, (Green, Yellow))", + "correct": "(Event-context, (Red, Blue, Green, Yellow))", + "explanation": "Merged duplicate Event-context tags into single occurrence" + }, + { + "wrong": "Task-context/Face-viewing, Task-context/Word-reading", + "correct": "Task-context/Face-viewing", + "explanation": "Removed duplicate task context, keeping most relevant one" + } + ], + "correction_patterns": [ + "Merge content of duplicate unique tags when semantically appropriate", + "Remove redundant instances keeping most complete one", + "Choose most specific or relevant unique tag when merging not possible", + "Reorganize annotation structure to avoid unique tag conflicts", + "Review annotation logic to ensure single clear context" + ], + "fix_instructions": [ + "1. Identify the unique tag appearing multiple times", + "2. Determine if content can be merged semantically", + "3. Combine compatible content into single tag occurrence", + "4. Remove redundant instances", + "5. Verify event context remains clear and unambiguous" + ], + "validation_hints": [ + "Check schema for unique attribute on tags", + "Scan entire event annotation for duplicate unique tags", + "Verify merged content maintains semantic coherence", + "Ensure single clear context per event" + ], + "specification_reference": "3.2.10.2. Event-level processing", + "related_errors": [ + "TAG_EXPRESSION_REPEATED", + "TAG_GROUP_ERROR" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Event-context, (Red, Blue)), (Event-context, (Green, Yellow))" + ], + "passes": [ + "(Event-context, (Red, Blue))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Event-context, (Red, Blue)), (Event-context, (Green, Yellow))" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Event-context, (Red, Blue))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Event-context, (Red, Blue)), (Event-context, (Green, Yellow))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Event-context, (Red, Blue))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Event-context, (Red, Blue)), (Event-context, (Green, Yellow))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Event-context, (Red, Blue))", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "(Event-context, (Red, Blue))" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TAG_REQUIRES_CHILD.json b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_REQUIRES_CHILD.json new file mode 100644 index 000000000..6b39955e3 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TAG_REQUIRES_CHILD.json @@ -0,0 +1,202 @@ +[ + { + "error_code": "TAG_REQUIRES_CHILD", + "alt_codes": [], + "name": "tag-requires-child-missing", + "description": "A tag has the requireChild schema attribute but does not have a child.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Using parent tags without required children", + "Incomplete tag paths", + "Missing value or extension for placeholder tags", + "Forgetting required specificity", + "Using abstract concepts without concrete instances" + ], + "explanation": "Some tags in the schema are marked with 'requireChild' attribute, meaning they must be followed by a more specific child tag or value. These tags represent abstract concepts that need concrete specification.", + "correction_strategy": "Add required child tags or values to complete the specification", + "correction_examples": [ + { + "wrong": "Item", + "correct": "Item/Object", + "explanation": "Added required child to specify type of item" + }, + { + "wrong": "Property/Physical-property", + "correct": "Property/Physical-property/Color", + "explanation": "Extended to required child property" + }, + { + "wrong": "Label", + "correct": "Label/ButtonPress", + "explanation": "Added specific label value" + } + ], + "correction_patterns": [ + "Extend parent tag with appropriate child", + "Add specific values for placeholder tags", + "Use concrete rather than abstract concepts", + "Follow schema hierarchy to required specificity", + "Provide values for tags requiring them" + ], + "fix_instructions": [ + "1. Identify the tag with requireChild attribute", + "2. Check schema for appropriate child options", + "3. Add specific child tag or value", + "4. Ensure semantic appropriateness", + "5. Verify complete tag path is valid" + ], + "validation_hints": [ + "Check schema for requireChild attribute", + "Verify child tag exists in schema", + "Ensure semantic relationship is appropriate", + "Confirm complete tag path validity" + ], + "specification_reference": "3.2.4. Tags that take values", + "related_errors": [ + "TAG_INVALID", + "PLACEHOLDER_INVALID", + "VALUE_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Blue, Def)", + "Def, Red" + ], + "passes": [ + "(Blue, Def/MyColor, (Red))", + "Label/Redish, Def/MyColor, Red" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Blue, Def)", + "ball": "Label, Red" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Blue, Def/MyColor, (Red))", + "ball": "Label/Redish, Red" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Blue, Def)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Blue, Def/MyColor, (Red))" + ], + [ + 5.0, + 0, + "Label/Redish, Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Blue, Def)", + "ball": "Label, Red" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Label/Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TEMPORAL_TAG_ERROR.json b/spec_tests/hed-tests/json_test_data/validation_tests/TEMPORAL_TAG_ERROR.json new file mode 100644 index 000000000..75aecba74 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TEMPORAL_TAG_ERROR.json @@ -0,0 +1,2553 @@ +[ + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-not-tag-group", + "description": "An Onset or Offset tag does not appear in a tag group.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Onset/Offset tags not enclosed in parentheses", + "Missing required Def tag with temporal tags", + "Temporal tags in nested groups instead of top-level", + "Incorrect pairing of Onset and Offset", + "Misunderstanding temporal tag requirements" + ], + "explanation": "Temporal tags (Onset, Offset, Inset, Duration, Delay) have strict structural requirements. They must appear in top-level tag groups with specific companions and follow precise timing relationships.", + "correction_strategy": "Ensure temporal tags follow required structural patterns", + "correction_examples": [ + { + "wrong": "Onset, Red", + "correct": "(Onset, (Def/MyEvent, (Red)))", + "explanation": "Enclosed Onset in group with required definition" + }, + { + "wrong": "Offset, Def/Acc/5.4", + "correct": "(Offset, (Def/Acc/5.4))", + "explanation": "Properly grouped Offset with definition" + }, + { + "wrong": "(Duration/5 s, Red, Blue)", + "correct": "(Duration/5 s, (Red, Blue))", + "explanation": "Moved content into required inner group" + } + ], + "correction_patterns": [ + "Enclose temporal tags in top-level parentheses", + "Include required Def tag or Def-expand group", + "Ensure proper Onset/Offset pairing and timing", + "Group additional content in inner groups", + "Verify temporal relationships are logical" + ], + "fix_instructions": [ + "1. Identify temporal tags requiring grouping", + "2. Enclose in top-level parentheses", + "3. Add required Def tag or Def-expand group", + "4. Verify proper temporal tag relationships", + "5. Check for appropriate inner group structure" + ], + "validation_hints": [ + "Ensure Onset comes before corresponding Offset", + "Verify temporal tags are at top level", + "Check for required definition companions", + "Validate temporal sequence logic" + ], + "specification_reference": "3.2.8.3. Onset, Offset, and Inset", + "related_errors": [ + "TAG_GROUP_ERROR", + "DEFINITION_INVALID", + "DEF_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Onset, Red", + "Offset, Def/Acc/5.4" + ], + "passes": [ + "(Onset, Def/Acc/5.4)" + ] + }, + "sidecar_tests": { + "fails": [], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Onset, Def/Acc/5.4)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Onset, Red" + ], + [ + 5.0, + 0, + "Onset, Def/MyColor" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, (Def-expand/MyColor, (Label/Pie)), (Red))" + ], + [ + 5.5, + 0, + "(Onset, Def/Acc/5.4)" + ], + [ + 6.3, + 0, + "(Offset, Def/Acc/5.4)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Onset, Red", + "ball": "(Onset, Def/Acc/5.4)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "Onset, Def/MyColor" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Onset, Def/Acc/5.4)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 5.5, + 0, + "n/a", + "(Onset, Def/Acc/5.4)" + ], + [ + 6.3, + 0, + "n/a", + "(Offset, Def/Acc/5.4)" + ], + [ + 8.5, + 0, + "face", + "Blue" + ], + [ + 9.0, + 0, + "n/a", + "Green, ((Def-expand/MyColor, (Label/Pie)), Onset)" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-nested-group", + "description": "An Onset or Offset tag appears in a nested tag group (not a top-level tag group).", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Temporal tags incorrectly nested within other groups", + "Double parentheses around temporal tag groups", + "Misunderstanding that temporal tags must be at top level", + "Incorrectly grouping temporal content" + ], + "explanation": "Temporal tags must appear at the top level of tag groups, not nested within other groups. This ensures proper temporal relationship parsing.", + "correction_strategy": "Move temporal tags to top-level groups", + "correction_examples": [ + { + "wrong": "((Onset, Def/MyColor), Red)", + "correct": "(Onset, Def/MyColor), Red", + "explanation": "Removed extra parentheses to make Onset top-level" + }, + { + "wrong": "Red, ((Offset, Def/Response))", + "correct": "Red, (Offset, Def/Response)", + "explanation": "Moved Offset to proper top-level group" + } + ], + "correction_patterns": [ + "Remove extra nesting parentheses around temporal tags", + "Ensure temporal tags are direct children of top-level groups", + "Separate temporal groups from content groups" + ], + "fix_instructions": [ + "1. Identify nested temporal tags", + "2. Remove extra parentheses layers", + "3. Ensure temporal tags are at top level", + "4. Verify proper group structure" + ], + "validation_hints": [ + "Check for double parentheses around temporal tags", + "Ensure temporal tags are not inside content groups", + "Verify proper separation of temporal and content elements" + ], + "specification_reference": "3.2.8.3. Temporal tag group structure", + "related_errors": ["TAG_GROUP_ERROR", "PARENTHESES_MISMATCH"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "((Onset, Def/MyColor), Red)" + ], + "passes": [ + "(Onset, Def/MyColor), Red" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "((Onset, Def/MyColor), Red)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor), Red" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "((Onset, Def/MyColor), Red)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, Def/MyColor), Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "((Onset, Def/MyColor), Red)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "n/a", + "((Onset, Def/MyColor), Red)" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor), Red" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "n/a", + "(Onset, Def/MyColor), Red" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-wrong-number-of-defs", + "description": "An Onset or Offset tag is not grouped with exactly one Def-expand tag group or a Def tag.", + "warning": false, + "schema": "8.4.0", + "error_category": "content", + "common_causes": [ + "Multiple Def tags in a single temporal group", + "Missing required Def tag with temporal tag", + "Confusion about definition requirements for temporal tags", + "Incorrectly combining multiple definitions" + ], + "explanation": "Each temporal tag group should contain exactly one definition or def-expand group. Multiple definitions create ambiguity about the temporal event.", + "correction_strategy": "Use exactly one definition per temporal tag group", + "correction_examples": [ + { + "wrong": "(Onset, Def/Event1, Def/Event2)", + "correct": "(Onset, Def/Event1)", + "explanation": "Removed extra definition to have exactly one" + }, + { + "wrong": "(Offset, Red, Blue)", + "correct": "(Offset, (Def/MyEvent, (Red, Blue)))", + "explanation": "Added required definition for temporal tag" + } + ], + "correction_patterns": [ + "Use exactly one Def tag per temporal group", + "Add missing definitions for temporal tags", + "Remove extra definitions from temporal groups" + ], + "fix_instructions": [ + "1. Count definitions in temporal groups", + "2. Remove extra definitions or add missing ones", + "3. Ensure each temporal group has exactly one definition", + "4. Verify definition content is appropriate" + ], + "validation_hints": [ + "Count Def tags in each temporal group", + "Ensure temporal events have clear definitions", + "Check for missing or duplicate definitions" + ], + "specification_reference": "3.2.8.3. Temporal tag definition requirements", + "related_errors": ["DEFINITION_INVALID", "DEF_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Onset, (Red))" + ], + "passes": [ + "(Onset, Def/MyColor, (Red))", + "(Onset, (Def-expand/MyColor, (Label/Pie)), (Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Onset, (Red))", + "ball": "(Onset, Def/MyColor, Def/Acc/4.3)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor, (Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, (Red))" + ], + [ + 5.5, + 0, + "(Onset, Def/MyColor, Def/Acc/4.32)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, Def/MyColor, (Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Onset, (Red))", + "ball": "(Onset, Def/MyColor, Def/Acc/4.3)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Green, Def/MyColor" + ], + [ + 5.0, + 0, + "n/a", + "(Onset, (Yellow))" + ], + [ + 6.0, + 0, + "ball", + "n/a" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor, (Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "n/a", + "(Onset, Def/MyColor, (Blue))" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-onset-has-more-groups", + "description": "An Onset group has more than one additional tag group.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Extra groups added to Onset beyond required definition", + "Misunderstanding Onset group structure requirements", + "Incorrectly nesting additional content in Onset group", + "Confusion about what belongs in temporal groups" + ], + "explanation": "Onset groups should contain only the temporal tag and its required definition group. Additional groups create structural violations.", + "correction_strategy": "Remove extra groups from Onset or restructure properly", + "correction_examples": [ + { + "wrong": "(Onset, Def/Event, (Red), (Blue))", + "correct": "(Onset, (Def/Event, (Red, Blue)))", + "explanation": "Combined extra groups into single definition content group" + }, + { + "wrong": "(Onset, Def/Action, (Extra, Group))", + "correct": "(Onset, Def/Action), (Extra, Group)", + "explanation": "Moved extra group outside Onset to top level" + } + ], + "correction_patterns": [ + "Combine extra groups into definition content", + "Move unrelated groups outside temporal groups", + "Ensure Onset contains only required elements" + ], + "fix_instructions": [ + "1. Identify extra groups in Onset", + "2. Determine if they belong to the definition or are separate", + "3. Combine into definition content or move to top level", + "4. Verify Onset group structure compliance" + ], + "validation_hints": [ + "Check Onset groups for extra nested groups", + "Ensure proper definition content grouping", + "Verify temporal group simplicity" + ], + "specification_reference": "3.2.8.3. Onset group structure", + "related_errors": ["TAG_GROUP_ERROR", "DEFINITION_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Onset, Def/MyColor, (Red), (Blue))", + "((Def-expand/MyColor, (Label/Pie)), (Green), (Red), Onset)" + ], + "passes": [ + "(Onset, Def/MyColor)", + "((Def-expand/MyColor, (Label/Pie)), (Red), Onset)" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor, (Red), (Blue))", + "ball": "((Def-expand/MyColor, (Label/Pie)), (Green), (Yellow), Onset)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor)", + "ball": "((Def-expand/MyColor, (Label/Pie)), (Green, (Yellow)), Onset)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, Def/MyColor, (Red), (Blue))" + ], + [ + 5.5, + 0, + "((Def-expand/MyColor, (Label/Pie)), (Green), ((Yellow)), Onset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, Def/MyColor)" + ], + [ + 5.0, + 0, + "((Def-expand/MyColor, (Label/Pie)), (Green, (Yellow)), Onset)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "((Def-expand/MyColor, (Label/Pie)), (Green), ((Yellow)), Onset)", + "ball": "(Onset, Def/MyColor, (Red), (Blue))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ], + [ + 6.0, + 0, + "n/a", + "(Def/MyColor, (Red), (Blue), Onset)" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor)", + "ball": "((Def-expand/MyColor, (Label/Pie)), (Green, (Yellow)), Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "n/a", + "((Def-expand/MyColor, (Label/Pie)), (Green, (Yellow)), Onset)" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-offset-has-groups", + "description": "An Offset appears with one or more tags or additional tag groups.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Adding extra content to Offset groups", + "Misunderstanding that Offset should be standalone", + "Including tags that belong outside the Offset group", + "Confusion about Offset group structure" + ], + "explanation": "Offset tags should appear alone in their groups without additional tags or nested groups. Extra content violates temporal structure requirements.", + "correction_strategy": "Remove extra content from Offset groups", + "correction_examples": [ + { + "wrong": "(Offset, Red, Blue)", + "correct": "(Offset)", + "explanation": "Removed extra tags from Offset group" + }, + { + "wrong": "(Offset, (Extra, Group))", + "correct": "(Offset), (Extra, Group)", + "explanation": "Moved extra group outside Offset to top level" + } + ], + "correction_patterns": [ + "Keep Offset groups simple and standalone", + "Move extra content outside Offset groups", + "Ensure Offset appears alone" + ], + "fix_instructions": [ + "1. Identify extra content in Offset groups", + "2. Remove or move extra tags/groups to appropriate locations", + "3. Ensure Offset stands alone in its group", + "4. Verify proper temporal structure" + ], + "validation_hints": [ + "Check Offset groups for extra content", + "Ensure Offset appears without companions", + "Verify proper temporal sequence" + ], + "specification_reference": "3.2.8.3. Offset group structure", + "related_errors": ["TAG_GROUP_ERROR", "TEMPORAL_TAG_ERROR"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor)", + "ball": "((Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Offset, Def/MyColor, (Red))", + "circle": "((Def-expand/MyColor, (Label/Pie)), Offset, Blue)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor)", + "ball": "((Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Offset, Def/MyColor)", + "circle": "((Def-expand/MyColor, (Label/Pie)), Offset)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, Def/MyColor)" + ], + [ + 4.8, + 0, + "(Offset, Def/MyColor, (Red))" + ], + [ + 4.9, + 0, + "(Onset, Def/MyColor, (Red))" + ], + [ + 5.5, + 0, + "((Def-expand/MyColor, (Label/Pie)), (Green), Offset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Onset, Def/MyColor)" + ], + [ + 4.8, + 0, + "(Offset, Def/MyColor)" + ], + [ + 4.9, + 0, + "(Onset, Def/MyColor, (Red))" + ], + [ + 5.5, + 0, + "((Def-expand/MyColor, (Label/Pie)), Offset)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor)", + "ball": "((Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Offset, Def/MyColor, (Red))", + "circle": "((Def-expand/MyColor, (Label/Pie)), Offset, Blue)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "n/a" + ], + [ + 4.8, + 0, + "square", + "n/a" + ], + [ + 4.9, + 0, + "ball", + "Green" + ], + [ + 5.5, + 0, + "((Def-expand/MyColor, (Label/Pie)), Offset, Blue)", + "Orange" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Onset, Def/MyColor)", + "ball": "((Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Offset, Def/MyColor)", + "circle": "((Def-expand/MyColor, (Label/Pie)), Offset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "n/a" + ], + [ + 4.8, + 0, + "square", + "n/a" + ], + [ + 4.9, + 0, + "ball", + "Green" + ], + [ + 5.5, + 0, + "circle", + "Orange" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [], + "name": "temporal-tag-error-offset-with-no-onset", + "description": "An Offset tag associated with a given definition appears after a previous Offset tag without the appearance of an intervening Onset of the same name.", + "warning": false, + "schema": "8.4.0", + "error_category": "temporal_logic", + "common_causes": [ + "Using Offset without corresponding Onset in temporal sequence", + "Missing Onset event that should precede Offset", + "Incorrect temporal event pairing", + "Misunderstanding Onset/Offset relationship requirements" + ], + "explanation": "Offset tags must have corresponding Onset tags to establish proper temporal relationships. An Offset without an Onset creates an incomplete temporal sequence.", + "correction_strategy": "Add corresponding Onset tag or remove orphaned Offset", + "correction_examples": [ + { + "wrong": "(Offset)", + "correct": "(Onset, Def/MyEvent), (Offset)", + "explanation": "Added corresponding Onset to complete temporal pair" + }, + { + "wrong": "Red, (Offset), Blue", + "correct": "(Onset, Def/MyEvent), Red, (Offset), Blue", + "explanation": "Added Onset before the temporal sequence" + } + ], + "correction_patterns": [ + "Add missing Onset before Offset", + "Ensure proper Onset/Offset pairing", + "Verify temporal sequence completeness" + ], + "fix_instructions": [ + "1. Identify orphaned Offset tags", + "2. Add corresponding Onset with appropriate definition", + "3. Ensure proper temporal sequence order", + "4. Verify temporal relationships are complete" + ], + "validation_hints": [ + "Check for Offset tags without preceding Onset", + "Verify temporal event pairing", + "Ensure logical temporal sequence" + ], + "specification_reference": "3.2.8.3. Onset/Offset pairing requirements", + "related_errors": ["TEMPORAL_TAG_ERROR", "TAG_GROUP_ERROR"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/MyColor, Offset)" + ], + [ + 6.5, + 0, + "Red, (Def/MyColor, Offset)" + ], + [ + 5.5, + 0, + "(Def/MyColor, Offset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/MyColor, Onset)" + ], + [ + 5.5, + 0, + "(Def/MyColor, Offset)" + ], + [ + 6.5, + 0, + "Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Onset)", + "ball": "(Def/MyColor, Offset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "Red, Blue" + ], + [ + 4.8, + 0, + "ball", + "Red, Blue" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Onset)", + "ball": "(Def/MyColor, Offset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-extra tags", + "description": "An Onset tag group with has tags besides the anchor Def or Def-expand that are not in a tag group.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Adding loose tags to temporal groups without proper grouping", + "Misunderstanding temporal group content structure", + "Incorrectly placing tags alongside definitions", + "Confusion about what content belongs in temporal groups" + ], + "explanation": "Temporal groups should contain only the temporal tag and its definition group. Extra tags must be properly grouped within the definition content.", + "correction_strategy": "Group extra tags properly within definition content", + "correction_examples": [ + { + "wrong": "(Def/MyColor, Blue, Green, Onset)", + "correct": "(Onset, (Def/MyColor, (Blue, Green)))", + "explanation": "Grouped extra tags within definition content and reordered properly" + }, + { + "wrong": "(Onset, Def/Action, Red, Blue)", + "correct": "(Onset, (Def/Action, (Red, Blue)))", + "explanation": "Grouped loose tags within definition content" + } + ], + "correction_patterns": [ + "Group extra tags within definition content", + "Ensure proper temporal tag ordering", + "Remove loose tags from temporal groups" + ], + "fix_instructions": [ + "1. Identify loose tags in temporal groups", + "2. Group them within the definition content", + "3. Ensure proper temporal tag structure", + "4. Verify temporal group compliance" + ], + "validation_hints": [ + "Check for ungrouped tags in temporal groups", + "Ensure definition content is properly grouped", + "Verify temporal tag order and structure" + ], + "specification_reference": "3.2.8.3. Temporal group content structure", + "related_errors": ["TAG_GROUP_ERROR", "DEFINITION_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Def/MyColor, Blue, Green, Onset)" + ], + "passes": [ + "(Def/MyColor, (Blue), Onset)" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Def/MyColor, Blue, Green, Onset)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Def/MyColor, (Blue), Onset)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/MyColor, Blue, (Green), Onset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/MyColor, (Blue), Onset)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Blue, Green, Onset)", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "((Blue, Green), Def/MyColor, Onset)", + "ball": "(Def/Acc/7, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [], + "name": "temporal-tag-error-duplicated-onset-or-offset", + "description": "An Onset or an Offset with a given Def or Def-expand anchor appears in the same event marker with another Onset or Offset that uses the same anchor.", + "warning": false, + "schema": "8.4.0", + "error_category": "temporal_logic", + "common_causes": [ + "Duplicate Onset or Offset tags for the same definition", + "Multiple temporal markers for the same event", + "Copy-paste errors creating duplicate temporal tags", + "Misunderstanding that each definition should have unique temporal markers" + ], + "explanation": "Each definition should have at most one Onset and one Offset per event. Duplicate temporal tags for the same definition create ambiguous temporal sequences.", + "correction_strategy": "Remove duplicate temporal tags or use different definitions", + "correction_examples": [ + { + "wrong": "(Onset, Def/Event), (Onset, Def/Event)", + "correct": "(Onset, Def/Event)", + "explanation": "Removed duplicate Onset for same definition" + }, + { + "wrong": "(Offset, Def/Action), (Offset, Def/Action)", + "correct": "(Offset, Def/Action)", + "explanation": "Kept only one Offset for the definition" + } + ], + "correction_patterns": [ + "Remove duplicate temporal tags for same definition", + "Use different definitions for multiple temporal events", + "Ensure unique temporal markers per definition" + ], + "fix_instructions": [ + "1. Identify duplicate temporal tags with same definition", + "2. Remove extra temporal tags", + "3. Consider using different definitions if multiple events needed", + "4. Verify temporal sequence uniqueness" + ], + "validation_hints": [ + "Check for repeated Onset/Offset with same Def", + "Ensure temporal uniqueness per definition", + "Verify proper event separation" + ], + "specification_reference": "3.2.8.3. Temporal tag uniqueness", + "related_errors": ["TEMPORAL_TAG_ERROR", "DEFINITION_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, (Green), Onset)", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Def/MyColor, (Blue), Onset)" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, (Green), Onset)", + "ball": "(Def/MyColor, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Def/MyColor, Offset)" + ], + [ + 5.0, + 0, + "ball", + "(Def/MyColor, Offset)" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, (Green), Onset)", + "ball": "(Def/MyColor, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Def/MyColor, Offset)" + ], + [ + 5.0, + 0, + "ball", + "(Def/MyColor, Offset)" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "((Blue, Green), Def/MyColor, Onset)", + "ball": "(Def/MyColor, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [], + "name": "temporal-tag-error-inset-outside-its-event", + "description": "An Inset tag is not grouped with a Def or Def-expand of an ongoing Onset.", + "warning": false, + "schema": "8.4.0", + "error_category": "temporal_logic", + "common_causes": [ + "Inset tag appearing without corresponding Onset event", + "Inset referencing different definition than its Onset", + "Temporal sequence violation with Inset placement", + "Misunderstanding Inset relationship to Onset events" + ], + "explanation": "Inset tags must occur within the temporal window of an ongoing Onset event and must reference the same definition as that Onset.", + "correction_strategy": "Ensure Inset appears within corresponding Onset temporal window", + "correction_examples": [ + { + "wrong": "(Inset, Def/Event), (Onset, Def/Action)", + "correct": "(Onset, Def/Event), (Inset, Def/Event)", + "explanation": "Made Inset reference same definition as preceding Onset" + }, + { + "wrong": "(Offset, Def/Event), (Inset, Def/Event)", + "correct": "(Onset, Def/Event), (Inset, Def/Event), (Offset, Def/Event)", + "explanation": "Added missing Onset before Inset" + } + ], + "correction_patterns": [ + "Ensure Inset follows corresponding Onset", + "Match Inset definition with Onset definition", + "Verify temporal sequence order" + ], + "fix_instructions": [ + "1. Identify Inset tags and their definitions", + "2. Find corresponding Onset with same definition", + "3. Ensure Inset appears after Onset but before Offset", + "4. Verify proper temporal window relationship" + ], + "validation_hints": [ + "Check Inset appears within Onset temporal window", + "Verify Inset and Onset use same definition", + "Ensure proper temporal sequence order" + ], + "specification_reference": "3.2.8.3. Inset temporal relationships", + "related_errors": ["TEMPORAL_TAG_ERROR", "DEFINITION_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Inset, (Red))" + ], + [ + 6.5, + 0, + "Red, (Def/MyColor, Offset)" + ], + [ + 5.5, + 0, + "(Def/MyColor, Offset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/MyColor, Onset)" + ], + [ + 5.5, + 0, + "(Def/MyColor, Offset)" + ], + [ + 6.5, + 0, + "Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Onset)", + "ball": "(Def/MyColor, Offset)", + "snack": "(Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "snack", + "Red, Blue" + ], + [ + 4.8, + 0, + "face", + "Red, Blue" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Onset)", + "ball": "(Def/MyColor, Offset)", + "snack": "(Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 4.8, + 0, + "snack", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-inset-group-has-extras", + "description": "An Inset group has tags or groups in addition to its defining Def or Def-expand.", + "warning": false, + "schema": "8.4.0", + "error_category": "temporal", + "common_causes": [ + "Extra content tags added to Inset groups", + "Misunderstanding that Inset should be minimal", + "Incorrect grouping of content with Inset", + "Over-specification of Inset temporal boundaries", + "Adding unnecessary tags to Inset structure" + ], + "explanation": "Inset tags should only include their defining Def or Def-expand tag. Additional content violates the minimal boundary specification for Insets.", + "correction_strategy": "Remove extra content from Inset groups", + "correction_examples": [ + { + "wrong": "(Def/MyColor, Blue, Inset)", + "correct": "(Def/MyColor, Inset)", + "explanation": "Removed extra content tag from Inset group" + }, + { + "wrong": "(Def/MyColor, (Blue), Inset)", + "correct": "(Def/MyColor, Inset)", + "explanation": "Eliminated additional grouped content" + } + ], + "correction_patterns": [ + "Keep only definition with Inset tag", + "Remove all additional content from Inset groups", + "Maintain minimal Inset boundary specification", + "Follow temporal minimalism requirements" + ], + "fix_instructions": [ + "1. Identify Inset groups with extra content", + "2. Remove all tags except definition and Inset", + "3. Ensure minimal Inset structure", + "4. Verify temporal boundary requirements", + "5. Check Inset group minimalism rules" + ], + "validation_hints": [ + "Inset should only have definition plus Inset tag", + "Remove any additional content from Inset groups", + "Check minimal temporal boundary rules", + "Verify Inset group simplicity" + ], + "specification_reference": "3.2.8.3. Inset minimal boundary requirements", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "TAG_GROUP_ERROR", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 2.5, + 0, + "Red, (Def/MyColor, Onset)" + ], + [ + 4.5, + 0, + "(Def/MyColor, Blue, Inset)" + ], + [ + 6.5, + 0, + "Red, (Def/MyColor, Onset)" + ], + [ + 5.5, + 0, + "(Def/MyColor, Offset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Def/MyColor, (Blue), Onset)" + ], + [ + 4.8, + 0, + "(Def/MyColor, (Green), Inset)" + ], + [ + 5.5, + 0, + "(Def/MyColor, Offset)" + ], + [ + 6.5, + 0, + "Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Onset)", + "ball": "(Def/MyColor, Offset)", + "snack": "(Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "snack", + "Red, Blue" + ], + [ + 4.8, + 0, + "face", + "Red, Blue" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Onset)", + "ball": "(Def/MyColor, Offset)", + "snack": "(Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 4.7, + 0, + "face", + "Blue" + ], + [ + 4.8, + 0, + "snack", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-duration-group", + "description": "A Duration or Delay has extra tags or groups.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Adding extra content to Duration or Delay groups", + "Misunderstanding that Duration/Delay should be standalone", + "Including descriptive content that belongs elsewhere", + "Confusion about temporal tag group structure" + ], + "explanation": "Duration and Delay tags should appear alone in their groups with only their time values. Extra content violates temporal structure requirements.", + "correction_strategy": "Remove extra content from Duration/Delay groups", + "correction_examples": [ + { + "wrong": "(Duration/3.0 s, (Green), (Blue))", + "correct": "(Duration/3.0 s), (Green), (Blue)", + "explanation": "Moved extra content outside Duration group" + }, + { + "wrong": "(Delay/2.0 s, Red, Blue)", + "correct": "(Delay/2.0 s), Red, Blue", + "explanation": "Separated Delay from descriptive content" + } + ], + "correction_patterns": [ + "Keep Duration/Delay groups simple and standalone", + "Move extra content outside temporal groups", + "Ensure temporal tags contain only time values" + ], + "fix_instructions": [ + "1. Identify extra content in Duration/Delay groups", + "2. Move extra tags/groups to appropriate locations", + "3. Ensure Duration/Delay stand alone with time values only", + "4. Verify proper temporal structure" + ], + "validation_hints": [ + "Check Duration/Delay groups for extra content", + "Ensure temporal tags appear with time values only", + "Verify proper separation of temporal and descriptive content" + ], + "specification_reference": "3.2.8.3. Duration and Delay group structure", + "related_errors": ["TAG_GROUP_ERROR", "TEMPORAL_TAG_ERROR"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Duration/3.0 s, Delay/2.0 s, (Green), (Blue))", + "(Duration/3.0 s, (Green), (Blue))", + "(Delay/3.0 s, (Green), (Blue))" + ], + "passes": [ + "(Duration/3.0 s, Delay/2.0 s, (Blue))", + "(Duration/3.0 s, (Blue))", + "(Delay/3.0 s, (Blue))" + ] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 5.0, + 0, + "(Duration/3.0 s, Delay/2.0 s)" + ], + [ + 5.5, + 0, + "(Duration/3.0 s, Delay/2.0 s, Event)" + ], + [ + 6.0, + 0, + "(Duration/3.0 s, Delay/2.0 s, (Green), (Blue))" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "((Blue), Duration/3.0 s)" + ], + [ + 4.8, + 0, + "((Green), Delay/2.0 s)" + ], + [ + 5.0, + 0, + "((Green), Duration/3.0 s, Delay/2.0 s)" + ] + ] + ] + }, + "combo_tests": { + "fails": [], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Duration/3.0 s, (Event))", + "ball": "(Delay/3.0 s, (Event))", + "snack": "(Duration/3.0 s, Delay/2.0 s, (Event))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 4.7, + 0, + "face", + "Blue" + ], + [ + 4.8, + 0, + "snack", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-tag-appears-where-not-allowed", + "description": "A temporal tag appears appears in a tsv with no onset column", + "warning": false, + "schema": "8.4.0", + "error_category": "context", + "common_causes": [ + "Temporal tags used in inappropriate file formats", + "Missing onset column for temporal tag usage", + "Temporal tags in non-temporal contexts", + "Misunderstanding temporal tag file requirements", + "Incorrect file format for temporal annotations" + ], + "explanation": "Temporal tags (Onset, Offset, Inset) require proper temporal context with onset timing information. They cannot be used in files without temporal structure.", + "correction_strategy": "Use temporal tags only in appropriate temporal contexts", + "correction_examples": [ + { + "wrong": "Using Onset, Def/MyColor in non-temporal file", + "correct": "Use in file with onset column or remove temporal tags", + "explanation": "Temporal tags require temporal file structure" + }, + { + "wrong": "Def/MyColor, Inset without onset timing", + "correct": "Remove temporal tags or add proper temporal structure", + "explanation": "Eliminated temporal tags from inappropriate context" + } + ], + "correction_patterns": [ + "Remove temporal tags from non-temporal files", + "Add proper temporal structure (onset column)", + "Use appropriate file format for temporal annotations", + "Verify temporal context requirements" + ], + "fix_instructions": [ + "1. Check if file format supports temporal tags", + "2. Add onset column if temporal tags needed", + "3. Remove temporal tags if inappropriate context", + "4. Verify file structure requirements", + "5. Use correct format for temporal annotations" + ], + "validation_hints": [ + "Temporal tags need onset timing context", + "Check file format temporal support", + "Verify proper temporal structure", + "Remove temporal tags from inappropriate files" + ], + "specification_reference": "3.2.8.3. Temporal tag context requirements", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "SIDECAR_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "duration", + "HED" + ], + [ + 0, + "(Duration/5 s, (Red))" + ], + [ + 0, + "Red, (Def/MyColor, Onset)" + ], + [ + 0, + "(Def/MyColor, Yellow, Inset)" + ], + [ + 0, + "Red, (Def/MyColor, Onset)" + ], + [ + 0, + "(Def/MyColor, Offset)" + ] + ] + ], + "passes": [ + [ + [ + "duration", + "HED" + ], + [ + 0, + "(Def/MyColor, (Blue))" + ], + [ + 0, + "(Def/MyColor, (Green))" + ], + [ + 0, + "(Def/MyColor)" + ], + [ + 0, + "Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Onset)", + "ball": "(Def/MyColor, Offset)", + "snack": "(Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "event_code", + "HED" + ], + [ + "n/a", + "(Duration/5.0, (Red))" + ], + [ + "face", + "Def/MyColor, Red, Blue" + ], + [ + "ball", + "Def/MyColor, Red, Blue" + ], + [ + "snack", + "Green" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Duration/5.0, (Red))", + "ball": "(Delay/4.0, (Green))" + } + } + }, + "events": [ + [ + "event_code", + "HED" + ], + [ + "face", + "Def/MyColor, Red, Blue" + ], + [ + "ball", + "Def/MyColor, Red, Blue" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor)", + "ball": "(Def/MyColor)", + "snack": "(Def/MyColor)" + } + } + }, + "events": [ + [ + "event_code", + "HED" + ], + [ + "face", + "Blue" + ], + [ + "face", + "Blue" + ], + [ + "snack", + "Blue" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "na-in-onset column", + "description": "n/a is in the onset column.", + "warning": false, + "schema": "8.4.0", + "error_category": "data_format", + "common_causes": [ + "Using n/a in onset column where temporal value expected", + "Missing onset time data marked as n/a", + "Incorrect data formatting in temporal columns", + "Confusion about required vs optional temporal data" + ], + "explanation": "Onset columns should contain valid temporal values or be empty. Using 'n/a' in onset columns creates temporal sequence errors.", + "correction_strategy": "Replace n/a with valid onset time or leave empty", + "correction_examples": [ + { + "wrong": "onset: n/a", + "correct": "onset: 4.5", + "explanation": "Provided actual onset time value" + }, + { + "wrong": "onset: n/a", + "correct": "onset: (empty)", + "explanation": "Left onset empty if no temporal relationship" + } + ], + "correction_patterns": [ + "Provide actual onset times when temporal relationship exists", + "Leave onset empty rather than using n/a", + "Ensure temporal data consistency" + ], + "fix_instructions": [ + "1. Identify n/a values in onset columns", + "2. Determine if onset time is available", + "3. Replace with actual time or leave empty", + "4. Verify temporal sequence consistency" + ], + "validation_hints": [ + "Check onset columns for n/a values", + "Ensure temporal data is properly formatted", + "Verify onset times align with event structure" + ], + "specification_reference": "3.4. Temporal data formatting requirements", + "related_errors": ["TEMPORAL_TAG_ERROR", "SIDECAR_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "Black, White" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 5.0, + 0, + "face", + "Def/MyColor, Red, Blue" + ], + [ + "n/a", + 0, + "ball", + "(Onset, Def/MyColor, (Red))" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "Orange", + "ball": "(Delay/4.0, (Green))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 5.0, + 0, + "face", + "Def/MyColor, Red, Blue" + ], + [ + "n/a", + 0, + "ball", + "Item" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "(Black, White)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 5.0, + "face", + "Red, Blue" + ], + [ + "n/a", + 0, + "ball", + "(Duration/5.0, (Red))" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5", + "ball": "(Black, White)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 5.0, + 0, + "face", + "Red, Blue" + ], + [ + "n/a", + 0, + "ball", + "(Duration/5.0, (Red))" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/TEMPORAL_TAG_ERROR_DELAY.json b/spec_tests/hed-tests/json_test_data/validation_tests/TEMPORAL_TAG_ERROR_DELAY.json new file mode 100644 index 000000000..6da1c5923 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/TEMPORAL_TAG_ERROR_DELAY.json @@ -0,0 +1,2321 @@ +[ + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-not-tag-group-delay", + "description": "A Delay is not in the tag group.", + "warning": false, + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Delay tag not in required tag group structure", + "Missing inner group for Delay content", + "Incorrect companions with Delay tag", + "Misunderstanding Delay tag requirements", + "Improper temporal tag grouping" + ], + "explanation": "Delay tags must appear in specific tag group structures with required inner groups containing the delayed content. They specify temporal relationships and must follow strict formatting rules.", + "correction_strategy": "Ensure Delay tags follow required group structure", + "correction_examples": [ + { + "wrong": "(Delay/5, Red)", + "correct": "(Delay/5 s, (Red))", + "explanation": "Added proper units and inner group structure" + }, + { + "wrong": "(Delay/5, Def/Acc/5.4)", + "correct": "(Delay/5 s, (Def/Acc/5.4))", + "explanation": "Added units and proper inner group for definition" + } + ], + "correction_patterns": [ + "Enclose Delay content in inner parentheses", + "Add proper time units to Delay values", + "Ensure Delay appears in top-level groups", + "Group delayed content in required inner structure", + "Follow temporal tag group requirements" + ], + "fix_instructions": [ + "1. Identify Delay tags requiring proper grouping", + "2. Add time units if missing from Delay values", + "3. Enclose delayed content in inner parentheses", + "4. Verify top-level group structure", + "5. Check temporal tag combination rules" + ], + "validation_hints": [ + "Delay values need time units", + "Delayed content must be in inner groups", + "Check proper temporal tag grouping", + "Verify Duration/Delay combination rules" + ], + "specification_reference": "3.2.8.3. Onset, Offset, and Inset", + "related_errors": [ + "TAG_GROUP_ERROR", + "TEMPORAL_TAG_ERROR", + "UNITS_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Delay/5, Red)", + "(Delay/5, Def/Acc/5.4)", + "(Delay/5, (Def-expand/Acc/5.4, (Acceleration/5.4 m-per-s^2, Red)))" + ], + "passes": [ + "(Delay/5 s, (Def/Acc/5.4))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Blue, Red", + "ball": "(Delay/5.0 s, Def/Acc/5.4)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, (Def/Acc/5.4))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 5.0, + 0, + "Delay/1.0 s, Red" + ] + ], + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Delay/1.0 s, (Red)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, (Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Red", + "ball": "Delay/5.0 s, Def/Acc/5.4" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "Red" + ], + [ + 4.8, + 0, + "n/a", + "Blue" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, (Def/Acc/5.4))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 8.5, + 0, + "face", + "Blue" + ], + [ + 9.0, + 0, + "n/a", + "Green, (Delay/5.0 s, (Def/MyColor))" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-nested-group-delay", + "description": "A delay appears in a group not in the top level.", + "schema": "8.4.0", + "error_category": "structure", + "common_causes": [ + "Delay tags incorrectly nested within other groups", + "Double parentheses around delay temporal groups", + "Misunderstanding that delay tags must be at top level", + "Incorrectly grouping delay content" + ], + "explanation": "Delay tags must appear at the top level of tag groups, not nested within other groups. This ensures proper temporal relationship parsing in delayed contexts.", + "correction_strategy": "Move delay tags to top-level groups", + "correction_examples": [ + { + "wrong": "((Delay/5.0 s, Delay/7.0 s, (Def/MyColor)), Red)", + "correct": "(Delay/5.0 s, Delay/7.0 s, Def/MyColor), Red", + "explanation": "Removed extra parentheses to make Delay top-level" + }, + { + "wrong": "Red, ((Delay/3.0 s, Def/Response))", + "correct": "Red, (Delay/3.0 s, Def/Response)", + "explanation": "Moved Delay to proper top-level group" + } + ], + "correction_patterns": [ + "Remove extra nesting parentheses around delay tags", + "Ensure delay tags are direct children of top-level groups", + "Separate delay groups from content groups" + ], + "fix_instructions": [ + "1. Identify nested delay tags", + "2. Remove extra parentheses layers", + "3. Ensure delay tags are at top level", + "4. Verify proper group structure" + ], + "validation_hints": [ + "Check for double parentheses around delay tags", + "Ensure delay tags are not inside content groups", + "Verify proper separation of delay and content elements" + ], + "specification_reference": "3.2.8.3. Delay tag group structure", + "related_errors": ["TAG_GROUP_ERROR", "PARENTHESES_MISMATCH"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "((Delay/5.0 s, Delay/7.0 s, (Def/MyColor)), Red)" + ], + "passes": [ + "(Onset, Delay/6 s, Def/MyColor), Red" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "((Delay/5.0 s, Onset, Def/MyColor), Red)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor), Red" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "((Delay/5.0 s, Onset, Def/MyColor), Red)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Onset, Def/MyColor), Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "((Delay/5.0 s, Onset, Def/MyColor), Red)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "n/a", + "((Delay/5.0 s, Onset, Def/MyColor), Red)" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor), Red" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "n/a", + "(Delay/5.0 s, Onset, Def/MyColor), Red" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-wrong-number-of-defs-delay", + "description": "An Onset or Offset tag is not grouped with exactly one Def-expand tag group or a Def tag.", + "schema": "8.4.0", + "error_category": "temporal", + "common_causes": [ + "Onset/Offset tag missing required definition association", + "Multiple definitions paired with single Onset/Offset", + "Temporal tags without proper definition context", + "Misunderstanding of Onset/Offset definition requirements", + "Incorrect delayed temporal tag structuring" + ], + "explanation": "Onset and Offset tags in delayed contexts must be paired with exactly one definition (Def or Def-expand) to establish proper temporal relationships and event boundaries.", + "correction_strategy": "Ensure each Onset/Offset has exactly one definition", + "correction_examples": [ + { + "wrong": "(Delay/5.0 s, Onset, (Red))", + "correct": "(Delay/5.0 s, Onset, Def/MyColor, (Red))", + "explanation": "Added required definition for Onset tag" + }, + { + "wrong": "(Delay/5.0 s, Onset, Def/MyColor, Def/Acc/4.3)", + "correct": "(Delay/5.0 s, Onset, Def/MyColor, (Red))", + "explanation": "Removed extra definition to have exactly one" + } + ], + "correction_patterns": [ + "Add single definition (Def/Name) to Onset/Offset tags", + "Remove multiple definitions to have exactly one", + "Use Def-expand for complex definition structures", + "Ensure definition matches temporal tag context" + ], + "fix_instructions": [ + "1. Identify Onset/Offset tags without definitions", + "2. Add appropriate Def/Name tag to temporal group", + "3. Remove extra definitions if multiple exist", + "4. Verify temporal-definition pairing rules", + "5. Check delayed context requirements" + ], + "validation_hints": [ + "Each Onset/Offset needs exactly one definition", + "Use Def/Name or Def-expand for definitions", + "Check temporal tag definition requirements", + "Verify delayed context structure" + ], + "specification_reference": "3.2.8.3. Onset, Offset temporal requirements", + "related_errors": [ + "TAG_GROUP_ERROR", + "DEFINITION_INVALID", + "DEF_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Delay/5.0 s, Onset, (Red))" + ], + "passes": [ + "(Delay/5.0 s, Onset, Def/MyColor, (Red))", + "(Delay/5.0 s, Onset, (Def-expand/MyColor, (Label/Pie)), (Red))" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, (Red))", + "ball": "(Delay/5.0 s, Onset, Def/MyColor, Def/Acc/4.3)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor, (Red))" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Onset, (Red))" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, Onset, Def/MyColor, Def/Acc/4.3)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Onset, Def/MyColor, (Red))" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, (Red))", + "ball": "(Delay/5.0 s, Onset, Def/MyColor, Def/Acc/4.3)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Green, Def/MyColor" + ], + [ + 5.0, + 0, + "n/a", + "(Delay/5.0 s, Onset, (Yellow))" + ], + [ + 6.0, + 0, + "ball", + "n/a" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor, (Red))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "n/a", + "(Delay/5.0 s, Onset, Def/MyColor, (Blue))" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-onset-has-more-groups-delay", + "description": "An Onset group has more than one additional tag group.", + "schema": "8.4.0", + "error_category": "temporal", + "common_causes": [ + "Multiple tag groups associated with single Onset", + "Misunderstanding Onset group cardinality rules", + "Incorrect grouping of delayed onset content", + "Over-specification of onset temporal relationships", + "Improper delayed temporal structure" + ], + "explanation": "Onset tags in delayed contexts can have at most one additional tag group beyond the required definition. Multiple groups violate temporal tag cardinality constraints.", + "correction_strategy": "Limit Onset to single additional tag group", + "correction_examples": [ + { + "wrong": "(Delay/5.0 s, Onset, Def/MyColor, (Red), (Blue))", + "correct": "(Delay/5.0 s, Onset, Def/MyColor, (Red, Blue))", + "explanation": "Combined multiple groups into single group" + }, + { + "wrong": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green), (Red), Onset)", + "correct": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green), Onset)", + "explanation": "Removed extra group to meet cardinality limit" + } + ], + "correction_patterns": [ + "Combine multiple groups into single group", + "Remove excessive tag groups from Onset", + "Consolidate related tags within single parentheses", + "Ensure Onset has definition plus at most one group" + ], + "fix_instructions": [ + "1. Identify Onset tags with multiple additional groups", + "2. Combine related groups into single structure", + "3. Remove unnecessary group separations", + "4. Verify Onset cardinality requirements", + "5. Check delayed context group limits" + ], + "validation_hints": [ + "Onset can have definition plus at most one group", + "Combine multiple groups when possible", + "Check temporal tag cardinality rules", + "Verify delayed Onset structure limits" + ], + "specification_reference": "3.2.8.3. Onset group cardinality rules", + "related_errors": [ + "TAG_GROUP_ERROR", + "PARENTHESES_MISMATCH", + "TEMPORAL_TAG_ERROR" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Delay/5.0 s, Onset, Def/MyColor, (Red), (Blue))", + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green), (Red), Onset)" + ], + "passes": [ + "(Delay/5.0 s, Onset, Def/MyColor)", + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Red), Onset)" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor, (Red), (Blue))" + } + } + }, + { + "event_code": { + "HED": { + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green), (Yellow), Onset)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor)", + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green, (Yellow)), Onset)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Onset, Def/MyColor, (Red), (Blue))" + ] + ], + [ + [ + "onset", + "duration", + "HED" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green), ((Yellow)), Onset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Onset, Def/MyColor)" + ], + [ + 5.0, + 0, + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green, (Yellow)), Onset)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green), ((Yellow)), Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "ball": "(Delay/5.0 s, Onset, Def/MyColor, (Red), (Blue))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "ball": "(Delay/5.0 s, Onset, Def/MyColor, (Blue))" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 6.0, + 0, + "n/a", + "(Delay/5.0 s, Def/MyColor, (Red), (Blue), Onset)" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor)", + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green, (Yellow)), Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "n/a", + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green, (Yellow)), Onset)" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-offset-has-groups-delay", + "description": "An Offset appears with one or more tags or additional tag groups.", + "schema": "8.4.0", + "error_category": "temporal", + "common_causes": [ + "Offset tag paired with additional content", + "Misunderstanding that Offset should be standalone", + "Adding unnecessary tags to Offset groups", + "Incorrect delayed offset temporal structure", + "Over-specification of offset boundaries" + ], + "explanation": "Offset tags in delayed contexts should only appear with their required definition and no additional tag groups or content, as they mark clean temporal boundaries.", + "correction_strategy": "Remove additional content from Offset groups", + "correction_examples": [ + { + "wrong": "(Delay/5.0 s, Offset, Def/MyColor, (Red))", + "correct": "(Delay/5.0 s, Offset, Def/MyColor)", + "explanation": "Removed additional content group from Offset" + }, + { + "wrong": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset, Blue)", + "correct": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset)", + "explanation": "Removed extra tag from Offset structure" + } + ], + "correction_patterns": [ + "Remove additional tags from Offset groups", + "Keep only definition with Offset tag", + "Eliminate extra content from offset boundaries", + "Ensure clean Offset temporal structure" + ], + "fix_instructions": [ + "1. Identify Offset tags with additional content", + "2. Remove extra tags or groups from Offset", + "3. Keep only required definition with Offset", + "4. Verify clean offset boundary structure", + "5. Check delayed context Offset requirements" + ], + "validation_hints": [ + "Offset should only have its definition", + "Remove additional content from Offset groups", + "Check clean temporal boundary requirements", + "Verify delayed Offset structure rules" + ], + "specification_reference": "3.2.8.3. Offset boundary requirements", + "related_errors": [ + "TAG_GROUP_ERROR", + "TEMPORAL_TAG_ERROR", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor)", + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Delay/5.0 s, Offset, Def/MyColor, (Red))" + } + } + }, + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor)", + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Onset)", + "circle": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset, Blue)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor)", + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Delay/5.0 s, Offset, Def/MyColor)", + "circle": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Onset, Def/MyColor)" + ], + [ + 4.8, + 0, + "(Delay/5.0 s, Offset, Def/MyColor, (Red))" + ], + [ + 4.9, + 0, + "(Delay/5.0 s, Onset, Def/MyColor, (Red))" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), (Green), Offset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Onset, Def/MyColor)" + ], + [ + 4.8, + 0, + "(Delay/5.0 s, Offset, Def/MyColor)" + ], + [ + 4.9, + 0, + "(Delay/5.0 s, Onset, Def/MyColor, (Red))" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor)", + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Delay/5.0 s, Offset, Def/MyColor)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "n/a" + ], + [ + 4.8, + 0, + "square", + "n/a" + ], + [ + 4.9, + 0, + "ball", + "Green" + ], + [ + 5.5, + 0, + "n/a", + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset, Blue), Orange" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor)", + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Delay/5.0 s, Offset, Def/MyColor, (Red))", + "circle": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset, Blue)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "n/a" + ], + [ + 4.8, + 0, + "square", + "n/a" + ], + [ + 4.9, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Onset, Def/MyColor)", + "ball": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Onset)", + "square": "(Delay/5.0 s, Offset, Def/MyColor)", + "circle": "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "n/a" + ], + [ + 4.8, + 0, + "square", + "n/a" + ], + [ + 4.9, + 0, + "ball", + "Green" + ], + [ + 10.0, + 0, + "n/a", + "(Delay/5.0 s, (Def-expand/MyColor, (Label/Pie)), Offset)" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-mismatch-delay", + "description": "An Offset tag associated with a given definition appears after a previous Offset tag without the appearance of an intervening Onset of the same name.", + "schema": "8.3.0", + "error_category": "temporal_logic", + "common_causes": [ + "Multiple Offset tags without intervening Onset in delayed context", + "Incorrect temporal sequence order with delays", + "Missing Onset between consecutive Offsets with delays", + "Confusion about temporal pairing requirements with delays" + ], + "explanation": "In delayed temporal contexts, Offset tags must still follow proper pairing with Onset tags. Multiple Offsets without intervening Onsets create invalid temporal sequences.", + "correction_strategy": "Add missing Onset tags or remove extra Offset tags in delayed contexts", + "correction_examples": [ + { + "wrong": "(Delay/2.0 s, Offset), (Delay/3.0 s, Offset)", + "correct": "(Delay/2.0 s, Offset), (Delay/3.0 s, Onset), (Delay/4.0 s, Offset)", + "explanation": "Added missing Onset between Offsets in delayed sequence" + }, + { + "wrong": "(Offset, Def/Event), (Delay/1.0 s, Offset, Def/Event)", + "correct": "(Onset, Def/Event), (Offset, Def/Event), (Delay/1.0 s, Onset, Def/Event), (Delay/2.0 s, Offset, Def/Event)", + "explanation": "Established proper Onset/Offset pairing in delayed temporal sequence" + } + ], + "correction_patterns": [ + "Ensure proper Onset/Offset pairing in delayed contexts", + "Add missing Onset tags between consecutive Offsets", + "Verify temporal sequence logic with delays" + ], + "fix_instructions": [ + "1. Identify consecutive Offset tags in delayed sequences", + "2. Add appropriate Onset tags between Offsets", + "3. Ensure proper temporal pairing with delay timing", + "4. Verify logical temporal flow with delays" + ], + "validation_hints": [ + "Check for Offset/Offset patterns in delayed contexts", + "Verify proper Onset/Offset alternation with delays", + "Ensure temporal logic consistency" + ], + "specification_reference": "3.2.8.3. Delayed temporal tag pairing", + "related_errors": ["TEMPORAL_TAG_ERROR", "TEMPORAL_TAG_ERROR_DELAY"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Def/MyColor, Offset)" + ], + [ + 6.5, + 0, + "Red, (Delay/5.0 s, Def/MyColor, Offset)" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, Def/MyColor, Offset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Def/MyColor, Offset)" + ], + [ + 5.5, + 0, + "(Def/MyColor, Onset)" + ], + [ + 6.5, + 0, + "Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Offset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "Red, Blue" + ], + [ + 4.8, + 0, + "ball", + "Red, Blue" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Offset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "Blue" + ], + [ + 5.0, + 0, + "face", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-extra tags-delay", + "description": "An Onset tag group with has tags besides the anchor Def or Def-expand that are not in a tag group.", + "schema": "8.3.0", + "error_category": "temporal", + "common_causes": [ + "Loose tags outside group structure in delayed Onset", + "Ungrouped content tags mixed with Onset definition", + "Missing parentheses around Onset content tags", + "Misunderstanding delayed Onset group requirements", + "Improper temporal tag group structure" + ], + "explanation": "Onset tags in delayed contexts must have all content tags (beyond the definition) properly grouped in parentheses. Loose tags violate temporal group structure requirements.", + "correction_strategy": "Group all non-definition content in parentheses", + "correction_examples": [ + { + "wrong": "(Delay/5.0 s, Def/MyColor, Blue, Green, Onset)", + "correct": "(Delay/5.0 s, Def/MyColor, (Blue, Green), Onset)", + "explanation": "Grouped loose content tags in parentheses" + }, + { + "wrong": "(Delay/5.0 s, Def/MyColor, Blue, (Green), Onset)", + "correct": "(Delay/5.0 s, Def/MyColor, (Blue, Green), Onset)", + "explanation": "Combined all content into single group" + } + ], + "correction_patterns": [ + "Wrap all non-definition content in parentheses", + "Combine loose tags into single content group", + "Maintain definition plus grouped content structure", + "Follow delayed temporal group requirements" + ], + "fix_instructions": [ + "1. Identify loose tags in delayed Onset groups", + "2. Wrap all content tags in parentheses", + "3. Keep definition outside content grouping", + "4. Verify proper delayed temporal structure", + "5. Check group organization requirements" + ], + "validation_hints": [ + "All Onset content beyond definition must be grouped", + "Look for loose tags outside parentheses", + "Check delayed temporal group structure", + "Verify proper Onset organization" + ], + "specification_reference": "3.2.8.3. Delayed Onset group structure", + "related_errors": [ + "TAG_GROUP_ERROR", + "PARENTHESES_MISMATCH", + "TEMPORAL_TAG_ERROR" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "(Delay/5.0 s, Def/MyColor, Blue, Green, Onset)" + ], + "passes": [ + "(Delay/5.0 s, Def/MyColor, (Blue), Onset)" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, Blue, Green, Onset)" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, (Blue), Onset)" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Def/MyColor, Blue, (Green), Onset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Def/MyColor, (Blue), Onset)" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, Blue, Green, Onset)", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, (Blue, Green), Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/Acc/7, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "ball", + "Blue" + ], + [ + 5.0, + 0, + "face", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-duplicated-onset-or-offset-delay", + "description": "An Onset or an Offset with a given Def or Def-expand anchor appears in the same event marker with another Onset or Offset that uses the same anchor.", + "schema": "8.3.0", + "error_category": "temporal_logic", + "common_causes": [ + "Multiple Onset/Offset tags with same definition in single event", + "Duplicate delayed temporal boundaries for same definition", + "Misunderstanding temporal tag uniqueness requirements", + "Incorrect event-level temporal tag organization", + "Over-specification of delayed temporal relationships" + ], + "explanation": "Each definition can have at most one Onset or Offset tag per event in delayed contexts. Multiple temporal tags with the same anchor create ambiguous temporal boundaries.", + "correction_strategy": "Remove duplicate temporal tags with same definition", + "correction_examples": [ + { + "wrong": "(Delay/5.0 s, Def/MyColor, Onset), (Delay/5.0 s, Def/MyColor, Onset)", + "correct": "(Delay/5.0 s, Def/MyColor, Onset)", + "explanation": "Removed duplicate Onset for same definition" + }, + { + "wrong": "(Delay/5.0 s, Def/MyColor, Offset), (Delay/5.0 s, Def/MyColor, Offset)", + "correct": "(Delay/5.0 s, Def/MyColor, Offset)", + "explanation": "Eliminated duplicate Offset temporal tags" + } + ], + "correction_patterns": [ + "Ensure unique temporal tags per definition per event", + "Remove duplicate Onset/Offset tags", + "Consolidate temporal information for same definition", + "Maintain temporal tag uniqueness in delayed contexts" + ], + "fix_instructions": [ + "1. Identify duplicate temporal tags with same definition", + "2. Remove redundant Onset/Offset instances", + "3. Keep single temporal tag per definition per event", + "4. Verify temporal uniqueness requirements", + "5. Check delayed context organization rules" + ], + "validation_hints": [ + "Each definition gets one temporal tag per event", + "Look for duplicate Onset/Offset with same anchor", + "Check temporal tag uniqueness requirements", + "Verify delayed context temporal organization" + ], + "specification_reference": "3.2.8.3. Temporal tag uniqueness requirements", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "TAG_GROUP_ERROR", + "DEFINITION_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, (Green), Onset)", + "ball": "Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Delay/5.0 s, Def/MyColor, (Blue), Onset)" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, (Green), Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Delay/5.0 s, Def/MyColor, Offset)" + ], + [ + 5.0, + 0, + "ball", + "(Delay/5.0 s, Def/MyColor, Offset)" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, (Green), Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "(Delay/5.0 s, Def/MyColor, Offset)" + ], + [ + 5.0, + 0, + "ball", + "(Delay/5.0 s, Def/MyColor, Offset)" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, (Blue, Green), Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Onset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-inset-outside-its-event-delay", + "description": "An Inset tag is not grouped with a Def or Def-expand of an ongoing Onset.", + "schema": "8.3.0", + "error_category": "temporal_logic", + "common_causes": [ + "Inset tag used without corresponding active Onset", + "Delayed Inset appears before Onset establishment", + "Misunderstanding Inset dependency on Onset context", + "Incorrect temporal sequence with delayed Insets", + "Orphaned Inset tags without temporal anchor" + ], + "explanation": "Inset tags in delayed contexts must reference definitions that have active Onset boundaries. They cannot exist without an established temporal context from a preceding Onset.", + "correction_strategy": "Ensure Inset follows corresponding Onset establishment", + "correction_examples": [ + { + "wrong": "(Delay/5.0 s, Inset, (Red))", + "correct": "(Delay/5.0 s, Def/MyColor, Onset), ..., (Delay/7.0 s, Def/MyColor, Inset)", + "explanation": "Added Onset before Inset with proper definition" + }, + { + "wrong": "(Delay/5.0 s, Def/MyColor, Inset) without prior Onset", + "correct": "(Def/MyColor, Onset), ..., (Delay/5.0 s, Def/MyColor, Inset)", + "explanation": "Established Onset context before delayed Inset" + } + ], + "correction_patterns": [ + "Establish Onset before using Inset with same definition", + "Ensure temporal sequence: Onset → Inset → Offset", + "Verify Inset has active temporal context", + "Check delayed temporal boundary relationships" + ], + "fix_instructions": [ + "1. Identify Inset tags without corresponding Onset", + "2. Add Onset establishment before Inset usage", + "3. Verify temporal sequence order", + "4. Check definition consistency across temporal tags", + "5. Ensure proper delayed temporal relationships" + ], + "validation_hints": [ + "Inset requires active Onset with same definition", + "Check temporal sequence: Onset must precede Inset", + "Verify delayed temporal context establishment", + "Look for orphaned Inset tags" + ], + "specification_reference": "3.2.8.3. Inset temporal dependency requirements", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "TAG_GROUP_ERROR", + "DEFINITION_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Inset, (Red))" + ], + [ + 6.5, + 0, + "Red, (Delay/5.0 s, Def/MyColor, Offset)" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, Def/MyColor, Offset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Def/MyColor, Onset)" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, Def/MyColor, Offset)" + ], + [ + 6.5, + 0, + "Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Offset)", + "snack": "(Delay/5.0 s, Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "snack", + "Red, Blue" + ], + [ + 4.8, + 0, + "face", + "Red, Blue" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/2.0 s, Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Offset)", + "snack": "(Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 1.5, + 0, + "face", + "Blue" + ], + [ + 4.8, + 0, + "ball", + "Blue" + ], + [ + 5.0, + 0, + "snack", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-inset-group-has-extras-delay", + "description": "An Inset group has tags or groups in addition to its defining Def or Def-expand.", + "schema": "8.3.0", + "error_category": "temporal", + "common_causes": [ + "Extra content tags added to delayed Inset groups", + "Misunderstanding that Inset should be minimal", + "Incorrect grouping of content with delayed Inset", + "Over-specification of Inset temporal boundaries", + "Adding unnecessary tags to Inset structure" + ], + "explanation": "Inset tags in delayed contexts should only include their defining Def or Def-expand tag. Additional content violates the minimal boundary specification for Insets.", + "correction_strategy": "Remove extra content from Inset groups", + "correction_examples": [ + { + "wrong": "(Delay/5.0 s, Def/MyColor, Blue, Inset)", + "correct": "(Delay/5.0 s, Def/MyColor, Inset)", + "explanation": "Removed extra content tag from Inset group" + }, + { + "wrong": "(Delay/5.0 s, Def/MyColor, (Blue), Inset)", + "correct": "(Delay/5.0 s, Def/MyColor, Inset)", + "explanation": "Eliminated additional grouped content" + } + ], + "correction_patterns": [ + "Keep only definition with Inset tag", + "Remove all additional content from Inset groups", + "Maintain minimal Inset boundary specification", + "Follow delayed temporal minimalism requirements" + ], + "fix_instructions": [ + "1. Identify Inset groups with extra content", + "2. Remove all tags except definition and Inset", + "3. Ensure minimal Inset structure", + "4. Verify delayed temporal boundary requirements", + "5. Check Inset group minimalism rules" + ], + "validation_hints": [ + "Inset should only have definition plus Inset tag", + "Remove any additional content from Inset groups", + "Check minimal delayed temporal boundary rules", + "Verify Inset group simplicity" + ], + "specification_reference": "3.2.8.3. Inset minimal boundary requirements", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "TAG_GROUP_ERROR", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 2.5, + 0, + "Red, (Delay/5.0 s, Def/MyColor, Onset)" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Def/MyColor, Blue, Inset)" + ], + [ + 6.5, + 0, + "Red, (Delay/5.0 s, Def/MyColor, Onset)" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, Def/MyColor, Offset)" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "(Delay/5.0 s, Def/MyColor, (Blue), Onset)" + ], + [ + 4.8, + 0, + "(Delay/5.0 s, Def/MyColor, (Green), Inset)" + ], + [ + 5.5, + 0, + "(Delay/5.0 s, Def/MyColor, Offset)" + ], + [ + 6.5, + 0, + "Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Offset)", + "snack": "(Delay/5.0 s, Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "snack", + "Red, Blue" + ], + [ + 4.8, + 0, + "face", + "Red, Blue" + ], + [ + 5.0, + 0, + "face", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Offset)", + "snack": "(Delay/5.0 s, Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 4.7, + 0, + "face", + "Blue" + ], + [ + 4.8, + 0, + "snack", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "TEMPORAL_TAG_ERROR", + "alt_codes": [ + "TAG_GROUP_ERROR" + ], + "name": "temporal-tag-error-tag-appears-where-not-allowed-delay", + "description": "An Inset, Offset, or Onset tag appears in a tsv with no onset column", + "schema": "8.3.0", + "error_category": "context", + "common_causes": [ + "Temporal tags used in inappropriate file formats", + "Missing onset column for temporal tag usage", + "Delayed temporal tags in non-temporal contexts", + "Misunderstanding temporal tag file requirements", + "Incorrect file format for temporal annotations" + ], + "explanation": "Temporal tags (Onset, Offset, Inset) including delayed versions require proper temporal context with onset timing information. They cannot be used in files without temporal structure.", + "correction_strategy": "Use temporal tags only in appropriate temporal contexts", + "correction_examples": [ + { + "wrong": "Using (Delay/5.0 s, Onset, Def/MyColor) in non-temporal file", + "correct": "Use in file with onset column or remove temporal tags", + "explanation": "Temporal tags require temporal file structure" + }, + { + "wrong": "(Delay/5.0 s, Def/MyColor, Inset) without onset timing", + "correct": "Remove temporal tags or add proper temporal structure", + "explanation": "Eliminated temporal tags from inappropriate context" + } + ], + "correction_patterns": [ + "Remove temporal tags from non-temporal files", + "Add proper temporal structure (onset column)", + "Use appropriate file format for temporal annotations", + "Verify temporal context requirements" + ], + "fix_instructions": [ + "1. Check if file format supports temporal tags", + "2. Add onset column if temporal tags needed", + "3. Remove temporal tags if inappropriate context", + "4. Verify file structure requirements", + "5. Use correct format for delayed temporal annotations" + ], + "validation_hints": [ + "Temporal tags need onset timing context", + "Check file format temporal support", + "Verify proper temporal structure", + "Remove temporal tags from inappropriate files" + ], + "specification_reference": "3.2.8.3. Temporal tag context requirements", + "related_errors": [ + "TEMPORAL_TAG_ERROR", + "SIDECAR_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [], + "passes": [] + }, + "event_tests": { + "fails": [ + [ + [ + "duration", + "HED" + ], + [ + 0, + "Red, (Delay/5.0 s, Def/MyColor, Onset)" + ], + [ + 0, + "(Delay/5.0 s, Def/MyColor, Yellow, Inset)" + ], + [ + 0, + "Red, (Delay/5.0 s, Def/MyColor, Onset)" + ], + [ + 0, + "(Delay/5.0 s, Def/MyColor, Offset)" + ] + ] + ], + "passes": [ + [ + [ + "duration", + "HED" + ], + [ + 0, + "(Def/MyColor, (Blue))" + ], + [ + 0, + "(Def/MyColor, (Green))" + ], + [ + 0, + "(Def/MyColor)" + ], + [ + 0, + "Red" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, Onset)", + "ball": "(Delay/5.0 s, Def/MyColor, Offset)", + "snack": "(Delay/5.0 s, Def/MyColor, Inset)" + } + } + }, + "events": [ + [ + "event_code", + "HED" + ], + [ + "face", + "Def/MyColor, Red, Blue" + ], + [ + "ball", + "Def/MyColor, Red, Blue" + ], + [ + "snack", + "Green" + ] + ] + }, + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Delay/5.0 s, Def/MyColor, Duration)", + "ball": "(Delay/5.0 s, Def/MyColor, Delay/4.2)" + } + } + }, + "events": [ + [ + "event_code", + "HED" + ], + [ + "face", + "Def/MyColor, Red, Blue" + ], + [ + "ball", + "Def/MyColor, Red, Blue" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "(Def/MyColor)", + "ball": "(Def/MyColor)", + "snack": "(Def/MyColor)" + } + } + }, + "events": [ + [ + "event_code", + "HED" + ], + [ + "face", + "Blue" + ], + [ + "face", + "Blue" + ], + [ + "snack", + "Blue" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/UNITS_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/UNITS_INVALID.json new file mode 100644 index 000000000..05a1387ef --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/UNITS_INVALID.json @@ -0,0 +1,394 @@ +[ + { + "error_code": "UNITS_INVALID", + "alt_codes": [], + "name": "units-invalid-for-unit-class", + "description": "A tag has a value with units that are invalid or not of the correct unit class for the tag.", + "warning": false, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "Using units not defined in schema", + "Wrong unit class for the tag", + "Incorrect unit abbreviations", + "Missing space between value and unit", + "Applying unit modifiers to non-SI units" + ], + "explanation": "HED tags requiring units must use valid units from the appropriate unit class. Units must be spelled correctly, properly spaced from values, and compatible with the tag's requirements.", + "correction_strategy": "Use valid units from correct unit classes", + "correction_examples": [ + { + "wrong": "Acceleration/3 s", + "correct": "Acceleration/3 m-per-s^2", + "explanation": "Used correct acceleration unit instead of time unit" + }, + { + "wrong": "Weight/3 ms", + "correct": "Weight/3 kg", + "explanation": "Used correct weight unit instead of time unit" + }, + { + "wrong": "Frequency/50Hz", + "correct": "Frequency/50 Hz", + "explanation": "Added required space between value and unit" + } + ], + "correction_patterns": [ + "Check schema for valid units in tag's unit class", + "Ensure proper spacing (value + space + unit)", + "Use standard SI units when possible", + "Apply unit modifiers only to SI units", + "Match unit class to tag requirements" + ], + "fix_instructions": [ + "1. Identify the tag's required unit class from schema", + "2. Check if current unit exists in that unit class", + "3. Replace with valid unit if needed", + "4. Ensure proper spacing between value and unit", + "5. Verify unit modifiers are used correctly" + ], + "validation_hints": [ + "Consult schema unit classes for valid units", + "Check spacing between numbers and units", + "Verify unit class matches tag requirements", + "Ensure unit modifiers only with SI units" + ], + "specification_reference": "3.2.4. Tags that take values", + "related_errors": [ + "VALUE_INVALID", + "TAG_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Acceleration/3 s", + "Weight/3 ms" + ], + "passes": [ + "Distance/4 km" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Acceleration/3 s", + "ball": "Weight/3 ms" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Distance/4 km", + "ball": "Angle/4 degrees" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Acceleration/3 s" + ], + [ + 5.5, + 0, + "Weight/3 ms" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Distance/4 km" + ], + [ + 5.0, + 0, + "Angle/4 degrees" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/3 s", + "ball": "Weight/3 ms" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "UNITS_INVALID", + "alt_codes": [], + "name": "units-invalid-si-units", + "description": "A unit modifier is applied to units that are not SI units.", + "warning": false, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "Applying SI prefixes (k, m, etc.) to non-SI units", + "Using modifiers like 'kilo' with imperial units", + "Confusion about which units support SI prefixes", + "Attempting to modify units that don't allow modification" + ], + "explanation": "SI unit modifiers (like kilo-, milli-, micro-) can only be applied to SI base units. Applying them to non-SI units like feet creates invalid unit combinations.", + "correction_strategy": "Use SI units with modifiers or remove modifiers from non-SI units", + "correction_examples": [ + { + "wrong": "Distance/3 kfeet", + "correct": "Distance/3 km", + "explanation": "Changed to SI unit (kilometer) instead of modifying non-SI unit" + }, + { + "wrong": "Weight/5 kpounds", + "correct": "Weight/2.27 kg", + "explanation": "Converted to proper SI unit with conversion" + }, + { + "wrong": "Distance/3 kmeters", + "correct": "Distance/3 km", + "explanation": "Used proper SI abbreviation for kilometers" + } + ], + "correction_patterns": [ + "Convert to proper SI units with modifiers", + "Remove invalid modifiers from non-SI units", + "Use standard SI prefix abbreviations" + ], + "fix_instructions": [ + "1. Identify units with invalid modifiers", + "2. Check if unit is SI-compatible", + "3. Either convert to SI unit or remove modifier", + "4. Use standard prefix abbreviations (k, m, μ, etc.)" + ], + "validation_hints": [ + "Check if unit accepts SI prefixes", + "Verify modifier applies to SI base unit", + "Ensure proper prefix abbreviation format" + ], + "specification_reference": "3.1.2.2. SI units and modifiers", + "related_errors": ["VALUE_INVALID", "UNITS_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Distance/3 kfeet", + "Distance/3 kmeters" + ], + "passes": [ + "Distance/3 kilometres" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Distance/3 kfeet", + "ball": "Distance/3 kmeters" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Distance/3 kilometres" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Distance/3 kfeet" + ], + [ + 5.0, + 0, + "Distance/3 kmeters" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Distance/3 kilometres" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Distance/3 kfeet", + "ball": "Distance/3 kmeters" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/hed-tests/json_test_data/validation_tests/VALUE_INVALID.json b/spec_tests/hed-tests/json_test_data/validation_tests/VALUE_INVALID.json new file mode 100644 index 000000000..759d47788 --- /dev/null +++ b/spec_tests/hed-tests/json_test_data/validation_tests/VALUE_INVALID.json @@ -0,0 +1,637 @@ +[ + { + "error_code": "VALUE_INVALID", + "alt_codes": [ + "CHARACTER_INVALID", + "TAG_INVALID" + ], + "name": "value-invalid-#-substitution", + "description": "The value substituted for a placeholder (`#`) is not valid.", + "warning": false, + "schema": "8.3.0", + "error_category": "validation", + "common_causes": [ + "Using incorrect data types for tag values (e.g., text where numbers expected)", + "Missing or incorrect units for numerical values", + "Invalid characters in tag values", + "Values that don't match the tag's value class requirements", + "Incorrect spacing between values and units" + ], + "explanation": "HED tags with placeholders (#) require values that match specific value classes (e.g., numeric, text, dateTime). The value must be compatible with the tag's requirements, including proper units, format, and character restrictions.", + "correction_strategy": "Provide values that match the tag's value class requirements", + "correction_examples": [ + { + "wrong": "Def/Acc/MyMy", + "correct": "Def/Acc/3.4", + "explanation": "Replaced invalid text with valid numeric value for acceleration" + }, + { + "wrong": "Distance/4mxxx", + "correct": "Distance/4 m", + "explanation": "Corrected units format with proper spacing and valid unit" + }, + { + "wrong": "Item-count/abc", + "correct": "Item-count/5", + "explanation": "Replaced text with valid integer for count" + } + ], + "correction_patterns": [ + "Use numeric values for tags requiring numbers", + "Include proper units with correct spacing (value + space + unit)", + "Ensure text values use only allowed characters", + "Match value format to tag's value class requirements", + "Use valid units from the schema's unit classes" + ], + "fix_instructions": [ + "1. Identify the tag's value class requirements from the schema", + "2. Check if the value matches the expected data type", + "3. For numeric values: ensure proper number format", + "4. For values with units: verify unit validity and spacing", + "5. For text values: check character restrictions" + ], + "validation_hints": [ + "Consult schema documentation for tag value requirements", + "Verify units are from valid unit classes", + "Check that numeric values use proper decimal notation", + "Ensure single space between value and unit", + "Confirm text values don't contain forbidden characters" + ], + "specification_reference": "3.2.4. Tags that take values", + "related_errors": [ + "UNITS_INVALID", + "CHARACTER_INVALID", + "PLACEHOLDER_INVALID" + ], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [], + "passes": [] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Def/Acc/MyMy", + "ball": "Distance/4mxxx" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Def/Acc/3.4", + "ball": "Distance/4 m" + } + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "response": { + "HED": "Item-count/#" + } + }, + "events": [ + [ + "onset", + "duration", + "response", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + 4, + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "response": { + "HED": "Item-count/#" + } + }, + "events": [ + [ + "onset", + "duration", + "response", + "HED" + ], + [ + 4.5, + 0, + 5, + "Blue" + ], + [ + 5.0, + 0, + 2, + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "VALUE_INVALID", + "alt_codes": [ + "CHARACTER_INVALID" + ], + "name": "value-invalid-incompatible-value-class", + "description": "A tag placeholder value is incompatible with the specified value class.", + "warning": false, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "Using characters invalid for specific value classes (e.g., letters in numeric values)", + "Providing values that don't match the expected data type", + "Using incompatible units or formats for specific tags", + "Violating name class restrictions for placeholder substitutions" + ], + "explanation": "HED tags with placeholders have specific value class requirements. The substituted value must be compatible with the tag's defined value class restrictions.", + "correction_strategy": "Ensure placeholder values match the required value class format", + "correction_examples": [ + { + "wrong": "Statistical-accuracy/1max1", + "correct": "Statistical-accuracy/0.95", + "explanation": "Replaced invalid character sequence with proper numeric value" + }, + { + "wrong": "Duration/abc", + "correct": "Duration/3.5", + "explanation": "Replaced text with numeric value for numeric value class" + } + ], + "correction_patterns": [ + "Use only numeric values for numeric value classes", + "Match the expected data type and format", + "Remove invalid characters for the specific value class", + "Verify units are appropriate for the tag context" + ], + "fix_instructions": [ + "1. Identify the tag's value class requirements", + "2. Check if the provided value matches the expected format", + "3. Replace invalid characters or format", + "4. Ensure numeric values use proper format (decimals, scientific notation)", + "5. Verify units match the tag's unit class if applicable" + ], + "validation_hints": [ + "Check HED schema for tag value class definitions", + "Verify numeric values use appropriate format", + "Ensure text values only contain allowed characters", + "Confirm units are valid for the specific tag" + ], + "specification_reference": "2.2. Value classes and validation", + "related_errors": ["CHARACTER_INVALID", "UNITS_INVALID", "PLACEHOLDER_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Statistical-accuracy/1max1" + ], + "passes": [ + "Statistical-accuracy/0.677" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Statistical-accuracy/1max1" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Statistical-accuracy/0.677" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Statistical-accuracy/1max1" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Statistical-accuracy/0.677" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Statistical-accuracy/1max1" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "VALUE_INVALID", + "alt_codes": [ + "CHARACTER_INVALID", + "TAG_INVALID", + "UNITS_INVALID" + ], + "name": "value-invalid-blank-missing-before-units", + "description": "The units are not separated from the value by a single blank.", + "warning": false, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "Missing space between numeric value and units", + "Multiple spaces between value and units instead of single space", + "No separator between value and units", + "Incorrect formatting of unit expressions" + ], + "explanation": "HED requires exactly one space to separate numeric values from their units. This ensures consistent parsing and interpretation of quantitative data.", + "correction_strategy": "Insert exactly one space between value and units", + "correction_examples": [ + { + "wrong": "Acceleration/5m-per-s^2", + "correct": "Acceleration/5 m-per-s^2", + "explanation": "Added required space between value and units" + }, + { + "wrong": "Duration/3.5ms", + "correct": "Duration/3.5 ms", + "explanation": "Added space between value and millisecond units" + } + ], + "correction_patterns": [ + "Insert single space between number and unit", + "Remove extra spaces to ensure only one space exists", + "Verify unit format follows HED specifications" + ], + "fix_instructions": [ + "1. Locate numeric values with units", + "2. Ensure exactly one space separates value from units", + "3. Remove any extra spaces", + "4. Verify units are properly formatted", + "5. Check that units are valid for the tag" + ], + "validation_hints": [ + "Look for patterns like 'number+units' without spaces", + "Verify single space separation (not multiple spaces)", + "Ensure units match HED unit specifications", + "Check that the complete value+unit expression is valid" + ], + "specification_reference": "2.3.1. Units and unit classes", + "related_errors": ["UNITS_INVALID", "CHARACTER_INVALID", "TAG_INVALID"], + "definitions": [ + "(Definition/Acc/#, (Acceleration/# m-per-s^2, Red))", + "(Definition/MyColor, (Label/Pie))" + ], + "tests": { + "string_tests": { + "fails": [ + "Acceleration/5m-per-s^2" + ], + "passes": [ + "Acceleration/5 m-per-s^2" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "face": "Acceleration/5m-per-s^2" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2" + } + } + } + ] + }, + "event_tests": { + "fails": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Acceleration/5m-per-s^2" + ] + ] + ], + "passes": [ + [ + [ + "onset", + "duration", + "HED" + ], + [ + 4.5, + 0, + "Acceleration/5 m-per-s^2" + ] + ] + ] + }, + "combo_tests": { + "fails": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/banana", + "ball": "Def/Acc/apple3, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Red, Def/MyColor" + ], + [ + 5.0, + 0, + "ball", + "Green" + ] + ] + } + ], + "passes": [ + { + "sidecar": { + "event_code": { + "HED": { + "face": "Acceleration/5 m-per-s^2", + "ball": "Def/Acc/7, Blue" + } + } + }, + "events": [ + [ + "onset", + "duration", + "event_code", + "HED" + ], + [ + 4.5, + 0, + "face", + "Blue" + ], + [ + 5.0, + 0, + "ball", + "Green, Def/MyColor" + ] + ] + } + ] + } + } + }, + { + "error_code": "VALUE_INVALID", + "alt_codes": [ + "UNITS_INVALID" + ], + "name": "invalid-character-numeric-class", + "description": "An invalid character was used in an 8.3.0 or greater style numeric value class.", + "warning": false, + "schema": "8.4.0", + "error_category": "validation", + "common_causes": [ + "Including non-numeric characters in numeric values (letters, symbols)", + "Using currency symbols or percentage signs in numeric fields", + "Typos that introduce invalid characters into numbers", + "Copy-paste errors that include formatting characters" + ], + "explanation": "Numeric value classes in HED 8.3.0+ require strict numeric formatting. Only digits, decimal points, scientific notation, and proper unit separators are allowed.", + "correction_strategy": "Remove invalid characters and use proper numeric formatting", + "correction_examples": [ + { + "wrong": "Weight/3.0$ kg", + "correct": "Weight/3.0 kg", + "explanation": "Removed currency symbol from numeric value" + }, + { + "wrong": "Weight/abc kg", + "correct": "Weight/3.0 kg", + "explanation": "Replaced text with proper numeric value" + }, + { + "wrong": "Weight/3.0% kg", + "correct": "Weight/3.0 kg", + "explanation": "Removed percentage symbol from numeric value" + } + ], + "correction_patterns": [ + "Remove non-numeric characters from numeric values", + "Use only digits, decimal points, and scientific notation", + "Ensure proper space separation between value and units", + "Replace text or symbols with valid numeric representations" + ], + "fix_instructions": [ + "1. Identify non-numeric characters in numeric value fields", + "2. Remove symbols, letters, and formatting characters", + "3. Ensure value uses standard numeric format", + "4. Verify decimal places and scientific notation are correct", + "5. Maintain proper space separation with units" + ], + "validation_hints": [ + "Numeric values should contain only digits, decimal points, and +/- signs", + "Scientific notation (e.g., 1.23e-4) is acceptable", + "Units must be separated from values by exactly one space", + "No currency symbols, percentages, or letters in numeric fields" + ], + "specification_reference": "2.2. Numeric value classes in HED 8.3.0+", + "related_errors": ["CHARACTER_INVALID", "UNITS_INVALID"], + "definitions": [], + "tests": { + "string_tests": { + "fails": [ + "Weight/3.0$ kg", + "Weight/3.0db kg", + "Weight/3.0& kg", + "Weight/abc kg", + "Weight/*3.0 kg", + "Weight/3.0% kg", + "Weight/3.0^ kg", + "Weight/3.0? kg" + ], + "passes": [ + "Weight/3.0e10 kg", + "Weight/3e10 kg", + "Weight/3.0 kg", + "Weight/3000 kg", + "Weight/3e10 kg", + "Weight/3.5e10 kg", + "Weight/2.998e8 g", + "Weight/6.022e23 g", + "Weight/7.0e-10 g", + "Weight/1.6e-35 kg" + ] + }, + "sidecar_tests": { + "fails": [ + { + "event_code": { + "HED": { + "show": "Weight/3.0a" + } + } + } + ], + "passes": [ + { + "event_code": { + "HED": "Weight/# g" + } + } + ] + }, + "event_tests": { + "fails": [], + "passes": [] + }, + "combo_tests": { + "fails": [], + "passes": [] + } + } + } +] \ No newline at end of file diff --git a/spec_tests/test_errors.py b/spec_tests/test_errors.py index 6ec362c8c..4ffeaa528 100644 --- a/spec_tests/test_errors.py +++ b/spec_tests/test_errors.py @@ -24,30 +24,49 @@ class MyTestCase(unittest.TestCase): @classmethod def setUpClass(cls): - test_dir = os.path.realpath( - os.path.join(os.path.dirname(os.path.realpath(__file__)), "hed-specification/tests/json_tests") - ) - cls.test_dir = test_dir + # New directory structure: hed-tests/json_test_data/ + test_base_dir = os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "hed-tests/json_test_data")) + schema_test_dir = os.path.join(test_base_dir, "schema_tests") + validation_test_dir = os.path.join(test_base_dir, "validation_tests") + + cls.test_base_dir = test_base_dir cls.fail_count = [] cls.current_test_file = None cls.test_counter = {"total": 0, "passed": 0, "failed": 0, "skipped": 0} - # Check if the required directory exists - if not os.path.exists(test_dir): + # Check if the required directories exist + if not os.path.exists(test_base_dir): cls.test_files = [] cls.skip_tests = True # Only print warning if not in CI environment to avoid interference if not os.environ.get("GITHUB_ACTIONS"): - print(f"WARNING: Test directory not found: {test_dir}") - print("To run spec error tests, copy hed-specification repository content to spec_tests/hed-specification/") + print(f"WARNING: Test directory not found: {test_base_dir}") + print("To run spec error tests, copy hed-tests repository content to spec_tests/hed-tests/") else: - # Get all .json files except backup files - cls.test_files = [ - os.path.join(test_dir, f) - for f in os.listdir(test_dir) - if os.path.isfile(os.path.join(test_dir, f)) and f.endswith(".json") and not f.endswith(".backup") - ] - cls.skip_tests = False + # Get all .json files from both schema_tests and validation_tests directories + cls.test_files = [] + + if os.path.exists(schema_test_dir): + schema_files = [ + os.path.join(schema_test_dir, f) + for f in os.listdir(schema_test_dir) + if os.path.isfile(os.path.join(schema_test_dir, f)) and f.endswith(".json") and not f.endswith(".backup") + ] + cls.test_files.extend(schema_files) + + if os.path.exists(validation_test_dir): + validation_files = [ + os.path.join(validation_test_dir, f) + for f in os.listdir(validation_test_dir) + if os.path.isfile(os.path.join(validation_test_dir, f)) + and f.endswith(".json") + and not f.endswith(".backup") + ] + cls.test_files.extend(validation_files) + + cls.skip_tests = len(cls.test_files) == 0 + if cls.skip_tests and not os.environ.get("GITHUB_ACTIONS"): + print(f"WARNING: No test files found in {test_base_dir}") cls.default_sidecar = Sidecar( os.path.realpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "test_sidecar.json")) @@ -450,7 +469,7 @@ def _run_single_schema_test(self, info, error_code, all_codes, description, name def test_errors(self): if hasattr(self, "skip_tests") and self.skip_tests: - self.skipTest("hed-specification directory not found. Copy submodule content to run this test.") + self.skipTest("hed-tests directory not found. Copy hed-tests repository content to run this test.") print("\n" + "=" * 80) print("Running HED Specification Error Tests")