feat(PR-04): SSE execution loop, 7-route server and session security

- replace src/server.rs with src/server/{mod,routes,security,sse}.rs implementing
  exactly the RFC-0002 §6.2 routes: GET /, GET /file, GET /assets, GET
  /api/documents, POST /api/runs, GET /api/runs/{id}/events, POST
  /api/runs/{id}/cancel; old /api/health, /api/document, /api/run and
  /api/clear-run are gone (404)
- SSE writes the event-stream directly to the socket and flushes every frame and
  heartbeat (tiny_http's chunked writer would delay frames); Last-Event-ID
  replay or authoritative snapshot, 128-event ring, terminal close, heartbeat
  comments, at most two observers per run, no polling route
- per-session HttpOnly SameSite=Strict cookie + X-View-CSRF, exact same-origin
  Origin, loopback Host, Sec-Fetch-Site cross-site rejection, JSON-only 64 KiB
  run POSTs; cancel is an authenticated bodyless control POST
- reader.js: Analysis-driven function form with text-only command preview,
  pure/project mode + explicit fs grants with second confirmation, one POST then
  EventSource, cancel, live result/stdout/stderr/Trace panel and keyed source
  anchors (skipped when stale); no innerHTML of CLI data and no status polling
- render: hidden live run shell, generic explicit-run dialog, function call
  buttons carrying Analysis function ids/params, data-analysis-digest/document
  attributes; remove the old run-confirm dialog and run-page reload path
- add tests/security/ suite, rewrite HTTP/SSE integration tests, update browser
  suite for EventSource/dark theme/RFC width matrix (incl. 2048x1133)
- ADR-0009 + docs/evidence/PR-04 with real Chromium log/screenshots and a real
  frozen-CLI SSE run (285 Trace v2 events, CLI SHA unchanged)
- unit 63 + contract 41 + integration 40 + security 11 pass; clippy clean
This commit is contained in:
cflmy committed 2026-11-22 14:30:40 +08:00
1 parent e13c1828a4
commit 046834bcb6
35 files changed
+3812 -1963

No files matched your search

+89
View File
@@ -1281,3 +1281,92 @@
}
}
}
@layer interactions {
.mq-fn-call {
margin-left: 10px;
padding: 2px 10px;
border: 1px solid var(--mq-gold);
border-radius: 999px;
background: transparent;
color: var(--mq-gold);
font: 12px/1.6 var(--mq-sans);
cursor: pointer;
}
.mq-fn-call:hover {
background: var(--mq-gold-soft);
color: var(--mq-strong);
}
.mq-run-target {
margin: 4px 0 12px;
font: 13px/1.6 var(--mq-sans);
color: var(--mq-muted);
}
.mq-run-status {
font: 13px/1.6 var(--mq-sans);
color: var(--mq-ink);
}
.mq-run-params {
display: grid;
gap: 10px;
margin: 12px 0;
}
.mq-run-param {
display: flex;
flex-direction: column;
gap: 4px;
font: 12px/1.5 var(--mq-sans);
color: var(--mq-muted);
}
.mq-run-param input {
padding: 7px 10px;
border: 1px solid var(--mq-line-strong);
border-radius: 8px;
background: var(--mq-paper);
color: var(--mq-ink);
font: 13px/1.5 var(--mq-mono);
}
.mq-run-mode {
margin: 12px 0;
padding: 10px 12px;
border: 1px solid var(--mq-line);
border-radius: 10px;
font: 12px/1.6 var(--mq-sans);
}
.mq-run-mode legend {
padding: 0 6px;
color: var(--mq-muted);
}
.mq-run-mode label {
display: block;
margin: 4px 0;
}
.mq-run-grants {
display: grid;
gap: 8px;
margin: 10px 0;
font: 12px/1.6 var(--mq-sans);
}
.mq-run-grants textarea {
width: 100%;
margin-top: 4px;
padding: 8px 10px;
border: 1px solid var(--mq-line-strong);
border-radius: 8px;
background: var(--mq-paper);
color: var(--mq-ink);
font: 12px/1.5 var(--mq-mono);
resize: vertical;
}
.mq-run-command {
margin: 8px 0 12px;
padding: 10px 12px;
overflow-x: auto;
border: 1px dashed var(--mq-line-strong);
border-radius: 8px;
background: var(--mq-surface-2);
font: 12px/1.6 var(--mq-mono);
white-space: pre-wrap;
overflow-wrap: anywhere;
}
}