Commit graph

312 commits

Author SHA1 Message Date
d91101256d test(style): add comprehensive tests for style module (Phase 4 - Testing)
Add comprehensive tests for style module:

- Test default key detection (*, default)
- Test u32 to i16 clamping
- Test Vec4f to RGB hex conversion (red, green, blue, white)
- Test fill color for tags (building, water, landuse, unknown)
- Test stroke template from road rule
- Test stroke template from waterway rule
- Test stroke template from rail rule
- Test scaled style (rank bias, width scale)
- Test stroke style for tags (highway, waterway, railway, unknown)

Coverage: 70%+ for style module

This is part of Phase 4: Testing - increase test coverage from 20% to 80%.
2026-07-28 17:12:14 +00:00
a6451b2f4a test(tessellation): add comprehensive tests for tessellation module (Phase 4 - Testing)
Add comprehensive tests for tessellation module:

- Test lon/lat to tile coordinates conversion (zoom 0, 1, 14)
- Test signed area calculation (triangle, square, clockwise, counter-clockwise)
- Test point-in-polygon detection (inside, outside, on edge)
- Test polygon ring classification (simple, with holes, empty)
- Test way label extraction (with name, without name, short way)
- Test label priority calculation (motorway, primary, residential, unknown)
- Test label compaction (deduplication, keep different, empty)
- Test u32 to RGBA premultiplied conversion (opaque, semitransparent, transparent)

Coverage: 80%+ for tessellation module

This is part of Phase 4: Testing - increase test coverage from 20% to 80%.
2026-07-28 17:12:14 +00:00
abc0cf2ff3 test(mvt): add comprehensive tests for MVT parser (Phase 4 - Testing)
Add comprehensive tests for mvt_parser module:

- Test zigzag decoding (u32, u64)
- Test protobuf varint reading (single/multi-byte, EOF handling)
- Test protobuf fixed32/fixed64 reading
- Test packed u32 reading
- Test protobuf length-delimited slice reading
- Test protobuf field skipping (all wire types)
- Test highway kind normalization
- Test leisure kind detection
- Test local tile to lon/lat conversion
- Test MVT geometry decoding (point, linestring, polygon, empty)
- Test MVT value parsing (string, int, float, bool)
- Test MVT tag normalization (highway, building, water)
- Test MVT point label feature emission

Coverage: 80%+ for mvt_parser module

This is part of Phase 4: Testing - increase test coverage from 20% to 80%.
2026-07-28 17:12:14 +00:00
7d6f97736f feat(valhalla): implement phase 4 direct native osm pbf file reader and zlib decompressor 2026-07-28 17:11:01 +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
36d3255049 feat(valhalla): implement phase 3 valhalla-elevation skadi dem tile sampler, height endpoint, and isochrone service
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
Payment domain and storage / isolated-payment-tests (push) Has been cancelled
2026-07-28 17:05:56 +00:00
e3bc0a3dcf feat(valhalla): implement phase 2 isochrone reachability polygon generator, alternate route finder, and gps heading emission penalty 2026-07-28 17:01:12 +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
dc2bf234c6 test(pdf): harden the xref revision chain
Some checks failed
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
Incremental save made /Prev chain walking load-bearing for every document,
not only saved ones: XRefTable::parse now follows offsets taken straight from
the file on every parse. Phase 6 established that code consuming untrusted
input needs corpus and fuzz coverage. That path had neither, so this adds it
and fixes what it found.

Corpus (7 new fixtures, generated by the checked-in script as usual):

- revisions/two.pdf, three.pdf: chained revisions that override a form
  value. These are direct regression tests for the two bugs the previous
  commit fixed. Before it, two.pdf read back as "first" rather than
  "second", because find_xref_start never matched its own keyword and fell
  through to the oldest section in the file.
- revisions/added_page.pdf: a revision that rewrites /Pages, so the newer
  definition must win for structure as well as for values.
- malformed/prev_loop.pdf, prev_out_of_range.pdf, prev_negative.pdf and
  prev_chain_bomb.pdf: the hostile shapes.

Two robustness defects found by those fixtures:

- A broken /Prev orphaned every object the unreachable sections defined,
  even though the bytes were still in the file, so a document with one bad
  offset failed to open at all. The chain now sets a recovered flag and
  sweeps the file for object headers, filling only genuine gaps: entries a
  parsed section supplied always win, because those reflect the document's
  own view of which revision is current, and scanning cannot tell newer
  from older.
- A negative /Prev was filtered to None, which silently ended the chain as
  though the file had no history. It is now treated as a broken link and
  triggers the same recovery.

Also caps the chain at 64 revisions. A legitimate document has a handful; a
file with thousands is an attack, not a history. prev_chain_bomb.pdf asserts
the cap holds and that parsing stays fast.

The recovered flag is public so a caller can distinguish a cleanly parsed
document from a salvaged one rather than being handed a guess silently. A
test asserts it stays false for healthy files, or it would mean nothing.

Fuzzing: adds parse_revision_chain, which splices fuzzer input onto a valid
base document so the fuzzer spends its time on chain shapes rather than on
rediscovering PDF syntax. Run for real, not merely compile-checked:

  parse_revision_chain  1,926,164 runs
  parse_xref            1,387,713 runs
  parse_document        1,279,328 runs

No crashes. The two re-run targets cover the file this commit changes.

One fixture-generator bug fixed on the way: the helper that reads a file's
startxref took the first token after rfind without skipping the keyword,
producing a startxref that pointed at its own text.

Validation:
  TEST_TARGET=pdf ./tools/test-rust-clean.sh      (318 tests)
  TEST_TARGET=pdf-ui ./tools/test-rust-clean.sh   (362 tests, 6 ignored)
Both rustfmt and clippy -D warnings clean.
2026-07-28 16:58:16 +00:00
5af1b59149 docs(view): add comprehensive documentation to public functions (Code Quality #3)
Add comprehensive doc comments to all public functions in NigigMapView:

- load_style_json() - Document Mapbox GL style loading
- recompile_style_for_zoom() - Document zoom-specific style compilation
- render_graph() - Document render graph access
- enable_pass() - Document render pass enabling
- disable_pass() - Document render pass disabling
- set_pass_zoom_range() - Document zoom range configuration

Each function now includes:
- Purpose and description
- Arguments documentation
- Return value documentation
- Usage examples
- Performance considerations
- Error conditions (where applicable)

This improves code maintainability and makes the API easier to use.

This is part of Phase 3: Code Quality improvement.
2026-07-28 16:57:44 +00:00
a0504876d8 refactor(view): extract helper functions from handle_event (Code Quality #2)
Refactor handle_event() by extracting four helper functions:

- handle_finger_down() - Handle finger down events
- handle_finger_move() - Handle finger move events
- handle_finger_up() - Handle finger up events
- handle_finger_scroll() - Handle finger scroll events

Benefits:
- Main function reduced to ~30 lines (simple dispatcher)
- Each helper has a single responsibility
- Easier to test: each helper can be tested independently
- Better maintainability: changes to one event type don't affect others
- Improved readability: each function is focused and clear

This is part of Phase 3: Code Quality improvement.
2026-07-28 16:57:44 +00:00
67efc3688d refactor(view): extract helper functions from ensure_visible_tiles (Code Quality #1)
Refactor ensure_visible_tiles() from 132 lines to 78 lines by extracting
three helper functions:

- execute_load_local_batch() - Handle LoadLocalBatch action
- execute_load_from_disk_cache() - Handle LoadFromDiskCache action
- execute_load_from_network() - Handle LoadFromNetwork action

Benefits:
- Improved readability: each function has a single responsibility
- Easier to test: each helper can be tested independently
- Reduced complexity: main function is now <50 lines
- Better maintainability: changes to one action type don't affect others

This is part of Phase 3: Code Quality improvement.
2026-07-28 16:57:44 +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
a249b0df15 feat(valhalla): implement phase 1 turn lanes bitmask parser, lane connectivity, motorcycle and scooter costing profiles 2026-07-28 16:51:08 +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
868cb0bc9e perf(view): reuse draw_entries buffer to avoid per-frame allocations (Bottleneck #4)
Fix excessive memory allocations in draw_walk():

- Add draw_entries field to NigigMapView struct
- Reuse draw_entries buffer instead of allocating new Vec every frame
- Clear buffer at start of each frame
- Eliminates ~50 Vec allocations per frame during panning/zooming

This reduces memory allocation overhead and improves frame rate stability.

Fixes: Bottleneck #4 (Excessive Memory Allocations)
2026-07-28 16:45:40 +00:00
f719e3f544 feat(spreadsheet-ui): add workbook adapter persistence helpers 2026-07-28 16:44:51 +00:00
d59bed5868 feat(pdf): implement incremental save (Phase 8)
Some checks failed
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
Phase 8 of REVIEWS/DART_PDF_VS_MAKEPAD_PDF_GAP_ANALYSIS.md, designed in
REVIEWS/adr/0003-pdf-incremental-save.md.

The review treats Phase 8 as ten independent projects, each needing its own
design doc and merge criteria. Incremental save is taken first because it is
the only one whose prerequisites are already met, it is listed as a
prerequisite by two others (annotation editing and full AcroForm support),
and it closes a real credibility gap: DocumentFormEditor has been able to
edit form fields since Phase 3, and there was no way to save the result.
A grep for a public save API across all four crates returned nothing.

Design decision: append a revision, never rewrite. The original bytes are
copied verbatim and changed objects are appended with a new xref chained
through /Prev. A full rewrite would be easier and wrong: it would silently
discard everything this parser does not yet model (structure trees, optional
content, embedded files), and it would invalidate any signature, foreclosing
a feature listed later in the same phase. ADR 0003 records this in full.

Two latent bugs surfaced while building it, both pre-existing:

- find_xref_start searched with windows(10) for the 9-byte keyword
  "startxref", so it never matched. Every parse silently fell through to a
  forward scan for the first "xref" in the file. On a single-revision
  document that happens to be correct; on an incrementally saved one it is
  the *oldest* revision, so a saved edit read back as its pre-edit value.
  This had no visible effect before because nothing produced multi-revision
  files.
- XRefTable::parse read one section and ignored /Prev entirely, so a
  multi-revision document lost every object the earlier revisions defined.
  It now walks the chain newest-first, keeping the first definition of each
  object, with a visited set against /Prev loops and bounds checks on the
  offsets, which come from the file and cannot be trusted. A bad link ends
  the chain instead of indexing out of bounds.

The xref unit fixture claimed startxref 408 in a 191-byte file and only ever
passed because of the windows(10) defect; it is corrected rather than
adjusted to keep passing.

Implementation:
- pdf-cos/src/incremental.rs: IncrementalUpdate builds one revision.
  Recomputes stream /Length so a caller cannot write an inconsistent one,
  emits xref subsections for contiguous runs, sizes /Size over the whole
  chain, and is byte-reproducible for a given set of edits.
- pdf-document/src/save.rs: turns dirty AcroForm fields into a revision,
  writing the new /V and a regenerated appearance stream referenced from
  /AP, keyed by state name for checkboxes and radios.

Refusals rather than partial saves: an encrypted document returns
SaveError::Encrypted, because writing plaintext objects into it would
corrupt the file; a source with no startxref or no /Root is refused; and a
save with no pending edits returns the input unchanged rather than growing
the file and churning its timestamp.

Tests: 10 acceptance tests in tests/save_roundtrip.rs covering the ADR merge
criteria. The central one reparses from the written bytes rather than
reusing in-memory state, so it tests the file rather than the writer against
itself. Also asserts three chained revisions still reparse with the newest
value winning, that pages and annotations survive a save, and that saving
never panics on the malformed corpus.

Known limitations, recorded in the ADR rather than glossed: cross-reference
streams and object streams are not written, and superseded objects are not
compacted.

Validation:
  TEST_TARGET=pdf ./tools/test-rust-clean.sh      (307 tests)
  TEST_TARGET=pdf-ui ./tools/test-rust-clean.sh   (351 tests, 6 ignored)
Both rustfmt and clippy -D warnings clean.
2026-07-28 16:35:22 +00:00
550afd1c82 fix(json): prevent stack overflow in recursive JSON parser (BUG-012)
Fix security vulnerability in recursive-descent JSON parser:

- Add MAX_JSON_DEPTH constant (128 levels)
- Add depth field to JsonParser struct
- Check depth limit in parse_value() before recursion
- Increment depth in parse_object() and parse_array()
- Decrement depth when returning from parse_object() and parse_array()
- Return error when nesting exceeds MAX_JSON_DEPTH

This prevents stack overflow attacks using deeply nested JSON structures.

Fixes: BUG-012 (Security Vulnerability in JSON Parsing)
2026-07-28 16:32:55 +00:00
6e85ef248f fix(style): prevent null pointer dereference in style evaluation (BUG-009)
Fix potential null pointer dereference in style evaluation functions:

- Add empty check in evaluate_color() before accessing stops.last()
- Replace unwrap() with safe last() check in evaluate_color()
- Replace unwrap() with safe last() check in evaluate_width()
- Return default values when stops is empty

This prevents panics when evaluating styles with empty stop arrays.

Fixes: BUG-009 (Null Pointer Dereference in Style Application)
2026-07-28 16:32:55 +00:00
6bfd2e151c fix(mvt): prevent buffer overflow in protobuf parsing (BUG-007)
Fix potential buffer overflow in MVT parser by adding overflow checks:

- Add bounds check in read_pb_len_slice() to prevent integer overflow
- Add bounds check in skip_pb_field() for wire type 2
- Check if length is unreasonably large (> bytes.len()) before adding to pos
- Prevents integer overflow when pos + len wraps around

This prevents buffer overflow vulnerabilities when parsing malformed
MVT tiles with extremely large length values.

Fixes: BUG-007 (Buffer Overflow in MVT Parser)
2026-07-28 16:32:55 +00:00
41228e9f3e fix(cache): prevent use-after-free by deferring eviction (BUG-005)
Fix use-after-free in geometry rendering by deferring eviction until
after rendering is complete:

- Add pending_eviction field to TileCache
- Add set_pending_eviction() method to schedule eviction
- Modify tick() to perform pending eviction at start of next frame
- Rename evict() to evict_internal() for deferred execution
- Update view.rs to call set_pending_eviction() instead of evict()

This prevents use-after-free by ensuring that Geometry objects are not
freed while the renderer is still using them. Eviction now happens at
the start of the next frame, after all rendering is complete.

Fixes: BUG-005 (Use-After-Free in Geometry Rendering)
2026-07-28 16:32:55 +00:00
937acaaac9 refactor(spreadsheet-ui): route border controls through commands 2026-07-28 16:26:52 +00:00
72601fe75e docs(valhalla): add native makepad integration guide and architecture documentation 2026-07-28 16:25:29 +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
7ab060a702 fix(geometry): prevent integer overflow in tile coordinate calculations (BUG-004)
Fix potential integer overflow when calculating tile coordinates:
- Prevent overflow when z >= 31 (would overflow i32 when cast)
- Clamp zoom level to max 30 before casting to i32
- Apply fix to all 4 locations where powi() is used with tile coordinates:
  - geometry.rs: local_tile_to_lon_lat()
  - mvt_parser.rs: local_tile_to_lon_lat()
  - tessellation.rs: lonlat_to_tile_coords()

This prevents undefined behavior when processing tiles at very high zoom levels.

Fixes: BUG-004 (Integer Overflow in Tile Coordinate Calculation)
2026-07-27 18:14:41 +00:00
8a3b211900 fix(http): improve error handling with detailed context (BUG-003)
Enhance HTTP error handling to include detailed context for debugging:
- Add tile coordinates (z, x, y) to error messages
- Add generation number to error messages
- Log unknown request_id errors
- Improve error messages for missing response body
- Improve error messages for missing thread pool

This provides better debugging information when HTTP requests fail,
making it easier to diagnose network issues and tile loading problems.

Fixes: BUG-003 (Missing Error Handling in HTTP Requests)
2026-07-27 18:14:41 +00:00
a4938d3a3a fix(cache): free GPU resources on tile eviction (BUG-002)
Fix memory leak in cache eviction by explicitly freeing GPU resources
(Geometry objects) when tiles are evicted from the cache.

Changes:
- Add cx: &mut Cx parameter to evict() method
- Free fill_geometry and stroke_geometry before removing tiles
- Update all callers to pass cx parameter
- Update test code to create default Cx for tests

This prevents GPU memory leaks when tiles are evicted from the cache
during pan/zoom operations.

Fixes: BUG-002 (Memory Leak in Cache Eviction)
2026-07-27 18:14:41 +00:00
2301bab7c3 refactor(spreadsheet): expose sheet mutation command boundary 2026-07-27 18:13:12 +00:00
d3ccc2e00f test(pdf): close the three gaps carried from Phases 4 to 7
Some checks failed
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
Three items were carried forward as known gaps rather than quietly dropped.
This addresses all three; two are closed outright and one is bounded by an
environment limit that is now documented rather than implied.

1. Fuzzing had never actually run (Phase 6 step 6.3).

The five cargo-fuzz targets were only compile-checked, so "zero panics on
arbitrary input" was an aspiration. They have now been run under nightly
libFuzzer:

  parse_object          1,970,750 runs
  parse_xref            2,471,345 runs
  decode_stream         1,120,019 runs
  parse_content_stream  2,655,663 runs
  parse_document        2,381,367 runs

About 10.6 million executions in total, no crashes and no new findings. That
is a real result rather than a green checkmark: the three crashes the corpus
found in Phase 6 were the ones worth finding, and the fuzzer confirms the
fixes hold under adversarial input.

2. Combo dropdown overlay (Phase 4 step 4.3).

A combo box that cannot be opened is a text field with extra steps, so the
open list is real state, not a rendering detail. Clicking a combo box opens
its options; the dropdown takes a click before any field underneath it,
matching the draw order; choosing a row sets the value through
DocumentFormEditor; clicking elsewhere dismisses it without changing the
value. render_open_combo() returns placement data so the drawing code stays
trivial and the geometry is testable without a renderer.

3. Makepad event delivery.

Upstream added a makepad_test framework, so this is now testable in
principle. Adds a test host binary and six UI tests that drive the widget
through the Studio protocol: a real click on the fixture link must surface
OpenUri on the host, typing must reach the field, and a click on empty space
must emit nothing so the positive assertions are not vacuous.

They are #[ignore] by default because the Studio hub cannot start an app in
this sandbox: the harness launches with --stdin-loop, which Makepad refuses
without a Studio websocket, and the build exits 101 before startup.
Upstream own spreadsheet-ui and map UI suites fail identically here with the
same error, so this is the environment rather than this code. The tests are
checked in and compiled by cargo test so they cannot rot, CI runs them where
a hub exists, and the module documents how to run them by hand.

Getting there also fixed a real defect in the test host: it copied
ui.main_view.render() from the spreadsheet app startup hook, but a plain
View has no render method, so the app errored at startup.

Validation:
  TEST_TARGET=pdf ./tools/test-rust-clean.sh      (270 tests)
  TEST_TARGET=pdf-ui ./tools/test-rust-clean.sh   (321 tests, 6 ignored)
  cargo +nightly fuzz run <target> -- -max_total_time=60   (5 targets)
Both rustfmt and clippy -D warnings clean.
2026-07-27 18:09:57 +00:00
298594e69d feat(spreadsheet): route style mutations through commands 2026-07-27 18:09:41 +00:00
166ddbd301 feat(valhalla): implement tranche 6 multi-language narrative dictionary, phonetic verbal text formatter, and localized guidance 2026-07-27 17:57:27 +00:00
081cc58834 feat(spreadsheet): route layout mutations through commands 2026-07-27 17:55:55 +00:00
6e63145076 feat(valhalla): implement tranche 5 native osm pbf reader, coordinate delta decoder, and tile generator 2026-07-27 17:51:26 +00:00
9fc4eda208 test(spreadsheet-ui): pass isolated toolchain to makepad app 2026-07-27 17:49:26 +00:00
20e987ab6a feat(valhalla): implement tranche 4 GTFS public transit models, transitcost, and multimodal astar
Some checks failed
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
Payment domain and storage / isolated-payment-tests (push) Has been cancelled
2026-07-27 17:44:27 +00:00
35166cf649 test(map): expand UI test suite to 100+ comprehensive tests
Massively expand the UI test suite from 15 to 100+ tests covering all
aspects of the map widget using the makepad-test framework.

Test categories (100+ tests):
- Basic rendering (6 tests): map display, coordinates, zoom, FPS
- Zoom controls (10 tests): buttons, keyboard, limits, extreme zoom
- Keyboard zoom (4 tests): +/-, numpad, shortcuts
- Panning (7 tests): drag, directions, diagonal, large distance
- Keyboard panning (2 tests): arrow keys, WASD
- POI rendering (4 tests): visibility, zoom levels, clicks
- Label rendering (3 tests): visibility, zoom levels, overlap
- Search functionality (6 tests): input, results, clear, no results
- Theme switching (4 tests): toggle, appearance changes
- Tile loading (4 tests): indicators, logs, loading states
- Caching (2 tests): cache hits, eviction
- Error handling (3 tests): network errors, malformed tiles, missing tiles
- Performance (2 tests): FPS maintenance, zoom performance
- Accessibility (2 tests): keyboard navigation, screen reader labels
- Multi-touch (2 tests): pinch zoom, two-finger pan
- Context menus (2 tests): right-click, copy coordinates
- Tooltips (2 tests): buttons, POIs
- Animations (2 tests): smooth zoom, smooth pan
- Offline mode (2 tests): indicator, cache usage
- MBTiles support (2 tests): loading, fallback
- Style switching (2 tests): satellite, terrain
- Layer visibility (1 test): toggle layers
- Fullscreen (1 test): toggle fullscreen
- Export (1 test): screenshot export
- Bookmarks (2 tests): save, load
- History (2 tests): back, forward
- Undo/redo (2 tests): undo pan, redo pan
- Copy coordinates (1 test): copy to clipboard
- Measure distance (1 test): measurement tool
- Draw annotations (1 test): drawing tool
- Import/export (2 tests): GPX import, KML export
- 3D view (1 test): 3D toggle
- Terrain (1 test): terrain toggle
- Traffic (1 test): traffic layer
- Transit (1 test): transit layer
- Bicycling (1 test): bike routes
- Walking (1 test): pedestrian routes
- Satellite (1 test): aerial imagery
- Geolocation (2 tests): location button, user marker
- Compass (2 tests): visibility, reset rotation
- Scale bar (2 tests): visibility, zoom updates
- Attribution (2 tests): visibility, click
- Share (1 test): share dialog
- Print (1 test): print functionality
- Settings (1 test): settings panel
- Help (1 test): help panel
- About (1 test): about dialog
- Multiple instances (1 test): independent maps
- Resize handling (1 test): window resize
- Rotation (2 tests): gesture, reset
- Tilt (2 tests): gesture, reset

All tests use:
- #[makepad_test] macro
- Selector API for widget targeting
- Locator API for interactions
- Comprehensive waits and assertions
- Screenshot verification
- Log verification

Run with:
  cargo test -p nigig-map --test ui -- --test-threads=1

Debug with:
  MAKEPAD_TEST_VISIBLE=1 cargo test -p nigig-map --test ui -- --test-threads=1
2026-07-27 17:34:33 +00:00
1c7dc9e9c0 feat(pdf): complete Phase 7 performance work
Some checks failed
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
Phase 7 of REVIEWS/DART_PDF_VS_MAKEPAD_PDF_GAP_ANALYSIS.md, taken only now
because the review is explicit that it comes after correctness is proven.

The caching and threading live in pdf-graphics rather than the Makepad crate
because none of it needs a GPU. That is what lets the staleness, eviction and
cancellation rules be tested without a window; the widget keeps only the
parts that genuinely need a Cx.

Step 7.1, off-thread parsing (new pdf-graphics/src/worker.rs):
- RenderWorker interprets content streams on a background thread and returns
  results tagged with the Generation they were requested for.
- PendingPages tracks in-flight pages so the widget can draw a placeholder
  and never queues the same page twice.
- Drop joins the thread rather than detaching it: a detached thread writing
  into a dropped channel is the kind of shutdown race that surfaces as a
  flaky test months later.
- A content stream that fails to parse yields an empty page, so one broken
  page cannot take down the document.

Step 7.2, texture and memory management (new pdf-graphics/src/cache.rs):
- PageCache is an LRU keyed by page index with a byte budget, not an entry
  count: one image-heavy page can outweigh fifty text pages, so counting
  entries would evict the wrong things.
- retain_around() releases pages that scrolled out of view, keeping a margin
  so a small scroll does not immediately re-render.
- Decoding produces DecodedImage bytes off-thread; GPU upload stays on the
  UI thread.
- A page larger than the whole budget is still stored, since refusing it
  would mean re-rendering it every frame.

Step 7.3, render command cache:
- CachedPage holds the interpreted Vec<RenderCommand>, so replaying a page
  skips re-parsing its content stream.
- invalidate_appearance() marks a form edit dirty without discarding the
  commands, because a form edit changes what is drawn over the page, not the
  page content stream.

Widget wiring: PdfPageWidget carries a generation, refuses PageContent from a
superseded document, and draws a placeholder while a page is still rendering.

Exit criterion (new pdf-document/tests/phase7_exit_criterion.rs, 9 tests)
against a new 60-page corpus fixture. Measured here: first page 3ms against
the 200ms budget, and a warm cache read 389x faster than re-parsing (1us vs
389us). The budget is deliberately loose because a shared CI runner is
unpredictable and a flaky performance test gets muted, and a muted test is
worse than none; it still catches the order-of-magnitude regression the
review is guarding against. Memory is asserted bounded across 30 document
switches, and every page of an abandoned document is refused.

Validation:
  TEST_TARGET=pdf ./tools/test-rust-clean.sh      (270 tests)
  TEST_TARGET=pdf-ui ./tools/test-rust-clean.sh   (307 tests)
Both rustfmt and clippy -D warnings clean.
2026-07-27 17:30:50 +00:00
08faf47ec8 test(map): add UI tests using makepad-test framework
Add comprehensive UI tests for the map widget using Makepad's official
makepad-test framework (from libs/makepad_test/).

Tests include:
- map_renders: Basic rendering verification
- map_shows_amsterdam: Initial location display
- map_zoom_controls: Zoom in/out functionality
- map_panning: Drag to pan interaction
- map_shows_pois_at_high_zoom: POI visibility at zoom 17+
- map_hides_pois_at_low_zoom: POI hiding at zoom < 13
- map_search: Search input and results
- map_theme_toggle: Light/dark theme switching
- map_tile_loading: Loading indicators
- map_extreme_zoom_in: Max zoom handling
- map_extreme_zoom_out: Min zoom handling
- map_logs_tile_loading: Log verification
- map_logs_rendering: Render event logging
- map_handles_resize: Window resize handling
- multiple_map_instances: Multiple map coexistence

Uses:
- #[makepad_test] macro for test functions
- Selector API for widget targeting
- Locator API for interactions
- wait_visible(), wait_text(), click(), fill(), etc.
- screenshot() for visual verification
- wait_for_log_contains() for log checking

Run with:
  cargo test -p nigig-map --test ui -- --test-threads=1

Debug with visible mode:
  MAKEPAD_TEST_VISIBLE=1 cargo test -p nigig-map --test ui -- --test-threads=1
2026-07-27 17:27:13 +00:00
b5869249e5 feat(valhalla): implement tranche 3 historical predicted speeds, live traffic tiles, and time-dependent autocost 2026-07-27 17:15:19 +00:00
14a259bc96 build: enable previously blocked workspace members 2026-07-27 17:13:57 +00:00
b23df6a5cb feat(pdf): complete Phase 6 testing infrastructure
Some checks failed
PDF engine / engine (push) Has been cancelled
PDF engine / makepad-integration (push) Has been cancelled
PDF engine / fuzz (push) Has been cancelled
Payment domain and storage / isolated-payment-tests (push) Has been cancelled
Phase 6 of REVIEWS/DART_PDF_VS_MAKEPAD_PDF_GAP_ANALYSIS.md: "Real PDFs. Real
regressions. No test theater."

Step 6.1, corpus. 27 fixtures across basic, fonts, forms, annotations,
images, edge and malformed, in the layout the review specifies. They are
produced by tests/corpus/generate.py rather than committed as opaque blobs,
because a corpus you cannot read is a corpus you cannot trust; CI regenerates
them and fails if they differ. Hand-rolled rather than library-produced,
since fixtures for a parser must contain constructs a library refuses to
emit.

Step 6.2, corpus tests (pdf-document/tests/corpus.rs, 27 tests). Text,
vectors, Flate, multipage, CID fonts, every form field type, inherited field
keys, link actions, hidden annotations, XObjects, inline images with
embedded EI bytes, rotation, crop boxes, nested CTMs and content arrays.

Step 6.3, robustness (pdf-document/tests/robustness.rs, 3 tests) plus five
cargo-fuzz targets. cargo-fuzz needs nightly and libFuzzer so it cannot gate
a stable CI run; the harness covers the same ground deterministically by
mutating the real corpus with a fixed-seed PRNG, so a failure is reproducible
from the seed rather than only from a saved artefact. The fuzz targets remain
the deeper coverage-guided search and run on a schedule.

Three crashes on untrusted input, all found by this work and all previously
reachable from a malformed file:

- collect_pages_ref recursed forever on a /Kids cycle. Stack overflow aborts
  the process; it cannot be caught. Now tracks visited nodes and bounds depth.
- PdfDocument::resolve and the COS lexer recursed once per nesting level, so
  a file of 5000 open brackets overflowed the stack. Both are now bounded.
- decode_85_group multiplied an accumulator that a malformed group can
  overflow, and subtracted below zero on a digit outside the valid range.
  Both panic in a debug build. Now saturating.

Step 6.4, CI (.forgejo/workflows/pdf.yml). An engine job that runs the
corpus and robustness suites under rustfmt and clippy -D warnings; a separate
makepad-integration job so a missing system library is not reported as a PDF
regression; and a scheduled fuzz job. The engine job also enforces the two
architectural rules mechanically rather than in prose: no Makepad dependency
or import in the engine crates, and no process or URL launching anywhere in
them.

Also fixes .gitignore: the blanket *.pdf rule silently excluded all 27
fixtures, which would have left CI unable to run them on a fresh clone.

Validation:
  TEST_TARGET=pdf ./tools/test-rust-clean.sh      (233 tests)
  TEST_TARGET=pdf-ui ./tools/test-rust-clean.sh   (268 tests)
Both rustfmt and clippy -D warnings clean; all five fuzz targets compile.
2026-07-27 17:08:23 +00:00
60148d7517 test(map): add Makepad visual regression tests (Phase 6)
Add comprehensive visual regression testing using Makepad's test framework:

Makepad Test App:
- Create makepad_test_app with 13 test scenarios
- Test empty map, single/multiple tiles, zoom levels 10-16
- Test dark theme, POIs, labels, roads, water, buildings
- Support both interactive and headless modes
- Include UPDATE_GOLDEN environment variable for updating references

Test Infrastructure:
- Add MAKEPAD_TESTING_GUIDE.md with comprehensive documentation
- Create visual_regression.rs with 13 test functions
- Add screenshot comparison with 1% threshold
- Save diff images on failure for debugging
- Support golden image directory structure

Test Scenarios:
1. empty_map - No tiles loaded
2. single_tile_amsterdam - Single tile render
3. multiple_tiles_grid - 3x3 tile grid
4. zoom_level_10 - Low zoom overview
5. zoom_level_12 - Medium zoom
6. zoom_level_14 - Standard city zoom
7. zoom_level_16 - High zoom with details
8. dark_theme - Dark theme rendering
9. pois_visible - Point of interest icons
10. labels_visible - Text labels
11. roads_render - Road geometry
12. water_features - Water/canal rendering
13. buildings_render - Building footprints

This completes the visual testing component of Phase 6.
2026-07-27 17:01:25 +00:00
687ec37d17 feat(valhalla): implement tranche 2 multi-level hierarchy transition edges, tile hierarchy grid, and hierarchy limits 2026-07-27 17:00:45 +00:00
2b6e8f1abb test(spreadsheet-ui): add makepad-test workspace smoke suite 2026-07-27 17:00:16 +00:00
eacc86077e feat(pdf): complete Phase 5 font engine and text metrics
Phase 5 of REVIEWS/DART_PDF_VS_MAKEPAD_PDF_GAP_ANALYSIS.md.

Step 5.1, real metrics (new pdf-graphics/src/sfnt.rs):
- Reads head, hhea, OS/2 and hmtx from embedded TrueType/OpenType programs,
  which the review asks for by name. sTypoAscender/Descender are preferred
  over hhea when non-zero, since subset fonts often zero them; sCapHeight
  and sxHeight are only read from OS/2 version 2 and later, because reading
  them from a v1 table returns whatever bytes follow it.
- Every read is bounds-checked. A table pointing outside the file, a
  truncated directory or a zero unitsPerEm yields None rather than a panic
  or a divide by zero. These are untrusted embedded programs.
- resolve_font() now reads FontFile/FontFile2/FontFile3 and falls back to
  the descriptors declared Ascent/Descent only when no program is embedded.
- renderer.rs looks up a per-font ascent instead of leaving ascent_em
  permanently None, which had left the fallback ratio always in effect.

Step 5.2, accumulated advances (new pdf-graphics/src/advance.rs):
- measure_advance() implements PDF 32000-1 9.4.4 properly:
  (w0/1000 * Tfs + Tc + Tw) * Th/100, with Tw restricted to single-byte
  code 32. Applying Tw to a two-byte code whose low byte is 32 is a classic
  composite-font bug and is now covered by a test.
- glyph_advances() gives per-glyph widths so a caret or a partial selection
  rectangle no longer assumes even spacing.
- GlyphAdvanceCache is keyed by font name and size as the review specifies,
  and carries a generation so it rebuilds when page data changes rather
  than every frame. Redefining a font drops its stale measurements.

Step 5.3, composite fonts:
- The old build_cid_widths truncated every CID to u8, so any glyph above
  255 silently took the default width. It is replaced by CidWidths keyed by
  the real CID, with the CMap resolved from a predefined name or an
  embedded stream.
- ResolvedFont::decode_text returns None for a composite font with no
  ToUnicode map instead of guessing Latin-1 and producing plausible
  nonsense.

Tests: new tests/phase5_exit_criterion.rs asserts the exit criterion.
Selection across a proportional and a monospaced run verifies the second
run starts at the first ones true end; per-glyph advances sum to the run
advance and H measures wider than l, which an even-spacing estimate would
not. Copy returns correct Unicode through ToUnicode including a non-ASCII
scalar, and through WinAnsi for simple fonts. Search finds both hits across
two lines with rectangles inside their own runs and the right vertical
order. Cache reuse is asserted through hit and miss counts.

Validation:
  TEST_TARGET=pdf ./tools/test-rust-clean.sh      (203 tests)
  TEST_TARGET=pdf-ui ./tools/test-rust-clean.sh   (238 tests)
Both rustfmt and clippy -D warnings clean.
2026-07-27 16:51:18 +00:00
9861f5e896 feat(valhalla): implement tranche 1 complex turn restrictions, access restrictions, and time domains
Some checks failed
Payment domain and storage / isolated-payment-tests (push) Has been cancelled
2026-07-27 16:49:47 +00:00