SSE Streaming & Cancellation
SQL Persistence & Ownership
Jump & context
Week 2: Prompt Injection, Crescendo Fuzzing, Streaming, Persistence & Cost Controls
The five hours
- 01
Concepts & system design
60 min· read · map the mechanismR08 — MDN Server-Sent Events lifecycle
R01 — FastAPI streaming
R09 — PostgreSQL constraints, indexes & transactions
R03 — OWASP API BOLA
Read the assigned sections; map the mechanism, threat model and trade-offs.
- 02
Project implementation
120 min· build · integrate · debugImplement Server-Sent Events (SSE) streaming and
/reset. *Lab:* Verify that a disconnected client cancels in-flight model generation and tool execution rather than leaking compute. (Optional UI hook: connect minimal React streaming view with safe Markdown).Implement SQL schema, ownership foreign keys, indexes, and migrations for conversation history. *Lab:* Run IDOR/BOLA tests across read, update, and delete operations on persisted conversations.
Build, integrate, debug and improve the increment in the active project.
- 03
Security lab
60 min· attack your own systemNo separate task text for this block on day 11 — the sourced work sits in the block above. Keep the time box.
Test the abuse case, failure path, authorization bypass or resource limit.
- 04
Verification & evidence
30 min· test · record evidenceClient-disconnect cancellation test + SQL tenant/owner isolation test suite.
Add or run regression tests; record the 9-point evidence record.
- 05
Deliberate practice & Socratic review
30 min· explain aloud · update gapsAnswer the 8 Socratic questions without notes: What? Why? How? What if? Why not? How can I prove it? Where can it break? What have I learned?
Re-explain the hardest concept aloud, inspect one edge case, update the gap log.
- total5 h
Read today · inside the concepts block
R01 R03 R08 R09FastAPI tutorial, request bodies, dependencies, async, and Pydantic model validation.
BOLA (API1), Broken Auth (API2), Unrestricted Resource Consumption (API4), SSRF (API7), Misconfiguration (API8).
EventSource interface, event stream wire format, connection lifecycle, cancellation, and reconnection.
Foreign-key constraints, indexes, ACID transactions, row-level security (RLS), and query planning.
Read only the named sections needed for today's task. Reading sits inside the 60-minute concepts block; it is not extra time.
Free resources for this day
5 curated- docsMDN Web DocsServer-sent events - Web APIs | MDN
Defines the event-stream wire format, EventSource lifecycle, and reconnect behaviour, which is what you implement for token streaming and what fires when a client disconnects mid-generation.
R08checked 2026-11-11 - videoHussein Nasser · 29:48Server-Sent Events Crash Course
Explains the one-way stream over a single HTTP response, keep-alive comments, and connection lifecycle, which is the basis for detecting a dropped client and cancelling work.
R08M5checked 2026-11-11 - videoMicrosoft Developer · 18:19Everything you need to know about Postgres Row Level Security | POSETTE 2024
Shows policies keyed to the current principal so a query for conversation rows physically cannot return another owner's rows, the database backstop behind your BOLA tests.
R09checked 2026-11-11 - articlegermano.devServer-Sent Events: the alternative to WebSockets you should be using
Explains why SSE survives proxies and reconnects automatically, and where the single-direction limit applies, which decides whether streaming tokens needs WebSockets at all.
R08checked 2026-11-11 - repoGitHubsysid/sse-starlette
EventSourceResponse implementation with ping keep-alives and client-disconnect signalling, which is how a disconnected browser aborts the in-flight model call instead of leaking compute.
R08M5checked 2026-11-11
Evidence record · 9-point standard
A lab is complete only when it produces evidence. Installing PyRIT, Garak, Presidio or TransformerLens is not completion. Saved on this device only.
Day notes
emptyThe two source formulations
verbatim · nothing summarisedProject & Stage Target
P1 | S0, M5
Focus 1 (SSE Streaming & Cancellation — Orig. Day 13)
Implement Server-Sent Events (SSE) streaming and /reset. *Lab:* Verify that a disconnected client cancels in-flight model generation and tool execution rather than leaking compute. (Optional UI hook: connect minimal React streaming view with safe Markdown).
Focus 2 (SQL Persistence & Ownership — Orig. Day 14)
Implement SQL schema, ownership foreign keys, indexes, and migrations for conversation history. *Lab:* Run IDOR/BOLA tests across read, update, and delete operations on persisted conversations.
Verification & Evidence
Client-disconnect cancellation test + SQL tenant/owner isolation test suite.
Read Today (60m Concepts Block)
R08 (MDN Server-Sent Events lifecycle), R01 (FastAPI streaming), R09 (PostgreSQL constraints, indexes & transactions), R03 (OWASP API BOLA).
---