Commit graph

317 commits

Author SHA1 Message Date
arena-agent
7d1a7316d2 feat(doc): render multi-line cell text on grown rows
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
nigig-build (CAD) / supply-chain (push) Successful in 2m39s
nigig-build (CAD) / cad-module (push) Failing after 8s
nigig-build (CAD) / full-crate-check (push) Successful in 4m46s
Cell values holding newlines (legacy strings, or fresh ones the
RFC-4180 quoting round-trip now produces) rendered collapsed inline;
the text round-tripped but every display line squeezed onto one
band. One shared line model now threads layout, renderer, caret,
highlight, hit test, and the keyboard surface:

- layout_projected_table grows a row by one 18px text line height
  per extra display line of its tallest visible cell over the 28px
  baseline; the table rect and the block flow below follow. Column
  widths stay fixed and single-line tables lay out byte-identical
  (control assertions pin both). Merge composition: a covered
  cell's hidden text never inflates its row, and a vertical merge
  anchor sums the grown heights of the rows it spans.
- The renderer draws styled runs segment by segment: an embedded
  newline in a run resets x to the inset and advances one line,
  keeping the whole text block vertically centered so single-line
  cells draw exactly where they did.
- table_cell_caret, cell_text_span_rects (one band per covered
  display line, replacing the single-rect helper), and the
  point-based cell_char_offset_at (y picks the band, x midpoint-
  splits within it) all resolve through one cell_text_line_col /
  cell_text_offset_at pair whose round-trip is unit-tested at every
  boundary, including empty lines and the newline's own offset.
- ArrowUp/ArrowDown, previously dead in cell mode, step between
  display lines keeping the visual column (clamped per line), Shift
  extending the in-cell selection; they stay inert at the first and
  last line and on single-line cells, so no implicit row exit and
  no half-moved cell ranges.

Defect fixed in-phase: an in-cell character span covering a newline
copied as a raw slice, so a paste re-distributed it across cells.
The in-cell copy branch now quotes through the same
quote_tabular_field as every other tabular payload; the
Shift+ArrowDown runtime test pins the quoted payload end to end.

Tests: line-math boundaries, row growth with block flow and merge
composition, multi-line caret rects, per-line selection bands,
point hit-testing clamps, vertical-arrow step/inertness/collapse,
a real tap parking on the tapped display line, and the quoted span
copy via copyable_selection_text and the TextCopy hit.
2026-08-02 10:36:28 +00:00
Arena Agent
e4fbd71d78 fix(cad): finish 1.9 and 4.6, found by auditing the whole plan
Some checks failed
nigig-build (CAD) / supply-chain (push) Successful in 2m39s
nigig-build (CAD) / cad-module (push) Failing after 7s
nigig-build (CAD) / full-crate-check (push) Successful in 4m51s
repo hygiene / hygiene (push) Successful in 4s
Asked whether every phase was complete, I checked each row against the
code instead of against my own record. Phases 0-5 were done except two
leftovers that had been reported as finished and were not.

1.9 -- the dead binding was still there:

    let rzyx = makepad_widgets::Mat4f::identity(); // Simplified — use transform directly
    let rzyx = mat4_mul(...);   // immediately shadows it

Harmless to execution, but it reads as though the rotation is being
skipped, in the one function that builds the model matrix -- in a module
where a rotation bug has already shipped four times. Deleted, with the
real computation formatted so the Z*Y*X order is legible and the degrees
contract stated. (The other half of 1.9, add_part's placement, was
genuinely done: the slot comes from the monotonic id, not parts.len().)

4.6 -- 10 `v18b rev2:` prefixes survived the archaeology sweep, in
arch_gltf, arch_pdf, viewport and workspace. Same treatment as the other
73: keep what the code does, drop which internal revision introduced it.
Now zero.

Also marked the 29 Phase 0/1/2/4 rows that were complete but never
recorded as such, with the specifics rather than a bare "DONE" -- 0.2
notes the lockfile is at the workspace root (a per-crate one would be
ignored, since nigig-build is a member); 1.1 notes the rotation contract
settled on DEGREES, not the radians the plan proposed; 4.3 notes it was
superseded by Phase 5.4 rather than done as written.

Every numbered row in the plan is now DONE, or REJECTED with the
measurement or counter-example that closed it.

783 lib + 154 integration tests pass. All 13 CI gates pass.
2026-08-02 10:27:45 +00:00
24d90b6855 feat(spreadsheet-ui): add retained cell render cache
Some checks failed
nigig-build (CAD) / supply-chain (push) Successful in 4m34s
nigig-build (CAD) / cad-module (push) Failing after 8s
repo hygiene / hygiene (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
2026-08-02 10:20:49 +00:00
Arena Agent
583fbbd092 docs(cad): record Phase 2 and 3 outcomes, including three rejections
Some checks failed
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
nigig-build (CAD) / supply-chain (push) Has been cancelled
repo hygiene / hygiene (push) Has been cancelled
Phase 2 is complete (2.6 was the last open item). Phase 3 is complete in
the sense that every item has been either done or measured and closed
with a reason.

Done:  3.2 world-AABB cache (5.9x), 3.4 redraw_all removal (53 calls),
       3.6 script regeneration on commit (425 us/frame at 500 parts),
       3.7 async exports, 3.9 grid batching (5,400 -> 1 tessellation
       per frame at 1080p), 2.6 save dialogs.
       3.1, 3.5 were already done in earlier phases.

Measured and rejected, with the numbers in the table:
  3.3  ParamHash memoisation. 50 ns/node for a Box. The polygon case is
       real (987 ns) but it is the vertex data, and bulk-hashing
       measured no faster; the fix would be a data-model change.
  3.8  Cost-estimate parallel threshold. 1.01x on a warm cache, which is
       the common case.

Two of the completed items were not what the plan described, and the
table now says so rather than quietly claiming the original wording:
  3.9  the plan blamed the "nice number" step computation. That is
       already a cheap if-else chain. The cost was stroke()-per-dash.
  3.2  the plan said to key the AABB cache on ParamHash. Doing that
       would have served a stale box after every drag, because
       ParamHash deliberately excludes the transform.

Also documents the export architecture in ARCHITECTURE.md 2d, including
why the 3D viewer and Bake stay directory-based -- both write companion
file pairs that reference each other by name.
2026-08-02 10:14:24 +00:00
Arena Agent
d61e215e9e perf(cad): batch the 2D grid into one stroke (3.9); measure 3.3 and 3.8
Some checks failed
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
nigig-build (CAD) / supply-chain (push) Has been cancelled
repo hygiene / hygiene (push) Has been cancelled
Phase 3.9 -- the real cost was not the "nice number" step computation
the plan named. That is already a cheap if-else chain, no log10/pow. It
was draw_dashed_line calling stroke() after every 6px dash, and stroke()
tessellates the entire accumulated path each time. A full-screen grid is
~50 lines of ~108 dashes: 5,400 tessellations per frame at 1080p, 14,688
at 4K.

Split into queue_dashed_line (appends to the path) and draw_dashed_line
(queues, then strokes) so single-line callers are unchanged. The grid
queues every dash and strokes once. Bubble markers are collected and
drawn after, not inside the loop -- they use draw_text and their own
fills, which would otherwise land in the middle of the grid's path. Also
one String allocation per grid line instead of two.

the_2d_grid_strokes_once_not_once_per_dash pins it. My first version
asserted exactly one stroke in the whole function and failed with 3: the
work-plane cross below the grid is a separate feature with its own
colour and correctly gets its own strokes. Scoped the assertion to the
grid rather than weakening it. Negative test: swapping one
queue_dashed_line back to draw_dashed_line fails it.

---

Phase 3.3 (memoise ParamHash on CadNode): MEASURED, NOT DONE.
  Box:              50 ns/node  -> 25 us/frame at 500 parts
  Extruded 64-gon: 987 ns/node  -> 493 us/frame

The Box case does not justify a cached field that every mutation would
have to invalidate -- the exact hazard Phase 5.4 removed from
part_geoms. The polygon case is the vertex data itself: I tried
bulk-hashing the slice as raw bytes and measured 125 us vs 128 us for
500 x 64 verts, i.e. nothing. The only real fix is to give polygons an
Arc identity the way Csg already has, which is a data-model change, not
a cache. Benchmark kept so the next person starts from numbers.

Phase 3.8 (cost estimate instead of node count): MEASURED, NOT DONE.
  200 nodes, cold cache: 8.80ms seq / 6.21ms par -> 1.42x
  200 nodes, warm cache: 5.81ms seq / 5.73ms par -> 1.01x

On a warm cache -- the common case, since the preview renderer has
already built every mesh -- parallel neither helps nor hurts. A cost
estimate would have to hash every node to count cache misses, in order
to choose between two paths that differ by 1% in the case it would most
often face. The threshold comment now carries these numbers instead of
"can be tuned based on real-world profiling".

783 lib + 154 integration tests pass. All 13 CI gates pass.
2026-08-02 10:13:13 +00:00
Arena Agent
bdf882b817 perf(cad): regenerate the parts script on drag commit, not per frame (3.6)
Some checks failed
nigig-build (CAD) / supply-chain (push) Successful in 2m39s
nigig-build (CAD) / cad-module (push) Failing after 7s
repo hygiene / hygiene (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
`script_dirty` was set on every MouseMove and FingerMove of a part drag.
That makes `sync_parts_from_any_dirty_viewport` call
`generate_parts_script()` -- formatting every part into a String -- and
the workspace then replaces the entire editor document via
`set_editor_text_all`. Per motion event.

Measured before changing it: 42 us at 50 parts, 170 us at 200, 425 us at
500, and that is the string formatting alone, before the code editor's
own work. See bench_parts_script_regeneration_per_drag_frame.

The reason it was set mid-drag no longer holds. The comment said it kept
the split 2D/3D viewports in sync while dragging -- true when each
viewport owned its own parts list, but since Phase 5.2 all three share
one CadDocument. A move IS their state the moment it happens; they need
a repaint, not a resync, and they get one.

Both commit paths already set the flag: the MouseUp arm for mouse
drags, and finish_part_drag for touch (reached from three places). So
the script still regenerates exactly when it needs to -- once, when the
edit is final.

a_drag_regenerates_the_script_on_commit_not_per_frame pins it. It walks
every arm that calls move_selected and asserts none of them set
script_dirty, then asserts the commit paths still exist -- because the
failure mode of this change is not "slow", it is "the script never
updates at all", and a test that only checked the first half would miss
it. Negative test: putting the assignment back fails it with the line
number.

782 lib + 154 integration tests pass. All 13 CI gates pass.
2026-08-02 10:05:45 +00:00
93faa96920 perf(spreadsheet-ui): invalidate grid after sheet switches
Some checks failed
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
repo hygiene / hygiene (push) Has been cancelled
nigig-build (CAD) / supply-chain (push) Has been cancelled
2026-08-02 10:03:16 +00:00
Arena Agent
84ed7d2e43 perf(cad): drop 53 redundant cx.redraw_all() calls (Phase 3.4)
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
repo hygiene / hygiene (push) Has been cancelled
cx.redraw_all() sets a flag that repaints every widget in the
application. Every one of the 52 calls in viewport.rs, and the 1 in
viewport_2d.rs, sat DIRECTLY after `self.area.redraw(cx)` -- the
targeted redraw was already there and the full-app repaint added
nothing. Verified mechanically before deleting: a scan for
`cx.redraw_all()` not preceded by `area.redraw(cx)` returns zero hits in
both files.

On a drag this ran per motion event: a whole-application relayout to
move one part.

What I did NOT touch, and why:
  workspace.rs (15)      cross-widget coordination. Both viewport sync
                         paths end in a redraw of the OTHER viewports,
                         and that is what makes removing the viewport's
                         own calls safe. Removing these would be a
                         different change with a different argument.
  viewport_input.rs (28) event paths; 13 are not paired with an
                         area.redraw at all, so each needs reading on
                         its own terms rather than a bulk edit.
  cad_editor_sheet.rs (2) not the viewport.

The risk here is a missed repaint, which no test can see, so I checked
the mechanism rather than relying on the suite staying green: cross-
viewport repaint runs through sync_parts_from_any_dirty_viewport (which
calls vp.redraw on each destination) and
sync_view_from_any_dirty_viewport (which ends in its own redraw_all).
Both live in workspace.rs and are untouched.

the_viewport_does_not_ask_the_whole_app_to_repaint pins it as a source
check, because asserting on repaints needs a live Cx the suite does not
have. Negative test: reintroducing one pairing in viewport_2d.rs fails
it with the file and line named.

781 lib + 154 integration tests pass. All 13 CI gates pass.
2026-08-02 10:02:20 +00:00
Arena Agent
73c4c49cb9 perf(cad): cache the world AABB per placement -- 230us -> 39us (Phase 3.2)
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
repo hygiene / hygiene (push) Has been cancelled
Measured before building, because I had previously dismissed this item
as "smaller" without checking. It is 5.9x at 500 parts, and hover
picking runs on mouse-move, so it is a per-frame cost.

pick_part's broad phase transformed 8 local corners by the model matrix
for every part on every pick. Phase 5.3 had already removed the
expensive half (it no longer re-meshes to read bounds), leaving 8 matrix
multiplies per part -- cheap individually, 230 us/frame at 500 parts.
SceneCache::world_aabb_for now memoises the result.

The key is a NEW type, PlacedHash, not the existing ParamHash. This is
the whole subtlety of the change: ParamHash deliberately excludes the
transform, because a local-space mesh cannot change when a part moves
(Phase 5.4). A world-space AABB is exactly the opposite -- moving the
part is the entire point. Reusing ParamHash here would serve a stale box
after every drag and make parts unpickable at their new position, which
is the picking equivalent of the stale part_geoms bug.

Making it a distinct type rather than "ParamHash plus a flag" means the
two cannot be confused at a call site.

a_move_invalidates_the_world_aabb_even_though_it_keeps_the_mesh pins the
asymmetry directly: the same move that rebuilds the AABB must still hit
the mesh cache. Negative test: making PlacedHash ignore the transform --
i.e. reverting it to ParamHash -- fails that test. Restored and green.

retain_world_aabbs is paired with every retain_meshes call site, for the
same reason that one exists: the map is keyed by NodeId and nothing
drops an entry when its node is deleted, so without it the map grows for
the session.

775 lib + 154 integration tests pass. All 13 CI gates pass.
2026-08-02 09:58:23 +00:00
arena-agent
54e1148b39 feat(doc): round-trip tabular clipboard payloads with RFC-4180 quoting
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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
doc-engine / engine (push) Successful in 16s
doc-engine / consumer (push) Successful in 3m58s
Cells holding tabs, newlines, CRs, or quotes re-distributed across the
grid on a copy/paste cycle — the documented caveat of every tabular
clipboard milestone. This closes it on both sides:

- table_grid_tsv quotes such fields on the way out (wrapped in double
  quotes, inner quotes doubled) via a new quote_tabular_field helper;
  plain and empty fields stay raw, so payloads stay byte-compatible
  with spreadsheets and plain text editors. The cell-range payload and
  the block-span document payload share the one builder, so both
  inherit the quoting at once.
- paste_table_payload replaces its split('\n')/split('\t') walk with
  split_tabular_payload, an RFC-4180-style tokenizer: quotes open only
  at field start (mid-field quotes are literal), doubled quotes read
  as one, tabs/newlines/CRs inside quotes are literal field text,
  CRLF rows outside quotes keep their tolerance, an unterminated
  quote reads to the end as best effort, and a single trailing
  newline adds no phantom row (a deliberate empty row survives).
- Caret parking, no-op skipping, empty-field clears, and the one-undo
  grouped write semantics of the raw paste milestone are unchanged;
  the caret offset in a multi-line value counts the newline too.

Tests: unit coverage for the writer and the tokenizer (every quoting
rule plus the quote/split round-trip property), runtime coverage of
copy quoting, paste restoring embedded tab/newline values verbatim
with one-undo and redo, and an end-to-end copy-cut-paste cycle; a
doc-engine materialize test pins special-character cell text
surviving peer sync and undo/redo verbatim. README caveats updated
and the milestone documented.
2026-08-02 09:54:40 +00:00
Arena Agent
07cef07dfb feat(cad): async exports with a save dialog (Phase 2.6 + 3.7)
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
repo hygiene / hygiene (push) Has been cancelled
Both plan items are the same call, so doing them separately would mean
writing the plumbing twice: the file picker's `save_data` takes owned
bytes, and serialising off the UI thread is what produces owned bytes.

Before: every export serialised on the UI thread straight into a File at
a hardcoded path -- generated/stl/model.stl, generated/3d/model.glb,
generated/floor_plan.pdf. A large scene froze the editor for the whole
serialise, and the second export of a session silently destroyed the
first.

Now:
  PDF, STL   spawn_export_to_target -> worker thread -> save dialog
  SVG        stays sync (the preview widget needs the bytes on the UI
             thread, so there is nothing to move) but gains the dialog
  CLI        already a String in memory; gains the dialog
  3D viewer  async, but stays directory-based ON PURPOSE: it writes TWO
             files and viewer.html references model.glb by relative
             name, so renaming the GLB through a picker would break it
  Bake       stays directory-based: writes the parts.obj/parts.cad pair,
             a workspace artefact rather than a document, and
             Solid::write_obj takes a path not a writer

Results come back through an mpsc channel drained on NextFrame, the same
mechanism the rebuild worker already uses -- not a second bespoke one.
The status says "exporting…" while in flight, and the completion message
for a dialog export says "ready — choose where to save" rather than
claiming the file is written, because at that point it is not. Reporting
success before the write is the exact bug fixed in the Save buttons
earlier.

The 3D companion HTML is now only written if the GLB actually landed.
Previously a truncated GLB still got a viewer.html beside it, which is
how "export succeeded" turned into a blank page.

ExportTarget::suggest gives each export a distinct default name
(<stem>-<project>-<counter>.<ext>) so successive exports do not propose
to overwrite each other.

sanitize_file_stem exists because a project name is user text that ends
up in a save dialog. It can contain a path separator, "..", a NUL, a
leading dash, or 300 characters of emoji. The test found a real bug in
my first version: replacing "/" with "_" turns "../../etc/passwd" into
"_.._.._etc_passwd", so trimming leading dots BEFORE the replacement
leaves "_.." behind. Trim after, and include "_".

Deleted in the same commit as their cause: write_floor_plan_pdf and
export_to_file, both now unreachable. Verified no callers remain
anywhere in crates/.

New tests: bytes land at the requested path; a failed write is reported
rather than swallowed (parent is a regular file, so create_dir_all
cannot succeed); an empty export still produces a file; the hostile
project-name corpus; successive suggestions do not collide.

772 lib + 154 integration tests pass. All 13 CI gates pass.
2026-08-02 09:52:27 +00:00
52eff6167d perf(spreadsheet-ui): invalidate full grid after scrolling
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
repo hygiene / hygiene (push) Has been cancelled
2026-08-02 09:51:13 +00:00
703bba3652 perf(spreadsheet-ui): distinguish dirty cells and full invalidation
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
nigig-build (CAD) / supply-chain (push) Successful in 2m38s
nigig-build (CAD) / cad-module (push) Failing after 8s
nigig-build (CAD) / full-crate-check (push) Successful in 4m53s
2026-08-02 09:38:43 +00:00
arena-agent
a66d7d2198 feat(doc): carry table grids in document-level clipboard payloads
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
nigig-build (CAD) / supply-chain (push) Has been cancelled
A block-span selection — Shift+Arrow across a table, select-all,
any multi-block drag — used to copy blank lines where tables sat,
so copying a document lost every table's content. Table blocks now
contribute their whole grid at their block position as tab/newline
lines, built by the same table_grid_tsv helper the cell-range
payload uses (extracted from cell_range_clipboard_text): one
builder, one convention, no drift between "copy a range" and
"copy across a table". Stored cell text exports verbatim — a
merge's covered cells keep their hidden values — and empty tables
still contribute nothing.

Cutting such a span was already structurally correct through
replace_block_range / CancelBlockRange, so the milestone is
payload-only: the payload now matches what actually disappears —
verified by a cut over [paragraph, 2x2 table, paragraph] draining
the document with "lead\na\tbc\nd\te\ntail" in the payload and one
undo restoring blocks AND every cell value. Also covered:
select-all through the TextCopy hit, and a partial mid-paragraph
span splicing the grid between its text fragments in order. The
stale "tables are skipped" select-all bullet is retired.
2026-08-02 09:35:13 +00:00
85f21a6f35 perf(spreadsheet-ui): consume dirty cells during intent dispatch
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
repo hygiene / hygiene (push) Has been cancelled
2026-08-02 09:34:16 +00:00
Arena Agent
c6e7635c5a test(cad): fuzz the coordinate parser; audit all 84 indexing sites
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
repo hygiene / hygiene (push) Has been cancelled
I dismissed indexing_slicing as "mechanical churn" without checking.
That was an unchecked claim about 105 reported panic sites, which is
exactly what I have been objecting to elsewhere in this codebase. Audited
all of them.

105 clippy hits are 84 unique lines. Every one is bounded:

  43  fixed-size arrays indexed by a literal or a 0..N loop whose bound
      matches the array -- mat4_mul, mat4_inverse, ray_aabb_intersect,
      the 8-corner projected box. Unindexable by construction.
  ~30 behind an explicit length check in the same function:
      verts.len() >= 12 (I-beam web), >= 8 (HSS inner wall),
      pts.len() == 4, chamfer_rect's `< 4` early return, polygon_area's
      `n < 3`, pick_part's per-triangle bounds test.
   ~11 `% len()` on a non-empty slice, or selection[i] over
      0..selection.len().min(3).

Converting these to .get() adds ~84 `else { continue }` arms guarding
conditions the compiler or an adjacent check already rules out, each one
a place to get the fallback subtly wrong. Not gated; the audit is
recorded in ARCHITECTURE.md 2c so the next reader gets the evidence
rather than the dismissal.

The one genuinely input-facing site is fuzzed instead.
parse_coord_input takes raw text from the coordinate box on every
keystroke and indexes parts[0..2] after a split. Two new tests: an
adversarial corpus (multi-byte leading characters, lone separators, RTL
and combining marks, 500-char inputs, inf/NaN/1e400) and every
char-boundary prefix of a valid input, because the box parses as you
type.

Building the corpus is where the actual work was. My first version --
garbage strings -- passed even with the length guards deleted, because a
first component that fails to parse makes `?` return before the second
index is evaluated. It looked like a strong test and tested nothing. The
cases that reach the guards are the ones whose FIRST component is valid:
"@5", "5<", "@5<45".

Negative test, per guard:
  spherical  parts.len() == 3 removed -> FAILS, index out of bounds
  polar      parts.len() == 2 removed -> FAILS, index out of bounds
  relative   parts.len() >= 2 removed -> still passes, and that is
             correct: the branch is gated on contains(','), and a string
             containing a comma always splits into at least two parts,
             so the check is redundant. Verified rather than assumed;
             left in place because it states intent locally.

763 lib + 154 integration tests pass. All 13 CI gates pass.
2026-08-02 09:33:31 +00:00
874a8481fa perf(spreadsheet-ui): track dirty grid cells
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
nigig-build (CAD) / cad-module (push) Has been cancelled
nigig-build (CAD) / full-crate-check (push) Has been cancelled
nigig-build (CAD) / supply-chain (push) Has been cancelled
2026-08-02 09:23:13 +00:00
1d3e6ab72a fix(pay): correlate USSD callbacks to the payment that asked for them
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
repo hygiene / hygiene (push) Has been cancelled
doc-engine / consumer (push) Successful in 3m56s
Payment domain, storage, platform and UI / payment-ui-tests (push) Failing after 4s
doc-engine / engine (push) Successful in 15s
nigig-map / test (push) Failing after 2s
Payment domain, storage, platform and UI / isolated-payment-tests (push) Failing after 1m58s
sms / gates (push) Successful in 3s
sms / robius-sms (push) Successful in 22s
sms / android (push) Successful in 21s
sms / nigig-sms (push) Successful in 4m6s
sms / supply-chain (push) Successful in 4s
R2.1. Review items 2.7 and 5.3.

## SessionRegistry was built in Phase 5 and never wired

The pump still read:

    while let Some(ev) = robius_ussd::next_event() {
        ... if let Some(id) = h.current.take() { ... }
    }

next_event() drains a process-wide queue and its entries carry no session
id, so every event was applied to whatever `current` happened to be.

Reproduced before changing anything: payment A is dispatched then abandoned
with events still queued; payment B starts; the pump drains A's ResultText
and SessionEnded and applies both to B. An abandoned payment settles the one
that replaced it.

## Now

- Dispatch claims the single in-flight slot. The USSD backend returns no
  session handle, so the intent id is the correlation id — enough, because
  the registry only has to tell this payment from the previous one.
- Every event is admitted against the live operation before it can touch an
  intent. Foreign and stale events are logged and dropped.
- Terminal events are de-duplicated; progress chatter still repeats freely.
  ussd_duplicate_key mirrors ProviderSignal::duplicate_key in the platform
  crate, and a test pins the two together.
- All six terminal and teardown paths retire the session id, so a late
  duplicate cannot revive a closed operation.

6 tests, including the abandoned-payment scenario by name. Verified by
removing the close call: that test goes red. CI gate asserts the pump still
admits, dispatch still claims, and at least six paths still close — matching
the method rather than a receiver literal, because rustfmt wraps the call.

## What this does not do

The pump still lives in PayFlowHandler, which still owns the pending-store
writes and the bulk queue. Moving *ownership* to PaymentCoordinator changes
who cancels on teardown and who observes an out-of-order callback, which is
what ADR 0007's device matrix exists to check. That is now tracked as R2.1b.

The correlation defect — the one that could settle the wrong payment — is
closed, and it did not need a device. I had previously filed the whole of
R2.1 as device-blocked; that was too coarse.

## Validation

  nigig-pay-ui 78 (was 72) / nigig-mpesa 20                        pass
  domain 148 / storage 41 / platform 64 / mpesa 29                 pass
  clippy -p nigig-pay-ui --no-deps -D warnings                     0 errors
  builds: pay-ui, pay, mpesa, core; default and --no-default       pass
  correlation injection: abandoned-session test fails without it   pass
  pin-capture guard                                                pass
2026-08-02 09:21:45 +00:00
Arena Agent
072dcde979 docs(cad): record Phase 5/6 outcomes, including the two rejections
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
repo hygiene / hygiene (push) Has been cancelled
Updates the file table in ARCHITECTURE.md for the three new files and
corrects the viewport.rs/workspace.rs descriptions, which still claimed
to hold the rendering and input code that moved out. A doc that lies is
worse than no doc.

Marks the plan items honestly:

  5.5 DONE   viewport.rs 8,023 -> 4,796. The original six-file target was
             not met and is not being pursued: the remaining 4,796 lines
             have no seam comparable to the two that were taken.
  5.6 DONE   workspace.rs 3,991 -> 3,273.
  5.7 REJECTED after counting. "Branched on in 40 methods" was 14, and
             21 of the 37 branches were in one function.
  5.8 REJECTED. The premise is false -- kind is not derivable from the
             solid, because six PartKinds share CadSolid::Box.

Phase 6 marked partially done, with what is left stated plainly: the
indexing_slicing ratchet is 105 sites in CAD, mechanical churn rather
than defect-finding, and the panic family it was really aimed at is now
at zero and gated.

Recording the rejections in the plan matters as much as the completions:
both items would have destroyed something real, and the next reader
should find the counter-evidence rather than the instruction.
2026-08-02 09:21:22 +00:00
Arena Agent
015cf44422 fix(cad): remove the reachable panics; gate unwrap/expect at 5
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
repo hygiene / hygiene (push) Has been cancelled
Phase 6, scoped to what is provable rather than a blanket -D warnings.

Measured the CAD module first: ~200 clippy warnings, but the panic
family -- the part the plan actually cared about, copying the pay
crates' ratchet -- was only 8: 2 unwrap, 6 expect, 0 panic!. Three were
real, five are genuine constructor invariants.

Fixed:

- code_editor.rs x2. `lazy_init_session(); self.session.as_mut().unwrap()`
  in both draw_walk and handle_event. Correct today, but the guarantee
  lived across a function boundary the compiler cannot see, so an
  unwrap sat on a widget draw path waiting for a third caller to forget
  the prologue -- and a panic there kills the editor with unsaved work
  in it. Added `editor_and_session()`, which splits the borrow and
  returns Option, so both sites take an early return instead.

  I first tried folding init into `get_or_insert_with`. That silently
  dropped the `keep_cursor_in_view = Once` side effect, which only
  happens on the create path. Caught it by grepping for the field rather
  than trusting the refactor; reverted.

- cad_scene.rs x1. MeshCache::get_or_build did
  `.write().expect("mesh cache poisoned")` while every other method on
  the type already degraded with `if let Ok(..)`. Reachable: the export
  path calls get_or_build on a spawned thread, so one panicking worker
  poisoned the lock and the next draw took the UI thread down with it.
  The cache is pure derived data -- every entry rebuilds from its node
  -- so a poisoned lock now costs memoisation, not correctness. The mesh
  is built before the lock is taken, and the double-check still prefers
  a racing thread's entry so Arc::ptr_eq comparisons stay consistent.

Left alone, with reasons: 4 x cad_scene "default material/layer always
exists" (SceneBuilder::new inserts both; verified) and 1 x arch_gltf
serde_json::to_vec over a Value built in that file.

New gate: "No new unwrap/expect in CAD production code", allowlist of 5.
A bare count drifts upward quietly and a blanket ban just gets
#[allow]-ed, so the count is pinned and each exemption is named in the
comment.

The gate skips #[cfg(test)] by BRACE DEPTH rather than stopping at the
first one. That matters: arch_gltf.rs has production code after two test
modules, so the existing panicking-macro gate's "stop at first
#[cfg(test)]" awk cannot see line 850 at all. My first attempt used the
same awk idiom and reported 4 of 5 -- I only noticed because the number
disagreed with clippy. Verified the older macro gate is not currently
hiding anything, but it is hiding it by luck.

Both negative tests pass: an unwrap added to viewport.rs is caught, and
one added to arch_gltf.rs *after* its test modules -- the exact blind
spot -- is also caught, named with file and line.

13 gates now, all green. 761 lib + 154 integration tests pass.
2026-08-02 09:20:12 +00:00
arena-agent
4df2193859 docs(doc): retire stale in-cell paste and migration-status claims
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
repo hygiene / hygiene (push) Has been cancelled
doc-engine / engine (push) Successful in 15s
doc-engine / consumer (push) Has been cancelled
Tabular paste superseded the clipboard section's "in-cell pastes
always stay a single whole-cell write, newlines included", and the
doc-engine README still framed the controller migration as "next"
even though the workspace navigation already runs on CrdtDocEditor
(the classic editor stays registered as a fallback). Found during
the phase audit.
2026-08-02 09:17:57 +00:00
Arena Agent
b26f4c8b91 refactor(cad): split handle_event into pointer and touch dispatch
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
repo hygiene / hygiene (push) Has been cancelled
Phase 5.7. handle_event was 952 lines holding two independent dispatch
loops -- one over raw Event (mouse buttons, motion, wheel), one over
hit-tested Hit (finger down/move/up/scroll). They share no locals, so
the seam was already there.

The plan item asked to "consider making 2D/3D two widgets" because the
view mode was "branched on in 40 methods". I counted before acting: 14
methods, 37 branches, and 21 of those branches are inside handle_event
alone. The remainder are mostly one-liners picking a pan axis or a zoom
helper.

Two widgets would have duplicated the entire input layer to delete a
handful of matches! guards, and doubled the surface the shared
CadDocument must keep coherent -- which is precisely what Phase 5.2 was
spent removing. The size problem was the event handler, not the enum.
Split the handler; keep the enum. Reasoning recorded in the module doc
so the plan item is not re-attempted from its original framing.

Verified as a move rather than a rewrite: the sequence of Event::/Hit::
match arms across viewport.rs + viewport_input.rs is identical to HEAD's
-- 41 arms, same order -- and the 3D-only desktop camera fall-through
appears exactly once, as before. Order between the two loops is
preserved and load-bearing: pointer arms set drag state the hit arms
read.

viewport.rs: 5,702 -> 4,796 lines (8,023 at the start of Phase 5.5).

761 lib + 154 integration tests pass. All 12 CI gates pass.
2026-08-02 09:14:22 +00:00
Arena Agent
f02de5645f refactor(cad): split handle_actions into three per-panel handlers
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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
Phase 5.6. `CadWorkspace::handle_actions` was a single 1,133-line
method: one flat sequence of `if button.clicked(actions)` arms covering
every control in the editor. Adding a control meant reading all of it to
find where the related ones lived.

Split along the seams the comments already marked -- the panel groupings
existed, they just were not expressed in the code:

  handle_view_and_plane_actions    work/inclined planes, per-axis grids,
                                   reference and clip planes,
                                   construction toggles, coordinate input
  handle_export_and_file_actions   CLI/OBJ/PDF/3D/STL/SVG export, the AI
                                   attach-image and model controls,
                                   open/save/save-as
  handle_properties_panel_actions  colour swatches, layer/material
                                   dropdowns, per-axis position/rotation/
                                   size inputs, DOF toggles

Order is the risk in splitting a sequential handler: several arms depend
on running after an earlier one has updated state. Verified mechanically
rather than by reading -- the full sequence of `ids!(..)` widget
references through handle_actions plus the three extracted bodies is
byte-identical to HEAD's, 147 references in the same order.

19 helpers became pub(super). That is not a widening: they were already
reachable from anywhere in the cad module, and pub(super) keeps them
exactly there. Nothing was made `pub`.

workspace.rs: 3,991 -> 3,273 lines.

761 lib + 154 integration tests pass. All 12 CI gates pass.
2026-08-02 09:11:20 +00:00
648c662a1e perf(spreadsheet-ui): cache visible text measurements
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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-08-02 09:10:46 +00:00
Arena Agent
1bc5d792a8 refactor(cad): extract the 25 draw_* methods into viewport_render.rs
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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
Phase 5.5, first cut. viewport.rs was 8,023 lines with a single
5,930-line `impl CadViewport`. The drawing methods are the largest
coherent seam in it: 25 methods, 2,321 lines, that only read editor
state and emit draw calls.

Rust merges inherent impl blocks for the same type across files, so this
is a pure move -- no signature changed and no caller was touched.
Verified mechanically rather than by eye: the set of method names across
viewport.rs + viewport_render.rs is byte-identical to the set in
viewport.rs at HEAD, 187 before and 187 after, none lost, none gained.

Two items needed pub(super) -- `part_model_matrix_cadnode` and
`DrawCadMesh::draw`. That is not a widening: both were already reachable
from anywhere in the cad module, and pub(super) keeps them there. No
item was made `pub`.

The module doc states the rule for what belongs in the file: a method
lives here if it takes &mut Cx2d/&mut Cx3d and emits drawing commands.
Anything that DECIDES what to draw -- picking, snapping, hit-testing,
tool state -- stays put. Deliberately mechanical, because the previous
attempts to split this file were judgement calls and did not hold.

viewport.rs: 8,023 -> 5,702 lines.

---

Phase 5.8 (remove kind_hint): REJECTED, with the counter-example
recorded as a test rather than a comment.

The plan item says to "derive kind from the solid variant". That is not
possible. Six PartKinds -- Cube, Wall, Slab, Door, Window, Beam -- all
build CadSolid::Box, and Cylinder/Column both build CadSolid::Cylinder.
kind_hint is not duplicated state; it is the only record of which one
the user asked for. Removing it would silently downgrade every Wall,
Slab, Door, Window and Beam to a Cube, taking the properties panel's
thickness controls and the Extrude tool's kind filter with it.

several_part_kinds_share_one_solid_variant_so_kind_is_not_derivable
asserts the collision directly, so the next person to read that plan
item finds the evidence instead of executing it.

I also built a script_tag/from_script_tag round-trip so the kind could
survive a save, then deleted it before committing: nothing reads
parts.cad back, so it would have been a write-only annotation -- the
exact "add an abstraction, declare the migration done" pattern this
phase exists to stop. The real gap is that the parts list has no
serialisation at all, which is a feature, not a cleanup.

756 lib + 154 integration tests pass. All 12 CI gates pass.
2026-08-02 09:08:27 +00:00
arena-agent
c5c1e0a3e9 feat(doc): paste tabular payloads across table cells
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
repo hygiene / hygiene (push) Has been cancelled
doc-engine / engine (push) Successful in 15s
doc-engine / consumer (push) Successful in 3m55s
A TextInput carrying tabs or newlines while the caret lives in a
table now pastes the spreadsheet way — one cell per tab stop, one
row per line — starting at the caret cell, or at the armed range's
normalized top-left (consuming the range like any paste-over-
selection). The distribution rides the grouped set_table_cells from
the previous milestone so the rectangle un-pastes in one undo step,
and the caret parks at the last cell the payload touched. Rows or
columns past the table edge clip, CRLF strips per line like
text-block pastes, empty fields clear their targets, and unchanged
cells are skipped so a paste lands neither redundant LWW ops nor
dead group members. Plain payloads keep the whole-cell char splice,
and cells still never spawn blocks.

The pre-existing in-cell paste test asserting the old "newline stays
embedded in the cell" behavior is rewritten to the distribution
semantics; new runtime tests cover the 2x2 distribution with caret
parking and the one-undo/redo round trip, edge clipping without
wrap-around, backward-spanned ranges pasting from their top-left,
CRLF with empty-field clears, and the mobile menu's Paste action
distributing from the pressed cell. Engine integration coverage
replays a grouped multi-cell write into a peer and asserts the
projections converge.
2026-08-02 09:02:05 +00:00
Arena Agent
5ffc515f91 perf(cad): build the command scene snapshot lazily -- 254us -> 0.8us
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
repo hygiene / hygiene (push) Has been cancelled
CadCommandCtx::new eagerly called scene_cache.scene_for(parts), which is
O(nodes): every node cloned, every material re-registered. No production
command reads that scene -- MoveNode, ResizeNode, RotateNode, YawNode,
ModifyNode, CreateNode and DeleteNode all address a node by id. Only
tests and the benchmark call ctx.scene().

Every command mutation bumps the PartsStore generation, so the next
context construction was a guaranteed cache miss. move_selected issues
one command per selected part per frame, making a drag O(commands x
nodes) for work that is O(1) per command. This arrived with Phase 5.1,
when the generation counter turned a previously accidental cache hit
into a guaranteed miss; the 0.4us baseline predated it.

The snapshot is now built on the first scene() call and memoised.
CommandContext::scene() returns Arc<CadScene> rather than &CadScene so
an implementation can build on demand instead of keeping one alive for
the context's lifetime.

This was also a latent CORRECTNESS bug, not only waste. The eager
snapshot was captured BEFORE the command ran, so a command that mutated
and then read scene() saw its own edit missing. Every mutating method
now drops the memo; those invalidate_snapshot() calls are placed
directly beneath the existing scene_cache.mark_dirty() calls so a new
mutator cannot silently miss one.

Two tests, both verified to fail against the old code:
- a_command_that_never_reads_the_scene_does_not_build_one asserts on
  SceneCache::rebuild_count (a new #[cfg(test)] counter) rather than
  wall-clock, so it is deterministic rather than machine-dependent.
  Fails 20-vs-0 when construction is made eager again.
- a_lazily_built_scene_reflects_edits_made_earlier_in_the_same_context
  reads the scene BEFORE mutating, then again after. Reading only after
  the mutation passes even with invalidate_snapshot() gutted -- the lazy
  build simply happens later -- so the first read is what gives the test
  teeth. I checked: the obvious version of this test was vacuous.

The benchmark was also measuring the wrong thing. It called ctx.scene()
each iteration to read the start position, which no production path
does: move_selected and finish_part_drag both read p.pos() off the parts
list. Fixing the lazy build alone moved undo 228us -> 0.5us but left
execute at 231us, because the benchmark was timing its own scene read.
It now mirrors the production callers.

Measured: execute 254us -> 0.8us, undo 246us -> 0.5us (1000 commands
over a 1000-node scene), ~300x. No other benchmark regressed.

755 lib + 154 integration tests pass. Test-name list diffed: +2, nothing
dropped. All 12 CI gates pass.
2026-08-02 08:57:10 +00:00
f33e999991 perf(spreadsheet-ui): improve unicode text width estimate
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
repo hygiene / hygiene (push) Has been cancelled
2026-08-02 08:53:26 +00:00
5800beb552 fix(pay): close the R1 gaps against the completion standard
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
Payment domain, storage, platform and UI / isolated-payment-tests (push) Failing after 2m2s
Payment domain, storage, platform and UI / payment-ui-tests (push) Failing after 3s
You are right that my first pass at R1 fell short. It deferred an item on a
judgement call, and it fixed three defects without regression tests naming
them. Four gaps, all closed here.

## 1. S8 was deferred; it is now done as far as the platform allows

I skipped certificate pinning as "wasted work if the endpoints get dropped".
That was my call to make about effort, not an external blocker.

Investigated properly: Makepad's HttpRequest exposes no pinning API. Its
only TLS control is set_ignore_ssl_cert, which weakens verification. Pinning
is not implementable at this layer without patching the platform crate.

What *is* enforceable is the property pinning mostly buys — that a mistyped,
injected or attacker-supplied URL cannot be dialled. check_transport gates
every request on HTTPS plus a four-host allowlist, at all three dial sites
in both copies of the client.

7 tests: lookalike hosts (api.coingecko.com.evil.example), embedded
credentials (https://evil@real/), explicit ports, plain HTTP, malformed
URLs, and an assertion that TLS is never disabled. Verified by disabling the
allowlist: 3 tests fail.

## 2. The 13-digit phone defect had no test naming it

I fixed it and moved on. It now has a regression test quoting the original
duplicated branches, plus a property test that normalisation output is
either empty or exactly a valid 10-digit 07/01 number — no third outcome.

## 3. The fee-policy UI wiring was untested

The domain guard had 11 tests; the wiring that connects it to the pay sheet
had none, so nothing proved the sheet actually consults it. Four tests now
cover the shipped policy: it identifies the bundled tariff, refuses once
stale, still quotes while current, and keeps "unknown band" distinct from
"stale table".

## 4. The exchange client had no tests at all

It does now, via the transport module above.

## A test that failed against itself

tls_verification_is_never_disabled_in_this_module asserts the module never
calls set_ignore_ssl_cert — and the literal in the assertion put the string
in the file, so it failed on first run. The needle is now assembled at
runtime. Recorded because it is exactly the kind of thing that gets
"fixed" by deleting the test.

## Completion standard, now written into the plan

A phase is done when: no item is deferred on a judgement call; no capability
is removed to satisfy a review item; defects found while implementing are
fixed in the same phase even if absent from the review; every fix carries a
test that fails without it; and CI enforces it.

## Validation

  domain 148 / storage 41 / platform 64 / mpesa 29                pass
  nigig-pay-ui 72 (was 66) / nigig-mpesa 20                       pass
  clippy -p nigig-pay-ui --no-deps -D warnings                    0 errors
  builds: pay-ui, pay, mpesa, core                                pass
  allowlist injection: 3 tests fail when disabled                 pass
  pin-capture guard                                               pass

Pre-existing and untouched: `cargo test -p nigig-pay --lib` fails to build
on clean HEAD (ClassifiedTransaction not in scope in transact.rs). Verified
by stashing. The transport tests are exercised through the nigig-mpesa copy.
2026-08-02 08:52:32 +00:00
3fda46b1eb fix(spreadsheet-ui): flush toolbar mutation intents per event
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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-08-02 08:46:05 +00:00
Arena Agent
11ef0fbf67 fix(cad): GPU buffers self-invalidate; stop re-meshing on every drag frame
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
repo hygiene / hygiene (push) Has been cancelled
Phase 5.4. Two defects with one root cause: part_geoms was keyed on the
raw node id, so staleness was invisible to the type and correctness rested
on seventeen scattered `part_geoms.remove(&id)` calls at the edit sites.
All seventeen are deleted; the map is now keyed on (id, ParamHash), the
same key MeshCache uses, and an entry whose hash no longer matches its
node is simply never read.

1. subdivide_selected drew the wrong geometry. It replaced each selected
   part's solid with a fresh Csg and invalidated the MESH cache, but never
   removed the part's part_geoms entry -- so the stale uploaded buffer
   stayed a hit and the viewport kept drawing the un-subdivided shape.
   An audit of every mutation path found this was the only edit site
   missing its manual eviction, which is exactly the failure mode a manual
   protocol produces.

2. ParamHash covered the transform and the material, so a pure move
   invalidated the mesh. It should not: build_mesh reads neither. The
   cached TriMesh is in the node's LOCAL space, and all four consumers --
   the draw loop, pick_part, the STL and glTF exporters -- apply the model
   matrix themselves. Dragging a part therefore re-triangulated it on
   every frame to produce byte-identical triangles, at up to 886 ns per
   extruded part per frame, per selected part. The hash now covers the
   solid parameters and nothing else.

Two existing tests asserted the old behaviour and were INVERTED, not
deleted -- they described what the code did rather than what it needed to
do:
  cache_detects_transform_edits_via_param_hash
    -> a_transform_edit_reuses_the_cached_local_space_mesh
  mesh_cache_self_invalidates_on_parameter_and_transform_edits
    -> mesh_cache_self_invalidates_on_solid_parameter_edits

New: build_mesh_output_does_not_depend_on_the_transform guards the
assumption the key now rests on -- if anyone makes build_mesh bake the
transform in, it fails and the key must grow it back. Plus
mesh_cache_hits_on_a_pure_transform_edit, mesh_cache_hits_on_a_material_edit
and an_uploaded_buffer_is_not_reused_after_the_solid_changes. Negative
test: restoring the transform to the hash makes the first two fail;
restored and green.

Deletion is still explicit (`retain` on the live id set) because it is the
one case a content hash cannot express -- there is no node left to hash.

ParamHash is pub(crate), not pub: it is how the caches agree on staleness,
not a consumer contract.

Also recorded in BENCH_BASELINE.md, not fixed here: bench_command_execute
_overhead is 227 us/cmd against a stale recorded 0.4 us. Verified
pre-existing -- 254 us on the commit before this branch, so this work
slightly improves it. CadCommandCtx::new eagerly builds a scene snapshot
that most commands never read, and every command bumps the generation, so
it is O(commands x nodes). The fix is to make that snapshot lazy; it is a
separate change and gets its own commit.

753 lib + 154 integration tests pass. Test-name list diffed, not just the
count. All 12 CI gates pass.
2026-08-02 08:44:42 +00:00
9a14c0ccad refactor(spreadsheet-ui): dispatch formula edits through intents
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
repo hygiene / hygiene (push) Has been cancelled
2026-08-02 08:43:50 +00:00
nigig-ci
25f32f7870 test(sms): build a real test suite (Phase G)
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
repo hygiene / hygiene (push) Has been cancelled
doc-engine / consumer (push) Has been cancelled
doc-engine / engine (push) Has been cancelled
nigig-map / test (push) Failing after 1s
sms / gates (push) Successful in 3s
sms / robius-sms (push) Successful in 23s
sms / android (push) Failing after 54s
sms / nigig-sms (push) Successful in 4m12s
sms / supply-chain (push) Successful in 6s
50 tests -> 102, and the two that were there at the start of this work
are deleted.

Where this started: robius-sms had ZERO tests, and nigig-sms had two --
bulk_sub_tab_default_is_contacts and bulk_sub_tab_variants_distinct.
Both asserted a derived Default and a derived PartialEq. Neither
mentioned SMS. Neither could fail short of the compiler breaking. That
is the defect that produced every other defect in this plan: nothing
could prove a change was safe, so nothing was ever deleted and every
bug survived contact with review.

Property tests (proptest, new dev-dependency)

  Seven over truncate_preview, format_timestamp, badge_text, and five
  more over segment_count, the rate limiter and ScheduleRequest.

  These are the ones that matter, because the hand-written cases in this
  repo all encode a bug someone had ALREADY found. proptest searches the
  space instead. I verified that by reinstating the original byte-slicing
  truncate_preview and confirming
  prop_truncate_preview_survives_mixed_scripts and
  prop_truncate_preview_respects_the_char_limit both fail against it --
  they would have caught A3 before it shipped.

  prop_rate_limiter_respects_capacity models the window independently
  and asserts the invariant across random clock sequences, rather than
  re-implementing the limiter's own arithmetic in the assertion.

Integration tests (2 new files, public API only)

  robius-sms/tests/sms_pipeline.rs and nigig-core/tests/sms_store.rs go
  through the public surface the application actually uses. The unit
  tests inside src/ can see private helpers; these cannot, which is the
  point -- they catch a refactor that keeps every unit test green while
  breaking the caller-visible contract.

  Two of them are privacy canaries. e1_message_bodies_are_never_persisted
  and e1_no_body_text_reaches_the_serialised_store fail if anyone removes
  #[serde(skip)] from OfflineSmsMessage.body. Verified by removing it:
  both fail, the other six pass. Nothing else in the tree would have
  noticed the inbox silently going back to plaintext on disk.

Named regression tests

  One per defect, named for it -- c1_*, d1_*, d3_*, e1_*, e7_*, a4_*,
  c3_*, c7_* -- so a future reader goes from a failing test straight to
  the bug it guards rather than to a git archaeology session.

New coverage for logic that had none

  - build_timeline_items / build_filtered_timeline_items: date-divider
    placement and the message indices the draw loop uses to index
    conv_data.messages. An off-by-one there renders the wrong body in
    the wrong bubble; it had no test at all.
  - kind_to_offline / kind_from_offline round-trip: the only thing
    stopping a cached Sent message reappearing as Inbox after a restart,
    which would flip the bubble to the wrong side of the screen.
  - normalize_number: what C1 groups on, across five formatting variants
    plus short codes and alphanumeric senders.

MessageKind::from_android_type / to_android_type were hoisted out of
sys/android/inbox.rs onto the type, the same way ScheduleRequest::validate
was in A4, so the provider mapping is testable off-device. An
unrecognised TYPE value is preserved verbatim in Unknown rather than
defaulted, and there is a property test asserting the round trip is
total over every i32.

CI: a test-count FLOOR at 100. A floor rather than a ratchet -- unlike
the clippy count, there is no reason to ever want this number to fall.

Deliberately NOT faked: the JNI cursor loop, the keystore round-trip and
broadcast delivery still need an emulator. A mock returning what I expect
would test my expectations, not Android. Those remain called out in the
Phase A and E commit messages.

Verified: 11/11 checks. 48 robius-sms + 46 nigig-sms + 8 sms_store = 102.
clippy -D warnings clean on host and aarch64-linux-android; nigig-sms
ratchet holds at 32 (my first draft added an orphaned `use super::*`,
caught by the ratchet and removed rather than baselined).
2026-08-02 08:43:16 +00:00
79950bbba6 refactor(spreadsheet-ui): dispatch grid intents through workspace
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
repo hygiene / hygiene (push) Has been cancelled
2026-08-02 08:34:27 +00:00
a264f53eb7 feat(pay): complete phase R1 of the remaining-work plan
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
Payment domain, storage, platform and UI / isolated-payment-tests (push) Has been cancelled
Payment domain, storage, platform and UI / payment-ui-tests (push) Has been cancelled
All four R1 items. Two of them uncovered defects that were not in the
review, and R1.4's corpus found a live bug.

## R1.1 versioned fee policy (U9)

The band table is a static "effective Jan 2024" snapshot. When Safaricom
revises a tariff, nothing notices: the old number is quoted and the user
authorises a total they are not charged.

FeePolicy attaches provenance and a 400-day trust horizon. Past it,
fee_for returns FeeError::PolicyOutOfDate rather than a number, and the
sheet refuses to quote exactly as it already does for an unknown band —
"no band for this amount" and "our table is old" stay distinguishable
because they need different messages. Verified by disabling the check:
4 tests fail. Domain tests 137 -> 148.

## R1.2 quality gate for nigig-pay-ui (Q2)

Correcting my own earlier count: 9 of the 10 unwraps were in tests. The one
production case, on the dispatch path inside the biometric branch, is now a
fail-closed path — no request, no prompt, no dispatch.

nigig-pay-ui now denies unwrap_used/expect_used outside tests and CI runs
clippy --no-deps -D warnings. Scoped with --no-deps because matrix_client
and robius-ussd carry pre-existing warnings that are not this crate's to
fix, and a gate that fails on someone else's code gets disabled.

Turning the lint on surfaced 13 more issues, one a real defect:
normalise_phone had two identical branches, and the 13-digit "254…" arm
produced an 11-digit result — not a valid MSISDN, but non-empty, so it
flowed on as a recipient. The duplication was hiding it.

## R1.3 exchange API (S7/S8/S10)

The client forged origin/referer for api2.bybit.com and p2p.binance.com,
impersonating those exchanges' own web clients against internal endpoints.
Removed from both copies (nigig-pay and nigig-mpesa — item A5 again), along
with the framework-identifying User-Agent. CI rejects either regrowing.

Requests are still made, now honestly identified. If those endpoints reject
an honest client the P2P panes fall back to their offline cache, which is
the true state of the integration rather than a disguised one.

Not done, deliberately: certificate pinning. Pinning an endpoint the
product may drop is wasted work, and whether to keep these endpoints is a
product call recorded in the plan.

## R1.4 adversarial CSV corpus (7.5)

parse_csv turns an untrusted file into a payment list. Corpus covers empty
input, injection-shaped fields, overflow, NUL, RTL override, full-width
digits, a 5,000-row file and malformed numbers. The bar is not "parses
correctly" but "never silently produces a payment nobody intended".
Verified it can fail. UI tests 61 -> 66.

## Validation

  domain 148 / storage 41 / platform 64 / mpesa 29 / pay-ui 66   pass
  clippy -p nigig-pay-ui --no-deps -D warnings                    0 errors
  builds: pay-ui, pay, mpesa, core; default and --no-default      pass
  pin-capture guard                                               pass
  fee-policy injection: 4 tests fail with the check removed       pass
  corpus injection: catches a fabricating normaliser              pass
2026-08-02 08:33:16 +00:00
Arena Agent
139f6de25a refactor(cad): one CadDocument shared by all three viewports
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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
The three CadViewport instances each owned a private PartsStore, kept in
step by copying the whole list every frame (parts_snapshot /
replace_parts_snapshot). Both are now deleted. They share one
Rc<RefCell<CadDocument>>: an edit in any viewport IS the edit in all of
them, so there is nothing to reconcile.

Copying was not an implementation detail, it was the source of a class
of bugs that were individually fixable and collectively unfixable:

- Only one viewport wins a sync frame, so the loser's id allocations
  were absent from the winner's snapshot and the assignment moved the
  counter BACKWARDS. Two parts drawn in different views between syncs
  got the same NodeId -- which keys MeshCache, part_geoms and every
  command. (Bounded earlier by sharing the allocator; now moot.)
- Breaking on the first dirty viewport left later ones dirty, so the
  loser overwrote the winner's edit on the next frame.
- Each sync deep-copied a Vec<CadNode> per destination and forced a
  full scene rebuild in each: ~98.5 us/frame at 100 parts, sustained
  for the whole of a drag.

sync_parts_from_any_dirty_viewport survives but no longer moves data. It
clears every script_dirty flag in one pass, returns the reporting
viewport's script, and asks the others to repaint.

Reads go through vp.parts() -> Ref<PartsStore>, writes through
vp.parts_mut() -> RefMut. Both borrow self, so "never hold a read guard
across a write" is checked by the compiler rather than left to reviewer
discipline. Where a read loop's body needs &mut self (a draw call), the
handle is cloned first via document() + read_parts() so the guard is
tied to the local Rc instead of to self -- restoring the disjoint-field
borrows the plain struct member used to give for free.

Deleted in the same commit as their cause:
- parts_snapshot / replace_parts_snapshot (40 lines)
- split_for_command + CommandBorrows, which existed only to prove to the
  borrow checker that parts, scene_cache and command_stack were distinct
  fields. The parts list is no longer a field at all;
  with_command_ctx replaces them.
- PartsStore::as_mut_vec, the last migration escape hatch. Its two
  remaining callers only wanted to edit fields, so they use a new
  iter_mut(); structural changes go through the specific methods, which
  is what makes "the generation moved" mean something.

share_document runs from request_rebuild as well as
initialize_split_viewports: the split viewports are created lazily, and
one that missed the join would quietly edit a document nobody can see.

Selection, part_geoms, scene_cache and camera state stay per-viewport by
design -- what is highlighted is a property of a view, not the model.

Test swap, verified by diffing the full test-name list rather than the
count (both are 761): command_borrows_fields_accessible is gone -- it
constructed a struct literal and read its fields back, asserting
something the compiler already guarantees, and would have passed against
every sync bug this removes. In its place,
an_edit_through_one_document_handle_is_visible_through_the_others
asserts the actual property. Negative test: replacing the shared handles
with three independent documents makes it fail (left: 0, right: 1);
restored and green.

746 lib + 154 integration tests pass. All 12 CI gates pass.
2026-08-02 08:30:09 +00:00
59dd29d1ce feat(spreadsheet-ui): queue grid mutation intents
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
repo hygiene / hygiene (push) Has been cancelled
2026-08-02 08:27:51 +00:00
arena-agent
08c3eed18d feat(doc): copy and clear cell ranges through the clipboard
Some checks failed
doc-engine / engine (push) Has been cancelled
doc-engine / consumer (push) Has been cancelled
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
repo hygiene / hygiene (push) Has been cancelled
An armed table cell range now copies as tab/newline text (rows top
to bottom, cells left to right, the spreadsheet convention) through
the same copyable_selection_text the TextCopy/TextCut hits answer
with, so the long-press cell menu floats the full action set instead
of a paste-only one. Cut and Backspace/Delete clear every non-empty
spanned cell via the engine's new set_table_cells, which pops each
sub-write's compensation into one Compensation::Group — the span
un-clears in a single undo step where Backspace previously dropped
the range and edited only the caret cell. Single writes keep the
leaf compensation and empty write lists record nothing.

Grouping cell writes surfaced a real undo asymmetry: an undo after a
redo re-applied the redone cell text, because redo pushed the write's
own text as its undo compensation (inverse() only swaps the verb,
keeping the stale text) while undo's leaf special-case captured live
cell state only in one direction. undo()/redo() now resolve
cell-text inverses per compensation member against the projected
text at both transition boundaries (redo_compensation/
undo_compensation), so leaves and groups round-trip through
arbitrary cycles and the "cells stay out of groups" restriction is
gone.
2026-08-02 08:21:31 +00:00
nigig-ci
1670ddf49c refactor(sms): delete the dead code and the duplication (Phase F)
Some checks failed
doc-engine / engine (push) Has been cancelled
doc-engine / consumer (push) Has been cancelled
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
repo hygiene / hygiene (push) Has been cancelled
nigig-map / test (push) Has been cancelled
sms / gates (push) Has been cancelled
sms / robius-sms (push) Has been cancelled
sms / android (push) Has been cancelled
sms / nigig-sms (push) Has been cancelled
sms / supply-chain (push) Has been cancelled
Net -596 lines. No behaviour change except F10, which replaces a label
that was lying.

F2 -- four copies of one stub backend.

  apple.rs, linux.rs and windows.rs were BYTE-IDENTICAL 66-line files,
  and unsupported.rs was the same again. That duplication is what let
  them drift: Phase C3 had to fix `Error::Unknown` in exactly one of the
  four, because only one had it wrong.

  Collapsed into sys/stub.rs, which each platform module invokes. 268
  lines become 35 plus one shared definition. The module is cfg'd out on
  Android, which has a real implementation and would otherwise report
  the macro as unused under -D warnings.

F3 -- TWO dead compose implementations.

  SmsComposePage (189 lines) was registered in the VM and instantiated
  nowhere. Separately, the FAB and its compose overlay were left in the
  DSL as `visible: false` with a comment saying "FAB removed: SMS
  compose/inbox navigation now lives in SmsActionBar" -- but 102 lines
  of DSL and 53 lines of handler stayed behind, wired to a button no
  user can reach.

  Deleted both, and send_reply() with them: it existed only to serve the
  unreachable overlay. Compose navigation is SmsActionBar's, as the
  comment already said.

F4 -- a whole second contact subsystem, unreachable.

  sms_screen.rs carried its own CONTACTS_CACHE, contacts_loaded(),
  load_contacts_into_cache(), display_name_for_number(),
  normalize_number(), try_load_contacts() and a
  contacts_load_attempted field. Nothing called any of it -- the live
  implementation is in conversations_list.rs.

  Worth noting the dead copy was also the WRONG one: its
  display_name_for_number did an O(n) linear scan of the whole phone
  book per lookup, where the live version is O(1) because
  cache_contact_number inserts under both the raw and normalised key.

F5 -- the page tree was written out twice.

  sms_bulk_page, sms_schedule_page and sms_more_page were each declared
  under Desktop AND under Mobile, byte-identical apart from indentation.
  Any change to a page header had to be made in both places or the
  layouts silently diverged. Now three named widgets plus a shared
  SmsPageHeader, referenced from both variants.

F8 -- serde, serde_json and robius-location were declared by nigig-sms
  and referenced nowhere in its sources.

F9 -- was_scrolling was read twice per frame from the same portal list;
  the copy in handle_event was bound and never used.

F10 -- the character counter was a hardcoded lie.

  The old compose page rendered "0 / 160 characters" and never updated
  it. It died with F3, but the bulk composer -- where the money actually
  goes -- had no cost indication at all. It now shows live segment count
  as you type, using segment_count() from Phase A5, because segments are
  the billing unit and "160" is only right for GSM-7: one emoji forces
  UCS-2 and drops the limit to 70.

  This is the only user-visible change in the commit.

F1 and F7 were already done, in Phase A (shared cursor.rs) and Phase D1
(I/O out of draw_walk).

The deletions orphaned eight imports, which are also removed. Together
that takes the nigig-sms clippy ratchet from 49 to 32 -- these were not
suppressed, the code they reported on is gone.

Verified: 10/10 checks. clippy -D warnings clean on host AND
aarch64-linux-android, 28 robius-sms tests, 22 nigig-sms tests,
nigig-build still builds, metadata --locked clean.
2026-08-02 08:21:07 +00:00
f3c2aa7a83 feat(spreadsheet-ui): define grid mutation intent type
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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-08-02 08:11:18 +00:00
23fce675de feat(pay): USSD automation on by default; containment moves to packaging
Some checks failed
Payment domain, storage, platform and UI / isolated-payment-tests (push) Has been cancelled
Payment domain, storage, platform and UI / payment-ui-tests (push) Has been cancelled
repo hygiene / hygiene (push) Has been cancelled
Option A, as requested. Plus an audit of the whole review against the code.

## The default flips

  nigig-pay-ui   default = []            (leaf stays off; see below)
  nigig-pay      default = ["demo"]
  nigig-mpesa    default = ["demo"]
  pageflipnav    default = ["native", "demo"]

`cargo run -p pageflipnav` now drives *334#, shows the PIN field and
dispatches. That is the app's primary function and it works out of the box.

A release build opts out:

  cargo build -p pageflipnav --no-default-features --features native

This was not one line. A first attempt flipped the four `default =` lines
and the opt-out still leaked: the app crates depended on nigig-pay-ui with
its own defaults, so `--no-default-features` on pageflipnav was silently
re-enabled one level down. Verified with a compile probe rather than
cargo tree, which truncates. The inner deps now carry
`default-features = false`, and the probe confirms both directions:
default -> demo ON, --no-default-features -> demo OFF.

ADR 0007's Play-policy note is untouched. The containment requirement of
review item 0.1 is not dropped — the flag exists, CI exercises both
directions, and a shipped build still cannot dispatch. What changed is
which way it points by default, so development and device testing are not
fighting it.

CI guards inverted to match: they now assert automation is on by default
*and* that the packaging opt-out still works. check-no-pin-capture.sh now
probes the packaging build, since the default legitimately captures a PIN.

## REVIEWS/IMPLEMENTATION_AUDIT.md

Every phase checked against the code, not against the tranche notes. Where
they disagreed the code won. Summary: phases 0-5 and 7 done bar 5.2 and
Keystore provisioning; phase 6 substantially done with the thread_local
session ownership outstanding; phase 8 partly.

## B7 found live while auditing

Month navigation had never been examined. Both copies of the transactions
widget still stepped months with Duration::days(31) and years with
Duration::days(366). Reproduced before touching it:

  2025-12-28 -1 month => 2025-11-27   (drifts a day)
  2026-03-30 -1 month => 2026-02-27   (drifts; repeated steps skip a month)
  2027-06-15 +1 year  => 2028-06-15   (366d wrong on a non-leap year)

Now uses checked_add_months/checked_sub_months, which clamp to the end of
the target month, and checked_add_signed on the day path. An
unrepresentable date leaves the view where it was.

Neither claimed done nor flagged open — simply never looked at. That is the
argument for auditing code rather than notes.

## Validation

  domain 137 / storage 41 / platform 64 / mpesa 29 / pay-ui 61   pass
  cargo check: pay-ui, pay, mpesa, core (default and opt-out)    pass
  demo-on-by-default probe, both directions                      pass
  no-PIN-capture guard against the packaging build               pass

Unrelated and still blocking a full APK: nigig-map fails to compile on
clean HEAD (12 errors, no field center_lat on ViewportState).
2026-08-02 08:06:43 +00:00
Arena Agent
c83f8e083f refactor(cad): commands mutate through PartsStore, not a bare Vec
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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
First migration step of Phase 5.2, and it closes a real hazard rather
than only moving types around.

`CadCommandCtx` held `&mut Vec<CadNode>`, taken out of the store by
`split_for_command` via `as_mut_vec()`. Every command therefore edited
the parts list *underneath* `PartsStore`, so none of their mutations
bumped its generation. `SceneCache::scene_for` compares generations, so
the only thing preventing a permanently stale scene was each command
remembering to call `mark_dirty()` by hand -- the exact discipline-based
invalidation the generation counter was introduced to replace.

Every command happens to call it today. One omission in a new command
would have produced a scene that never rebuilds, with no failing test.

`CadCommandCtx` and `CommandBorrows` now carry `&mut PartsStore`.
move_node and update_node go through `get_mut_by_raw_id`; create,
delete and insert already used store methods once the type changed.
The generation now moves on its own and the `mark_dirty()` calls become
belt-and-braces instead of load-bearing. `CadCommandCtx::new` also
builds its scene with `scene_for`, so it shares the cache rather than
rebuilding unconditionally.

Four tests. Three exercise the real `CadCommandCtx` against a real
`PartsStore` -- the mock keeps its own `Vec` and structurally cannot
observe the generation, which is why the gap survived this long. The
fourth pins the hazard itself: a mutation that skips the generation
still needs `mark_dirty()`, demonstrated through a `#[cfg(test)]`
`as_mut_vec_without_bump` that models the old path. Negative-tested by
restoring the bypass: "a command edit must move the generation, not
rely on a manual mark_dirty()".

Scope kept deliberately narrow: commands.rs only, ~93 sites left in
viewport.rs and workspace.rs. ARCHITECTURE.md updated with what is done
and what remains.

746 lib + 154 integration, 0 failed. All twelve gates pass, benchmarks
still build and run.
2026-08-02 08:01:19 +00:00
7566374237 refactor(spreadsheet-ui): make shared model handle mandatory
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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-08-02 07:51:41 +00:00
arena-agent
00b3eb6e98 feat(doc): select the whole editing context with Ctrl/Cmd+A
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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
Keyboard select-all lands in the CRDT editor, mirroring makepad's
text_input. A parked cell cursor selects its whole cell text (the
in-cell character span, collapsing any armed merge range); otherwise
the selection spans the first layout glyph to the last with the
caret following the focus, so Copy, Cut, style toggles and
Backspace-over-span all treat it like a maximal Shift+Arrow
selection. Table blocks ride the range like any middle block: the
clipboard payload keeps skipping their cells while a cut drains them
through replace_block_range, so one undo restores the document.

Touch sessions in Edit mode float the platform clipboard menu on the
fresh selection (the keyboard-select-all pattern from text_input),
mirrored through clipboard_menu like the long-press request; the
cell-rect lookup it shares is factored into cursor_cell_rect. A
desktop Ctrl+A never makes a menu request, and a document without
glyphs leaves the caret put. copyable_selection_text goes
crate-visible so hosts rendering their own copy affordances read the
same payload the hits answer with.
2026-08-02 07:47:06 +00:00
Arena Agent
0d05a5e62f feat(cad): add the shared CadDocument (Phase 5.2 foundation)
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
repo hygiene / hygiene (push) Has been cancelled
Introduces `CadDocument` and `SharedCadDocument`
(`Rc<RefCell<CadDocument>>`) -- one owner for the parts list, its
generation counter and the id allocator -- with the semantics the
viewports will move onto.

Deliberately NOT wiring `CadViewport` onto it in this commit. That is
103 call sites (73 viewport.rs, 20 workspace.rs, 8 commands.rs), each
needing its borrow scope checked individually, and bundling it with the
type definition would produce a diff nobody can review and a bisect
target nobody can isolate. This lands the destination, proven by test;
the migration follows one file per commit.

Four tests, each negative-tested:

- an edit through one handle is visible through the other -- the whole
  point of the phase;
- the generation counter is shared, so SceneCache::scene_for cannot
  serve a stale scene to a viewport that has not synced yet;
- two separately constructed documents do NOT share, so the first two
  cannot pass for the wrong reason;
- sequential borrows are fine and overlapping ones are rejected. That
  one states the borrow discipline as an executable rule rather than a
  comment, using try_borrow_mut so it documents the failure without
  aborting.

Verified before designing, rather than assumed:

- Every `self.parts` read in viewport.rs is a short-lived expression or
  a loop, and only two loops mutate `self` at all (~6231, ~6265) -- both
  touching `selection`, a different field, so neither becomes a
  BorrowMutError.
- `split_for_command` hands out `&mut Vec<CadNode>` tied to `&mut self`,
  which is the one construct genuinely awkward under RefCell. Every
  caller already scopes it in a block and drops it before touching
  `self` again, so it maps onto a RefMut guard -- but that holds because
  of how the callers are written, not because the signature enforces it,
  and ARCHITECTURE.md now says to re-check it rather than assume it.

The migration rule -- never hold a `parts()` guard across a call that
can reach `parts_mut()` -- is recorded with the two loops to re-check
first if a BorrowMutError ever appears.

738 lib + 154 integration, 0 failed. All twelve gates pass.
2026-08-02 07:43:52 +00:00
f021bdc0f5 fix(pay): the gate message hid the way to turn automation back on
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
Payment domain, storage, platform and UI / isolated-payment-tests (push) Has been cancelled
Payment domain, storage, platform and UI / payment-ui-tests (push) Has been cancelled
Reported: the *334# automation used to work and now cannot be reached, and
the status message reads as though the capability was removed.

The capability was not removed. Verified with git:

- `demo` and the USSD dispatch gate are both present in cc05abd, the
  initial commit, before any of my work.
- 67abe2b "phase zero payment containment" (2026-07-27) predates my first
  commit d0f5e74 (2026-07-29); `git merge-base --is-ancestor` confirms it.
- `git diff d0f5e74..HEAD` on pay_flow_handler.rs shows I added and removed
  no `cfg!(feature = "demo")` gate at all.
- robius-ussd, including the 534-line AccessibilityService that drives the
  menu, is untouched by my commits.

What I did get wrong is the wording. The original message was:

  "USSD dispatch disabled: compile with `--features demo` to enable"

Blunt, but it named the flag. I replaced it with "This app tracks payments —
it doesn't send them", which is accurate about the default build and says
nothing about how to change it. Read on a device, that sounds like the
feature was deleted. That is a real regression in usability and it is mine.

The message now leads with the fact that it is off *in this build* and names
the flag again, while keeping the honest framing about the PIN:

  "Automated *334# payment is off in this build. Rebuild with
   `--features demo` on Android to enable it, or send in the M-Pesa app and
   it will appear here automatically. No M-Pesa PIN was requested or
   stored. [tracker-3]"

Marker bumped to tracker-3 so the running build is identifiable.
2026-08-02 07:43:45 +00:00
ea3eee6d41 refactor(spreadsheet-ui): name model sheet selection explicitly
Some checks failed
repo hygiene / hygiene (push) Has been cancelled
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-08-02 07:42:13 +00:00
Arena Agent
5e2d578583 fix(project): port the mobile grid to the shared 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
repo hygiene / hygiene (push) Has been cancelled
origin/main (92b1daf) removed `SpreadsheetGrid.data` in favour of a
`SharedWorkspaceModel`, but did not update this caller, so nigig-build
stopped compiling: five E0609s on `grid.data`.

The desktop/mobile handover open-coded what the model now does:

- Going to mobile it read the saved workbook, deserialized it by hand,
  branched on the multi-sheet vs legacy format, and copied the active
  sheet's data into the grid. That is `WorkspaceModel::load_saved()`,
  which handles both formats.
- Going to desktop it serialized the grid's data, re-read the workbook
  from disk, replaced the active sheet, and wrote the whole thing back.
  The grid now edits the shared model in place, so `model.save()`
  preserves every sheet with no read-modify-write.

The save error was also being discarded with `let _ =` in both branches.
It is now logged: a failed handover save loses whatever the user typed
on mobile, and reporting it costs a line.

Both branches shrink to roughly a third of their previous size, because
the duplicated format-handling was the bulk of them.

734 lib + 154 integration + spreadsheet-ui pass. All twelve gates pass.
2026-08-02 07:36:55 +00:00
Arena Agent
5a4ddc993f refactor(cad): share one part-id allocator across viewports (Phase 5.2)
First piece of state to become genuinely shared rather than copied.

Last commit fixed the id allocator moving backwards during sync by
reconciling the three counters on every push. That bounded the damage
but left the cause: three viewports each owning a `next_part_id`, kept
in step by copying whole snapshots, where only one viewport can win a
frame. A counter duplicated three ways cannot be made correct that way,
only patched -- which is exactly the argument for Phase 5.2, so this
takes the step instead of adding another patch.

`PartIdAllocator` is an `Rc<Cell<u64>>` handed to all three viewports by
`CadWorkspace::share_part_id_allocator`. An id handed out in any view is
never handed out again, with no sync step involved. `Rc<Cell>` rather
than `Arc<Mutex>`: the viewports are UI-thread only, and a `u64` is
`Copy` so no borrow can outlive the call and there is no `RefCell` panic
to reason about.

Removed as a result:
- `next_part_id` from `CadViewport` and all five open-coded
  `let id = self.next_part_id; self.next_part_id += 1;` sites.
- The `next_part_id` element of `parts_snapshot` /
  `replace_parts_snapshot`. The snapshot pair is one field smaller,
  which is the direction Phase 5.2 is going.
- `reconcile_next_part_id` and its four tests, now dead. Deleting the
  workaround in the same commit that removes its cause -- leaving both
  is how this codebase accumulated two of everything.

Kept: ids arriving from outside the allocator (script rebuild, file
load, undo restore) were never issued by it, so `reserve_past_nodes`
still runs on every `replace_parts_snapshot`.

Five tests. The load-bearing one asserts two clones interleave without
collision AND that they alias the same counter; a companion asserts two
*separately constructed* allocators do not share, so the first cannot
pass for the wrong reason. Negative-tested by making `clone` deep-copy:
"ids must be globally unique" fails.

Also covered: reserving past adopted nodes, reserving never lowering the
counter, and saturating at u64::MAX rather than wrapping to 0 and
reissuing live ids.

734 lib + 154 integration, 0 failed. All twelve gates pass.
2026-08-02 07:36:55 +00:00
6f4fb8058e refactor(spreadsheet-ui): keep shared model attachment single-source
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
repo hygiene / hygiene (push) Has been cancelled
2026-08-02 07:34:54 +00:00