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:
1 parent
e13c1828a4
commit
046834bcb6
35 files changed
+3812
-1963
No files matched your search
@@ -123,6 +123,19 @@ pub enum OutlineKind {
|
||||
}
|
||||
|
||||
impl PresentationModel {
|
||||
/// True when the entry module exposes a resolvable `main` (canonical or
|
||||
/// unique local name). The dock Run button never substitutes another
|
||||
/// function for a missing entry function (RFC-VIEW-0002 §2.4).
|
||||
pub fn has_entry_main(&self) -> bool {
|
||||
let Some(semantic) = self.semantic.as_ref() else {
|
||||
return false;
|
||||
};
|
||||
semantic.functions.iter().any(|function| {
|
||||
let canonical = canonical_function_name(&function.id, &semantic.module_id);
|
||||
canonical == "main" || function.local_name == "main"
|
||||
})
|
||||
}
|
||||
|
||||
pub fn run_state(&self) -> RunDisplayState {
|
||||
match &self.run {
|
||||
Some(run) => run.state,
|
||||
@@ -165,6 +178,14 @@ pub fn anchor_for_span(start: u64, end: u64) -> String {
|
||||
format!("mq-h-{start:x}-{end:x}")
|
||||
}
|
||||
|
||||
/// Analysis v2 function ids are `<module id>::<canonical name>`.
|
||||
fn canonical_function_name(function_id: &str, module_id: &str) -> String {
|
||||
function_id
|
||||
.strip_prefix(&format!("{module_id}::"))
|
||||
.unwrap_or(function_id)
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in new issue
Block a user