Skip to content

test(bt): pin the advertise refusal and stop guard exits - #97

Merged
ChrisUFO merged 1 commit into
mainfrom
fix/bt-adv-guard-pins
Nov 19, 2026
Merged

ChrisUFO merged 1 commit into
mainfrom
fix/bt-adv-guard-pins

Conversation

@ChrisUFO

Copy link
Copy Markdown
Owner

Why

PR #93 (BT adv editor, PLAN unit PR-12) was squash-merged to main without fix-lane commit a67b115 (reset away by a concurrent session pre-merge). That commit carried guard-exit regression pins; without them, three safety-exit mutations were verified to pass the entire host suite on main undetected — the existing ordering/polarity pins see the guard's condition but not its body:

Mutation Change on main Suite (pre-pin)
M1 delete gate-refusal return ERROR; (m1_bt.c:1809) PASS
M2 delete non-OK-classification return ERROR; (m1_bt.c:1827) PASS
M3 stop latch unconditional stopped = 0U; → 1U; (m1_bt.c:1845) PASS

Concretely: M1 sends the adv command on firmware the gate just refused; M2 latches g_bt_adv_active after an ADV:FAIL reply; M3 reports "stopped" without ever consulting the console.

What

Test-only hardening of m1_csrc/test/m1_bt_adv_test.py (adapts a67b115's pins onto the suite as it exists on main, which has since gained the compiled editor-mapping harness — 85 → 92 checks; no existing check weakened or duplicated; reuses the suite's existing function() extractor style):

  • if_body() extractor — brace-matched, string/comment-aware body of an if (<cond>) { ... } (same token discipline as function()/switch_block()); extraction anchored in the bt_adv_exec_start / bt_adv_exec_stop function bodies.
  • Check 3b (start path refusal bodies): the gate-refusal block (if (!esp_feature_gate_allows(gate.state))) must contain return ERROR; and never bt_cmd_process(; the non-OK block (if (m1_bt_adv_classify_reply(g_bt_scratch) != M1_BT_ADV_REPLY_OK)) must contain return ERROR; and never set g_bt_adv_active.
  • Check 4c (stop latch): stopped = 1U; appears exactly once in bt_adv_exec_stop, only inside the brace-matched condition chaining build ∧ send-success ∧ m1_bt_adv_classify_reply(...) == M1_BT_ADV_REPLY_OK, with no || bypass.
  • CHANGELOG [Unreleased] entry.

Mutation evidence (with these pins)

Mutation Suite result
baseline (no mutation) PASS — 92 passed, 0 failed
M1 delete gate-refusal return ERROR; FAIL — gate refusal block returns ERROR
M2 delete non-OK return ERROR; FAIL — non-OK reply block returns ERROR
M3 stopped = 0U; → 1U; FAIL — stopped is assigned exactly once

Each mutation applied in isolation, source reverted (git checkout -- m1_csrc/m1_bt.c) between runs. Full wired host suite (sh scripts/run_host_tests.sh) green.

Scope

PR-14 remediation (PLAN §18): PR #93's squash merge dropped fix-lane
commit a67b115, so on main all three guard-exit deletions passed the
host suite undetected (M1 gate-refusal return, M2 non-OK-classification
return, M3 unconditional stop latch -- each verified passing pre-pin).

Port a67b115's brace-matched if_body() extractor and checks 3b/4c onto
the evolved suite (now with the compiled editor-mapping harness):

- 3b: the gate-refusal block must contain 'return ERROR;' and never
  'bt_cmd_process('; the non-OK-reply block must contain 'return ERROR;'
  and never set g_bt_adv_active.
- 4c: 'stopped = 1U' appears exactly once, only inside the brace-matched
  classify == M1_BT_ADV_REPLY_OK condition of bt_adv_exec_stop, with no
  '||' bypass.

Mutation verification: baseline 92/92 green; M1/M2/M3 applied in
isolation each fail the suite (1 FAIL each); source reverted clean.
@ChrisUFO
ChrisUFO merged commit 2fd8950 into main Nov 19, 2026
2 checks passed
@ChrisUFO
ChrisUFO deleted the fix/bt-adv-guard-pins branch November 19, 2026 19:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant