Skip to content

Local verification stack, provider seams (embeddings/LLM/storage), and 3 bug fixes - #1

Merged
Dappner merged 6 commits into
mainfrom
claude/cloud-workable-repo-skills-k9a1bc
Sep 27, 2026
Merged

Dappner merged 6 commits into
mainfrom
claude/cloud-workable-repo-skills-k9a1bc

Conversation

@Dappner

@Dappner Dappner commented Sep 26, 2026 •

Copy link
Copy Markdown
Owner

Summary

Makes the app runnable and provable without Doppler, Neon, R2 or AI keys (cloud sessions included). It also puts the three external providers behind interfaces with offline fakes. Driving the real app against those fakes surfaced three user-facing bugs, all fixed here:

Bug User impact Root cause Fix commit
New citations, captures, takeaways and sections never got embedded New highlights invisible to Ask and search FastAPI runs BackgroundTasks before get_db commits, so the embedding task couldn't see the row and skipped silently 7dcd322
Reflect follow-up chips always empty No follow-up suggestions, ever generate_followups read response.parsed, which Jetflow leaves unset after an exit action 2e20e1d
PDF viewer never showed an uploaded PDF "No PDF uploaded" after every upload Viewer keys "has PDF" off metadata.page_count; the backend stripped it and nothing set it 74a6619

How to review

Go commit by commit. Each commit is self-contained, passes tests on its own, and has a detailed message. Size by area:

Area Files Lines Review depth
fast-api/app 43 +899 / −372 careful
fast-api/tests 13 +439 / −69 normal
frontend 1 +15 / −4 careful
config + docs 7 ~+40 skim
.claude/ (verification tooling) 27 +1577 skim, dev-only

Most of the fast-api/app line count is mechanical renames. The parts that need judgment are called out below.

1. 8f57ce6 Verification skill (tooling only, safe to skim)

  • .claude/skills/verify-root/: bash scripts (up/doctor/down/compare), a Playwright harness, a feature map, and a stdlib HTTP fake for Voyage and Gemini.
  • Also adds the generic create-verification-skill and maintain-verification-skill skills.
  • Product change: one optional setting, EMBEDDING_BASE_URL (config.py, clients.py, both compose files).

2. 7dcd322 Embedder seam + background-task commit fix ⚠️ review the fix

  • Look closely at:
    • app/api/*.py: every route that takes BackgroundTasks now uses Depends(get_db, scope="function"). This is the existing pattern from captures.py, applied everywhere.
    • tests/test_background_task_db_scope.py: enforces that rule.
    • app/providers/embedder.py: the new Embedder protocol and FakeEmbedder.
    • app/integrations/voyage.py: VoyageEmbedder.
  • Mechanical, skim: VoyageClient → Embedder and voyage_client → embedder renames across services, deps and agents. Call sites move from .embed(texts=..., input_type=...) to embed_documents / embed_query / rerank.

3. 2e20e1d LLM seam + follow-ups fix ⚠️ review the fix

  • Look closely at:
    • app/providers/llm.py: create_llm_client() now resolves through LLM_PROVIDER=live|fake. FakeLLMClient implements Jetflow's AsyncBaseClient.
    • app/services/agent/followup_agent.py: now parses response.content, the same way transcript_sectioning_service already does.
    • tests/test_fake_llm.py: drives the real Jetflow agent, which is how the bug showed up. The old unit test mocked a response shape Jetflow never produces.
  • Behavior change: app/integrations/llm.py (JetflowLLMProvider) now owns API-key checks. A missing key raises when the client is created instead of when it is first called. VoiceSuggestionMatcher() no longer takes a key, and rag_service no longer gates follow-ups on google_api_key.

4. 6b3d9aa ObjectStore seam

  • Look closely at: five call sites that read the backend's own transcripts by presigning a URL and GETting it with httpx now call read_json(store, key):

    • chunk hydrator
    • suggestion service
    • transcript embed
    • transcript pipeline
    • embedding backfill

    Error types move from httpx.HTTPError / FileNotFoundError to ObjectStoreError / ObjectNotFoundError. Presigned URLs remain only for browsers and AssemblyAI.

  • Also new: R2Client gains get_bytes / get_json, and R2 credentials are only required when OBJECT_STORE_PROVIDER=r2.

  • Mechanical, skim: R2Client → ObjectStore type hints, and get_r2 → get_object_store.

5. 74a6619 PDF viewer fix ⚠️ review the fix

  • Backend: counts pages with pypdf (new dependency), stores page_count, and returns 400 for unreadable PDFs or PDFs over 500 pages (previously that limit was enforced client-side only).
  • Frontend (source-pdf-slideover/index.tsx):
    • hasPdf also accepts size_bytes, so PDFs uploaded before this fix open without a backfill.
    • PdfLoader gets the bundled pdf.js worker. Before, it fetched its worker from unpkg.com at runtime.

Deploy notes

  • No env changes are required. The new vars default to the real providers: EMBEDDING_PROVIDER=voyage, LLM_PROVIDER=live, OBJECT_STORE_PROVIDER=r2, EMBEDDING_BASE_URL empty. They're added to both compose files.
  • New Python dependency: pypdf, pinned in uv.lock. The image rebuild picks it up.
  • After deploy, run the admin embedding refresh per user. Entities created before the fix are missing embeddings. The refresh already selects rows with no embedding.
  • No API contract changes, so frontend and mobile don't need generate:api.

Testing

  • fast-api: 154 unit tests and 71 integration tests pass, the integration tests against the CI Postgres image (paradedb/paradedb:0.20.5). mypy and ruff are clean on changed files.

  • frontend: tsc passes. The PDF slideover file already had 3 ESLint errors on main and has the same 3 here.

  • End to end, all 5 browser scenarios pass on a fresh local stack via .claude/skills/verify-root:

    • library-add-source
    • quote-embed-ask
    • reflect-followups, in both LLM modes
    • pdf-upload
  • Before/after proof: compare.sh <base> <scenario> runs a scenario against the previous commit and the fix side by side:

    Scenario Previous commit This PR
    quote-embed-ask fails (quote never embedded) passes
    reflect-followups fails (no chips, via the real Gemini SDK over the HTTP fake) passes
    pdf-upload fails (page_count never stored) passes

    To reproduce locally, run .claude/skills/verify-root/scripts/compare.sh HEAD~1 pdf-upload.

Not in this PR

  • Fakes for transcription (AssemblyAI), YouTube, and ElevenLabs voice. Features that need them are marked unreachable in the feature map.
  • CI doesn't run the browser scenarios yet.

🤖 Generated with Claude Code

https://claude.ai/code/session_016wtkrky4phkWzyb6s99yN2

… compare

- .claude/skills/verify-root: up/doctor/down/db/compare scripts, Playwright
  harness (scenarios for library add-source and quote -> embed -> ask), and a
  feature map. Runs fully in the container: paradedb Postgres (same image as
  CI), moto for R2, and a stdlib fake for Voyage + Gemini. Services start with
  an explicit env so Doppler/Neon/Logfire values never leak in.
- create-verification-skill / maintain-verification-skill: generic generator
  and upkeep skills, adapted to .claude/skills.
- fast-api: optional EMBEDDING_BASE_URL so Voyage can point at a local fake
  (wired into both compose files).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wtkrky4phkWzyb6s99yN2
Embedder seam (first of the provider refactors):
- app/providers/embedder.py: Embedder Protocol (embed_documents, embed_query,
  rerank), deterministic FakeEmbedder, create_embedder() picking
  EMBEDDING_PROVIDER=voyage|fake. VoyageEmbedder in app/integrations/voyage.py
  owns model + rerank model; services no longer touch the Voyage SDK.
- Services, deps and agents depend on Embedder; tests default to the fake
  (no Voyage key needed for unit tests).

Bug fix: new citations/captures/takeaways/sections were never embedded.
FastAPI runs BackgroundTasks before tearing down request-scoped deps, so
get_db committed after the embedding task had already looked for the row and
silently skipped. Routes that take BackgroundTasks now use
Depends(get_db, scope="function") (as captures already did), enforced by
tests/test_background_task_db_scope.py; a skipped row now logs a warning.
Existing unembedded rows are picked up by the admin per-user refresh.

verify-root: wait for the postgres image's post-init restart before
migrating; feature map updated (quote-embed-ask now passes).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wtkrky4phkWzyb6s99yN2
LLM seam (second provider refactor):
- app/providers/llm.py: create_llm_client(ModelConfig) resolves through an
  LLMProvider chosen by LLM_PROVIDER=live|fake. Jetflow's AsyncBaseClient is
  the (already vendor-neutral) client interface.
- Live: JetflowLLMProvider (app/integrations/llm.py) builds vendor clients and
  owns API-key checks, so services no longer gate on vendor keys
  (VoiceSuggestionMatcher lost its key arg and OpenAI isinstance assert;
  rag_service no longer checks google_api_key).
- Fake: FakeLLMClient speaks Jetflow's protocol (complete/stream/extract):
  scripted responders keyed by action/schema name, auto-calls the RAG search
  tool once, then answers "[fake-llm] ...". Missing responder fails loudly.
- Tests default to LLM_PROVIDER=fake; new tests drive real Jetflow agents.

Bug fix found by the fake: follow-up chips in Reflect were always empty.
generate_followups read response.parsed, which Jetflow leaves unset after an
exit action (the run ends on the tool message); it now parses
response.content like transcript sectioning. The old unit test mocked a
response shape Jetflow never produces.

verify-root: in-process fake LLM by default (VERIFY_LLM=http keeps the Gemini
SDK-over-HTTP path; its fake now answers forced function calls), new
reflect-followups scenario, provider calls copied into each run's evidence,
up.sh refuses to reuse an instance started in another LLM mode.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wtkrky4phkWzyb6s99yN2
…esigned URLs

- app/providers/object_store.py: ObjectStore Protocol, InMemoryObjectStore,
  create_object_store() (OBJECT_STORE_PROVIDER=r2|memory), provider-level
  ObjectStoreError/ObjectNotFoundError, read_json() for async callers.
- R2Client implements it and gains get_bytes/get_json (boto errors mapped).
- The five places the backend read its own transcripts by presigning a URL
  and GETting it with httpx (chunk hydrator, suggestion service, transcript
  embed, transcript pipeline, embedding backfill) now call read_json.
  Presigned URLs remain only for browsers and AssemblyAI.
- Services/deps/routes type against ObjectStore; R2 credentials are required
  only when the provider is r2. Tests default to the in-memory store.

verify-root: pdf-upload scenario (object in the S3 stand-in, key on the row,
presigned URL serves the bytes). It surfaced a pre-existing viewer bug
(page_count is never stored, so the viewer says "No PDF uploaded"),
documented in features/pdf.md and not fixed here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wtkrky4phkWzyb6s99yN2
The viewer treats a source as having a PDF only when metadata.page_count is
set, but upload_pdf stripped page_count and nothing ever wrote it, so every
upload showed "No PDF uploaded".

- Backend counts pages with pypdf on upload, stores page_count (also used by
  citation page-bounds validation), and rejects unreadable or >500-page files
  with 400 (the limit was only enforced client-side).
- Viewer: hasPdf also accepts size_bytes, so PDFs uploaded before this fix
  open without a backfill.
- Viewer: pass the bundled pdf.js worker to PdfLoader, which otherwise
  fetched its worker from unpkg.com at runtime.

Tests: page counting unit tests, API upload regression + unreadable-file
rejection. verify-root pdf-upload now asserts the viewer renders (fresh and
legacy rows); compare.sh shows the previous commit failing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016wtkrky4phkWzyb6s99yN2
Copilot AI lite review requested due to automatic review settings September 26, 2026 19:35

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@Dappner Dappner changed the title Add verify-root skill: local stack, Playwright evidence, before/after compare Local verification stack, provider seams (embeddings/LLM/storage), and 3 bug fixes Sep 26, 2026
@Dappner
Dappner merged commit d0c0d4c into main Sep 27, 2026
3 checks passed
Dappner added a commit that referenced this pull request Sep 27, 2026
…-skills-k9a1bc"

This reverts commit d0c0d4c, reversing
changes made to 541c5ab.
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.

3 participants