Add ID scheme validator and profile selection - #60
Open
HassanAkbar wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR completes the ISO/IEC usage profile layer for NISO STS by adding a public profile entry point, implementing an optional semantic ID scheme validator (ISO vs IEC), and documenting usage. It keeps parsing unchanged by validating already-parsed Sts::NisoSts::Standard documents.
Changes:
- Add
Sts::Profiles.validator(:iso_iec, id_scheme: ...)entry point withUnknownProfileErrorfor unknown profiles. - Implement opt-in ISO/IEC semantic ID scheme checking by re-reading IDs from serialized XML.
- Add specs + README documentation for profile validation and ID scheme behavior; update anti-pattern allowlist to permit explicit
require "moxml".
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| TODO.sts-refactor/08-isoiec-profile.md | Marks ISO/IEC profile layer checklist items as completed. |
| spec/profiles/profiles_spec.rb | Exercises Sts::Profiles.validator profile selection and id_scheme argument validation. |
| spec/profiles/iso_iec_validator_spec.rb | Adds coverage for validator behavior with id_scheme enabled and updates constraints expectations. |
| spec/profiles/id_scheme_spec.rb | Unit + fixture-based conformance tests for ISO/IEC ID scheme prefixes. |
| spec/anti_patterns_spec.rb | Allows require "moxml" as an external dependency in lib/. |
| README.adoc | Documents ISO/IEC usage profile validation and optional semantic ID scheme checking. |
| lib/sts/profiles/iso_iec/validator.rb | Adds opt-in ID scheme validation by extracting IDs from serialized XML. |
| lib/sts/profiles/iso_iec/id_scheme.rb | Introduces IdScheme for ISO/IEC per-element ID prefix validation. |
| lib/sts/profiles/iso_iec/constraints.rb | Updates constraint constants and adds committee reference examples. |
| lib/sts/profiles/iso_iec.rb | Autoloads the new IdScheme implementation. |
| lib/sts/profiles.rb | Adds Sts::Profiles.validator entry point and UnknownProfileError. |
| lib/sts.rb | Explicitly requires moxml to avoid relying on transitive dependencies. |
| .rubocop_todo.yml | Excludes new profile specs from RSpec/SpecFilePathFormat cop. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
README.adoc:212
- This sentence implies
<std-meta>/<std-ident>are always checked, but the current validator only validates metadata when<std-ident>is present (missing<std-ident>does not currently produce an error). Update the wording to match the implementation (or alternatively enforce presence in the validator).
`validate` returns an array of message strings, empty when the document satisfies the profile. It checks document structure and `<std-meta>`/`<std-ident>` metadata. The validator targets NISO STS documents (`Sts::NisoSts::Standard`).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Finishes the ISO/IEC usage profile layer — the last 4 boxes in
TODO.sts-refactor/08-isoiec-profile.md.A profile is a constraint layer over NISO STS, not a schema, so this adds no model classes and parsing is unchanged.
Adds the profile entry point, an opt-in ID scheme check for ISO and IEC, committee reference patterns for both, and a README section covering all of it.
The ID check is off by default. Annex F calls OSD ids arbitrary and warns against relying on them, and real documents agree —
ISO_13849-1_2008-12_en_TBX.xmlmatches the IEC scheme for figures and tables but usessub-for sections. Elements outside the scheme table are never checked.Ids are read back off the serialized document, so annexes and refs inside
ref-listare covered. Walking the model accessors by hand would miss them.lib/sts.rbnow requires Moxml explicitly. lutaml-model already loaded it, but naming a constant you only get transitively breaks on the next dependency bump.Additive only. Existing
Validator.newcallers keep working.bundle exec rspec: 5231 examples, 0 failures.bundle exec rubocop: clean.spec/anti_patterns_spec.rbpasses.Metanorma PR checklist