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
@@ -22,11 +22,11 @@ Marqdo View(`0.2.0`)是一个独立的可执行文档阅读器:以**原始
|
||||
|---|---|
|
||||
| 原始 Markdown + GFM 阅读、源码态、文档态 | ✅ |
|
||||
| Analysis v2 静态语义(函数/Unit/签名/诊断/导入/引用/资源) | ✅ 严格校验,span 无效则降级 |
|
||||
| 本机 Live 阅读(默认 `127.0.0.1`,只读 API) | ✅ |
|
||||
| 用户确认后运行 + 真实 Trace v2 可视化(`pure` 模式) | ✅(0001 同步模型;0002 的 SSE 异步闭环开发中) |
|
||||
| 本机 Live 阅读(默认 `127.0.0.1`,只读 API + 显式执行端点) | ✅ |
|
||||
| 显式确认后运行 + SSE 状态/取消 + 真实 Trace v2 | ✅ 单任务、无轮询、断线重放 |
|
||||
| 纯只读静态导出(离线 `file://`、manifest/哈希、原子发布) | ✅ |
|
||||
| 单函数参数表单 + 受控 `project` fs grants | 🚧 RFC-VIEW-0002 PR-03/04 |
|
||||
| SSE 状态推送 / 取消 / 断线重放(禁止轮询) | 🚧 RFC-VIEW-0002 PR-04(MVP 阻塞项) |
|
||||
| 单函数参数表单 + 受控 `project` fs grants | ✅ 参数来自 Analysis 签名;project 需显式 glob 二次确认 |
|
||||
| SSE 状态推送 / 取消 / 断线重放(禁止轮询) | ✅ `POST /api/runs` + `GET …/events` + `POST …/cancel` |
|
||||
| 逐语句变量值 / 参数值 / 内存快照 | ❌ UNSUPPORTED(协议不提供,绝不伪造) |
|
||||
| 知识“已证明” / Prove / Lint / 调试器 | ❌ 非目标/等待独立协议 |
|
||||
|
||||
@@ -62,9 +62,11 @@ marqdo view export examples/welcome --out ./site
|
||||
marqdo view export examples/mixed-modes --out ./site --no-annotations
|
||||
```
|
||||
|
||||
开发期可直接运行 `marqdo-view`(用 `--marqdo-bin` 指定冻结核心)。运行入口在 Live
|
||||
页面中:点击“运行”→ 阅读风险说明 → 点击“确认运行”,才会调用冻结核心执行
|
||||
`--mode pure`;页面刷新/打开/搜索/导出都不会运行。
|
||||
开发期可直接运行 `marqdo-view`(用 `--marqdo-bin` 指定冻结核心)。运行只有一个入口:
|
||||
Live 页面点击 Dock “运行”(执行 `main`)或函数面板的“调用”(执行 `call`),
|
||||
阅读命令预览与权限说明后点击“确认执行”,服务端才 `POST /api/runs` 启动一个
|
||||
CLI 子进程;状态与结果通过 SSE 推送,可取消,断线可重放。页面刷新/打开/搜索/
|
||||
切换/导出都不会运行,也没有状态轮询。
|
||||
|
||||
## 架构(强制约束)
|
||||
|
||||
@@ -75,21 +77,25 @@ Reader UI(唯一 assets/reader.css + assets/reader.js)
|
||||
│
|
||||
ReaderRenderer(唯一模板,Live/Export 共用)
|
||||
│
|
||||
PresentationModel(DocumentModel / SemanticProjection / RunProjection)
|
||||
PresentationModel(reader::assemble / reader::model)
|
||||
│
|
||||
PublicCoreClient ─ MARQDO_BIN 子进程 + 公开 JSON(check --emit / run --trace-file)
|
||||
CoreClient ─ MARQDO_BIN 子进程 + 公开 JSON(check --emit / run/call --trace-file)
|
||||
│
|
||||
ExecutionController ─ 单任务、取消、SSE 事件(仅 POST /api/runs 可达)
|
||||
│
|
||||
冻结发布版 marqdo CLI(不修改、不重编译、不链接、不读源码)
|
||||
```
|
||||
|
||||
- 单一 Rust package、单一渲染入口、单一主题文件;没有第二个 Markdown→语义管线。
|
||||
- 服务端只有 7 条固定路由;SSE 只推送 View 自有 `run.*` 生命周期事件。
|
||||
- Analysis v2 是唯一语义权威:函数/语句/分支/循环/诊断均来自 `check --emit`,
|
||||
源码字节 span 只用于绑定视觉位置。
|
||||
- Trace v2 与 Analysis 字节摘要严格绑定;`STALE/TRUNCATED/FAILED/UNSUPPORTED`
|
||||
状态显式呈现,不猜测未公开值。
|
||||
- Live/Export 内容同源;导出绝不执行、绝不覆盖项目源文件或无关目录。
|
||||
- 门禁:`tests/contract/no_coupling.rs` 拒绝旧 crate/源码依赖、第二套渲染器/主题、shell 执行;
|
||||
`tests/contract/asset_integrity.rs` 锁定内嵌资产与唯一主题层。
|
||||
`tests/contract/asset_integrity.rs` 锁定内嵌资产与唯一主题层;
|
||||
`tests/security/` 覆盖 CSRF/Origin/Cookie/路径/symlink/XSS/跨会话 SSE。
|
||||
|
||||
## 开发与验收
|
||||
|
||||
@@ -122,15 +128,11 @@ MARQDO_BIN=... ./scripts/test-browser.sh # 真实 Chromium 视觉/交互/响
|
||||
|
||||
## 已知限制(诚实状态)
|
||||
|
||||
- 首版运行只支持 `--mode pure`;`project`/`strict` 及 grants 授权界面未实现。
|
||||
- 运行完成后整页重载并保留阅读位置;无 SSE 流式输出/取消/多运行历史。
|
||||
- 变量实际值、参数值、内存快照、知识证明状态不在 Trace v2 中,UI 一律标 UNSUPPORTED。
|
||||
- 平台仅 Linux x86_64 glibc 正式验证;macOS/Windows 未验证。
|
||||
- 视觉自动化门禁 PASS,但参考截图的像素级人工比对仍未执行(`U-01 UNVERIFIED`);
|
||||
SVG 曲线侧注未实现,运行事件以可访问的内联 chip 呈现(`U-04 PARTIAL`)。
|
||||
- 远端正 CI 未实际运行;`.woodpecker.yml` 已提供,本地验收证据完整。
|
||||
|
||||
## 许可
|
||||
|
||||
代码按 MIT / Apache-2.0 双许可发布(`LICENSE-MIT`、`LICENSE-APACHE`)。复用的旧
|
||||
View 视觉资产(Apache-2.0)来源与哈希见 `assets/licenses/ASSETS.md`。
|
||||
- 运行仅 `pure`(默认)与受控 `project` fs read/write;`strict`、网络/进程/环境/
|
||||
plugin/provider/kernel 授权不在首版 UI,必须使用终端 CLI。
|
||||
- `project` 不是 OS 沙箱;View 不继承 `marqdo.yaml` 的 capability 请求。
|
||||
- SSE 只推送 View 生命周期与终态数据,不承诺逐字 stdout/Token 流;Trace v2 不含
|
||||
参数实际值/逐语句变量/内存快照。
|
||||
- 平台:仅 Linux x86_64 正式验证;Windows/macOS 不支持声明。
|
||||
- 像素级人工视觉比对与完整 screen-reader 走查为 `UNVERIFIED`(自动化几何/响应式/
|
||||
无外部资源/无 JS/打印证据见 `docs/evidence/PR-04/`)。
|
||||
Reference in new issue
Block a user