Skip to content

Add ID scheme validator and profile selection - #60

Open
HassanAkbar wants to merge 2 commits into
mainfrom
feat/isoiec-profile-completion
Open

Add ID scheme validator and profile selection#60
HassanAkbar wants to merge 2 commits into
mainfrom
feat/isoiec-profile-completion

Conversation

@HassanAkbar

Copy link
Copy Markdown
Member

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.

doc = Sts::NisoSts::Standard.from_xml(xml)
Sts::Profiles.validator(:iso_iec).validate(doc)
Sts::Profiles.validator(:iso_iec, id_scheme: :iso).validate(doc)

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.xml matches the IEC scheme for figures and tables but uses sub- for sections. Elements outside the scheme table are never checked.

Ids are read back off the serialized document, so annexes and refs inside ref-list are covered. Walking the model accessors by hand would miss them.

lib/sts.rb now 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.new callers keep working.

bundle exec rspec: 5231 examples, 0 failures. bundle exec rubocop: clean. spec/anti_patterns_spec.rb passes.

Metanorma PR checklist

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 with UnknownProfileError for 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.

Comment thread lib/sts/profiles/iso_iec/validator.rb
Comment thread lib/sts/profiles/iso_iec/id_scheme.rb Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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`).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants