Skip to content

Print tool diagnostics to stderr without --json and point formats/help to the help topics - #102

Merged
Malcolmnixon merged 3 commits into
mainfrom
tool/stderr-diagnostics
Nov 4, 2026
Merged

Malcolmnixon merged 3 commits into
mainfrom
tool/stderr-diagnostics

Conversation

@Malcolmnixon

Copy link
Copy Markdown
Member

Pull Request

Description

Feedback from agents using the canvasnet tool: features that were ignored or unsupported looked like silent failures, and the per-format help topics were hard to find.

Diagnostics on stderr without --json

Before this change, render diagnostics (vl-*, scad-*, and so on) appeared only in the --json result. A plain canvasnet render printed wrote ... and exited 0. Now:

  • Each diagnostic is written to stderr as Unsupported: <code>: <message> or Warning: <code>: <message>, with the page, input or side in parentheses where there is one.
  • A Scad echo is written as ECHO: <text>; it was silent before too.
  • Output is capped at 20 lines of each kind, followed by ... and N more diagnostics (use --json for all).
  • --silent suppresses them, though --log still records them. With --json nothing is written to stderr, and the exit code is unchanged.
  • This applies to render/convert, the verbs, inspect, montage and compare.
  • Control characters are escaped in stderr output only: C0, DEL, C1, U+2028/2029 and the bidi controls, written as \uXXXX, with \n, \r and \t. A model therefore can't inject terminal sequences. The --json values are unchanged.

Example:

$ canvasnet render chart.vl.json -o out.png
wrote out.png (347x347 png, 8162 bytes) from chart.vl.json
Unsupported: vl-channel-shape: chart.vl.json:1:180 /encoding/shape: The 'shape' channel is not drawn by the 'line' mark; it is ignored.

Finding the help topics

  • canvasnet formats gets a Help column with each input format's topic, plus a footer pointing to canvasnet help <topic>.
  • formats --json adds helpTopic to each input; the six raster formats map to raster.
  • Every command's text help ends with a "See also" paragraph that names the help topics.

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

User and reviewer feedback: silent ignored features, and no supported-feature list found through formats --help.

Pre-Submission Checklist

Before submitting this pull request, ensure you have completed the following:

Build and Test

  • Code builds successfully and all tests pass: pwsh ./build.ps1 (46,035 tests, 0 failed). After the escaping fix, the Tool tests were re-run and pass. canvasnet --validate passes 16/16.
  • Code produces zero warnings

Code Quality

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

Quality Checks

Please run the following checks before submitting:

  • All linters pass: pwsh ./lint.ps1 passed

Testing

  • Added unit tests for new functionality:
    • Context output: format, cap, suppression by --silent and --json, and escaping.
    • Entry-point stderr tests for Vega-Lite, Scad and montage.
    • Every helpTopic resolves to a topic, and the footer and See-also lines are present.
  • Updated existing tests if behavior changed (golden formats JSON)
  • All tests follow the AAA (Arrange, Act, Assert) pattern
  • Test coverage is maintained or improved

Documentation

  • Updated README.md (if applicable)
  • Updated docs/ documentation (if applicable)
  • Added code examples for new features (if applicable)
  • Updated requirements.yaml (if applicable)

Additional Notes

The help topics (errors, json, scad, vega-lite, vsdx) are updated to match, and the help drift tests pass.

Malcolm Nixon and others added 2 commits November 3, 2026 20:16
Without --json, write each diagnostic of a successful command to standard error as 'Unsupported: <code>: <message>' or 'Warning: <code>: <message>' (with the page, input, or side when there is one), and a SCAD model's echo output as 'ECHO: <text>'. At most 20 of each are written, then a count. --silent suppresses them; --json writes none (standard output stays one JSON document); the exit code is unchanged.

Make the help topics discoverable: 'formats' lists the help topic of every input format (a Help column, and helpTopic in --json) with a footer that points to 'canvasnet help <topic>', and the help of every command ends with a See also line naming the topics.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
A model's echo text and the messages of diagnostics could carry ESC, NUL, or other control characters straight to the terminal. In text mode every control character, line or paragraph separator, and bidirectional control is now written as \\n, \\r, \\t, or \\uXXXX; --json values are unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 4, 2026 02:13

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.

🟡 Changes recommended

Several moderate issues remain, including missing stderr/entry-point coverage, lost input context in render and inspect diagnostics, and incomplete bidi-control escaping.

6 open issues
What changed in this PR

This pull request makes successful-command diagnostics visible in text mode while preserving JSON output, exit-code behavior, and suppression semantics. It also improves format discoverability through help-topic metadata and command-help guidance.

Changes:

  • Added centralized, capped, escaped stderr reporting for diagnostics and SCAD echo output across render, montage, inspect, and compare workflows.
  • Added helpTopic metadata, format-listing links, help footers, and “See also” guidance.
  • Added regression tests and updated user documentation, requirements, verification records, and design documentation.
File Summary
test/​DemaConsulting.CanvasNet.Tool.Tests/​ContextTests.cs Tests diagnostic formatting, escaping, suppression, and output limits.
test/​DemaConsulting.CanvasNet.Tool.Tests/​Commands/​RenderCommandVegaLiteTests.cs Tests Vega-Lite stderr diagnostics and JSON/silent behavior.
test/​DemaConsulting.CanvasNet.Tool.Tests/​Commands/​RenderCommandScadTests.cs Tests SCAD echo, diagnostics, and control-character escaping.
test/​DemaConsulting.CanvasNet.Tool.Tests/​Commands/​MontageCommandSourceTests.cs Tests montage diagnostic output and input/page context.
test/​DemaConsulting.CanvasNet.Tool.Tests/​Commands/​DiscoveryCommandsTests.cs Tests format help topics and command-help references.
src/​DemaConsulting.CanvasNet.Tool/​Context.cs Implements diagnostic output, escaping, suppression, logging, and limits. Moderate: U+061C is missing from the bidi-control escaping set. Nit: method documentation describes only successful renders rather than successful operations generally.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​RenderCommand.cs Emits render and convert diagnostics after text results. Moderate: passes a null origin, losing input context for PPTX/VSDX diagnostics.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​MontageCommand.cs Emits montage diagnostics with input and page context.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​InspectCommand.cs Emits inspect diagnostics after text results. Moderate: lacks entry-point coverage for diagnostic, --silent, and --json behavior. Moderate: passes a null origin, losing input context for PPTX/VSDX diagnostics.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​Help/​vsdx.json Documents VSDX text-mode diagnostics.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​Help/​vega-lite.json Documents Vega-Lite text-mode diagnostics.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​Help/​scad.json Documents SCAD diagnostics and echo output.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​Help/​json.json Documents diagnostic and format metadata in JSON results.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​Help/​errors.json Documents successful-command diagnostics and output limits.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​DiscoveryCommands.cs Adds help-topic metadata to input formats and listings.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​CompareCommand.cs Emits comparison diagnostics with side context. Moderate: lacks entry-point coverage for stderr output, suppression behavior, and threshold-failure ordering.
src/​DemaConsulting.CanvasNet.Tool/​Commands/​CommandRegistry.Help.cs Adds command-help “See also” guidance.
docs/​verification/​canvas-net-tool/​context.md Records context diagnostic verification cases.
docs/​verification/​canvas-net-tool/​commands/​render-command.md Verifies render-mode diagnostic output.
docs/​verification/​canvas-net-tool/​commands/​montage-command.md Verifies montage diagnostic output.
docs/​verification/​canvas-net-tool/​commands/​discovery-commands.md Verifies format help-topic and command-help behavior.
docs/​user_guide/​canvas-net-tool.md Documents text-mode diagnostics and format help discovery.
docs/​reqstream/​canvas-net-tool/​context.yaml Adds requirements for centralized diagnostic output.
docs/​reqstream/​canvas-net-tool/​commands/​render-command.yaml Updates render diagnostic requirements and verification links.
docs/​reqstream/​canvas-net-tool/​commands/​montage-command.yaml Updates montage diagnostic requirements and verification links.
docs/​reqstream/​canvas-net-tool/​commands/​discovery-commands.yaml Updates format metadata and help-topic requirements.
docs/​reqstream/​canvas-net-tool/​commands/​command-registry.yaml Updates command-help requirements.
docs/​reqstream/​canvas-net-tool.yaml Updates system diagnostic requirements and traceability.
docs/​design/​canvas-net-tool/​context.md Describes diagnostic output implementation. Nit: refers to WriteDiagnostics as applying only to successful renders. Nit: architecture model documentation does not describe the new stderr behavior or affected relationships.
docs/​design/​canvas-net-tool/​commands/​render-command.md Describes render stderr diagnostics.
docs/​design/​canvas-net-tool/​commands/​montage-command.md Describes montage stderr diagnostics.
docs/​design/​canvas-net-tool/​commands/​inspect-command.md Describes inspect stderr diagnostics.
docs/​design/​canvas-net-tool/​commands/​discovery-commands.md Describes format help-topic metadata and listing changes.
docs/​design/​canvas-net-tool/​commands/​compare-command.md Describes compare stderr diagnostics.
docs/​design/​canvas-net-tool/​commands/​command-registry.md Describes command-help topic references.

Review effort: Lite

…s tests

- render and inspect pass the input path as the origin of each note, as montage does (the page of a document is kept).
- Escape U+061C (ARABIC LETTER MARK), completing the Unicode Bidi_Control set.
- Say 'successful command' in the WriteDiagnostics summary.
- Entry-point tests for inspect, compare (including a failed threshold), and document diagnostics of render; regression tests for every bidirectional control.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings November 4, 2026 02:54

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.

🔵 Needs a closer look

The design documentation inaccurately limits WriteDiagnostics to successful renders, omitting its use by inspect, montage, and compare, so the documented scope does not match the implementation.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Low severity Update WriteDiagnostics design scope to cover all calling commands

docs/​design/​canvas-net-tool/​context.md:66

This design text still describes WriteDiagnostics as applying only to a successful render, but the changed method is also called by inspect, montage, and compare (including before a failed compare threshold is reported). Update the description to cover the command operations that use it, so the design artifact matches the implementation and the documented scope of this PR.

6 resolved since last review

Review effort: Lite

@Malcolmnixon
Malcolmnixon merged commit 739ce6f into main Nov 4, 2026
16 checks passed
@Malcolmnixon
Malcolmnixon deleted the tool/stderr-diagnostics branch November 4, 2026 03:43
Malcolmnixon pushed a commit that referenced this pull request Nov 4, 2026
Since #103 a shape on a line enables the point overlay, so it is drawn and no
longer reports vl-channel-shape; the #102 stderr tests (merged after #103 on a
stale base) relied on that diagnostic and failed on main.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Malcolmnixon added a commit that referenced this pull request Nov 4, 2026
…107)

Since #103 a shape on a line enables the point overlay, so it is drawn and no
longer reports vl-channel-shape; the #102 stderr tests (merged after #103 on a
stale base) relied on that diagnostic and failed on main.

Co-authored-by: Malcolm Nixon <Malcolm.Nixon@hiarc.inc>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Malcolmnixon pushed a commit that referenced this pull request Nov 4, 2026
Follow-up from the final review of #102.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Malcolmnixon added a commit that referenced this pull request Nov 4, 2026
…#104)

* Describe WriteDiagnostics as used by every command that reports notes

Follow-up from the final review of #102.

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

* Wrap the WriteDiagnostics line within 120 characters

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

---------

Co-authored-by: Malcolm Nixon <Malcolm.Nixon@hiarc.inc>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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