217625dcf7f4d7fff205f1fde2f4160254056caf
12
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
92d31a3191 |
Every file is spelled the way the formatter spells it
`ruff format .` across the repo: 153 files, no behaviour change. This is the second gate CONTRIBUTING.md promises, and until now it reported 154 files needing reformat — so a first contributor ran the command the guide told them to run and could not tell their own diff from the background. Landed on its own, with nothing else in it, because a whole-repo reformat is only safe to skip past in blame if it is provably nothing but layout. It was checked that way rather than assumed: every changed file was formatted in memory and compared by full `ast.dump()`, and 152 of 153 come out structurally identical (the one exception was a docstring opening on a quote character, fixed in the commit before this one). The string and comment token streams were diffed separately, so a quote flip or an edited comment could not hide inside a re-layout — five quote-style normalisations and sixteen implicit-concatenation joins, all value-identical, and one commented-out line gaining the space after its `#`. `meshterm specimen` is byte-identical on both platforms, and the suite is 1888 green, gallery gate and `test_theme16` included. What actually changed, in order of how much of the diff it is: wrapped calls and signatures rejoin onto one line where they fit inside the hundred columns; the magic trailing comma expands what it is there to expand; complex slices gain their spaces (`[len(noise) :]`); a few redundant parens go. The tables that are laid out to be read were fenced in the previous commit and are untouched here. The aligned trailing-comment column is gone from about ninety lanes that were not fenced — including the `heat.*` ladder in `MESH_THEME`, which cannot be fenced where it sits. Every comment stays on the entry it describes, so nothing there reads wrong; it just no longer lines up. Add this commit to `.git-blame-ignore-revs`, which follows immediately. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
211f38255b |
A path field means two different things, and now says which
No, it isn't the ack — ACK is its own payload class and was never in the match. Both symptoms come from the same place: a packet header's route type, which we never recorded, decides what its `path` field *is*. A FLOOD packet accumulates: every relay appends its hash, so the path is the route it travelled to reach us. A DIRECT packet is the opposite — the path is a routing instruction the sender wrote and the relays consume — so it says where the packet is going, and an empty one means the route was used up, not that the packet arrived in a single leap. Reading every path the first way is what drew a message from five hops out as having appeared from nowhere. The evidence is in your own log. The four-hop route on those sends is identical across four consecutive messages, where a flood-accumulated path varies every time; it ends on 40ef0f, which is the first hop of everything hairu sends *us*; and a PATH frame carrying exactly those four hops crosses the log seconds before the first message that uses it. That is a learned route to hairu being announced and then used — not a route anything took to us. So route_typename is stored (schema v15, a `route` column beside the crypto and addressing ones added for the same reason), and an Arrival carries whether it was routed. A routed frame with no path has route_known False: it is kept as a copy that reached us — the count and the time are real — but it is drawn as "routed · route not carried" instead of a confident zero hops, and it puts no lane in the fan, because an empty lane there is a claim of adjacency the frame never made. Frames from before the column read None and fall back to the old behaviour rather than to a guess. The round trip is a second bug and needed no new data. The path line closed on our own ★ unconditionally, and for an outgoing message its head is our ★ too — so every send drew ★ ▶ … ▶ ★. The graph did the same, DST_NODE having been hardcoded to us. Both now take a destination: the far end for a message we sent, ourselves for one we received. It is the rule the line's head already followed — a path runs between the nodes it went between — applied at last to its tail. A channel broadcast keeps us at both ends, because there the copies we log really are our own message coming back. collapse now keys on the route type as well as the hops, so a route travelled and a route intended never fold into one row even when the hashes match. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
c246fb8080 |
Persistence: a trace's link readings get a column, not a borrowed one
The readings a trace collects arrive where every other class keeps its relay hashes, so `path` was exactly the wrong place to keep them — and keeping them there fed the topology graph links nobody observed. They get `observations.trace_snrs` instead, written and read like the crypto trio and the addressing columns before them, so a replayed frame shows the same links a live one does rather than a blank lane. The 1606 rows already stored were migrated in place: 2454 readings recovered, every one of them at the 1-byte width the wire uses, and every fabricated path cleared. The pairs read as what they always were — one trace heard twice, once a hop out (+13.25 dB) and once on the way home (+13.25, -5.0, -4.25), the return legs weaker exactly as a longer walk should be. |
||
|
|
f69d1785b7 |
Performance sweep: cache the render funnel, the queries, the graphs
Every repaint re-rasterized every row and re-ran every layout; every screen open re-scanned the whole history. Now work is done once per change instead of once per frame: Render pipeline — a content-keyed ANSI cache in render_to_ansi (every Text/str row app-wide), memoized corner glow, and panel-wrap memos for the base frame and stacked dialogs, all dropped on a platform switch or emoji recalibration. Idle-frame compose falls 5-100x per screen (contacts 5.6->0.1 ms, record card 8.5->0.07 ms, trace 7.6->0.6 ms). Repository — an observed_at index turns every since-window query into a range walk (recent_observations 7.5->1 ms); heard_nodes and first_seen aggregate in one streaming pass by ISO-string comparison instead of hydrating dataclasses and sorting; node_names groups in SQL (NOT INDEXED past a slow planner choice). Per packet — livefeed no longer repaints on events that drew nothing, the channel list's stats TTL rises above the tick so the repository is not queried per frame, watch-store alerts batch through the throttled flush instead of a full-state disk write per new node, and the header's 360-bucket histogram/flags tuples are memoized per minute and packet. Per open — the resolvers, topology canonical()/display_name(), and Yen's route search memoize over their frozen inputs; timemachine, chat, and livefeed drop duplicate queries; the config editor, device actions, info, advert, and tx-optimize reuse the devstate session cache instead of re-asking the radio. Per frame, per screen — dashboard folds five window scans into one digest; walk caches everything derived from its frozen graph (the onward-count quadratic included); packet viewer, record dialog, trophy rows, trace stats/log, and the node-detail route fan memoize on their frozen inputs, invalidated by revision counters where the input can move. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
63cd4e5f96 |
Performance: SQLite WAL, lighter startup, per-platform tick rates
PicoCalc plan phase P2, driven by measurements taken on the Lyra as a paired A/B (git archive HEAD vs the working tree, run side by side against the same venv). The headline is the database. Every packet the monitor hears is one durable commit, and on the SD card each was costing 33.78 ms of fsync. db._tune() opens in WAL with temp_store=MEMORY: 0.59 ms per commit, a 54x cut. synchronous=NORMAL is requested only once WAL is confirmed engaged - the pragma returns the mode it settled on rather than raising when a filesystem refuses it - because under WAL it risks the last transactions to a power cut, and under the rollback journal it risks the file itself. This device runs on a battery pack. Startup: bleak/dbus-fast were already lazy; the real finds were two cheap *values* dragging heavy subtrees. core/connection.py imports one constant from core/channels.py, which imported PyCryptodome at module level (224 ms of CPU-feature probing per run) - now deferred into the two functions that decrypt. And tools/map.py's register_cli, which runs for every tool at boot, reached into ui/map_screen.py for a --fraction default, dragging the basemap's urllib.request -> http.client -> ssl behind it; DEFAULT_VIEW_FRACTION moves to core/geo.py (pure arithmetic, already on the boot path) and is re-exported so existing importers are untouched. 26 modules and 316 ms of import self-time gone. Per-frame: the corner glow only ever recolours truecolor foregrounds, so on a 16-slot console it scanned every line of every frame to hand back the identical list - skipped outright where effects are off, along with the battery blink and the braille spinner cycle. _has_wide_glyph answers from the platform when no emoji can be drawn instead of scanning the composed frame (6.5-9.1 ms per repaint on its own). The header built its segments twice to measure the compact separator, on exactly the narrow terminals that take that branch every frame; it now builds once and measures arithmetically. Together: 101.2 -> 73.2 ms per frame at 53x26, 151.8 -> 110.4 at 53x40, and 72x24 unregressed at 91.7. That finally gave numbers to set the clocks against. refresh_interval becomes per-platform tick_s (2.0 s on picocalc: a 1 Hz idle tick alone was 7-11% of a core doing nothing, and only the header's per-minute pulse drifts, since screens push their own repaints via invalidate). The 0.12 s spinner was untenable - 84% of a core at 53x26, and at 53x40 it did not fit in its own interval at all. Five duplicate _SPINNER_INTERVAL = 0.12 constants across the UI collapse into one platform-aware spinner_interval() beside the Spinner it paces. The header refactor was verified equivalent over 540 renders, plain text and style spans both. The span check earned its keep: the first cut passed style= to the Text constructor, which makes it the object's base style and blankets everything appended after, so the version string would have rendered brand-under-muted. test_header.py only asserted on .plain and never saw it; it now pins the styling too. tests/test_performance.py pins each contract as behaviour rather than timing, including a subprocess guard that fails if Crypto, the network stack, or the map screen ever creep back onto the startup import graph. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> |
||
|
|
01ca242c98 |
Live feed: the lane is about the packet, whatever the packet is about
The NODE lane suited the two classes that name a node and left every other one reading a dash. On this mesh that is half the traffic: the direct messages, requests, responses, returned paths, acks and traces that relay past us naming no origin. So the lane asks each class its own question instead, and the header says SUBJECT — the word that stays true down the whole column. An advert or a telemetry frame is still about its node. A channel text is about its channel, named by the key whose MAC confirms the frame — never by the fingerprint alone, which 256 buckets make no proof at all; a channel we hold no key for reads as that fingerprint and says so. A direct message, request, response, returned path or anonymous request is about the two nodes it travels between, drawn sender → recipient on the hop-sequence widget, so endpoints read exactly as route hops do: resolved names, key-derived hues, our own node white the moment a frame is addressed to us. Too wide, and the sender drops to its hash — the frame is addressed, so the addressee is the half worth the cells. An ack is about the message it answers, a trace about its tag. And an unsigned channel post is filed under its channel rather than the bare word "channel", which named nothing. Half of that was unreadable before because nobody had opened the frame. The companion hands every overheard packet to the library, which decodes the body for exactly two classes — advert and channel text — and leaves the rest as bytes. Those bytes are not opaque: MeshCore addresses a frame in the first few of them, and core/frames.py now reads them, class by class, against the layouts the protocol's own docs/payloads.md publishes. The trace tag is the little-endian uint32 the firmware writes, so it reads as the same number a trace reply reports; an ack's checksum keeps wire order, the form the companion reports its own delivery acks in. Two checks guard every decode, because a wrong slice yields not an error but a plausible-looking hash: the frame's payload version must be v1 (the header reserves two bits for a v2 that widens both hash and MAC), and the body must be long enough for the layout its class promises. Either failing yields nothing at all. The feed opens seeded from history, so any of this that lived only in a live event's raw payload would leave the opening screen blank — the same problem the channel-text crypto trio had. Same answer: three columns (dest/src/tag), written on capture and restored to the very keys the event used, so a replayed frame and a fresh one read identically all the way up. Older rows carry NULL until re-heard. The viewer gained the matching rows: to, from, tag, acks, and a channel for a datagram — whose body is not text, but whose MAC still names it. Verified against the MeshCore protocol documentation and firmware source, then corroborated on the air: every frame captured off the radio has a body length that decomposes exactly into its documented layout, an anonymous request's 51 bytes (1 + 32 + 2 + one AES block) included. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> |
||
|
|
434ffda253 |
Observations: capture the full public key, keep node as the 12-hex id
Adverts carry the transmitting node's whole public key, but only its 12-hex prefix was ever stored (observation_from_event truncated it with [:12]). That prefix is the app's identity/join key — heard_nodes groups on it, and the map, nodes, and watchtower screens correlate it against contacts' 12-hex key_prefix — so it must stay short. Instead, record the whole key alongside it in a new observations.public_key column (schema v12) and keep the prefix as node. The Time Machine picker prefers the captured full key, then the live contact resolver, then the bare prefix — so a heard node's key now shows as fully as the hash lane fits, offline included. HeardNode surfaces the key from whichever row captured it; the simulator's observations carry it too. No backfill: the full keys past adverts arrived in were never persisted (the raw payload wasn't stored) and no local source has them, so old rows can't be completed. The database was wiped to start fresh under the new schema. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
f1385666a8 |
Records: score every walk into a trophy case, per discipline
A walk is any trace — it starts and ends at our node (a Trace path route directly, a Trace target boomerang just the same) — so every walk home can be measured and scored. services/records.py owns that scoring: measure a walk once (distance, reach, node counts, weakest link, enclosed area) and offer it to every one of six disciplines it places in — Longest distance, Farthest node, Most nodes, No revisits, Weakest link, Biggest loop. walk_from_trace turns a reply into its re-walkable spec, canonical route, and stats in one call. Records persist per (category, hash width) in the discovered_paths table (schema v11) — the 64-byte path field makes each width its own game — kept top-5 with spec-dedupe and worst-first pruning, stamped with the app version. Disciplines carry plain descriptive names; their ids stay stable database keys so stored records survive the naming. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
a3398bebf5 |
UI punch-list: dashboard feed, chart axes, chat counter, popups
Two rounds of interactive-polish fixes across the dashboard, Time Machine, chat, and the menu popups. Dashboard - Feed name lane names what a row actually is: a channel message's parsed sender, or a relayed packet's payload class (channel text / trace / …), instead of a bare "?" or a redundant "ch N". The class is persisted so history-seeded rows carry it too (observations.payload_typename, schema v10). - PgUp/PgDn walk the feed selection so the highlight travels with the view. Packet viewer - Takes a live source and re-locates the viewed packet by identity, so packets arriving after it opens become reachable; the n/total title stays current. - Decrypts overheard channel text straight from stored history (crypto fields persisted: chan_hash/cipher_mac/crypted, schema v9). Time Machine - Day charts label their bars with column ticks: each date sits under its own bar with a ┬ notch, shortens (month only on the first tick and on rollover), and thins to fit. axis_chart grows an optional ticks path for columnar charts. - Node history charts render through the shared axis_chart widget; the mesh Rhythm is 96 fifteen-minute slices at 4x width, "now/newest" hints dropped. Chat - The byte counter pins to the right edge of the input's last line, so it stays bottom-right when the compose wraps instead of trailing the cursor. Menu popups - The per-node Rules popover gets an explicit Close row. - The Send advert popup drops the emoji from its floating title (a terminal that paints it narrow left the content-sized dialog's border short, bleeding the backdrop through); the menu row keeps its icon. 625 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |
||
|
|
f1e1896918 |
Composer asks the gateway: fetch a repeater's neighbour table mid-path
The topology graph gains its fourth evidence source — the only one not derived from our own reception. A repeater we hold admin rights on reports its neighbour table (who it hears directly, at what SNR) when asked over the mesh, revealing links and whole nodes our radio has never received anything from: exactly the second vantage point the composer runs dry without, two hops out. Probed live against YUL-Cartierville (v1.15.0) through the Waymarker before building: firmware answers the binary NEIGHBOURS request but silently ignores guests, so the flow is login-first, tx-optimize style (stored password, one-time prompt, forget on rejection). An empty table is a normal answer — the gateway's own table was empty during the probe (confirmed via its text CLI: '-none-') — so the UI says "ask again later" instead of erroring. Standing on a fetchable repeater, the composer shows a "fetch neighbours" row with the suggestions it extends; the fetch runs under the abortable spinner dialog, persists as a runs-row-owned snapshot (schema v8, neighbour_reports), and the composer reopens mid-thought with the same hops and refreshed suggestions tagged N. Refetching supersedes the old snapshot per (repeater, neighbour) pair rather than inflating the link's sample count: a table is current state, not an event stream. Verified end-to-end on hardware via MeshCoreDevice over BLE (login + fetch + clean empty-table return) and in the mock (guest refusal, discovery of a never-heard node, composer render + hand-off). 441 tests pass; the real database migrated v7 -> v8 cleanly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
3502a2e09d |
Trace opens idle: compose the path from received topology, probe scenarios
Everything we receive carries a fragment of the mesh's shape: successful traces crossed every link in their path (out and back — the reply retraces the reverse path, so links read both ways), each contact's out_path is a route the firmware distilled from received floods, and RX-logged packets report the relay chain they rode in on. A new topology service folds those into one undirected evidence graph (schema v7 persists packet paths). The trace screen stops auto-starting on target pick. Enter runs a burst under a floating tracing dialog (spinner chip, live progress, Abort); "p" opens a hop-by-hop path composer whose suggestions are the tail's observed neighbours, strongest link first, with raw hex entry for unseen nodes; "x" browses ranked path scenarios (device route, direct, best observed alternatives) and can probe them all — a measured burst per candidate, recorded as path_candidates rows, reliability-first ranking, winner offered for adoption. Composed specs are outbound-only, always ending at the target's hash: the stored data shows the firmware auto-replies along the reversed path, and user-composed "there and back" loops (3d,f2,3d) never succeeded. Specs collapse to a uniform per-hop width the narrowest known hash can honour. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> |
||
|
|
2ec18138a7 |
Rename project from MeshTools to MeshTerm
Rename the package directory, imports, brand strings, env-var prefixes, console-script entry point, and the config/data dir (~/.config/meshterm). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> |