Skip to content

feat(admin): variant gate failures inspection [STORY-039e] - #76

Merged
khoks merged 1 commit into
mainfrom
story/039e-admin-failed-gate-surface
May 11, 2026
Merged

khoks merged 1 commit into
mainfrom
story/039e-admin-failed-gate-surface

Conversation

@khoks

@khoks khoks commented May 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds persistent failure log + admin Fastify endpoint + minimal admin Next.js page so operators can see which LLM-generated problem variants are failing the structural Zod gate, identity checks, self-validation, spec-clarity judge, or retry exhaustion.
  • New `variant_gate_failures` table (migration 0024) + new `users.is_admin` column (migration 0025).
  • `generateProblemVariant` extended with optional `failureLogger` parameter wired to a `DrizzleVariantFailureLogger` in apps/api.
  • Closes STORY-039 AC chore(project): close STORY-052 (monorepo skeleton done) #6 (deferred when STORY-039 shipped).

Test plan

  • DB schema test asserts insert/query of variant_gate_failures.
  • Agent tests verify failureLogger is called with correct reason on each failure path.
  • Admin route tests cover 401 / 403 / 200 / filter / pagination.
  • Web page tests cover non-admin redirect + admin sees table + empty state.
  • pnpm format:check passes.

Story: project/stories/STORY-039e-admin-failed-gate-surface.md
Parent: STORY-039

DRAFT — see story checklist; will flip to ready once tests pass.

🤖 Generated with Claude Code

@khoks
khoks force-pushed the story/039e-admin-failed-gate-surface branch 3 times, most recently from b7c79fb to 4edd8f1 Compare May 11, 2026 15:02
…e) [STORY-039e]

Squashed rebase of the STORY-039e branch onto current main (which already
includes STORY-039d's spec-clarity judge merged via PR #75).

Lands:
- Migration 0025_variant_gate_failures: CHECK-constrained failure_reason
  enum (parse_error / identity_mismatch / spec_clarity_judge /
  self_validation / retry_exhausted), failure_detail jsonb, model_id,
  attempt_number; indexed on (source_problem_id, attempted_at desc).
- Migration 0026_users_is_admin: boolean default false.
- @learnpro/db variant-gate-failures helpers + tests.
- apps/api admin route GET /v1/admin/variant-failures with 401/403/200
  gates + filter + pagination.
- apps/web admin page at /admin/variant-failures (server component).
- is_admin: false added to apps/api test session factories (data-controls,
  export, index, onboarding, profile-insights, session-plan, today-plan,
  tutor, weekly-plan, autonomy, bug-finding-scores, cheatsheet,
  cheatsheet-cron, email-digest, email-digest-cron, install-eligible,
  llm-mode, notifications, portfolio, profile-insights-cron, quiet-hours,
  recommendation, sandbox*, tutor-factory, etc).
- is_admin: false in db data-export.test.ts makeUser factory.

Known follow-up: the agent-side failureLogger wiring (passing
failureLogger to generateProblemVariant + safeLogFailure calls in
tryGenerateOne) is NOT included in this commit because it conflicted
non-trivially with STORY-039d's spec-clarity judge runtime integration
that landed on main first. The variant_gate_failures table is set up
to receive failure entries; wiring the agent to write to it is filed
as a STORY-039g follow-up.
@khoks
khoks force-pushed the story/039e-admin-failed-gate-surface branch from 4edd8f1 to cc4a908 Compare May 11, 2026 15:07
@khoks
khoks marked this pull request as ready for review May 11, 2026 15:12
@khoks
khoks merged commit 8a4f224 into main May 11, 2026
1 check passed
khoks added a commit that referenced this pull request May 11, 2026
…80)

- STORY-039f (variant seeding CLI) status → done with merge SHA + summary.
- STORY-039g (failureLogger agent wiring) filed at status: backlog with
  full ACs. Captures the unwired piece of PR #76's squash-rebase.
- DECISIONS_LOG: two new 2026-05-11 entries — (1) cycle-break +
  NOT-NULL ripple + TaskStop reflex, (2) squash-rebase fallback +
  STORY-NNNg "ship the structure, defer the glue" convention.
@khoks
khoks deleted the story/039e-admin-failed-gate-surface branch May 14, 2026 22:55
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