Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide "validate" method #4

Closed
ronaldtse opened this issue Jul 8, 2024 · 6 comments · Fixed by #7
Closed

Provide "validate" method #4

ronaldtse opened this issue Jul 8, 2024 · 6 comments · Fixed by #7
Assignees
Labels
enhancement New feature or request

Comments

@ronaldtse
Copy link
Contributor

We need to validate ModSpec instances

@ronaldtse
Copy link
Contributor Author

@opoudjis could you help describe the cases you need for validation?

  • Validation of single instance
  • Validation of class
  • Validation of a loaded set of classes/instances

Ones I can think of:

  1. URI identifiers of ModSpec instances exist in the loaded collection
  2. No loops or identify reference loops (ie these requirements need to be satisfied together)
  3. Presence of description and identifier
  4. No duplicated identifiers
  5. No missing doubly linked references (to and from)
  6. The content of the description is valid (if in a particular rich text format)
  7. No orphaned instance (every instance needs to belong to a class)

@opoudjis
Copy link

opoudjis commented Aug 11, 2024

What I need, Ronald, is content in the spec so I know what the hell this gem does, because I don't, and I'm not going to waste your clients' time trying to work it out. I don't care what validation functionality you want to add to this gem, there is no validation in spec of what it already does.

I misunderstood what you meant by validation here. But if you're going to start developing code for this project, then you are going to be held to a far greater standard than this:

Dir.glob("spec/fixtures/*-rc.yaml").each do |file|
    it "parses normative statements class #{file}" do
      yaml = IO.read(file)
      ms = Modspec::Suite.from_yaml(yaml)

      # TODO: tests

    end
  end

  Dir.glob("spec/fixtures/*-cc.yaml").each do |file|
    it "parses conformance class #{file}" do
      yaml = IO.read(file)
      ms = Modspec::Suite.from_yaml(yaml)

      # TODO: tests

    end
  end

@opoudjis
Copy link

opoudjis commented Aug 11, 2024

And if you seriously want to reimplement mn-requirements/modspec from scratch, including all its validation, without talking to me, the spec files of mn-requirements are publicly available.

Right now, this is a naive attempt to reimplement mn-requirements/modspec/metanorma, with no idea about validation, no idea about Presentation XML, no idea about the cyclical dependencies and the conflict between anchors and identifiers. Just a bare shell of Shale on top of an object model. It's unusable, it does only the easy bit of mn-requirements/modspec, it is not thought through, and I will ignore it.

@ronaldtse
Copy link
Contributor Author

It will never have anything to do with Presentation XML.

You mentioned about the “easy bits”, so what are the difficult bits?

@opoudjis
Copy link

You need to say what exactly this code is meant to input and output, with test code, and why, and what bits of the existing mn-requirement code it is meant to replace. I don't know what you want this code to do, and I don't trust you.

Modspec Validation functionality is in

https://github.com/metanorma/mn-requirements/blob/main/lib/metanorma/modspec/validate.rb

@ronaldtse
Copy link
Contributor Author

Based on the content provided, this Ruby file implements several validations for ModSpec requirements. Here's an overview of the key validations performed:

  1. Cycle detection:

    • Checks for cycles in requirement linkages (child, dependency, indirect_dependency, implements)
    • Uses topological sorting to detect strongly connected components
  2. Requirement to Conformance mapping:

    • Validates that general requirements have corresponding verification tests
    • Validates that requirement classes have corresponding conformance classes
  3. Conformance to Requirement mapping:

    • Checks that verification tests have corresponding general requirements
    • Checks that conformance classes have corresponding requirement classes
  4. Class to Children mapping:

    • Ensures requirement classes have child requirements
    • Ensures conformance classes have child verification tests
  5. Children to Class mapping:

    • Validates that verification tests belong to a conformance class
  6. Dependency validation:

    • Checks that dependencies, indirect dependencies, and implemented provisions point to valid requirements within the document
  7. Label uniqueness:

    • Ensures that ModSpec identifiers (labels) are unique across requirements
  8. Nested requirement detection:

    • Identifies and handles nested requirements differently
  9. Type validation:

    • Maps requirement types to specific validation rules (e.g., "abstracttest" is treated as "verification")

The code uses a logging mechanism to report validation issues, providing details about the nature of the problem and the affected requirements.

This validation helps ensure the integrity and consistency of the ModSpec requirement structure, particularly in terms of relationships between different types of requirements and conformance tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants