Skip to content

docs(logger): document level convention re Slack/PostHog hook#3650

Merged
bokelley merged 1 commit into
mainfrom
bokelley/logger-level-convention
Apr 30, 2026
Merged

docs(logger): document level convention re Slack/PostHog hook#3650
bokelley merged 1 commit into
mainfrom
bokelley/logger-level-convention

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Document in server/src/logger.ts JSDoc that logger.error / logger.fatal (level ≥ 50) trigger the #aao-errors Slack alert and PostHog $exception capture via the pino hook in this file (and notifyErrorChannel in utils/posthog.ts).

Authors writing tool handlers should use:

  • error for unexpected, page-worthy failures (network/parse failures in catch blocks that "shouldn't happen")
  • warn for expected failures that already return a graceful user-facing fallback (third-party 4xx, validation errors, "issue not found", etc.)

This is the convention I learned the hard way fixing the :rotating_light: System error: unknown Slack noise in PRs #3578, #3622, and #3648. Codifying it next to the existing log-level guide so future authors and reviewers have a clear reference.

Audit data

178 logger.error call sites currently exist across server/src/addie/mcp/*.ts. Top files:

count file
78 addie/mcp/admin-tools.ts
27 addie/mcp/member-tools.ts
15 addie/mcp/certification-tools.ts
6 mcp/si-host-tools.ts, mcp/moltbook-tools.ts, mcp/knowledge-search.ts, mcp/billing-tools.ts

Many are legitimate (catch blocks for unexpected failures), some are likely the user-driven-failure-with-graceful-fallback anti-pattern. Triage will follow as alerts surface in #aao-errors. No automated downgrade in this PR — that's judgment-dependent and would have a high false-positive rate as a lint rule.

Test plan

  • Pre-commit (test:unit + test-dynamic-imports + typecheck) — passed
  • Docs-only change to JSDoc; no behavior change

🤖 Generated with Claude Code

Add JSDoc context next to the level guide in server/src/logger.ts
explaining that logger.error / logger.fatal trigger the #aao-errors
Slack alert and PostHog $exception capture via the pino hook, so they
should be used only for unexpected, page-worthy failures. Expected
failures with a graceful fallback (third-party 4xx, validation, etc.)
should be logger.warn so the alert path is not taken.

Same anti-pattern surfaced as ":rotating_light: System error: unknown"
noise in PRs #3578, #3622, #3648.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bokelley
bokelley enabled auto-merge (squash) April 30, 2026 10:11
@bokelley
bokelley merged commit f81e5e9 into main Apr 30, 2026
12 of 13 checks passed
@bokelley
bokelley deleted the bokelley/logger-level-convention branch April 30, 2026 11:17
bokelley added a commit that referenced this pull request Apr 30, 2026
Extends the convention added in #3650 with the third tier that emerged
during the alert-noise cleanup:

- Tier 1: logger.error — unexpected, pages on-call
- Tier 2: logger.warn — expected third-party state we accept
- Tier 3: logger.warn + createEscalation({ category, dedup_key }) —
  actionable but not page-worthy, queued for batch triage

Docs-only. Future authors picking between error and warn for a third-party
failure now have a single reference, and the escalation tier (introduced
in #3672) is discoverable from the same JSDoc instead of being implicit
in PR history.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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