Skip to content

feat(validation): enforce label-to-score-band consistency - #79

Open
peterexcel494-oss wants to merge 2 commits into
Gryd-lock:mainfrom
peterexcel494-oss:feat/label-score-band-validation
Open

feat(validation): enforce label-to-score-band consistency#79
peterexcel494-oss wants to merge 2 commits into
Gryd-lock:mainfrom
peterexcel494-oss:feat/label-score-band-validation

Conversation

@peterexcel494-oss

Copy link
Copy Markdown

Summary

Extends scripts/validate-fixtures.mjs to enforce the documented score bands for each destination label, as specified in CONTRIBUTING.md. Before this change the validator confirmed scores were integers in 0–100 but never checked whether a score matched the band for its label — a fixture could be labelled clean with a malicious-range score and CI would not catch it.

Changes

scripts/validate-fixtures.mjs

  • Export SCORE_BANDS constant mapping each label to its { min, max } band: clean → 0–25, suspicious → 40–70, malicious → 75–100
  • Export scoreMatchesBand(label, score) — returns true when score falls within the expected band for the given label
  • Export bandRangeLabel(label) — returns a human-readable range string (e.g. "0–25") for use in error messages
  • Band-check loop produces actionable errors naming the fixture ID, actual score, and expected range; intentional gaps (26–39 and 71–74) are preserved

scripts/validate-fixtures.test.mjs (new file)

78 tests using Node's built-in node:test runner covering:

  • SCORE_BANDS shape and values for all three labels
  • bandRangeLabel output and unknown input handling
  • scoreMatchesBand boundary values (min and max of each band)
  • Values just inside and just outside each boundary
  • All gap values (26–39 and 71–74) rejected by every label
  • Cross-label mismatch scenarios (the core issue Enforce label-to-score-band consistency in fixture validation #62 case)
  • Invalid/unknown label inputs

package.json

  • Added "test": "node --test scripts/validate-fixtures.test.mjs" script

Acceptance Criteria

  • Valid existing fixtures pass (npm run validate exits 0)
  • Mismatched label/score bands fail with an actionable error message
  • Boundary values follow CONTRIBUTING.md (clean 0–25, suspicious 40–70, malicious 75–100)
  • Error output identifies the fixture ID and expected range
  • Automated tests cover valid and invalid boundaries (78 tests, all passing)

Testing

npm test          # 78 tests — all pass
npm run validate  # Fixture validation passed: 12 destinations, 12 scores

Cross-Repository Impact

None. Fixture values in destinations.json and scores.json are unchanged.

Closes #62

peterexcel494-oss and others added 2 commits August 17, 2026 18:38
Extend validate-fixtures.mjs to compare each fixture's score against the
documented band for its label (CONTRIBUTING.md: clean 0–25, suspicious
40–70, malicious 75–100). Intentional gaps (26–39 and 71–74) are
preserved and not filled.

Changes:
- Export SCORE_BANDS constant with min/max for each label
- Export scoreMatchesBand(label, score) helper used in the validator loop
- Export bandRangeLabel(label) for human-readable error messages
- Band-check loop in the main validator produces actionable errors that
  name the fixture ID, the actual score, and the expected range
- Add scripts/validate-fixtures.test.mjs (node:test, 78 tests) covering
  boundary values, gap values, mismatched labels, and all three bands
- Add 'test' script to package.json

Closes Gryd-lock#62
@knytcomics-ui

Copy link
Copy Markdown
Contributor

please one test failing

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.

Enforce label-to-score-band consistency in fixture validation

2 participants