Skip to content

Commit 644b400

Browse files
ThinkOffAppPetrus Pennanenclaude
authored
Chat-reply poller: a non-owner /approve for an intent held elsewhere stays silent (#141)
The owner check ran before the intent lookup, so a poller with no owners that never held the intent still posted 'NOT recorded' over an approval the owning poller had settled (2806f59b, 7 Oct 2026). Same multi-poller rule as the unknown-intent branch: only the poller holding the intent may report a failure. Authorization is unchanged. Also move real-agent-demo.mjs from test/ to scripts/: a bare 'node --test' ran it and posted two live confirmation cards to the room. Co-authored-by: Petrus Pennanen <petrus@example.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 2f851ca commit 644b400

3 files changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// Real MCP-driven request_confirmation demo.
2+
// NOT a test: it posts a REAL confirmation card to the room and waits up to
3+
// 10 min. It lived in test/, where a bare `node --test` picked it up and sent
4+
// petrus two live "deploy to production?" cards on 7 Oct 2026. Run by hand.
25
//
36
// Acts as a Claude Code agent: spawns the IAK MCP server, calls
47
// request_confirmation as it would in production, blocks until the user

‎src/confirmations.mjs‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,6 +2210,15 @@ export function startChatReplyPoller({ apiKey, room, intervalMs = 5000, log, own
22102210
// to owners is the fix, silence never is.
22112211
if (!ownerSet.has(sender)) {
22122212
emit(`${text} from ${m.from}: sender is not the owner — ignoring`);
2213+
// Same multi-poller rule as the unknown-intent branch below: only
2214+
// the poller that HOLDS the intent may tell anyone it failed. On
2215+
// 7 Oct 2026 petrus approved 2806f59b; the Mini's poller (which
2216+
// holds it, and lists him as owner) settled it, while this
2217+
// MacBook's poller (no owners configured, never held the id)
2218+
// answered "NOT recorded" in the room. Refusing is right; the
2219+
// public failure notice from a poller that does not own the
2220+
// intent is a false alarm.
2221+
if (!getIntent(match[2])) continue;
22132222
// Answer only senders who plausibly ARE the owner (`petrus`,
22142223
// `petrus-boox`, a future `petrus-watch`). claudeMB's review caught
22152224
// that replying to everything amplifies the very misbehaviour this

‎test/confirmations.test.mjs‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,3 +1052,37 @@ test('the HTML queue renders the server wording, and never calls an unknown outc
10521052
server.close();
10531053
}
10541054
});
1055+
1056+
test('chat-reply poller: a non-owner /approve for an intent held elsewhere stays silent', async () => {
1057+
// 7 Oct 2026: a second poller with no owners and no such intent posted
1058+
// "NOT recorded" over an approval the owning poller had already settled.
1059+
_resetForTests();
1060+
const batches = [
1061+
{ messages: [] },
1062+
{ messages: [
1063+
{ id: 'x1', from: 'petrus', body: '/approve 2806f59b', isHuman: true },
1064+
] },
1065+
];
1066+
let call = 0;
1067+
const posts = [];
1068+
const originalFetch = globalThis.fetch;
1069+
globalThis.fetch = async (url, opts) => {
1070+
if (opts && opts.method === 'POST') { posts.push(JSON.parse(opts.body)); return { ok: true, json: async () => ({}) }; }
1071+
const batch = batches[Math.min(call++, batches.length - 1)];
1072+
return { ok: true, json: async () => batch };
1073+
};
1074+
const lines = [];
1075+
const handle = startChatReplyPoller({
1076+
apiKey: 'k', room: 'r', intervalMs: 10,
1077+
owners: [],
1078+
log: (m) => lines.push(m),
1079+
});
1080+
try {
1081+
await new Promise((r) => setTimeout(r, 120));
1082+
} finally {
1083+
clearInterval(handle);
1084+
globalThis.fetch = originalFetch;
1085+
}
1086+
assert.equal(posts.length, 0, 'no room reply for an intent this poller does not hold');
1087+
assert.match(lines.join('\n'), /not the owner/, 'the refusal is still logged');
1088+
});

0 commit comments

Comments
 (0)