dsh-vision-router 2.3.0 → 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 (103) hide show
  1. package/README.md +12 -3
  2. package/README.zh.md +12 -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 +441 -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 +5 -3
  15. package/docs/releases/v3.0.0.md +85 -0
  16. package/entry.js +1 -1
  17. package/index.js +108 -71
  18. package/lib/agent-request-route-authority.js +1 -20
  19. package/lib/core-apply-lifecycle.js +37 -43
  20. package/lib/core-cache.js +87 -0
  21. package/lib/core-primitives.js +3 -143
  22. package/lib/core-vision-surface-domain.js +63 -0
  23. package/lib/core-vision-surface.js +11 -77
  24. package/lib/delegated-call-config.js +15 -24
  25. package/lib/doctor-cli.js +0 -0
  26. package/lib/doctor-runtime.js +4 -1
  27. package/lib/dsh-contract-compat.js +26 -230
  28. package/lib/dsh-host-capabilities.js +3 -9
  29. package/lib/dsh-settings-017-compat.js +17 -10
  30. package/lib/file-logger.js +8 -3
  31. package/lib/grounding-coordinate-runtime.js +1 -2
  32. package/lib/http-body-limit.js +97 -79
  33. package/lib/image-offload-compat.js +30 -21
  34. package/lib/image-resource-governor.js +210 -228
  35. package/lib/legacy-global-proxy-boundary.js +46 -3
  36. package/lib/live-model-client-prelude.js +12 -4
  37. package/lib/live-model-discovery.js +134 -43
  38. package/lib/local-vision-stabilizer.js +31 -17
  39. package/lib/maintenance-routes.js +1 -3
  40. package/lib/native-image-coexistence.js +15 -3
  41. package/lib/ollama-cold-start.js +87 -23
  42. package/lib/pi-ai-bridge-wire-compat.js +3 -2
  43. package/lib/proxy-dispatcher-pool.js +151 -92
  44. package/lib/proxy-routing.js +75 -51
  45. package/lib/proxy-url-compat.js +3 -10
  46. package/lib/public-config.js +23 -44
  47. package/lib/public-entry.d.ts +148 -0
  48. package/lib/public-entry.js +17 -4
  49. package/lib/replay-delegation.js +12 -7
  50. package/lib/replay-envelope-v2-compat.js +12 -7
  51. package/lib/runtime-composition.js +22 -4
  52. package/lib/screenshot-source-boundary.js +2 -2
  53. package/lib/session-affinity-runtime.js +113 -97
  54. package/lib/session-affinity.js +89 -76
  55. package/lib/session-event-history-compat.js +30 -0
  56. package/lib/session-query-readers.js +263 -0
  57. package/lib/session-surface-compat.js +30 -31
  58. package/lib/session-surface-policy-domain.js +85 -0
  59. package/lib/session-surface-policy.js +2 -111
  60. package/lib/session-turn-resolver.js +2 -6
  61. package/lib/session-vision-attachment-index.js +143 -0
  62. package/lib/session-vision-delegation-boundary.js +34 -0
  63. package/lib/session-vision-delegation.js +22 -0
  64. package/lib/session-vision-index.js +25 -107
  65. package/lib/session-vision-mode-authority.js +229 -192
  66. package/lib/session-vision-mode-boundary.js +65 -22
  67. package/lib/session-vision-policy-domain.js +304 -0
  68. package/lib/session-vision-policy.js +104 -0
  69. package/lib/session-vision-state.js +368 -378
  70. package/lib/settings-client-017-compat.js +9 -7
  71. package/lib/structured-flow-hardening.js +22 -4
  72. package/lib/tesseract-exec-compat.js +9 -1
  73. package/lib/turn-budget-context.js +47 -41
  74. package/lib/update-check.js +11 -2
  75. package/lib/vision-attachment-handle-runtime.js +176 -156
  76. package/lib/vision-backend-runtime-policy.js +16 -0
  77. package/lib/vision-background-benchmark.js +41 -4
  78. package/lib/vision-background-failure-policy.js +41 -41
  79. package/lib/vision-background-stop-store-core.js +217 -0
  80. package/lib/vision-background-stop-store.js +8 -179
  81. package/lib/vision-capability-benchmark.js +11 -61
  82. package/lib/vision-capability-evidence.js +35 -0
  83. package/lib/vision-capability-fingerprint.js +72 -0
  84. package/lib/vision-capability-identity.js +116 -61
  85. package/lib/vision-capability-router.js +13 -33
  86. package/lib/vision-chunk-assembler.js +95 -0
  87. package/lib/vision-diagnostics-routes.js +34 -4
  88. package/lib/vision-execution-order-apply.js +45 -55
  89. package/lib/vision-execution-order.js +19 -19
  90. package/lib/vision-execution-policy.js +12 -7
  91. package/lib/vision-model-registry.js +30 -17
  92. package/lib/vision-provider-transport.js +137 -147
  93. package/lib/vision-routing-authority.js +47 -48
  94. package/lib/vision-routing-product.js +26 -29
  95. package/lib/vision-routing-settings-prelude.js +8 -3
  96. package/lib/vision-runtime-performance-store.js +166 -0
  97. package/lib/vision-runtime-performance.js +13 -142
  98. package/lib/vision-tool-runtime-boundary.js +99 -30
  99. package/lib/web/dsh-settings-017-root-transport.js +27 -12
  100. package/lib/web/remote-settings-client.js +4 -7
  101. package/lib/web-capability-boundary.js +17 -7
  102. package/lib/wrapper-directory.js +14 -23
  103. package/package.json +37 -11
@@ -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.