Commit graph

109 commits

Author SHA1 Message Date
Arena Agent
667f565ddd fix(cad): match arms bound new variables instead of matching KeyCode
Went looking for a clippy ratchet and found that clippy had never run on
this crate at all: two dependencies fail deny-by-default lints, so
`cargo clippy -p nigig-build` aborted before linting nigig-build. Fixing
those two unblocked the crate and immediately exposed a real defect
class.

THE BUG. A bare identifier in a match pattern that is not a known variant
is parsed by Rust as a NEW BINDING that matches everything. Nine such
names were used as KeyCode patterns:

  KeyEnter, KeyBackspace, BracketLeft, BracketRight   (cad/viewport.rs)
  Digit0..Digit9, Equal, LeftBracket, RightBracket,
  Apostrophe                                          (doc, invoice, pm)

Real names are ReturnKey, Backspace, LBracket, RBracket, Key0..Key9,
Equals, Quote.

Consequences, in severity order:

- cad/viewport.rs: `BracketLeft => { .. }` is UNGUARDED and sits above
  the numeric arms, so it swallowed every remaining key. All
  direct-distance-entry input -- digits, '.', '-', ',' -- was
  unreachable. The entire DDE feature was dead.
- The guarded ones fired for any key satisfying the guard: pressing Q
  while drawing with a non-empty buffer committed the coordinate.
- doc/invoice/project_management: `Digit0 => '0'` swallowed the rest of
  the keymap, so every digit and symbol typed produced '0'.

This compiles cleanly and no test catches it. rustc's only signal is
`unreachable_pattern` plus `unused variable: \`Capitalised\`` -- both
buried in the 200+ warnings nobody could see, because clippy never ran.
85 unreachable-pattern warnings before, 1 after (a benign catch-all).

UNBLOCKING CLIPPY. Two deny-level errors in dependencies:

- nigig-uikit user_project_pill.rs: a `for` loop returning on its first
  iteration (never_loop). Rewritten as `.next()`.
- spreadsheet-engine formula2.rs: CellRef had an inherent to_string
  shadowing Display (inherent_to_string_shadow_display). The naive fix is
  a trap: Display::fmt was `f.write_str(&self.to_string())`, which
  resolved to the inherent method -- delete it and the same call resolves
  to ToString::to_string, which calls Display::fmt, recursing until the
  stack overflows. Verified with a standalone repro before fixing. The
  body moved into Display; Range got the Display impl it never had.

Tests: keycode_variant_tests names the four correct variants, so it stops
compiling if any is renamed -- the point being that the old code compiled
precisely because the names were wrong. Two formula2 tests pin that
`x.to_string()` and `format!("{x}")` agree, which is what the shadowing
lint exists to protect.

CI gate added and negative-tested: greps for a capitalised
`unused variable`, which is the signature of this bug. Restoring
BracketLeft makes it fire.

625 lib + 154 integration + 225 spreadsheet-engine + 44 doc-engine, 0
failed.
2026-07-28 20:24:03 +00:00
0fefb03254 test(spreadsheet-ui): cover workbook grid data exchange
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 20:22:20 +00:00
b5e0044272 chore(spreadsheet-ui): remove unreachable drag state
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 19:34:20 +00:00
efcabb7c0d refactor(spreadsheet-ui): format and consolidate workspace adapter
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 19:25:30 +00:00
0033564660 chore(spreadsheet-ui): remove unused grid import
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 18:55:18 +00:00
Arena Agent
cf29ba78a4 fix(spreadsheet-ui): bind the WidgetRef before borrowing in a let-else
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
origin/main did not compile: E0716 in exchange_grid_with_model.

  let Some(mut grid) = self.view.widget(cx, ids!(grid))
      .borrow_mut::<SpreadsheetGrid>() else { return false; };

`widget()` returns a temporary WidgetRef and `borrow_mut` borrows from
it. In a `let ... else`, temporaries in the scrutinee are dropped at the
end of the statement rather than living to the end of the enclosing
block as they do in `if let`. So `grid` outlives what it borrows from.

The three neighbouring call sites use `if let` and are unaffected, which
is why this reads as correct next to them.

Bound the WidgetRef to a local first, with a comment recording the
`if let` / `let else` difference so the next copy-paste from a
neighbouring line does not reintroduce it.
2026-07-28 18:32:46 +00:00
ffc8973b50 refactor(spreadsheet-ui): route sheet switching through adapter
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 18:16:50 +00:00
441bcde01a refactor(spreadsheet-ui): adapt legacy startup through workbook model
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 18:15:08 +00:00
2d415a47a9 refactor(spreadsheet-ui): initialize workspace through workbook adapter
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 18:14:00 +00:00
29accc38f4 refactor(spreadsheet-ui): route add-sheet through workbook adapter
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 18:00:49 +00:00
c374778684 refactor(spreadsheet-ui): load workbooks through adapter
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 17:48:09 +00:00
2f6e50f0c4 refactor(spreadsheet-ui): simplify workspace model extraction
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 17:46:18 +00:00
5d98626b55 refactor(spreadsheet-ui): unify workbook serialization bridge
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 17:38:59 +00:00
Arena Agent
bf280c0fb6 refactor(cad): delete the dead Legacy command system and duplicate types
Phase 4 of CAD_ASSESSMENT_AND_PLAN.md: remove the second copy of things
the module carried alongside their replacements. No behaviour change.

Removed, after confirming each has no live caller:

- The entire LegacyCommand system: the trait, LegacyCommandCtx,
  LegacyUndoRedoStack and the six LegacyMovePart/Resize/Rotate/Add/Delete/
  ModifyPart structs, plus their tests. The editor has used the Command /
  UndoRedoStack pair since v19; the legacy set was still exported and
  still maintained, so grepping for a command type returned two answers.
- CadViewport::legacy_ctx(), which nothing called.
- CommandError::Legacy, which was never constructed.
- The duplicate DofConstraint in mod.rs and its two bridge From impls.
  Production reads cad_scene::DofConstraint exclusively; the legacy struct
  existed only so a conversion test could round-trip it.
- Three dead functions in exporters.rs. The dead write_3d_viewer also
  carried a bug the live path does not: it wrote an absolute filesystem
  path into the exported viewer's <model-viewer src>, which breaks the
  moment the folder is copied anywhere.

Renamed LegacyCommandCtxHolder -> CommandBorrows. Despite the name it
holds the *new* UndoRedoStack and is the split-borrow helper for the live
command path.

Also refreshed the v10/v13/v18b archaeology comments that referenced the
deleted types, and ported bench_command_execute_overhead to the live
Command/CadCommandCtx path so the measurement survives.

1,588 lines removed: commands.rs 1863 -> 1318, tests.rs 3754 -> 2840,
exporters.rs 186 -> 93.

Tests: 728 -> 714 passing, 0 failing. The 29 removed all exercised the
deleted system; verified by diffing the full test-name list before and
after, which also caught 16 live-system tests that merely *mentioned* a
Legacy type in passing and had to be kept.
Rebasing onto origin/main also required repairing that branch, which did
not compile (4 errors) and so had never run its own tests:
- lookup.rs: an over-eager .clone() removal left *bt.category, deref'ing a
  String field to an unsized str and breaking the key type.
- estimate_store.rs: two different tests shared one name; renamed both to
  say what they assert.
- Once building, 3 tests failed. EstimateStore::dispatch took an undo
  snapshot and emitted UndoRedoChanged even when the command was a no-op,
  so a rejected out-of-range edit still consumed an undo slot and cleared
  the redo stack. Command::Initialize also never cleared the room list, so
  re-initialising kept the previous run's rooms.
- spreadsheet-ui/workspace.rs: missing `use crate::model::WorkspaceModel`.
2026-07-28 17:37:21 +00:00
679d249426 refactor(spreadsheet-ui): use workbook adapter for save action
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 17:34:58 +00:00
4ebf7939a8 refactor(spreadsheet-ui): route workspace save through workbook adapter
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 17:33:01 +00:00
c9f14ec386 feat(spreadsheet-ui): add workbook persistence adapter
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 17:22:05 +00:00
60db0f21db build: update Nigig to Makepad dev reexport fork
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
2026-07-28 17:14:18 +00:00
79fe101a7c feat(spreadsheet-ui): add workbook data exchange adapter
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 17:07:00 +00:00
02c05e1794 refactor(spreadsheet-ui): prepare workbook adapter ownership access
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 17:00:33 +00:00
020a4bc924 feat(spreadsheet-ui): expose command application on workspace model
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 16:54:10 +00:00
0573e4dc22 feat(spreadsheet-ui): expose adapter sheet navigation state
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-07-28 16:50:13 +00:00
Arena Agent
b5471e32e3 fix(cad): make the crate buildable, testable and safe to ship
Some checks failed
nigig-build (CAD) / supply-chain (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
Phases 0-2 of CAD_ASSESSMENT_AND_PLAN.md. The crate did not compile and no
test had ever run; it now builds clean with a green suite.

Build and CI (Phase 0)
- Pin all 33 git dependency manifests to an explicit rev. A branch
  dependency re-resolves on every build and is a code-execution path into
  CI if force-pushed.
- Commit Cargo.lock (540 packages). Producing it required fixing three
  resolution failures the workspace had always had: a non-existent
  makepad-widgets feature, two rusqlite versions both linking sqlite3, and
  four missed CellId call sites in spreadsheet-ui.
- Add .forgejo/workflows/nigig-build.yml.
- Replace five stale CAD docs that contradicted the code with one
  ARCHITECTURE.md; add PHASE0/1/2_STATUS.md and TEST_BASELINE.md.

Correctness (Phase 1)
- Rotation units: transform_point bound sin_cos() backwards, transposed X
  and Z, and applied axes in reverse order, so every exported STL was wrong
  even at zero rotation. It now shares the renderer's matrix helpers.
- GLB quaternions had norm 0.125 (half-angle applied to cos/sin, degrees
  read as radians) - invalid per the glTF spec.
- PDF wall/door/window yaw fed degrees to cos/sin.
- Fix a TOCTOU unwrap in touch picking; viewport.rs now has no unwrap().
- CommandContext gains update_node/insert_node_at/node_index: resize and
  modify were delete+create, silently moving nodes to the end of the scene.
- Wire MAX_UNDO_LEVELS (defined, exported, never read) and switch the undo
  stack to VecDeque; this also made the existing drag-merge logic reachable.
- CadNode::size() returned a fake 1x1x1 for CSG and extruded solids, making
  them unpickable outside a 1x1x1 box at their origin.
- Reject non-finite script input; makepad_csg clamps NaN rather than
  propagating it, so bad input produced silently wrong geometry.

Test baseline: 0 -> 722 passing, 0 failing
- 17 pre-existing failures fixed: 10 real defects (dependency-cycle
  detection, over-allocation of unassigned tasks, quote/backslash
  corruption on save, default rooms lost for all but the first region,
  RGA text ordering) and 7 tests that were themselves wrong, each checked
  against its production caller first.

Security (Phase 2)
- env!("CARGO_MANIFEST_DIR") was used as a runtime path in three places,
  including as the AI agent's working directory. All runtime data now goes
  under app_data_dir().
- Remove the hardcoded LAN LLM endpoint. It is now opt-in via
  NIGIG_CAD_LOCAL_OPENAI_URL/_MODEL and refuses plaintext HTTP to anything
  but loopback.
- Bound and content-sniff AI image attachments (8 MB cap, magic bytes);
  the MIME type came from the filename extension.
- Escape SVG/HTML output, and add SRI to the exported viewer's script tag.
  The pinned model-viewer@3.5.1 does not exist, so every exported viewer
  was silently broken; now 4.0.0 with a verified hash.
- Stop embedding $USER in exported PDFs and logging document content in
  release builds.
- CI now rejects reintroducing the runtime-path and hardcoded-endpoint
  classes; both gates were verified to fail on a reintroduced defect.

Add system_prompt.md and embed it with include_str!. The file was missing
from the repository, so the agent silently used a one-line fallback.
2026-07-28 16:49:30 +00:00
f719e3f544 feat(spreadsheet-ui): add workbook adapter persistence helpers 2026-07-28 16:44:51 +00:00
937acaaac9 refactor(spreadsheet-ui): route border controls through commands 2026-07-28 16:26:52 +00:00
ea4dcb801f feat(spreadsheet): centralize border mutations 2026-07-28 16:15:56 +00:00
037f5207af refactor(spreadsheet-ui): route style controls through commands 2026-07-28 16:05:46 +00:00
9455cfdf75 refactor(spreadsheet-ui): route grid mutations through commands 2026-07-28 16:02:31 +00:00
2301bab7c3 refactor(spreadsheet): expose sheet mutation command boundary 2026-07-27 18:13:12 +00:00
298594e69d feat(spreadsheet): route style mutations through commands 2026-07-27 18:09:41 +00:00
081cc58834 feat(spreadsheet): route layout mutations through commands 2026-07-27 17:55:55 +00:00
9fc4eda208 test(spreadsheet-ui): pass isolated toolchain to makepad app 2026-07-27 17:49:26 +00:00
2b6e8f1abb test(spreadsheet-ui): add makepad-test workspace smoke suite 2026-07-27 17:00:16 +00:00
30d3d79a93 feat(spreadsheet-ui): add headless workspace model 2026-07-27 16:49:16 +00:00
b1f6a6a90d fix(spreadsheet-ui): match current Makepad key codes 2026-07-27 16:46:01 +00:00
f01a15cf8a fix(spreadsheet-ui): use packed cell ids in grid lookups 2026-07-27 16:39:02 +00:00
4b9ed4f051 feat(spreadsheet): expose workbook sheet names 2026-07-27 15:55:41 +00:00
be88bafda8 feat(spreadsheet): add workbook sheet lifecycle APIs 2026-07-27 15:47:25 +00:00
0ad7171d82 feat(spreadsheet): preserve workbook active sheet in adapters 2026-07-27 15:42:19 +00:00
004ffc4bbf feat(spreadsheet): expose workbook-owned sheet data access 2026-07-27 15:37:33 +00:00
c0465c4f26 test(spreadsheet): verify batched command undo 2026-07-27 15:29:14 +00:00
27958ca2cc feat(spreadsheet): support batched workbook commands 2026-07-27 15:26:28 +00:00
a967341cee refactor(spreadsheet): route workbook mutations through commands 2026-07-27 15:22:53 +00:00
454b696f63 feat(spreadsheet): add workbook mutation command boundary 2026-07-27 15:20:04 +00:00
6d2ee6c844 refactor(spreadsheet): centralize sheet data exchange 2026-07-27 15:17:21 +00:00
1114f44b36 perf(spreadsheet): swap sheet data without cloning 2026-07-27 15:12:35 +00:00
0ffd2dd487 refactor(spreadsheet): structure dependency cycle errors 2026-07-27 15:10:10 +00:00
3845c9ce8e style(spreadsheet): format engine and test sources 2026-07-27 15:06:04 +00:00
b28fb02616 chore(spreadsheet): remove unused engine warnings 2026-07-27 15:04:30 +00:00
fe26cbe29a test(spreadsheet): harden cell reference coverage
Some checks failed
Payment domain and storage / isolated-payment-tests (push) Has been cancelled
2026-07-27 15:02:50 +00:00