Commit d951e5e
The /live token rode in URLs, the page was blind while the planner thought, and a finished run could not be watched (#89)
Three defects in the same file, fixed together because they share it.
The token was accepted in the query string on every `/live` route, and a URL
outlives the request: the uvicorn request line, the nginx access log, browser
history, the referrer of anything the page opens. The index wrote the token
into every link it rendered, so clicking a trace filed the secret a second
time. `?token=` now reaches `/live/api/stream` alone — a browser `EventSource`
cannot set a header, so that route has no alternative — and every other route
refuses it with a 401 that says where to put the token instead. A browser gets
a sign-in page rather than a bare 401 and trades the token for a cookie: a
digest of it, `HttpOnly`, `SameSite=Strict`, scoped to `/live`, and ASCII, so a
non-ASCII secret works where a latin-1 header could not carry it. The residual
exposure — the SSE request line — is named in the cookbook beside
`--live-token`, with what to scrub.
The page rendered nothing for the whole planning phase, because it keys the
graph off the `topology` event that only lands once a round is admitted and
materialised — while `plan`, `admission` and `round` events were already on
disk, thousands of tokens in. A run refused on every round has no topology at
all and showed nothing from start to "finished". The snapshot now carries a
`planning` block folded from those same events — no new trace events — and the
page renders it: per round the proposal size, admission status, failed checks
and rejection codes, planner tokens, and the loop's stop reason when it stopped
without a graph. An open planning round also reads as active, since a planner
mid-inference writes nothing for a minute at a time.
A finished trace rendered instantly all-green, which makes the amber `running`
styling unreachable for every run that is already over. `?replay=1` walks the
recorded events in timestamp order and emits the snapshots the run would have
sent, `&speed=N` divides the wall clock, and the whole replay is capped at 40
seconds so a long incident trace stays watchable. Frames come from the same
snapshot code a live stream uses, pointed at a prefix of the file, and consult
no clock — a trace replayed twice renders identically. With no parameter,
nothing about the stream changed.
The reader's confinement is untouched: `../`, `%2e%2e%2f`, absolute paths, NUL
bytes and symlinked traces are the same 404s, and a hostile token is still a
401 rather than a crash.
Fixes #41
Fixes #47
Fixes #48
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>1 parent 62a1832 commit d951e5e
5 files changed
Lines changed: 897 additions & 39 deletions
File tree
- docs/cookbook
- grapharc/server
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1322 | 1322 | | |
1323 | 1323 | | |
1324 | 1324 | | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
1325 | 1342 | | |
1326 | 1343 | | |
1327 | 1344 | | |
| |||
1338 | 1355 | | |
1339 | 1356 | | |
1340 | 1357 | | |
1341 | | - | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
1342 | 1378 | | |
1343 | 1379 | | |
1344 | 1380 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
186 | 188 | | |
187 | 189 | | |
188 | 190 | | |
| |||
0 commit comments