dsh-vision-router 2.3.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. package/README.md +18 -3
  2. package/README.zh.md +16 -3
  3. package/docs/architecture/3.0-architecture-plan.md +252 -0
  4. package/docs/architecture/3.0-r0-contract-ledger.md +137 -0
  5. package/docs/architecture/3.0-r1-source-artifact-boundary.md +98 -0
  6. package/docs/architecture/3.0-r10-final-correctness-closure.md +207 -0
  7. package/docs/architecture/3.0-r11-adversarial-review.md +447 -0
  8. package/docs/architecture/3.0-r5-browser-go-no-go.md +165 -0
  9. package/docs/architecture/3.0-r5-browser-typescript-gate.md +105 -0
  10. package/docs/architecture/3.0-r6-compat-retirement.md +203 -0
  11. package/docs/architecture/3.0-r7-public-api.md +151 -0
  12. package/docs/architecture/3.0-r8-ci-release.md +248 -0
  13. package/docs/architecture/3.0-r9-final-audit.md +370 -0
  14. package/docs/architecture/dsh-support-window.md +13 -3
  15. package/docs/releases/v3.0.0.md +85 -0
  16. package/docs/releases/v3.0.1.md +77 -0
  17. package/entry.js +1 -1
  18. package/index.js +110 -71
  19. package/lib/agent-request-route-authority.js +1 -20
  20. package/lib/core-apply-lifecycle.js +37 -43
  21. package/lib/core-cache.js +87 -0
  22. package/lib/core-primitives.js +11 -144
  23. package/lib/core-vision-surface-domain.js +63 -0
  24. package/lib/core-vision-surface.js +11 -77
  25. package/lib/delegated-call-config.js +15 -24
  26. package/lib/doctor-cli.js +0 -0
  27. package/lib/doctor-runtime.js +4 -1
  28. package/lib/dsh-contract-compat.js +26 -230
  29. package/lib/dsh-host-capabilities.js +3 -9
  30. package/lib/dsh-settings-017-compat.js +17 -10
  31. package/lib/file-logger.js +8 -3
  32. package/lib/grounding-coordinate-runtime.js +1 -2
  33. package/lib/http-body-limit.js +97 -79
  34. package/lib/image-offload-compat.js +30 -21
  35. package/lib/image-resource-governor.js +210 -228
  36. package/lib/legacy-global-proxy-boundary.js +46 -3
  37. package/lib/live-model-client-prelude.js +12 -4
  38. package/lib/live-model-discovery.js +134 -43
  39. package/lib/local-vision-stabilizer.js +33 -18
  40. package/lib/maintenance-routes.js +1 -3
  41. package/lib/native-image-coexistence.js +15 -3
  42. package/lib/ollama-cold-start.js +87 -23
  43. package/lib/pi-ai-bridge-wire-compat.js +3 -2
  44. package/lib/proxy-dispatcher-pool.js +151 -92
  45. package/lib/proxy-routing.js +75 -51
  46. package/lib/proxy-url-compat.js +3 -10
  47. package/lib/public-config.js +23 -44
  48. package/lib/public-entry.d.ts +148 -0
  49. package/lib/public-entry.js +17 -4
  50. package/lib/replay-delegation.js +12 -7
  51. package/lib/replay-envelope-v2-compat.js +12 -7
  52. package/lib/runtime-composition.js +30 -10
  53. package/lib/screenshot-source-boundary.js +2 -2
  54. package/lib/session-affinity-runtime.js +113 -97
  55. package/lib/session-affinity.js +89 -76
  56. package/lib/session-event-history-compat.js +30 -0
  57. package/lib/session-query-readers.js +263 -0
  58. package/lib/session-surface-compat.js +30 -31
  59. package/lib/session-surface-policy-domain.js +85 -0
  60. package/lib/session-surface-policy.js +2 -111
  61. package/lib/session-turn-resolver.js +2 -6
  62. package/lib/session-vision-attachment-index.js +143 -0
  63. package/lib/session-vision-delegation-boundary.js +34 -0
  64. package/lib/session-vision-delegation.js +22 -0
  65. package/lib/session-vision-index.js +25 -107
  66. package/lib/session-vision-mode-authority.js +229 -192
  67. package/lib/session-vision-mode-boundary.js +65 -22
  68. package/lib/session-vision-policy-domain.js +304 -0
  69. package/lib/session-vision-policy.js +104 -0
  70. package/lib/session-vision-state.js +368 -378
  71. package/lib/settings-client-017-compat.js +16 -10
  72. package/lib/structured-flow-hardening.js +22 -4
  73. package/lib/tesseract-exec-compat.js +9 -1
  74. package/lib/turn-budget-context.js +47 -41
  75. package/lib/update-check.js +11 -2
  76. package/lib/vision-attachment-handle-runtime.js +176 -156
  77. package/lib/vision-backend-runtime-policy.js +16 -0
  78. package/lib/vision-background-benchmark.js +55 -6
  79. package/lib/vision-background-failure-policy.js +41 -41
  80. package/lib/vision-background-stop-store-core.js +217 -0
  81. package/lib/vision-background-stop-store.js +8 -179
  82. package/lib/vision-capability-benchmark.js +11 -61
  83. package/lib/vision-capability-evidence.js +35 -0
  84. package/lib/vision-capability-fingerprint.js +72 -0
  85. package/lib/vision-capability-identity.js +116 -61
  86. package/lib/vision-capability-router.js +13 -33
  87. package/lib/vision-chunk-assembler.js +95 -0
  88. package/lib/vision-diagnostics-routes.js +42 -4
  89. package/lib/vision-execution-order-apply.js +45 -55
  90. package/lib/vision-execution-order.js +19 -19
  91. package/lib/vision-execution-policy.js +12 -7
  92. package/lib/vision-model-registry.js +30 -17
  93. package/lib/vision-model-visibility-boundary-main.js +15 -16
  94. package/lib/vision-provider-transport.js +137 -147
  95. package/lib/vision-routing-authority.js +47 -48
  96. package/lib/vision-routing-product.js +26 -29
  97. package/lib/vision-routing-settings-prelude.js +8 -3
  98. package/lib/vision-runtime-performance-store.js +166 -0
  99. package/lib/vision-runtime-performance.js +13 -142
  100. package/lib/vision-tool-runtime-boundary.js +99 -30
  101. package/lib/web/dsh-settings-017-root-transport.js +27 -12
  102. package/lib/web/remote-settings-client.js +4 -7
  103. package/lib/web-capability-boundary.js +17 -7
  104. package/lib/wrapper-directory.js +14 -23
  105. package/package.json +37 -11
package/README.md CHANGED
@@ -42,9 +42,15 @@
42
42
  > **Data leaves your machine by default.** When a cloud vision model is used, Vision Router sends the image (or a derived crop), the vision prompt and related request metadata to that provider. A fresh install has an anonymous OVHcloud vision fallback enabled, so "free" and "no key" do **not** mean offline. Do not use the cloud chain for confidential, regulated or classified material. See [Data flow and strict local-only use](#data-flow-and-strict-local-only-use).
43
43
 
44
44
  > [!WARNING]
45
- > 📌 **Announcement (v2.3.0)**
45
+ > 📌 **Announcement (v3.0.1)**
46
46
  >
47
- > **v2.3.0:** Architecture hardening and compatibility convergence. The supported DSH 0.1.x window now starts at `0.1.5-rc.1`, while the 0.2.x train starts at verified `0.2.0-rc.2`; composition, Session repair, Settings/browser ownership and Desktop lifecycle contracts are hardened, and only proven-unreachable pre-floor shims are retired. [What’s new →](docs/releases/v2.3.0.md)
47
+ > **v3.0.1: five corrective fixes on the 3.0 line.** The Vision Router settings surface
48
+ > reads and writes real values on the Desktop shell, the model picker no longer groups the
49
+ > same model twice, and every provider leg that can reach a remote provider — background
50
+ > profiling, the local vision stabilizer, the settings "test connection" probe and the
51
+ > LM Studio native transport — now follows the same `proxy` / `proxyHosts` decision as
52
+ > foreground vision turns. Supported Hosts are unchanged: DSH 0.1.x from `0.1.5-rc.1`,
53
+ > DSH 0.2.x from verified `0.2.0-rc.2`. [What’s new →](docs/releases/v3.0.1.md)
48
54
 
49
55
  <p align="center">
50
56
  <img src="assets/vision-demo.gif" width="640" alt="Demo: paste an image, the agent locates the send button with vision_ground / vision_crop / vision_pixel_diff and answers with coordinates" />
@@ -151,6 +157,15 @@ For normal npm/npx installs, installation is a single command:
151
157
  npx @deepseek-ai/dsh plugin --profile web add dsh-vision-router
152
158
  ```
153
159
 
160
+ > [!IMPORTANT]
161
+ > **Which profile?** Install into an **existing profile that already serves the Web UI**:
162
+ >
163
+ > - Web DSH: `--profile web` (default data directory `~/.dsh`);
164
+ > - the official DeepSeek Harness desktop app: `--profile desktop` (same `~/.dsh` data directory; reload the plugin or restart the app afterwards);
165
+ > - Oh-DSH Desktop: its data directory is `~/.ohdsh`, see [Oh-DSH Desktop](#oh-dsh-desktop) below.
166
+ >
167
+ > `dsh plugin add` only adds the plugin to the profile you name. A **brand-new** profile contains just `@deepseek-ai/dsh-base`, and `dsh web` never binds a port in that state (no Web surface). Install into an existing profile, or give the new profile a Web surface first.
168
+
154
169
  > [!WARNING]
155
170
  > If this profile already loads community plugins manually through `cordis.patch.yml`, do **not** mix that legacy setup with `dsh plugin add` / `dsh plugin list`: current DSH CLI behavior can also append bundle-patch dependencies to `dsh.profile.bundles`, causing those plugins to register twice. Migrate the existing manual plugin rows to bundle-managed loading first, or keep using the manual installation path. See [deepseek-harness discussion #2889](https://github.com/deepseek-ai/deepseek-harness/discussions/2889).
156
171
 
@@ -436,7 +451,7 @@ ollama pull qwen2.5vl
436
451
  ## Requirements
437
452
 
438
453
  - DeepSeek Harness Web profile. Normal installs can use `npx @deepseek-ai/dsh ...`; source checkouts use `pnpm dsh ...`. A bare `dsh ...` command only works when the CLI is already on your shell `PATH`.
439
- - **DSH Host support policy:** DVR 2.3.x supports DSH 0.1.x continuously from `0.1.5-rc.1` (current stable evidence: `0.1.5-rc.3`) and supports the 0.2.x train from verified `0.2.0-rc.2`. Exact `0.2.0-rc.2` is also the ordinary 2.3 development Host. Pre-0.1.5 Hosts are unsupported, and DVR no longer publishes the older jagged 0.1.x exception list. Runtime behavior remains capability-based. See [DSH Host support window](docs/architecture/dsh-support-window.md).
454
+ - **DSH Host support policy:** DVR 3.0.x supports DSH 0.1.x continuously from `0.1.5-rc.1` (current stable evidence: `0.1.5-rc.3`) and supports the 0.2.x train from verified `0.2.0-rc.2`. Exact `0.2.0-rc.2` is also the ordinary 3.0 development Host. Pre-0.1.5 Hosts are unsupported, and DVR no longer publishes the older jagged 0.1.x exception list. Runtime behavior remains capability-based. See [DSH Host support window](docs/architecture/dsh-support-window.md).
440
455
  - Node ≥ 22 (host side).
441
456
  - No API key for the default free chain; a credential reference (`apiKeyEnv`) only for paid `httpProviders`.
442
457
  - Chrome / Chromium / Edge is needed only for `vision_html_screenshot`; every other tool works without a browser.
package/README.zh.md CHANGED
@@ -42,9 +42,13 @@
42
42
  > **默认配置会让数据出网。** 使用云端视觉模型时,Vision Router 会将图片(或由它裁剪出的局部)、识图提示词及相关请求元数据发送给对应供应商。新安装默认开启 OVHcloud 匿名视觉兜底,因此“免费”和“免 Key”不等于离线。涉密、涉案、内部或其他受限材料请勿使用云端链路。详见[数据流向与严格纯本地配置](#数据流向与严格纯本地配置)。
43
43
 
44
44
  > [!WARNING]
45
- > 📌 **公告(v2.3.0)**
45
+ > 📌 **公告(v3.0.1)**
46
46
  >
47
- > **v2.3.0:架构加固与兼容收敛。DSH 0.1.x 正式支持线提高到 `0.1.5-rc.1` 起,0.2.x 从已验证的 `0.2.0-rc.2` 起;composition、Session repair、Settings/浏览器 ownership 与 Desktop lifecycle 均完成加固,只退休已证明在新支持窗口不可达的旧 shim。** [查看完整更新 →](docs/releases/v2.3.0.md)
47
+ > **v3.0.1:3.0 线上的五处修正。** Desktop 壳上的 Vision Router 设置面能读取并写入真实值,
48
+ > 模型选择器不再把同一模型重复分组;所有可能触达远程 provider 的腿 —— 后台基准分析、本地视觉
49
+ > 稳定器、设置里的「测试连接」探针、LM Studio native 传输 —— 现在都与前台视觉轮次遵守同一套
50
+ > `proxy` / `proxyHosts` 判定。支持的 Host 不变:DSH 0.1.x 自 `0.1.5-rc.1` 起,DSH 0.2.x 自
51
+ > 已验证的 `0.2.0-rc.2` 起。 [查看完整更新 →](docs/releases/v3.0.1.md)
48
52
 
49
53
  <p align="center">
50
54
  <img src="assets/vision-demo.gif" width="640" alt="演示:粘贴图片,Agent 用 vision_ground / vision_crop / vision_pixel_diff 定位发送按钮并给出坐标" />
@@ -149,6 +153,15 @@ Vision Router 在默认配置下不是完全离线工具。具体边界取决于
149
153
  npx @deepseek-ai/dsh plugin --profile web add dsh-vision-router
150
154
  ```
151
155
 
156
+ > [!IMPORTANT]
157
+ > **装到哪个 profile?** 请装进**已经存在、并且自带 Web 界面**的 profile:
158
+ >
159
+ > - 网页版 DSH:`--profile web`(默认数据目录 `~/.dsh`);
160
+ > - 官方 DeepSeek Harness 桌面应用:`--profile desktop`(同一个 `~/.dsh` 数据目录,装完在应用里重新加载插件或重启一次应用);
161
+ > - Oh-DSH Desktop:数据目录是 `~/.ohdsh`,见下方 [Oh-DSH Desktop](#oh-dsh-desktop)。
162
+ >
163
+ > `dsh plugin add` 只是把插件加进**指定** profile。**全新创建**的 profile 只含 `@deepseek-ai/dsh-base`,此时 `dsh web` 不会绑定端口(没有 Web 面)。请装进已有的 profile,或先让新 profile 具备 Web 面。
164
+
152
165
  > [!WARNING]
153
166
  > 如果这个 profile 里已经有通过 `cordis.patch.yml` **手动挂载**的社区插件,不要再把这种旧式加载方式与 `dsh plugin add` / `dsh plugin list` 混用:当前 DSH CLI 可能同时把带 bundle patch 的依赖追加到 `dsh.profile.bundles`,导致这些插件被重复注册。请先把原有手动插件迁移到 bundle 管理方式,或继续沿用手动安装路径。详见 [deepseek-harness Discussion #2889](https://github.com/deepseek-ai/deepseek-harness/discussions/2889)。
154
167
 
@@ -434,7 +447,7 @@ ollama pull qwen2.5vl
434
447
  ## 环境要求
435
448
 
436
449
  - DeepSeek Harness 的 Web profile。普通安装可用 `npx @deepseek-ai/dsh ...`;从源码仓库运行时用 `pnpm dsh ...`。只有 CLI 已经进入系统 `PATH` 时才能直接写 `dsh ...`。
437
- - **DSH Host 支持策略:** DVR 2.3.x 从 `0.1.5-rc.1` 起连续支持 DSH 0.1.x(当前稳定证据为 `0.1.5-rc.3`),并从已验证的 `0.2.0-rc.2` 起支持 0.2.x;精确 `0.2.0-rc.2` 同时作为 2.3 默认开发 Host。低于 0.1.5 的 Host 不再支持,也不再维护旧的 0.1.x 锯齿式例外列表。运行时仍按能力判断,而不是按版本字符串分支。详见 [DSH Host 支持窗口](docs/architecture/dsh-support-window.md)。
450
+ - **DSH Host 支持策略:** DVR 3.0.x 从 `0.1.5-rc.1` 起连续支持 DSH 0.1.x(当前稳定证据为 `0.1.5-rc.3`),并从已验证的 `0.2.0-rc.2` 起支持 0.2.x;精确 `0.2.0-rc.2` 同时作为 3.0 默认开发 Host。低于 0.1.5 的 Host 不再支持,也不再维护旧的 0.1.x 锯齿式例外列表。运行时仍按能力判断,而不是按版本字符串分支。详见 [DSH Host 支持窗口](docs/architecture/dsh-support-window.md)。
438
451
  - Node ≥ 22(宿主侧)。
439
452
  - 默认免费链路无需 API Key;付费 `httpProviders` 只需一个凭据引用(`apiKeyEnv`)。
440
453
  - 只有 `vision_html_screenshot` 需要 Chrome / Chromium / Edge;其余工具无浏览器也能用。
@@ -0,0 +1,252 @@
1
+ # DVR 3.0 architecture plan
2
+
3
+ Status: **complete through R10 post-main correctness closure**
4
+
5
+ Baseline:
6
+
7
+ - DVR `main@c61802dfc591410ba328b7f4c8f983b0e3d5f447`
8
+ - DSH `deepseek-ai/deepseek-harness@639ed015397290b3745d163aafe02ffee4aa3f84` (`0.2.0-rc.2`)
9
+ - 3.0 development branch: `3.0`
10
+ - R9 architecture checkpoint: `1e331b1b8f8ea74a5cd38a1347f4e0bd13ef9ef9`
11
+ - R9 architecture audit: `docs/architecture/3.0-r9-final-audit.md`
12
+ - R10 post-main correctness implementation: `b38d427d54024f739dabbb3dacf389dc719a960f`
13
+ - R10 closure: `docs/architecture/3.0-r10-final-correctness-closure.md`
14
+
15
+ 3.0 is **typed architecture consolidation**, not a repository-wide TypeScript rewrite.
16
+ The success criterion is that changes to DSH contracts, lifecycle ownership, Settings,
17
+ Session, provider contracts, and public package boundaries fail loudly at the nearest
18
+ compiler/runtime/package gate. The percentage of files ending in `.ts` is not a goal.
19
+
20
+ ## Invariants inherited from 2.3
21
+
22
+ 3.0 must preserve the semantic owners established by 2.3:
23
+
24
+ | Responsibility | Owner |
25
+ | --- | --- |
26
+ | routing/background authority | `lib/vision-routing-authority.js` |
27
+ | routing evidence | `lib/vision-routing-evidence.js` |
28
+ | planning/scoring | `lib/vision-capability-router.js` |
29
+ | execution order | `lib/vision-execution-order.js` |
30
+ | Session visual state/index | Session runtime/state/index owners |
31
+ | managed artifacts | `lib/vision-artifact-store.js` |
32
+ | DVR-owned provider HTTP | explicit `VisionProviderTransport` instance |
33
+ | Host/product projection | server presentation boundaries |
34
+ | browser rendering | client/presentation layer |
35
+
36
+ High fan-out in `runtime-composition` is expected for a composition root and is not
37
+ by itself an extraction target. Core extraction requires a stable semantic owner, not
38
+ a line-count or import-count justification.
39
+
40
+ ## Required architecture direction
41
+
42
+ ```text
43
+ DSH public contracts
44
+ |
45
+ v
46
+ narrow Host boundaries
47
+ |
48
+ v
49
+ DVR domain types
50
+ |
51
+ v
52
+ Authority -> Evidence -> Planner -> Execution
53
+ | |
54
+ +------ composition ----+
55
+ |
56
+ v
57
+ mature core
58
+ ```
59
+
60
+ Host types and DVR domain types must not become one giant interface graph.
61
+
62
+ ## Source/build target
63
+
64
+ The target package model is:
65
+
66
+ ```text
67
+ canonical source generated package artifact
68
+ src/**/*.ts / transitional .js -> lib/**/*.js
69
+ client typed/transitional source -> lib/client.js
70
+ -> lib/types/**/*.d.ts
71
+ ```
72
+
73
+ The preferred artifact directory remains `lib`; introducing `dist` has no identified
74
+ architectural benefit. Ordinary generated Host JavaScript should not become a second
75
+ checked-in source of truth.
76
+
77
+ Host code remains unbundled ESM. Browser code is a separate build/type world.
78
+
79
+ ## Type ownership
80
+
81
+ Use DSH package-exported public contracts wherever DSH owns the concept. DVR owns only
82
+ DVR semantics such as routing decisions, capability evidence, image ownership, Session
83
+ vision state, provider configuration, diagnostics, and resource ownership.
84
+
85
+ Do not create a generic `DvrContext`, Host facade, service locator, DI container,
86
+ global registry, or callback bag to make TypeScript conversion easier.
87
+
88
+ ## Runtime validation
89
+
90
+ TypeScript never replaces validation at Settings/JSON, RPC, provider/network,
91
+ filesystem, persisted state, environment, browser/Node, or user-input boundaries.
92
+
93
+ Preferred rule:
94
+
95
+ ```text
96
+ unknown -> boundary parser/official codec -> typed value -> domain
97
+ ```
98
+
99
+ Schemastery remains the owner for plugin Config/Settings schema. Zod or another runtime
100
+ validator is justified only for complex untrusted external shapes; browser code should
101
+ not gain a heavyweight validator merely for type symmetry.
102
+
103
+ ## Host / Client programs
104
+
105
+ Host and browser Client must be type-checked as separate programs. DSH itself separates
106
+ the two because both sides augment Cordis Context under different runtime contracts.
107
+
108
+ Host compilation should follow real Node ESM resolution rather than copying DSH's
109
+ monorepo-only build choices mechanically. Current target for the Host compiler is
110
+ NodeNext/NodeNext with explicit ESM extension discipline.
111
+
112
+ ## Browser constraint
113
+
114
+ The existing `262144` byte single-file review bound for `lib/client.js` is frozen.
115
+ 3.0 must not raise it to make TypeScript fit. Client migration is an independent Go/No-Go
116
+ workstream and may remain partly JavaScript if typed generation would weaken
117
+ determinism, debugging, loader transparency, or the size gate.
118
+
119
+ ## Compatibility
120
+
121
+ Runtime Host compatibility and durable user-data compatibility are independent.
122
+
123
+ 3.0 may raise the Host floor only after a dedicated evidence gate proves that the
124
+ removed Host generations account for real compatibility complexity. A higher Host floor
125
+ does not authorize deleting readers/migrations for persisted Settings, profile data,
126
+ Session/replay data, attachment identity, or historical image ownership.
127
+
128
+ No speculative DSH 0.3 implementation is part of this plan.
129
+
130
+ ## Production dependency policy
131
+
132
+ Production runtime code may depend on documented/package-exported DSH faces. It must
133
+ not import `@deepseek-ai/*/src/*` or DeepSeek Harness monorepo filesystem internals.
134
+
135
+ Exact-source compatibility surveillance under `scripts/` and tests is a separate
136
+ category: it may inspect upstream implementation source to detect Host drift or a shim's
137
+ removal condition, but that source dependency must not enter runtime code, public
138
+ declarations, or the npm runtime graph.
139
+
140
+ ## Public API direction
141
+
142
+ R7 replaced the former transitive mature-Core export graph with an explicit package-root
143
+ runtime/type surface. New Core exports no longer become package API automatically.
144
+
145
+ `./client` remains a DSH loader entry and is not treated as an ordinary consumer
146
+ library API.
147
+
148
+ ## Roadmap
149
+
150
+ Final status:
151
+
152
+ | Phase | Result |
153
+ | --- | --- |
154
+ | R0 | complete |
155
+ | R1 | complete |
156
+ | R2 | complete |
157
+ | R3 | complete |
158
+ | R4 | complete |
159
+ | R5 | complete — production Browser TypeScript switch No-Go |
160
+ | R6 | complete |
161
+ | R7 | complete |
162
+ | R8 | complete |
163
+ | R9 | complete |
164
+ | R10 | complete — post-main final correctness closure |
165
+
166
+ R9 records the typed-architecture audit at its historical checkpoint. The post-main
167
+ correctness findings and repairs are recorded separately in
168
+ `docs/architecture/3.0-r10-final-correctness-closure.md`.
169
+
170
+ ### R0 - Baseline and contract ledger
171
+
172
+ - freeze package/export/browser/support facts;
173
+ - record DSH public type authorities;
174
+ - classify current package-root exposure;
175
+ - gate production private DSH source imports;
176
+ - record compatibility candidates without deleting them.
177
+
178
+ ### R1 - Source/artifact boundary
179
+
180
+ - establish `src` as canonical source and `lib` as generated output;
181
+ - preserve behavior/module ownership during relocation;
182
+ - add clean/reproducible artifact checks;
183
+ - do not combine source moves with semantic refactors.
184
+
185
+ ### R2 - Type infrastructure and Host boundaries
186
+
187
+ - separate Host and Client TypeScript programs;
188
+ - add strict compiler policy;
189
+ - type Settings, Session, LLM/provider, attachment, RemoteResult, and composition inputs
190
+ against DSH public contracts;
191
+ - allow a controlled JS bridge during migration.
192
+
193
+ ### R3 - DVR domain types
194
+
195
+ Type only stable DVR-owned semantics. Do not create interfaces without a named owner and
196
+ a concrete coupling/risk they reduce.
197
+
198
+ ### R4 - Composition and mature Core
199
+
200
+ Migrate composition/lifecycle before low-value algorithmic code. Mature Core conversion
201
+ is incremental and must not trigger decomposition solely for file size.
202
+
203
+ ### R5 - Browser Client
204
+
205
+ Run an independent typed-source/build experiment. Switch production ownership only when
206
+ the output is deterministic, understandable, uses only supported runtime externals,
207
+ passes real browser/Desktop tests, and stays at or below 256 KiB.
208
+
209
+ ### R6 - Compatibility retirement / Host floor
210
+
211
+ Re-run every shim's documented removal condition. Host-floor changes are evidence-based
212
+ and do not retire durable-data compatibility.
213
+
214
+ ### R7 - Public API
215
+
216
+ Classify root exports as plugin contract, supported API, compatibility API, accidental
217
+ internal, or test-only. Publish only deliberate types/runtime faces.
218
+
219
+ ### R8 - CI/release
220
+
221
+ Add typecheck, lint, clean build, generated sync, reproducibility, packed declaration
222
+ smoke, and source-to-artifact evidence without weakening the existing pack-once,
223
+ tarball-identity, trusted-publishing, and provenance model.
224
+
225
+ ### R9 - Final audit
226
+
227
+ Re-run ownership, lifecycle, dependency-cycle, browser, compatibility, package,
228
+ Node 22/24, supported DSH, Desktop, adversarial, property, resource, and release audits.
229
+
230
+ ### R10 - Final correctness closure
231
+
232
+ - review post-main implementation rather than treating R9 green evidence as transitive;
233
+ - repair provider transport capture, dynamic Host validation and optional Cordis seams;
234
+ - complete Session Vision sidecar/user-authority lifecycle ownership;
235
+ - align package-root runtime and declaration contracts;
236
+ - migrate CI trigger ownership from generated artifacts to canonical source;
237
+ - verify the exact package candidate before tag creation while preserving pack-once.
238
+
239
+ ## Explicit non-goals
240
+
241
+ - 100% TypeScript conversion;
242
+ - Big Bang rewrite;
243
+ - generic DI/service locator;
244
+ - global current owner or registry;
245
+ - `Object.create(core)` facade;
246
+ - Config/Settings impersonation;
247
+ - Core decomposition by LOC;
248
+ - composition splitting by fan-out;
249
+ - routing/Session/provider rewrites unrelated to a proven 3.0 seam;
250
+ - browser size-limit increase;
251
+ - importing DSH private implementation to obtain richer types;
252
+ - deleting runtime validation because code is typed.
@@ -0,0 +1,137 @@
1
+ # DVR 3.0 R0 contract ledger
2
+
3
+ Status: **R0 baseline**
4
+
5
+ Audit baseline:
6
+
7
+ - DVR source baseline: `main@c61802dfc591410ba328b7f4c8f983b0e3d5f447`
8
+ - 3.0 planning commit: `9fe18fb0abe8732ee2848140e10113dfada92623`
9
+ - DSH source baseline: `deepseek-ai/deepseek-harness@639ed015397290b3745d163aafe02ffee4aa3f84`
10
+ - DSH package line at audit: `0.2.0-rc.2`
11
+
12
+ R0 records facts and installs non-behavioral architecture gates. It does not move source,
13
+ change Host support, delete compatibility, or alter plugin runtime behavior.
14
+
15
+ ## Package and runtime baseline
16
+
17
+ | Contract | R0 value |
18
+ | --- | --- |
19
+ | package | `dsh-vision-router@2.3.0` |
20
+ | module kind | ESM |
21
+ | Node | `^22.19.0 || >=24.0.0` |
22
+ | package root | `lib/public-entry.js` |
23
+ | DSH browser entry | `lib/client.js` |
24
+ | CLI | `lib/doctor-cli-p0.js` |
25
+ | browser hard bound | `262144` bytes |
26
+ | browser R0 size | `261672` bytes |
27
+ | browser headroom | `472` bytes |
28
+ | production ESM cycles at 2.3 close | 0 |
29
+
30
+ The 256 KiB browser review bound is a retained constraint, not a migration target to relax.
31
+
32
+ ## Current root export topology
33
+
34
+ The current root is intentionally **not** curated during R0:
35
+
36
+ ```text
37
+ package "."
38
+ -> lib/public-entry.js
39
+ -> export * from ../entry.js
40
+ -> export * from ./index.js
41
+ -> export * from ./lib/vision-resilience.js
42
+ ```
43
+
44
+ Static export inventory at the R0 baseline:
45
+
46
+ - `index.js`: 101 direct named exports;
47
+ - `lib/vision-resilience.js`: 13 named exports re-exported by `index.js`;
48
+ - `entry.js`: 10 direct named exports plus the Core star export;
49
+ - estimated distinct package-root named surface after shadowing/deduplication: **122 names**.
50
+
51
+ This is an **inventory**, not an assertion that all 122 names are supported public API.
52
+ R7 must classify every root export as one of:
53
+
54
+ - `PLUGIN_CONTRACT`;
55
+ - `PUBLIC_SUPPORTED`;
56
+ - `PUBLIC_COMPAT`;
57
+ - `INTERNAL_ACCIDENTAL`;
58
+ - `TEST_ONLY`.
59
+
60
+ R0 must not reduce this surface before that classification because doing so would mix API
61
+ breakage with source/build migration.
62
+
63
+ ## DSH type authority ledger
64
+
65
+ Production TypeScript must prefer package-exported DSH contracts where DSH owns the
66
+ concept.
67
+
68
+ | Concept | Current DSH authority |
69
+ | --- | --- |
70
+ | `RemoteResult` / remote failures | `@deepseek-ai/dsh-typert-protocol` |
71
+ | Session client/controller faces | `@deepseek-ai/dsh-api-session-controller/client` |
72
+ | Session/model-selection value contracts | `@deepseek-ai/dsh-api-session-controller/types` |
73
+ | LLM/provider/message vocabulary | `@deepseek-ai/dsh-llm/types` |
74
+ | attachment vocabulary | `@deepseek-ai/dsh-attachment` / exported types face |
75
+ | Settings transport/view vocabulary | `@deepseek-ai/dsh-settings/types` |
76
+ | generated client remote assembly | `@deepseek-ai/dsh-api-remotes/client` |
77
+ | browser slots | `@deepseek-ai/dsh-client-ui-slots` |
78
+ | ModelDirectory controller/state | `@deepseek-ai/dsh-client-ui-model-selection/client` |
79
+
80
+ `ModelDirectory` and `ModelDirectoryState` are package-exported browser contracts, but
81
+ remain model-selection UI/controller types. They are not DVR routing-domain types.
82
+
83
+ ## Production private-source policy
84
+
85
+ R0 installs a hard architectural rule:
86
+
87
+ > Production runtime code must not import or reference DSH package `src/*` entry points
88
+ > or `deepseek-harness/packages/*/src/*` monorepo implementation paths.
89
+
90
+ This applies to production entry points and `lib/**/*.js` now, and later to generated
91
+ runtime output from `src`.
92
+
93
+ The rule deliberately does **not** ban scripts/tests that inspect exact upstream source.
94
+ Files such as `scripts/dsh017-source-contract.mjs` are upstream compatibility
95
+ surveillance; they are allowed to inspect DSH implementation source because they do not
96
+ enter the npm production runtime graph.
97
+
98
+ ## Compatibility baseline
99
+
100
+ 2.3 closes with runtime Host support spanning the 0.1.5 train and exact 0.2.0-rc.2
101
+ evidence. 3.0 does not change that in R0.
102
+
103
+ Runtime Host compatibility and durable-data compatibility remain independent. A later
104
+ Host-floor raise cannot by itself remove replay, Settings/profile, Session, attachment,
105
+ route-identity, or historical image-ownership readers.
106
+
107
+ ## R0 compatibility candidate: dsh-client-runtime
108
+
109
+ Current DVR still names `@deepseek-ai/dsh-client-runtime` in two places:
110
+
111
+ 1. `package.json#dsh.client.inject`;
112
+ 2. `lib/doctor-runtime.js#HOST_PACKAGES`.
113
+
114
+ At the audited DSH `0.2.0-rc.2` source baseline, repository search finds historical
115
+ references but no current package implementation that establishes this as a current
116
+ browser runtime package. DVR also has no identified `ctx.runtime` consumption.
117
+
118
+ Classification: **candidate stale Host/browser edge, not yet deletion-authorized**.
119
+
120
+ Removal requires real package/Host/browser evidence and must update both the manifest
121
+ and Doctor assumption together. R0 records the candidate; R6 owns the decision.
122
+
123
+ ## R0 exit criteria
124
+
125
+ R0 is complete when:
126
+
127
+ - the 3.0 architecture plan exists in-repo;
128
+ - this contract ledger exists;
129
+ - the existing package/browser/support baselines remain unchanged;
130
+ - CI runs on the 3.0 development branch;
131
+ - production private DSH source references are forbidden by an executable architecture
132
+ test;
133
+ - no runtime behavior, support floor, compatibility shim, release metadata, tag, npm
134
+ package, or GitHub Release is changed.
135
+
136
+ The next phase is R1: establish a source/artifact boundary without mixing that move with
137
+ semantic refactors.
@@ -0,0 +1,98 @@
1
+ # DVR 3.0 R1 source/artifact boundary
2
+
3
+ Status: **complete**
4
+
5
+ R1 was intentionally split so source relocation and artifact removal were not performed
6
+ in one unreviewable change.
7
+
8
+ ## Final source/artifact model
9
+
10
+ The canonical editable runtime tree is `src/`, preserving the established 2.3 package
11
+ artifact topology:
12
+
13
+ ```text
14
+ src/entry.js / transitional .ts -> entry.js
15
+ src/index.js / transitional .ts -> index.js
16
+ src/lib/**/*.js / src/lib/**/*.ts -> lib/**/*.js
17
+ ```
18
+
19
+ `entry.js`, `index.js`, and `lib/**` are generated package artifacts and are no longer
20
+ tracked by Git.
21
+
22
+ The move did not authorize import rewrites, Core decomposition, public API contraction,
23
+ or runtime ownership changes. Source relocation and TypeScript migration remain separate
24
+ review dimensions.
25
+
26
+ ## Build ownership
27
+
28
+ `scripts/build-source-artifacts.mjs` is the only writer for the package runtime tree.
29
+
30
+ A normal `pnpm build`:
31
+
32
+ 1. removes any stale root `entry.js`, `index.js`, and `lib/**`;
33
+ 2. copies transitional canonical JavaScript from `src/` byte-for-byte;
34
+ 3. compiles canonical TypeScript in an isolated temporary output directory;
35
+ 4. copies compiled JavaScript into the established package artifact paths.
36
+
37
+ This clean-before-build rule prevents deleted or renamed source modules from surviving as
38
+ stale files that could later enter `pnpm pack`.
39
+
40
+ `pnpm build:check` builds into a temporary directory and compares generated output with
41
+ the current package tree without mutating it.
42
+
43
+ `pnpm build:reproducible` performs two clean builds into independent temporary
44
+ directories and compares relative paths, byte sizes, and SHA-256 hashes.
45
+
46
+ ## Install and package lifecycle
47
+
48
+ Repository installs run `prepare -> pnpm build`, so workflows and direct test commands
49
+ that historically consumed `lib/**` receive current artifacts from canonical source.
50
+
51
+ The one security workflow that intentionally installs with `--ignore-scripts`
52
+ (`adversarial-fuzz`) has an explicit build step.
53
+
54
+ `prepack -> pnpm build` is an independent package safety gate. Packaging therefore does
55
+ not rely on generated files being present in the checkout or left over from tests.
56
+
57
+ Generated runtime paths are ignored by Git:
58
+
59
+ - `/entry.js`;
60
+ - `/index.js`;
61
+ - `/lib/`.
62
+
63
+ The npm `files` allowlist continues to name those artifact paths because they are package
64
+ outputs, not repository source.
65
+
66
+ ## Workflow trigger migration
67
+
68
+ Specialized workflows whose path filters referenced the old root `index.js`,
69
+ `entry.js`, or `lib/**` now also follow `src/**`. This prevents removal of tracked
70
+ artifacts from silently disabling architecture, Host, browser, resource, compatibility,
71
+ or fuzz gates.
72
+
73
+ ## Browser client
74
+
75
+ The browser client remains a separate workstream. Canonical browser source currently
76
+ lives under `src/lib/client.js`; its deterministic embedded maintenance-actions sync is
77
+ performed on canonical source before package artifacts are rebuilt.
78
+
79
+ The existing 262144-byte hard review bound is unchanged.
80
+
81
+ ## R1 verification
82
+
83
+ R1b was verified from a checkout with **zero tracked generated runtime artifacts**:
84
+
85
+ - frozen install succeeded;
86
+ - prepare rebuilt the runtime tree;
87
+ - clean build succeeded;
88
+ - generated artifact verification succeeded;
89
+ - two-build reproducibility succeeded;
90
+ - Host and Client typecheck succeeded;
91
+ - full Node 22 and Node 24 test suites succeeded;
92
+ - Linux and macOS native Host/sharp smoke succeeded;
93
+ - Windows runtime regression succeeded;
94
+ - Windows `pnpm pack` succeeded with generated artifacts ignored by Git;
95
+ - the packed tarball installed into a DSH-like Host with the shared-sharp invariant intact.
96
+
97
+ R1 is closed. Further source migration is R2/R3/R4 work and must preserve this build
98
+ contract.