AgentSkillsCN

user-error-logging-guardrails

明确并规范SNS用户错误日志的采集范围、来源类型、负载最小值,以及用于开发与运维可观测性的同步规则。

SKILL.md
--- frontmatter
name: user-error-logging-guardrails
description: Define and govern SNS user-error log collection scope, source types, payload minima, and sync rules for dev-maintenance observability.

User Error Logging Guardrails

Use this skill when adding/removing/changing SNS user error log collection behavior.

1) Scope

  • This skill governs "which user error logs SNS collects" and "how collection contracts are versioned."
  • This skill does not replace security boundary constraints. Secret exposure and redaction rules remain governed by:
    • .agents/skills/security-boundary-guardrails/SKILL.md

2) Required Log Source Types

Log source valueTrigger conditionMinimum required fieldsSensitive handling notes
window.errorBrowser runtime uncaught error eventsource, message, pathname, url, context.filename, context.lineno, context.colnoNever include secrets/tokens/private keys in message/context
window.unhandledrejectionBrowser unhandled promise rejectionsource, message, pathname, urlcontext is allowed only as sanitized preview-safe JSON
next.error-boundaryNext.js app-level error boundary fallback rendersource, message, pathname, urlstack optional; do not include server secrets in client-sent data
status-bubbleGlobal SNS status bubble emits error-kind messagesource, message, pathname, urlMessage should remain user-facing error text only
manage-agents-bubbleManage Agents page local bubble emits error-kind messagesource, message, pathname, urlDo not attach decrypted security-sensitive payloads

3) Collection Behavior Rules

  • Logging must stay fail-open: logging failure must never break user flows.
  • walletAddress may be included for triage, but must not be treated as secret-auth material.
  • context must be size-limited and serialization-safe.
  • Keep dedupe/rate limiting to reduce repeated client-noise and DoS pressure.
  • Keep payload as minimal as possible for operational debugging.

4) Sync Rule (Non-Negotiable)

  • When adding/removing/renaming any user error log source in code, update this skill in the same change.
  • Keep producer/ingest/persistence implementations aligned with this skill:
    • producers: apps/sns/src/components/UserErrorLogger.tsx, apps/sns/src/components/StatusBubbleBridge.tsx, apps/sns/src/app/manage/agents/page.tsx, apps/sns/src/app/error.tsx
    • ingest: apps/sns/src/app/api/logs/user-errors/route.ts
    • persistence: apps/sns/src/lib/userErrorLogServer.ts

5) Verification Floor

  • At minimum, run and report:
    • npx tsc --noEmit -p apps/sns/tsconfig.json