Skip to content

Implement export subsystem with CLI integration and tests#27

Merged
Malcolmnixon merged 6 commits into
mainfrom
feature/export-verb
Jul 11, 2026
Merged

Implement export subsystem with CLI integration and tests#27
Malcolmnixon merged 6 commits into
mainfrom
feature/export-verb

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

This pull request introduces the new export command to the SysML2 Tools CLI, enabling users to dump the resolved semantic model (declarations, edges, diagnostics) as JSON or JSON Lines for offline or AI-assisted analysis. The documentation, design, and review infrastructure are updated to cover this new feature. The changes also clarify the command-line interface and subsystem architecture.

Major feature addition:

  • Added the export command to the CLI, allowing users to export the resolved semantic model as a single JSON document or as JSON Lines, with options for output file selection and including the OMG standard library. The command is implemented by the new Export subsystem (ExportCommand, ExportResult, ExportResultSerializerContext, ExportLineSerializerContext). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]

Documentation and user guide updates:

  • Updated README.md to document the new export command, its options, usage examples, and integration into the general CLI interface. [1] [2] [3] [4] [5]
  • Updated ROADMAP.md to mark the export verb as complete and describe its implementation and use cases. [1] [2]
  • Updated docs/design/sysml2-tools-tool.md to include the Export subsystem in the architecture diagram and describe its integration and localization. [1] [2] [3] [4] [5] [6]

Review and verification:

  • Added a new review section for the Export subsystem in .reviewmark.yaml, specifying relevant code, tests, and documentation for focused review.

Malcolm Nixon and others added 6 commits July 11, 2026 15:31
- New Export subsystem: ExportOptions, ExportArgumentParser, ExportCommand,
  ExportResult (+ 3 JSONL line wrapper records), ExportResultSerializerContext
  (indented, JSON path), ExportLineSerializerContext (compact, JSONL path),
  ExportStrings.resx/.cs.
- ExportCommand loads a workspace, filters stdlib declarations/edges via a
  locally-replicated IsVisible helper (mirrors QueryEngine.IsVisible exactly;
  diagnostics are never stdlib-filtered), builds an ExportResult, and renders
  it as a single indented JSON document or as JSON Lines (one compact object
  per declaration/edge/diagnostic, tagged with a Kind discriminator).
- Wire export into CLI dispatch: SysmlCommand.Export enum value,
  GlobalArgumentParser export token recognition, Context.Export property +
  Create switch arm, Program.cs RunToolLogicAsync/help dispatch/top-level
  help, ProgramStrings TopLevel_CommandExport1/2.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add RunExportSelfTestAsync (loads the built-in self-test model, builds an
export result, serializes as JSON, asserts expected declarations are
present), wired into the sequential RunAsync call list, mirroring the
established RunLintSelfTestAsync/RunRenderSvgSelfTestAsync pattern. A single
JSON self-test is sufficient qualification evidence since JSONL shares the
same loading/filtering logic and its distinct wire shape is covered by
dedicated unit tests instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- ExportSubsystemTests.cs: ExportArgumentParser flag parsing/rejection,
  ExportCommand happy path (json/jsonl), stdlib include/exclude, --output
  file vs stdout, missing-files/no-match/invalid-format error paths,
  export --help.
- ExportRenderingTests.cs: JSON \ discriminator round-trips,
  SysmlEdgeKind round-trip, diagnostic field presence, JSONL line
  compactness/Kind-discriminator checks, and a full CLI end-to-end
  integration test (via Runner.Run) against the VehicleExample fixture,
  validating both JSON and JSONL output shapes.
- ExportTestFixtures.cs: RunExportAsync helper mirroring
  QueryTestFixtures.RunQueryAsync.
- ValidationTests.cs: coverage for the new SysML2Tools_ExportSelfTest.
- ResxResourceTests.cs: add ExportStrings to the resx bidirectional-parity
  theory data.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- New requirements/design/verification triple for the Export subsystem
  (docs/reqstream/sysml2-tools-tool/export.yaml, docs/design/
  sysml2-tools-tool/export.md, docs/verification/sysml2-tools-tool/
  export.md), mirroring query's triple structure.
- requirements.yaml: include the new export reqstream file.
- docs/design/sysml2-tools-tool.md: add the Export subsystem to the
  architecture diagram, dispatch description, and localization list.
- .reviewmark.yaml: new SysML2Tools-Tool-Export review-set entry mirroring
  SysML2Tools-Tool-Query's shape.
- README.md and docs/user_guide/introduction.md: new export usage
  examples, options table, and JSON/JSONL output-shape documentation.
- ROADMAP.md: mark the export verb done under 'Model query & analysis',
  keeping the other AI-analysis candidates (sarif/metrics/diff/uniform-json)
  listed as open.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…verification doc

Quality-retry fix for feature/export-verb (see .agent-logs/planning-export-verb-fix-b7c210.md):

- Add 7 Context_Create_ExportCommand_* tests to ContextTests.cs mirroring the
  existing Render/Query dispatch-level test blocks, closing the coverage gap
  that made export.md's Verification Approach claim about ContextTests.cs
  inaccurate.
- Add a ContextTests.cs subsection to docs/verification/sysml2-tools-tool/export.md
  describing the new tests, mirroring query.md's equivalent section.
- Weave Export into docs/verification/sysml2-tools-tool.md's existing prose:
  reference the eight per-subsystem verification docs in Verification Approach,
  and add an Acceptance Criteria bullet covering export's JSON/JSONL/
  --include-stdlib behavior with a cross-reference to export.md.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Code review of feature/export-verb found that 'export --output <file>'
had no error handling: an unhandled DirectoryNotFoundException or
UnauthorizedAccessException (e.g. --output pointed at an existing
directory, or a nonexistent parent directory) would crash with a raw
stack trace and a non-standard exit code, unlike every other
user-facing failure path in this tool.

- Create the parent directory of --output up front (mirroring
  'render's Directory.CreateDirectory guard for its --output
  directory), so a missing nested output directory now succeeds.
- Wrap the write in a try/catch for IOException,
  UnauthorizedAccessException, and NotSupportedException, surfacing
  failures via context.WriteError instead of an unhandled exception.
- Add regression tests: --output in a missing nested directory now
  succeeds and creates it; --output pointing at an existing directory
  now fails cleanly with a clear error message and non-zero exit code.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Malcolmnixon
Malcolmnixon merged commit 71b96a6 into main Jul 11, 2026
15 checks passed
@Malcolmnixon
Malcolmnixon deleted the feature/export-verb branch July 11, 2026 22:57
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