merge: fleet ack retry refusal fix and AGENTS test counts

This commit is contained in:
Jason Huebert committed 2026-10-16 16:17:03 -05:00
commit ed9846bb0a
4 files changed
+57 -13

No files matched your search

+4 -4
View File
@@ -88,9 +88,9 @@ commit** — the guides are user-facing API documentation, not optional docs.
drain).
- `main.cpp` — serial CLI entry (upstream + fork's buffer-hardening lines).
**Tests:** `test/test_packet_filter/` (295 behavior-level cases: matching,
**Tests:** `test/test_packet_filter/` (301 behavior-level cases: matching,
content rules, limiter, persistence upgrades, CLI surface, TinyRegex,
PatternMatch), `test/test_fleet/` (82 cases: runner grammar, tag targeting,
PatternMatch), `test/test_fleet/` (112 cases: runner grammar, tag targeting,
acknowledgements, scheduling, persistence, CLI surface, the battery
exemption contract), `test/test_battery_gate/`, and `test/test_mesh_clock/` (24
behavior-level cases). Test-only shims:
@@ -281,8 +281,8 @@ FILTER.md:
fails any release target whose `src/`/`examples/` code holds a frame
>= 2 KB (formerly a filter-release.yml CI check) — keep new frames well
under it.
- Pure refactors keep both suites green **unchanged** — the suites (295 filter,
82 fleet, 44 battery) are the safety net that proves no behavior slipped.
- Pure refactors keep both suites green **unchanged** — the suites (301 filter,
112 fleet, 50 battery) are the safety net that proves no behavior slipped.
- Run both suites, then re-read the diff:
```
+6 -3
View File
@@ -256,9 +256,12 @@ exactly one reply per node. "Heard a repeat" proves a repeater relayed the
reply; it does **not** prove the operator's companion received it — there is no
end-to-end ack for flood group text. Each such miss is counted as `rtx` on the
status line; a climbing `rtx` means replies are not being repeated — likely no
neighbouring repeater in range, or heavy loss. The retry is build-time tunable
(`FLEET_ACK_RETRY`, `FLEET_ACK_REPEAT_WINDOW_MS`), never persisted; build with
`FLEET_ACK_RETRY=0` to restore the single fire-and-forget send.
neighbouring repeater in range, or heavy loss. If the packet pool refuses an
initial send or retry, it is tried again after the configured backoff; `rtx`
increments only when the retry is queued. The retry is build-time tunable
(`FLEET_ACK_RETRY`, `FLEET_ACK_REPEAT_WINDOW_MS`, and
`FLEET_ACK_RETRY_BACKOFF_MS`), never persisted; build with `FLEET_ACK_RETRY=0`
to restore the single fire-and-forget send.
## Inline pauses (`!delay <ms>`)
+17 -6
View File
@@ -309,8 +309,17 @@ void FleetManager::serviceReplies() {
// window elapsed with no repeater heard repeating the reply: one
// byte-identical resend. Same ts => same packet hash, so every node that
// already relayed attempt 1 suppresses this copy — no duplicate on air.
if (send_fn != NULL) {
send_fn(send_ctx, r.chan_secret, r.chan_hash, r.tx_ts, body, NULL);
if (send_fn == NULL) {
removeReply(i);
continue;
}
bool sent = send_fn(send_ctx, r.chan_secret, r.chan_hash, r.tx_ts, body, NULL);
if (!sent) {
// packet pool refused the retry: it was not sent, so retain the slot and
// try again after the same bounded backoff as an initial-send refusal.
r.deadline_ms = millis() + FLEET_ACK_RETRY_BACKOFF_MS;
i++;
continue;
}
reply_retries++; // the miss count: the first attempt drew no repeat
removeReply(i);
@@ -318,10 +327,13 @@ void FleetManager::serviceReplies() {
}
// first attempt: stamp it now, remember the ts and hash for a possible retry
if (send_fn == NULL) {
removeReply(i);
continue;
}
uint32_t ts = time_fn ? time_fn(time_ctx) : 0;
uint8_t hash[MAX_HASH_SIZE];
bool sent = send_fn != NULL &&
send_fn(send_ctx, r.chan_secret, r.chan_hash, ts, body, hash);
bool sent = send_fn(send_ctx, r.chan_secret, r.chan_hash, ts, body, hash);
if (!sent) {
// packet pool refused the send: no attempt used, try again shortly
r.deadline_ms = millis() + FLEET_ACK_RETRY_BACKOFF_MS;
@@ -363,8 +375,7 @@ void FleetManager::onHeardPacket(const mesh::Packet* packet) {
bool FleetManager::sendAlert(const char* body) {
if (!enabled || psk_len == 0 || send_fn == NULL) return false;
uint32_t ts = time_fn ? time_fn(time_ctx) : 0;
send_fn(send_ctx, psk, chan_hash, ts, body, NULL); // one-shot: no retry
return true;
return send_fn(send_ctx, psk, chan_hash, ts, body, NULL); // one-shot: no retry
}
// ---------------------------------------------------------------- relay side
+30
View File
@@ -1089,6 +1089,30 @@ TEST_F(FleetHooksTest, AckSendRefusalUsesNoAttempt) {
EXPECT_EQ(fleet.getReplyRetries(), (uint32_t)1);
}
// A refused retry was not sent: keep the reply queued for retry and do not
// count it until the packet is actually accepted by the sender.
TEST_F(FleetHooksTest, AckRetryRefusalDoesNotConsumeRetry) {
deliver("!id k1\n!ack\nset a");
ASSERT_TRUE(pass());
g_mock_millis += env.jitter;
fleet.runScripts(ExecRecorder::fn, &env.rec);
ASSERT_EQ(env.sent.size(), (size_t)1);
g_mock_millis += FLEET_ACK_REPEAT_WINDOW_MS;
env.next_send_fails = true;
fleet.runScripts(ExecRecorder::fn, &env.rec);
EXPECT_EQ(env.sent.size(), (size_t)1);
EXPECT_EQ(fleet.getReplyRetries(), (uint32_t)0);
EXPECT_EQ(fleet.getReplyCount(), 0);
EXPECT_EQ(fleet.getAwaitingCount(), 1);
g_mock_millis += FLEET_ACK_RETRY_BACKOFF_MS;
fleet.runScripts(ExecRecorder::fn, &env.rec);
EXPECT_EQ(env.sent.size(), (size_t)2);
EXPECT_EQ(fleet.getReplyRetries(), (uint32_t)1);
EXPECT_EQ(fleet.getAwaitingCount(), 0);
}
#else
// Off switch: the reply is dropped the instant the first send succeeds —
@@ -1219,6 +1243,12 @@ TEST_F(FleetHooksTest, SendAlertUnwiredSenderIsSilent) {
EXPECT_EQ(env.sent.size(), (size_t)0);
}
TEST_F(FleetHooksTest, SendAlertReportsPacketPoolRefusal) {
env.next_send_fails = true;
EXPECT_FALSE(fleet.sendAlert("BATT RESUME 3700mV"));
EXPECT_EQ(env.sent.size(), (size_t)0);
}
TEST_F(FleetHooksTest, AlertIsNotAScript) {
// the alert body does not start with "!id ", so a receiver counts it as
// ordinary chat (noid) and never queues it