Repository navigation
Conversation
|
A question about the shared module for links to other design files that this plan mentions: I'm working on linked parameters (#5354), which needs the same helpers. A review on Discord Is that move already part of this branch? If it is, I'll wait for it and import from it. If not, |
|
Thanks @CarelT, and good timing. The move isn't on this branch yet: it's step 5 of the plan, and nothing for it is written. Please do open the small PR for the move alone, with no change in behaviour. I'll build on it here, and so can #5113 and #2349. The second part, one way of opening a linked design that reports its state and the reason, with one set of state words, could follow as its own PR on top. Whoever needs it first can take it, and I'm happy to review either. |
|
Thanks @CamWight! Here it is: #5420 moves I'd like to take the second part next, since linked parameters (#5355) already needs it: one way
I'll open it as its own PR on top of #5420. Thanks for offering to review! |
91f4735 to
088ce83
Compare
088ce83 to
cef6b58
Compare
|
Review of the K2 record at Drawing::from_json limits the incoming text, but to_json has no output-size check. A concrete input is the following prefix, then exactly 2,000,000 zeros separated by commas, then This is 4,000,194 ASCII bytes and satisfies the record checks. With the locked serde_json formatter's two-space indentation, the array elements alone occupy at least 21,999,998 bytes in the saved output, exceeding 16,777,216 before counting the rest of the record. The next Could the read/write budgets guarantee that every accepted, successfully saved drawing reopens, without truncating preserved properties? A compact-input → save → reopen regression crossing the output limit would cover this case. If a save cannot fit the budget, it should return an explicit failure before a future container/file writer publishes it. This is independently verified source inspection and byte arithmetic, not an executed Rust or UI reproduction. K2 has no file-writing UI yet, so I am reporting a library round-trip defect, not observed user-file loss. The separate border-profile/layout checks match the documented contract and are not another finding here. |
…abs#3890) from_json reads at most MAX_DRAWING_BYTES (16 MiB), but to_json had no limit. Other tools' properties are kept as they came, and indenting them can grow a drawing read in at about 4 MB past 16 MiB (two million zeros in one array), so the next read refused what the save had just written. 0xlillith found it in review of tangency-labs#3891. to_json now returns a Result and refuses JSON longer than a read takes ("drawing too large to save (at most 16 MiB)"), so every drawing saved opens again. Nothing writes drawing files yet, so the error reaches the future file writer before it publishes anything. Test: that case is refused, and a smaller compact drawing saves and reopens unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cef6b58 to
4f7fcf4
Compare
|
@0xlillith, thank you, confirmed and fixed in 4f7fcf4. Your exact case is the regression test: 2,000,000 zeros read in, then refused on save. A smaller compact drawing saves and reopens unchanged. The gate passed on it (fmt, clippy, tests, assets, layers and wasm) apart from three Windows-only failures |
drawing.open now joins doc.open in the suggestion for `file.open`, as the rule says: both end in the same word. The engine's and the CLI's tests check that doc.open comes first and let other close ids follow, as the `solid.extrud` line beside them already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
72dfdb5 to
36cf48a
Compare
…d machine B Records what changed since session 1: upstream merged tangency-labs#4817, tangency-labs#3877 and tangency-labs#2457 into the drawings branch overnight and force-pushed tangency-labs#5867, so section 6 is rewritten around the stack as it is now. Adds machine B (the Mac), its build caps after it was overloaded, and the owner's decision still open on tangency-labs#3891. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… PNG) Paper scene dashes plus the PNG writer, which includes tangency-labs#7255's grid walk. Stacked on the drawings branch, not on tangency-labs#3891, so it is independent of the storage decision. Conflicts, both from dependency lists: - crates/io/Cargo.toml: kept both sides. Ours adds the cadmpeg FreeCAD/Rhino crates, theirs adds png and tiny-skia for src/paper/png.rs. - Cargo.lock: took ours and let cargo regenerate it, so only the two new io entries are added. cargo xtask licences --check passes: both crates were already in the workspace and in THIRD-PARTY-LICENSES.txt. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ands and storage)
The owner's decision on 2026-10-27: follow upstream's storage model rather than
the beta's D1. A drawing now lives inside the design's file ("bherbruck's
proposal, Cameron's choice, so the separate drawing file goes"), and DRAWING_EXT,
read_drawing, read_drawing_file, write_drawing_container, file_kind, FileKind and
is_drawing_path are gone with it. The beta's `.scdwg` plan and beta item 6 are
superseded. This also delivers most of Phase 2's "drawing session" and "records"
tasks as a merge instead of hand-written code.
Three commits: drawings saved in the design (472a330), ten drawing commands, with
each drawing keeping its own undo history (e0cb46c), and the unknown-command
tests (36cf48a). Three of the ten (list, inspect, properties) are .noundo().
20 conflict regions in 9 files, each combining both sides, because ours and the
branch changed different things in the same places:
- engine/src/lib.rs (8): Snapshot carries BOTH main's `visibility` and the
branch's `part`, and Snapshot::of fills in visibility. Session keeps
sketch_entry and feature_edit_sketch beside open_drawing. execute() takes the
branch's spec.allowed() (it calls spec.enabled inside, adding the Model/Drawing
gate) and keeps main's active_component/occurrence tracking and `replacements`.
The failure path restores open_drawing and keeps main's `hidden` check.
- doc/src/format.rs: keeps main's `check_design_numbers`, NOT the branch's
`DESIGN.check_numbers(&v, "metadata")`. They are not equivalent: main's also
caps user_materials and sends each physical_card through validate_card's typed
bounds. main's raw check runs before the design is decoded and
`check_typed_numbers` repeats it on the typed document afterwards, so the two
are a pair, not alternatives. The branch's `take_drawings` still runs first,
and drawings
keep their own family rule (DRAWING.check_numbers in doc/src/drawing.rs).
- engine/src/cmd/metadata.rs: the branch's shared `reading`/`setting`/`removing`,
which drawing.properties calls, but built on main's key table
(metadata::keys(Owner::Design)). WELL_KNOWN no longer exists in doc.
- engine/src/cmd/inspect.rs: main's newer params text and main's 2-argument
`checked!`, plus the branch's `.any_part()` on engine.commands and
engine.describe. DESCRIBE_CONTRACT is registered by `.contract(&…)`, which the
2-argument macro looks up, so the branch's 3-argument form is not needed.
- engine/src/cmd/file.rs: main's params text (it documents `overwrite?`) with the
branch's `.any_part()`.
- engine/src/cmd/edit.rs: the branch's drawing-aware go_to, keeping main's
display_only so undoing a hide still refreshes the display only. The guard is
now `if same { if display_only {…} else if moved {…} }`, so a drawing's change
evaluates nothing while a hide/show still repaints.
- engine/src/cmd/mod.rs: the branch's self.allowed(s) with main's
colored_components label and icon.
- io/src/design.rs: main's render validation and HDR resource blobs, with the
branch's drawings entries and `drawing::write`. encode_model keeps main's
3-argument form with writer.space(2, budget).
- ui-egui/src/agent_chat/tests.rs: the Snapshot literal takes both new fields.
Two follow-on fixes the merge needed:
- io/src/design.rs: tangency-labs#3891 inlines PackageWriter::new/finish and replaces
has_part with names(), and inlines open_regular_file/is_container_source. All
four removed helpers are byte-identical to the merge base, so main added
nothing to them and the inlining loses nothing; the inlined open path still
does vfs::check, two is_file checks and the MAX_DESIGN_BYTES cap. The
container version is read with limited_part, because main removed
PackageReader::part.
- engine/src/lib.rs: same_but_features destructures Document exhaustively, so
the new `drawings` field had to be decided on. It is ignored (`drawings: _`):
its only caller is solve_joints, joints never read drawings, and comparing
them would make every drawing edit re-solve the joints, against tangency-labs#3891's own
rule that a drawing's change evaluates nothing.
Checked on macOS (machine B) with the caps PROGRESS.md section 5 gives for that
machine, except RUST_TEST_THREADS=2 rather than 1:
- cargo check --all-targets on doc, io, engine, ui-egui, the app, the CLI and mcp:
clean.
- solidcraft-doc 466 passed, solidcraft-io 190 passed, 0 failed.
- The full solidcraft-engine --lib suite: 2595 passed, 3 failed. That run was on
the tree before the `drawings: _` edit; the joints tests and the three failures
were re-run after it.
- cargo fmt --check, cargo xtask lists, cargo xtask skills and
scripts/test-format-pending.sh pass.
The 3 engine failures are macOS platform divergence in the kernel, not this
merge: prism_local_tests::a_ring_cut_round_a_counterbored_hole_in_a_chamfered_disc
and robustness_goldens seeds 36 and 71. Seed 36 is proven: macOS produces the
WINDOWS golden to six decimals (area 9964.083286 against 9964.083285, faces 21,
edges 45, the same lumps error), while tests/robustness/goldens.json carries
overrides for windows only, so macOS falls back to the Linux-recorded shared
value. Neither failing test file was touched by any merge, crates/kernel and
crates/sketch are byte-identical to the base even with this merge staged, and
tangency-labs#3891 changes no geom, kernel or sketch code at all (it does change doc/src:
Document gains `drawings` and format.rs takes them out before the number check). The one geometry change in the base is tangency-labs#4817's rewrite of
Seg2::polyline through a new chords(); it is output-identical: the arc step's old
.max(1e-6) could never bind, because tol >= radius*1e-6 forces the step above
2.8e-3, and the other branches apply the same max(1e-9) once instead of per
branch. Recording macOS goldens is upstream's call, so none were blessed here.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Session 1 restored main's check_design_numbers after an auto-merge dropped it, and the drawings merge in this branch nearly dropped it again: upstream replaced it with DESIGN.check_numbers(&v, "metadata"), which looks equivalent but only skips `metadata`, while main's also caps user_materials and sends each physical_card through validate_card's typed bounds. Nothing tested it either time. The cap's value is that it runs on the raw JSON, before the design is decoded; check_typed_numbers repeats it on the typed document afterwards. A test with well-formed materials therefore passes either way. This one uses entries that are over the cap AND malformed, so the two orders give different refusals: - with the check in place: "exceeds 1000 user materials"; - with DESIGN.check_numbers instead: "invalid type: string …, expected f64", because the design is decoded first. Verified by mutation: swapping DESIGN.check_numbers back in makes this test fail with that serde message, and the fix makes it pass. It also carries a `drawings` key, so it covers tangency-labs#3891's take_drawings running in front of the check, and one in-cap design to prove the case is not vacuous. In format.rs's existing tests, not a per-bug file (tangency-labs#3226). solidcraft-doc 467 passed, 0 failed; cargo fmt --check clean. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…ll owes Records session 3: tangency-labs#7316, tangency-labs#6482, tangency-labs#7430 and tangency-labs#3891 merged, the owner's decision to follow upstream's in-design storage (so D1 and beta item 6 are superseded), and the regression test for the user_materials cap. New in this file: - BETA-BASE.md: every merged SHA in order, a Phase 1 item. - Section 6.6: the 10 drawing.* commands that owe contracts, and the 20 that predate this work. The coverage test passes (a missing schema is a warning today), and unconverted.txt must not gain lines. - Section 6.7: two integration gaps recorded, not fixed. Part::Model commands are refused while a drawing is open, and a drawing's properties are listed from the design's key table. - Section 8.6: the 3 engine tests that fail on macOS, with the evidence that they are kernel platform divergence rather than these merges, and the list of what a machine with more headroom still owes (wasm, the CLI test, engine clippy, and those three tests on Windows). - Section 5: engine tests always with --lib (building the 10 integration binaries is what crashed the Mac), RAYON_NUM_THREADS, the pgrep self-match that makes a wait loop spin forever, and that PIPESTATUS is empty in zsh. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…, W07 V2) Head cce39b4, stacked on tangency-labs#3891 (already merged here as 6926136), so only its own four commits come in: model extents on a plane (30906de), projected views in first or third angle (bedae91), measurement on view frames (cfa5602) and drawing.view.snapshot itself (cce39b4). 4 conflict regions in 4 files, each both sides adding a line in the same place, all kept: - engine/src/lib.rs, render/src/lib.rs: mod lines, kept sorted (drawing_view before easyprint; transmission before visual_style). - engine/src/schema/mod.rs: main's export of run_checked_as with tangency-labs#5867's pub(crate) use check::read. - engine/src/tests.rs: the hostile-parameter key list takes both sides' keys. The checked! mismatch: tangency-labs#5867's one call site used a 3-argument form (id, contract, handler). main's macro takes 2 and finds the contract through .contract(&CONTRACT), which the spec already has, so the call site is now checked!("drawing.view.snapshot", snapshot). No other 3-argument use exists. tangency-labs#5867's only deletions are geom drawing_view's require() and PARALLEL, which become pub(crate) for drawing_measure, so nothing is lost. Checked on Windows (laptop), 4 jobs, 2 test threads: - cargo check --all-targets on geom, doc, render, engine: clean apart from the two Windows-only dead-code warnings upstream main already has. - geom drawing 38, doc drawing 19, render visual_style 1, engine --lib drawing + schema:: 70, hostile_params_never_panic: all pass. - The three engine tests that fail on macOS pass here: prism_local_tests::a_ring_cut_round_a_counterbored_hole_in_a_chamfered_disc and robustness_goldens seeds 36 and 71. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ands tangency-labs#3891's ten commands (drawing.create, .list, .open, .close, .delete, .inspect, .set, .properties, .properties.set, .properties.remove) had no contracts, so the schema coverage test listed them among the commands without schemas (30 then, 20 now; the other 20 predate this branch). unconverted.txt is untouched: it only shrinks. - schema/drawing.rs: a parameters type per command, each key read the way its handler reads it and refused in the handler's words (the drawing id, `units`, `values` and `keys` through small readers, the text keys through `present`, so null is refused as the handlers refuse it), and the reply types: InspectResult (also what create, open and set return), ListResult, CloseResult, DeleteResult and the three properties results. - cmd/drawing.rs: each spec runs through checked! with .contract and .output, keeping its .params prose; the replies are built from the result types instead of json! literals, with the same JSON as before (the existing drawing tests pass unchanged). drawing.properties builds its reply from the same key table metadata::reading uses. - schema/drawing_tests.rs: the key lists, strict giving today's errors for the commands that need no drawing and, in a design with one open, for those that do, and every form of every command matching its output schema in warn with no warnings. engine --lib drawing + schema:: 74 passed (70 before plus the 4 new); fmt and lists pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
144 commits of main since this branch's base (2373414), merged after Phase 1 was finished, as the owner chose. 5 conflicting files, each both sides adding code in the same place, all kept: - doc/src/document.rs: tangency-labs#3891's differs_only_in_drawings, drawing and put_drawing beside main's differs_only_in_appearance. - doc/src/lib.rs: the assembly re-exports take both BomType and WorldNames. - engine/src/cmd/edit.rs: undo, redo and checkpoint keep tangency-labs#3891's .any_part(), so they work while a drawing is open; main's new edit.repeat goes between them unchanged (it is the app's command: the engine always refuses it). Both sides' helpers kept: repeat and its contract, latest, nothing, and tangency-labs#3891's fuller go_to doc. - engine/src/lib.rs: render_only_change accepts drawings-only and appearances-only changes, and its doc says both. - engine/src/schema/mod.rs: pub mod drawing, drawing_view and edit, sorted. One change git could not see: main's new doc/src/placement_reuse.rs names every Document field in same_geometry_inputs, so a new field needs a decision. drawings is compared like every other non-placement field. They never feed the geometry, so ignoring them would also be correct, but comparing keeps the function's rule, and at worst skips a reuse when a drawing and a placement change together (a drawing edit alone never evaluates: render_only_change). Checked for silent drops: across the 22 files both sides changed, every line main added is in the result, apart from the two rewordings above (the export list reflowed, the doc comment). check_design_numbers is still called and take_drawings still runs first. Checked on Windows (laptop), 4 jobs, 2 test threads: - cargo check --all-targets on doc, io, engine, ui-egui, mcp, the app and the CLI: clean apart from main's Windows-only warnings. - doc drawing + format + eval::cost_tests 96, io design + drawing + paper 71, engine --lib drawing + schema:: + cmd::edit + appearance 135: all pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Records the merge of upstream main (51f0c2d) on the laptop: - Status: Phase 1 done and main merged; next is Phase 2, starting from the exact view basis and view lines, since tangency-labs#3891 and tangency-labs#5867 already give the session, records and drawing.view.snapshot. - BETA-BASE.md row 10: upstream main 9fb41f8. - Section 6.9 marked done, with the placement_reuse.rs decision. - Session 4 log: the merge, its checks (doc 96, io 71, engine 135), and the launch of the merged app, where per-drawing undo works end to end; the dev build's leftover "Recover unsaved design?" prompt and why. - Section 8.6: the dev window now says v0.25.1, and the recovery prompt. - Fixes the links to the renamed section 6.6. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* Drawing sheets: sizes, the ISO 5457 border and its marks (tangency-labs#3875) (tangency-labs#5108) * Drawing sheets: sizes and the ISO 5457 border (tangency-labs#3875) A sheet is a paper size and an orientation: ISO A0 to A5, Letter, Legal, ANSI A to F, architectural A to E1, or a custom size (finite, above 0 and at most 5,000 mm a side), landscape by default and either way for every size. A border profile is the rule for its border, and layout() works it out for a sheet: the frame inside the margins, and the reference fields with their labels. The ISO profile has a 20 mm filing margin on the left and 10 mm elsewhere, a 0.7 mm frame, fields of 50 mm out from the centre lines with the corner fields taking what's left, rows lettered from the top without I and O (AA, AB and on past Z), columns numbered from the left, and an A4 sheet labelled on its top and right only. A profile can divide the frame equally instead, or have no grid. The records sit in geom, next to the section records, so saving, rendering and export can all use them. Nothing is saved or drawn yet: there is no command and no format change. Margins that leave no drawing space, values that aren't finite, fields outside 1 to 1000 mm, more than 200 equal fields and unknown JSON fields are refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: ISO 5457's centring and trimming marks (tangency-labs#3875) A drawing border profile now also holds the grid reference border and the centring and trimming marks, either of which can be left out. The ISO profile follows ISO 5457:1999 (read in its identical adoption, IS 10711:2001): - the grid reference border 5 mm outside the drawing border on every side, with the field labels between the two; - four centring marks on the sheet's centre lines, from the grid reference border to 10 mm inside the drawing border; - at each corner a trimming mark of two overlapping 10 x 5 mm rectangles, in the margin outside the grid reference border. The labelled sides are now a rule worked out for each sheet: ISO 5457's (the top and right of A4, all four sides of the others) or fixed sides. So one profile labels every size correctly. validate() checks what doesn't depend on the sheet, for when a profile is read; layout() calls it, then checks the rest against the sheet. Refused: - a grid reference border that isn't finite, is negative or is wider than a margin; - a centring mark that isn't above 0, would reach past the sheet's centre lines, or is on a drawing border those lines miss; - a trimming mark that isn't above 0, is wider than it is long, is wider than the margin left outside the grid reference border, or is longer than half the sheet's shorter side. The grid rule's JSON is now externally tagged ("none", {"from_centre": {"field_mm": 50}}), as the sheet size is, so an unknown field is refused in every form; the internally tagged "none" ignored one. Nothing is saved yet, so the shape change costs nothing. The names follow the glossary, and ISO 5457's "drawing sheets": the module is drawing_sheet (was sheet, which means sheet metal elsewhere here), DrawingBorderProfile and SheetLayout (were BorderProfile and BorderLayout), sheet_border and drawing_border (were paper and frame), and Sheet::size_mm (was paper_mm). The first part of S1 is still a draft, so the renames are made here rather than in a commit of their own. The extra centring marks ISO 5457 asks for on sheets larger than A0 aren't here yet. Still nothing is saved or drawn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: a lighter built-in border, the filing margin a choice (tangency-labs#3875) Cameron's decisions after seeing the sheet in the app, 2026-10-23: - No trimming marks in the built-in profile: the filled corner blocks take a lot of ink. trimming_mark_mm stays, so a profile can still ask for them. - Centring marks stop at the drawing border: from the grid reference border to the drawing border, never into the drawing area (on A4 they crossed the tables). centring_mark_mm keeps its meaning, how far a mark reaches inside the drawing border, and now takes 0, the built-in value, as grid_border_mm already takes 0 for "on the drawing border". A mark of no length (a reach of 0 with no grid reference border) is refused. - Margins of 10 mm all round. ISO 5457's 20 mm filing margin on the left, for drawings that get bound, is a named choice: filing_margin, off when not given. On, it stands in for margins.left_mm, which is kept, and still checked, for when it's off again. The 20 mm is FILING_MARGIN_MM, and validate() and layout() both take the margins from one helper, laid_out_margins(). A3 landscape is now 400 x 277 at (10, 10), with eight 50 mm columns. With the filing margin it is 390 x 277 at (20, 10) again, the same as a 20 mm left margin set by hand. A profile with all three choices on (ISO 5457's full border) lays out exactly as the built-in profile did before, and the tests keep the old hand values for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Drawing W23a workshop plate oracle fixtures (tangency-labs#4950) (tangency-labs#4962) * test(oracle): reviewer-aligned parameterized workshop plate fixtures (tangency-labs#4950) Independent analytic W23 expected values and seven verified models, including four R10 corners and the 2 mm tangent top chamfer. Document accepted Drawing states and commit regenerated docs/oracle.md from successful workflow run tangency-labs#29 (90/90 pass). * fix(oracle): correct W23 chamfer centroid and clarify drawing session ownership * Paper scene: plain records of what is drawn on a sheet (tangency-labs#4890 A1) (tangency-labs#5513) geom::paper holds what a sheet shows as plain data: groups of strokes and fills, each group tagged with the object that drew it (an opaque id) and its kind, with one validation pass over a bounded record count. Seg2's checks and the coordinate rule move into profile.rs so section and paper share them, and drawing_sheet takes its side and line limits from paper, so each limit is written once. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: centring marks across the whole margin (tangency-labs#3875) (tangency-labs#5554) The built-in sheet's centring marks now run from the trimmed sheet's edge to the drawing border. From the grid reference border, as before, a mark was the same length as a grid field mark, and on A3 it sat on one (the sheet's centre falls on a field edge), so it no longer read as a mark once the grid reference border's outline is left out (Cameron, after the prototype on tangency-labs#3875). - DrawingBorderProfile.centring_mark_start: sheet_edge (the built-in's, and when not given) or grid_border (ISO 5457's figure 5); ISO's full border in the tests asks for grid_border. - A mark still needs a length: one that stops on the drawing border needs room outside it on the side it starts from, every margin for sheet_edge, the grid reference border for grid_border. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: no centring or trimming mark longer than the largest sheet's side (tangency-labs#3875) (tangency-labs#6410) A border profile capped every length at 5000 mm (the largest sheet's side) but two: a centring mark's reach inside the drawing border and a trimming mark's length. A file could give either a huge whole number, such as 18446744073709551615. The read's number check passes whole numbers, so the profile took it as 1.8e19 mm, and saving wrote it as a decimal the next read refused: a drawing that saved but didn't open again. K2's fuzz test of drawing files (tangency-labs#3890) found it. Both now take the cap the margins have, `MAX_SIDE_MM`, in `validate`, so the file is refused when it's read. Layout's own checks against the sheet are unchanged, so a 5000 mm mark still validates and is refused only on a sheet too small for it. Tests: the hostile-profile test refuses 5000.000001 mm and 1.8e19 mm for each mark, and takes 5000 mm on its own; 4 planted faults (each cap removed or made one short) are all caught. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Bill of materials types: phantom, reference, purchased and inseparable (tangency-labs#3874) (tangency-labs#5107) * Bill of materials types: phantom, reference, purchased and inseparable (tangency-labs#3874) A component's bill of materials type is a part property (`bom_type` in its metadata, set with component.metadata.set and read by component.metadata, as part_number is), so older releases keep it and no format change is needed. It isn't a design property: the Design Properties dialog doesn't list it and document.metadata.set refuses it. A word this build doesn't know reads as normal and is kept. assembly.bom counts by type: a phantom has no row and what it holds counts where it is placed, in the same rows as the same parts there; a reference counts nowhere, and nothing inside it does; purchased and inseparable components are one row, and in parts only an inseparable component's purchased parts are listed too. Rows of one part number but different types are different rows. Rows and children carry bom_type. With no types set the rows are as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Glossary: bill of materials and bill of materials type (tangency-labs#3874) The bill of materials types are a new idea, so the glossary gets their term, with the five types, and "normal" gets its fourth meaning in the table of words with more than one meaning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Bill of materials types: a plain line for each (tangency-labs#3874) The guide's table and the glossary entry say what each type is for in plain words: something you make, something just to group, something to use as a reference, something you buy, something made as one piece. The names stay the five standard ones. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Bill of materials: kits fold together only when their contents' types match (tangency-labs#3874) With group_children, two kits with one part number share a row when what they hold reads the same. That reading (kit_key) compared each child by part number and count, but not by its bill of materials type, though rows themselves are told apart by type. So a kit holding a made bolt and a kit holding a bought one, both KIT, folded into one KIT x2 row listing the first kit's bolt twice: the other type was lost, and which one depended on creation order. 0xlillith found it in review of tangency-labs#5107. kit_key now includes each child's type. Equal part number, type and contents still fold. Test: two KIT kits each holding a BOLT fold into one row of two; once one bolt is purchased they are two rows, each listing its own bolt. Planted fault (the type left out of the key): caught. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Drawing files: a drawing saved as a container or as plain JSON, never read as a design (tangency-labs#3890) (tangency-labs#7098) * File format families: drawings share the design format's versioning (tangency-labs#3890) The format code works for a family of files: its own tag, its own numbers and its own folder of change files, with one reading of a file's format, one refusal of a file a newer build saved and one upgrade for every family. Designs (solidcraft/N) are one family and keep everything they had: FORMAT and FORMATS are as they were, and pending_names, format_string, version_of and read mean what they did. Drawings (solidcraft-drawing/N) are the other, with format 1 as their first record and each later change one file in crates/doc/src/drawing/format/pending/, as design changes are. Nothing saved changes. A design tag never reads as a drawing's or the other way round, and a file that names no format is a design from before format strings, never a drawing. Every refusal names its family; a design's read word for word as before. A design listing a pending change this build doesn't have is now refused as a newer build's before its content is checked, as a newer number already was, so a newer build's fields never read as damage. The list reader is take_names(v, key, noun), the shape tangency-labs#4811 uses for its own list. For the maintainer, the release step changes: scripts/fold-format-pending.sh now folds every family that crates/doc/build.rs lists (FAMILIES), each into its own next number: designs into crates/doc/src/format/v<N>/ as before, drawings into crates/doc/src/drawing/format/v<N>/ from 2. With nothing pending in a family it says so and moves nothing. Its test folds a drawing change into v2 beside the design changes. docs/releasing.md, CONTRIBUTING.md and AGENTS.md say so. build.rs lists each family's changes from its own folder, each folder's versions contiguous from its own base. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing record: format 1 of the drawing family (tangency-labs#3890) A drawing is now a record of its own (crates/doc/src/drawing.rs): its name, the designs it draws (sources: an id and the design file's path, relative to the drawing's folder as a linked design's is), its properties under the design metadata's rules, its units (each design's own, or one length unit of the expression unit table), its content language (a BCP 47 tag) and its sheets. A sheet holds its paper, a copy of its drawing border's profile, the resolution its pictures are rendered at (300 dpi unless it says, 25 to 2400), the component it documents and whether it is left out of the sheet count or of printing. This is format 1 of the drawing family; each later kind of record adds one file in crates/doc/src/drawing/format/pending/. The rules: one id counter for every object, raised above the largest id when a file is read and never rewound; every reference is an id that must resolve, or the file is damaged and refused, never patched; 1 to 1,000 sheets, at most 64 sources, names of 1 to 256 bytes, paths of 1 to 4,096 bytes without NUL. The same drawing always saves as the same bytes. Drawing::from_json reads at most 16 MiB of text, then runs the family's format check, the number check, the upgrade, the typed record (unknown fields refused everywhere) and Drawing::validate. The number check is now one function every family calls, Family::check_numbers, told which field holds other tools' data; a design's refusals read as before. Nothing saves or opens a drawing yet: the container is the next step. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing ids: random and collision-free from format 1 (tangency-labs#3890) A drawing's objects now take random ids, the form jyviko chose on tangency-labs#3890 from tangency-labs#1017: no counter, so objects added on two branches never share an id and never edit one line. The allocator is one module for drawings now and designs later (tangency-labs#626 Phase 3), crates/doc/src/ids.rs: an IdSource gives nonzero u64s by splitmix64 from a seed, each checked against the ids in use and drawn again when it is one, or when it is 0. A run never draws a number twice, so at most one draw per id in use comes before a free one, and a seeded run over a file the same seed made still gets a new id. IdSource::seeded gives the same ids for tests and replays; IdSource::from_entropy seeds a session from the standard library's hash keys, the time and a count, with no new dependency. In a file an id is 13 characters of Crockford base32, lowercase (0000000000001 to fzzzzzzzzzzzz): ids::encode writes it and ids::decode reads only that spelling, case-sensitive, so an id has one form to search for. Anything else, 0 included, makes the drawing damaged. The drawing loses next_id (a file that holds one is refused), and Drawing::new and allocate_id take the IdSource. Messages name ids as the file writes them. The component a sheet documents stays its design's own number until designs move over. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing record: a drawing too large to reopen isn't saved (tangency-labs#3890) from_json reads at most MAX_DRAWING_BYTES (16 MiB), but to_json had no limit. Other tools' properties are kept as they came, and indenting them can grow a drawing read in at about 4 MB past 16 MiB (two million zeros in one array), so the next read refused what the save had just written. 0xlillith found it in review of tangency-labs#3891. to_json now returns a Result and refuses JSON longer than a read takes ("drawing too large to save (at most 16 MiB)"), so every drawing saved opens again. Nothing writes drawing files yet, so the error reaches the future file writer before it publishes anything. Test: that case is refused, and a smaller compact drawing saves and reopens unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing files: a drawing saved as a container or as plain JSON, never read as a design (tangency-labs#3890) K3 of the drawing storage plan (W11.2): the file a drawing is saved in. Nothing writes one from a command yet; opening and saving come with K5. - A drawing container is a design container holding `drawing.json` (Deflate, as `document.json`) in place of `document.json`, and `container.json` says so: {"content": "drawing", "format": "solidcraft-container/1"}. A design's `container.json` is as it was, with no `content`. The plain JSON form is the drawing's own text. Both give the same bytes every save, so a drawing can live in version control as text. - `io::file_kind` tells a design from a drawing by `container.json` or by the JSON's format. The design reader refuses a drawing ("this file is a SolidCraft drawing, not a design: open it as a drawing") and the drawing reader a design; plain JSON only asks when it isn't a design, so reading a design costs nothing more. A container's content this build doesn't know, or a drawing container that also holds a design's `document.json`, is refused. - `read_drawing` (bytes, either form), `read_drawing_file` (one seekable handle, the design reader's checks) and `write_drawing_container`; `DRAWING_EXT` (`scdwg`) and `is_drawing_path` beside the design's. - The container writer's set-up and finish, the file opening and the container sniffing move into one function each, which designs and drawings both use. The container's own checks (budgets, entries, the ZIP directory) are the design container's, word for word. Tests: a drawing round-trips through both forms byte for byte, and the container holds exactly `container.json` and `drawing.json`; `file_kind` on both forms of both kinds; each reader refuses the other's file; unknown content, a stray `document.json`, a missing drawing, an unknown container version and a damaged drawing refused; both forms from disk, and a directory refused; mutation fuzz of both forms (an error or a drawing, never a panic). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Paper scene: SVG of a sheet, its lines, arcs, cubics and fills (tangency-labs#4890 A3a) (tangency-labs#7032) The first export of a paper scene, as SVG first (jyviko and 0xlillith on tangency-labs#4890), from the research in the plan's §16. A3b adds ellipses, hyperbolas and Béziers above degree 3, which this refuses as "not supported yet". - `geom::paper::Prepared`: writers read a scene through `Scene::prepare`, which checks it first, so none reads one unchecked. Clipping goes there too, once (A8). - `geom::paper::arc_pieces`: an arc's ends in pieces of at most a quarter turn, the last its own end. A half turn drawn from its ends is ill-conditioned: rounded to the nanometre (six decimals of a millimetre) its centre moves up to 1e-2 mm, where a quarter turn's stays under 1e-6 mm. - `io::paper::paper_svg`: one user unit a millimetre, the size in mm on the root; y flipped by writing the height less y, so the file's numbers are page coordinates and an anticlockwise arc has sweep flag 0; lines `L`, arcs `A` (never large-arc), cubics `C`, parabolas `Q`; fills black and even-odd; one path per item; groups as `data-object` and `data-kind` (object ids can't be XML ids). No background, so cutters see only the marks. - Numbers are whole nanometres (six decimals of a millimetre): no exponent, no "-0", the same bytes every time. They are the writer's own state too, so a joint is written once and a closed path ends exactly on its first point. Numbers are written straight onto the document, with no text made per number. A width under half a nanometre is written as one, and a piece too short for the grid is merged into the next, both counted in the report; a path's last piece has no next, so it is kept however short (unless it has no length). Output over 64 MiB is refused. Tests: the A3 drawing border's whole document; quarter, 270°, clockwise and whole-turn arcs, and a circle of two halves giving the same four quarters; the quarter-turn boundary both sides; cubics and parabolas, and the conics refused; the number format; a closed path whose start and end round apart; a sliver merged; an open path's short last line and arc kept, and one of no length dropped; read back through our own SVG reader (lines exactly, the arc as an arc); the scene's JSON mutated into the writer (never a panic). Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Drawing W17a: view definitions as data (tangency-labs#4816) (tangency-labs#4817) * claim: tangency-labs#4816 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views as data: named views, scales and the map onto paper (tangency-labs#4816, W17a P1) What a drawing view is, before anything draws it (geom::drawing_view): - NamedView: the six principal views and the isometric views from the four upper corners, each an exact basis (a Plane whose normal points back at the viewer), never taken from a camera, whose pitch clamp would tilt a top view, with no -0 to write out; `iso` reads as the front-right one. - basis_looking: any other view from its direction, an up and an origin (paper x = direction x up, paper y = x x direction), refusing a zero direction, an up along it, or an origin that isn't finite or within 1e12 mm. W07's {direction, up, origin} view reads through it. - Scale: paper : model as two positive numbers, read and written as "1:2", from 1:100000 to 1000:1; Scale::fit picks the largest ISO 5455 preset (50:1 to 1:10000) at which a view fits a space (W07's "fits the page" default), compared as size x paper <= room x model so an exact fit at a reduction isn't lost to rounding. - ViewFrame: a view's basis, scale and place on paper, the point of its plane at `centre` landing at `position_mm`. Its paper map moves the view's curves and their accuracy onto paper (paper error = scale x model error); `boundary` maps a box of its plane onto paper from its four corners. In geom, where Seg2 lives: - Similarity2 and Seg2::similar (new): scale, turn and shift a segment exactly, an arc staying an arc. Similarity2::new refuses a scale that isn't above 0 and works the turn out once, not per point; - Seg2::map_controls: a segment's control points mapped by any function. It was doc's sheet::map_controls; its four callers in doc use the method now, unchanged. CurveAccuracy::scaled gives a curve's accuracy at another scale. Tests: each named view's basis and viewer side, and the same bases from a direction and up; a 50 mm cube in every principal view at 1:1 and 1:2, and in isometric (edges 50 x sqrt(2/3), outline 50 x sqrt(2)); the view's centre on its position (W07's 100 x 20 front view on A3 at 2:1); scales read, written and refused; the fitted scale, an exact fit at 1:5 and ISO's smallest; no -0 in any named view's axes; an origin refused by its own message; hostile bases, centres and positions; every segment kind moved by a similarity, and the similarities refused; scaled accuracy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: the bottom view pinned, square near parallel, bounded scales and boxes (tangency-labs#4816) From DevonHope's review of tangency-labs#4817: - The tests pin all six principal views exactly. The direction-and-up test uses literal ups, so a bottom view turned half round now fails it. - basis_looking squares x to the direction before normalising. Near the 1e-9 threshold the normal was up to 8.8e-9 rad off; now it is about 1e-16. - Scale::fit fits nothing for a size or room that is negative or not finite. A size of 0 still sets no limit that way. - Each side of a scale is 1e-6 to 1e6, so a scale writes at most 49 characters. - ViewFrame::boundary returns a Result. It refuses a box that is inside out or not finite on paper, instead of dropping a corner. - paper_map, boundary and seg_to_paper say which coordinates they take. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Drawing W18 S2: title blocks as data (tangency-labs#3875) (tangency-labs#3877) * Title blocks: what a cell shows and where its text goes (tangency-labs#3875) geom::cell holds a title-block cell's content: parts of text and fields (component, drawing, sheet, revision or prompt, by key, with an optional unit and decimals kept as written for the resolver to check), at most 64 parts and 4096 bytes of text, with no control character but a line break. Beside it are a resolved value (live, overridden and drifted, or missing, with "-" for each part that couldn't be read and why), an override with the value it replaced, and the projection a drawing's views use (first or third angle), which the title block's symbol will read. A fit warns and never cuts: a count of characters, not bytes, with its own count for text in Chinese, Japanese, Korean or Yi characters. The cell text rule places a label and a value: the label's baseline 1 mm plus its cap height below the cell's top, the value box under it inset by 1 mm, one line centred in the box, and wrapped or several lines down from its top at the font's pitch, with a warning when the last falls below the box. Wrapping by width, width warnings and glyphs a font lacks need the text measured, so they wait for the paper scene's text. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Title blocks: definitions and their place on a sheet (tangency-labs#3875) geom::title_block holds a title block's definition: its size (1 to 1000 mm a side), its outline and cell line widths, and up to 64 cells. Each cell has a snake-case name of its own, a rectangle measured from the block's lower-right corner, an optional one-line label with its cap height, and a value: text from cell content, with its cap height, alignment and fit, or the projection symbol, which reads the drawing's projection and is never fixed in the block. validate() checks a definition on its own, as when one is read: cells inside the block and not overlapping (touching is fine), label and value cap heights that fit, and the content's own limits. layout() puts the block on the drawing border's lower-right corner of a sheet, refusing one that doesn't fit, and gives each cell's rectangle, its label's place and its value box by the cell text rule. On A3 landscape a 180 x 54 mm block runs from (230, 10) to (410, 64); it fits A5 landscape and every larger sheet, but not A5 upright. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Cell text: a value box lies within the paper's coordinates (tangency-labs#3875) place_lines took any finite, ordered value box, but centring one far out (min x 1e308, max x 1.1e308) overflows: the anchor came back infinite, with no warning. 0xlillith found it in review of tangency-labs#3877. The paper scene already bounds every coordinate it holds by MAX_COORDINATE_MM (twenty times the longest sheet side). That limit is now public, and place_lines keeps its box inside it, so its anchor is always finite: one rule for what a paper coordinate may be. Tests: the hostile-box test refuses both overflow cases from the review and a box just past the limit on each side, and places lines in a box the size of the whole paper limit. The fuzz test's numbers now include values past the limit (1.1e5, ±1e308). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Title blocks: padding from the lines' inner edges, one label rule, nothing unread (tangency-labs#3875) A cell's text is padded from the inner edge of its lines: each side of a cell moves in by half the line drawn on it (the outline's on the block's edges, a cell line's inside), so a wide outline never covers the text. Before, the padding ran from the line's centre. The label's one-line rule lives with the cell text rules (`cell::check_label`), where parts lists will find it. The cell types nothing read yet (`Override`, `Resolved`, `State`, `Problem`, `Reason` and `MISSING`) wait for the resolver that will read them. The tests check the exact thresholds inside the lines (a label that leaves no room, a value that just fits), pick each of the lines, alignment and wrapping on their own so every combination comes up, and lay fuzzed blocks out on every standard sheet, either way, with and without the filing margin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Title blocks: the drawing border's line, descenders, room where the block sits (tangency-labs#3875) From DevonHope's review of tangency-labs#3877: - Each cell's lines are clamped to the inner edge of the drawing border's line. That line runs along the block's right and bottom edges, and along any other edge it reaches, as when the block fills the border. Aabb2::intersection, the 2D twin of Aabb3's, does the clamping. - layout checks each cell's room again where the block sits (place_cells, which validate runs at the origin), so rounding at the real corner can't turn a cell inside out. - The cell text rule counts descenders, at 3/10 of the cap height (ISO 3098's lettering B). They may reach into the padding under a value box, never past it to a line. place_lines warns Height when they would, and validate asks it whether one line fits. - The module doc no longer links to a private function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> * Drawing W06a: exact orthographic hidden lines for the analytic subset (tangency-labs#2455) (tangency-labs#2457) * Drawing W06a: exact orthographic hidden lines for the analytic subset (tangency-labs#2455) crates/geom/src/hlr (L0): prepare once per body, then hidden_lines for a scene of placed bodies. Edges and face silhouettes are projected from their exact curves, split where projections cross, and each piece is classified by rays toward the viewer against the trimmed faces: visible, hidden or explicitly uncertain, never guessed. Planes, cylinders, cones, spheres and tori are supported whether stored as analytic records, revolutions or spline patches; freeform faces are reported and make what they could hide uncertain. Screen geometry is Seg2 with the W01a accuracy vocabulary: exact lines and conic arcs where the projection is exact, bounded chords otherwise. docs/drawing-hlr.md holds the contract and its limits. * geom/hlr: handle the brep records main gained in tangency-labs#3093 Main's exact model storage (tangency-labs#3093) added Curve::SurfaceIntersection, Surface::PlaneThrough and Surface::PlacedRevolution, and the HLR matches on the records no longer compiled. A plane through three points is a plane: it is trimmed and intersected as one, and a box stored that way draws the same bits as one with axis-stored planes. The procedural intersection curve and the placed revolution (whose affine placement may scale it unevenly) are refused by prepare as not supported yet, until the kernel adapter handles them. The records' positions move with the body's centre like the others. * geom/hlr: pad plane faces' boxes, so a plane record off by rounding still hides Plane faces took the box of their boundary chords unpadded, flat along the normal. When the plane record and its edges disagree by rounding (a unit cube's top plane one ulp above its edges, a 100 mm cube's 1e-11), the ray toward the viewer reached the plane just outside that box, the slab test culled the hit, and the back edges came out Visible with no doubt. Every face's box is now padded by 1e-6 of its size, as curved faces' boxes already were. Reported by DevonHope on tangency-labs#2457. * geom/hlr: limits from review: trim samples, scene extent, crossing pairs, surface groups From DevonHope's review of tangency-labs#2457: - Options::trim_samples must be 1 to MAX_TRIM_SAMPLES (4096). - Placed bodies must stay within MAX_COORDINATE (1e12 mm, as section and brep bound stored numbers). Placements 1e200 apart made the scene's size infinite and every tolerance taken from it with it, so everything came out Visible. - The crossing search counts its candidate pairs before it starts and meets each pair only in the first grid cell the two segments share, instead of keeping a set of the pairs met, which could outgrow wasm's 4 GB before the 500 million pair budget tripped. The same pairs in the same order. - prepare groups faces on one quadric or torus by comparing each face with the faces of its kind whose size agrees to the tolerance (sorted), not with every face; at most 50 million comparisons. prepare_cancellable polls a cancel callback between edges, faces and comparisons. * geom/hlr: boundary chords on a grid, and no fine pass over coincident curved chords The cost items of DevonHope's review of tangency-labs#2457: - Every ray hit asked how far it lies from its face's boundary by scanning all of the face's chords (4096 per circle; a plate's face with 256 holes has about a million). The chords are now bucketed on a uniform grid over the boundary's box, cells at least as long as the longest chord, and the test looks only at the cells around the point. It finds exactly the chords the scan finds. - Chords of two curved curves that lie on each other end to end (aligned holes seen along their axes) were cut into 16 by 16 pieces and intersected, to find crossings that are only noise within the curves' tolerance. They are now skipped; visibility changes where a coincident run starts or ends, and chords that only partly overlap still find those. - Fixtures: a plate with holes, coaxial cylinders seen along their axis, and 300 placements. * geom/hlr: pad boxes by the body's coordinates too; coincident chords only to rounding Review of the previous commits found two holes: - The padding grew with the face's size, but rounding grows with where the body was modelled: a 0.001 mm cube 1e7 mm out, its top plane one step (1.9e-9 mm) above its edges, still had its hit culled. The pad now adds 1e-12 of the body's offset. - Two chords were taken for coincident when their ends lay within each other's sag, which in a coarse scene can hide real crossings: an arc can bulge across a line 1 mm off its chord twice. Only chords that coincide to rounding are skipped now; identical projections, the costly case, still are. * geom/hlr: coincident curves meeting at shared sample points do not cross Timing the review's scenes showed that skipping coincident chords was not enough: chords of two coincident curves also touch end to end at every sample point they share, and each touch was a crossing to refine and split at. 64 coaxial cylinders seen along their axis gave 8.3 million crossings (19 s), 64 cylinders one behind another along the line of sight 4.2 million (214 s; before these commits the crossing budget refused it). A touch at a shared sample point is now dropped when the two curves also coincide, to rounding, on both sides of it. Where a coincident run starts or ends one side differs, and the touch is kept. * geom/hlr: the own-face margin allows for rounding where a body was modelled The far 0.001 mm cube of the previous commit showed a second effect of records rounded at large coordinates: its top plane, one ulp (1.9e-9 mm) above its edges, hid the top edges themselves, because a ray leaving an edge met its own face 3.2e-9 mm along, past the own-face margin of 1e-6 of the face (1.4e-9). The margin now also covers 1e-14 of the body's offset (about 45 ulps of its coordinates), which only matters for parts far smaller than their distance from the origin. * geom/hlr: no parity test for a hit on the boundary, where it is uncertain anyway * docs/drawing-hlr: the fixtures of the review's second round --------- Co-authored-by: MateuszSychXpl <151755914+MateuszSychXpl@users.noreply.github.com> --------- Co-authored-by: CamWight <91156642+CamWight@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Benny1496 <163034806+Benny1496@users.noreply.github.com> Co-authored-by: Mateusz Sych <151755914+SychPL@users.noreply.github.com> Co-authored-by: MateuszSychXpl <151755914+MateuszSychXpl@users.noreply.github.com>
…on (Refs tangency-labs#3890) A sheet now keeps the views it draws and a copy of its title block, and a drawing says which projection its views are drawn in. The format change is the one file the rule asks for, `drawing/format/pending/sheet-views.rs`, and it needs no step: a drawing from before it has no views and no block, and reads as first angle. The format number does not move either, because 2 is already the number pending changes are written under; what changes is that a drawing lists `in-design` and `sheet-views`. A view (`doc/src/drawing_view.rs`) holds what it draws, where its centre sits on the paper, which way it looks, and what it draws differently from the view it follows -- and nothing measured from the design, which `drawing.update` works out again. `extents_mm`, `lines` and `basis` are refused outright, so nothing can quietly cache them there later. Its style mirrors `ViewSettings` less the direction, each field optional, which is what that module's own note asked for. Two rules are worth stating. A projected view is turned from a *base* view of the same sheet, drawing the same component: a chain then cannot exist, so a reader has no walk to make and no loop to refuse on hostile input, and widening the rule later keeps every file that is valid today valid. A title block is checked by laying it out with the very code that draws it, which makes the border's layout part of reading the sheet: a sheet with a block has a border, and paper that border leaves no drawing space on is refused with a block and read without one. That second one failed `damaged_files_are_refused_and_never_patched` as soon as the fixture gained a block; the test now says it in both directions rather than being weakened. The projection default is first angle, which is what every other default here follows (ISO 5457's border, ISO 5455's scales, A3 paper). Nothing upstream settles it, and every drawing writes its own, so it is one line to change. Dimensions and notes are deliberately not here: a dimension record is its references, and Phase 3's Dimensions item is where those are specified, down to how a dangling one is reported. Both checklists in PROGRESS.md say so, and each will be its own pending file. PROGRESS.md also records that Phase 2's drawing session item needed no code -- tangency-labs#3891 is already in the branch -- and corrects four stale "uncommitted" labels. Verified one crate at a time at two jobs, because the full gate rebooted this Mac on 2026-10-28: `cargo fmt --all --check` clean; `cargo clippy -p solidcraft-doc` and `-p solidcraft-io --all-targets` silent (dev profile, no `-D warnings`); 497 doc lib tests pass; io's 6 drawing tests pass, the byte-for- byte container round trip and the mutation fuzz case among them, both fixtures now carrying views and a block; 40 engine tests matching `drawing` pass (`--lib`), output schemas included; `scripts/test-format-pending.sh` ok. Six mutations of the new rules were each caught. `cargo xtask ci` was NOT run: free disk stayed between 38 and 44 GB, under the 60 GB a workspace-wide build needs here. Nothing outside `crates/doc/src` embeds a drawing record, and only doc, io and engine name `doc::drawing` at all. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… W20a) (#8959) * Drawings saved inside the design's file, in both forms (#3890) K3b of the drawing storage plan, after #7098: a drawing lives in the file of the design it draws (bherbruck's proposal, Cameron's choice), so the separate drawing file goes. - `Document.drawings`: the design's drawings, each its own record of the drawing family (`solidcraft-drawing/N`), each behind its own `Arc`. Every reader and writer of a design now carries them: save, Save As, autosave and recovery, crash copies, the CLI. - A design container keeps each drawing in its own entry, `drawings/<id>.json` (Deflate), beside `document.json`, which holds nothing of them: its bytes, and the model cache keyed to them, are the same with drawings or without. A plain JSON design keeps them inline under `drawings`. - Each drawing is read by its own family's rules, taken out of the design's JSON before the design's own checks. One a build can't read (a newer number, a change it doesn't know, damage) refuses the whole design, never dropped. So does an entry under `drawings/` that isn't a drawing's, one whose record has another id, drawings inline in a container's `document.json`, two drawings with one id, or more than 1,000 (counted before any is read). A design is never saved with two drawings of one id. - Drawings are listed by name, then id: no stored order, nothing to merge when two people add drawings. - A drawing has an `id`, unique among its design's drawings (`Drawing::new` takes the ids already taken). Its source is the design it is in: at most one, an id and no path. - One pending design change, `drawings`: the last release refuses a design saved with it, so it never opens one and saves it without its drawings. One pending drawing change, `in-design`, for the record's new shape. - Gone: `read_drawing`, `read_drawing_file`, `write_drawing_container`, `file_kind`, `FileKind`, `DRAWING_EXT` and `is_drawing_path`. `read_document`, `read_design` and the container writer are as they were before #7098, with the drawings added. Tests: a design's drawings round-trip through both forms byte for byte, with `document.json` and `container.json` the same with drawings or without; their order; every refusal above; a drawing's properties kept as other tools wrote them while a sheet's number out of range is refused; the drawing's id among its objects', a new drawing's id none of the design's; a design with two drawings of one id not saved; mutation fuzz of a design with drawings in both forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing commands on the design's own drawings, each drawing its own undo (#3890) K4' of the drawing storage plan, on K3b (a drawing lives in its design's file): make, list, open, close and delete a design's drawings, and read and change the open one's settings and properties. It replaces #3891's drawing sessions, which held a drawing as a file of its own. - `drawing.create {name?, language?, units?}` adds a drawing of the design (one ISO A3 landscape sheet with the ISO border, the design its one source) and opens it; refused on an empty design. `drawing.list`, `drawing.open {drawing}`, `drawing.close`, `drawing.delete {drawing}`. `drawing.inspect`, `drawing.set`, `drawing.properties`, `.properties.set`, `.properties.remove` work on the open drawing. Labels in en, ja and zh. - The open drawing is the session's (`Session::open_drawing`, kept in checkpoints), and the part gate keeps the parts apart: a command says the part it works on, the model unless it says otherwise (`.in_drawing()`, `.any_part()`). While a drawing is open the model's commands wait ("a drawing is open: close it to change the model"); the drawing's run only while one is. Files, recovery, undo and redo, checkpoints, selection, diagnostics, the command list and choosing a drawing work either way. `CommandSpec::allowed` is the one check running a command, running it inside another and listing it make. - `Session::drawing` and `Session::edit_drawing` are the open drawing's one way in: an edit is kept when it changed something and still keeps the record's rules, in a new design whose other drawings are shared. - A change that only touches drawings evaluates nothing: `Document::differs_only_in_drawings` joins the render-only path, as render settings and part properties do. A model edit shares every drawing, so it pays nothing for the check. - Undo per part: a step records the part it changed (`Snapshot::part`: a drawing, or the model and its list of drawings). Undo and redo go through the open part's steps only. A drawing's step puts back only that drawing; the model's step puts back the design as it was, keeping each drawing it had as it is now. Making and deleting a drawing are the model's steps. A new step ends what could be redone in its own part only. `Snapshot::of` is the one place a step is taken. - An agent's message that changed several parts keeps their steps apart, rather than merging them into one step that would undo only one part. - `cmd::metadata`'s rules for reading, setting and removing properties are written once (`reading`, `setting`, `removing`) and used by the design's and the drawing's commands. - `drawing::sort` is the one place the drawings' order (by name, then id) is kept; `Document::put_drawing` adds or replaces one in that order. Tests: making, listing, opening, closing and deleting; what making one refuses, at the cap too; the gate both ways, inside another command and in the command list; drawing edits as undo steps that evaluate nothing over 100 rounds; undo and redo per part with model and drawing steps interleaved; redo ended per part; the order by name, then id, after renames; delete and its undo; refused changes; checkpoints; save and open in both forms; properties; hostile values for every command that runs with a drawing open, from the registry; a fuzz of the steps in any order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Unknown-command tests: the closest id first (#3890) drawing.open now joins doc.open in the suggestion for `file.open`, as the rule says: both end in the same word. The engine's and the CLI's tests check that doc.open comes first and let other close ids follow, as the `solid.extrud` line beside them already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Model bodies: their extents seen on a plane, for a drawing view's size (#5866) ModelBody::mesh_bounds_in(plane) is the box of a body's mesh in a plane's own coordinates (Plane::to_local), beside mesh_bounds and in the same way: a body meshed already is measured from its own mesh, and a placement of a part from its definition's shared mesh, with the placement folded into the plane's two axes once (two dot products a point), so no moved copy is made. W07's drawing.view measures a view's extents with it. Tests: a 100 x 50 x 20 block seen on the three principal pairs of axes and from an isometric corner (150/sqrt(2) by 190/sqrt(6), worked by hand), a plane away from the origin, and every placement in the shared-mesh test against its moved mesh, still without a moved copy, and the same again from its own mesh once it is meshed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: projected views in first or third angle, lined up with their parent (#4816, W17a) W17a's second slice: the principal views derived from a base view. - `ProjectedSide` (left, right, above, below): the side of its parent a projected view sits on. - `projected_basis(parent, side, projection)`: in third angle a view shows the side of the model it sits on (one to the right looks from the right), in first angle the side away from it (ISO 5456-2). It's the parent's basis turned a quarter turn about one of its paper axes, through its origin, with no -0. From the front view it gives exactly the named views: right, left, top and bottom in third angle; left, right, bottom and top in first. - `ViewFrame::aligned(side, projection, centre, position_mm)`: a projected view at its parent's scale, lined up with it, so it moves only along the free axis. - The projection is S2's `cell::Projection`, the value the title block's symbol reads, so a drawing has one first-or-third setting. Tests: the front view's projections are the named views in both angles, with no -0; from every named view and a leaning one, a projected view looks from its side and keeps the parent's other axis and origin, four turns or a turn and its opposite bring the parent back; a box's corners line up across aligned views in both angles; hostile parents, centres and positions refused. Corner (isometric) projected views wait for one convention check on first angle. The derivation graph (projected from, aligned to, cycles refused) moves to the view record in the drawing file, where the view ids live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions: measurement on view frames (#4896, W19a) `geom::drawing_measure` is what a dimension on a view reads, in model mm or radians, from model points and edges and the view's basis: one rule for every dimension. The view's scale and place on the sheet never enter. - `linear`: horizontal and vertical along the view's paper x and y, aligned as the view shows the segment, or along a direction picked on the view; a true reading is the segment's own length (aligned only). - `angle`: from the view's horizontal or vertical, a model axis as the view shows it, or another edge, from 0 to π as each line is oriented; a true reading is between model lines. - `foreshortened` says a measured line isn't parallel to the view's plane. - Refused with a reason: points that aren't finite or are past 1e12 mm, an invalid basis, a zero-length segment, a line seen end-on, a zero direction, a zero reading, parallel lines, and a true reading where there is none. `drawing_view`'s `PARALLEL` and `require` are shared. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * drawing.view.snapshot: a view's scale, place and boundary on its sheet (#5866, W07 V2) The first slice of W07: one orthographic view of the design, worked out and returned as data, before any line is drawn, so scripts can lay views out by their boundaries. - `drawing.view.snapshot` takes the view's settings, the sheet it goes on (A3 landscape at 300 dpi when not given) and where its centre goes (the sheet's centre when not given). With no scale it takes the largest ISO 5455 scale at which the view, centred there, lies inside the sheet's drawing border. It returns the resolved view, the scale (and whether it was fitted), the extents on the view's plane, the boundary on the sheet and what it was drawn from. Read-only and not undoable; it opens nothing and saves nothing. - Every body the design places is in the view, wherever its occurrences place it; the browser's eye counts for nothing (`engine::drawing_view::extents`, from P2's `mesh_bounds_in`). A design whose assembly walk stops at its limits (deeper than 64 levels, or past 100,000 placements) is refused rather than drawn with parts left out: `Document::placements_complete`, beside the walk, says whether every placement it holds had its occurrences walked. - `doc::drawing_view::ViewSettings` is the view's one parameter set: the view (named, or a direction and an up), the scale, the two visual styles, the reference settings and tangent edges. A saved view (W12) keeps the same fields; no scale is written as none, not null, so what it writes reads back as the snapshot's parameters. - `render::VisualStyle` names the five styles: visible, visible_hidden, shaded, shaded_visible and shaded_visible_hidden. The shaded ones are refused as not supported yet until the drawing renderer (#5624). - The command has a typed contract (input and output schemas). Its handler reads the contract's own type through `schema::read`, in the contract check's own words, so the check's levels give one message for one mistake and an unknown field is refused by name. The reply includes the sheet, its defaults filled in. Tests: the 100 x 50 x 20 block's boundary in the front, top, right and isometric views at 1:2, worked by hand; the fitted scale on A3 and A4 and near the border; scale, position and margin; the browser's eye ignored; the design untouched; each hostile setting refused; the walk's depth limit one level either side; the contract's keys the same as the settings' own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views in the drawing record: base and projected views, and the projection (#4816) E4 of the view-boundary plan, with #4816's derivation graph (plan on #4816). A drawing now saves its views, as one pending drawing-format change (`drawing/format/pending/sheet-views.rs`): - `Drawing.views`: each view an object of the drawing, on one of its sheets. A base view draws a source from a direction (`ViewDirection`, as `drawing.view.snapshot` takes it); a projected view sits on one side of its parent. Its place is a point of the sheet, or, lined up with its parent, only how far along the free axis, as the other comes from the parent. A projected view's source and basis come from its chain, so neither is saved. - `ViewOverrides` beside V2's settings: what a view sets itself, each setting on its own (scale, display style, reference style, reference parts hide the model, tangent edges); none is written when left out. Each view has its own reference margin. - `Drawing.projection`: first or third angle (S2's `cell::Projection`). Third angle is the type's own default (Cameron, 2026-10-26), for a drawing that doesn't say and for a new one until a template or a preference chooses. - The rules, checked on reading and after every edit: a view is on one of the drawing's sheets; a base view draws one of its sources, has a scale and a direction that makes a view; every parent is a view, no chain of parents loops, and a chain is at most 32 views; a lined-up view is on its parent's sheet; a place is on paper; at most 4,096 views. A view's id is the drawing's, never another object's. - `Drawing::resolve_view`: one rule for every reader. It turns the base view's basis down the chain (`projected_basis`, in the drawing's projection) and takes each setting from the nearest view that sets it, then the default, saying who gave it. - geom's `is_paper_coordinate`: the one rule for a view's place on paper, now used by `ViewFrame::new` and the record. The record tests' seed drawing has views, so its round trip and mutation tests cover them; their unknown-field examples no longer use `views`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Engine tests: one temporary folder helper and the schema check for every test module (#4816) The view tests use the drawing tests' temporary folder and the schema tests' `conforms`, which were private to their modules. `Folder` moves to the engine's test module and `conforms` is open to the crate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: inspect and edit a saved view (#4816, W17c) E5 of the view-boundary plan (plan on #4816): what the view's window reads and writes, for the views of a drawing (E4). Both are drawing commands with input and output schemas, and neither evaluates a model. - `drawing.view.inspect {view}`: its kind (base or projected), sheet, source, parent and side, its direction as resolved (named only when it is exactly a named view), its place, and each setting as {value, from, parent?, set}: where the value comes from (the view, a parent by id, the default) and what the view saves itself. A projected view says whether its display settings follow its parent (`linked`: true, false or "partly"). `choices` gives the display styles and the preset scales, so a window keeps no list of its own. - `drawing.view.edit {view, set}`: one undo step. Each setting takes a value, or null to follow the parent (a base view keeps a scale); the margin, a base view's direction and the place change too. `linked: false` saves the display settings at the values they have, `linked: true` clears them so they follow. The reply names the fields changed and the views projected from it whose settings changed with it. The record's rules hold after every edit; an edit that changes nothing is no step. The contract test keeps the edit's fields and the record's (ViewOverrides) one list. The view's boundary comes with the next slice, which works out where each saved view sits on its sheet from its design's extents. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: where a saved view sits on its sheet (#4816) `Drawing::view_centre` gives a view's centre on its sheet: its point, or, lined up with its parent, its own place along the free axis and the parent's centre across it. The free axis is one rule on `ProjectedSide` (`along`, `on_free_axis`), which `ViewFrame::aligned` uses too. `engine::drawing_view::on_sheet` puts a saved view on its sheet: its design's extents on its plane, grown by its reference margin, at its scale, round its centre. The snapshot and saved views share `measure` (refusing an assembly past the walk's limit or one with no bodies) and `boundary`. With nothing to measure (the design has no bodies or places more than a view walks) a view gets a 20 x 20 mm placeholder round its centre. A view's source is the design the drawing is in, so the session's own model is what it measures. `drawing.view.inspect` adds `boundary_mm` and `extents` (status `placeholder` and why, when there is nothing to measure). It still evaluates no model. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Projection of new drawings: a preference, and drawing.set takes the projection (#4816) A drawing's views follow its projection, first or third angle (third when nothing chooses). `drawing.inspect` now shows it and `drawing.set {projection}` changes it as one undo step. Preferences > Design gets a Drawings section with "Projection of new drawings" (First angle / Third angle). A new drawing takes it as a new design takes "Units of new designs": the app sets it after `drawing.create`, with no undo step of its own. A saved value this version doesn't know reads as third angle; asked for over the control channel, it is refused. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: one edit, one lookup, a border that lays out, and schemas (#3875) The sheet commands change the drawing through `Session::edit_drawing`, so the same settings or order again leave no undo step, and answer from one reply type. A sheet is looked up by id or name on `Drawing` (`sheet_index`), where later commands that name sheets find it too. A sheet's border must lay out on it: the record's check runs the border's own layout, the one rule drawing uses, so a 15 x 15 mm sheet with the ISO border is refused when it is made, not when it is drawn. `excluded` must be an object of `count` and `print`: a mistyped key changed nothing unseen. A new sheet documents nothing and leaves nothing out unless told, and the add's parameter documentation says it takes `documents` and `excluded` too. The drawing's properties sit behind an `Arc`, as its sheets do, so an undo step shares them. Each sheet command has an input and an output schema (#4035). A flattened part of a contract reports its keys as the parent's own (`schema::flattened`, which `FeatureCommon` now uses). The tests add the missing cases: 1000 sheets and the 1001st, `after` by id and unknown, the resolution's bounds, a name two sheets share, the same order and settings again, an undone delete in place, and the add's reset of what it documents and leaves out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing ids: one id source per session, its seed kept for replays (#3890) The drawing commands drew ids from a fresh random source each time, so a crash replay of a drawing could never find what an earlier command made by its id. A session now has one id source (`Session::ids`), kept across a file change, from which `drawing.create` draws its drawing's, sheet's and source's ids: seeded alike and run alike, a session gives the same ids, and a failed command draws none, so a replay of what succeeded draws the same. The crash journal keeps the seed at each base and `replay.json` carries it, which `solidcraft-cli crashes replay` seeds the replay with (`Session::seed_ids`). Tests: two sessions seeded alike make a drawing with the same ids, another seed other ids. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: add, change, reorder and delete a drawing's sheets (#3875) W18 S4: the sheets of a drawing, on the drawing session K4 made (#3890). Each command is one undo step of the drawing and names a sheet by its id or, when only one has it, its name. - `drawing.sheet.add {after?, name?, size?, orientation?, dpi?}`: a new sheet after the one named (the last when not), taking that sheet's paper, border and resolution, with a name of its own ("Sheet 2") and nothing documented yet. - `drawing.sheet.set {sheet, name?, size?, orientation?, dpi?, documents?, excluded?}`: one setting at a time, the rest kept; `documents: null` clears what it documents, and `excluded` changes only the flags it gives. - `drawing.sheet.reorder {sheets}`: every sheet's id once, in the new order. - `drawing.sheet.delete {sheet}`: a drawing keeps at least one sheet. - Every change goes through the drawing's own rules (`Drawing::validate`), so what a saved file would refuse is refused here. Changing a sheet's paper changes only the paper: regrowing its border and moving what is on it is S5's. Labels in en, ja and zh. Tests: a new sheet copying the paper it follows, after a named sheet too, and undone; each setting changed with the others kept; nine refusals (resolution, sizes, orientation, name, an unknown source, a flag, an unknown sheet, no sheet named) with the drawing unchanged; reordering, and four orders that aren't every id once; a name two sheets share refused in favour of the id; the last sheet kept. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: a new sheet's id from the session's id source (#3875) `drawing.sheet.add` draws its id from `Session::ids` (#3890's one id source per session), so a crash replay of "add a sheet, then change it by id" finds the sheet: seeded alike and run alike, a session adds sheets with the same ids, and a failed add draws none. Tests: two sessions seeded alike add the same sheet ids, another seed others, a failed add none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: move or copy a view to a sheet (#4816) `drawing.view.move_to_sheet {view, sheet, position_mm?, break_alignment?}` puts a saved view on another sheet as one undo step, keeping its id, direction, source and settings. The views lined up with it go with it and keep their places beside it; a view placed apart stays. Without a position it keeps its place. A view lined up with its parent moves only with `break_alignment`, and is then placed apart: at the position, else the sheet's centre. Its own sheet changes nothing. `drawing.view.copy_to_sheet {view, sheet, position_mm?, with_linked?}` makes new views, each following none of the views it was copied from (Cameron's rule). A view with views lined up with it needs `with_linked`: true copies them too, lined up with the copy; false copies it alone. A projected view copied alone becomes a base view, looking the way it did (by name when it is exactly a named view) with the settings it had as its own. The copy goes to the position, else the sheet's centre. A lined-up view's centre comes from the places alone: its place along the free axis, and its parent's centre across it. So the views that travel with a view are shifted along their free axis, and nothing needs the design's extents. `descendants` takes which views it follows, so the edit's followers and the views lined up with a view are one walk. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: move and copy take a view's centre from the record (#4816) Moving or copying a view to a sheet worked out a view's centre with its own copy of the lined-up rule. It now uses `Drawing::view_centre`, and a lined-up view's place moves along its free axis by `ProjectedSide::along`, so the rule is written once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: a change of paper lists the views it leaves outside, and moves none (#3875) W18 S5, its first part. `Sheet::drawing_space` is where a sheet's drawing goes: inside its drawing border, or the whole paper with none. Nothing on a sheet is saved against the border, so a change of paper regrows the border and its zones by itself. `engine::drawing_view::outside` lists the views whose boundary (`on_sheet`) leaves their sheet's drawing space, sides included. `drawing.sheet.set` lists them after a change of paper (size or orientation; nothing else moves the space, so nothing else is measured), and moving or copying a view to a sheet lists those it puts outside there. None is moved: where a view goes stays the author's choice. A view with nothing to measure is listed by its placeholder, with why. Tests: the drawing space with the ISO border, a filing margin and no border, and margins that leave none; A3 to A4 either way up listing the right and top views with their boundaries and moving nothing; a border through a view's edge leaving it inside, 0.1 mm less paper putting it outside; a change of name checking nothing; undo; a move to a smaller sheet listed and a copy that fits not; a placeholder listed as `past_walk_limit`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing ids and the sheet border: the tests the slices left out (#3890, #4816, #3875) What the slices' planted faults found untested, now each caught by a test: - a file change keeps the session's id source: a drawing made after `file.new` draws the same ids in two sessions seeded alike; - a copied view's ids come from the session's id source, seeded alike giving the same copies; - a crash report's replay carries the session's id seed, from a caught panic (the seed when the command started) and from the journal of an unclean exit (the seed at its base); - a view short of the sheet's border by less than a rounding is still inside it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: listed by id, whatever order they were added in (#4816) The record's rule says a drawing saves its later records by id, never in the order they were added in. Views were kept, and saved, in the order they were added, so the same views added in another order saved as other bytes. - `Drawing::add_views` adds views where their ids put them. It is the one way views are added: `drawing.view.copy` uses it, and so do the test fixtures. - `Drawing::validate` checks the order, so every edit keeps it. - Reading puts a file's views in id order before it checks the record. The order means nothing, so a file in another order (saved before views went by id, or edited by hand) isn't damaged: it opens, and saves by id. - What a command lists in the drawing's order (the views a change of paper leaves outside, an edit's followers) now comes by id. No format change: no release has saved a view (the views change is still pending). Tests: - views added out of id order are listed and saved by id; - the same views added the other way round make the same drawing and the same bytes, which read back as saved; - a file that lists them the other way round reads by id, as the same drawing, and saves as those bytes; - an edit that leaves them in another order breaks the record's rule; - the existing tests now index the file by id order, and the engine's lists are by id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions: the dimension record, saved by name on a view (#4896, W19b) A drawing saves its dimensions: each on one of its views, measuring named corners or edges of the view's model (a linear distance between two corners, a straight edge's length, or the angle between two edges), with the direction and reading W19a measures with, how far its line sits from what it measures, where its text sits on paper, its decimals and any text shown instead of the number. A reference names its body, the feature that made the body and its occurrence path, never a picked point. Nothing worked out is saved. - Dimensions are listed by id, read in that order whatever order a file has, as views are: one helper pair (add_by_id, in_id_order) now keeps both lists. - One cap for the names a saved model reference keeps (MAX_REFERENCE_NAME_BYTES, used where 512 was written three times), and the corner's edge cap shared with construct's vertex references. - LinearDirection and Reading save as snake_case words; a direction along a line saves as its two coordinates. - A direction along a line is at most 1e9 each way (format::MAX_REAL, the limit the file's number check holds every real number to): a whole number past it passes that check, reads as a real, and would save as one the next read refuses (found by the mutation test). - One pending drawing-format file (dimensions.rs). Tests: what each dimension saves and reads back as the same bytes, a file in another order reads by id, an older drawing has none; every rule on both sides of its cap, unknown fields at every level, the id rule, and the count cap; the plate fixture carries one dimension of each kind, so the existing round-trip and mutation tests cover them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Edges and corners by name: the matching step and the shared ends, each in one place (#4896, W19b) A dimension finds an edge by name the way a fillet does, but never takes the piece nearest an old pick, and finds a corner where its named edges meet, refusing to choose between two. Both steps are split out of the code that already does them, so there is one rule each: - BodyEdges: a body's edge and face names, worked out once for every name looked up on it, and `matching(name)`: the edge with that name, else the one edge between the faces it names, else the pieces of it. locate_edge now calls it and then takes the piece nearest the pick, as before. - construct::shared_ends: the ends every named edge has, each once. named_vertex keeps the one nearest its point, as before. No behaviour change: every caller of locate_edge, find_edge and the vertex references gets the same results. The existing naming, joint and construction tests cover both paths; three new ones pin what they left open: a vertex only where every named edge ends, the piece of a split edge nearest the pick, and a lone match through the stem of a face taken as a piece, with the warning. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A body's frame through an occurrence path, in one place (#4896, W19b) Document::body_frame_at(body, path): the placement the path leads to, then the body's offset, without expanding every assembly instance. It is what EmbossFace::body_frame composed for its saved path; that now calls it, and drawing dimensions use it for the occurrence path they save. No behaviour change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions found again in the model, strictly (#4896, W19b) Document::resolve_dimensions(model, drawing, ids) works out each dimension as the model has it now: - An edge by its name, or the one edge between the faces it names (BodyEdges::matching), never the piece nearest an old pick. A corner is the one end all its named edges, or their pieces, share; two shared ends are ambiguous, never "the nearer one". - The body by its name and the feature that made it, placed through the saved occurrence path (Document::body_frame_at). A same-named body made by another feature isn't it. - Status: ok; overridden (the text given is shown, the value still worked out); ambiguous (the candidates, at most 16, none chosen); suppressed (its feature is suppressed or rolled back, read from the evaluation's own skipped mark); lost (why); unmeasurable (found, but the view can't measure it so, in W19a's words, such as a line seen end-on). - The value comes from W19a on the view's basis. An angle is the smaller one between the two lines, or pi minus it on its other side, whichever way the kernel runs the edges; a split edge's pieces on one line are still that line. A split edge's length is ambiguous. - The text: the override, else length_number in the drawing's unit (or the design's) with the dimension's decimals, or degrees for an angle. - The cost: each body named is looked up once per call, and its edge names worked out once, however many dimensions name it. A body none names isn't touched. Not saved: nothing here changes the drawing. The last good value of a lost dimension needs the session, so it comes with the commands (W19d). Tests (engine, an 80 x 40 x 30 box, values by hand): front and right view values, foreshortening and text, the drawing's own unit, several at once and an unknown id; a change and its undo; a chamfer's 45 and 135 degrees, and end-on in the front view; lost after a fillet and back on undo, suppressed and back, a path to no occurrence, a new box with the same body name; a notched edge's length ambiguous with both pieces while its end corners still read 80 and its angle to the left edge 90 degrees, neither exact; an angle on a piece of an edge whose slot is then suppressed still reads 90 degrees, found through the stem of the face it was cut from, so not exact; one edge named twice gives two corner candidates; an override shown while the value follows the model. Not covered by a test here: a part placed twice through real occurrences (only a path to no occurrence is); the once-per-body cost (not measured). A drawing unit outside display_units' five (um, yd, km, mil, nm, inch, µm) shows millimetre numbers, the formatter's existing fallback; named as its own follow-up. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing sheets: a sheet with anything on it goes only with it, when asked (#3875) drawing.sheet.delete refuses a sheet with anything on it, and its error names what is there: its views and the dimensions in them, the first few ids of each. With `contents: "delete"` the sheet goes with everything on it as one undo step, which an undo brings back whole. What is on a sheet is said once, in the record (Drawing::on_sheet), and Drawing::remove_sheet takes the sheet out with exactly that; each later kind of record on a sheet (a sheet's own sketches) adds itself there, so delete covers it with no change here. drawing.sheet.set's list of a sheet's views uses the same function. Nothing on another sheet goes with it: a view there projected from one of the sheet's views would lose its parent, so the delete is refused naming those views, to be moved or deleted first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: a view found by id by halves, in one place (#4816) The views are listed by id, so Drawing::view and Drawing::view_index find one by halves instead of walking the list. Every lookup by id uses them: a view's chain of parents (so resolving a view no longer walks the list once for each parent), the views' rules (which no longer build a map of every view to check each chain), a dimension's view, and the engine's view commands and outside check. The rules check the id order before anything looks a view up, so a file with its views out of order is still refused as before. Measured on a drawing of 4096 views (1024 chains of a base view and three views projected one from another), median of 30 runs: 4096 lookups by id took 6.85 ms by a linear find and take 105 us by halves; the rules' check took 1.77 ms and takes 1.45 ms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: a damaged chain names the view whose parent is missing (#4816) A view whose chain of parents breaks further up was refused with "its parent X isn't one of the drawing's views", naming a view that isn't its parent. Further up the chain, the refusal now names the view whose parent is missing: "its chain of parents reaches view Y, whose parent X isn't one of the drawing's views". A missing parent of the view itself reads as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions: add one to a view, and read it back (#4896, W19d) drawing.dimension.add puts a dimension on a saved view of the open drawing; drawing.dimension.inspect reads one back with what it measures now. Adding is one undo step of the drawing; neither evaluates the model. What a dimension measures is picked and saved by name, never by the point picked. Document::edge_reference and corner_reference turn a pick into the record's names: an edge is a point on it in the design's frame or {body, index} (its index among the body's edges as the model lists them, as an ambiguous dimension's candidates are given), and a corner is a point or the edges that meet there, each with the occurrence path its body is placed through. A pick that doesn't name one thing is refused, saying what it found: no edge, a point on several edges, a corner of more than one body, edges that don't meet. Each body's edges are placed in the design's frame once per pick, and only the body picked has its edge names worked out. The kind is given as the record saves it ({linear: {a, b, direction?, reading?}}, {length: …}, {angle: …}), read by the record's own types, so a command and a file read the same words. A new dimension's line is 10 mm from what it measures (until a dimension style gives it), shows 2 decimals, and its text is centred on its line; the text's default place at its centred point (Q58) comes with the layout on paper. The inspect reply has the record, the status (ok, overridden, ambiguous, suppressed, lost or unmeasurable, with why), the value (model mm, or degrees for an angle), whether it is foreshortened, the text, whether every name was found by exact history, and an ambiguous dimension's candidates. One rule, one place: the corner rule's point tolerance is construct::point_tolerance, shared by the picks; a dimension by id is Drawing::dimension, which the resolver uses too. Not here yet: edit, the view's list of its dimensions, the layout on paper and the last good value (the next slices); delete waits with view delete for the drawing UI's choice of one delete command or one for each kind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions: change a dimension's settings (#4896, W19d) drawing.dimension.edit {dimension, set} changes what a dimension shows and where, as drawing.view.edit changes a view: the offset of its line, its text's place, its decimals, the text shown instead of its number (null shows the number again), and its kind's direction, reading or other side. The reply names the fields that changed. The same values again change nothing and add no undo step (the drawing is put back only when it differs). What a dimension measures isn't a setting: to measure something else, add a new one. A setting its kind hasn't got is refused (an angle has no direction, only an angle has an other side); every changed record passes the check a file read runs, so an edit can't save what opening the file would refuse. A dimension's place in the list is Drawing::dimension_index, which Drawing::dimension now uses too, as a view's is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: inspect lists a view's dimensions (#4896, W19d) drawing.view.inspect answers `dimensions`: the ids of the view's dimensions, in id order, so a caller can find them and read each with drawing.dimension.inspect. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing views: a copied view takes copies of its dimensions (#4896, W19d) drawing.view.copy_to_sheet copies each copied view's dimensions with it, each with an id of its own on the copy, in the same undo step: they are part of what the view shows (the W19d plan's question 1, its recommended answer). A dimension's text placed `at` a point is from its view's centre, so it keeps its place on the copy. A moved view keeps its own dimensions as they are: they name the view by id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions: the last good value, in memory (#4896, W19d) A dimension that can't be measured now (its edge filleted away, its corner gone) gives `last_good`: the value it last read this session, as `value` gives it (model mm, or degrees for an angle). Each value a dimension reads is kept by drawing and dimension in the session, and a scratch copy keeps the session's. It is never saved (the W19b plan's question 3), so a design's drawings don't change with every model edit, and after reopening a lost dimension shows no number. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions: hostile values anywhere in the commands' params (#4896, W19d) A hostile value in each place of drawing.dimension.add, .edit and .inspect's parameters, at every depth (the kind, its picks and paths, a corner's edges, the edit's settings), with 1 000-item lists, the largest index and 600-byte text besides the engine's shared hostile values: no panic, and the drawing keeps its rules. The engine's own hostile test sends only its list of key names, none of which these commands read. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions: a new dimension's defaults, tested (#4896, W19d) The offset (10 mm), the text's place (centred) and the decimals (2) a dimension is added with when not told. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * A plane carried by a transform, in one place `assembly::map_plane` is public and gives `None` for a transform that flattens the plane; its two copies (the occurrence mapping, which keeps the plane as it was, and the face anchor's, which refuses) now call it and keep their own fallback. W20a's radial dimensions use it to carry a view's plane into a body's frame. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Drawing dimensions: a circle's or an arc's radius and diameter (#4896, W20a) A radial dimension saves its edge by name and whether it shows the diameter. It reads the edge's exact circle in the view's plane through the edge (`Body::planar_edges`, as the view draws it), so a view that doesn't see the circle face on can't measure it; its text is R or Ø before the number. `drawing.dimension.add` takes `{radial: {edge, diameter?}}`, a diameter by default for a whole circle or half a turn or more (a hole's rim is two halves), and refuses a dimension of any kind its view can't measure; `drawing.dimension.edit` switches `diameter`, keeping the id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
424 commits of main since 9fb41f8. Among them is tangency-labs#8249 (9bcb2ff), upstream's first landing of the drawings branch on main, as one squashed commit. This branch already carries that branch's history as real merges (rows 1 and 3 of BETA-BASE.md), so git saw the same work twice: 35 files conflicted, ten of them add/add. Each was resolved by what upstream changed beyond the drawings branch, measured file by file against four versions (the drawings branch ebafe07, the landing, main now, ours): - Ours, where main's file is the drawings branch's unchanged (12 files: the paper scene, title block, SVG writer, drawing records and their tests), and where the landing was main's only change and ours is the same work resolved our way (eval_more.rs, sheet.rs, cmd/metadata.rs, io/design/drawing_tests.rs, io/mutate.rs, the file-formats skill). - Three-way against the drawings branch, where main changed a drawings file after the landing (geom cell.rs, drawing_view.rs, lib.rs): clean. - Three-way against the landing, where both the landing and later main changed it (doc drawing_tests.rs, format.rs, lib.rs; geom tests.rs; io lib.rs; the glossary): clean but for io/lib.rs, which keeps tangency-labs#3891's removal of the .scdwg constants with main's newer comment, and the glossary, which keeps both entries. - io/design.rs is main's file with tangency-labs#3891's five changes put back: the .scdwg exports gone, drawings written as entries of their own and read back, the container version checked instead of "is this a drawing file", ambiguous drawings refused, and names() for has_part(). tangency-labs#3891's inlining of open_regular_file, is_container_source and PackageWriter::new/finish was a pure refactor, and main has since given those helpers the limits checks, so they stay. - doc/metadata.rs and engine/cmd/bom.rs are main's: upstream resolved the same bom_type question we did in c443412, with a component's refusals listing bom_type among its keys (main's bom test expects it). One line of ours is kept: setting bom_type on a design or drawing still says to use component.metadata.set, which tangency-labs#3891's own drawing test expects. - Ordinary conflicts, both sides kept: placement_reuse.rs compares drawings and point_clouds; cmd/mod.rs runs allowed() (the drawing gate) and names the command in a parameter error, and registers settings beside the drawing commands; schema/mod.rs lists component, drawing and drawing_view; edit.rs and file.rs take main's new commands and text, with select.clear and file.save keeping .any_part(). Checked for silent drops: across the 32 files both sides changed, every line main added before or after the landing is in the result. Checked on Windows (laptop), 4 jobs, 2 test threads: - cargo check --all-targets on geom, doc, render, io, engine, ui-egui, mcp, the app and the CLI: clean, no warnings. - clippy on doc, io and engine, all targets: silent. fmt, xtask lists and skills pass. - geom drawing + paper + title_block + cell 96, doc drawing + format + eval::cost_tests + metadata 111 (97 after the metadata change), io design + drawing + paper + cloud + mutate 82, engine --lib drawing + schema:: + cmd::edit + cmd::bom + cmd::metadata + cmd::file 250: all pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`design_link.rs` gives every kind of link to another design file one way to read it and one set of state words (agreed on tangency-labs#3891, review on tangency-labs#5420): - `open_linked(file)` reads through vfs, or returns a `LinkProblem`: its `LinkState` (missing, unreadable, not_allowed, newer) and the reason; `link_presence(file)` says the same without reading. The words also cover up_to_date and out_of_date for each link's own comparison. - `DocError::Newer` carries the format check's "saved by a newer SolidCraft", same message, so `newer` doesn't depend on the text. - `rebase(link, from, to)`: one Save As rule; `rebased` maps over it. - `same_file`: one self-link rule (same path, or an alias on native hosts). Insert Design, Update Links and Relink read through `open_linked` and use `same_file` (only Relink caught an alias before); a design from a newer SolidCraft says to update. `component.links` adds `state` and `reason` when a file can't be reached; `found` is unchanged. Rebased onto main f96b5e0: - A design from a newer SolidCraft opens with a notice since tangency-labs#12166, so the `newer` state and `DocError::Newer` are gone. - `open_linked` is `read_linked_file` and returns the file's bytes: Update Links keeps their digest (tangency-labs#9739) and reads a container's saved geometry. It reads up to `limits::max_design_bytes()` (tangency-labs#7565). - `rebased` keeps every `DesignLink` field. - `component.links` reports `state` and `reason` in its typed reply (`LinkInfo`, tangency-labs#12277), with a schema test for a missing file. - Tests use `.sc` names (tangency-labs#7325). Co-Authored-By: Claude <noreply@anthropic.com>
…ule (tangency-labs#5449) `design_link.rs` gives every kind of link to another design file one way to read it and one set of state words (agreed on tangency-labs#3891, review on tangency-labs#5420): - `open_linked(file)` reads through vfs, or returns a `LinkProblem`: its `LinkState` (missing, unreadable, not_allowed, newer) and the reason; `link_presence(file)` says the same without reading. The words also cover up_to_date and out_of_date for each link's own comparison. - `DocError::Newer` carries the format check's "saved by a newer SolidCraft", same message, so `newer` doesn't depend on the text. - `rebase(link, from, to)`: one Save As rule; `rebased` maps over it. - `same_file`: one self-link rule (same path, or an alias on native hosts). Insert Design, Update Links and Relink read through `open_linked` and use `same_file` (only Relink caught an alias before); a design from a newer SolidCraft says to update. `component.links` adds `state` and `reason` when a file can't be reached; `found` is unchanged. Rebased onto main f96b5e0: - A design from a newer SolidCraft opens with a notice since tangency-labs#12166, so the `newer` state and `DocError::Newer` are gone. - `open_linked` is `read_linked_file` and returns the file's bytes: Update Links keeps their digest (tangency-labs#9739) and reads a container's saved geometry. It reads up to `limits::max_design_bytes()` (tangency-labs#7565). - `rebased` keeps every `DesignLink` field. - `component.links` reports `state` and `reason` in its typed reply (`LinkInfo`, tangency-labs#12277), with a schema test for a missing file. - Tests use `.sc` names (tangency-labs#7325). Co-authored-by: Carel Theron <careltheron@Carels-MacBook-Pro.local> Co-authored-by: Claude <noreply@anthropic.com>
Part of #3890: W11, W12 and W15 of the #860 plan. W11 is where drawings are saved, W12 their records and W15 the commands that make and change them. Since 2026-10-26 a drawing lives inside the file of the design it draws (@bherbruck's proposal, which Cameron chose). The updated plan is on #3890: #3890 (comment). Sheets (#3875) and sheet tables (#3874) build on this.
Changes a default: no
This draft is the claim for #3890 and holds the next slices in order, one commit each. Each slice goes up for review as a small PR of its own. K1 (#6196), K2 (#7097) and K3 (#7098) are merged into
drawings; K3b is #7490.What it does, slice by slice
The K numbers are the drawing storage plan's slices (on #3890).
drawing.opennow followsdoc.openin the suggestion forfile.open, so each test checks thatdoc.opencomes first and lets other close ids follow.What changed since the last push. The slices built for a drawing as a file of its own are gone from this branch:
Model edits from a drawing come back with K8' on the new model. Drawings of other designs come back later, with drawing-only files.
Next on this branch: K7', K8', K9' and K10' on the new model, then the sheet scene cache (K7b) and revisions (R1). Nothing here is visible in the app yet: these are the commands the drawing workspace (#4894) will drive.
K4' in detail
drawing.create {name?, language?, units?}adds a drawing of the design and opens it. The drawing has one ISO A3 landscape sheet with the ISO border, and the design is its one source. It is refused on an empty design.drawing.list,drawing.open {drawing},drawing.closeanddrawing.delete {drawing}choose and remove drawings.drawing.inspect,drawing.set,drawing.properties,drawing.properties.setanddrawing.properties.removework on the open drawing.Session::open_drawing), and checkpoints keep it. A command says which part it works on: the model, unless it says otherwise (.in_drawing(),.any_part()).CommandSpec::allowedis the one check that running a command, running it inside another and listing it all make.Session::drawingreads it andSession::edit_drawingchanges it. An edit is kept only when it changed something and still keeps the record's rules. It makes a new design that shares every other drawing.Document::differs_only_in_drawingsjoins the render-only path that render settings and part properties already take. A model edit shares every drawing, so the check costs it nothing.Snapshot::part): a drawing, or the model with its list of drawings.Snapshot::ofis the one place a step is taken.cmd::metadata(reading,setting,removing), for the design's commands and the drawing's.drawing::sortkeeps the drawings' order (by name, then id).Document::put_drawingadds or replaces a drawing in that order.Tests
Planted faults: 22 of 22 caught, then a clean run.
What no test reaches:
maineither. One line would catch it (dok.openmust suggestdoc.openfirst); it follows as a small PR onmain.Validation
xtask's ui-containers test andrequested_menu_icons_have_artwork_and_match_manifeston a Windows checkout (fixed onmainin ci: fix local scheduling and Windows test baselines #4941 and icon_audit: compare the requested-icons manifest with CRLF checkouts ignored (#4932) #4960, whichdrawingsdoesn't have yet);dialogs::dense'snew_cards_settle_before_the_first_click_in_both_layouts, which timed out under the gate's load and passes alone;drawing.opennow followsdoc.openin the suggestion forfile.open. K4''s follow-up commit in Drawing W11, W12, W15: where drawings are saved, their records and their commands (#3890) #3891 fixes both.run_resultstests and the engine's unknown-command test pass; rustfmt, and clippy on the CLI and the engine with all targets, pass.drawingsf18616e. The same patches, re-parented ontodrawingsebafe07 (title blocks, view definitions and exact hidden lines landed there; none of them touches these files), checked again on this branch's head (36cf48a):doc(310) andio(128) library tests, the engine's drawing tests (139),ui-egui's agent chat tests (119) and the CLI's run results (9) pass, and so do clippy ondoc,io, the engine,ui-eguiand the CLI with all targets, and the wasm check (doc,io, the engine).drawingsebafe07, the gate (Windows) on the top of the drawing slices stacked on this (ab75908, which holds this PR's commits at the bottom): fmt, assets, icons, licences, lists, layers, ui-containers, both clippy runs, wasm and web offline all pass, and the unknown-command tests pass with the follow-up in it; 6,293 tests passed, 4 failed and 57 ignored, in 76 test binaries. None of the four is from this stack, which changes no file they test:icon_audit'srequested_menu_icons_have_artwork_and_match_manifestand xtask'sui_containerstest fail on a Windows checkout (fixed onmainin ci: fix local scheduling and Windows test baselines #4941 and icon_audit: compare the requested-icons manifest with CRLF checkouts ignored (#4932) #4960);cmd::clearance::tests::a_pin_seated_line_to_line_in_its_bushing_is_measuredis on the same PC's known list; and the kernel'sboolean_props::commutativefailed on a case proptest drew at random (a cylinder against a sphere, where truck refuses a tolerance under 1e-6).Integration status
Based on
drawingsebafe07, with K3b (#7490) under it. Others working nearby, checked on 2026-10-27:crates/engine/src/cmd/mod.rsand its own catalog entries: a keep-both merge, and no command id is in both.crates/io/src/lib.rsthan K3b does.Refs #860