japa-backend-auditor
Full systematic audit of the JapaConnect Go backend API for standards drift, missing features, unwired handlers, missing catalog entries, security gaps, and architectural conformance. Use when the use
SKILL.md.claude/skills/japa-backend-auditor/SKILL.md
GitHubJapa Backend Auditor
Systematic sweep of the JapaConnect Go backend against JEOS catalogs. Not a code reviewer (single PR) or debugger (specific bug) — this is a proactive full-backend conformance audit.
Stack
- Go 1.26, Chi router, sqlc + pgx/v5 + PostgreSQL 18 (pgvector)
- Asynq (68 tasks catalogued in JEOS), Valkey (jc: namespace, 34 key patterns)
- Meilisearch 1.45, SeaweedFS, imgproxy, Honcho (separate logical DB)
- GlitchTip (self-hosted), Env var prefix: JC_, API base: /api/v1
Audit Checklist
0 Route Completeness
- List every Chi route registered in the codebase.
- Verify if the api backend routes and features cover all use cases in .JEOS Specification
- Verify all entities are properly gated using RBAC acccording to JEOS
- Verify all RBAC entities have CRUD operation endpoints
- Flag: routes and features not covered yet in JEOS
1. Route Catalog Coverage
- Cross-reference against the API routes catalog in JEOS (
conventions/api-routes-catalog.md). - Flag: route in code but absent from catalog (undocumented).
- Flag: route in catalog but absent from code (phantom).
- Confirm all routes mounted under
/api/v1.
2. Asynq Task Catalog Coverage
- List every task name registered in the Asynq server mux.
- List every task enqueued anywhere in the codebase.
- Cross-reference both lists against the 68-task JEOS catalog (
sections/11-job-queue-asynq.md). - Flag: task in code but not in catalog (undocumented).
- Flag: task in catalog but no handler registered (dead entry).
- Flag: task enqueued but no matching handler (orphaned enqueue).
3. Valkey Key Pattern Compliance
- List every Valkey key string constructed in the codebase.
- Confirm each key begins with
jc:prefix. - Cross-reference against the 34-pattern JEOS catalog (
conventions/valkey-keys-catalog.md). - Flag: key pattern not in catalog.
- Flag: key written without explicit TTL where one is expected.
4. System Settings Catalog Coverage
- List every
system_settingskey read or written. - Cross-reference against the 49-key JEOS catalog (
conventions/system-settings-catalog.md). - Flag: key used in code but absent from catalog.
- Flag: key in catalog never read or written in code (stale).
5. Migration & Table Integrity
- Count total migration files; confirm they account for all 145 tables in
schemas/MIGRATION-ORDER.md. - Confirm migration files numbered/ordered correctly — no gaps, no duplicates.
- Flag: table referenced in sqlc queries but absent from migrations.
- Flag: table in migrations with no corresponding sqlc query file.
- Confirm Honcho DB schema entirely separate from main migration pipeline.
6. RBAC Coverage
- For every non-public Chi route, confirm authentication middleware is applied.
- For every write/update/delete handler, confirm permission check (UserGroup → UserRole → Permission).
- List all permission nodes in code; cross-reference against JEOS permissions catalog.
- Confirm all
ai.context.*permission nodes default to OFF in catalog and seed data.
7. Security Sweep
- Check all handler input-parsing paths for missing validation/sanitization before reaching sqlc queries or external services.
- Confirm Honcho erasure on account deletion is hard deletion (not soft, not best-effort, not queued-only).
- Check for direct MinIO references (MinIO archived per ADR-048; must use SeaweedFS).
8. Financial Integrity
- Confirm no mutable balance or running-total column in Wallet/Credits tables — ledger must be purely transactional.
- Confirm no Credits → Points reverse conversion in any code path.
- Confirm Points → Credits conversion is one-way and irreversible in code (not just docs).
- Confirm no Credits expiration logic in any handler, task, or scheduled job.
9. SQLC & Database Hygiene
- List sqlc query files with no corresponding handler (orphaned queries).
- Check for raw pgx query execution (
conn.Exec,conn.Querywith inline SQL) where sqlc should be used. - Check for N+1 query patterns: loops issuing individual SELECTs where JOIN/IN would be correct.
10. Environment Variable Compliance
- List every
os.Getenvor config struct field. - Confirm all env var names begin with
JC_prefix. - Flag: env var in code but not in JEOS env var catalog.
- Flag: hardcoded credential, hostname, or secret that should be an env var.
11. Error Tracking Coverage
- Confirm GlitchTip capture in all top-level error paths (unrecoverable handler errors, Asynq panics, critical Valkey/DB failures).
- Flag: error path that logs to stdout only without GlitchTip capture.
12. House Rules Compliance
- Scan commits/PRs for AI-generated labels (AGENTS.md Rule 17). Flag violations.
- Confirm no Coupon embed stores a resolved coupon code — only entity IDs.
- Confirm no Honcho code passes through main sqlc/migrate pipeline.
Output Format
Produce a structured audit report:
SUMMARY
- Total findings by severity: Critical / High / Medium / Low / Info
- Total findings by category
FINDINGS
ID: AUDIT-BE-###
Category: Routes | Tasks | Valkey | Settings | Migrations | RBAC |
Security | Financial | Database | Environment | Monitoring |
Standards
Severity: Critical | High | Medium | Low | Info
Location: File path and line range (or "catalog" if catalog-only)
Finding: One sentence describing the deviation
Action: The specific change required to resolve it
CATALOG GAPS
- Undocumented routes, tasks, keys, or settings found in code
- Dead catalog entries with no code counterpart
CLEAN AREAS
- Explicitly confirm each checklist area that found no issues
JEOS Files to Load
Before running the audit, load these JEOS reference files:
JEOS.md(index)conventions/api-routes-catalog.mdsections/11-job-queue-asynq.mdconventions/valkey-keys-catalog.mdconventions/system-settings-catalog.mdschemas/MIGRATION-ORDER.mdsections/03-rbac.mdconventions/permissions-catalog.mdsections/02-authentication-sessions.md
Load sections/ files referenced by specific findings as needed. Do not load all 56 sections at once.