feat(addie): instrument agent test runs for staleness-aware prompts#3258
Conversation
67e9ba6 to
d1114cc
Compare
|
TypeScript Build is failing — multiple unit tests crash on WorkOS init at module load: These tests don't directly import member-context. The new import chain in this PR — likely Same shape as the fix on PR #2729: convert the offending import to a lazy dynamic import inside the function body so module initialization doesn't pull WorkOS through. Or, if the eager init is unavoidable, the test files that newly transit this chain need explicit |
|
Fixed in 58de812. The static Removed the static import and converted both Generated by Claude Code |
|
Acknowledged — lazy Triaged by Claude Code. Session: https://claude.ai/code/session_01SZLAcg56zWESGWZi1HeBW9 Generated by Claude Code |
|
Two new failures since the lazy-import fix — main moved while the routine was working: 1. Duplicate Main added its own 2. Migration number 442 now duplicate against main Renumber |
…3254) Adds `agent_test_runs` table and hydrates `agent_testing` on `MemberContext` so #2299 Stage 2 can fire a "Time for a fresh agent test" suggested prompt to builder personas who haven't run a test recently. https://claude.ai/code/session_018QWw9FNTxNgKLejx54HYs2
…tests
The top-level `import { invalidateMemberContextCache }` on member-tools.ts
forced member-context.ts (and transitively auth.ts) to load at module init,
triggering the eager WorkOS constructor before vi.mock could intercept it.
Removed the static import; both call sites in the fire-and-forget .then()
callbacks now use dynamic `await import('../member-context.js')` — same
pattern as line 2195 and as the fix applied in #2729.
https://claude.ai/code/session_018QWw9FNTxNgKLejx54HYs2
Two post-rebase conflicts against main: 1. Remove fetchAgentTesting stub (main's narrow type) — keep this PR's richer AgentTestingContext shape (total_tests_30d + 4-state outcome) which the staleness-prompt rule actually depends on. 2. Renumber 442_agent_test_runs.sql → 444_agent_test_runs.sql; main claimed 442 (addie_prompt_telemetry_clicks) and 443 (agent_test_history_user_id_index) while this branch was in review. https://claude.ai/code/session_01W4Djuhqn6SJJk5qBSPSdTt
58de812 to
d1c675c
Compare
|
Both fixes applied in d1c675c (force-pushed after rebase onto main): 1. Duplicate 2. Migration renumbered — Typecheck after fix: the Generated by Claude Code Generated by Claude Code |
|
Acknowledged — both fixes noted:
Triaged by Claude Code Generated by Claude Code |
PRs #3258 and #3136 both shipped a 444_*.sql migration in parallel. Every deploy after the second merge fails at the duplicate-detection preflight, blocking the queue. Renames the later-merged of the two: - 444_agent_test_runs.sql → 445_* (from #3258, merged after #3136) Both migrations are idempotent (DROP TABLE IF EXISTS / CREATE TABLE IF NOT EXISTS). Dev DBs that already pulled 444_agent_test_runs.sql will see 445 as a no-op next migrate run; prod's release_command was blocked at the duplicate, so it applies fresh as 445. Same shape as the earlier 436 collision fix (#3300). Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Top-level import of member-context.ts transitively loads middleware/auth.ts, which constructs a WorkOS client at module load time. Any test that imports admin-tools.ts without WORKOS_API_KEY set (or without mocking middleware/auth) fails with a WorkOS constructor error. Matches PR #3258's fix for the same pattern in member-tools.ts: remove the top-level import and use `await import('../member-context.js')` inside the two handlers that call invalidateMemberContextCache(). https://claude.ai/code/session_01J5x2do9fKEfGg3uZGZtAzw
Top-level import of member-context.ts transitively loads middleware/auth.ts, which constructs a WorkOS client at module load time. Any test that imports admin-tools.ts without WORKOS_API_KEY set (or without mocking middleware/auth) fails with a WorkOS constructor error. Matches PR #3258's fix for the same pattern in member-tools.ts: remove the top-level import and use `await import('../member-context.js')` inside the two handlers that call invalidateMemberContextCache(). https://claude.ai/code/session_01J5x2do9fKEfGg3uZGZtAzw
…fety checks (#3393) * fix(admin): auto-approve member logo uploads that pass format/size/safety checks Closes #2568. Mary launch blocker — logos uploaded by members sit in a pending queue with no admin UI and no member-visible resolution path. - brand-logos.ts: community uploads now auto-approve (review_status: 'approved') after passing the existing membership + ban + magic-bytes + SVG-sanitization + size gates. Manifest rebuild extended to all uploads (was owner-only). Source still tracks brand_owner vs community. - brand-viewer.html: success message now reflects actual review_status from the API response ('Logo uploaded and live.' vs 'pending review.') instead of hardcoding the pending message. - brand-tools.ts: Addie upload_brand_logo tool had the same pending-only logic as a separate code path. Fixed to match HTTP route: inserts as approved, rebuilds manifest, returns correct status. - brand-logo-db.ts: insertBrandLogo default changed from 'pending' to 'approved' so future callers that omit review_status don't silently re-introduce the queue. - brand-logo-digest.ts: comment updated to explain the job is now a drain for pre-deploy historical pending logos only. - changeset auto-approve-verified-owner-logos.md: removed now-incorrect note that community uploads still queue. https://claude.ai/code/session_019WyF5yW7B8jkypARtKHqcg * fix(admin): lazy-import invalidateMemberContextCache in admin-tools.ts Top-level import of member-context.ts transitively loads middleware/auth.ts, which constructs a WorkOS client at module load time. Any test that imports admin-tools.ts without WORKOS_API_KEY set (or without mocking middleware/auth) fails with a WorkOS constructor error. Matches PR #3258's fix for the same pattern in member-tools.ts: remove the top-level import and use `await import('../member-context.js')` inside the two handlers that call invalidateMemberContextCache(). https://claude.ai/code/session_01J5x2do9fKEfGg3uZGZtAzw --------- Co-authored-by: Claude <noreply@anthropic.com>
Closes #3254
Adds the
agent_test_runstable and surfaces anagent_testingblock onMemberContextso #2299 Stage 2 can fire a "Time for a fresh agent test" suggested prompt tomolecule_builderandpragmatic_builderpersonas who haven't run a test recently. The migration creates the table with constrainedoutcome/agent_protocolcolumns. Write calls are wired into theevaluate_agent_qualityandrun_storyboardhandlers; on success, the Slack-path member context cache is invalidated so the updatedagent_testingsignal is available on the next prompt evaluation without waiting for the 30-minute TTL.Non-breaking justification: adds a new optional table, two new write paths, and a new optional field on
MemberContext— no existing consumers are affected.433_auto_provision_verified_domain.sqland433_catalog_adagents_lookup_index.sqlboth use migration number 433. This PR uses 434 to avoid a second collision. The 433 duplication should be resolved before the migration runner reaches a state where ordering matters. Flagged for @bokelley.Stage 2 design questions (for #2299, not this issue):
last_outcome. Consider outcome-conditioned thresholds:pass+ 21d,fail/partial/error+ 7d.total_tests_30d > 0(or at least one prior run) — users with builder persona but zero test history need a different first-run prompt, not a staleness nudge.Pre-PR review:
COUNT(*)::intmisleading re:parseInt(safe but confusing), nit ontest_kindusing raw storyboardId (text column, no enum constraint needed at this scope)agent_url→agent_hostnameto match stored value, droppedawaiton fire-and-forget record calls, added conditionalinvalidateMemberContextCacheafter each successful writeSession: https://claude.ai/code/session_018QWw9FNTxNgKLejx54HYs2
Generated by Claude Code