Skip to content

Commit 0ec420a

Browse files
committed
fix(heartbeat): redact suppressed private final from heartbeat event preview
Addresses ClawSweeper P1: the message_tool_only no-tool suppression path copied the private reply text into emitHeartbeatEvent.preview, which is stored as lastHeartbeat, broadcast to gateway subscribers, returned by last-heartbeat, and rendered in the Debug view. Replace with a metadata-only marker so the off-channel reply is not exposed via operator status surfaces. Regression test asserts Telegram is not called and getLastHeartbeatEvent() does not carry the private final text.
1 parent 799a52e commit 0ec420a

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎src/infra/heartbeat-runner.tool-response.test.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,14 @@ describe("runHeartbeatOnce heartbeat response tool", () => {
445445
// The private text must not reach the channel; run still completes.
446446
expect(result.status).toBe("ran");
447447
expect(sendTelegram).not.toHaveBeenCalled();
448+
449+
// The suppressed private text must not leak through the heartbeat event
450+
// preview either (stored as lastHeartbeat, broadcast to gateway
451+
// subscribers, and rendered in the Debug view).
452+
const lastEvent = getLastHeartbeatEvent();
453+
expect(lastEvent?.preview ?? "").not.toContain("private follow-ups");
454+
expect(lastEvent?.preview ?? "").not.toContain("overnight logs");
455+
expect(lastEvent?.preview).toBe("[private heartbeat reply suppressed]");
448456
});
449457
});
450458

‎src/infra/heartbeat-runner.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1898,10 +1898,15 @@ export async function runHeartbeatOnce(opts: {
18981898
});
18991899

19001900
const okSent = await maybeSendHeartbeatOk();
1901+
// Privacy: the suppressed final text must not leak through the heartbeat
1902+
// event preview either (heartbeat events are stored as lastHeartbeat,
1903+
// broadcast to gateway subscribers, returned by last-heartbeat, and
1904+
// rendered in the Debug view). Emit a metadata-only marker instead of the
1905+
// raw private reply text.
19011906
emitHeartbeatEvent({
19021907
status: "ok-token",
19031908
reason: opts.reason,
1904-
preview: replyPayload.text?.slice(0, 200) ?? "",
1909+
preview: "[private heartbeat reply suppressed]",
19051910
durationMs: Date.now() - startedAt,
19061911
channel: delivery.channel !== "none" ? delivery.channel : undefined,
19071912
accountId: delivery.accountId,

0 commit comments

Comments
 (0)