@thomasminh1995/depverdict 0.6.0-alpha.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 (252) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +518 -0
  3. package/bin/depverdict.js +7 -0
  4. package/bin/upgradelens.js +7 -0
  5. package/docs/GR-01-Semantic-Grounding-Failure-Analysis.md +309 -0
  6. package/docs/GR-02-Versioned-Action-Evaluation-Criteria.md +187 -0
  7. package/docs/GR-03-Extractive-Contract-Safety-Experiment.md +242 -0
  8. package/docs/GR-04-Versioned-Production-Extractive-Contract.md +154 -0
  9. package/docs/IA-01-Repository-Usage-Discovery.md +122 -0
  10. package/docs/IA-02-Repository-Impact-Analysis.md +118 -0
  11. package/docs/IA-03-Repository-Impact-Evidence.md +160 -0
  12. package/docs/IA-04-CLI-Orchestration.md +235 -0
  13. package/docs/IA-05-Real-Provider-Validation.md +235 -0
  14. package/docs/IA-05-VinGrade-Validation.md +339 -0
  15. package/docs/MVP-01.md +48 -0
  16. package/docs/MVP-02-Architecture.md +536 -0
  17. package/docs/MVP-02-CLI-HTTP-Runtime.md +50 -0
  18. package/docs/MVP-02-HTTP-Lifecycle.md +37 -0
  19. package/docs/MVP-02-Knowledge-Manifest-Generation.md +75 -0
  20. package/docs/MVP-02-Knowledge-Manifest.md +279 -0
  21. package/docs/MVP-02-Knowledge-Research-Orchestration.md +62 -0
  22. package/docs/MVP-02-Knowledge-Store.md +87 -0
  23. package/docs/MVP-02-PyPI-Registry-Adapter.md +97 -0
  24. package/docs/MVP-02-Research-Planning.md +196 -0
  25. package/docs/MVP-02-Source-Provenance.md +81 -0
  26. package/docs/MVP-02-npm-Registry-Adapter.md +99 -0
  27. package/docs/RR-01-End-to-End-and-Real-Provider-Validation.md +393 -0
  28. package/docs/RR-01-RERUN-Extractive-Contract-Validation.md +566 -0
  29. package/docs/RR-02-Full-Product-Workflow-and-Developer-CLI-UX-Review.md +35 -0
  30. package/docs/RR02-FIX-01-Persistent-Qualification-Resolution.md +32 -0
  31. package/docs/RR02-FIX-02-Stage-aware-CLI-Progress-and-Heartbeat.md +28 -0
  32. package/docs/RR02-FIX-03-npm-Capture-Evidence-Exclusion.md +33 -0
  33. package/docs/RR02-FIX-03A-Complete-Package-Exclusion-and-Evidence-Commit.md +223 -0
  34. package/docs/RR02-FIX-04-Event-loop-safe-Heartbeat.md +393 -0
  35. package/docs/RR02-FIX-05-Materialize-Persisted-Qualification.md +207 -0
  36. package/docs/RR02-RERUN-CLI-Qualification-Progress-UX-and-Package-Validation.md +342 -0
  37. package/docs/VinGrade-MVP-02-Validation.md +480 -0
  38. package/docs/VinGrade-RC02-Live-Validation.md +273 -0
  39. package/docs/ai-capability-discovery.md +573 -0
  40. package/docs/ai-engineering-production-readiness.md +390 -0
  41. package/docs/ai-engineering-review.md +251 -0
  42. package/docs/ai-runtime-governance-discovery.md +754 -0
  43. package/docs/architecture-overview.md +78 -0
  44. package/docs/cli-progress.md +111 -0
  45. package/docs/decisions/diff-01-brand-distribution-identity.md +450 -0
  46. package/docs/decisions/diff-02-identity-compatibility-contract.md +274 -0
  47. package/docs/decisions/diff-03-repository-docs-community-migration.md +165 -0
  48. package/docs/decisions/diff-04-release-evidence-gap-acceptance.md +110 -0
  49. package/docs/discovery/mvp-05-ai-migration-planning-discovery.md +350 -0
  50. package/docs/gateway-runtime-discovery.md +614 -0
  51. package/docs/live-ai-validation.md +299 -0
  52. package/docs/migration-planning-qualification-resolution.md +99 -0
  53. package/docs/migrations/upgradelens-to-depverdict.md +97 -0
  54. package/docs/mp-r03-deterministic-upgrade-decision-architecture.md +135 -0
  55. package/docs/mp-r04-evidence-bounded-migration-handoff-architecture.md +116 -0
  56. package/docs/mp-r05-product-completion-and-decision-first-cli-architecture.md +162 -0
  57. package/docs/mvp-05-deterministic-context-runtime.md +127 -0
  58. package/docs/mvp-05-migration-checklist-contract.md +166 -0
  59. package/docs/mvp-05-migration-checklist-orchestration.md +105 -0
  60. package/docs/mvp-05-migration-evaluation-and-qualification.md +135 -0
  61. package/docs/mvp-05-provider-neutral-generator.md +79 -0
  62. package/docs/ollama-local-smoke-validation.md +156 -0
  63. package/docs/openai-compatible-runtime-discovery.md +789 -0
  64. package/docs/openrouter-one-dependency-validation.md +205 -0
  65. package/docs/oss-02-package-guard-hardening-architecture.md +131 -0
  66. package/docs/oss-04-public-ci-package-metadata-architecture.md +142 -0
  67. package/docs/package-content-policy.md +98 -0
  68. package/docs/releases/v0.5.0-technical-preview.md +114 -0
  69. package/docs/releases/v0.6.0-alpha.1-depverdict-preview.md +101 -0
  70. package/docs/reviews/diff-02-identity-contract-compatibility.md +413 -0
  71. package/docs/reviews/diff-03-repository-docs-community-migration.md +364 -0
  72. package/docs/reviews/diff-04-depverdict-distribution-identity-readiness-rereview.md +453 -0
  73. package/docs/reviews/diff-04-fix-post-rename-identity-release-remediation.md +310 -0
  74. package/docs/reviews/diff-05-final-preview-distribution-qualification.md +561 -0
  75. package/docs/reviews/mvp-05-final-product-value-workflow-rereview.md +471 -0
  76. package/docs/reviews/mvp-05-product-workflow-review.md +605 -0
  77. package/docs/reviews/oss-01-duplicate-artifact-investigation-cleanup.md +411 -0
  78. package/docs/reviews/oss-02-package-guard-hardening.md +303 -0
  79. package/docs/reviews/oss-03-community-scaffolding.md +378 -0
  80. package/docs/reviews/oss-04-public-ci-package-metadata.md +439 -0
  81. package/docs/reviews/oss-05-technical-preview-qualification.md +482 -0
  82. package/docs/reviews/upgradelens-vs-upgradedepdetective-source-comparison.md +355 -0
  83. package/docs/reviews/v0.5.0-pre-release-smoke.md +263 -0
  84. package/docs/reviews/v0.5.0-version-bump-release-verification.md +306 -0
  85. package/docs/runtime-contract-discovery.md +521 -0
  86. package/docs/structured-output-compatibility-report.md +100 -0
  87. package/docs/ts-fix-01-exact-duplicate-occurrence-target-selection-architecture.md +111 -0
  88. package/docs/version-analysis-architecture.md +827 -0
  89. package/eval/README.md +86 -0
  90. package/eval/datasets/generic/declared-constraint.json +59 -0
  91. package/eval/datasets/generic/evidence-conflict.json +73 -0
  92. package/eval/datasets/generic/major-breaking-release.json +66 -0
  93. package/eval/datasets/generic/missing-evidence.json +46 -0
  94. package/eval/datasets/generic/patch-release-low.json +59 -0
  95. package/eval/datasets/node/axios-patch-low.json +59 -0
  96. package/eval/datasets/node/react-major-breaking.json +66 -0
  97. package/eval/datasets/node/react-minor-compatibility.json +66 -0
  98. package/eval/datasets/python/fastapi-deprecation.json +66 -0
  99. package/eval/datasets/python/pydantic-major-breaking.json +66 -0
  100. package/eval/migration-planning/golden-dataset-v2.json +306 -0
  101. package/eval/migration-planning/golden-dataset.json +214 -0
  102. package/eval/schemas/expected-result.schema.json +88 -0
  103. package/eval/schemas/golden-case.schema.json +181 -0
  104. package/package.json +57 -0
  105. package/schemas/ai-scorecard.schema.json +132 -0
  106. package/schemas/benchmark-report.schema.json +189 -0
  107. package/schemas/benchmark.schema.json +55 -0
  108. package/schemas/capability-profile.schema.json +44 -0
  109. package/schemas/conformance-report.schema.json +150 -0
  110. package/schemas/deployment-profile.schema.json +64 -0
  111. package/schemas/evaluation-report.schema.json +158 -0
  112. package/schemas/knowledge-evidence-bundle.schema.json +150 -0
  113. package/schemas/knowledge-manifest.schema.json +548 -0
  114. package/schemas/metrics.schema.json +178 -0
  115. package/schemas/migration-checklist-extractive-candidate.schema.json +42 -0
  116. package/schemas/migration-checklist.schema.json +706 -0
  117. package/schemas/migration-evaluation-dataset-v2.schema.json +208 -0
  118. package/schemas/migration-evaluation-dataset.schema.json +204 -0
  119. package/schemas/migration-planning-qualification-record.schema.json +234 -0
  120. package/schemas/project-manifest.schema.json +308 -0
  121. package/schemas/qualification-record.schema.json +56 -0
  122. package/schemas/repository-impact-evidence.schema.json +232 -0
  123. package/schemas/repository-impact.schema.json +202 -0
  124. package/schemas/upgrade-decision.schema.json +273 -0
  125. package/schemas/usage-index.schema.json +179 -0
  126. package/schemas/version-analysis.schema.json +449 -0
  127. package/src/ai-runtime-debug.js +325 -0
  128. package/src/ai-runtime-error.js +42 -0
  129. package/src/ai-runtime.js +174 -0
  130. package/src/ai-scorecard.js +204 -0
  131. package/src/ai-version-analysis.js +484 -0
  132. package/src/artifact-root-compatibility.js +91 -0
  133. package/src/benchmark-report.js +111 -0
  134. package/src/benchmark-runner.js +191 -0
  135. package/src/canonical-json.js +69 -0
  136. package/src/cli.js +1299 -0
  137. package/src/conformance-report.js +158 -0
  138. package/src/conformance-runner.js +253 -0
  139. package/src/constants.js +73 -0
  140. package/src/cooperative-scheduler.js +79 -0
  141. package/src/dependencies.js +44 -0
  142. package/src/dependency-ai-context.js +625 -0
  143. package/src/detectors.js +253 -0
  144. package/src/discovery.js +234 -0
  145. package/src/ecosystem-version-adapter.js +294 -0
  146. package/src/environment-compatibility.js +77 -0
  147. package/src/evaluation-comparator.js +158 -0
  148. package/src/evaluation-report.js +76 -0
  149. package/src/evaluation-runner.js +248 -0
  150. package/src/evidence-source-adapter.js +472 -0
  151. package/src/files.js +89 -0
  152. package/src/governance-diagnostics.js +64 -0
  153. package/src/governance-loader.js +63 -0
  154. package/src/governance-metadata.js +346 -0
  155. package/src/governance-validator.js +360 -0
  156. package/src/http/bounded-fetch.js +278 -0
  157. package/src/http/cli-http-runtime.js +44 -0
  158. package/src/impact/input-loader.js +157 -0
  159. package/src/impact/matcher.js +40 -0
  160. package/src/impact/repository-impact.js +199 -0
  161. package/src/impact/runtime.js +24 -0
  162. package/src/impact/status.js +62 -0
  163. package/src/impact/writer.js +30 -0
  164. package/src/impact-evidence/input-loader.js +202 -0
  165. package/src/impact-evidence/repository-impact-evidence.js +234 -0
  166. package/src/impact-evidence/runtime.js +16 -0
  167. package/src/impact-evidence/writer.js +30 -0
  168. package/src/index.js +563 -0
  169. package/src/installed-version-baseline.js +196 -0
  170. package/src/knowledge-cache.js +324 -0
  171. package/src/knowledge-evidence-bundle.js +101 -0
  172. package/src/knowledge-evidence-producer.js +233 -0
  173. package/src/knowledge-manifest-builder.js +188 -0
  174. package/src/knowledge-manifest-writer.js +32 -0
  175. package/src/knowledge-manifest.js +255 -0
  176. package/src/knowledge-research.js +615 -0
  177. package/src/metrics-engine.js +205 -0
  178. package/src/migration-checklist/ai-candidate.js +320 -0
  179. package/src/migration-checklist/assembler.js +37 -0
  180. package/src/migration-checklist/context-runtime.js +828 -0
  181. package/src/migration-checklist/evaluation/action-criteria.js +244 -0
  182. package/src/migration-checklist/evaluation/comparator-v2.js +332 -0
  183. package/src/migration-checklist/evaluation/comparator.js +279 -0
  184. package/src/migration-checklist/evaluation/dataset-v2.js +227 -0
  185. package/src/migration-checklist/evaluation/dataset.js +336 -0
  186. package/src/migration-checklist/evaluation/extractive-fixtures-v2.js +148 -0
  187. package/src/migration-checklist/evaluation/metrics-v2.js +226 -0
  188. package/src/migration-checklist/evaluation/metrics.js +158 -0
  189. package/src/migration-checklist/evaluation/qualification-v2.js +321 -0
  190. package/src/migration-checklist/evaluation/qualification.js +239 -0
  191. package/src/migration-checklist/evaluation/runner-v2.js +294 -0
  192. package/src/migration-checklist/evaluation/runner.js +194 -0
  193. package/src/migration-checklist/evaluation/scorecard-v2.js +106 -0
  194. package/src/migration-checklist/evaluation/scorecard.js +86 -0
  195. package/src/migration-checklist/extractive-candidate.js +166 -0
  196. package/src/migration-checklist/extractive-prompt.js +62 -0
  197. package/src/migration-checklist/generator.js +702 -0
  198. package/src/migration-checklist/grounding-policy.js +117 -0
  199. package/src/migration-checklist/input-loader.js +613 -0
  200. package/src/migration-checklist/migration-checklist.js +635 -0
  201. package/src/migration-checklist/presentation.js +292 -0
  202. package/src/migration-checklist/progress.js +96 -0
  203. package/src/migration-checklist/prompt.js +83 -0
  204. package/src/migration-checklist/qualification-guard.js +462 -0
  205. package/src/migration-checklist/qualification-resolution.js +122 -0
  206. package/src/migration-checklist/qualification-store.js +225 -0
  207. package/src/migration-checklist/runtime.js +205 -0
  208. package/src/migration-checklist/verification.js +134 -0
  209. package/src/migration-checklist/writer.js +35 -0
  210. package/src/openai-compatible-provider.js +451 -0
  211. package/src/orchestration/failure-log.js +32 -0
  212. package/src/orchestration/pipeline.js +200 -0
  213. package/src/orchestration/progress-events.js +337 -0
  214. package/src/orchestration/progress-reporter.js +131 -0
  215. package/src/orchestration/text-writer.js +22 -0
  216. package/src/portable.js +13 -0
  217. package/src/product-completion.js +249 -0
  218. package/src/project-manifest-input.js +90 -0
  219. package/src/project-manifest.js +141 -0
  220. package/src/python-requirements.js +137 -0
  221. package/src/registry/npm-packument.js +256 -0
  222. package/src/registry/npm-registry-adapter.js +262 -0
  223. package/src/registry/pypi-project.js +300 -0
  224. package/src/registry/pypi-registry-adapter.js +235 -0
  225. package/src/registry/sanitize-registry-body.js +51 -0
  226. package/src/renderers/console.js +160 -0
  227. package/src/renderers/impact-presentation.js +278 -0
  228. package/src/renderers/markdown.js +172 -0
  229. package/src/research-plan.js +455 -0
  230. package/src/runtime-conformance.js +275 -0
  231. package/src/source-provenance.js +393 -0
  232. package/src/source-url.js +62 -0
  233. package/src/structured-output-schema.js +66 -0
  234. package/src/target-selector.js +306 -0
  235. package/src/upgrade-decision/input-loader.js +107 -0
  236. package/src/upgrade-decision/presentation.js +43 -0
  237. package/src/upgrade-decision/runtime.js +21 -0
  238. package/src/upgrade-decision/upgrade-decision.js +626 -0
  239. package/src/upgrade-decision/writer.js +30 -0
  240. package/src/usage/analyzer-registry.js +63 -0
  241. package/src/usage/coverage.js +116 -0
  242. package/src/usage/input-loader.js +139 -0
  243. package/src/usage/js/analyzer.js +240 -0
  244. package/src/usage/js/parser.js +21 -0
  245. package/src/usage/runtime.js +187 -0
  246. package/src/usage/scope.js +44 -0
  247. package/src/usage/source-files.js +50 -0
  248. package/src/usage/usage-index.js +217 -0
  249. package/src/usage/writer.js +31 -0
  250. package/src/version-analysis-loader.js +203 -0
  251. package/src/version-analysis-manifest.js +314 -0
  252. package/src/version-analysis-writer.js +30 -0
@@ -0,0 +1,754 @@
1
+ # LR-00C — AI Runtime Governance Discovery
2
+
3
+ **Status:** Architecture discovery only
4
+
5
+ **Ngày:** 2026-07-15
6
+
7
+ **Phạm vi:** Governance cho MVP-03 Version Analysis, MVP-04 Impact Analysis và MVP-05 Migration Planning. Tài liệu này không triển khai governance tooling hoặc thay đổi behavior hiện tại.
8
+
9
+ ## 1. Executive Summary
10
+
11
+ Ba discovery trước đã trả lời ba câu hỏi khác nhau:
12
+
13
+ - [`openai-compatible-runtime-discovery.md`](./openai-compatible-runtime-discovery.md) xác định transport protocol-first nhỏ nhất;
14
+ - [`gateway-runtime-discovery.md`](./gateway-runtime-discovery.md) xác định routing/fallback có thể làm mất reproducibility và quality equivalence;
15
+ - [`ai-capability-discovery.md`](./ai-capability-discovery.md) xác định capability cần có và model shortlist.
16
+
17
+ Discovery và benchmark vẫn chưa đủ để vận hành runtime lâu dài. Discovery là ảnh chụp từ documentation tại một thời điểm; benchmark chỉ đo một run configuration nếu configuration đó thực sự đúng và ổn định. Cả hai không tự chứng minh endpoint đã giữ exact JSON Schema, model alias không đổi, gateway không fallback, runtime không transform prompt, usage/finish reason có thể audit, hoặc deployment hiện tại vẫn giống deployment đã benchmark.
18
+
19
+ Repository hiện có foundation tốt nhưng chưa có governance boundary:
20
+
21
+ - [`src/ai-runtime.js`](../src/ai-runtime.js) chỉ yêu cầu `generateStructured(request)`; không kiểm tra model capability, exact revision, fallback hoặc routing.
22
+ - [`src/ai-version-analysis.js`](../src/ai-version-analysis.js) parse JSON, validate candidate schema, allowlist evidence references/URLs và áp human-review policy. Không có `src/trust-*.js` riêng; trust boundary hiện nằm trong module này.
23
+ - [`src/evaluation-runner.js`](../src/evaluation-runner.js) chạy cùng analysis/trust path trên Golden Dataset.
24
+ - [`src/benchmark-runner.js`](../src/benchmark-runner.js) thu quality score cùng latency/token/cost cơ bản, nhưng runtime settings hiện là object mở và chưa chứng nhận identity/capability.
25
+ - [`docs/live-ai-validation.md`](./live-ai-validation.md) xác nhận real evidence đã tới AI boundary nhưng chưa có live model call; do đó hiện chưa model/deployment nào được production-certified.
26
+
27
+ Governance layer tối thiểu cần ba chức năng:
28
+
29
+ ```text
30
+ Capability Discovery
31
+ ↓ declared metadata
32
+ Capability Conformance
33
+ ↓ observed contract
34
+ Model Qualification
35
+ ↓ task-scoped decision
36
+ Production Runtime
37
+ ```
38
+
39
+ Quyết định kiến trúc:
40
+
41
+ 1. **Capability Registry** là tập JSON portable, source-controlled, mô tả “model/API được document là có thể làm gì”. Nó không được runtime tự scan để chọn model.
42
+ 2. **Deployment Profile** là JSON portable mô tả exact tuple “sẽ chạy như thế nào”. Nó không chứa secret.
43
+ 3. **Conformance Report** chứng minh tuple đó thực hiện đúng protocol/structured-output/identity/error contract. Conformance không chấm reasoning quality.
44
+ 4. **Qualification Record** liên kết exact capability profile, deployment profile, conformance report, dataset/prompt/schema và quality artifacts để quyết định trạng thái theo từng task.
45
+
46
+ Không cần database, service, plugin system, dynamic registry hay enterprise policy engine. Static files + deterministic validation + existing Evaluation/Metrics/Scorecard/Benchmark là đủ.
47
+
48
+ Trạng thái hiện tại theo thiết kế này:
49
+
50
+ - mọi real model/deployment: tối đa **EXPERIMENTAL**, vì chưa có live conformance và real model benchmark;
51
+ - golden fake runtime: dùng để regression test foundation, không phải model qualification candidate;
52
+ - chưa deployment nào **CERTIFIED** cho MVP-03;
53
+ - MVP-04/MVP-05 chưa có task-specific evaluation contract, nên chưa thể certification dù một model sau này pass MVP-03.
54
+
55
+ ## 2. Capability Conformance Test
56
+
57
+ ### Mục tiêu
58
+
59
+ Capability Conformance là tầng fail-fast giữa documentation và quality benchmark:
60
+
61
+ ```text
62
+ Capability Discovery
63
+
64
+ Capability Conformance
65
+ ↓ only conformant deployments
66
+ Golden Benchmark
67
+ ↓ only quality-qualified deployments
68
+ Production
69
+ ```
70
+
71
+ Nó trả lời câu hỏi: **exact deployment tuple có thực hiện contract mà benchmark sắp dựa vào hay không?** Nó không trả lời model có phân tích release note tốt hay không.
72
+
73
+ ### Boundary
74
+
75
+ Conformance được phép kiểm tra:
76
+
77
+ - profile/schema metadata hợp lệ;
78
+ - request mapping, protocol, auth mode và `stream: false`;
79
+ - exact final structured-output mode và JSON Schema keyword behavior;
80
+ - response envelope, output extraction, model/provider identity;
81
+ - finish reason, truncation, refusal, empty output;
82
+ - usage metadata, timeout, rate limit, model missing và sanitized errors;
83
+ - routing/fallback/transform policy;
84
+ - task-required operating context/output budget;
85
+ - Unicode/multilingual transport integrity.
86
+
87
+ Conformance không được:
88
+
89
+ - dùng release risk accuracy, evidence entailment hoặc migration quality làm pass/fail;
90
+ - sửa prompt, candidate schema hoặc trust behavior để làm endpoint pass;
91
+ - tự downgrade `jsonSchema → jsonMode → promptOnly`;
92
+ - auto-select model/provider;
93
+ - ghi secret, full prompt/evidence hoặc raw provider body vào portable report;
94
+ - thay thế Golden Benchmark hoặc real-repository validation.
95
+
96
+ ### Input và artifacts
97
+
98
+ | Input | Vai trò |
99
+ | --- | --- |
100
+ | Capability Profile digest | Các capability được documentation khai báo. |
101
+ | Candidate Deployment Profile digest | Exact endpoint/runtime/model/config cần kiểm tra. |
102
+ | Conformance Specification version | Bộ case và required/optional policy. |
103
+ | Task ID | `version-analysis.v1`, sau này `impact-analysis.v1`, `migration-planning.v1`. |
104
+ | Exact task schema digest | Schema thực tế cần endpoint chấp nhận. |
105
+
106
+ Output portable là **Capability Conformance Report**, không phải Evaluation Report:
107
+
108
+ ```json
109
+ {
110
+ "schemaVersion": "1.0.0",
111
+ "specVersion": "runtime-conformance.v1",
112
+ "task": "version-analysis.v1",
113
+ "capabilityProfileDigest": "sha256:...",
114
+ "deploymentProfileDigest": "sha256:...",
115
+ "taskSchemaDigest": "sha256:...",
116
+ "result": "PASS",
117
+ "cases": [],
118
+ "observed": {
119
+ "actualModel": "...",
120
+ "actualProvider": "...",
121
+ "structuredOutputMode": "jsonSchema",
122
+ "fallbackOccurred": false,
123
+ "transforms": []
124
+ },
125
+ "limitations": []
126
+ }
127
+ ```
128
+
129
+ Report chỉ lưu bounded observations/digests. Raw request/response có thể tồn tại tạm trong opt-in diagnostic nhưng không phải portable artifact và không được chứa secret.
130
+
131
+ ### Case result và overall pass/fail
132
+
133
+ Mỗi case có một trong bốn kết quả:
134
+
135
+ - `PASS`: observed behavior đúng expectation;
136
+ - `FAIL`: contract sai hoặc fail-closed behavior sai;
137
+ - `NOT_APPLICABLE`: capability không thuộc task/profile và spec cho phép bỏ;
138
+ - `NOT_RUN`: test không chạy; chỉ hợp lệ với optional case, không hợp lệ với required case.
139
+
140
+ Overall `PASS` chỉ khi:
141
+
142
+ 1. tất cả required cases là `PASS`;
143
+ 2. không required case nào `NOT_RUN`/`NOT_APPLICABLE`;
144
+ 3. actual model/provider match deployment policy;
145
+ 4. không hidden fallback, routing hoặc prompt/response transform;
146
+ 5. exact task schema được giữ ở configured mode;
147
+ 6. mọi negative case fail closed và error được sanitize;
148
+ 7. report validate, canonicalize và có digest ổn định ngoài timestamp/observations được khai báo variable.
149
+
150
+ Một `FAIL` không được retry bằng model/mode yếu hơn rồi gộp thành pass. Retry cùng exact tuple chỉ được phép nếu Deployment Profile đã khai báo và conformance report ghi mọi attempt.
151
+
152
+ ### Acceptance Criteria cho specification
153
+
154
+ - Conformance đứng trước benchmark và không gọi Evaluation Runner.
155
+ - Dùng cùng exact schema mà production task dùng; không dùng schema demo đơn giản làm certification proof.
156
+ - Có mocked protocol suite chạy offline/default CI và opt-in live suite tách biệt.
157
+ - Live suite không tự tải model, tạo account, đọc API key từ file hoặc chạy paid call ngoài explicit operator action.
158
+ - Report phân biệt declared capability với observed behavior.
159
+ - Conformance pass chỉ cấp quyền vào smoke/benchmark; không cấp quyền production.
160
+
161
+ ## 3. Capability Registry
162
+
163
+ ### Vai trò
164
+
165
+ Capability Registry là metadata inventory source-controlled:
166
+
167
+ ```text
168
+ governance/ai/capabilities/
169
+ gpt-5.6-sol.json
170
+ claude-sonnet-5.json
171
+ gemini-2.5-pro.json
172
+ qwen3-8b.json
173
+ ```
174
+
175
+ Đường dẫn chỉ là recommendation cho task triển khai sau; LR-00C không tạo registry files. Registry được load bằng explicit path/list trong qualification tooling. Production runtime không scan directory, không query database và không auto-pick “best” model.
176
+
177
+ ### Capability Profile tối thiểu
178
+
179
+ ```json
180
+ {
181
+ "schemaVersion": "1.0.0",
182
+ "id": "claude-sonnet-5",
183
+ "subject": {
184
+ "family": "claude-sonnet",
185
+ "modelId": "claude-sonnet-5",
186
+ "revisionSemantics": "providerPinnedId"
187
+ },
188
+ "capabilities": {
189
+ "structuredOutput": {
190
+ "modes": ["jsonSchema"],
191
+ "jsonSchemaSupport": "subset",
192
+ "toolSchemaStrict": true
193
+ },
194
+ "context": {
195
+ "inputTokens": 1000000,
196
+ "outputTokens": 128000
197
+ },
198
+ "toolCalling": true,
199
+ "citation": "nativeAvailable",
200
+ "multilingual": true,
201
+ "reasoning": {
202
+ "supported": true,
203
+ "mode": "adaptive"
204
+ },
205
+ "transport": {
206
+ "protocols": ["anthropicMessages"],
207
+ "streaming": true,
208
+ "finishReason": true,
209
+ "usageMetadata": true
210
+ }
211
+ },
212
+ "constraints": {
213
+ "temperature": "defaultOnly",
214
+ "assistantPrefill": false
215
+ },
216
+ "evidence": [
217
+ {
218
+ "kind": "officialDocumentation",
219
+ "url": "https://...",
220
+ "checkedAt": "2026-07-15"
221
+ }
222
+ ]
223
+ }
224
+ ```
225
+
226
+ Đây là ví dụ shape, không phải file được tạo hoặc schema được chốt trong task này.
227
+
228
+ ### Field policy
229
+
230
+ Registry nên mô tả:
231
+
232
+ - model family, exact public ID và revision semantics;
233
+ - supported protocols/endpoints ở mức logical offering;
234
+ - final structured-output modes, JSON Schema support/subset, JSON mode;
235
+ - tool calling/strict tool arguments;
236
+ - context input/output limits;
237
+ - reasoning/thinking modes và defaults;
238
+ - temperature/top-p/seed constraints;
239
+ - streaming support, finish reason, usage metadata;
240
+ - native citation/grounding availability;
241
+ - multilingual declaration;
242
+ - known documentation limitations;
243
+ - official evidence URLs, checked date và confidence/source type.
244
+
245
+ Registry không chứa:
246
+
247
+ - prompt text hoặc prompt version;
248
+ - benchmark/evaluation score, latency sample, cost result hoặc ranking;
249
+ - endpoint URL, API key, Authorization, account hoặc secret reference;
250
+ - gateway routing, timeout, retry, quantization hoặc runtime flags;
251
+ - vendor-specific executable logic;
252
+ - qualification/certification decision;
253
+ - claims suy ra từ unofficial benchmark.
254
+
255
+ ### Registry invariants
256
+
257
+ 1. Một profile mô tả một logical model offering/revision semantics; không gộp DeepSeek V4 API với DeepSeek V3.2 weights hoặc nhiều Qwen quantization.
258
+ 2. Alias mutable phải ghi `revisionSemantics: mutableAlias`; không được giả thành exact revision.
259
+ 3. “Supported” trong registry nghĩa là official documentation khai báo, không phải UpgradeLens đã chứng nhận.
260
+ 4. Capability không được default từ family name. Missing field là `unknown`, không phải `false` hoặc `supported`.
261
+ 5. Thay capability/source tạo profile revision/digest mới và trigger requalification cho deployment liên quan.
262
+ 6. Registry không phải runtime allowlist. Production eligibility chỉ đến từ Qualification Record.
263
+
264
+ ### Vì sao không hard-code
265
+
266
+ Hard-code capability trong adapter (`if model === ...`) sẽ trộn documentation lifecycle với transport logic, buộc release code khi model đổi và làm local/gateway deployment khó so sánh. Portable profile cho phép review diff, pin digest và re-run conformance mà không đổi Version Analysis core.
267
+
268
+ ## 4. Capability Conformance Suite
269
+
270
+ Suite nên có hai lớp dùng cùng case IDs:
271
+
272
+ - **offline protocol conformance:** fake HTTP/runtime fixtures, chạy CI, không gọi model;
273
+ - **opt-in live deployment conformance:** chạy trên exact Deployment Profile, có explicit operator authorization; không chạy default CI.
274
+
275
+ ### Nhóm test chuẩn
276
+
277
+ | Group | Required cases | Pass condition |
278
+ | --- | --- | --- |
279
+ | Profile integrity | schema/version, digest, exact identity, no secret, task binding | Profiles validate; mutable/unknown identity bị policy đánh dấu đúng. |
280
+ | Request contract | protocol endpoint, model, messages/input, `stream:false`, schema mode | Adapter-owned fields không bị extras override; one request mode. |
281
+ | Basic JSON | object parse, no markdown/prose wrapper | Output parse được theo configured mode. |
282
+ | JSON Schema | exact task schema accepted; dialect/subset recorded | Endpoint không silently drop/rewrite schema. |
283
+ | Required fields | bỏ từng required field | Negative output bị constrained hoặc local validation reject fail-closed. |
284
+ | Enum | invalid `riskLevel`/kind | Invalid enum không được publish. |
285
+ | Additional properties | top-level và nested extra field | `additionalProperties:false` được endpoint hoặc local validator enforce. |
286
+ | Nested objects | `findings[]` shape | Nested required/type/ref structure giữ đúng. |
287
+ | Arrays | empty/non-empty, `minItems`, `uniqueItems`, ordering-independent refs | Exact candidate rules được local validator giữ. |
288
+ | String constraints | evidence digest `pattern`, non-empty summary | Invalid values không publish. |
289
+ | Unicode | Vietnamese, package scope, emoji/non-ASCII evidence | Request/response round-trip không corrupt text/IDs. |
290
+ | Operating context | task-required context size, không phải marketing maximum | Không truncate input; token count/limit behavior quan sát được. |
291
+ | Large output | output gần configured task budget | Complete JSON hoặc explicit `length`/truncation failure; không partial publish. |
292
+ | Finish reason | stop, length, refusal, content filter, tool-only | Chỉ accepted finish state được parse; trạng thái khác fail rõ. |
293
+ | Usage | present/absent/partial usage | Normalize khi có; absence là `null`, không fabricate zero. |
294
+ | Identity | requested vs actual model/provider | Match policy; unknown/mismatch fail. |
295
+ | Routing | zero/multiple attempts, fallback metadata | Benchmark profile chỉ pass zero unexpected fallback. |
296
+ | Transform | prompt/response/plugin pipeline flags | Không transform trong baseline; unknown transform fail. |
297
+ | Streaming disabled | endpoint respects non-streaming | Một bounded response envelope; SSE bất ngờ fail. |
298
+ | Empty/invalid response | empty content, malformed envelope/JSON | Stable invalid-response/output error; no claim published. |
299
+ | Truncation | `finish_reason=length`, context overflow, body cutoff | Distinct failure; không gọi là schema support failure. |
300
+ | Error handling | structured/unstructured 4xx/5xx | Stable sanitized category; raw body/prompt không leak. |
301
+ | Auth | no-auth local, mocked 401/403, configured auth mode | Header policy đúng; error/redaction đúng; report không chứa value. |
302
+ | Model missing | 404/stable provider error | `MODEL_NOT_FOUND`-class failure, không thành output schema error. |
303
+ | Rate limit | 429 + bounded `Retry-After` | Retry đúng declared policy/same tuple hoặc fail; không route khác. |
304
+ | Timeout | connect/read/inference deadline | Abort bounded; stable timeout; không auto-switch model. |
305
+ | Response size | oversized success/error body | Abort/reject bounded; no raw body persistence. |
306
+
307
+ ### Task-specific requirements
308
+
309
+ Conformance spec không nên thử toàn bộ advertised 1M context. Nó kiểm tra **operating envelope của task**:
310
+
311
+ | Task | Initial conformance envelope |
312
+ | --- | --- |
313
+ | `version-analysis.v1` | Exact current candidate schema; minimum 32K input capability; bounded context tương đương current selector + headroom; non-streaming structured result. |
314
+ | `impact-analysis.v1` | Chỉ định nghĩa sau khi MVP-04 input/output schema và source-fact bundle tồn tại. |
315
+ | `migration-planning.v1` | Chỉ định nghĩa sau khi MVP-05 plan schema, evidence/impact-ref rules và truncation policy tồn tại. |
316
+
317
+ Không dùng MVP-03 schema để “certify trước” MVP-04/05.
318
+
319
+ ### Conformance không phải quality
320
+
321
+ Một model có thể pass mọi case vì grammar-constrained decoding nhưng vẫn invent API hoặc phân loại risk sai. Vì vậy conformance report không chứa `overallScore`, risk accuracy hoặc benchmark ranking. Nó chỉ cho phép candidate đi tiếp.
322
+
323
+ ## 5. Capability Certification
324
+
325
+ Certification là trạng thái của tuple:
326
+
327
+ ```text
328
+ (task, capabilityProfileDigest, deploymentProfileDigest,
329
+ conformanceSpecVersion, promptVersion, taskSchemaDigest,
330
+ datasetVersion, trust/evaluation version)
331
+ ```
332
+
333
+ Không certification model family “cho mọi use case”.
334
+
335
+ ### Trạng thái
336
+
337
+ | Status | Ý nghĩa | Được phép |
338
+ | --- | --- | --- |
339
+ | `NOT_SUPPORTED` | Thiếu capability bắt buộc hoặc conformance hard-fail. | Không smoke quality, không benchmark quality, không production. |
340
+ | `EXPERIMENTAL` | Profile hợp lệ nhưng conformance/smoke/quality evidence chưa đủ hoặc deployment mutable chưa pin. | Discovery và explicit developer experiment; không trusted downstream. |
341
+ | `SUPPORTED` | Conformance + technical smoke pass cho exact deployment/task. | Golden Benchmark và real-repo validation; không production. |
342
+ | `CERTIFIED` | Golden Benchmark, representative real-repo validation và production gate pass cho exact task tuple. | Production allowlist trong phạm vi task/certification validity. |
343
+ | `DEPRECATED` | Vẫn có record lịch sử nhưng có replacement, expiry hoặc trigger requalification chưa hoàn tất. | Không qualification mới; existing production chỉ trong explicit bounded migration policy. |
344
+ | `RETIRED` | Removed, unsafe, unavailable hoặc hard regression. | Bị block cho new runs; chỉ giữ artifacts để audit. |
345
+
346
+ ### Chuyển trạng thái
347
+
348
+ ```text
349
+ New discovery
350
+ ├── missing hard capability ──→ NOT_SUPPORTED
351
+ └── profile valid ────────────→ EXPERIMENTAL
352
+ ↓ conformance + smoke pass
353
+ SUPPORTED
354
+ ↓ all qualification gates pass
355
+ CERTIFIED
356
+ ↓ drift/change/expiry
357
+ DEPRECATED
358
+ ├── requalify pass → CERTIFIED
359
+ └── removal/failure → RETIRED
360
+ ```
361
+
362
+ `NOT_SUPPORTED → EXPERIMENTAL` chỉ sau capability/profile revision mới hoặc conformance specification thay đổi có lý do. Hard security/identity failure có thể đưa bất kỳ state nào thẳng tới `RETIRED`.
363
+
364
+ ### Qualification Record
365
+
366
+ Record portable chứa:
367
+
368
+ - scope tuple/digests ở trên;
369
+ - current status, decision timestamp và optional expiry/review trigger;
370
+ - links/digests đến Conformance Report, smoke evidence, Evaluation Report, Metrics, Scorecard, Benchmark Report và real-repository validation;
371
+ - gates pass/fail và limitations;
372
+ - `supersedes`/previous decision digest khi status đổi;
373
+ - không chứa raw prompt/evidence, secret hoặc benchmark payload duplication.
374
+
375
+ Decision record không được tự sinh `CERTIFIED` chỉ vì `overallScore` cao. Tất cả hard gates và real-repo gate phải pass.
376
+
377
+ ## 6. Model Qualification Pipeline
378
+
379
+ Mỗi stage phải tạo artifact độc lập; stage sau chỉ đọc validated artifact của stage trước.
380
+
381
+ Model qualification phải inject/resolve một explicit runtime từ Deployment Profile. [`runEvaluation`](../src/evaluation-runner.js) hiện chủ ý fallback sang golden fake khi `runtime` vắng; behavior này đúng cho deterministic CI nhưng **không hợp lệ cho qualification**. Workflow phải reject artifact có provider/model `golden-fake`, missing deployment digest hoặc missing observed actual identity trước khi chấm quality gate.
382
+
383
+ | Stage | Input | Output/artifact | Quality gate | Rollback strategy |
384
+ | --- | --- | --- | --- | --- |
385
+ | 1. Discovery | Official docs/model cards + task requirements | Capability Profile | Sources official, checked date, unknowns explicit, no vendor logic | Giữ profile cũ; profile mới không active. |
386
+ | 2. Capability Conformance | Capability + candidate Deployment Profile + spec/schema digest | Conformance Report | All required cases pass; exact identity; no hidden fallback/transform | Candidate stays EXPERIMENTAL; production profile untouched. |
387
+ | 3. Smoke Validation | Conformant deployment + bounded safe fixture | Smoke Report/execution trace | One end-to-end request, local schema/trust path, sanitized metadata | Revert to mocked/offline path; no model substitution. |
388
+ | 4. Golden Benchmark | SUPPORTED tuple + versioned dataset/prompt/schema | Existing Evaluation/Metrics/Scorecard/Benchmark artifacts | Existing hard metrics all pass; no invalid samples/route drift | Keep previous certified tuple; failed candidate not promoted. |
389
+ | 5. Real Repository Validation | Benchmark-passing tuple + representative repositories/evidence | Real Validation Report + trusted artifacts | Real evidence, schema/trust pass, human review confirms usefulness/grounding | Discard candidate outputs; never feed failed results downstream. |
390
+ | 6. Production Qualification | All prior digests + privacy/SLO/ops evidence | Qualification Record `CERTIFIED` | Task-specific quality + privacy + identity + reproducibility gates pass | Active pointer remains previous certified profile. |
391
+ | 7. Continuous Evaluation | Certified tuple + canary/golden subset + runtime telemetry | Drift Evaluation Record | No hard-gate regression, identity/config unchanged | Mark DEPRECATED or RETIRED; fail closed or return to previous certified tuple. |
392
+ | 8. Requalification | Trigger + updated profiles/spec/dataset | New conformance/benchmark/qualification artifacts | Same gates as affected stages; no inherited pass without evidence | Old record remains historical; only valid old profile may stay active. |
393
+ | 9. Retirement | Deprecated/failed/unavailable record | Qualification Record `RETIRED` | Replacement/communication/data review complete, or immediate hard block | No automatic fallback; explicitly select another certified tuple. |
394
+
395
+ ### Existing MVP-03 hard gates
396
+
397
+ Qualification phải reuse thresholds trong [`src/ai-scorecard.js`](../src/ai-scorecard.js), không tạo scorecard thứ hai:
398
+
399
+ | Metric | Gate |
400
+ | --- | ---: |
401
+ | Risk classification accuracy | ≥ 0.90 |
402
+ | Human review accuracy | ≥ 0.95 |
403
+ | Human review reason accuracy | ≥ 0.95 |
404
+ | Evidence reference accuracy | ≥ 0.95 |
405
+ | Evidence reference coverage | ≥ 0.95 |
406
+ | Unsupported claim rate proxy | ≤ 0.05 |
407
+ | Validation pass rate | ≥ 0.98 |
408
+ | Deterministic pass rate | = 1.00 |
409
+
410
+ Ngoài aggregate gate, qualification phải fail nếu có invented evidence/URL trong release candidate set, unknown actual identity, unexpected fallback/transform hoặc required slice regression. Current unsupported-claim metric là `CLAIMS_DROPPED` proxy, chưa phải semantic entailment proof; real-repository human review vẫn bắt buộc trước certification.
411
+
412
+ ### MVP-04/MVP-05 gate
413
+
414
+ - MVP-04 cần dataset/metrics cho source-fact linkage, affected-location precision/recall, no-impact correctness và trust propagation.
415
+ - MVP-05 cần step-level evidence/impact refs, invented command/API rate, ordering/precondition correctness, rollback/verification completeness và human-review policy.
416
+ - Cho đến khi các artifacts này tồn tại, model dù CERTIFIED cho MVP-03 vẫn chỉ là EXPERIMENTAL cho MVP-04/05.
417
+
418
+ ### Production rollback
419
+
420
+ Production selection là explicit reference tới một CERTIFIED Deployment Profile + Qualification Record digest. Promote candidate không overwrite record cũ. Khi regression xảy ra:
421
+
422
+ 1. stop new runs trên affected profile;
423
+ 2. chuyển record sang `DEPRECATED` hoặc `RETIRED` theo severity;
424
+ 3. chọn lại previous still-valid certified profile bằng explicit config, không router fallback;
425
+ 4. nếu không có profile hợp lệ, fail closed và yêu cầu human review;
426
+ 5. đánh dấu outputs sinh trong affected window để review; rollback model không tự sửa artifacts đã publish.
427
+
428
+ ## 7. Requalification Policy
429
+
430
+ ### Trigger matrix
431
+
432
+ | Change/trigger | Minimum required action |
433
+ | --- | --- |
434
+ | Exact model/revision/weights change | Full conformance + smoke + Golden Benchmark + real-repo validation. |
435
+ | Mutable/latest alias resolves khác | Invalidate certification; create exact profile and full qualification. |
436
+ | Provider changes underlying model behavior | Full quality requalification even if model string unchanged. |
437
+ | Tokenizer change | Context/Unicode/large-output conformance + full benchmark; recalculate token/cost budgets. |
438
+ | Reasoning/thinking default or mode change | Structured output + latency/output conformance and full benchmark. |
439
+ | Temperature/top-p/seed policy change | Stability/conformance + Golden Benchmark repeated-run comparison. |
440
+ | Context window/input/output limit change | Context/truncation conformance; benchmark if operating envelope changes. |
441
+ | Structured-output/API/schema semantics change | Full structured-output/error conformance; benchmark only after pass. |
442
+ | Protocol/endpoint family change | Full protocol conformance + smoke; benchmark because response behavior may differ. |
443
+ | Runtime/inference-engine upgrade | Full conformance; quality benchmark for model/template/decoder-affecting changes. |
444
+ | Gateway version/config/routing update | Routing/identity/transform conformance + benchmark for any translated path. |
445
+ | Quantization/precision/KV/cache/template change | New Deployment Profile; full conformance and quality qualification. |
446
+ | Fallback/retry policy change | Routing/error conformance; full benchmark if a different tuple can answer. |
447
+ | Prompt version change | Conformance only if request/size changes; always full Golden Benchmark. |
448
+ | Candidate/task schema change | Full structured-output conformance + task benchmark. |
449
+ | Trust/evaluation/metric/dataset change | Recompute affected evaluation/qualification; do not compare unlike versions as one score. |
450
+ | Privacy/retention policy change | Re-approve deployment; no production until compliant. |
451
+ | Continuous evaluation hard-gate regression | Immediate DEPRECATED/RETIRED decision and affected-run review. |
452
+ | Model/provider deprecation or removal notice | Mark DEPRECATED, qualify replacement before cutoff; RETIRED at removal. |
453
+
454
+ ### Partial vs full requalification
455
+
456
+ - **Conformance-only** chỉ cho change chắc chắn không ảnh hưởng semantic generation, ví dụ observability mapper sửa field usage mà request/model/config bytes không đổi.
457
+ - **Conformance + benchmark** khi decoding, prompt, schema, tokenizer, context, runtime/template hoặc provider behavior có thể đổi output.
458
+ - **Full qualification** khi model/revision/quantization/provider route thay đổi hoặc production task contract đổi.
459
+
460
+ Người review phải ghi lý do nếu chọn action nhỏ hơn matrix; không có silent inheritance.
461
+
462
+ ### Drift và expiry
463
+
464
+ Immutable local weights với pinned digest vẫn có thể drift khi runtime/template đổi. Remote model ID có thể ổn định theo provider contract nhưng serving implementation vẫn thay đổi. Vì vậy:
465
+
466
+ - requalification chủ yếu event-driven theo profile/observed identity digest;
467
+ - remote mutable deployments cần continuous canary/golden subset ở cadence do maintainer định nghĩa trước;
468
+ - Qualification Record cần review/expiry policy cho deployment không thể pin weights;
469
+ - hết validity không tự chọn replacement; status chuyển DEPRECATED và production fail/rollback theo policy.
470
+
471
+ ## 8. Deployment Profile
472
+
473
+ ### Vai trò
474
+
475
+ Capability Profile trả lời **“offering được document hỗ trợ gì?”**. Deployment Profile trả lời **“UpgradeLens sẽ gọi exact tuple nào, với configuration nào?”**.
476
+
477
+ | Dimension | Capability Profile | Deployment Profile |
478
+ | --- | --- | --- |
479
+ | Subject | Logical model/API offering | Executable provider/runtime/gateway/model tuple |
480
+ | Source | Official documentation/model card | Operator-reviewed configuration + observed identity |
481
+ | Structured output | Modes có thể hỗ trợ | Exact mode sẽ dùng |
482
+ | Context | Advertised limits | Configured operating/max limits |
483
+ | Model identity | Public model ID/revision semantics | Requested ID + expected actual ID/revision/digest |
484
+ | Quantization/runtime | Không thuộc registry logical API profile | Required cho open weights/local serving |
485
+ | Routing/fallback/retry | Không | Exact policy |
486
+ | Prompt/schema/benchmark score | Không | Chỉ task/schema binding digest; không chứa prompt text/score |
487
+ | Secret | Không | Không; chỉ auth source/mode, không value |
488
+ | Certification | Không | Không tự thân; Qualification Record quyết định |
489
+
490
+ ### Shape khái niệm
491
+
492
+ ```json
493
+ {
494
+ "schemaVersion": "1.0.0",
495
+ "id": "qwen3-14b-vllm-awq-version-analysis",
496
+ "task": "version-analysis.v1",
497
+ "capabilityProfile": "qwen3-14b",
498
+ "provider": "self-hosted",
499
+ "runtime": {
500
+ "name": "vllm",
501
+ "version": "<exact>",
502
+ "protocol": "openaiChatCompletions"
503
+ },
504
+ "endpoint": {
505
+ "class": "loopback",
506
+ "reference": "UPGRADELENS_AI_ENDPOINT",
507
+ "tlsRequired": false
508
+ },
509
+ "model": {
510
+ "requested": "Qwen/Qwen3-14B-AWQ",
511
+ "expectedActual": "Qwen/Qwen3-14B-AWQ",
512
+ "revision": "<commit-or-digest>",
513
+ "quantization": "AWQ-4bit"
514
+ },
515
+ "generation": {
516
+ "thinking": "disabled",
517
+ "reasoningEffort": null,
518
+ "temperature": 0,
519
+ "topP": null,
520
+ "seed": 1,
521
+ "contextTokens": 32768,
522
+ "maxOutputTokens": 4096
523
+ },
524
+ "structuredOutput": {
525
+ "mode": "jsonSchema",
526
+ "taskSchemaDigest": "sha256:..."
527
+ },
528
+ "routing": {
529
+ "gateway": null,
530
+ "fallback": "disabled",
531
+ "transforms": []
532
+ },
533
+ "transport": {
534
+ "streaming": false,
535
+ "timeoutMs": 90000,
536
+ "retry": { "maxAttempts": 1 }
537
+ },
538
+ "auth": {
539
+ "mode": "none",
540
+ "source": null
541
+ },
542
+ "observability": {
543
+ "requireModelIdentity": true,
544
+ "requireFinishReason": true,
545
+ "usage": "optional"
546
+ }
547
+ }
548
+ ```
549
+
550
+ Các giá trị chỉ minh họa field boundary, không phải recommendation runtime hay file được tạo trong LR-00C.
551
+
552
+ ### Profile invariants
553
+
554
+ - endpoint không có username/password/query secret; portable profile có thể dùng environment reference;
555
+ - auth chỉ mô tả `none|bearer|providerHeader` và secret source, không secret value;
556
+ - `requested`, expected actual model và revision/digest không được unknown cho benchmark;
557
+ - open-weight profile bắt buộc quantization/precision, runtime version và model digest;
558
+ - cloud profile bắt buộc provider identity/revision semantics và actual-model check;
559
+ - gateway profile bắt buộc gateway version/config digest, provider pinning, fallback/transform policy;
560
+ - `latest`, auto/free router hoặc mutable alias chỉ được EXPERIMENTAL trừ khi official semantics chứng minh ID là pinned; không đánh giá chỉ bằng hình thức tên;
561
+ - extras không được override messages/prompt, model, schema mode hoặc streaming do profile sở hữu;
562
+ - thay bất kỳ semantic field tạo profile digest mới.
563
+
564
+ ## 9. Runtime Governance Policy
565
+
566
+ ### Được phép
567
+
568
+ - direct local/cloud endpoint hoặc optional gateway route với exact Deployment Profile;
569
+ - protocol-neutral `AiRuntime`, provider adapter chỉ map wire/error/usage;
570
+ - native final JSON Schema hoặc runtime grammar-constrained JSON Schema đã conformance;
571
+ - non-streaming baseline cho Version Analysis;
572
+ - retry bounded trên cùng exact tuple nếu profile khai báo và mọi attempt được trace;
573
+ - missing usage biểu diễn `null`;
574
+ - local Ajv + existing trust validation luôn chạy;
575
+ - execution trace tách khỏi portable Version Analysis Manifest và đã redact;
576
+ - production chỉ dùng task-scoped CERTIFIED qualification digest.
577
+
578
+ ### Bị cấm trong benchmark và production qualification
579
+
580
+ - auto-router, free-router, combo, fusion, round-robin hoặc model pool;
581
+ - `latest`/mutable alias không có exact resolution semantics;
582
+ - unknown model revision, actual provider/model hoặc open-weight quantization;
583
+ - hidden model/provider/account fallback;
584
+ - fallback sang tuple chưa qualification độc lập;
585
+ - prompt transform, system injection, context compression hoặc response healing không được profile khai báo;
586
+ - extras ghi đè model/messages/schema/streaming;
587
+ - silent schema downgrade sang JSON mode/prompt-only/tool envelope;
588
+ - runtime capability auto-probe rồi đổi request mode trong benchmark run;
589
+ - streaming khi task/profile yêu cầu non-streaming;
590
+ - retry đổi model, provider, quantization hoặc reasoning mode;
591
+ - benchmark sample thiếu route identity nhưng vẫn tính vào average;
592
+ - benchmark qua profile khác production rồi reuse certification;
593
+ - dùng Capability Registry như production allowlist;
594
+ - chép benchmark score vào registry;
595
+ - log API key, Authorization, raw headers, full prompt/evidence, source code hoặc raw provider error body;
596
+ - để gateway/runtime quyết định current/target version, evidence selection, trust hoặc human review.
597
+
598
+ ### Fail-closed policy
599
+
600
+ Unknown identity, schema downgrade, unexpected fallback/transform, invalid finish reason, truncation, refusal, oversized response hoặc conformance mismatch phải làm run invalid/failed. Không được publish raw candidate và không được chuyển sang MVP-04/MVP-05. Availability không được ưu tiên hơn semantic safety.
601
+
602
+ ### Environment policy
603
+
604
+ - **Development:** EXPERIMENTAL/SUPPORTED được dùng với explicit opt-in; output không được coi production-qualified.
605
+ - **Benchmark:** chỉ SUPPORTED exact profiles; all routing/transforms locked; invalid sample không được average.
606
+ - **Production:** chỉ CERTIFIED task-scoped profile; privacy policy approved; rollback target explicit.
607
+ - **Retired:** block new runs ở mọi mode ngoài controlled forensic replay.
608
+
609
+ ## 10. Future Architecture
610
+
611
+ ### Logical flow
612
+
613
+ ```text
614
+ Static Capability Registry
615
+ +
616
+ Candidate Deployment Profile
617
+
618
+ Capability Conformance Specification/Runner
619
+
620
+ Conformance Report
621
+
622
+ Model Qualification Workflow
623
+ ├── technical smoke
624
+ ├── existing Evaluation/Metrics/Scorecard/Benchmark
625
+ └── real repository validation
626
+
627
+ Qualification Record
628
+ ↓ only CERTIFIED for task
629
+ Existing AiRuntime
630
+
631
+ Local schema validation + trust validation
632
+
633
+ Portable task artifact
634
+
635
+ Continuous evaluation / requalification / retirement
636
+ ```
637
+
638
+ Deployment Profile phải tồn tại ở dạng candidate trước conformance vì không thể test một model trừu tượng. Sau conformance, cùng immutable profile digest trở thành “conformant deployment”; không tạo thêm `ValidatedDeploymentProfile` abstraction.
639
+
640
+ ### Minimal components
641
+
642
+ | Component | Cần mới? | Trách nhiệm duy nhất |
643
+ | --- | --- | --- |
644
+ | Capability Profile JSON + schema | Có, sau LR-00C | Declared capability metadata/provenance. |
645
+ | Deployment Profile JSON + schema | Có | Exact non-secret runtime configuration identity. |
646
+ | Conformance Specification + Report | Có | Portable test contract và observations. |
647
+ | Qualification Record | Có | Task-scoped lifecycle decision/linkage. |
648
+ | Evaluation/Metrics/Scorecard/Benchmark | Dùng lại | Quality measurement; không duplicate. |
649
+ | `AiRuntime` và trust/manifest path | Giữ nguyên | Runtime boundary và semantic publication safety. |
650
+
651
+ Không cần:
652
+
653
+ - registry service/database/API;
654
+ - plugin loader/dynamic adapter discovery;
655
+ - policy DSL/rule engine;
656
+ - model marketplace;
657
+ - auto negotiation/auto selection;
658
+ - new production microservice;
659
+ - vendor-specific Version Analysis implementation.
660
+
661
+ ### Consumption rule
662
+
663
+ Production configuration trỏ explicit tới Deployment Profile + current Qualification Record digest. Runtime không tự recompute certification và không scan registry mỗi request. CI/release qualification tooling mới đọc profiles/reports và tạo decision record. Điều này giữ production path nhỏ và provider-neutral.
664
+
665
+ ## 11. Recommended MVP Roadmap
666
+
667
+ LR-00 và LR-00A đã dùng tên **LR-01, LR-02, LR-03** cho OpenAI-compatible provider, Ollama smoke và gateway conformance. Không nên reuse cùng ID cho governance. Đề xuất prefix `LR-G` để tránh collision.
668
+
669
+ ### LR-G01 — Portable Governance Metadata Contracts
670
+
671
+ **Scope:** schema + examples cho Capability Profile, Deployment Profile, Conformance Report và Qualification Record; canonical digest/invariants; documentation.
672
+
673
+ **Acceptance criteria:** provider/model-neutral; no secrets; static explicit loading; profile distinction rõ; fixture validation/determinism tests.
674
+
675
+ **Out of scope:** live endpoint, CLI selection, benchmark execution, registry service/database.
676
+
677
+ ### LR-G02 — Offline Capability Conformance Suite
678
+
679
+ **Scope:** implement conformance specification/runner trên mocked protocol fixtures; exact MVP-03 schema cases; error/identity/routing/redaction cases.
680
+
681
+ **Acceptance criteria:** default CI không network/model; required case semantics; deterministic report; no Evaluation Runner dependency; all current adapters can supply mocked fixtures.
682
+
683
+ **Out of scope:** quality scoring, model download, account/API key, production promotion.
684
+
685
+ ### LR-G03 — Opt-in Deployment Conformance and Smoke
686
+
687
+ **Scope:** bind explicit Deployment Profile vào runtime adapter; live opt-in conformance cho direct Ollama đầu tiên, sau đó locked gateway/cloud profile khi operator cung cấp; separate sanitized trace.
688
+
689
+ **Acceptance criteria:** exact identity/schema/finish/usage/error observations; no auto pull/account creation; no default CI; report contains no secret/full evidence.
690
+
691
+ **Out of scope:** model ranking và production certification.
692
+
693
+ ### LR-G04 — Qualification Workflow Integration
694
+
695
+ **Scope:** reuse existing Evaluation → Metrics → Scorecard → Benchmark artifacts; validate hard gates; add real-repo validation linkage; emit task-scoped Qualification Record.
696
+
697
+ **Acceptance criteria:** cannot certify without conformant/smoke/benchmark/real-repo artifacts; no duplicate metrics; failed candidate leaves current production selection unchanged.
698
+
699
+ **Out of scope:** MVP-04/MVP-05 metrics until their contracts exist; auto model selection.
700
+
701
+ ### LR-G05 — Requalification and Retirement
702
+
703
+ **Scope:** change-impact comparison giữa profile digests, trigger matrix, continuous canary linkage, deprecation/retirement decision và explicit rollback selection.
704
+
705
+ **Acceptance criteria:** mutable alias/runtime/gateway/quantization/prompt/schema changes invalidate đúng scope; retired profile blocked; no hidden fallback.
706
+
707
+ **Out of scope:** scheduler service, monitoring platform, database, enterprise approval workflow.
708
+
709
+ ### Sequencing
710
+
711
+ ```text
712
+ LR-01 provider implementation (existing roadmap)
713
+
714
+ LR-G01 metadata contracts
715
+
716
+ LR-G02 offline conformance
717
+
718
+ LR-02 / LR-G03 local live smoke
719
+
720
+ LR-G04 qualification
721
+
722
+ LR-G05 lifecycle governance
723
+ ```
724
+
725
+ LR-G01/G02 có thể chuẩn bị song song với runtime implementation về mặt planning, nhưng live conformance cần một real adapter. MVP-04/05 chỉ thêm task-specific conformance/qualification criteria khi schema/evaluation của chúng được định nghĩa; không cần framework mới.
726
+
727
+ ## 12. Validation
728
+
729
+ ### Scope validation
730
+
731
+ - Chỉ thêm `docs/ai-runtime-governance-discovery.md` cho LR-00C.
732
+ - Không sửa production code.
733
+ - Không sửa runtime hoặc runtime behavior.
734
+ - Không thay đổi behavior.
735
+ - Không sửa CLI.
736
+ - Không sửa schema.
737
+ - Không sửa prompt.
738
+ - Không sửa trust layer.
739
+ - Không sửa benchmark.
740
+ - Không sửa evaluation, metrics hoặc scorecard.
741
+ - Không thêm dependency hoặc cài SDK.
742
+ - Không gọi model, không dùng API key và không tạo account.
743
+ - Không tạo registry files, conformance runner, qualification workflow, database, service hoặc plugin system.
744
+ - Không có secret trong tài liệu.
745
+ - Không chạy test suite vì không có executable change.
746
+
747
+ ### Repository validation
748
+
749
+ - Deliverable có đúng 12 section tương ứng yêu cầu LR-00C.
750
+ - Thiết kế phục vụ trực tiếp `version-analysis.v1`; MVP-04/MVP-05 được scoped riêng thay vì thừa hưởng certification.
751
+ - Capability Registry chỉ là portable metadata; không prompt, benchmark score hoặc vendor logic.
752
+ - Conformance chỉ là portable specification/report; không quality benchmark.
753
+ - Qualification chỉ là portable workflow/decision record; không service mới.
754
+ - `git diff --check` phải pass trước handoff.