Skip to content

Add structured dictionary Citations alongside Suggestion - #29

Merged
Malcolmnixon merged 4 commits into
mainfrom
feat/dictionary-citations
Sep 29, 2026
Merged

Malcolmnixon merged 4 commits into
mainfrom
feat/dictionary-citations

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

Pull Request

Description

Adds structured Citations data alongside the existing free-text Suggestion string for
STE100-DICT (dictionary) findings. Each citation pairs an approved alternative term with its
grammatical role (Pos), so an integrating tool can consume dictionary corrections as
structured data instead of parsing a formatted string.

This is the remaining half of feature #4 from the integrator write-up. The rule-catalog-level
suggestionKind classification ("advice" vs "citationForm") was already shipped via
--list-rules in an earlier PR; this PR adds the missing per-diagnostic structured citation
data itself.

  • Diagnostic.Citations (IReadOnlyList<DictionaryCitation>?, additive, defaults to null) -
    new DictionaryCitation(Term, Pos) record.
  • DictionaryChecker.ConfidentDiagnostic/AmbiguousDiagnostic build Citations in parallel
    with Suggestion, using identical filtering (excludes purely self-referential senses and
    alternatives-less candidates), so the two representations never disagree.
  • DiagnosticReporter.WriteJson serializes Citations as a new JSON citations array
    (JsonCitation: term, pos), null when the diagnostic has no citable alternative.
  • Suggestion is unchanged, preserving backward compatibility with existing text-mode CLI
    output and all pre-existing test assertions.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code quality improvement

Related Issues

Closes #

Pre-Submission Checklist

Build and Test

  • Code builds successfully and all tests pass: pwsh ./build.ps1
    • Ran: pwsh ./build.ps1 — total: 1350 succeeded: 1350 failed: 0
  • Code produces zero warnings
    • Build output: 0 Warning(s), 0 Error(s)

Code Quality

  • New code has appropriate XML documentation comments
  • Static analyzer warnings have been addressed

Quality Checks

  • All linters pass: pwsh ./lint.ps1
    • Ran: pwsh ./lint.ps1 — exited 0, lint: no errors found. (YAML, markdown, cspell,
      reqstream, versionmark, reviewmark, sysml2tools, dotnet format --verify-no-changes all
      clean)

Testing

  • Added unit tests for new functionality
    • Report_JsonFormat_WritesCitationsForDictionaryDiagnostic (new)
    • Extended Evaluate_MultiSenseTerm_NounContext_ReportsNounSense,
      Evaluate_MultiSenseTerm_VerbContext_ReportsVerbSense,
      Evaluate_MultiSenseTerm_AmbiguousContext_ReportsAllSensesAmbiguous,
      Evaluate_SingleSenseTerm_InconclusiveContext_ReportedWithoutPosLabel,
      Evaluate_PureSelfReferentialEntry_ConfidentDisallowedUsage_UsesRoleRestrictionMessage,
      Evaluate_PureSelfReferentialCandidate_WithinAmbiguousResult_UsesRoleRestrictionClause,
      Evaluate_AmbiguousTerm_CandidateWithNoAlternatives_SuggestionHasNoEmptyFragment with
      Citations assertions covering the populated, self-referential (null), and
      alternatives-less (null) cases.
  • Updated existing tests if behavior changed
    • Behavior is additive only; no existing assertion needed to change.
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
    • Not applicable: no JSON schema example in README references per-diagnostic fields.
  • Updated docs/ documentation (if applicable)
    • docs/design/ste100-mark/linting/dictionary-checker.md,
      docs/design/ste100-mark/linting/diagnostic-reporter.md,
      docs/verification/ste100-mark/linting.md,
      docs/reqstream/ste100-mark/linting.yaml
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)
    • Not applicable: no new requirement created; new/extended tests were added to the tests
      list of the existing Ste100Mark-Linting-DictionaryPos and Ste100Mark-Linting-OutputFormats
      requirements in docs/reqstream/ste100-mark/linting.yaml, whose scope already covers this
      behavior.

Additional Notes

Design choice: kept Suggestion as-is rather than replacing it, to avoid a large,
low-value rewrite of ~15+ existing .Suggestion test assertions and to preserve
text-mode CLI output quality. Citations is null (not an empty array) whenever there
is no citable alternative (purely self-referential sense, or a sense/candidate with zero
alternatives), mirroring the cases where Suggestion itself carries no word list.

Add Diagnostic.Citations (IReadOnlyList<DictionaryCitation>) as an
additive, structured alternative to the free-text Suggestion string
for STE100-DICT findings. Each citation pairs an approved alternative
term with its grammatical role (Pos), letting integrators consume
dictionary corrections as data instead of parsing prose.

- DictionaryChecker.ConfidentDiagnostic/AmbiguousDiagnostic now build
  Citations in parallel with Suggestion, using identical filtering
  (excludes pure-self-referential senses and alternatives-less
  candidates) so the two representations never disagree.
- DiagnosticReporter.WriteJson serializes Citations as a new
  citations JSON array (JsonCitation: term, pos), null when absent.
- Suggestion is unchanged for backward compatibility with existing
  text-mode CLI output and test assertions.

Extends feature #4 from the integrator write-up (structured
suggestionKind/citation data instead of a pre-formatted string);
the rule-catalog-level suggestionKind classification was already
shipped via --list-rules.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 29, 2026 22:04

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.

Copilot review overview

🟡 Changes recommended

Citation coverage, documentation, and ReqStream traceability updates remain unresolved.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

Adds structured dictionary citations to diagnostics and JSON output while preserving existing suggestion text.

Changes:

  • Adds citation data to dictionary diagnostics.
  • Serializes citations in JSON reports.
  • Adds tests and supporting documentation.
File Reviewed change
test/​DemaConsulting.Ste100Mark.Tests/​Linting/​DictionaryCheckerTests.cs Tests citation generation.
test/​DemaConsulting.Ste100Mark.Tests/​Linting/​DiagnosticReporterTests.cs Tests JSON citation serialization.
src/​DemaConsulting.Ste100Mark/​Linting/​DictionaryChecker.cs Builds filtered citations.
src/​DemaConsulting.Ste100Mark/​Linting/​DiagnosticReporter.cs Emits citations in JSON.
src/​DemaConsulting.Ste100Mark/​Linting/​Diagnostic.cs Adds citation data to diagnostics.
docs/​verification/​ste100-mark/​linting.md Documents verification coverage.
docs/​reqstream/​ste100-mark/​linting.yaml Tracks requirements and test coverage.
docs/​design/​ste100-mark/​linting/​dictionary-checker.md Documents citation behavior.
docs/​design/​ste100-mark/​linting/​diagnostic-reporter.md Documents JSON citation changes.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/DemaConsulting.Ste100Mark/Linting/Diagnostic.cs
Addresses reviewer feedback on PR #29: the Diagnostic design doc still
described the record as ending at Suggestion, omitting the new
Citations field and DictionaryCitation record added alongside it.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 29, 2026 22:17

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.

Copilot review overview

🟡 Changes recommended

Documentation traceability and test-coverage descriptions need correction.

Review effort: Lite
Findings: 3 Low severity

Open (3)

Comment thread docs/reqstream/ste100-mark/linting.yaml
Comment thread docs/verification/ste100-mark/linting.md Outdated
Addresses reviewer feedback on PR #29:
- Add the two self-referential Citations tests
  (Evaluate_PureSelfReferentialEntry_ConfidentDisallowedUsage_UsesRoleRestrictionMessage,
  Evaluate_PureSelfReferentialCandidate_WithinAmbiguousResult_UsesRoleRestrictionClause)
  to Ste100Mark-Linting-DictionaryPos's tests list in linting.yaml, closing the
  traceability gap between the verification narrative and ReqStream.
- Correct linting.md wording that overstated coverage: the
  alternatives-less-candidate and self-referential-candidate tests prove
  Citations omits the non-citable candidate from a mixed result (non-null),
  not that the whole Citations list is null; only the sole-self-referential-
  candidate case is actually null.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 29, 2026 22:33

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.

Copilot review overview

🔵 Needs a closer look

Add coverage for confident and fully filtered alternatives-less citation cases.

Review effort: Lite
Findings: 1 Low severity

Open (1)
Resolved since last review (2)
Previously missed (1)

In code that hasn't changed since last review

Medium severity Add test for confident resolution with no alternatives

src/​DemaConsulting.Ste100Mark/​Linting/​DictionaryChecker.cs:357

The confident path now defines the Citations == null behavior for a sense with zero alternatives, but the updated tests only exercise that case through AmbiguousDiagnostic; the confident no-alternatives branch remains unverified. Please add a DictionaryChecker test for a confidently resolved, alternatives-less sense and assert both Suggestion and Citations are null.

Addresses reviewer feedback on PR #29: the confident (single-sense),
non-self-referential, alternatives-less path in DictionaryChecker sets
both Suggestion and Citations to null, but was previously only
exercised indirectly through AmbiguousDiagnostic's filtering. Add
Evaluate_ConfidentSingleSenseTermWithNoAlternatives_SuggestionAndCitationsAreNull
to verify this branch directly, and wire it into the verification
narrative and ReqStream traceability.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 29, 2026 22:48

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.

Copilot review overview

🔵 Needs a closer look

Add test coverage verifying citations for confident senses with multiple alternatives.

Review effort: Lite
Findings: 1 Low severity

Open (1)

@Malcolmnixon
Malcolmnixon merged commit dad9be2 into main Sep 29, 2026
16 checks passed
@Malcolmnixon
Malcolmnixon deleted the feat/dictionary-citations branch September 29, 2026 23:56
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