Skip to content

P2 — LLM seam & extraction #3

Description

@foae

Goal: provider-agnostic vision extraction with fail-closed metering, gated by a real eval. Spec: design/plays-plan.md §4, design/plays-product.md §4.1.

  • Deps: ai, @ai-sdk/openai, sharp; verify ai v5 zod-4 generateObject support and OpenAI strict-output .nullable() (not .optional()) constraint
  • PlayAnalyzer seam + injected fake; image downscale via sharp (off the main event loop)
  • PlayExtraction zod schema, pinned per product §4.1: per-leg positions with stable position_id, side (quantity always positive), full expiry, ×100 convention, opened_at, currency + prompt v1 (versioned, under plays/prompts/)
  • Deterministic validation: three-outcome ticker check (committed known-non-equity list), P&L arithmetic cross-check, confidence derived from the deterministic pass
  • markPlay(extraction, quotes) stub + unit tests — the compile-checked P2↔P5 pin
  • Metering fail-closed: zero/missing price refuses dispatch; daily cap summed from DB cost_usd rows (UTC day); worst-case pre-dispatch reservation via max_output_tokens; unit tests cover all-zero-price and restart cases
  • Per-stage atomicity: child row + status advance + cost in one transaction; LLM call outside any tx (P9)
  • Eval: fixtures/plays/ ≥30 stratified, redacted screenshots, hand-labeled; machine-scored per-field; near-perfect thresholds on marking-critical fields (ticker/side/quantity/strike/expiry)
  • Ops that must not wait for P6: spend + queue-depth logging; OPENAI_API_KEY in deploy/v2/.env.example; stop_grace_period in compose
  • Model + budget decision happens here (deferred by owner 2026-08-18)

Gate: eval thresholds met (hand-judged sample spot-checked by owner); budget behavior proven incl. fail-closed cases; live queue extracts real plays.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    playsWSB Plays product work

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions