Phase 0 engine#2
Merged
Merged
Conversation
…ipeline (dev/fake)
End-to-end /analyze pipeline working offline in fake mode, with real Groq/Tavily/Gemini
providers wired for when keys are present.
packages/providers:
- LLMProvider/SearchProvider protocols; factory on ZEROFORCE_MODE = fake|dev|prod.
- FakeLLMProvider/FakeSearchProvider: deterministic, offline, the default for tests/CI.
- GroqProvider, TavilyProvider (dev) and GeminiProvider two-pass + VertexGrounding (prod),
all with lazy SDK imports so the base install needs no vendor SDKs.
packages/schemas: shared API models (AnalyzeRequest, AnalysisResult, JobRecord with the
{pending,running,done,failed} status enum, Simulate/WhatIf models); engine types re-exported.
services/backend: the six services as pure cores + thin wiring.
- extractor (Prompt 1 + grounding), validator (§7.2 normalization invariant),
engine (wraps packages/zeroforce; analyze/simulate/what-if), reporter (Prompt 3),
orchestrator (async job lifecycle + 5-min timeout), gateway (FastAPI, all /api/v1 routes).
- ServiceClient abstraction: InProcessServiceClient (default, offline) + HTTPServiceClient
(compose/prod). Storage: Repository protocol with SQLite + in-memory impls.
- BEA 15-sector bundle (data/bea-15-sector.json) behind /api/v1/sectors.
api.compute now uses the numba JIT path with a pure-Python fallback (n=15 sectors was
unusably slow on the reference DP).
uv workspace at repo root (packages/* + services/*). 8 backend tests pass (validator units +
full pipeline integration through the gateway); 49 tests pass overall.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…kend - Landing page: input + example chips -> starts async analysis, routes to /analyze/[id]. - Dashboard /analyze/[id]: polls job status; three-panel layout (left recap + selected-node detail with unreachable_from_here disclosure; center force-directed graph; right rail). - ForceGraph (react-force-graph-2d, dynamic/ssr-false): node color by impact percentile, size by n_reachable, link width by weight, link color by confidence. - RightRail tabs: impact-ranked table (with raw EPT + reach + non-cascading section), executive report, citations, validation notes. - next.config rewrites /api/v1/* to the backend (API_BASE). next@14.2.35 (security-patched). tsc --noEmit clean; vitest 3/3 (color scale); next build clean (4 routes); live uvicorn smoke confirms end-to-end analyze over real HTTP. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…aform - Per-service FastAPI apps (worker_apps.py): extractor/validator/engine/reporter, each wrapping one core over HTTP. Gateway switches to HTTPServiceClient when ZEROFORCE_SERVICE_URLS is set (compose/prod); InProcess otherwise. - FirestoreRepository (prod) implementing the Repository protocol; Redis + in-memory caches. Both lazy-import their SDKs; untested without GCP/Redis. - Dockerfile.backend (one image, command selects the service) + Dockerfile.web (Next standalone). docker-compose.dev.yml runs all six services + redis + web. - Terraform: Cloud Run service per microservice, Firestore, Memorystore Redis, Artifact Registry, Secret Manager, runtime SA + IAM. Written as IaC; NOT applied (no GCP creds, no deploy, per the build constraints). - tests/parity: engine-golden (BEA ring EPT regression + determinism) and extraction-consistency (node Jaccard >= 0.7, top-3 overlap >= 2; no EPT comparison). Decision (PROGRESS.md): orchestrator is co-located in the gateway service rather than a seventh process. 52 tests pass; worker chain verified end-to-end over HTTP. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Cascade animation: select a node -> "Simulate cascade from here" calls /simulate; a bottom timeline plays/pauses/scrubs rounds, and the force graph recolors each node white->red by its per-round disruption probability. - What-if panel: pick an edge, drag its weight, Compute -> /whatif; shows the top EPT movers (baseline -> modified, colored by direction) plus the model narration. - Responsive: single-column stacked layout below 1024px (graph + rails), three-panel at lg+. DECISION (PROGRESS.md): the executive report renders non-streaming; token streaming via the Vercel AI SDK is deferred (the fake/Groq reporter returns a single shot). tsc --noEmit clean; next build clean (4 routes). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… a11y - Observability: per-request timing middleware emitting structured JSON access logs and a Server-Timing header; opt-in OpenTelemetry FastAPI tracing (ZEROFORCE_OTEL=1, console exporter dev / Cloud Trace prod). - Hardening tests: bearer-token auth enforcement, PII redaction on /upload, and a chaos test injecting a failing LLM provider (pipeline fails cleanly as llm_provider_error, no hang). The PII test caught a real bug — non-PDF uploads fell back to the filename and skipped scanning; fixed to decode and redact text bytes. - k6 load script (tests/load): 10 RPS sustained + 100 RPS burst against the async analyze path with poll-to-completion and failure-rate/latency thresholds. - SECURITY.md: spec §12 threat model with per-item implementation status; verified no secrets are committed and no .env files are tracked. - a11y: prefers-reduced-motion disables cascade auto-play; aria-live round announcements; ranking table caption + column scopes. 55 Python tests pass; frontend tsc + build clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- ARCHITECTURE.md: three layers, service topology + ServiceClient abstraction, dev/prod/fake hinge, repo layout, and a prominent oracle-strategy callout (the project's load-bearing safety decision) plus the two recurrence/invariant clarifications. - README rewritten from stub: pitch, offline quickstart, tests, status. - docs/RUNBOOK.md: local single-process + six-service compose, mode matrix, the (un-applied) Terraform/Cloud Run deploy procedure, observability toggles, k6 load, and the beta onboarding process. DECISION (PROGRESS.md): no separate apps/docs site; math explainer lives in the engine README + ARCHITECTURE.md. Cloud deploy documented but not applied (no GCP credentials). 55 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.