Commit Graph
3750 Commits
Author SHA1 Message Date
Jason Huebert 4b735e51ab ci: rename filter-build.yml to filter-release.yml
The workflow no longer builds anything; the file name was the last
stale artifact of the rename. Updates the two reusable-workflow calls
in sync-upstream.yml, the concurrency group id, and the references in
AGENTS.md and the local build script's comments.
2026-10-09 13:08:55 -05:00
Jason Huebert 309cb5ac23 refactor: trim local-release-build.sh
- workers receive their platform from the map computed once up front
  (WORKER_PLATFORM) instead of re-running pio project config through a
  subprocess per target -- 155 subprocess invocations saved per full run
- fail a worker that compiles but produces no artifacts, instead of
  surfacing later as a confusing empty gh upload
- (fix en route: the first platform-plumbing attempt looked the platform
  up under the wrong key inside run_one -- caught by the end-to-end
  test, not by syntax checking)
2026-10-09 13:07:28 -05:00
Jason Huebert 15967e461e ci: simplify release workflows
- filter-build.yml: drop the create_release input — the workflow's only
  purpose is cutting a release, and an input to make it a no-op was
  vestigial; the release job runs unconditionally
- filter-build.yml: replace the hand-rolled natCmp comparator (~16 lines
  of JS) with git's own version sort (--sort=-v:refname), which orders
  this tag scheme identically — verified against the fork's tags:
  dev prevTag filter-v1.17.1-dev.16, next counter 17, stable r5
- sync-upstream.yml: rename job ids build-dev/build-stable to
  release-dev/release-stable to match what they do now
2026-10-09 13:07:10 -05:00
Jason Huebert 06ad435865 fix: make local-release-build.sh machine-independent
- pin LC_ALL=C for the embedded build date: %b is locale-dependent, so a
  non-English system would bake a different FIRMWARE_BUILD_DATE string
  (and different artifact bytes) than CI or any other machine
- fail fast with a clear message on bash < 4 (mapfile/declare -A/wait -n;
  macOS ships bash 3.2)
- document the remote assumption: the bare-tag form needs a remote named
  "fork"; the release-URL form works from any clone

No other machine- or user-specific bits: paths are $HOME-based, the
PlatformIO home is the generic default, and gh targets are passed
explicitly.
2026-10-09 12:43:31 -05:00
Jason Huebert 3a3276fbeb ci: manual sync only; every non-fork workflow disabled
- sync-upstream.yml: drop the weekly cron; sync and stable promotion now
  run only when dispatched deliberately
- disabled at the fork level (Actions settings, no file changes):
  run-unit-tests, github-pages, stale-bot — leaving only the fork-owned
  sync-upstream and filter-build workflows active
2026-10-09 12:41:21 -05:00
Jason Huebert ddaa76e2e7 ci: cut releases in CI without building firmware
The 155-target build matrix cost 6-7 runner hours per release and got
Actions disabled on the fork. Firmware is now built and uploaded locally
(scripts/local-release-build.sh); CI keeps only the parts that are cheap
and need to be centralized.

- filter-build.yml: drop the validate-targets and build jobs and the
  targets input; keep the version job (tag scheme and change gate are
  unchanged) and create the release with no assets — the local script
  fills the assets in afterwards
- sync-upstream.yml: same two calls, retitled Create release; the
  force_build input now means create-the-release, not build
- AGENTS.md: describe the new split and where the stack-usage gate lives

Also disabled the upstream firmware-builder workflows at the fork level
(Actions settings, no file changes, so weekly upstream syncs cannot
conflict): build-{companion,repeater,room-server}-firmwares,
firmware-builder, and pr-build-check, which built firmware on every
push to main/dev — i.e. on every weekly sync.
2026-10-09 12:38:55 -05:00
Jason Huebert 7afc0ee6b8 feat: add local release build script
Builds a filter release's firmware locally and uploads the assets to its
GitHub release, replacing the 155-target GitHub-hosted runner fan-out.
Given a release URL or tag, it checks out the exact commit the release
names into a persistent worktree (reruns are incremental via .pio),
builds every repeater target of the release tree N at a time, and streams
each target's artifacts to the release as it finishes.

- mirrors build.sh's per-target logic (build.sh itself cannot run in
  parallel: it wipes out/ on every invocation)
- version derivation and build flags match what filter-build.yml produced
- carries the stack-usage gate that used to run per target in CI
- uploads via gh from the host; build workers run in an isolated venv
  with PlatformIO's pinned toolchains, so nothing else on the machine
  participates in the build
2026-10-09 12:38:49 -05:00
Jason Huebert 605fd54a3a ci: simplify workflows; default to all repeater targets
- filter-build.yml: with no explicit targets input, build every repeater
  target this branch defines (build.sh list, case-insensitive 'repeater'
  match) instead of falling back to the FIRMWARE_TARGETS repo variable,
  so the variable is no longer needed and stable publishes the full
  repeater set like dev. Explicit input still validates with the
  unknown-name warning.
- filter-build.yml: drop the dead 'Clear stale artifacts' step (fresh
  runner, no out/ can exist) and trim release needs/if: validate-targets
  is required transitively through build, and a skipped build skips the
  release anyway, so the skip re-check is redundant.
- sync-upstream.yml: the two near-identical conflict-issue scripts
  (~50 lines each) become calls to a new composite action
  .github/actions/open-conflict-issue; one authoritative copy of the
  marker/search/update-or-create/setFailed logic.
- sync-upstream.yml: 'Configure Git' is two git config lines, not a
  github-script step spawning git in a loop.

Verified: all YAML parses; simulated target selection against
build.sh list resolves 155 repeater targets with no non-repeater
leakage and a working explicit-input path.
filter-v1.17.1-dev.16
2026-10-08 11:15:47 -05:00
Jason Huebert 6d51726193 ci: replace every shell step with github-script actions
All 'run:' steps in sync-upstream.yml and filter-build.yml become
actions/github-script scripts driving git/build via spawnSync, so no
step interprets input text as shell syntax and the actions carry no
shell scripting at all.

- Derive Version: JS port of the tag-scheme derivation; verified
  byte-equivalent to the shell version against this repo's state and a
  synthetic tag zoo (dev counter, -rN suffix, date-tag filtering,
  sort -V ordering). Dead SHORT_SHA dropped.
- Sync/promotion: git orchestration via spawnSync; conflict paths set
  their outputs and exit cleanly, and the conflict-issue steps raise
  core.setFailed. The two 'Fail on conflict' steps (run: exit 1) are
  gone; the stable issue step previously never ran because the stable
  step's exit 1 skipped it via the implicit success() gate — the
  failure now always comes from the issue step that reports it.
- Build Firmware / Clear stale artifacts: build.sh is invoked through
  spawnSync instead of a shell line.

Verified the merge, promotion and conflict paths against a throwaway
fork/upstream fixture (clean merge, conflict abort with
conflicted-files.txt, cherry-pick, README-only skip, README sync,
gate-skip, push/idempotent rerun, bad source branch).
2026-10-08 11:06:40 -05:00
Jason Huebert 3fb1437cb6 Merge branch 'repeater-filter-ack-reply-tweaks' 2026-10-08 10:36:39 -05:00
Jason Huebert 3f169d0dcc feat: fleet ack reply uses repeater path-hash size and default flood scope
The ack reply was sent via sendFlood(): 1-byte path hashes and an
unscoped flood, regardless of the repeater's configuration. Route it
through a new sendFleetReply() hook on MyMesh that sends with the
repeater's configured path-hash size and, when a default flood scope is
set, scoped; with no default scope set it stays unscoped. The scoping
contract is documented in FLEET.md in the same commit.
2026-10-08 09:16:17 -05:00
Jason Huebert 91fec44034 feat: fleet ack reply body — newline after job key
Separate the job key from the response with a newline instead of a
space, so companions show the id and the response on distinct lines.
The body buffer is unchanged (the newline replaces the space byte), so
one packet still carries the same summary length. FLEET.md documents
the on-air body format, so that section is updated in the same commit.
2026-10-08 09:16:11 -05:00
Jason Huebert a6dd7992bb ci: fix unmatched brace in stack usage check step
The OK-path echo used ${SU_FILES[@]" with no closing brace, so bash
consumed the rest of the script hunting for it and the step died with
'unexpected EOF while looking for matching }' before any .su file was
inspected. The firmware builds themselves compiled clean; every matrix
target failed only here (run 37724977530).
filter-v1.17.1-dev.15
2026-10-07 23:03:28 -05:00
Jason Huebert 0ee33f31e5 fix: fleet script intake, kill switches and relay exemption
Found by on-air and on-device adversarial testing of the fleet CLI and the
script runner (Xiao repeater, driven through the aries companion).

- !at 0000000000 parsed to due_epoch 0, which the manager read as "run now":
  the script ran at once, bypassing the stale and clock-unset refusals.
  parse() now reports a `scheduled` flag, so 0 is a (stale) time.
- fleet off and fleet chan clear are the kill switches, but queued, sleeping
  and armed (!at) scripts kept running. They are now cancelled between passes
  (never inside run(), so a script switching the fleet off cannot pull its
  own slot away). Their keys stay consumed.
- A key forgotten while its job was still queued, sleeping or armed could be
  queued or armed a second time and run twice. A re-send of an in-flight job
  is now a duplicate.
- The relay exemption matched the one-byte channel hash, so every packet on
  any of the ~1-in-256 channels sharing it bypassed the battery gate.
  onGroupData() now records the packet the core just MAC-verified under the
  fleet key (MyMesh passes the packet, one-line hook change), and
  checkForward() exempts only that packet, by content hash.
- Scripts must be plain group text (txt_type 0). Other types were executed.
- The noid counter never moved, and malformed scripts were not counted as
  refused; both now match FLEET.md.
- The fleet status line shows badline, as documented.
- execCliLine logs `cli[key] line` before dispatch: the handlers tokenise the
  line in place, so the transcript showed a truncated command.

Tests: test_fleet covers each case (97 cases, ASan/UBSan clean). The five-env
native run is green (490 cases). FLEET.md and BATTERY.md updated to match.
2026-10-07 22:51:33 -05:00
Jason Huebert d877757de6 Merge branch 'repeater-filter-fix-ack-header' — fleet ack group-text header fix 2026-10-07 17:30:12 -05:00
Jason Huebert af148296f6 fix: fleet acks must carry the group text header or every receiver drops them
fleetReplySend() composed the ack as a bare "<name>: <body>" string, but a
GRP_TXT payload on air is [ts(4)][txt_type(1)]"<name>: <body>" — receivers
parse the first five bytes as the text header (BaseChatMesh::onGroupDataRecv).
With the raw text, the byte at offset 4 was '-' (0x2d), an unsupported
txt_type, so every ack was dropped by every receiving device: scripts ran and
acked, but companions never saw the reply.

Compose the header like BaseChatMesh::sendGroupMessage does. FLEET.md already
documented replies as txt_type 0x00 plain group texts, so docs are unchanged.
2026-10-07 17:30:12 -05:00
Jason Huebert 786888a0c9 docs: AGENTS.md — stack is a boot-breaking constraint the suites cannot see 2026-10-07 15:53:45 -05:00
Jason Huebert 40546978ca ci: fail targets whose repo code holds a stack frame >= 2 KB
The 2026-10 boot crash-loop shipped because a compiler-measurable hazard
(~8.5 KB of scratch in one boot-path frame vs a 4 KB nRF52 / 8 KB ESP32
loop-task stack) is invisible to the host-native test suites. Each release
target now builds with -fstack-usage (metadata-only, codegen unchanged) and
fails when any src/ or examples/ frame reaches 2 KB; the check errors out
loudly if the scan comes up empty instead of passing blind. Vendored
crypto and libdeps libraries are excluded: their larger frames ship today
and are not what this repo edits.
2026-10-07 15:35:33 -05:00
Jason Huebert 7dbe96c8e8 fix: parse filter config into the member stores — the stack scratch overflowed boot on ESP32
The v7 capacity bump (32 rules + 32 channels) made FilterRules::load()
stack-allocate ~8.5 KB of scratch copies on top of an already deep boot
chain. The Arduino loopTask stack is 8 KB, so every repeater that booted
this build ran off the bottom of the stack into the adjacent heap block;
the first fopen() after the overflow then died in malloc (Guru Meditation
LoadProhibited, crash-loop at boot, no config file required).

load() now parses straight into rules/channels, which resetToDefaults()
has already zeroed, and re-resets on a failed parse so a partial store
never survives. Behavior is unchanged; all 475 native tests pass as-is.
2026-10-07 15:26:39 -05:00
Jason Huebert cb79e14201 Merge branch 'repeater-filter-fleet-standalone' — standalone fleet feature (FleetManager, CliScript runner, acks, scheduling) filter-v1.17.1-dev.14 2026-10-07 13:08:02 -05:00
Jason Huebert a833e1dc64 fix: load() must not wipe the fleet's injected device services
resetToDefaults() NULLed time_fn/jitter_fn/send_fn, and load() calls it —
but MyMesh::begin() wires those services in just before fleet.begin(fs), so
after every boot the clock read as unset (!at jobs always refused) and
send_fn was NULL (!ack replies silently dropped). Wiring, not config
state: the three members now get in-class initializers and
resetToDefaults() never touches them.

Regression test drives a load after wiring the clock and asserts the !at
admission path still sees it; verified the test fails against the old
resetToDefaults() and passes with the fix. AGENTS.md fleet count 81 -> 82.
2026-10-07 12:14:05 -05:00
Jason Huebert f195aa70f4 fix: dedup the fleet decrypt candidate against the filled prefix of dest
appendChannelByHash() was called with 'channels + n' and scanned
max_matches entries from there, so its same-PSK dedup could only see the
uninitialised tail of core's candidate array — never the entries the filter
store had already appended. The exact case the comment describes (the same
PSK in both stores) appended a duplicate candidate and burned one of core's
four decrypt slots.

The manager now takes 'filled' (how many leading entries core has already
supplied) and scans/appends at the right offsets; unfilled entries are raw
stack and are never compared. Test updated to the new signature plus the
append-after-filled and store-full cases.
2026-10-07 12:14:05 -05:00
Jason Huebert 0b162e53e7 fix: consult the battery gate only for non-fleet packets in allowPacketForward
The exemption condition was inverted: '!fleet.checkForward(packet) &&
!battGate.checkForward()' short-circuits for non-fleet packets (the gate is
never consulted, so suspension gated nothing) and evaluates the gate for
fleet-channel packets (dropping and counting them while suspended — the
exact opposite of the documented FLEET.md/BATTERY.md exemption).

Correct form: fleet.checkForward(packet) && !battGate.checkForward() — a
false from the fleet side short-circuits past the gate, a true falls
through to it. Not covered by the native suites (MyMesh is firmware-only);
verified by the four-board compile checks.
2026-10-07 12:13:16 -05:00
Jason Huebert 90beb0132b fix: finish the filter-side cli removal; filter docs/code read as pre-cli
PacketFilter.h had kept the dead cli remnants (FILTER_ACT_CLI, the
CliScriptRunner member, runCliScripts/getScripts forwards and the
CliScript.h include) — the subtraction edit for the header never actually
applied, and the commit claiming its removal was wrong. The header is now
byte-identical to the pre-cli ancestor, as are FILTER.md (the fleet
chapter, nav entry, RAM-only bullet and fleet-era downgrade note are gone),
PacketFilterConfig.h, the test fixture and the filter test suite; the
latter two lose the stray cli-section header and the 'cli scripts' line in
the coverage map. PacketFilter.cpp keeps only the two cliDecodeHex call
sites (the shared hex decoder hoist to CliUtil.h) and sheds three
cosmetic reformattings the removal had left behind. platformio.ini's
filter env no longer compiles CliScript.cpp.

Since the action=cli firmware never shipped, the filter docs and code
carry no trace of it; the fleet feature documents itself in FLEET.md and
README.md. All native suites and the four-platform firmware builds
re-verified.
2026-10-07 11:55:40 -05:00
Jason Huebert 19150afc3a chore: drop the unused CliExecRecorder from the filter test fixture
The cli tests that used it left with the action=cli removal; the fleet
suite has its own recorder.
2026-10-07 11:45:40 -05:00
Jason Huebert 8cf8dcc054 fix: parse !at epochs without strtoul — it clamps on 32-bit-long platforms
strtoul on the ESP32/nRF52/RP2040 ABIs (32-bit unsigned long) saturates a
10-digit epoch above UINT32_MAX to 0xFFFFFFFF instead of reporting the
overflow, so an out-of-range timestamp would have been accepted as year
2106 and sat armed in the scheduled store. Accumulate the digits by hand
with a uint64 and refuse anything above the RTC range. Also fix a comment
typo in the run() delay-resume path.
2026-10-07 11:45:14 -05:00
Jason Huebert 7f2a69f040 docs: FLEET.md; filter docs revert to drop/forward; battery exception
CLI.md becomes FLEET.md and is rewritten for the standalone fleet feature:
setup via fleet chan set / fleet tag add, the directive-block grammar
(!tags / !ack / !at) and inline !delay rules, exact-equality tag targeting,
acknowledgements with the jitter-window sizing guidance and the
never-a-script reply rule, the !at UTC statement and the sync → verify →
schedule recipe (time <epoch> in scripts, never clock sync), idempotency,
two-phase cutovers and when an armed !at job replaces them, recipes,
troubleshooting, limits, the security model, and the battery supersession
in both the dedicated section and the troubleshooting table.

FILTER.md: the fleet chapter becomes a pointer to FLEET.md; action=cli rows,
the C legend entry and the filter cli command rows are removed; the action
list reverts to drop|forward; the downgrade note now says fleet-era filter
configs are byte-identical to pre-fleet ones and /fleet_cfg is ignored by
older firmware.

BATTERY.md: the suspends-all-forwarding statement gains its explicit
exception — fleet-channel traffic, scripts and acknowledgements are exempt —
plus the fleet bullet in what-suspension-does-not-touch.

README.md fleet section and AGENTS.md (code map, tests, build commands,
fleet behavioral invariants) follow the same rename and counts.
2026-10-07 11:43:22 -05:00
Jason Huebert 9e2b01bea5 refactor: remove action=cli from the packet filter
The fleet feature owns remote scripts now, and no field device ever stored
an action=3 rule — the filter side is a clean subtraction with no migration
code: FILTER_CFG_VERSION stays at v7, validRule() simply returns to refusing
action bytes above FILTER_ACT_FORWARD, and no fixture or record byte
changes. /filter_cfg files written by pre-cli and post-cli firmware are
byte-identical.

Removed: FILTER_ACT_CLI, the CliScriptRunner member and its runCliScripts/
getScripts() forwards, the action=cli add/validation/constraint errors
(prob/throttle/chan/type refusals and the txt-only forcing), the cli
enqueue in checkContent(), confineCliRule() and its call sites (its
'#'-channel concern was cli-only), the 'filter cli' command and its USAGE
entry, the C list token and cli action word, and the FILTER_CLI_* tunables
(renamed FLEET_CLI_* in FleetConfig.h since commit 2). The action list is
drop|forward everywhere again.

The cli/script behaviour tests leave test_packet_filter (296 -> 295 cases;
the runner coverage lives in test/test_fleet now). Both suites green
unchanged otherwise; four-platform firmware compile checks pass.
2026-10-07 11:39:18 -05:00
Jason Huebert 09f39d1924 feat: fleet top-level command + onGroupData/allowPacketForward hooks + acknowledgements + scheduling
FleetManager gains the script machinery and the full feature surface:
- onGroupData hook: parses fleet-channel group text (pure parse, so ordinary
  chat moves nothing), matches tags (absent !tags = broadcast, else exact
  intersection), captures the channel of arrival into the queue entry, and
  either enqueues the script or admits an !at job to the scheduled store.
  Nothing executes in the receive path.
- Scheduled scripts: staleness (> FLEET_AT_STALE_SECS past) and RTC-unset
  (below FLEET_AT_CLOCK_FLOOR) refusals are manager decisions counted in the
  runner's refused counter; dups counted as dups; store full refuses with the
  key unmarked. runScripts() moves due jobs to the run queue (waiting, not
  dropping, when the queue is full) and drains one script per pass — the same
  cadence the filter drain had.
- Acknowledgements: !ack / !ack err schedule a reply from the finished
  script's summary, jittered uniformly in [0, reply_window_ms) via the
  injected core RNG and sent as a plain txt_type 0x00 group text (sender =
  node name, body '<key> <summary>', composed inside the 168 B datagram data
  limit) on the captured channel — never a script for other members, never
  split across packets. Store full drops and counts.
- Relay-side exemption: checkForward() returns 'let the gate decide' except
  for GRP_TXT/GRP_DATA whose first payload byte (the on-air channel hash,
  read while still encrypted) matches the fleet channel — fleet traffic
  relays and is never counted as a battery drop while suspended.
- searchChannelsByHash merge: filter store plus fleet channel, deduped by
  secret.
- fleetCLI: on/off, chan set/clear, tag add/del/list/clear, reply [<secs>],
  seen/forget — replies carried over from the filter cli namespace wherever
  they port, psk never echoed, status line per the plan plus ackq occupancy.
- MyMesh wiring stays a handful of hook lines: dispatch, receive hook above
  the battery gate early-return (deliberate ordering, commented), the
  allowPacketForward short-circuit, loop() save+drain, channel merge, and
  injected device services (RTC clock, RNG jitter, reply send trampoline).

Tests: intake/targeting/deferral, ack modes + jitter timing + captured
channel + store-full, !at staleness/clock-floor/armed-fire/queue-wait,
RAM-only stores across load, checkForward exemption contract, channel
supply dedup, and the full CLI surface. All five native envs green;
compile checks pass on Xiao_S3_WIO/RAK_4631/PicoW/wio-e5 repeaters.
2026-10-07 11:33:15 -05:00
Jason Huebert 2904ea99fd feat: CliScriptRunner directive block (!tags, !ack, !at, !delay) + resumable run; parseGroupText hoist to CliUtil
The runner gains the fleet script grammar per the fleet-standalone plan:
- parse() is now public and pure (no state, no counters): it validates the
  whole script and returns the directive block — job key, !tags list
  (1..8 tags, job-key charset, exact comma list), !ack / !ack err mode and
  the !at epoch — plus the command-body offset. FleetManager uses it for
  targeting decisions before enqueueing; enqueue() re-parses through the
  same code so the parser stays authoritative in one place.
- The directive block is the run of !-lines after !id: !tags/!ack/!at each
  at most once, either order; any other block line, a repeat, or a !delay
  in block position rejects the whole script (fail-safe, as before).
- !delay <ms> (1..300000) pauses execution anywhere in the command body:
  run() is resumable, walking the queue slot in place across loop passes
  (signed-difference millis deadline, the BatteryGate wrap pattern; body
  offsets recorded between passes — restPos() peeking keeps the next
  line's terminator intact, and slot text is zero-filled so a resume past
  the final line reads empty and finishes). A sleeping script holds its
  queue slot; two sleepers fill the 2-slot queue.
- run() accumulates the acknowledgement summary as lines execute and
  reports it in CliRunResult when the script finishes (single command: its
  actual reply; several: 'ran N ok' / 'ran N; err: <first failing reply>').
- markKeySeen() + enqueueValidated() support the scheduled-script store:
  mark at admission, queue later without re-marking.
- FILTER_CLI_* tunables move to FleetConfig.h as FLEET_CLI_*; the runner's
  PacketFilterConfig.h include becomes FleetConfig.h.
- parseGroupText() hoists from PacketFilter.cpp to CliUtil.h: the
  definition of a message's sender/text split now lives in one place for
  the filter's text= selectors and the fleet intake alike.

Runner behaviour tests (parsing, directive block, delays/resume, summaries,
idempotency, seen ring) move into test/test_fleet; the existing filter
suite stays green unchanged.
2026-10-07 11:21:27 -05:00
Jason Huebert 704a715b06 feat: FleetManager — fleet channel, tags, /fleet_cfg persistence
First slice of the fleet-standalone plan: the config store for the new
top-level fleet feature. One PSK-backed channel (16/32-byte hex, sha256[0]
air hash derived at set/load), this repeater's tag set (exact string
identity, job-key charset grammar) and a default reply window, persisted
in /fleet_cfg format v1 — magic + version + fields + CRC-16 over the whole
payload, staged save, lazy dirty write-back via PersistUtil. RAM-only
state (pending acks, armed !at scripts, seen ring) never persists.

Shared helpers move to CliUtil.h: cliValidToken() (one token-charset
validator now shared by job keys and fleet tags) and cliDecodeHex()
(hoisted from PacketFilter.cpp, which now calls it).

New native suite test/test_fleet (envs native_fleet / native_fleet_san)
covers channel set/clear/refusals, tag grammar/cap/delete and the
persistence paths: roundtrip, CRC/magic/version/truncation rejection,
tag_count clamping, backup recovery + repair save.
2026-10-07 11:03:47 -05:00
Jason Huebert 26b6ab84dd Merge branch 'repeater-filter-cli-scripts' — remote CLI scripts (action=cli) 2026-10-07 10:15:42 -05:00
Jason Huebert 6c15bc2415 docs: CLI.md script examples drop the sender prefix 2026-10-07 10:09:15 -05:00
Jason Huebert b58e517840 docs: move fleet-script guide into CLI.md; README gains fleet management
CLI.md is the new comprehensive user guide for the action=cli feature:
trust model, quick start, script format, per-boot idempotency, the
filter cli command reference, the two-phase cutover pattern, seven
recipes (radio preset, advert hygiene, filter updates, renaming,
channel rotation, quiet mode, canary rollout), target groups,
troubleshooting, security model and limits. Command names verified
against the firmware — the commit job is , not  as the
plan draft had it (CliScript.h comment corrected too).

FILTER.md keeps only a brief 'Fleet management over a channel' section
that links to CLI.md; the command-reference, action row and reboot
bullets keep one-line mentions with the same pointer.

README.md lists fleet management as the fork's third capability, adds a
fleet-operator bullet to the why-page, and points fleet users at CLI.md.
AGENTS.md registers CLI.md as an authoritative user guide.
2026-10-07 08:58:39 -05:00
Jason Huebert 282cb5be5b docs: FILTER.md fleet-management chapter + AGENTS.md code map
New chapter 'Running CLI scripts from a channel (fleet management)':
trust warning, setup, script format, per-boot idempotency, the two-phase
cutover pattern, execution deferral and kill switches, text= target
groups, and the command/limit tables. The action= row, filter list
legend and command reference gain cli/C; the config-format section notes
that same-version downgrade truncates the rule list at a cli record.

AGENTS.md: CliScript.h/.cpp joins the fork-owned list and code map, the
MyMesh hook line list gains the execCliLine trampoline, the behavioral-
invariants note records the action=cli semantics, and the suite counts
are refreshed.
2026-10-07 08:51:09 -05:00
Jason Huebert 3cd6eadcd2 feat(filter): filter cli status/seen/forget
The 'filter cli' namespace surfaces the runner: bare status with the
ran/dup/noid/refused/badline counters, queue fill and seen-ring fill;
'cli seen [<key>]' is the did-this-job-run-here check; 'cli forget
<key>|all' is the deliberate re-run lever. Lookups hash the given key
string — no hash value ever appears in a reply. FILTER_USAGE gains |cli.
2026-10-07 08:47:28 -05:00
Jason Huebert 6e52010474 feat(filter): deferred script execution hook (MyMesh loop)
A file-static trampoline runs each queued script line through
handleCommand(0, ...) — the same dispatch and privilege as the serial
console — and logs 'cli[<key>] <line>' plus its reply, so an operator at
the console sees exactly what ran. MyMesh::loop() drains one script per
call right after filter.loop(), outside the receive bracket that queued
it: no rule-list mutation while checkContent() is scanning, no verdict
stash cleared mid-receive, no flash I/O in the receive path.

MyMesh.h is unchanged (trampoline is file-static; handleCommand is
already public) and hasPendingWork() is unchanged: the queue drains in
the same loop() call that received the message, before the sleep check.
2026-10-07 08:45:01 -05:00
Jason Huebert bce4736d72 feat(filter): CliScriptRunner — script parse, queue and seen-hash ring
One authoritative home for the action=cli script machinery, shaped like
AdvertRateLimiter and owned by FilterRules: enqueue() validates the
'!id <key>' marker and the reserved-directive rule, dedupes against a
RAM-only ring of FNV-1a-64 key hashes (32 x 8 B, oldest evicted), and
queues at most one script per packet behind a 2-slot FIFO. run() drains
one script per call through a CliExecFn callback, skipping blank lines,
'#' comments and lines over the serial CLI's own command-buffer size.

Keys are marked at enqueue — one mechanism covers duplicate flood
deliveries and re-sends; a refused script is never marked. The key
string is hashed at parse time and never stored; hashes are never shown
to a user. No persistence: everything resets on boot, by design (the
re-runnable-scripts convention is documented in FILTER.md).

checkContent() enqueues on a FILTER_ACT_CLI verdict before stashing it;
the verdict still flows to the normal forwarding path unchanged.
resetToDefaults() resets the runner with the rest of the RAM state.
2026-10-07 08:42:32 -05:00
Jason Huebert fc4b2e930b feat(filter): add action=cli rule model + validation
One new rule action, cli, joins drop and forward: a matching decrypted
group-text message on a keyed channel is forwarded like action=forward
AND queued as a CLI script for deferred execution (the runner lands in a
following commit). The action rides the existing FilterRule::action byte,
so the persisted v7 layout, its static_asserts and the load path are all
untouched.

Constraints enforced at filter add and re-checked in validRule():
chan= is required and must name at least one PSK-backed (non-#-named)
channel, type is forced to txt, prob=/throttle= are rejected (a gated
cli rule could fragment a fleet). A cli rule left with '#' channels only
after a chan del is made inert by clearing its mask — MASK_SET with no
bits stays the documented inert rule and keeps the record savable.

Display: filter list shows C, filter get prints cli, add errors state
what is accepted.
2026-10-07 08:35:00 -05:00
Jason Huebert ffc2183464 Merge branch 'repeater-filter-payload-types' into repeater-filter 2026-10-07 08:23:59 -05:00
Jason Huebert efcd8907b9 fix(filter): undefined chan_mask shift when deleting the last channel of a full store
delChannel() remaps each rule's chan_mask with (chan_mask >> (idx + 1)) << idx.
The v7 branch widened chan_mask to 32 bits and the store to 32 channels, so
deleting the last channel of a full store shifts by exactly 32 — undefined
behavior. On x86 (variable shift counts mask to 5 bits) a rule naming channel
0 came out of the delete with a spurious bit 31 set instead.

Guard the shift: at idx == FILTER_MAX_CHANNELS - 1 nothing sits above the
deleted channel, so the high contribution is simply zero. Regression test
covers the full-store edge (mask integrity plus a behavioral re-check that
the surviving named channel still matches).
2026-10-07 07:43:14 -05:00
Jason Huebert 31a40e6884 refactor: deslop pass over the v7 payload-type branch
No behavior change. Factor the duplicated minute-uptime conversion and
key-prefix sampling in AdvertRateLimiter into file-local helpers, hoist the
repeated ruleTypeMask() calls in cliAdd's content guard and cliGet's renderer
into locals, drop a leftover debug printf from the paginated chan list test,
and share the patch-byte + re-attach-CRC helper between the two v7 record
integrity tests.
2026-10-06 16:50:46 -05:00
Jason Huebert 4f93aba038 feat(filter): shrink advert cache entry to 8 bytes via minute-granular stamps
The 512-entry advert cache grew to 8 KB when FILTER_ADVERT_CACHE_SIZE was
raised, more than expected. The stamp was the real cost: a uint64 millis
field forces the entry to 16 bytes (4-byte key + 4 padding). Storing
minutes since boot in a uint32 instead keeps the entry at exactly 8 bytes
(pinned by static_assert), so the cache now costs 4096 bytes at 512
entries — the same RAM the 256-entry cache used before.

Minute granularity rounds the window edge by <1 min (an advert can be
re-admitted up to a minute early); uint32 minutes cannot wrap. The
wouldDrop/recordForward API still takes uptime millis. RAM-only state, so
no persistence impact. WindowExpiryAllowsAndRefreshes updated for the
minute-granular edge; FILTER.md notes the relaxed boundary.
2026-10-06 16:29:25 -05:00
Jason Huebert cbdc445488 docs: describe the v7 named-step migration chain and per-record CRC in AGENTS.md
The support-window note now names the excision procedure (delete the step
function, raise the floor in rule_bytes_for(), delete its fixtures); the
config-integrity bullet reflects that v7 rule records carry a CRC-16 while
channel records and the battery config stay length-only until their own
layout change. Suite counts updated (294 filter cases).
2026-10-06 16:05:37 -05:00
Jason Huebert 96bf7917cc feat(filter): config v7 — all payload types, capacity expansion, per-record CRC with stepwise v3..v7 migration
One version bump covers: the five high payload types become nameable
(path, trace, multipart, control, raw; type_mask_hi joins the record at
byte 186), the capacity knobs double (32 rules, 32 channels, sender 24->32,
text 48->64, advert cache 256->512, chan_mask u16->u32), and each rule
record gains a CRC-16/CCITT-FALSE over its 188 payload bytes (record on
disk: 190 B). The pad byte at 187 is format-guaranteed zero: the writer
forces it, the reader refuses a record that has it set.

parseConfigFile() replaces its inline per-version fixups with a named
migration chain — one step function per version pair (v3->v4 ... v6->v7),
applied in order, so retiring a version later is one excision. A pre-v7
record whose sender/text/regions did not terminate inside the OLD field
widths is still refused up front: migrating would terminate the copy and
mask a record the old firmware could never have written.

Also fixed a latent bug the wider store exposes: cliChanList's pass-2
hold-back could be eaten by the last entry, truncating the '; next=N'
marker (first reachable now that page indexes go two-digit).

FILTER.md: type table rows, trace/control visibility caveats, updated
limits (32/32/31/63), status-line examples, and a new 'Config file
format' section documenting v7, the per-record CRC and the downgrade
caveat.
2026-10-06 16:05:32 -05:00
Jason Huebert 27b75819a7 feat(filter): type= predicate for REQ, RESPONSE, TXT_MSG, ACK, ANON_REQ
The filter already sees every payload type the repeater would relay; type=
could only name advert/txt/data. Add the five low-byte encrypted/auxiliary
types as names (req, response, msg, ack, anonreq), driven by one shared
name/type table that both the parser and the renderer use. Render order keeps
advert,txt,data first so replies for pre-existing rules stay byte-identical.

Same commit, the content-predicate guard: sender=/text=/chan= can only ever
be decided on decrypted group traffic, so a rule narrowed to envelope-only
types (e.g. type=advert sender=...) would sit deferred forever and never
match. add now rejects that with 'Err - sender=/text=/chan= only match group
traffic'; rules with type= unset or including a group type keep working.

The 0x80 bit of type_mask is now a defined value (ANON_REQ), so the
malformed-record fixture case that used it as garbage is removed; the
fully-loaded-rule truncation test switches type=advert -> type=txt because
its chan= predicate would now be rejected alongside an advert-only type.

FILTER.md: type table rows, encrypted-payload subsection, ACK visibility
caveat.
2026-10-06 15:45:00 -05:00
Jason Huebert d669190a10 ci: stop the shell comment spelling an empty template expression
GitHub evaluates template expressions in run: blocks even inside
shell comments, so the literal empty expression in the env-hardening
comment was parsed as a syntax error and filter-build.yml failed
validation before any job could start. Describe the idiom in words.
2026-10-05 15:52:01 -05:00
Jason Huebert fc41b2150f Merge remote-tracking branch 'fork/repeater-filter' into repeater-filter 2026-10-05 15:43:04 -05:00
Jason Huebert 4150320ff7 Merge branch 'repeater-filter-quality' into repeater-filter 2026-10-05 15:41:38 -05:00
github-actions[bot] ccd50b4725 Merge remote-tracking branch 'origin/dev' into repeater-filter filter-v1.17.1-dev.13 2026-10-05 10:46:02 +00:00