dsh-vision-router 2.2.8 → 3.0.0

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 (132) hide show
  1. package/README.md +16 -7
  2. package/README.zh.md +16 -7
  3. package/docs/architecture/2.3.0-compat-retirement.md +147 -0
  4. package/docs/architecture/2.3.0-execution-plan.md +410 -0
  5. package/docs/architecture/2.3.0-final-audit.md +279 -0
  6. package/docs/architecture/2.3.0-reopened-plan.md +720 -0
  7. package/docs/architecture/3.0-architecture-plan.md +252 -0
  8. package/docs/architecture/3.0-r0-contract-ledger.md +137 -0
  9. package/docs/architecture/3.0-r1-source-artifact-boundary.md +98 -0
  10. package/docs/architecture/3.0-r10-final-correctness-closure.md +207 -0
  11. package/docs/architecture/3.0-r11-adversarial-review.md +441 -0
  12. package/docs/architecture/3.0-r5-browser-go-no-go.md +165 -0
  13. package/docs/architecture/3.0-r5-browser-typescript-gate.md +105 -0
  14. package/docs/architecture/3.0-r6-compat-retirement.md +203 -0
  15. package/docs/architecture/3.0-r7-public-api.md +151 -0
  16. package/docs/architecture/3.0-r8-ci-release.md +248 -0
  17. package/docs/architecture/3.0-r9-final-audit.md +370 -0
  18. package/docs/architecture/compat-inventory.md +26 -34
  19. package/docs/architecture/dsh-compatibility-matrix.md +65 -54
  20. package/docs/architecture/dsh-support-window.md +30 -22
  21. package/docs/architecture/final-closure-audit.md +2 -0
  22. package/docs/releases/v2.3.0.md +53 -0
  23. package/docs/releases/v3.0.0.md +85 -0
  24. package/entry.js +9 -57
  25. package/index.js +268 -761
  26. package/lib/agent-request-route-authority.js +1 -20
  27. package/lib/catalog-corrections.js +1 -2
  28. package/lib/client-maintenance-actions.js +145 -0
  29. package/lib/client-presentation-boundary-main.js +75 -17
  30. package/lib/client-presentation-boundary.js +53 -28
  31. package/lib/client.js +246 -144
  32. package/lib/core-apply-lifecycle.js +41 -0
  33. package/lib/core-cache.js +87 -0
  34. package/lib/core-primitives.js +91 -278
  35. package/lib/core-vision-surface-domain.js +63 -0
  36. package/lib/core-vision-surface.js +11 -77
  37. package/lib/delegated-call-config.js +15 -24
  38. package/lib/desktop-screenshot-tool.js +262 -0
  39. package/lib/doctor-cli.js +0 -0
  40. package/lib/doctor-runtime.js +4 -1
  41. package/lib/dsh-contract-compat.js +37 -256
  42. package/lib/dsh-host-capabilities.js +3 -9
  43. package/lib/dsh-settings-017-compat.js +17 -10
  44. package/lib/dsh-support-window.js +3 -3
  45. package/lib/file-logger.js +8 -3
  46. package/lib/grounding-coordinate-runtime.js +1 -2
  47. package/lib/http-body-limit.js +97 -79
  48. package/lib/http-compat.js +1 -2
  49. package/lib/image-offload-compat.js +30 -21
  50. package/lib/image-resource-governor.js +210 -228
  51. package/lib/legacy-global-proxy-boundary.js +46 -3
  52. package/lib/live-model-client-prelude.js +12 -4
  53. package/lib/live-model-discovery.js +134 -43
  54. package/lib/local-remote-settings-permission.js +33 -7
  55. package/lib/local-vision-stabilizer.js +31 -17
  56. package/lib/maintenance-routes.js +134 -0
  57. package/lib/native-image-coexistence.js +15 -3
  58. package/lib/ollama-cold-start.js +87 -23
  59. package/lib/pi-ai-bridge-wire-compat.js +3 -2
  60. package/lib/proxy-dispatcher-pool.js +151 -92
  61. package/lib/proxy-routing.js +75 -51
  62. package/lib/proxy-url-compat.js +3 -10
  63. package/lib/public-config.js +36 -0
  64. package/lib/public-entry.d.ts +148 -0
  65. package/lib/public-entry.js +19 -11
  66. package/lib/remote-settings-bridge.js +11 -0
  67. package/lib/remote-settings-risk-client-boundary.js +155 -0
  68. package/lib/remote-settings-risk-confirmation.js +17 -105
  69. package/lib/replay-delegation.js +12 -7
  70. package/lib/replay-envelope-v2-compat.js +12 -7
  71. package/lib/runtime-composition.js +127 -34
  72. package/lib/runtime-i18n-boundary.js +10 -11
  73. package/lib/screenshot-source-boundary.js +2 -2
  74. package/lib/session-affinity-runtime.js +113 -97
  75. package/lib/session-affinity.js +89 -76
  76. package/lib/session-event-history-compat.js +30 -0
  77. package/lib/session-message-source-compat.js +7 -3
  78. package/lib/session-query-readers.js +263 -0
  79. package/lib/session-surface-compat.js +30 -31
  80. package/lib/session-surface-policy-domain.js +85 -0
  81. package/lib/session-surface-policy.js +2 -111
  82. package/lib/session-turn-resolver.js +2 -6
  83. package/lib/session-vision-attachment-index.js +143 -0
  84. package/lib/session-vision-delegation-boundary.js +34 -0
  85. package/lib/session-vision-delegation.js +22 -0
  86. package/lib/session-vision-index.js +179 -116
  87. package/lib/session-vision-mode-authority.js +229 -192
  88. package/lib/session-vision-mode-boundary.js +65 -22
  89. package/lib/session-vision-policy-domain.js +304 -0
  90. package/lib/session-vision-policy.js +104 -0
  91. package/lib/session-vision-state.js +368 -378
  92. package/lib/settings-client-017-compat.js +9 -7
  93. package/lib/settings-client-loader-lifecycle.js +129 -0
  94. package/lib/sharp-runtime.js +0 -7
  95. package/lib/structured-flow-hardening.js +25 -6
  96. package/lib/tesseract-exec-compat.js +9 -1
  97. package/lib/turn-budget-context.js +47 -41
  98. package/lib/update-check.js +11 -2
  99. package/lib/vision-attachment-handle-runtime.js +176 -156
  100. package/lib/vision-backend-runtime-policy.js +19 -2
  101. package/lib/vision-background-benchmark.js +41 -4
  102. package/lib/vision-background-failure-policy.js +41 -41
  103. package/lib/vision-background-stop-store-core.js +217 -0
  104. package/lib/vision-background-stop-store.js +8 -179
  105. package/lib/vision-capability-benchmark-service.js +1 -0
  106. package/lib/vision-capability-benchmark.js +11 -61
  107. package/lib/vision-capability-evidence.js +35 -0
  108. package/lib/vision-capability-fingerprint.js +72 -0
  109. package/lib/vision-capability-identity.js +116 -61
  110. package/lib/vision-capability-router.js +13 -33
  111. package/lib/vision-chunk-assembler.js +95 -0
  112. package/lib/vision-diagnostics-routes.js +246 -0
  113. package/lib/vision-evidence-guidance.js +3 -1
  114. package/lib/vision-execution-order-apply.js +45 -55
  115. package/lib/vision-execution-order.js +19 -19
  116. package/lib/vision-execution-policy.js +12 -7
  117. package/lib/vision-model-registry.js +30 -17
  118. package/lib/vision-provider-transport.js +137 -176
  119. package/lib/vision-routing-authority.js +47 -48
  120. package/lib/vision-routing-product.js +26 -29
  121. package/lib/vision-routing-settings-prelude.js +8 -3
  122. package/lib/vision-runtime-performance-store.js +166 -0
  123. package/lib/vision-runtime-performance.js +13 -142
  124. package/lib/vision-toggle-root-hardening.js +22 -5
  125. package/lib/vision-tool-runtime-boundary.js +104 -31
  126. package/lib/web/dsh-settings-017-root-transport.js +27 -12
  127. package/lib/web/remote-settings-client.js +6 -9
  128. package/lib/web-capability-boundary.js +17 -7
  129. package/lib/wrapper-directory.js +14 -23
  130. package/package.json +56 -20
  131. package/lib/android-attachment-compat.js +0 -244
  132. package/lib/settings-client-rc8-lifecycle.js +0 -397
@@ -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.
@@ -0,0 +1,207 @@
1
+ # DVR 3.0 R10 — Final Correctness Closure
2
+
3
+ Status: **complete — integrated into `3.0` through PR #621**
4
+
5
+ Implementation checkpoint:
6
+
7
+ - implementation branch: `r10-final-correctness-closure`
8
+ - original review base: `3.0@cc6bdd8d24bc186e13ae5bfa73502a30196aa16b`
9
+ - implementation HEAD: `b38d427d54024f739dabbb3dacf389dc719a960f`
10
+ - reconciled R10 head: `9c77880c69e3a85ff07666a83c9006d82cc48cba`
11
+ - integration PR: `#621`
12
+ - integrated `3.0` merge commit: `3e63545804617a3ffcd354cca05db9e6ff6918a5`
13
+ - DSH authority: `deepseek-ai/deepseek-harness@639ed015397290b3745d163aafe02ffee4aa3f84` (`0.2.0-rc.2`)
14
+ - package version: `2.3.0`
15
+ - version bump / tag / npm publish: **not part of R10**
16
+
17
+ R10 is a post-R9 correctness closure. It does not reopen the 3.0 architecture program,
18
+ and it does not broaden the TypeScript migration. It reviews the implementation after
19
+ current `main` was absorbed into `3.0`, then repairs concrete runtime, lifecycle,
20
+ source-ownership, public-contract, and release-order defects found by code review.
21
+
22
+ ## Closure decisions
23
+
24
+ ### 1. Provider transport restores module-time Host fetch ownership
25
+
26
+ The TypeScript migration had changed the module-time `globalThis.fetch.bind(globalThis)`
27
+ snapshot into a wrapper that re-read `globalThis.fetch` on every request. That made the
28
+ Router-owned direct-provider transport re-enter process-wide fetch wrappers installed
29
+ later by Core/compat layers.
30
+
31
+ R10 restores a real module-time bound fetch snapshot. The transport may still observe the
32
+ live Undici global dispatcher as designed; it no longer observes later replacement of the
33
+ `globalThis.fetch` function itself.
34
+
35
+ ### 2. Dynamic Host tool definitions keep runtime validation
36
+
37
+ `vision-attachment-handle-runtime` again treats tool definitions as runtime Host input.
38
+ Nullish or malformed registrations are passed through for Host-owned validation instead
39
+ of throwing inside DVR merely because a TypeScript generic describes the expected shape.
40
+
41
+ This preserves the 3.0 rule that static typing never replaces validation at dynamic Host
42
+ boundaries.
43
+
44
+ ### 3. Optional Cordis capabilities use non-owning lookup semantics
45
+
46
+ R10 removes remaining direct optional-service property fallbacks for:
47
+
48
+ - `sessionQuery`;
49
+ - `sessionProjections`;
50
+ - `systemPrompt`;
51
+ - `attachments`.
52
+
53
+ These paths now use `Context#get` capability probes. Required services continue to be
54
+ owned through the existing `inject`/composition seams. This prevents optional detection
55
+ from accidentally becoming a Cordis pending dependency.
56
+
57
+ ### 4. Session Vision sidecar owns its complete async lifecycle
58
+
59
+ The Session Vision policy domain now binds its consumer effect before asynchronous
60
+ `storageDomain.open()` begins. Unload/HMR can therefore await and close an eventual late
61
+ handle instead of leaving a same-name domain open in the longer-lived facility.
62
+
63
+ The store also:
64
+
65
+ - retires an old domain before opening against a replacement facility;
66
+ - closes stale/late opens exactly once;
67
+ - degrades to volatile authority after a storage failure without losing the current
68
+ in-process Session decision;
69
+ - evicts durable hot-cache rows at Agent disposal while keeping durable Session truth for
70
+ future cold resume.
71
+
72
+ Persistent policy retention remains Session-scoped by design; R10 does not add an
73
+ arbitrary TTL that would break cold-resume semantics.
74
+
75
+ ### 5. User Session authority is connected to the official durable selection fact
76
+
77
+ DSH rc.2 records explicit Session model changes as the durable `model/selection` event.
78
+ R10 consumes that committed event and materializes DVR `source: 'user'` Session Vision
79
+ policy from the exact selected route.
80
+
81
+ This completes the authority model that already allowed user policy to outrank an
82
+ inherited delegation snapshot. Delegation still creates a child-local snapshot and later
83
+ parent changes do not retroactively mutate that child; a later explicit selection in the
84
+ child Session can now override the inherited snapshot through a real production path.
85
+
86
+ ### 6. Package-root declarations match the package-root runtime
87
+
88
+ `public-entry.d.ts` no longer exposes the internal third `runtime` argument of
89
+ `src/entry.js` through package-root `apply()`. The package wrapper owns provider transport
90
+ creation, so consumer injection of that internal seam is not public API.
91
+
92
+ `installHostSettingsCompatibility` now declares and enforces both `namespace` and `Config`
93
+ as required. The declaration source is included in the Host TypeScript program, and the
94
+ packed consumer contract contains negative type assertions for both invalid calls.
95
+
96
+ ### 7. Provider transport teardown is an awaited Cordis disposer
97
+
98
+ The public entry returns the transport-disposal Promise from its effect disposer instead
99
+ of discarding it. HMR/plugin unload therefore waits for Router-owned dispatcher leases and
100
+ ProxyAgent cleanup. The synchronous apply-failure path starts the same idempotent cleanup
101
+ and absorbs cleanup rejection while rethrowing the original apply failure.
102
+
103
+ ### 8. CI triggers now follow canonical source ownership
104
+
105
+ After R1, `src/**` is canonical and root `entry.js` / `index.js` / `lib/**` are generated
106
+ package artifacts. R10 migrates workflow path filters and the CI impact classifier to the
107
+ canonical source paths, including the real `.ts` extension for migrated owners.
108
+
109
+ A repository contract now rejects workflow trigger ownership by generated package paths
110
+ and verifies every literal canonical `src/**` trigger resolves to a real source file.
111
+
112
+ ### 9. Release correctness preserves both pre-tag verification and pack-once
113
+
114
+ The release workflow no longer creates a new immutable tag before the exact package
115
+ candidate is packed and inspected.
116
+
117
+ The release sequence is now:
118
+
119
+ ```text
120
+ verify exact main source
121
+ -> build / type / test / source-artifact gates
122
+ -> pin npm client
123
+ -> npm pack exactly once
124
+ -> verify packed public API
125
+ -> probe existing npm version against tarball SHA-1
126
+ -> persist exact tarball as same-run artifact
127
+ -> create/verify immutable tag
128
+ -> rehydrate the same tarball
129
+ -> verify SHA-1 + SHA-256 handoff
130
+ -> publish that exact tarball with trusted OIDC
131
+ -> registry identity wait + attestation + GitHub Release
132
+ ```
133
+
134
+ This closes the tag-before-pack failure window without weakening the pre-existing
135
+ pack-once / exact-tarball / provenance model.
136
+
137
+ ## Negative review
138
+
139
+ R10 deliberately did **not**:
140
+
141
+ - rewrite `src/index.js` or the mature Core; it remains byte-identical to current
142
+ `origin/main:index.js` at the implementation checkpoint;
143
+ - introduce a generic `DvrContext`, Host facade, DI/service locator, global runtime owner,
144
+ or second source tree;
145
+ - raise the browser `262144` byte gate; `src/lib/client.js` remains `261672` bytes;
146
+ - convert the production browser client merely to increase TypeScript percentage;
147
+ - add DSH private `/src/*` runtime imports;
148
+ - change the advertised Host support window;
149
+ - bump the package to `3.0.0`, create a tag, or publish a release.
150
+
151
+ ## Explicitly retained findings
152
+
153
+ The following findings were intentionally kept outside R10 and remain visible for future
154
+ work rather than being hidden by the closure:
155
+
156
+ 1. `runtime-composition.js` is still a JavaScript composition root. Its phase objects are
157
+ not compiler-enforced contracts. R10 does not convert it merely to satisfy a language
158
+ metric.
159
+ 2. `tsconfig.client.json` protects the browser-only compiler world, but production
160
+ `src/lib/client.js` is not under strict TypeScript/checkJs coverage. The R5 production
161
+ Browser TypeScript switch remains No-Go under the frozen size/build constraints.
162
+ 3. R9 remains historical evidence for `1e331b1`; R10 is the post-main correctness
163
+ checkpoint and does not rewrite R9 as though it had audited this later code.
164
+
165
+ ## Local implementation evidence
166
+
167
+ At `b38d427d54024f739dabbb3dacf389dc719a960f` plus the documentation-only closure that
168
+ follows it:
169
+
170
+ ```text
171
+ canonical source files 182
172
+ canonical runtime TS owners 38
173
+ canonical public declarations 1
174
+ canonical package artifacts 182
175
+ browser client bytes 261672
176
+ browser hard gate 262144
177
+ ```
178
+
179
+ Source-to-artifact evidence digest:
180
+
181
+ ```text
182
+ 2a9f8d2c2ed1f60506871a0237383fd8e31304296360c1193009cfbf300a8821
183
+ ```
184
+
185
+ Local post-fix validation completed with:
186
+
187
+ - generated artifacts: `182/182` in sync;
188
+ - Host + Client typecheck: pass;
189
+ - source ownership lint: pass;
190
+ - no remaining audited direct optional-service property reads;
191
+ - main regression: `1605 tests / 1604 pass / 0 fail / 1 skip`;
192
+ - backend runtime policy: `10/10` pass;
193
+ - reproducible build: `182` artifacts verified;
194
+ - targeted R10 transport/release/trigger regressions: pass;
195
+ - workflow YAML parse: pass;
196
+ - canonical workflow literal trigger audit: `0` invalid paths.
197
+
198
+ These gates verify the repaired implementation; they are evidence after the code review,
199
+ not a substitute for the code review that produced R10.
200
+
201
+ ## Exit decision
202
+
203
+ R10 closes the concrete correctness defects found after R9 and after current `main` was
204
+ absorbed into `3.0`. PR #621 has been reviewed for mergeability and integrated into `3.0`. The integrated
205
+ branch is `0` commits behind current `main`; GitHub-side Host/Desktop/package evidence
206
+ can now run against the integrated R10 head as part of the later 3.0 release-candidate
207
+ phase. No further architecture migration pass is justified by R10 itself.