Skip to content

fix(heartbeat): allow empty body when --heartbeat (caught live; airc#644 PR-2 follow-up) - #648

Merged
joelteply merged 1 commit into
canaryfrom
fix/heartbeat-empty-body
May 17, 2026
Merged

joelteply merged 1 commit into
canaryfrom
fix/heartbeat-empty-body

Conversation

@joelteply

Copy link
Copy Markdown
Contributor

What

PR-2 (#647) shipped `cmd_send --heartbeat` + the `reminder_timer_loop` hook calling `cmd_send --heartbeat --internal ""` every 60s. Locally testing showed zero heartbeats reaching `messages.jsonl` — silent emission failure.

Root cause: `cmd_send`'s empty-body usage-check (sane default for chat) was rejecting the heartbeat:

```
$ airc msg --heartbeat --internal ""
ERROR: Usage: airc send or airc send @peer
```

This unit tests didn't catch because they're structural (grep for the flag's existence) not behavioural (actually invoke the send). The reminder-loop's subshell suppressed stdout+stderr so the failure was invisible from logs too.

Caught Live

Joel: "have to see if it works." I did the actual user-surface test:

  1. `airc update --channel canary` → pulled new code
  2. `airc teardown && airc join` → restarted with new code
  3. Waited 75s (cadence + buffer)
  4. `grep -c '"kind":"heartbeat"' messages.jsonl` → 0

The failure was found by running the substrate the way a user would, not by trusting tests.

Fix

The empty-body check now exempts heartbeats. The signal in a heartbeat IS its envelope metadata (`kind` / `ts` / `from`); body MUST be empty. Other empty-body sends still die loudly per the prior contract.

```bash
local first="${1:-}"
if [ -z "$first" ] && [ "$heartbeat" != "1" ]; then
die "Usage: airc send or airc send @peer "
fi
```

Validation

`bash -n lib/airc_bash/cmd_send.sh` → ok

After this lands + airc update + restart, the live test should produce:

```
$ grep -c '"kind":"heartbeat"' .airc/messages.jsonl
1+ # one per ~60s of process uptime
```

Title Prefix

`fix:` per conventional-commits; targets `canary` per the merge-to-canary-in-active-loop rule. Closes the regression introduced by #647 in the same active-loop iteration.

Followup

PR-2's tests should grow a behavioural check that actually invokes `cmd_send --heartbeat --internal ""` in a temp-scope and asserts a heartbeat lands in messages.jsonl. Filing as a TODO; the priority right now is fixing the live emission.

…644 PR-2 follow-up)

PR-2 (#647) shipped the cmd_send --heartbeat path + the
reminder_timer_loop hook calling 'cmd_send --heartbeat --internal '
every 60s. Locally tested by:

  $ airc msg --heartbeat --internal ""
  ERROR: Usage: airc send <message>  or  airc send @peer <message>

The empty-body usage-check (sane default for chat) was rejecting the
heartbeat send. As a result no heartbeats reached messages.jsonl
after teardown+rejoin+75s — silent emission failure that PR-2's
unit tests didn't catch because they're structural (grep for the
flag) not behavioural (actually invoke the send).

Joel's discipline applied: 'have to see if it works.' Code review +
unit tests do NOT validate user experience. Run the actual command
a user would run. The reminder loop's invocation IS the user
surface here; teardown+rejoin+wait is the equivalent of a fresh
install path.

Fix: the usage-check now exempts heartbeats. The signal in a
heartbeat is in envelope metadata (kind/ts/from), not the msg body —
empty body is the correct shape. Other empty-body sends still die
loudly per the prior contract.

bash -n lib/airc_bash/cmd_send.sh → ok.
@joelteply
joelteply merged commit 153928d into canary May 17, 2026
6 checks passed
@joelteply
joelteply deleted the fix/heartbeat-empty-body branch May 17, 2026 05:40
This was referenced May 28, 2026
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