Skip to content

fix(onboarding): capture the nudge's message id, which is nested under message - #957

Merged
lilyshen0722 merged 1 commit into
mainfrom
fix/stalled-connect-message-id
Aug 15, 2026
Merged

lilyshen0722 merged 1 commit into
mainfrom
fix/stalled-connect-message-id

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Found by reading production after #956 deployed, not by CI.

What happened

The first live pass did the right thing: candidates=26 nudged=10 tooRecent=0 notStalled=16, and ten messages landed in ten pods — right people, right pods, right commands. Verified in PG, e.g.

@kaka — I'm installed here, but nothing has ever started me, so mentioning @kaka-agent won't reach anyone yet. Run commonly agent run kaka-agent on the machine where I should live and I'll come online. I'll post here the moment I connect.

And all ten episodes recorded nudgeMessageId: ''.

AgentMessageService.postMessage returns { success, message, summary } — the id is at message.id (PG, the primary store) or message._id (Mongo fallback). The code read posted.id. Undefined every time.

The messages were fine. The audit trail was not, and "why did this person never get nudged" is unanswerable without it — which is exactly the question this feature exists to make answerable. @sprint-impl's reactive responder inherits the same record.

Why the tests passed

The fixture returned { id: 'msg1' } — the shape the bug expected. I wrote the mock from the calling code's assumption instead of from what postMessage actually returns, so the test agreed with the bug rather than with the service.

That is the third variant of this in two days, after "a test that re-declared the handler instead of importing it" and "a test that passed podAuthorized: true and so only proved the service honours a flag". Same root: a fixture asserted against an assumption is not evidence. The fixture now matches the real return shape and a test pins the recorded id.

Second fix in here

postMessage can succeed-without-posting ({ success: true, skipped: true } for duplicate or suppressed sends). That was being counted as a delivered nudge — the silent-success shape yet again. The episode stays claimed, which is right (something decided that room did not need the message), but the caller is no longer told a nudge went out when none did.

Not fixed here

The ten already-sent episodes keep their empty ids. The messages exist (53316–53325) and are recoverable by pod + timestamp if we want them backfilled — say the word. I did not do it silently because it is a data write to repair an audit field, and the messages themselves are already correctly delivered.

Correction to something I said before deploying

I told Sam "nobody gets more than one" nudge. True for every real user, and false for the smoke fixture, which has two stalled seats in one pod and so got two messages there. Episodes are per (installation, token), so a user with two stalled seats in one pod gets two posts. Correct behaviour, wrong claim.

65 tests green, tsc:check clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8

…r `message`

Found by reading production after #956 deployed. Ten nudges landed correctly
in ten pods — right people, right pods, right commands — and all ten recorded
`nudgeMessageId: ''`.

`AgentMessageService.postMessage` returns `{ success, message, summary }`. The
id lives at `message.id` (PG, the primary store) or `message._id` (the Mongo
fallback). The code read `posted.id`, which is undefined.

The messages were fine; the audit trail was not. "Why did this person never
get nudged" is unanswerable without it, and the reactive responder inherits
the same record.

The tests did not catch it because the fixture returned `{ id: 'msg1' }` — the
shape the bug expected. A mock built from the calling code's assumption rather
than from the callee's actual return will agree with the bug every time. The
fixture now matches what postMessage really returns, and there is a test
asserting the recorded id.

Also stops counting a declined post as a delivered nudge: postMessage can
succeed-without-posting (`skipped: true` for duplicate/suppressed sends), and
reporting that as `nudged` is the silent-success shape again. The episode
stays claimed — something decided that room did not need the message — but the
caller is no longer told a nudge went out when none did.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01XeUH4HVDsDHYPsHJthXjB8
@lilyshen0722
lilyshen0722 merged commit c0e5d5d into main Aug 15, 2026
11 checks passed
@lilyshen0722
lilyshen0722 deleted the fix/stalled-connect-message-id branch August 15, 2026 17:15
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