Skip to content

Promote Query Engine to Core as Public API and Update Documentation#49

Merged
Malcolmnixon merged 2 commits into
mainfrom
feature/public-query-api
Jul 21, 2026
Merged

Promote Query Engine to Core as Public API and Update Documentation#49
Malcolmnixon merged 2 commits into
mainfrom
feature/public-query-api

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

This pull request expands the documentation and review structure to cover the new Query subsystem in the SysML2Tools Core library. It adds detailed design and data-flow documentation for the Query subsystem, updates the architecture diagrams and dependencies, and introduces new review definitions for Query design, verification, and implementation. Additionally, it removes outdated review definitions and clarifies file path inclusions for the Tool's Query subsystem.

Documentation and Architecture Updates:

  • Added the Query subsystem to the Core library's architecture overview, including its public API surface and data flow, and updated the mermaid diagram and dependencies to reflect Query-related components (QueryEngine, QueryResultRenderer, QueryResultExporter). [1] [2] [3] [4]
  • Expanded the introduction and navigation aid documentation to describe the Query subsystem and its units, including QualifiedNameShortener as a shared utility. [1] [2] [3]

Review Definitions:

  • Added new review definitions for Query design, verification, and implementation, specifying relevant documentation and code paths for comprehensive coverage.
  • Removed the obsolete review definition for QualifiedNameShortener under the Tool project, since it is now covered as part of the Core Query subsystem.
  • Updated the Tool Query subsystem's review path list to explicitly include only the main Query command and parser files, removing tests that are no longer relevant.

Other Improvements:

  • Updated the CLI documentation to clarify the --output option for the Query command.

Malcolm Nixon and others added 2 commits July 20, 2026 18:52
Moves the `query` CLI command's implementation from the internal
`DemaConsulting.SysML2Tools.Tool` project into the public
`DemaConsulting.SysML2Tools.Core` library, so it can be called
in-process by other applications (e.g. the SysML2Workbench Avalonia
app) without shelling out to the CLI. The Tool project becomes a thin
adapter over the new public Core API; CLI observable behavior is
unchanged except for one new addition.

Moved to Core (namespace DemaConsulting.SysML2Tools.Query, all public):
- QueryEngine: the 12 verb implementations, plus a new Execute(...)
  dispatcher that centralizes verb-selection logic for reuse by both
  the CLI and future library callers.
- QueryResult / QueryResultEntry / QueryEntryDirection: plain
  JSON-serializable result model.
- QueryResultRenderer: Markdown/JSON rendering, now public.
- QueryResultSerializerContext: source-generated JSON serialization.
- QueryVerb / QueryVerbParsing: the 12-verb vocabulary and parsing.
- QueryOptions: the shared option record, with the CLI-only `Files`
  glob-pattern property dropped (library callers pass an
  already-loaded SysmlWorkspace).
- QueryArgumentParser: token parsing, adjusted to return files
  alongside options since Files no longer lives on QueryOptions.
- QualifiedNameShortener: moved from Tool/Utilities to Core/Utilities.

New in Core:
- QueryResultExporter: WriteMarkdown/WriteJson and async variants that
  render a QueryResult and write it to a file, for callers (CLI or
  library) that want file output instead of an in-memory string.
  Exceptions propagate to the caller since Core has no CLI context to
  report through.

Tool changes (thin adapter):
- QueryCommand now calls the public Core QueryEngine/QueryResultRenderer
  APIs instead of hosting the logic itself.
- New QueryCliArgumentParser wraps Core's QueryArgumentParser to also
  track the CLI-only Files/Output values.
- New `--output <file>` flag on the `query` command, mirroring
  `export`'s `--output` semantics exactly (single output file, not a
  directory like `render`). When supplied, output is written via
  QueryResultExporter instead of stdout. Broadened exception handling
  covers ArgumentException/PathTooLongException for malformed paths.
- Context.cs gained a QueryOutput property to carry the new flag.

Tests:
- Pure QueryEngine/QueryResultRenderer/QueryResultExporter tests moved
  to a new test/DemaConsulting.SysML2Tools.Tests/Query/ folder in the
  Core test project; QualifiedNameShortenerTests moved alongside it.
- CLI-specific tests (arg parsing, validation errors, stdout formatting,
  the new --output end-to-end file-writing test) remain in Tool.Tests.
- Added ContextTests coverage for the new QueryOutput property.

Documentation:
- New docs/design, docs/verification, and docs/reqstream entries for
  the Core Query subsystem, mirroring sibling Core subsystem docs.
- Updated docs/design/introduction.md decomposition tree, the Tool
  query docs (thin-adapter description + --output flag), and the Tool
  Cli/Context companion docs/tests for the new QueryOutput property.

Verified: build.ps1 (0 warnings/errors, full test suite green across
net8.0/net9.0/net10.0), fix.ps1, lint.ps1 all clean; manually confirmed
`--output` produces byte-identical content to stdout for both Markdown
and JSON formats. Ran formal-review sub-agents across all 25
review-sets affected by this change's file list (computed via wcmatch
GLOBSTAR|NEGATE|BRACE matching against .reviewmark.yaml); fixed every
finding genuinely caused by this change (missing Query entry in the
design decomposition tree, missing Core Query verb verification
scenarios, wrong heading depth in the Tool query docs, narrow --output
exception handling, missing QueryOutput requirement/design/test
coverage) and re-verified each fix with a fresh review. Remaining
FAILED review-sets were confirmed via `git diff main` to reference
files untouched by this branch (pre-existing, unrelated issues such as
Template-* placeholder requirement IDs, OTS rendering dependency
documentation gaps, and a pre-existing QueryTestFixtures.cs temp-file
leak) and were left deferred per instructions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
QualifiedNameShortener physically moved from Tool/Utilities to Core/Utilities
as part of the public Query API refactor, but its decomposition-tree entry
and legacy per-unit docs/reqstream/review-set were never updated to match:

- docs/design/introduction.md: moved the unit's decomposition-tree bullet
  from Tool's Utilities subsystem to Core's Query subsystem; added Core's
  Utilities/ folder to the source-tree map.
- docs/design/sysml2-tools-tool/utilities.md and
  docs/verification/sysml2-tools-tool/utilities.md: now describe PathHelpers
  as the subsystem's sole remaining unit, with a pointer to the new Core
  location.
- Deleted the orphaned Tool-side per-unit docs
  (design/verification/reqstream) for QualifiedNameShortener; moved their
  9 QualifiedNameShortenerTests.cs test-scenario write-ups into
  docs/verification/sysml2-tools-core/query.md.
- docs/reqstream/sysml2-tools-tool/utilities.yaml: dropped the duplicate
  QualifiedNameShortening requirement; requirements.yaml: removed the
  now-deleted file's include.
- docs/reqstream/sysml2-tools-core/query.yaml: added a new
  SysML2Tools-Core-Query-QualifiedNameShortening requirement tracing the 9
  unit-level tests (previously untracked after the old Tool-side
  requirements were removed).
- .reviewmark.yaml: removed the stale
  SysML2Tools-Tool-Utilities-QualifiedNameShortener review-set (now
  redundant with SysML2Tools-Core-Query, which already covers the unit's
  new location).

Verified: build.ps1 (367 + 551x3 tests) and lint.ps1 both green.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Malcolmnixon
Malcolmnixon merged commit 8151a57 into main Jul 21, 2026
9 checks passed
@Malcolmnixon
Malcolmnixon deleted the feature/public-query-api branch July 21, 2026 00:54
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.

1 participant