feat(PR-02): DocumentModel, Analysis v2 projection, single renderer and Live browsing

- document.rs: comrak marqdo.md.v1 parse -> DocBlock/Inline with exact UTF-8 spans
- semantic.rs: typed Analysis v2 validation (schema/profile/root_id/source_digest,
  units/functions/statements/resources/imports/references/calls/diagnostics,
  per-span UTF-8 checks with explicit view.source_span_invalid warnings)
- presentation.rs: one PresentationModel/Outline with source status matrix
- render.rs: one ReaderRenderer; sanitized GFM, statement anchors, heading mode
  badges (display-only prefix strip), source pane, docs/Live|Static link policy,
  CSP meta, no inline scripts, no raw HTML execution
- server.rs: loopback-only Live reader with Host/DNS-rebinding checks, strict
  percent decoding, project path boundary, security headers, read-only APIs
- app.rs: AppContext degradation (core missing -> prose-only, check error ->
  diagnostics + revoked semantics, protocol mismatch -> hard error)
- assets: single reader.css/reader.js + embedded SHA-256 AssetBundle, copied
  legacy logo/blossom/feather with provenance
- examples + frozen-CLI Analysis goldens + rendering/HTTP/asset/no-coupling tests
- ADR-0003 heading prefix/anchor identity; docs updated
This commit is contained in:
marqdo-view dev committed 2026-11-22 11:19:11 +08:00
1 parent 8ba20a5c67
commit 80ce564f09
47 files changed
+26127 -203

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
# Protocol goldens
These Analysis v2 files were emitted by the **frozen** `marqdo` CLI release
binary, not hand-written:
| Binary | SHA-256 |
|---|---|
| `marqdo 3.0.0-beta.1` | `062cb56e226bee55c21d238e195920caa985e62bb3877ba7b07abcc04dc0fe3f` |
| CLI source SHA | `2c7c4f31e7a388d3fcfa717a77067e696ed13854` |
Command shape used for every golden:
```bash
"$MARQDO_BIN" check <example> --emit tests/golden/analysis-v2/<name>.json
```
| Golden | Input |
|---|---|
| `mixed-modes.json` | `examples/mixed-modes/index.mq.md` |
| `control-flow.json` | `examples/control-flow/index.mq.md` |
| `tables-math.json` | `examples/tables-math/index.mq.md` |
| `welcome.json` | `examples/welcome/00-welcome.mq.md` |
`tools/gen-golden.sh` regenerates them from a frozen binary. If an example's
bytes change, its `source_digest` changes too and the tests will fail until the
golden is regenerated — that is intentional evidence, not a test bug.
`examples/diagnostics/index.mq.md` is deliberately invalid and has **no**
golden; its failure path is covered with `check --json` output.
File diff suppressed because it is too large. Load diff
+278
View File
@@ -0,0 +1,278 @@
{
"diagnostics": [],
"modules": [
{
"calls": [],
"functions": [
{
"body": [
{
"arms": [
{
"body": [
{
"kind": "assign",
"span": {
"end": 422,
"start": 406
},
"target": "result",
"value": {
"kind": "binary",
"left": {
"kind": "variable",
"name": "n",
"span": {
"end": 417,
"start": 416
}
},
"op": "mul",
"right": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "int",
"value": "2"
},
"span": {
"end": 421,
"start": 416
}
}
},
{
"kind": "return",
"span": {
"end": 439,
"start": 424
},
"value": {
"kind": "variable",
"name": "result",
"span": {
"end": 438,
"start": 432
}
}
}
],
"condition": {
"kind": "binary",
"left": {
"kind": "variable",
"name": "n",
"span": {
"end": 398,
"start": 397
}
},
"op": "gt",
"right": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "int",
"value": "0"
},
"span": {
"end": 402,
"start": 397
}
},
"condition_span": {
"end": 404,
"start": 392
},
"span": {
"end": 404,
"start": 392
}
},
{
"body": [
{
"kind": "return",
"span": {
"end": 461,
"start": 451
},
"value": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "int",
"value": "0"
}
}
],
"condition": {
"kind": "literal",
"span": {
"end": 0,
"start": 0
},
"type": "bool",
"value": true
},
"condition_span": {
"end": 404,
"start": 392
},
"span": {
"end": 404,
"start": 392
}
}
],
"kind": "branch",
"span": {
"end": 404,
"start": 392
}
}
],
"effects": [
"unknown"
],
"heading_span": {
"end": 259,
"start": 246
},
"id": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
"local_name": "main",
"namespace": "演示",
"signature": {
"kind": "explicit",
"params": [
{
"default": null,
"name": "n",
"required": true,
"span": {
"end": 274,
"start": 268
},
"type": "Int"
}
]
},
"span": {
"end": 470,
"start": 246
},
"unit_id": "root:mixed-modes@0.1.0::index.mq.md#演示/main"
}
],
"id": "root:mixed-modes@0.1.0::index.mq.md",
"imports": [],
"package_instance_id": "root:mixed-modes@0.1.0",
"references": [],
"relative_path": "index.mq.md",
"resources": [],
"source_digest": "c5fed57a716e06a29b669c334d475ec03bf08442e27983451ec8dd791dc999ea",
"units": [
{
"function": null,
"id": "root:mixed-modes@0.1.0::index.mq.md#",
"kind": "root",
"level": 0,
"name": "",
"span": {
"end": 470,
"start": 0
}
},
{
"function": null,
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记",
"kind": "namespace",
"level": 1,
"name": "计算笔记",
"span": {
"end": 25,
"start": 0
}
},
{
"function": null,
"id": "root:mixed-modes@0.1.0::index.mq.md#计算笔记/算法说明",
"kind": "knowledge",
"level": 2,
"name": "算法说明",
"span": {
"end": 149,
"start": 123
}
},
{
"function": null,
"id": "root:mixed-modes@0.1.0::index.mq.md#演示",
"kind": "namespace",
"level": 1,
"name": "演示",
"span": {
"end": 244,
"start": 230
}
},
{
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main",
"kind": "function",
"level": 2,
"name": "main",
"span": {
"end": 259,
"start": 246
}
},
{
"function": null,
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/用法",
"kind": "section",
"level": 3,
"name": "用法",
"span": {
"end": 300,
"start": 279
}
},
{
"function": "root:mixed-modes@0.1.0::index.mq.md::演示.main",
"id": "root:mixed-modes@0.1.0::index.mq.md#演示/main/计算",
"kind": "section",
"level": 3,
"name": "计算",
"span": {
"end": 390,
"start": 374
}
}
]
}
],
"producer": {
"markdown_profile": "marqdo.md.v1",
"name": "marqdo",
"version": "3.0.0-beta.1"
},
"project": {
"identity_kind": "manifest",
"lock_digest": "",
"root_id": "root:mixed-modes@0.1.0",
"stdlib": {
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"version": "0.1.0"
}
},
"schema": "marqdo.analysis",
"schema_version": 2
}
+108
View File
@@ -0,0 +1,108 @@
{
"diagnostics": [],
"modules": [
{
"calls": [],
"functions": [],
"id": "root:tables-math@0.1.0::index.mq.md",
"imports": [],
"package_instance_id": "root:tables-math@0.1.0",
"references": [
{
"source": "root:tables-math@0.1.0::index.mq.md",
"span": {
"end": 403,
"start": 354
},
"state": "external",
"target_module": null,
"target_unit": null,
"url": "https://github.com/cflmy/marqdo-cli"
}
],
"relative_path": "index.mq.md",
"resources": [
{
"content_digest": "2820951a377c18ce3e89093ca7c31c204b1196a7e571781c6080f8207524a8dc",
"display": false,
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-1",
"kind": "formula",
"language": null,
"module_id": "root:tables-math@0.1.0::index.mq.md",
"span": {
"end": 164,
"start": 154
},
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
},
{
"content_digest": "8b1e8a7ed159e8223af79e768681907870ae7143f0b16001091377f9ff018db2",
"display": true,
"id": "root:tables-math@0.1.0::index.mq.md#resource:formula-2",
"kind": "formula",
"language": null,
"module_id": "root:tables-math@0.1.0::index.mq.md",
"span": {
"end": 222,
"start": 181
},
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
},
{
"content_digest": "a0d49e456637468d7f594f4e2bb513321875855c1fe85d28e0ca62f1e9180d15",
"id": "root:tables-math@0.1.0::index.mq.md#resource:code-1",
"kind": "code",
"language": "python",
"module_id": "root:tables-math@0.1.0::index.mq.md",
"span": {
"end": 280,
"start": 224
},
"unit_id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源"
}
],
"source_digest": "66ce180252d201ff0f3f831d47f7a58d7f6804cb9655898cc80ef6d2262f1ce6",
"units": [
{
"function": null,
"id": "root:tables-math@0.1.0::index.mq.md#",
"kind": "root",
"level": 0,
"name": "",
"span": {
"end": 406,
"start": 0
}
},
{
"function": null,
"id": "root:tables-math@0.1.0::index.mq.md#表格、公式与惰性资源",
"kind": "namespace",
"level": 1,
"name": "表格、公式与惰性资源",
"span": {
"end": 43,
"start": 0
}
}
]
}
],
"producer": {
"markdown_profile": "marqdo.md.v1",
"name": "marqdo",
"version": "3.0.0-beta.1"
},
"project": {
"identity_kind": "manifest",
"lock_digest": "",
"root_id": "root:tables-math@0.1.0",
"stdlib": {
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"version": "0.1.0"
}
},
"schema": "marqdo.analysis",
"schema_version": 2
}
+69
View File
@@ -0,0 +1,69 @@
{
"diagnostics": [],
"modules": [
{
"calls": [],
"functions": [],
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md",
"imports": [],
"package_instance_id": "root:welcome-demo@0.1.0",
"references": [
{
"source": "root:welcome-demo@0.1.0::00-welcome.mq.md",
"span": {
"end": 536,
"start": 507
},
"state": "resolved",
"target_module": "root:welcome-demo@0.1.0::guide.mq.md",
"target_unit": null,
"url": "./guide.mq.md"
}
],
"relative_path": "00-welcome.mq.md",
"resources": [],
"source_digest": "879215bf0dc432b78924800a08eac37d353a9694652c5542294f4ce7fe6da173",
"units": [
{
"function": null,
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#",
"kind": "root",
"level": 0,
"name": "",
"span": {
"end": 659,
"start": 0
}
},
{
"function": null,
"id": "root:welcome-demo@0.1.0::00-welcome.mq.md#欢迎来到 Marqdo",
"kind": "namespace",
"level": 1,
"name": "欢迎来到 Marqdo",
"span": {
"end": 32,
"start": 0
}
}
]
}
],
"producer": {
"markdown_profile": "marqdo.md.v1",
"name": "marqdo",
"version": "3.0.0-beta.1"
},
"project": {
"identity_kind": "manifest",
"lock_digest": "",
"root_id": "root:welcome-demo@0.1.0",
"stdlib": {
"digest": "sha256:5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"instance_id": "std:marqdo-stdlib@0.1.0#5407d3665ba2fe105820d0f1af5efaafa10c277a69eb819c3225719813c8c713",
"version": "0.1.0"
}
},
"schema": "marqdo.analysis",
"schema_version": 2
}