Implement export subsystem with CLI integration and tests#27
Merged
Conversation
- 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>
This was referenced Jul 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces the new
exportcommand 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:
exportcommand 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 newExportsubsystem (ExportCommand,ExportResult,ExportResultSerializerContext,ExportLineSerializerContext). [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12]Documentation and user guide updates:
README.mdto document the newexportcommand, its options, usage examples, and integration into the general CLI interface. [1] [2] [3] [4] [5]ROADMAP.mdto mark theexportverb as complete and describe its implementation and use cases. [1] [2]docs/design/sysml2-tools-tool.mdto include theExportsubsystem in the architecture diagram and describe its integration and localization. [1] [2] [3] [4] [5] [6]Review and verification:
.reviewmark.yaml, specifying relevant code, tests, and documentation for focused review.