Skip to content

Phase 0 engine#2

Merged
justin06lee merged 7 commits into
masterfrom
phase-0-engine
May 22, 2026
Merged

Phase 0 engine#2
justin06lee merged 7 commits into
masterfrom
phase-0-engine

Conversation

@justin06lee

Copy link
Copy Markdown
Owner

No description provided.

justin06lee and others added 7 commits May 22, 2026 04:03
…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>
@justin06lee
justin06lee merged commit 1c344f3 into master May 22, 2026
1 check passed
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