Skip to content

CLI: info and convert report what a damaged DWG left out (read notes, #859) - #2337

Merged
tanish2k09 merged 1 commit into
storytold:mainfrom
STE1200:cli-read-notes-2
Nov 2, 2026
Merged

tanish2k09 merged 1 commit into
storytold:mainfrom
STE1200:cli-read-notes-2

Conversation

@STE1200

@STE1200 STE1200 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Part of #1039. Redo of #1048 (closed after it went stale), rebased on main (26da98e).

A damaged DWG opens partially since #859, and the drawing's read_notes say what was left out. run and MCP open show the notes, but cadcraft-cli info and convert did not. @Rickpixell measured this again on v0.13.0 and main in #1039 (comment). On a damaged R12 DWG, convert wrote a DXF with 0 entities and printed only wrote out.dxf. info reported entityCount: 0 and skipped: {count: 0}. Both commands exited 0. A script using either command gets an empty drawing and no sign that anything was lost.

Changes

  • convert (apps/cadcraft-cli/src/main.rs): before writing, prints each read note on stderr as PATH: <note> (read_note_messages), next to the existing skipped-records warning (DXF: count the records the reader can't place; info reports them, convert warns #872). The exit code stays 0, the same as for skipped records.
  • info / drawing.inspect (crates/engine/src/cmd/inquiry.rs): new field readNotes holding the notes as strings (an empty array for a complete read), next to skipped. info prints drawing.inspect, so MCP inspect_drawing and the control channel get the field too. No existing field changes.
  • run and MCP open: unchanged. They already show the notes.
  • Docs: README.md (CLI section) and docs/control-protocol.md (drawing.inspect row).

#1790 contains the same change inside a larger PR. If #1790 lands first, I'll close this one.

Not in this PR (from the same measurement)

Test plan

  • apps/cadcraft-cli/tests/read_notes.rs: builds a 200-line R2000 DWG and damages copies the way Open damaged DWGs partially and say what was left out (acadrust 0.6.4, #800) #859's own test does (flipping bytes across the objects area) until one reads partially. This also gives the damaged 2000+ case that could not be produced by hand. info on that copy has exactly one readNotes entry. convert prints exactly one PATH: DWG: … couldn't be read and … line and still writes the copy. The intact DWG gives readNotes: [] and no warning.
  • Unit test read_notes_become_one_warning_each covers the message format.
  • cargo xtask ci: fmt, clippy, i18n, assets, layers and wasm pass; the workspace tests pass except text_double_click::double_clicked_text_takes_ime_composition_and_commit, which fails on my machine for a missing CJK font ("No glyph for 中", no CRAFT_FONTS_DIR) and is unrelated to this change.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Drawing-reader notes about unreadable records are now surfaced in drawing summaries and MCP responses. The info command reports skipped records and read notes, while run logs DWG notes.
  • Bug Fixes
    • convert now warns about drawing read notes before reporting skipped records, while still completing successfully and writing the converted copy when notes are present.
  • Documentation
    • Updated the README and control-protocol documentation to describe where read notes and skipped records appear.

@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 30c9f13 and 7dd73de.

Files selected for processing: 3
  • apps/cadcraft-cli/src/convert.rs
  • apps/cadcraft-cli/src/output.rs
  • crates/engine/src/cmd/inquiry.rs

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Walkthrough

Inspection output now includes drawing read notes. The CLI convert command emits path-prefixed read-note diagnostics before skipped-message diagnostics. Documentation and tests describe and verify these reports.

Changes: Read-Note Reporting

Layer / File(s) Summary
Expose read notes in inspection results
crates/engine/src/cmd/inquiry.rs, docs/control-protocol.md, README.md
drawing.inspect now includes readNotes. The protocol documentation and README describe inspection fields and read-note reporting.
Report read notes during conversion
apps/cadcraft-cli/src/output.rs, apps/cadcraft-cli/src/convert.rs, apps/cadcraft-cli/tests/read_notes.rs
The CLI formats read notes with a path prefix and emits them before skipped-message diagnostics. Unit and integration tests cover damaged and intact DWG files.

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Possibly related issues

Suggested reviewers: aiongg, dylanmtaylor

Merge Risk: Minimal · up to 7dd73

The read-note reporting changes are consistent across inspection, conversion, tests, and documentation, with no merge-blocking risk found.

Security architecture risk: Minimal · up to 30c9f

The change makes existing partial-read diagnostics visible without adding privileges, executable behavior, or a new entrypoint. Inspection remains read-only, and conversion retains its existing output and success behavior. No material security risk was identified in the reviewed changes.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The changed exposure is diagnostic metadata from the drawing already opened by the caller, delivered through existing inspection results and conversion stderr. The additions do not select another asset, create a network listener, or introduce a privileged operation.

Trust Boundaries and Controls

  • observed — Note text includes reader-derived counts and diagnostic record-type labels, including nonnumeric labels. The new code carries this text as JSON string values or literal-formatted stderr output; it does not use notes as executable commands, file destinations, or authorization inputs.
Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: reporting read notes from damaged DWG files in the CLI info and convert commands.
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@STE1200

STE1200 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Heads-up: #2268 (clap migration) splits apps/cadcraft-cli/src/main.rs into modules, including convert.rs, and this PR touches convert there. If #2268 lands first, I'll rebase this onto it and move read_note_messages into the new convert module. No need to hold either PR for the other.

@austin62jake

Copy link
Copy Markdown
Contributor

Thanks, a convert that writes an empty DXF and says only "wrote out.dxf" is easy to miss in a script. #2268 has landed now (5654240), so this conflicts with main as you expected. To check that the change still holds after the move, I ported it onto today's main f536bf4 locally. It is about ten lines: read_note_messages goes next to skipped_message in apps/cadcraft-cli/src/output.rs, and the loop goes into convert.rs. The inquiry.rs hunk applies unchanged.

What I ran on the port

  • cargo test -p cadcraft-cli --test read_notes passes, and so does the rest of cargo test -p cadcraft-cli.
  • On a damaged copy built the way your test builds one, convert to .dxf, .dwg and .png each print one line, <path>: DWG: 1 of 282 object records couldn't be read and was left out (APPID × 1); …, and exit 0. info lists the same note in readNotes, and an intact DWG gives [] and no warning.

One small thing for the rebase
run already prints the note on main, but without the path in front (DWG: 1 of 282 …), while convert now prints <path>: DWG: …. If scripts are meant to match these lines, giving run the same <path>: prefix would make the two consistent. That's optional and could be its own change.

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: the CLI info and convert report what a damaged DWG left out (read notes, #859). When reading leaves something out (records a DXF reader cannot place, object records of a damaged DWG), info reports it as skipped and readNotes, convert warns on stderr, run prints the DWG notes with its log, the exit code stays 0, and MCP open replies with the notes as warnings. A converter that silently drops objects makes data loss invisible, so reporting is the right thing, and keeping exit 0 matches the README. A script that wants to fail on loss would want a flag (--strict) to change the exit code. A test with a damaged file is the proof. The messages are catalogue-free and meant for the log. I have not run it, and no exact-head CI result exists for this head. Nothing was run.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

…torytold#859)

A damaged DWG opens partially since storytold#859 and the drawing's read notes
say how many object records were left out. OPEN echoes them and MCP
`open` returns them as `warnings`, but `cadcraft-cli info` and
`convert` stayed silent: a corpus round trip wrote thousands of skipped
records away without a word.

- convert: each read note goes to stderr as `IN: <note>`, next to the
  skipped-records warning (storytold#872). The exit code stays 0.
- drawing.inspect (and so info, MCP inspect_drawing and the control
  channel): new field `readNotes`, next to `skipped`. Existing fields
  are unchanged.
- run already prints OPEN's notes with the session log.
- README and docs/control-protocol.md say where the notes appear.

Part of storytold#1039.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@STE1200

STE1200 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for porting and running it, that saved a round. I rebased onto main 2034d68 the way you laid it out: read_note_messages now sits next to skipped_message in apps/cadcraft-cli/src/output.rs (its unit test moved with it), and the loop is in convert.rs. The inquiry.rs, README, protocol-doc and tests/read_notes.rs hunks applied unchanged. cargo test -p cadcraft-cli, cargo clippy -p cadcraft-cli --all-targets -D warnings and cargo fmt --check pass locally.

I'd rather keep this PR to info and convert and leave two follow-ups out of it:

  • run with the same <path>: prefix (thanks for spotting the mismatch). That's a one-line change, but it alters existing output, so it's better as its own PR.
  • --strict (from the review above), so a script can fail on loss through the exit code. That's a new option with its own docs and tests, and exit 0 stays the default as the README says.

I can open both after this one lands, if that's useful.

@austin62jake austin62jake left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. I merged it onto current main with six other PRs (#2620, #2337, #2117, #2028, #2022, #2006, #1976, #1759). cargo xtask ci passes: all 7 steps, 3166 tests.

info and convert now print the reader's notes, one warning line each, before the skipped-records line. So a damaged DWG's "3 of 10 object records couldn't be read… saving over the original would lose them" reaches a script on stderr instead of being silent. The new CLI tests and the unit test pin down the format.

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.

4 participants