Skip to content

Reject shape ids beyond u32 in shape.connect, sites and points - #847

Merged
skylartaylor merged 1 commit into
storytold:mainfrom
Silvertree2010:fix/h1767-shape-connect-and-shape-sites-po
Oct 16, 2026
Merged

skylartaylor merged 1 commit into
storytold:mainfrom
Silvertree2010:fix/h1767-shape-connect-and-shape-sites-po

Conversation

@Silvertree2010

Copy link
Copy Markdown
Contributor

Found while testing crates/engine/src/cmd/shape.rs:1154 (shape_id, used by connect/sites); same pattern at crates/engine/src/cmd/points.rs:358-359 and :432-433 (no existing issue): shape.connect (and shape.sites, points.* commands) truncate shape ids to u32, so an out-of-range id silently targets a different shape.

Cause

shape_id() in shape.rs and the target()/points() helpers in points.rs cast the id with as u32, which wraps modulo 2^32. An id like A + 2^32 therefore addressed shape A instead of being rejected, as id_param does.

Fix

shape.connect (from, to, id), shape.sites and the points commands (shape.points, shape.editPoints, shape.movePoint, shape.addPoint, shape.deletePoint, shape.pointType, shape.moveHandle) now read ids with id_param. An id that is not a valid u32 returns a 'not a valid shape id' error. I removed the shape_id helper.

Verified

  • Regression test shape_ids_beyond_u32_are_rejected_not_wrapped: fails on main without the fix and passes with it (cargo test -p deckcraft-engine --lib shape_ids_beyond_u32_are_rejected_not_wrapped).
  • cargo xtask ci passes.

Not changed

The id that shape.connect reads back from its own shape.insert call still uses as u32. The engine produced that id, so it is always in range. In-range ids and the selection fallback behave as before.

🤖 Generated with Claude Code

Found while testing crates/engine/src/cmd/shape.rs:1154 (shape_id, used by connect/sites); same pattern at crates/engine/src/cmd/points.rs:358-359 and :432-433

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@skylartaylor
skylartaylor merged commit acea4e3 into storytold:main Oct 16, 2026
1 check passed
@skylartaylor

Copy link
Copy Markdown
Member

Thanks @Silvertree2010! I checked the shape-ID validation, regression coverage, and green CI. This nicely extends the earlier #97 fix to the remaining shape commands without changing valid IDs. Merged!

anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
* Print: Windows lists its printers and spools jobs (storytold#756)

The Print dialog's printer list comes from Win32_Printer through PowerShell's
CIM (wmic is gone from Windows 11), and jobs are spooled by the embedded
windows_print.ps1: the in-box Windows.Data.Pdf renders each sheet at the
printer's own resolution and System.Drawing.Printing carries copies,
collation, duplex and colour as the job's settings. Both run through
powershell, so the Rust code touches no Win32 API. Fixes storytold#756, with the
printer-not-showing duplicates storytold#160, storytold#244, storytold#293, storytold#465 and storytold#644; CIM approach
from storytold#452. On CI a paused Generic / Text Only test printer catches the job in
its queue; a parser test keeps the script valid PowerShell.

* Print: fix the Windows await helper and render the job on CI (dry run)

Real-machine testing found [System.WindowsRuntimeSystemExtensions]::GetMethods()
failing with 'does not contain a method named GetMethods': GetMethods is an
instance method of [Type], so it is called with '.', the form the canonical
WinRT-await snippets use, not '::'. The first CI run missed it because the
end-to-end test skipped silently when the runner refused the test printer, so
the script had never actually run.

The script now honours PDFCRAFT_PRINT_DRYRUN=1: render every sheet with
Windows.Data.Pdf to PNGs in the temporary folder and print nothing. The test
runs that half unconditionally, so CI exercises the whole WinRT path —
projection, await helpers, render — on any machine, while the paused-printer
half stays best-effort and prints why it skipped. Win32_Printer enumeration
asks only for Name and Default, so a machine with nine printers waits less.

* Tests: the find-options wait in the viewer test is a deadline too

4280f83 converted the frame-count waits in this test to deadlines after the
same 12-of-15 race under a full workspace test run, but left the first wait —
the one for the 'page' matches — on the old 60-frame loop, and it flaked the
same way on PR storytold#847's CI. Same fix: wait up to 20 s for the 15 matches, then
assert.
anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
…w-up to storytold#847) (storytold#1007)

* M10: Windows printing prints at actual size, off the UI thread (follow-up to storytold#847)

- Sheets print at 100% on the driver's paper closest to their size, landscape
  when wide, instead of being shrunk into .NET's default 1-inch margins
  (about 76% on Letter) and never rotated. Each sheet is capped at ~64 MP so a
  poster-sized sheet can't exhaust memory.
- PowerShell runs with CREATE_NO_WINDOW: the release app has no console, so
  Windows opened one over the app for the whole job.
- The Print dialog lists printers in the background (the desktop app's
  printer_source) and spools jobs on a worker thread, so Ctrl+P and long jobs
  no longer freeze the UI. A list arriving late preselects the default only if
  the user hasn't picked a printer.
- Parity evidence named a test that storytold#847 renamed; xtask parity passes again.
  The raster-only limit is now stated in the parity notes and README.

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

* M10: refresh catalog hashes in ATTRIBUTION.toml for the new print strings

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
…old#1064)

The parity and roadmap docs were last refreshed before a batch of fixes
merged, so they still described closed issues as open problems.

- storytold#774 (encrypted output rejected by Acrobat, fixed by storytold#836): gap 1
  removed from gaps.md; its remaining interop-suite work moved to gap 12.
  Gap numbers are kept so existing "gap N" references stay valid.
- storytold#756 (Windows printing, storytold#847): Printers row, Print area and roadmap
  rank 1 now name web printing as the remaining gap.
- storytold#740 column select (storytold#765), storytold#759 1:1 touchpad scrolling (storytold#868),
  storytold#810 Shift-Cmd-G (storytold#835), storytold#825 (storytold#822).
- storytold#844 multi-object move (storytold#907): marked partial, same page only.
- storytold#799, storytold#800, storytold#807, storytold#809, storytold#811, storytold#815-storytold#819, storytold#821 (incl. the storytold#816 panic):
  gap 6 and the area tables list them as fixed.

Scores, readiness percentages and the stage are not re-judged; only the
rank-0 estimate drops by gap 1's 8-15 h (40-70 -> 32-55).

Co-authored-by: Brandon Thomas <echelon@gmail.com>
anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
)

`powershell_command` passed the bare name "powershell" to
`std::process::Command::new`. On Windows, Rust resolves a bare name in the
directory of the running executable before System32
(https://doc.rust-lang.org/std/process/struct.Command.html, "Platform-specific
behavior"), so a powershell.exe sitting beside a portable pdfcraft.exe ran
instead of Windows PowerShell, for every printer list and every print job.
Seen in Windows Sandbox against bbbe600 with a harmless stand-in exe: the
Print dialog listed the stand-in's output as the printer and Print "sent" to
it.

Name it by its full path under %SystemRoot%, the way `open_printer_preferences`
already names rundll32 in the same file. The same Sandbox test against this
build: the stand-in beside the app never runs, the real printer is listed and
the job spools.

Regression test: `windows_starts_powershell_by_its_full_path` (red with the
bare name, green with the fix). Not in any release yet: storytold#847 is on main only.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
 follow-up) (storytold#1123)

* M10.5: Restore architectural paper presets and PDF scale controls

Port the missing paper catalog and scale controls from PR storytold#599 onto the merged Windows printing implementation. Keep the spooler and background discovery from storytold#847/storytold#1007. Document the feature-by-feature audit and verification limits.

Assisted-by: OpenAI Codex

* Drop the provenance write-up and the screenshot example (the kittest covers the dialog)

* Refresh catalog hashes

---------

Co-authored-by: Brandon Thomas <echelon@gmail.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