Repository navigation
feat(cli): add squirrel channel to push cloud audit events into Claude Code - #571
Conversation
…e Code #569 Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review of the new The design is sound. The injection defence is good: events are built only from re-validated ids, counts and fixed strings, titles and bodies are dropped at parse time, and
|
…hten state dir #569 Signed-off-by: Nik Cubrilovic <[email protected]>
|
Pushed Medium, fixed: Lows and nits:
Local gates on the merged tree: typecheck, lint and format clean, 316 tests pass (channel, cli, completions, mcp), |
|
Review of
|
…, soften fix guidance #569 Signed-off-by: Nik Cubrilovic <[email protected]>
|
Pushed to address the second review. Medium, fixed: the channel now re-resolves the active org every 10 polls. On a switch it opens that org's own state and starts from now, so there is no cross-org delivery and no replay. A failed lookup keeps the current org. Tests: org switch, failed lookup, and 401 recovery without a restart. Docs no longer tell users to restart after switching. Lows and nits:
Local gates: typecheck, lint, format clean; 320 tests pass; |
|
Reviewed the diff for
|
|
Reviewed the channel server, poller, state store, events and CLI wiring. I didn't run the tests. The design is sound: event text is built only from validated ids and counts, delivery is marked per row, and the poll loop backs off on failure. I found nothing that should block merge.
Test coverage looks good: events, poller, server loop and an e2e test are all included. A poller test for a page with some malformed rows would cover the first point. |
Signed-off-by: Nik Cubrilovic <[email protected]>
|
Pushed Cause: the Fix: restored Local gates on the merged head: typecheck, lint and format clean; 327 tests pass across channel, mcp, cli and completions. The latest review (all lows and nits, none blocking) is not addressed in this push: the raw page length when rows are malformed, hostname text in |
PR too large for auto-reviewThis PR is 6062 changed lines (limit 6000), so the automated reviewer was skipped: past that size it runs out of turns mid-session and posts nothing, which is worse than saying so. Run it manually ( Diff measured: 19 reviewable files, 6062 changed lines (1 generated files ignored). |
What changed and why
Adds
squirrel channel, a stdio MCP server that Claude Code registers as a channel. It polls the logged-in org's cloud notification feed (GET /v1/notifications) and pushesaudit_complete,audit_failedandissues_detectedevents into a running session, so the agent can triage without being asked.apps/cli/src/channel/, separate fromapps/cli/src/mcp/server.ts. It uses the low-levelServerfrom@modelcontextprotocol/sdkv1, which negotiates up to2025-11-25(Claude Code refuses channels that negotiate2026-07-28), so a later migration ofsquirrel mcpleaves it alone.capabilities.experimental['claude/channel']only. No permission relay.categoryand validated ids, counts and fixed strings. Titles and bodies are dropped at parse time, so crawled text never reaches the agent. Meta keys arecategory,website_id,run_id,audit_id,domain,notification_id,reason_code.~/.squirrel/channel/<org id>.json. First run starts from now and replays nothing.login_requiredevent, then the server keeps running and picks up a later login without a restart.--interval(default 30s, min 5) and--categoriesare configurable. 429, 5xx and network errors back off exponentially up to 10 minutes.docs/developers/channel.mdx(including the allowlist and development-flag caveats) anddocs/cli/channel.mdx.Cloud cursor dependency
The cloud feed is gaining an
after=<cursor>parameter and anext_cursoron every response, which is tracked on the cloud side. The channel supports both shapes:afterto get a starting cursor, thenafter=next_cursor(oldest first).next_cursorin the response (today): it reads the newest-first page and de-dupes by notification id and by run (a run produces a user-scoped and an org-scoped row) with a bounded persisted seen-set. In this mode, more than 50 new notifications between polls can be missed.It switches between the two automatically.
Acceptance criteria
squirrel channelstarts a stdio server registered as a channel:tests/channel/server.test.ts(capabilities),tests/channel/e2e.test.ts(real CLI over stdio).category,website_id,run_id,domainmeta and a one-line summary:tests/channel/e2e.test.ts,tests/channel/events.test.ts. Latency is one poll interval (default 30s).audit_failedandissues_detectedare delivered and categories are configurable (--categories):events.test.ts,poller.test.ts,parseCategoriestest.poller.test.ts("a restart catches up exactly once", legacy de-dupe tests).events.test.ts("never echoes title, body or free text").server.test.ts("no login").server.test.ts("backoff", "429 and 5xx").src/self/completion.ts.docs/developers/channel.mdx.Verification
In
apps/cli:bun run typecheck,bun run lint,bun run format:checkall clean.bun test tests/channel tests/cli tests/self/completion.test.ts tests/mcp: 314 pass, 0 fail. Indocs/:make validatepasses. The compiled binary (bun run build) was driven by an MCP client against a mocked feed and emitted anotifications/claude/channelevent for the mocked row after the bootstrap poll, and persisted the cursor.Notes for reviewers
squirrel auth login(there is no top-levelsquirrel login), so the event text uses that.login_requiredevent.compare_auditsis named in the channel instructions as "when your squirrelscan server offers it": it is not a tool on the local or hosted servers today.Agent skill
The squirrelscan agent skill needs a change (a new command and what the events mean). This is tracked privately.
Generated by Claude Code