feat(backend): core runtime — scaffold, watchdog, orchestrator, SSE, push, intake, 3 tools, loader, demo endpoints - #72
Merged
Conversation
…push, intake, 3 tools, loader, demo endpoints
BE.1 FastAPI scaffold: app factory, /health, env-only settings, run script.
BE.2 Watchdog: deterministic ingest->normalize->threshold->debounce, fully
data-driven from alarm_dictionary.csv, event-time debounce, zero LLM.
BE.3 Orchestrator: full state machine incl. pivot loop, agents pluggable via
the FROZEN contracts.Agent protocol, dummy agents in registry, agent
timeout/error -> graceful events (INT.5 groundwork). No diagnosis logic.
BE.4 GET /api/stream: SSE per contract, heartbeat, Last-Event-ID resume,
concurrent clients.
BE.5 Push service: contract-validated payload on diagnostic_ready, simctl
primary (file mode = the simctl input), APNs flag-gated.
BE.6 POST /api/validation: schema-validated, idempotent on client_event_id,
409 on wrong state.
BE.7-9 Cost/Inventory/Dispatch tools: deterministic over seeds, DRAFT contract
signatures implemented as drafted, conflict/no-stock cases flagged.
BE.10 Seed loader per data/schema.md with FK checks + loud errors; fallback
sample seeds until DEMO.2.
BE.11 inject-fault (drives the real watchdog path) + reset < 5 s.
23 tests green, incl. E2E confirm + pivot runs with EVERY emitted envelope
validated against contracts/events.schema.json, and SSE over a real uvicorn
server. Live curl-verified: inject -> stream -> validate -> report -> reset.
Closes #13, closes #14, closes #15, closes #16, closes #17, closes #18,
closes #19, closes #20, closes #21, closes #22, closes #23.
Co-Authored-By: Claude Fable 5 <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.
What (the Phase-1 backend lane — closes #13 #14 #15 #16 #17 #18 #19 #20 #21 #22 #23)
The full backend runtime, built on the frozen contracts (#66, #68) and the seed shape contract (#64).
/health, env-only settings,python backend/run.pyalarm_dictionary.csv(zero hardcoded thresholds, zero LLM), event-time debounce so replays behave identicallycontracts.Agentprotocol; no diagnosis logic in /backend — dummy agents return canned shapes, real agents swap in by registry name (handoff notes in backend/README.md)GET /api/stream: SSE identical in wire semantics tocontracts/mock_stream/replay.py— frontend swap = base-URL flip. Heartbeat, Last-Event-ID resume, concurrent clientsPOST /api/validation: validated against the frozen schema (422 with precise errors), idempotent onclient_event_id, 409 on wrong state/incidentdata/schema.mdwith FK validation + loudSeedErrors; sample-row fallback seeds until DEMO.2 lands real volumesPOST /api/demo/inject-fault(drives the REAL watchdog path, any alarm family) +reset< 5 sVerification
cd backend && pytest): watchdog threshold/debounce/no-duplicate, every state transition incl. pivot loop, intake idempotency/409/422, tool determinism + conflict cases, seed FK errors, agent-timeout graceful handling.contracts/events.schema.jsonin the E2E tests — backend cannot drift from what web/iOS build against.phase_started {cause: pivot}→ re-diagnosis → single push →outcome: downgraded.main(post [AGV.2+P0.5] VultronRetriever client + corpus ingestion + tests #69/[AGA.1] Validation agent (confirm/pivot) #70/[AGV.1+P0.4+P0.3] Vultr inference client + pinned model + env hygiene #71); trial merge clean.For reviewers
backend/README.md§ Plugging real agents documents the registry handoff — your agents replace the dummies with zero backend changes. aminssutt's Validation agent ([AGA.1] Validation agent (confirm/pivot) #70) should slot straight into thevalidationregistry key.$ARC_PUSH_OUT_DIR— @daniwavy5032 can drive the iOS simulator from it with the documented one-liner.🤖 Generated with Claude Code