observability: transport-log-stream-sse — one SSE route through the community door, plus the bounded log download #808

Closed
opened 2026-08-25 10:58:37 +00:00 by matou-build-agent · 2 comments

Parent

Feature spec: #791 — control-panel observability child spec: logs (P10) (DDR 0203).
Design ticket #760; slice-map fan-in #770; wayfinder map #7.
Slice transport-log-stream-sse of docs/slices/observability.yaml; covers spec #791 stories 39–40.

What to build

SSE is ruled in, scoped to logs. One route: EventSource, one-directional, plain HTTP through
the community door's forward_auth, auto-reconnecting, no WebSocket upgrade machinery — the
client never sends up the socket, so re-scoping opens a new subscription rather than negotiating
on an open one. Plus the bounded log download for the same scope.

The provisionClient.ts "no SSE/WebSocket" line stays true of provisioning's projection reads:
it was never a global rule, and logs are its inverse. No other dashboard read is converted to push
by this slice.

Both routes sit behind the community door, operators only (DDR 0172): EventSource rides the same
community session cookie and the gateway's forward_auth covers the SSE route like any admin
route. An unauthenticated or non-operator caller is refused and no line is emitted. No
redaction tier is built — there is no public tier to redact for, and the
secrets-never-enter-logs-by-construction rule is unchanged.

Acceptance criteria

  • (story 39) Given the OpenAPI spec, then it carries the SSE stream route and the bounded log download; the download goes through the generated client (no hand-rolled fetch), and wire fields are snake_case camelised at the client boundary.
  • (story 37) Given an authenticated operator, when they open the stream route, then the response is a well-formed event stream and events are delivered.
  • (story 37) Given an unauthenticated or non-operator caller, then the stream route refuses exactly as every other admin route does and no line is emitted.
  • (story 37) Given the bounded download, then it sits behind the same community door and returns the bounded artifact for the requested scope.
  • (story 40) Given every other dashboard read, then it keeps its existing re-read cadence — no projection is converted to push by this slice.
  • (story 40) Given the hub, then this route adds no new port and no new ingress surface: one route through the existing front door.
  • (story 37) Given the operator-only posture, then no redaction tier is built.

Blocked by

  • #806 — observability:logstream-hub
  • bootstrap:control-plane-tracer (#127 — done, satisfied)

Task manifest

task: observability:transport-log-stream-sse
interface: one SSE stream route (EventSource-shaped, one-directional, plain HTTP, auto-reconnecting) and
  one bounded log-download route, both on the existing OpenAPI spec behind the community door's `forward_auth`
seam: 'transport integration tests (prior art `fleet_integration_test.go`, `authgate_test.go`): an authenticated
  operator receives a well-formed event stream; an unauthenticated caller is refused and **no line is
  emitted**; the bounded download returns the artifact for its scope; no new port or ingress is opened'
acceptance:
- given: an authenticated operator
  when: the stream route is opened
  then: a well-formed event stream is returned and lines are delivered
- given: an unauthenticated caller
  when: the stream route is opened
  then: it is refused and no line is emitted
- given: an authenticated operator
  when: the bounded download is requested for a scope
  then: the bounded artifact for that scope is returned
- given: provisioning's projection reads
  when: the tree is inspected after this slice
  then: they still carry no SSE/WebSocket — SSE is scoped to logs
depends_on:
- logstream-hub
- bootstrap:control-plane-tracer
out_of_scope:
- the browser-side `EventSource` construction, reconnect and guards (`dashboard-log-stream-source`)
- converting any other dashboard read to push
- a WebSocket upgrade path
- a redaction tier or member-facing logs tier
- log retention / history search beyond the hub's ring and the bounded operation logs
needs_human_decision: []

Emitted by /to-tickets over docs/slices/observability.yaml in an unattended session under ADR 0174 (two-way-door posture — Ben's veto is asynchronous, never blocking). Advances #797.

## Parent Feature spec: **#791** — control-panel observability child spec: logs (P10) (DDR 0203). Design ticket #760; slice-map fan-in **#770**; wayfinder map #7. Slice `transport-log-stream-sse` of `docs/slices/observability.yaml`; covers spec #791 stories 39–40. ## What to build **SSE is ruled in, scoped to logs.** One route: `EventSource`, one-directional, plain HTTP through the community door's `forward_auth`, auto-reconnecting, **no WebSocket upgrade machinery** — the client never sends up the socket, so re-scoping opens a new subscription rather than negotiating on an open one. Plus the **bounded log download** for the same scope. The `provisionClient.ts` "no SSE/WebSocket" line stays true of provisioning's *projection* reads: it was never a global rule, and logs are its inverse. No other dashboard read is converted to push by this slice. Both routes sit behind the community door, operators only (DDR 0172): `EventSource` rides the same community session cookie and the gateway's `forward_auth` covers the SSE route like any admin route. **An unauthenticated or non-operator caller is refused and no line is emitted.** No redaction tier is built — there is no public tier to redact for, and the secrets-never-enter-logs-by-construction rule is unchanged. ## Acceptance criteria - [ ] (story 39) Given the OpenAPI spec, then it carries the SSE stream route and the bounded log download; the download goes through the **generated client** (no hand-rolled fetch), and wire fields are snake_case camelised at the client boundary. - [ ] (story 37) Given an authenticated operator, when they open the stream route, then the response is a well-formed event stream and events are delivered. - [ ] (story 37) Given an **unauthenticated or non-operator** caller, then the stream route refuses exactly as every other admin route does and **no line is emitted**. - [ ] (story 37) Given the bounded download, then it sits behind the same community door and returns the bounded artifact for the requested scope. - [ ] (story 40) Given every other dashboard read, then it keeps its existing re-read cadence — no projection is converted to push by this slice. - [ ] (story 40) Given the hub, then this route adds **no new port and no new ingress surface**: one route through the existing front door. - [ ] (story 37) Given the operator-only posture, then **no redaction tier is built**. ## Blocked by - #806 — `observability:logstream-hub` - `bootstrap:control-plane-tracer` (#127 — done, satisfied) ## Task manifest ```yaml task: observability:transport-log-stream-sse interface: one SSE stream route (EventSource-shaped, one-directional, plain HTTP, auto-reconnecting) and one bounded log-download route, both on the existing OpenAPI spec behind the community door's `forward_auth` seam: 'transport integration tests (prior art `fleet_integration_test.go`, `authgate_test.go`): an authenticated operator receives a well-formed event stream; an unauthenticated caller is refused and **no line is emitted**; the bounded download returns the artifact for its scope; no new port or ingress is opened' acceptance: - given: an authenticated operator when: the stream route is opened then: a well-formed event stream is returned and lines are delivered - given: an unauthenticated caller when: the stream route is opened then: it is refused and no line is emitted - given: an authenticated operator when: the bounded download is requested for a scope then: the bounded artifact for that scope is returned - given: provisioning's projection reads when: the tree is inspected after this slice then: they still carry no SSE/WebSocket — SSE is scoped to logs depends_on: - logstream-hub - bootstrap:control-plane-tracer out_of_scope: - the browser-side `EventSource` construction, reconnect and guards (`dashboard-log-stream-source`) - converting any other dashboard read to push - a WebSocket upgrade path - a redaction tier or member-facing logs tier - log retention / history search beyond the hub's ring and the bounded operation logs needs_human_decision: [] ``` --- *Emitted by `/to-tickets` over `docs/slices/observability.yaml` in an unattended session under ADR 0174 (two-way-door posture — Ben's veto is asynchronous, never blocking). Advances #797.*
Author
Member

swarm-claim host=matou-dev-server-01 run=10067
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=matou-dev-server-01 run=10067 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #808 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 808,
  "status": "success",
  "commits": [
    "3250880e"
  ],
  "changed_files": [
    "STATUS.md",
    "dashboard/src/lib/api/generated.ts",
    "internal/controlapi/logstream.go",
    "internal/controlapi/logstream_integration_test.go",
    "packages/openapi-spec/openapi.yaml",
    "packages/openapi-spec/tests/unit/spec.test.ts"
  ],
  "tests": [
    {
      "command": "nix develop .#go-ci --command go build ./...",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command go vet ./internal/controlapi/ ./internal/logstream/",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command bash -c 'CGO_ENABLED=1 go test -race ./internal/controlapi/ ./internal/logstream/'",
      "exit_code": 0
    },
    {
      "command": "node packages/openapi-spec/scripts/generate-client.mjs --check",
      "exit_code": 0
    },
    {
      "command": "CI=true pnpm --filter @idss/openapi-spec run test",
      "exit_code": 0
    },
    {
      "command": "nix develop .#go-ci --command golangci-lint run ./internal/controlapi/...",
      "exit_code": 0
    }
  ],
  "criteria": {
    "story 39 — OpenAPI carries the SSE stream route and the bounded download; download via generated client, snake_case camelised": "packages/openapi-spec/openapi.yaml adds GET /logs/stream/{scope} (text/event-stream) and GET /logs/download/{scope} (application/json -> LogDownload); regenerated dashboard/src/lib/api/generated.ts emits getLogsDownload(scope): Promise<LogDownload> with snake_case fields seq/text/scope/lines/truncated (camelised at the client boundary per wire.ts); check:client exit 0; spec.test.ts asserts both routes",
    "story 37 — authenticated operator opens the stream route -> well-formed event stream, events delivered": "TestLogStream_AuthenticatedOperatorReceivesEventStream asserts 200, Content-Type text/event-stream, every seeded line delivered plus the terminal event: end (streamLogs in logstream.go)",
    "story 37 — unauthenticated or non-operator caller -> refused as every admin route, no line emitted": "TestLogStream_UnauthenticatedIsRefusedAndNoLineEmitted asserts 401, zero data lines, and the follow was never opened; operatorAuthed refuses before Follow via HeaderSessionResolver, the mail.go pattern (DDR 0172)",
    "story 37 — bounded download behind the same community door returns the bounded artifact for the requested scope": "TestLogDownload_ReturnsBoundedArtifactForScope asserts the LogDownload{scope,lines,truncated} for the scope; TestLogDownload_UnknownScopeIs404AndUnauthenticatedIs401 covers 404 + 401",
    "story 40 — every other dashboard read keeps its re-read cadence, no projection converted to push": "provisionClient.ts untouched (not in the commit diff); its 'no SSE/WebSocket' projection note stands; SSE scoped to logs only",
    "story 40 — no new port and no new ingress: one route through the existing front door": "TestLogStream_AddsNoNewPortJustRoutesOnTheExistingMux drives both /healthz and the stream route on one httptest server; the routes are added via WithLogStream onto the shared control-plane mux (registerLogStream)",
    "story 37 — operator-only posture, no redaction tier built": "logstream.go builds no redaction tier; the route gates on operator identity only (DDR 0172 ruling 5), documented in the package doc and the openapi comment"
  },
  "summary": "Shipped the observability logs transport: one SSE stream route and one bounded JSON log-download route on the control-plane OpenAPI spec + mux, behind the community door, refusing unauthenticated callers before any follow opens.",
  "reason": "",
  "blockers": []
}
**close-report** for #808 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 808, "status": "success", "commits": [ "3250880e" ], "changed_files": [ "STATUS.md", "dashboard/src/lib/api/generated.ts", "internal/controlapi/logstream.go", "internal/controlapi/logstream_integration_test.go", "packages/openapi-spec/openapi.yaml", "packages/openapi-spec/tests/unit/spec.test.ts" ], "tests": [ { "command": "nix develop .#go-ci --command go build ./...", "exit_code": 0 }, { "command": "nix develop .#go-ci --command go vet ./internal/controlapi/ ./internal/logstream/", "exit_code": 0 }, { "command": "nix develop .#go-ci --command bash -c 'CGO_ENABLED=1 go test -race ./internal/controlapi/ ./internal/logstream/'", "exit_code": 0 }, { "command": "node packages/openapi-spec/scripts/generate-client.mjs --check", "exit_code": 0 }, { "command": "CI=true pnpm --filter @idss/openapi-spec run test", "exit_code": 0 }, { "command": "nix develop .#go-ci --command golangci-lint run ./internal/controlapi/...", "exit_code": 0 } ], "criteria": { "story 39 — OpenAPI carries the SSE stream route and the bounded download; download via generated client, snake_case camelised": "packages/openapi-spec/openapi.yaml adds GET /logs/stream/{scope} (text/event-stream) and GET /logs/download/{scope} (application/json -> LogDownload); regenerated dashboard/src/lib/api/generated.ts emits getLogsDownload(scope): Promise<LogDownload> with snake_case fields seq/text/scope/lines/truncated (camelised at the client boundary per wire.ts); check:client exit 0; spec.test.ts asserts both routes", "story 37 — authenticated operator opens the stream route -> well-formed event stream, events delivered": "TestLogStream_AuthenticatedOperatorReceivesEventStream asserts 200, Content-Type text/event-stream, every seeded line delivered plus the terminal event: end (streamLogs in logstream.go)", "story 37 — unauthenticated or non-operator caller -> refused as every admin route, no line emitted": "TestLogStream_UnauthenticatedIsRefusedAndNoLineEmitted asserts 401, zero data lines, and the follow was never opened; operatorAuthed refuses before Follow via HeaderSessionResolver, the mail.go pattern (DDR 0172)", "story 37 — bounded download behind the same community door returns the bounded artifact for the requested scope": "TestLogDownload_ReturnsBoundedArtifactForScope asserts the LogDownload{scope,lines,truncated} for the scope; TestLogDownload_UnknownScopeIs404AndUnauthenticatedIs401 covers 404 + 401", "story 40 — every other dashboard read keeps its re-read cadence, no projection converted to push": "provisionClient.ts untouched (not in the commit diff); its 'no SSE/WebSocket' projection note stands; SSE scoped to logs only", "story 40 — no new port and no new ingress: one route through the existing front door": "TestLogStream_AddsNoNewPortJustRoutesOnTheExistingMux drives both /healthz and the stream route on one httptest server; the routes are added via WithLogStream onto the shared control-plane mux (registerLogStream)", "story 37 — operator-only posture, no redaction tier built": "logstream.go builds no redaction tier; the route gates on operator identity only (DDR 0172 ruling 5), documented in the package doc and the openapi comment" }, "summary": "Shipped the observability logs transport: one SSE stream route and one bounded JSON log-download route on the control-plane OpenAPI spec + mux, behind the community door, refusing unauthenticated callers before any follow opens.", "reason": "", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Matou/idss#808
No description provided.