Context
The product is always-on: the UI should see scan progress, detected changes, action delivery, state changes, and entitlement changes over one EventSource stream. This issue owns only the /v1/stream contract and server-side event fan-out.
Acceptance Criteria
Files to Touch
apps/api/src/routes/stream.ts
apps/api/src/stream/broker.ts
apps/api/src/stream/events.ts
apps/api/src/auth.ts
apps/api/src/server.ts
packages/shared/src/types.ts
packages/shared/src/schemas.ts
tests/api/stream.test.ts
Prompt
/plan
Implement the Redline `/v1/stream` SSE contract from the handoff. Build query-param auth, org-scoped EventSource fan-out, heartbeat keepalives, documented event shapes, and reconnect support. This branch must stand alone from other issue branches.
Test Plan
- Run stream route tests
- Verify unauthenticated requests fail with the standard error envelope
- Verify connected clients receive heartbeat comments every 15 seconds
- Verify events only deliver to clients in the same org
- Verify each documented event kind serializes to the expected payload shape
Redline Handoff Adherence
- SSE contract from
handoff/API.html
- Scheduler cadence from
handoff/Runbook.html
- Always-on product behavior from
handoff/Product Decisions.html
- This issue has no dependency on Add Vendor, Stripe, evidence brief, Slack, or lifecycle routes
Per-Issue PR Workflow (REQUIRED)
- Branch from
main: d3v07/sse-stream-contract
- Implement without waiting on any other issue branch
- PR to
main: Closes this issue
- Review pass for auth, org scoping, and event shape stability
- Address comments
- Leave final merge to
main for the owner
Definition of Done
Context
The product is always-on: the UI should see scan progress, detected changes, action delivery, state changes, and entitlement changes over one EventSource stream. This issue owns only the
/v1/streamcontract and server-side event fan-out.Acceptance Criteria
/v1/streamas a long-lived EventSource endpoint:heartbeatkeepalives every 15 secondsscheduler.tick,run.stage,change.detected,action.delivered,change.stateChanged, andorg.entitlements.changedFiles to Touch
apps/api/src/routes/stream.tsapps/api/src/stream/broker.tsapps/api/src/stream/events.tsapps/api/src/auth.tsapps/api/src/server.tspackages/shared/src/types.tspackages/shared/src/schemas.tstests/api/stream.test.tsPrompt
Test Plan
Redline Handoff Adherence
handoff/API.htmlhandoff/Runbook.htmlhandoff/Product Decisions.htmlPer-Issue PR Workflow (REQUIRED)
main:d3v07/sse-stream-contractmain:Closes this issuemainfor the ownerDefinition of Done
d3v07/sse-stream-contractmain