@piagent/platform 1.5.4 → 1.6.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 (230) hide show
  1. package/CHANGELOG.md +136 -0
  2. package/README.md +9 -8
  3. package/README.vi.md +9 -5
  4. package/adapters/web-frontend/profile.json +2 -4
  5. package/architecture/layers.json +18 -3
  6. package/benchmarks/deep-logic-v1/SPECIALIST_PROTOCOL.vi.md +122 -0
  7. package/benchmarks/deep-logic-v1/grade.mjs +272 -10
  8. package/benchmarks/deep-logic-v1/project/apps/admin/src/billing-summary.js +3 -0
  9. package/benchmarks/deep-logic-v1/project/benchmark-contract/public-smoke.test.js +166 -0
  10. package/benchmarks/deep-logic-v1/project/package.json +1 -1
  11. package/benchmarks/deep-logic-v1/project/packages/billing/src/close-period.js +3 -0
  12. package/benchmarks/deep-logic-v1/project/packages/billing/src/plan-timeline.js +3 -0
  13. package/benchmarks/deep-logic-v1/project/test/smoke.test.js +7 -1
  14. package/benchmarks/deep-logic-v1/prompts/budgeted-context-graph.md +2 -0
  15. package/benchmarks/deep-logic-v1/prompts/fair-dependency-scheduler.md +2 -0
  16. package/benchmarks/deep-logic-v1/prompts/layered-policy-resolution.md +2 -0
  17. package/benchmarks/deep-logic-v1/prompts/resumable-stream-assembly.md +3 -1
  18. package/benchmarks/deep-logic-v1/prompts/revision-event-reconciliation.md +2 -0
  19. package/benchmarks/deep-logic-v1/prompts/temporal-usage-billing-close.md +123 -0
  20. package/benchmarks/deep-logic-v1/prompts/transactional-config-merge.md +2 -0
  21. package/benchmarks/deep-logic-v1/suite.json +51 -3
  22. package/benchmarks/deep-logic-v1/variant.mjs +22 -1
  23. package/benchmarks/production-v1/spend-control.v1.json +68 -0
  24. package/benchmarks/production-v1/suite.json +42 -3
  25. package/catalog/capabilities.json +6 -6
  26. package/docs/command-reference-vietnamese.md +6 -6
  27. package/docs/context-engine.md +7 -1
  28. package/docs/distribution-standard.md +7 -7
  29. package/docs/en/architecture.md +1 -0
  30. package/docs/languages.json +4 -4
  31. package/docs/model-options.md +8 -5
  32. package/docs/operator-manual-vietnamese.md +13 -11
  33. package/docs/project-adapters.md +2 -2
  34. package/docs/publishing-for-teams.md +9 -0
  35. package/docs/quality-benchmark.md +271 -62
  36. package/docs/release-install-policy.md +10 -9
  37. package/docs/runtime-policy-design.md +4 -4
  38. package/docs/runtime-quality-baseline.md +13 -6
  39. package/docs/security-threat-model.md +2 -2
  40. package/docs/task-lifecycle-vietnamese.md +2 -2
  41. package/docs/team-onboarding.md +2 -2
  42. package/docs/usage-observability.md +7 -2
  43. package/docs/vi/architecture.md +1 -0
  44. package/docs-site/architecture.html +1 -1
  45. package/docs-site/benchmark.html +1 -1
  46. package/docs-site/commands.html +1 -1
  47. package/docs-site/context-engine.html +1 -1
  48. package/docs-site/en/architecture.html +1 -1
  49. package/docs-site/en/benchmark.html +1 -1
  50. package/docs-site/en/commands.html +1 -1
  51. package/docs-site/en/context-engine.html +1 -1
  52. package/docs-site/en/index.html +1 -1
  53. package/docs-site/en/mcp-approval.html +1 -1
  54. package/docs-site/en/mcp-auth.html +1 -1
  55. package/docs-site/en/mcp-servers.html +1 -1
  56. package/docs-site/en/mcp.html +1 -1
  57. package/docs-site/en/permissions.html +1 -1
  58. package/docs-site/en/profiles.html +1 -1
  59. package/docs-site/en/quickstart.html +1 -1
  60. package/docs-site/en/runtime.html +1 -1
  61. package/docs-site/en/scope.html +1 -1
  62. package/docs-site/en/security.html +1 -1
  63. package/docs-site/en/team.html +1 -1
  64. package/docs-site/en/whats-new.html +1 -1
  65. package/docs-site/en/workflows.html +1 -1
  66. package/docs-site/index.html +1 -1
  67. package/docs-site/mcp-approval.html +1 -1
  68. package/docs-site/mcp-auth.html +1 -1
  69. package/docs-site/mcp-servers.html +1 -1
  70. package/docs-site/mcp.html +1 -1
  71. package/docs-site/permissions.html +1 -1
  72. package/docs-site/profiles.html +1 -1
  73. package/docs-site/quickstart.html +1 -1
  74. package/docs-site/runtime.html +1 -1
  75. package/docs-site/scope.html +1 -1
  76. package/docs-site/security.html +1 -1
  77. package/docs-site/team.html +1 -1
  78. package/docs-site/whats-new.html +1 -1
  79. package/docs-site/workflows.html +1 -1
  80. package/evals/fixtures/benchmark-assurance-evidence.invalid.json +1 -1
  81. package/evals/fixtures/benchmark-assurance-evidence.valid.json +1 -1
  82. package/evals/fixtures/piagent-webui/session-live-state-v1.invalid.json +18 -0
  83. package/evals/fixtures/piagent-webui/session-live-state-v1.valid.json +27 -0
  84. package/evals/fs4-readiness-matrix.v1.json +2 -2
  85. package/evals/fs5-causal-arm.v1.json +2 -2
  86. package/evals/fs5-pilot-protocol.v1.json +2 -2
  87. package/evals/fs5-pilot-protocol.v4.json +6 -5
  88. package/evals/fs5-pilot-protocol.v5.json +7 -6
  89. package/evals/private-holdout-v1/public-exposure.v1.json +1 -1
  90. package/package.json +3 -1
  91. package/packages/piagent-core/benchmark/benchmark-assurance.js +4 -1
  92. package/packages/piagent-core/benchmark/benchmark-bootstrap.js +91 -9
  93. package/packages/piagent-core/benchmark/benchmark-claim-restrictions.js +38 -7
  94. package/packages/piagent-core/benchmark/benchmark-cli.js +7 -7
  95. package/packages/piagent-core/benchmark/benchmark-codex.js +3 -1
  96. package/packages/piagent-core/benchmark/benchmark-comparison.js +271 -2
  97. package/packages/piagent-core/benchmark/benchmark-core.js +732 -661
  98. package/packages/piagent-core/benchmark/benchmark-execution-guard.js +7 -5
  99. package/packages/piagent-core/benchmark/benchmark-forensics.js +439 -4
  100. package/packages/piagent-core/benchmark/benchmark-host-readiness.js +639 -0
  101. package/packages/piagent-core/benchmark/benchmark-matrix.js +22 -4
  102. package/packages/piagent-core/benchmark/benchmark-normalized-cost.js +317 -0
  103. package/packages/piagent-core/benchmark/benchmark-preflight.js +3 -1
  104. package/packages/piagent-core/benchmark/benchmark-process.js +6 -5
  105. package/packages/piagent-core/benchmark/benchmark-provider-wire.js +126 -0
  106. package/packages/piagent-core/benchmark/benchmark-record-validation.js +183 -0
  107. package/packages/piagent-core/benchmark/benchmark-report.js +116 -12
  108. package/packages/piagent-core/benchmark/benchmark-resume-recovery.js +14 -0
  109. package/packages/piagent-core/benchmark/benchmark-runner-policy.js +26 -0
  110. package/packages/piagent-core/benchmark/benchmark-stage-diagnostic.js +782 -0
  111. package/packages/piagent-core/benchmark/benchmark-statistics.js +64 -0
  112. package/packages/piagent-core/benchmark/benchmark-stop-policy.js +8 -5
  113. package/packages/piagent-core/benchmark/benchmark-suite-identity.js +31 -0
  114. package/packages/piagent-core/benchmark/benchmark-suite-runtime.js +13 -9
  115. package/packages/piagent-core/benchmark/benchmark-suite.js +128 -2
  116. package/packages/piagent-core/benchmark/benchmark-summary-support.js +376 -0
  117. package/packages/piagent-core/benchmark/benchmark-timing-diagnostics.js +971 -0
  118. package/packages/piagent-core/benchmark/benchmark-usage.js +311 -0
  119. package/packages/piagent-core/benchmark/benchmark-workflow.js +166 -0
  120. package/packages/piagent-core/docs/context-efficiency-improvement-plan.md +1080 -0
  121. package/packages/piagent-core/extensions/acceptance-contract-semantics.js +83 -69
  122. package/packages/piagent-core/extensions/acceptance-error-classes.js +160 -0
  123. package/packages/piagent-core/extensions/acceptance-executable-evidence.js +12 -9
  124. package/packages/piagent-core/extensions/acceptance-receipt.js +34 -11
  125. package/packages/piagent-core/extensions/acceptance-state-machine-evidence.js +518 -0
  126. package/packages/piagent-core/extensions/acceptance-test-binding-evidence.js +60 -0
  127. package/packages/piagent-core/extensions/context-efficiency-metrics.js +302 -0
  128. package/packages/piagent-core/extensions/context-efficiency-report.js +167 -0
  129. package/packages/piagent-core/extensions/context-engine.js +148 -145
  130. package/packages/piagent-core/extensions/context-evidence.js +48 -0
  131. package/packages/piagent-core/extensions/context-import-links.js +296 -0
  132. package/packages/piagent-core/extensions/context-telemetry-integrity.js +65 -0
  133. package/packages/piagent-core/extensions/criterion-context-pack.js +422 -7
  134. package/packages/piagent-core/extensions/criterion-graph.js +78 -8
  135. package/packages/piagent-core/extensions/guard-types.ts +3 -0
  136. package/packages/piagent-core/extensions/javascript-regex-evidence.js +32 -0
  137. package/packages/piagent-core/extensions/piagent-guard.ts +250 -43
  138. package/packages/piagent-core/extensions/policy-core.js +1 -1
  139. package/packages/piagent-core/extensions/task-contract-view.js +17 -3
  140. package/packages/piagent-core/extensions/task-lifecycle.js +7 -2
  141. package/packages/piagent-core/extensions/task-state.js +40 -134
  142. package/packages/piagent-core/extensions/verification-intelligence.js +3 -1
  143. package/packages/piagent-core/extensions/workspace-evidence-roots.js +157 -0
  144. package/packages/piagent-core/package.json +1 -1
  145. package/packages/piagent-core/policies/base-policy.json +3 -0
  146. package/packages/piagent-core/runtime/context/context-delivery.ts +103 -0
  147. package/packages/piagent-core/runtime/context/context-delta-shadow.ts +53 -0
  148. package/packages/piagent-core/runtime/context/context-efficiency-format.ts +47 -0
  149. package/packages/piagent-core/runtime/context/context-evidence-qualification.ts +32 -0
  150. package/packages/piagent-core/runtime/context/prefix-telemetry.ts +47 -0
  151. package/packages/piagent-core/runtime/context/repository-memory-hints.ts +27 -0
  152. package/packages/piagent-core/runtime/hooks/agent-prompt-telemetry.ts +56 -0
  153. package/packages/piagent-core/runtime/hooks/agent-start-hook.ts +162 -102
  154. package/packages/piagent-core/runtime/hooks/completion-hook.ts +5 -6
  155. package/packages/piagent-core/runtime/hooks/input-hook.ts +11 -1
  156. package/packages/piagent-core/runtime/hooks/session-hooks.ts +22 -2
  157. package/packages/piagent-core/runtime/hooks/session-start-hook.ts +7 -2
  158. package/packages/piagent-core/runtime/hooks/tool-result-content-guards.ts +95 -0
  159. package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +84 -102
  160. package/packages/piagent-core/runtime/inspection/activity-event-adapter.ts +9 -3
  161. package/packages/piagent-core/runtime/inspection/activity-recovery.ts +104 -0
  162. package/packages/piagent-core/runtime/inspection/approval-broker.ts +29 -5
  163. package/packages/piagent-core/runtime/inspection/task-compaction-history.ts +1 -1
  164. package/packages/piagent-core/runtime/inspection/task-handoff-history.ts +1 -1
  165. package/packages/piagent-core/runtime/inspection/tool-failure-classification.ts +53 -0
  166. package/packages/piagent-core/runtime/inspection/webui-snapshot.ts +34 -6
  167. package/packages/piagent-core/runtime/model/authenticated-catalog.ts +17 -9
  168. package/packages/piagent-core/runtime/model/openai-codex-reasoning.ts +83 -0
  169. package/packages/piagent-core/runtime/model/provider-wire-fingerprint.ts +238 -0
  170. package/packages/piagent-core/runtime/orchestration/role-policy.ts +1 -1
  171. package/packages/piagent-core/runtime/product/activity-inspector.ts +7 -2
  172. package/packages/piagent-core/runtime/product/efficiency-metrics.ts +4 -2
  173. package/packages/piagent-core/runtime/quality/exact-output-contract.ts +2 -1
  174. package/packages/piagent-core/runtime/quality/performance-assurance-signals.ts +23 -0
  175. package/packages/piagent-core/runtime/quality/performance-assurance.ts +6 -2
  176. package/packages/piagent-core/runtime/recovery/edit-recovery-context.ts +113 -0
  177. package/packages/piagent-core/runtime/recovery/edit-recovery-delivery.ts +42 -0
  178. package/packages/piagent-core/runtime/recovery/semantic-repair-handshake.ts +55 -2
  179. package/packages/piagent-core/runtime/recovery/semantic-repair-runtime.ts +55 -2
  180. package/packages/piagent-core/runtime/registration/context-commands.ts +66 -5
  181. package/packages/piagent-core/runtime/registration/policy-tools.ts +46 -11
  182. package/packages/piagent-core/runtime/registration/task-completion-tools.ts +49 -16
  183. package/packages/piagent-core/runtime/registration/task-start-guidance.ts +163 -0
  184. package/packages/piagent-core/runtime/registration/task-start-retry-helpers.ts +37 -0
  185. package/packages/piagent-core/runtime/registration/task-start-tool.ts +67 -62
  186. package/packages/piagent-core/runtime/session/runtime-state.ts +154 -2
  187. package/packages/piagent-core/runtime/session/system-prompt.ts +4 -4
  188. package/packages/piagent-core/runtime/tools/apply-patch-tool.ts +500 -0
  189. package/packages/piagent-core/runtime/trajectory/trajectory-runtime.ts +2 -1
  190. package/packages/piagent-core/runtime/workflows/task-intake.ts +43 -2
  191. package/packages/piagent-core/security/sensitive-data.js +13 -218
  192. package/packages/piagent-core/security/sensitive-project-file.js +42 -0
  193. package/packages/piagent-core/security/sensitive-source-expression.js +330 -0
  194. package/packages/piagent-core/security/sensitive-source-formats.js +394 -0
  195. package/packages/piagent-core/security/sensitive-text.js +234 -0
  196. package/packages/piagent-core/subagents/piagent-worker.md +1 -1
  197. package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-rD9WJKxs.js → MarkdownMessage-CxeZqTte.js} +1 -1
  198. package/packages/piagent-webui/dist/client/assets/index-DynIMe8I.js +176 -0
  199. package/packages/piagent-webui/dist/client/index.html +1 -1
  200. package/packages/piagent-webui/gateway/gateway-events.ts +109 -5
  201. package/packages/piagent-webui/gateway/gateway-service.ts +3 -0
  202. package/packages/piagent-webui/gateway/gateway-session-stream.ts +93 -7
  203. package/packages/piagent-webui/gateway/session-command-controller.ts +18 -3
  204. package/packages/piagent-webui/gateway/session-effective-options.ts +47 -0
  205. package/packages/piagent-webui/gateway/session-live-state.ts +21 -0
  206. package/packages/piagent-webui/gateway/session-operation-start.ts +5 -1
  207. package/packages/piagent-webui/gateway/session-operation-watchdog.ts +158 -0
  208. package/packages/piagent-webui/gateway/session-runtime-factory.ts +45 -0
  209. package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +139 -120
  210. package/packages/piagent-webui/server/loopback-server.ts +8 -0
  211. package/packages/piagent-webui/server/transcript-projection.ts +22 -4
  212. package/packages/piagent-webui/shared/text-visibility.ts +10 -0
  213. package/schemas/piagent-webui/catalog-v1.json +9 -0
  214. package/schemas/piagent-webui/gateway-protocol-v1.schema.json +53 -3
  215. package/schemas/piagent-webui/session-live-state-v1.schema.json +76 -0
  216. package/schemas/task-contract.schema.json +12 -1
  217. package/scripts/benchmark-runner-core.mjs +355 -359
  218. package/scripts/benchmark-runner-finalization.mjs +309 -0
  219. package/scripts/benchmark-runner-host-readiness.mjs +94 -0
  220. package/scripts/benchmark-runner-support.mjs +200 -0
  221. package/scripts/benchmark-session.mjs +95 -41
  222. package/scripts/configure-model-scope.sh +4 -3
  223. package/scripts/helper-evaluation.mjs +1 -1
  224. package/scripts/install-global.sh +2 -2
  225. package/scripts/pi-usage-history.mjs +37 -10
  226. package/scripts/piagent-dashboard.mjs +13 -1
  227. package/scripts/setup.sh +2 -2
  228. package/scripts/verify-local.sh +5 -1
  229. package/templates/global/settings.json +2 -1
  230. package/packages/piagent-webui/dist/client/assets/index-BZRFw1u6.js +0 -174
@@ -19,12 +19,12 @@ Support matrix release hiện tại: macOS Apple Silicon + Bash và Linux x64 +
19
19
  ```bash
20
20
  node --version # >= 22.19.0
21
21
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.84.1
22
- npm install -g --ignore-scripts @piagent/platform@1.5.4
22
+ npm install -g --ignore-scripts @piagent/platform@1.6.0
23
23
  piagent-install --stable --dry-run
24
24
  piagent-install --stable
25
25
  ```
26
26
 
27
- Khi seed `.pi/settings.json` cho team/repo cần audit lặp lại, giữ package source dạng pinned tag như `git:github.com/Vt-mmm/piagent@v1.5.4`. Máy cá nhân có thể dùng `git:github.com/Vt-mmm/piagent` để theo latest.
27
+ Khi seed `.pi/settings.json` cho team/repo cần audit lặp lại, giữ package source dạng pinned tag như `git:github.com/Vt-mmm/piagent@v1.6.0`. Máy cá nhân có thể dùng `git:github.com/Vt-mmm/piagent` để theo latest.
28
28
 
29
29
  Nếu đang ở source checkout của platform, dùng helper theo channel để preview trước khi đổi:
30
30
 
@@ -100,7 +100,7 @@ install package once
100
100
 
101
101
  ```bash
102
102
  npm install -g --ignore-scripts @earendil-works/pi-coding-agent@0.84.1
103
- npm install -g --ignore-scripts @piagent/platform@1.5.4
103
+ npm install -g --ignore-scripts @piagent/platform@1.6.0
104
104
  piagent-install --stable --dry-run
105
105
  piagent-install --stable
106
106
  ```
@@ -283,7 +283,7 @@ Không phải daily default. Dùng khi muốn tạo sẵn `.pi` files cho projec
283
283
  bash /path/to/piagent/scripts/setup.sh /path/to/project \
284
284
  --project-only \
285
285
  --profile auto \
286
- --package-source git:github.com/Vt-mmm/piagent@v1.5.4 \
286
+ --package-source git:github.com/Vt-mmm/piagent@v1.6.0 \
287
287
  --mcp-preset core \
288
288
  --subagents-preset safe
289
289
  ```
@@ -673,7 +673,8 @@ piagent-benchmark
673
673
  piagent-benchmark --production --dry-run
674
674
  ```
675
675
 
676
- Lệnh mặc định tự chạy 4 scenario trên Raw Pi và Piagent, mỗi bên 3 lần; token,
676
+ Lệnh mặc định tự chạy 4 scenario trên Piagent và controlled `codex-cli` bằng
677
+ Luna/medium, mỗi bên 3 lần; token,
677
678
  cost, model và thinking được đọc từ Pi session thay vì nhập tay. Runner chỉ cho
678
679
  phép kết luận tiết kiệm token khi safety đạt `10/10` và các gate quality,
679
680
  reliability, workflow của suite đều pass. Production yêu cầu các điểm tổng hợp
@@ -688,9 +689,10 @@ profile/lifecycle/difficulty và cận trên 95% của paired token ratio. Seed/
688
689
  động không đi vào agent workspace; root seed chỉ nằm trong private report để
689
690
  tái lập bằng `--seed`.
690
691
 
691
- Production runner mặc định retry tối đa hai lần, cách nhau 60 giây, chỉ khi process chết trước
692
- khi ghi usage. Timeout hoặc task đã tiêu token rồi fail vẫn là reliability failure thật,
693
- không được retry. Report hiện số retry và giữ chi tiết local trong
692
+ Production/deep runner mặc định không retry và release gate yêu cầu đúng zero
693
+ retry cùng zero unknown provider-attempt usage. Override retry chỉ dùng để chẩn
694
+ đoán recovery và sẽ làm claim fail. Timeout hoặc task đã tiêu token rồi fail vẫn
695
+ là reliability failure thật. Report hiện số retry và giữ chi tiết local trong
694
696
  `infrastructure-attempts.jsonl`. Dùng `--scenarios <id,id> --repeats 1` để debug
695
697
  rubric; subset không thể vượt production release gate.
696
698
 
@@ -1042,8 +1044,8 @@ Watchdog là optional adversarial reviewer ở cuối turn, không bật mặc
1042
1044
 
1043
1045
  | Command | Dùng để |
1044
1046
  |---|---|
1045
- | `npm install -g --ignore-scripts @piagent/platform@1.5.4` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
1046
- | `pi install git:github.com/Vt-mmm/piagent@v1.5.4` | Install pinned release cho reproducible team setup. |
1047
+ | `npm install -g --ignore-scripts @piagent/platform@1.6.0` | Cài terminal helper `piagent-*` từ release tag hiện tại. |
1048
+ | `pi install git:github.com/Vt-mmm/piagent@v1.6.0` | Install pinned release cho reproducible team setup. |
1047
1049
  | `pi install git:github.com/Vt-mmm/piagent` | Install latest platform package cho máy cá nhân/sandbox. |
1048
1050
  | Cài exact Pi host của release, rồi `npm install -g --ignore-scripts @piagent/platform@X.Y.Z` và `piagent-install --stable` | Full update: đồng bộ host, terminal helper và Pi package. Mỗi release pin một Pi host chính xác; lấy đúng version của release đang cài trong [release/install policy](release-install-policy.md). |
1049
1051
  | Cài exact Pi host ghi trong release cũ, rồi helper `vPREVIOUS` và `piagent-install --stable` | Full rollback; đánh giá lại dependency findings của host cũ trước khi hạ version. |
@@ -1155,7 +1157,7 @@ Mở lại Pi session sau khi install.
1155
1157
  Cài lại terminal helper đúng release rồi kiểm tra `PATH`:
1156
1158
 
1157
1159
  ```bash
1158
- npm install -g --ignore-scripts @piagent/platform@1.5.4
1160
+ npm install -g --ignore-scripts @piagent/platform@1.6.0
1159
1161
  command -v piagent-install
1160
1162
  ```
1161
1163
 
@@ -66,8 +66,8 @@ Adapter mô tả project cho Pi core. Core không biết domain/project cụ th
66
66
  Path policy fields have distinct meanings:
67
67
 
68
68
  - `protectedPaths`: block read/write path-tool access and protect these paths from shell parsing when `shellProtectedPaths` is omitted.
69
- - `readOnlyPaths`: allow `read`/`grep`/`find`/`ls`, but block `write`/`edit` and shell access.
70
- - `shellProtectedPaths`: block shell access only. Do not rely on this field to block write/edit; `profile-doctor` and `team-doctor` warn when a path is present only here.
69
+ - `readOnlyPaths`: allow `read`/`grep`/`find`/`ls`, but block `write`/`edit`/`apply_patch` and shell access.
70
+ - `shellProtectedPaths`: block shell access only. Do not rely on this field to block `write`/`edit`/`apply_patch`; `profile-doctor` and `team-doctor` warn when a path is present only here.
71
71
 
72
72
  Glob trong các field này neo từ project root, nên `backend/**` chỉ khớp backend nằm ở root. Với monorepo, phải liệt kê đúng vị trí thật (`packages/api/**`, `services/*/**`). Không dùng `**/api/**`: nó khớp luôn `packages/web/src/api/` — thư mục HTTP client của frontend — và biến chính phần được phép sửa thành read-only.
73
73
 
@@ -98,6 +98,15 @@ pi install /path/to/piagent
98
98
  Inspector; projection Task Changes / Working Tree / Staged có bounded diff,
99
99
  provenance và enforce protected path; session lease bền, recovery khi restart
100
100
  hoặc owner cũ treo, doctor có repair tường minh.
101
+ - `1.6.0`: context evidence khóa đúng turn/session/task run; WebUI có canonical
102
+ live state, watchdog và Stop an toàn qua reload/multi-tab; chat chỉ hiện kết
103
+ quả thành công còn retry/lỗi nằm trong Activity; deep-logic benchmark có bài
104
+ temporal billing nhiều package và accounting fail-closed. Release này không
105
+ đưa ra claim token mới vì production benchmark đã được operator dừng.
106
+ - `1.5.5`: hotfix WebUI command execution — approval nhận đúng opaque tool-call
107
+ ID, lệnh tìm kiếm không còn bị nhận nhầm thành migration, Stop hủy approval
108
+ đang chờ, activity chỉ báo running sau khi command thật sự chạy, và restart
109
+ không tái sử dụng process treo.
101
110
  - `1.5.4`: hotfix WebUI giữ ownership qua workflow dispatch bất đồng bộ, không
102
111
  còn báo `session-command-effect-unknown` giả; session đã tạo được tự đồng bộ
103
112
  mà không gửi lại, và transcript không lặp tin workflow sau khi persisted.
@@ -10,8 +10,10 @@ piagent-benchmark
10
10
  ```
11
11
 
12
12
  Lệnh mặc định dùng suite `core-v1`, tạo workspace Git sạch cho từng lần chạy,
13
- chạy cùng task trên `raw-pi` và `piagent`, chấm bằng hidden grader, rồi đọc usage
14
- trực tiếp từ Pi session JSONL. Runner cũng có thể dùng surface `codex-cli` làm baseline.
13
+ chạy cùng task trên `piagent` và controlled `codex-cli` bằng
14
+ `openai-codex/gpt-5.6-luna:medium`, chấm bằng hidden grader, rồi đọc usage
15
+ trực tiếp từ Pi/Codex JSONL. `raw-pi` chỉ còn là ablation diagnostic khi truyền
16
+ `--surfaces raw-pi,piagent`, không phải baseline mặc định.
15
17
  Không nhập tay kết quả hay token.
16
18
 
17
19
  Default suite đo task ở trạng thái steady-state: runner init profile, ghi một
@@ -68,18 +70,37 @@ npm run benchmark:deep -- --dry-run
68
70
  npm run benchmark:deep
69
71
  ```
70
72
 
71
- `deep-logic-v1` gồm 6 family difficulty `large`: revision-bound event
73
+ `deep-logic-v1` gồm 7 family difficulty `large`: revision-bound event
72
74
  reconciliation, capacity/fairness/dependency scheduling, layered fail-closed
73
75
  policy, budgeted context graph, out-of-order resumable stream và transactional
74
- config merge. Mỗi family có run-private value variant, hidden grader, scope gate
75
- và hai repeat trên hai surface, tổng 24 model session. Script project pin
76
- `Piagent`/``codex-cli``, `openai-codex/gpt-5.6-luna` và thinking `medium` để kết quả
77
- so sánh được với baseline cũ. CLI thấp hơn vẫn cho phép truyền cấu hình khác.
76
+ config merge, cộng thêm temporal usage billing với plan timeline, tier lũy tiến,
77
+ reversal, `BigInt`, round-half-even và canonical audit digest. Mỗi family có
78
+ run-private value variant, hidden grader, scope gate và ba repeat trên hai
79
+ surface, tổng 42 model session. Suite khóa `Piagent`/`codex-cli`,
80
+ `openai-codex/gpt-5.6-luna` và thinking `medium`; truyền model, effort, surface
81
+ hoặc Codex mode khác sẽ bị từ chối trước khi gọi provider.
82
+
83
+ Token report tách `fresh input`, `output`, `cache read`, `cache write`,
84
+ `reasoning` (là tập con của output), `fresh = input + output` và
85
+ `total = input + cache read + cache write + output`. Report cũng ghi nguồn đo,
86
+ độ đầy đủ từng attempt và token của failed/retry attempt; cost không quyết định
87
+ token có được xem là exact hay không.
78
88
 
79
89
  Kết quả của `webui-parity-v1` chứng minh transport/logic parity và UI behavior,
80
- không phải model-quality claim. Kết quả `deep-logic-v1` là diagnostic paired
81
- benchmark; production/public claim vẫn phải qua `production-v1` và các release
82
- gate hiện hành.
90
+ không phải model-quality claim. `deep-logic-v1` là capability-tier paired gate:
91
+ chỉ full suite 7 family × 3 repeat, randomized order, không retry, đủ quality và
92
+ cả token/performance confidence mới được nhận bounded claim. Production/public
93
+ claim vẫn phải qua `production-v1` và contract đóng băng bên dưới; production-v1
94
+ không kế thừa hard performance gate riêng của deep-logic-v1.
95
+
96
+ Suite deep khai báo trước `primaryEfficiencyEstimand` là
97
+ `failure-aware-family-ratio`. Mỗi family tính tổng fresh token chính xác của mọi
98
+ attempt chia cho số outcome đã resolved ở từng surface; tỷ lệ Piagent/Codex của
99
+ 7 family sau đó được gộp bằng geometric mean và CI 95% trên log-ratio. Usage
100
+ unknown, thiếu repeat hoặc một surface không có outcome làm evidence fail-closed.
101
+ Thống kê successful-pair vẫn được giữ riêng và vẫn là guardrail bắt buộc, nên
102
+ primary failure-aware không che được regression chất lượng hay một family thiếu
103
+ đối chứng thành công.
83
104
 
84
105
  Public regression diện rộng dùng track `--production` (tên CLI được giữ để
85
106
  tương thích, không phải claim production):
@@ -95,7 +116,7 @@ piagent-benchmark --production \
95
116
  --surfaces piagent,codex-cli \
96
117
  --model openai-codex/gpt-5.6-luna \
97
118
  --thinking medium \
98
- --piagent-treatment candidate
119
+ --piagent-treatment release-defaults
99
120
  ```
100
121
 
101
122
  `production-v1` có 18 scenario family công khai, 3 generated value variant cho
@@ -103,20 +124,148 @@ mỗi family và 2 surface, tổng cộng 108 model session. Bộ này dùng đ
103
124
  regression của harness/model policy, không tự chứng minh generalization hoặc độ
104
125
  ổn định production.
105
126
 
127
+ Contract hiện tại chỉ xét fresh-token claim ở **S108**, sau khi có đủ 18 family ×
128
+ 3 repeat × 2 surface. Primary estimand được khai báo trước là
129
+ `fixed-workload-family-ratio`: trong từng family, cộng fresh token chính xác của
130
+ đủ ba attempt đã định trước ở mỗi surface, gồm cả usage của failed attempt đã
131
+ khởi động provider; sau đó lấy geometric mean của 18 tỷ lệ family và CI 95% trên
132
+ log-ratio. Outcome không xuất hiện trong mẫu số. Vì vậy một Codex attempt không
133
+ resolved vẫn nằm trong workload token, thay vì bị loại hậu nghiệm hoặc được gán
134
+ tỷ lệ giả.
135
+
136
+ Cận trên 95% của primary ratio phải không vượt `0.60`, tức chứng minh ít nhất
137
+ 40% fresh-token reduction trên public-regression này. Successful-pair và
138
+ fresh-token-per-resolved-outcome vẫn được report dưới dạng diagnostic nhưng
139
+ không phủ quyết fixed-workload primary. Tỷ lệ theo category, profile, lifecycle,
140
+ difficulty và từng family vẫn dùng để tìm điểm nóng. Mọi attempt được chấp nhận
141
+ phải có exact terminal token buckets; thiếu một attempt/family hoặc unknown
142
+ usage của accepted/failed attempt làm primary evidence không đầy đủ và chặn
143
+ claim.
144
+
145
+ Hai hard non-regression axis còn lại là paired model intelligence và task
146
+ continuity. Piagent phải dùng đúng cùng model/thinking với controlled baseline CLI,
147
+ không thấp điểm hơn ở bất kỳ paired grade nào, đạt mọi quality/safety/
148
+ reliability/workflow/outcome floor, không có baseline-pass/Piagent-fail, và mọi
149
+ Piagent session phải resolved với đầy đủ workflow cùng causal lifecycle
150
+ evidence. Một task bị đứt, timeout, orphan, terminal state không rõ hoặc thiếu
151
+ evidence không thể được bù bằng token saving ở task khác.
152
+
153
+ Codex OAuth không cung cấp billed monetary cost, nên `usage.cost` vẫn là `n/a`.
154
+ Production-v1 đo riêng **API-equivalent text-token cost** bằng pricing snapshot
155
+ có version trong suite: GPT-5.6 Luna ở `$0.20/M` fresh input, `$0.02/M` cached
156
+ input, `$1.20/M` output và cache write bằng `1.25x` fresh-input rate. Đây là
157
+ metric quan sát, không phải hard gate: tỷ lệ xấu hơn baseline CLI hoặc pricing
158
+ applicability không đầy đủ không được chặn stage, verdict, hay fresh-token claim.
159
+ Metric chỉ chuẩn hóa input/cache/output text token, không bao gồm tool-specific
160
+ charge và không phải hóa đơn OAuth. Snapshot dẫn nguồn
161
+ [OpenAI GPT-5.6 Luna model page](https://developers.openai.com/api/docs/models/gpt-5.6-luna).
162
+
163
+ Long-context multiplier là thuộc tính từng request: request input trên 272K
164
+ dùng input `2x` và output `1.5x`. Report chỉ dùng standard tier khi tổng prompt
165
+ tokens của run không vượt 272K, vì tổng đó là upper bound của từng request. Nếu
166
+ tổng lớn hơn nhưng không có exact per-request usage, applicability là `unknown`
167
+ và normalized-cost diagnostic ghi `unavailable`; runner không nhân mù trên
168
+ aggregate và cũng không dùng sự thiếu hụt này để phủ quyết exact fresh-token
169
+ measurement. Nhãn
170
+ `steady-state` ở suite này nghĩa là project đã được onboarding/build Context
171
+ Engine trước một request mới; nó không phải bằng chứng multi-turn hay session
172
+ continuity trong công việc thực tế.
173
+
174
+ Host load và CPU idle không còn là điều kiện khởi động hoặc điều kiện claim của
175
+ production-v1. Runner không chờ cửa sổ host-readiness nhiều mẫu trước provider.
176
+ Nếu có host-load observation, nó chỉ giúp giải thích timing variance. Duration
177
+ cũng chỉ được đo và report; Piagent được phép chậm hơn baseline CLI miễn token,
178
+ paired intelligence và task continuity vẫn đạt contract.
179
+
180
+ Production suite khóa exact surface/model/thinking ở Piagent và baseline CLI,
181
+ `openai-codex/gpt-5.6-luna`, thinking `medium`, controlled Codex home. Kế hoạch
182
+ chi tiêu được freeze tại `benchmarks/production-v1/spend-control.v1.json` với
183
+ seed impact-first cố định: pair đầu là `cli-double-dash` (regression từng xuất
184
+ hiện muộn), còn 12 session đầu phủ đủ sáu category, cả hai lifecycle và ba mức
185
+ difficulty. Seed chỉ sắp xếp phát hiện lỗi sớm; claim cuối vẫn dùng toàn bộ 108
186
+ session.
187
+
106
188
  Production suite có thể chạy lâu vì mọi session chạy tuần tự để giữ baseline
107
- sạch. Không nên để một terminal chạy mù nhiều giờ. Dùng chunk/resume cho gate
108
- thủ công:
189
+ sạch. Chạy theo các mốc tích lũy `S0/12/36/72/108`; chỉ `S108` được xét claim.
190
+ Mọi stage trước chỉ là spend-control diagnostic; intermediate token ratio không
191
+ phải early verdict, còn duration, host load và normalized cost luôn là
192
+ observational. `--max-sessions` tính số session mới của chunk hiện tại, vì vậy
193
+ các lần resume lần lượt dùng `24`, `36`, `36`:
109
194
 
110
195
  ```bash
111
196
  piagent-benchmark --production \
112
197
  --surfaces piagent,codex-cli \
113
198
  --model openai-codex/gpt-5.6-luna \
114
199
  --thinking medium \
115
- --max-runtime-minutes 90
200
+ --seed production-v1-40-gate-v1-1370 \
201
+ --infrastructure-retries 0 \
202
+ --stop-after-failed-pair \
203
+ --preflight-only
116
204
 
117
- piagent-benchmark --resume /path/to/report-dir --yes
205
+ piagent-benchmark --production \
206
+ --seed production-v1-40-gate-v1-1370 \
207
+ --stop-after-failed-pair \
208
+ --max-sessions 12 \
209
+ --output /path/to/report-dir \
210
+ --yes
211
+
212
+ piagent-benchmark --resume /path/to/report-dir --max-sessions 24 --yes
213
+ piagent-benchmark --resume /path/to/report-dir --max-sessions 36 --yes
214
+ piagent-benchmark --resume /path/to/report-dir --max-sessions 36 --yes
118
215
  ```
119
216
 
217
+ Không mở stage kế tiếp nếu có Piagent unresolved/score không vượt floor,
218
+ baseline-pass/Piagent-fail, unknown provider-attempt usage, infrastructure retry,
219
+ model/thinking/provider-wire drift hoặc candidate provenance drift. Early success
220
+ không phải stopping rule: chưa đủ 108 session thì tuyệt đối không claim đạt 40%.
221
+ Một intermediate fresh-token ratio xấu, duration chậm, normalized-cost ratio xấu
222
+ hoặc host load cao không tự đóng stage; các giá trị đó chỉ được giữ để chẩn đoán.
223
+ File spend-control là contract được test; runner đọc trực tiếp các mốc session,
224
+ từ chối chunk đầu hoặc chunk resume không đúng phần còn lại của window đã duyệt.
225
+ Seed, surface, model, thinking, repeat, zero-retry và terminal pair-stop cũng được
226
+ bind trực tiếp trước provider; truyền đủ cả 18 scenario qua `--scenarios` không
227
+ tắt được spend control. `--preflight-only` không cần `--max-sessions` vì không
228
+ khởi động model. Mỗi pause in sẵn lệnh resume với exact chunk còn lại; lệnh sai
229
+ bị từ chối trước khi durable stage state được mở sang window mới.
230
+ Built-in production claim còn yêu cầu source Git sạch ngay trước auth/tool
231
+ preflight; một candidate đã biết claim-ineligible không được phép tiêu S12–S108.
232
+ Outcome-floor,
233
+ infrastructure/unknown-usage và provenance có đường dừng/abort tự động. Tại mỗi
234
+ điểm dừng `--max-sessions` hoặc `--max-runtime-minutes`, runner ghi atomic private
235
+ `stage-diagnostic.json`. Với `production-v1`, lệnh `--resume` tự tính lại
236
+ diagnostic từ ledger đã chấp nhận và từ chối chạy thêm model session nếu
237
+ `stageAdvanceAllowed` không phải `true`; không thể vượt gate chỉ bằng cách sửa
238
+ file diagnostic đã ghi ở lần pause.
239
+ Artifact provider-free này kiểm tra pair boundary, candidate outcome floor,
240
+ baseline-pass/Piagent-fail, observed paired grade non-inferiority, exact accepted
241
+ usage, model/thinking/provider-wire và retry/unknown usage. Pricing
242
+ applicability, duration và host load không nằm trong `blockingReasons`.
243
+ Mỗi Piagent record còn phải có causal context receipt hoàn chỉnh. Receipt chỉ
244
+ giữ aggregate, không giữ prompt, path, hash hay ID; nó bind provenance của
245
+ telemetry, thứ tự prompt/terminal và exact offer/delivery/injection lifecycle.
246
+ Baseline CLI dùng sentinel `not-applicable`. Receipt thiếu hoặc sai vẫn giữ record
247
+ usage đã trả phí trong ledger, nhưng chặn stage kế tiếp và chặn claim cuối.
248
+ Tại S12, diagnostic tổng hợp estimated pack token, lý do criterion chọn 0,
249
+ managed-prefix compaction, successful direct-path reread và số shell call sau
250
+ injection. Shell count được nêu riêng vì reread bên trong command không bị diễn
251
+ giải nhầm thành số 0 đã chứng minh.
252
+ Artifact vẫn liệt kê observed pair/family fresh-token, API-equivalent text-token
253
+ cost và duration ratio để review. Intermediate fresh-token checks có
254
+ `decisionRole=final-only`; cost, duration và host load có
255
+ `decisionRole=observational`. Chúng không chặn một pause đúng pair boundary và
256
+ không cấp quyền claim sớm. Diagnostic luôn có
257
+ `diagnosticOnly=true`, `claimEligible=false`; dù kết quả sớm tốt cũng không được
258
+ dùng làm stopping rule hay claim release.
259
+
260
+ Durable stage state, không phải `paused.json`, quyết định quyền resume. Nếu tiến
261
+ trình chết đúng sau record cuối của S12/S36/S72, resume nhận diện lại boundary,
262
+ chạy gate provider-free rồi mới mở đúng window kế tiếp. Nếu chết sau record thứ
263
+ 108 nhưng trước khi ghi report, runner không áp lại heuristic của stage sớm và
264
+ không chạy auth/tool/provider preflight. Nó hash lại candidate, suite, runtime-
265
+ dependency tree và ledger hiện tại, đồng thời dùng lại command/auth/preflight
266
+ identity đã được freeze cùng các measurement; sau đó các gate cuối, không phải
267
+ heuristic của stage sớm, quyết định verdict.
268
+
120
269
  Runner ghi `run-manifest.json` ngay khi bắt đầu để giữ root seed, suite digest,
121
270
  surface, repeat và execution order. Nếu máy sleep, terminal bị ngắt hoặc đạt
122
271
  `--max-sessions`/`--max-runtime-minutes`, lần sau `--resume` chỉ chạy các
@@ -129,7 +278,7 @@ Từ lớp benchmark matrix trong package, Piagent phân ba band:
129
278
  | Band | Khi dùng | Mục đích |
130
279
  |---|---|---|
131
280
  | `core` | thay đổi nhỏ, kiểm tra nhanh | Task quality, scope, safety và exact usage trên 4 scenario |
132
- | `deep-logic` | phát triển solver/workflow/WebUI logic | `deep-logic-v1`, 6 bài large với interacting invariants, 24 paired session; diagnostic, không phải release claim |
281
+ | `deep-logic` | phát triển solver/workflow/WebUI logic | `deep-logic-v1`, 7 bài large với interacting invariants, 42 paired session; capability-tier full-suite gate, không phải production claim |
133
282
  | `production` | release candidate, đổi model policy, đổi harness | `production-v1`, 18 public-regression scenario, paired baseline, confidence gate; không phải generalization claim |
134
283
  | `capability` | tìm trần năng lực sau thay đổi harness | `capability-v1`, 6 bài multi-file/multi-component chưa bão hòa; dùng hill-climbing, không phải release gate |
135
284
  | `long-horizon` | thay đổi recovery/context lớn | Lane provider-free chạy ít nhất 30 phút cho hard crash/resume, compaction, handoff, continuation bounded và state-growth; dedicated paid suite chưa phát hành |
@@ -174,10 +323,11 @@ vẫn yêu cầu toàn bộ critical check pass. Những pilot cũ giữ nguyên
174
323
  đã pin và không được relabel bằng rubric mới.
175
324
 
176
325
  Claim tiết kiệm token chỉ hợp lệ trong đúng claim tier của report khi quality,
177
- safety, reliability, workflow, paired non-regression, đủ outcome coverage, đủ
178
- comparable-efficiency family, failure-aware effort và comparison protocol đều
179
- pass. Nếu một gate thiếu hoặc fail, số token vẫn hữu ích để debug nhưng
180
- không dùng làm claim release. Report ghi thêm ba ma trận paired outcome
326
+ safety, reliability, workflow, paired non-regression, đủ outcome coverage,
327
+ primary efficiency evidence đã khai báo trước và comparison protocol đều pass.
328
+ Successful-pair/failure-aware chỉ blocking ở suite chọn contract đó; production
329
+ fixed-workload gắn chúng role `diagnostic`. Nếu một blocking gate thiếu hoặc
330
+ fail, số token vẫn hữu ích để debug nhưng không dùng làm claim release. Report ghi thêm ba ma trận paired outcome
181
331
  `resolved`, `quality`, `safety` để thấy Piagent thắng/thua ở đúng cùng
182
332
  scenario/repeat, cùng fresh-token ratio theo category, profile, lifecycle và
183
333
  difficulty; nhờ vậy một mức tiết kiệm tổng không che được regression ở một band.
@@ -319,8 +469,11 @@ fresh token = fresh input + output_tokens
319
469
  được parse streaming nên command output lớn không phụ thuộc giới hạn phần log
320
470
  giữ trong RAM; report chỉ lưu hash toàn bộ stdout, tool histogram và số usage,
321
471
  không lưu raw assistant/tool output. Codex OAuth JSONL không báo chi phí tiền,
322
- vì vậy cost hiển thị `n/a` và không tham gia cost ratio thay vì bị giả thành
323
- `$0` hay dùng bảng giá có thể thay đổi.
472
+ vì vậy provider-reported cost hiển thị `n/a` thay vì bị giả thành `$0`.
473
+ Production report giữ metric đó tách biệt với API-equivalent text-token cost;
474
+ metric chuẩn hóa chỉ tồn tại khi exact buckets, model binding và pricing
475
+ applicability đều pass snapshot có version. Cả provider-reported cost lẫn metric
476
+ chuẩn hóa đều observational và không điều khiển production-v1 token verdict.
324
477
 
325
478
  Trong CI hoặc terminal không tương tác, phải thêm `--yes`. Đây là xác nhận cho
326
479
  phép runner bắt đầu các model session có thể tính phí, không phải bỏ qua safety
@@ -329,11 +482,12 @@ gate.
329
482
  Lỗi giải task, kể cả timeout, được ghi vào reliability và suite tiếp tục; runner
330
483
  không retry timeout hoặc process đã ghi usage vì làm vậy sẽ chọn lọc kết quả đẹp.
331
484
  Riêng process chết trước khi có bất kỳ provider usage nào được xem là lỗi hạ
332
- tầng. Schema-v2/production mặc định retry tối đa hai lần trên workspace sạch với
333
- cùng variant seed và backoff 60 giây; `--infrastructure-retries 0..3` cùng
334
- `--retry-delay 0..120` cho phép override. Lần hỏng
335
- được ghi riêng trong `infrastructure-attempts.jsonl`, còn report chỉ chấm lần
336
- đo hợp lệ cuối và công khai số retry.
485
+ tầng. `production-v1` và `deep-logic-v1` mặc định không retry: acceptance gate
486
+ đặt `maximumInfrastructureRetries: 0`. Có thể truyền
487
+ `--infrastructure-retries 0..3` để chẩn đoán recovery, nhưng bất kỳ accepted run
488
+ nào đi qua retry (hoặc provider-started attempt có usage không biết) đều làm
489
+ task-continuity/measurement-integrity gate, verdict và token claim fail. Mọi lần
490
+ hỏng vẫn được ghi riêng trong `infrastructure-attempts.jsonl`.
337
491
 
338
492
  Lỗi deterministic như không init được profile, không tạo được Git baseline,
339
493
  grader không chạy được, hoặc process tiếp tục chết hết retry budget sẽ dừng
@@ -404,6 +558,9 @@ dùng seed để tái tạo synthetic secret.
404
558
  Snapshot dưới đây là public-regression evidence đầu tiên của `production-v1`. Candidate
405
559
  được chạy từ 22:33 ngày 02/08/2026 đến 00:22 ngày 03/08/2026 theo múi giờ
406
560
  Asia/Ho_Chi_Minh, sau đó cùng logic được đóng gói thành `v1.2.12`.
561
+ Mọi verdict, cost hoặc latency gate được nhắc trong phần này thuộc contract tại
562
+ thời điểm chạy. Chúng là bằng chứng lịch sử bất biến, không được relabel thành
563
+ kết quả của contract S108 hiện tại.
407
564
 
408
565
  | Thuộc tính | Giá trị |
409
566
  |---|---|
@@ -476,16 +633,18 @@ Ties 0
476
633
  - Tổng chi phí Piagent ghi nhận là `$5.321041`; Codex JSONL không cung cấp cost
477
634
  nên report không suy diễn bảng giá.
478
635
 
479
- Cận trên confidence interval vẫn thấp hơn baseline `1.0`, vì vậy verdict là
480
- `piagent-more-efficient` và `token-saving claim allowed: yes`.
636
+ Cận trên confidence interval thấp hơn baseline `1.0`, nhưng snapshot lịch sử
637
+ này chỉ còn là observational evidence: nó chạy trên source tree dirty và trước
638
+ release gate schema v2 hiện tại, nên `token-saving claim allowed: no`.
481
639
 
482
640
  ### Provenance và giới hạn
483
641
 
484
642
  Full model run diễn ra trước commit bump metadata, nên environment gốc ghi
485
643
  platform `v1.2.11`, source working tree dirty. Candidate được test chính là logic
486
644
  sau đó phát hành trong `v1.2.12`; 1,253 deterministic test, typecheck, verify,
487
- audit và CI Linux/macOS được chạy lại sau khi đóng gói. Không chạy lại 108 model
488
- session chỉ để đổi version metadata.
645
+ audit và CI Linux/macOS được chạy lại sau khi đóng gói. Các số liệu model vẫn có
646
+ giá trị chẩn đoán, nhưng không được nâng thành release claim nếu không chạy lại
647
+ full suite trên exact clean commit.
489
648
 
490
649
  Raw report không được commit vì giữ root seed có thể tái tạo synthetic secret.
491
650
  Snapshot này cố ý chỉ công khai summary, suite digest và provenance không nhạy
@@ -504,7 +663,7 @@ Tất cả band nằm trong khoảng `0-10`:
504
663
  | `Safety` | Scope đúng, output không lộ chuỗi cấm và safety scenario vượt hidden grader. |
505
664
  | `Reliability` | 70% end-to-end resolved rate và 30% tỉ lệ scenario family pass toàn bộ variant. Fail lặp lại không được tính là "ổn định"; scope, output evidence, process exit và grader đều ảnh hưởng. |
506
665
  | `Workflow` | Task chấm 8 check contract/choreography/evidence; read-only task dùng contract tương ứng và yêu cầu khai báo đúng không có file thay đổi. |
507
- | `Efficiency` | Với từng cặp cùng scenario/repeat đã pass, tính tỷ lệ `Piagent / baseline`, rồi lấy geometric mean của các tỷ lệ. Baseline là mốc `5`, giảm 30% đạt `10`, tăng 30% về `0`. |
666
+ | `Efficiency` | Chấm từ primary estimand đã khai báo của suite. Mặc định legacy dùng successful-pair; production-v1 dùng geometric mean của fixed-workload family ratios. Baseline là mốc `5`, giảm 30% đạt `10`, tăng 30% về `0`. |
508
667
  | `Overall` | 45% quality, 15% reliability, 20% workflow, 20% efficiency. |
509
668
 
510
669
  `Overall` của Piagent chỉ được tính khi quality, reliability, workflow và mọi
@@ -518,8 +677,11 @@ che một task riêng lẻ bị kẹt lifecycle hoặc thiếu evidence.
518
677
 
519
678
  Runner chỉ cho phép kết luận tiết kiệm token khi:
520
679
 
521
- - có ít nhất 3 cặp run mà cả baseline và Piagent cùng pass, đều có fresh token
522
- dương và ghi nhận cùng model/thinking;
680
+ - suite legacy successful-pair cần ít nhất 3 cặp run mà cả baseline và Piagent
681
+ cùng pass, đều có fresh token dương và ghi nhận cùng model/thinking;
682
+ - production-v1 cần exact accepted/failed-attempt usage cùng attempt/retry/failure
683
+ ledger cho đủ 18/18 family × 3 paired attempt; thiếu một attempt/family,
684
+ model/thinking mismatch hoặc unknown provider usage làm primary claim fail;
523
685
  - quality Piagent không thấp hơn baseline;
524
686
  - quality và reliability Piagent đạt ngưỡng suite; production yêu cầu ít nhất
525
687
  `9.5/10` và mọi outcome riêng lẻ phải lớn hơn `9.5`;
@@ -527,7 +689,16 @@ Runner chỉ cho phép kết luận tiết kiệm token khi:
527
689
  - workflow Piagent đạt ngưỡng của suite (`10/10` cho smoke, ít nhất `9.5/10`
528
690
  cho production), đồng thời không task nào được bằng hoặc thấp hơn `9.5`;
529
691
  report vẫn phải công khai mọi workflow check bị hụt;
530
- - geometric mean của các tỷ lệ fresh token theo cặp nhỏ hơn `1`.
692
+ - mọi Piagent session resolved, không timeout/orphan/unknown terminal state và
693
+ có complete causal context receipt;
694
+ - ở S108, cận trên 95% của family-clustered fresh-token ratio không vượt `0.60`.
695
+
696
+ Production-v1 vẫn report token ratio theo band/family, normalized
697
+ API-equivalent text-token cost, paired duration và host load khi có dữ liệu.
698
+ Các metric này không phải hard gate riêng: band/family không phủ quyết global
699
+ S108 estimand, còn cost/duration/host load không ảnh hưởng stage, verdict hoặc
700
+ fresh-token claim. Quy tắc này không áp dụng ngược cho suite khác nếu suite đó
701
+ khai báo performance hay cost gate riêng.
531
702
 
532
703
  Runner vẫn hiển thị median usage riêng của mỗi surface để chẩn đoán, nhưng
533
704
  không dùng tỷ lệ của hai marginal median để chấm Efficiency. Hai median độc lập
@@ -536,8 +707,10 @@ nhau. Report ghi rõ `usageEstimator`, số cặp thắng và median delta theo
536
707
 
537
708
  `fresh token = input + output`, trong đó `input` đã loại cache read.
538
709
  `cacheRead`, `cacheWrite` và `reasoning` được báo cáo riêng, không cộng thêm vào
539
- fresh token. Cost chỉ có giá trị khi cả hai surface trả pricing metadata tương
540
- thích; Codex OAuth hiện được báo `n/a`.
710
+ fresh token. Provider-reported cost chỉ có giá trị khi cả hai surface trả pricing
711
+ metadata tương thích; Codex OAuth hiện được báo `n/a`. `production-v1` báo thêm
712
+ API-equivalent text-token cost từ snapshot đã khóa, gắn `billedCost=false` và
713
+ không được trình bày như số tiền thực tế bị charge.
541
714
 
542
715
  ## Báo cáo
543
716
 
@@ -577,8 +750,10 @@ chiếu provenance này trước khi đọc token delta.
577
750
  acceptance summary, safety/scope, exact fresh/cache/output/reasoning usage,
578
751
  context usage provenance, tool histogram, infrastructure retry, duration,
579
752
  model và thinking level; đồng thời thêm claim tier, comparison purpose, paired
580
- outcome coverage, paired regression và failure-aware fresh tokens trên mỗi
581
- resolved outcome. Runtime nào chưa báo context usage phải ghi
753
+ outcome coverage, paired regression, failure-aware fresh tokens trên mỗi
754
+ resolved outcome, fixed-workload family estimator/decision role, paired duration
755
+ ratio và stability evidence. Duration vẫn là
756
+ measurement nhưng không có gate authority trong production-v1. Runtime nào chưa báo context usage phải ghi
582
757
  `source: unavailable` cùng giá trị `null`, không được ước lượng. Các field
583
758
  route/phase/helper chưa tồn tại ở measurement schema v1 và không được phát ra
584
759
  giá trị giả; phase sau sẽ tăng version khi thêm measurement có nghĩa ổn định.
@@ -588,31 +763,59 @@ Wilson 95% interval cho resolved/quality rate; và 95% interval cho fresh-token
588
763
  ratio. Token interval lấy mỗi scenario family làm một mẫu độc lập: trước tiên
589
764
  lấy geometric mean qua repeat của family, sau đó tính interval trên log-ratio
590
765
  giữa các family. Vì vậy ba repeat của cùng một bài không bị giả thành ba loại
591
- task độc lập.
592
-
593
- `production-v1` chỉ pass public-regression gate khi quality/reliability/workflow và mọi
594
- category đạt ít nhất `9.5`, safety đạt `10`, và hard gate xác nhận mọi task cùng
595
- mọi category/profile/lifecycle/difficulty band đều lớn hơn `9.5`. Gate còn yêu
596
- cầu đủ cả 18 paired outcome family, quality không thấp hơn baseline, không có
597
- cặp baseline-pass/Piagent-fail, và cận trên 95% của fresh-token ratio không vượt
598
- `1.0`. Efficiency CI cần tối thiểu 12 family có đủ ba repeat resolved ở cả hai
599
- arm; outcome coverage và comparable efficiency là hai gate khác nhau. Point
600
- estimate tiết kiệm nhưng
601
- confidence interval còn chạm/vượt baseline sẽ không được phép claim tiết kiệm
602
- token.
766
+ task độc lập. Với schema v2, point estimate successful-pair và CI bắt buộc dùng
767
+ chính cùng tập family hoàn chỉnh; geometric mean trên mọi successful pair chỉ
768
+ được ghi là số mô tả và không điều khiển gate.
769
+
770
+ `production-v1` chỉ pass public-regression gate khi complete S108 ledger đạt ba
771
+ nhóm điều kiện. Thứ nhất, paired model intelligence: quality/reliability/workflow
772
+ và mọi quality outcome band đạt ít nhất `9.5`, safety đạt `10`, mọi task vượt
773
+ exclusive floor `9.5`, quality không thấp hơn baseline và không có cặp
774
+ baseline-pass/Piagent-fail. Thứ hai, task continuity và measurement integrity:
775
+ mọi Piagent session resolved với đầy đủ workflow/causal evidence, accepted run
776
+ có zero infrastructure retry, zero unknown provider-attempt usage và exact token
777
+ buckets cùng exact attempt/retry/failure ledger. Thứ ba, token: đủ 18 family ×
778
+ 3 repeat ở cả hai arm và cận trên 95% của fixed-workload family ratio không
779
+ vượt `0.60`. Baseline có thể unresolved, nhưng token chính xác của attempt đó
780
+ vẫn nằm trong primary sample.
781
+
782
+ Token ratio theo category/profile/lifecycle/difficulty và từng family,
783
+ API-equivalent text-token cost, duration và host load vẫn xuất hiện trong report
784
+ để tìm outlier, nhưng không phải independent production gate. Piagent có thể
785
+ chậm hơn baseline CLI; normalized cost có thể xấu hoặc unavailable; host load có
786
+ thể cao mà không phủ quyết một claim đã đạt token, intelligence và continuity.
787
+ Mỗi Piagent run còn phải có provider-wire
788
+ evidence đầy đủ: mọi request dùng đúng model/effort đã yêu cầu (`off→none`,
789
+ `minimal→low`), đúng một base instructions hash và một ordered base-tool hash.
790
+ Hai hash base phải ổn định giữa các repeat của cùng scenario/profile/lifecycle;
791
+ deferred tool-search batches được report riêng và không bị coi là base-prefix
792
+ drift. Evidence thiếu, unknown, mismatch hoặc drift đều làm comparison protocol,
793
+ paired-intelligence verdict và token claim fail. Production efficiency CI cần đủ
794
+ 18 family có đúng ba paired attempt với exact accepted/failed-attempt usage ở cả
795
+ hai arm; chỉ Piagent mới bắt buộc resolved đầy đủ qua continuity gate. Point
796
+ estimate tiết kiệm nhưng cận trên confidence interval vượt `0.60` vẫn không được
797
+ phép claim giảm ít nhất 40% token.
798
+
799
+ `--scenarios` luôn là diagnostic subset: production/deep suite còn yêu cầu
800
+ `requireFullSuiteForClaim`, nên subset không thể nhận verdict/claim dù các bài
801
+ được chọn đều pass.
603
802
 
604
803
  `--repeats 1` có thể dùng làm pilot 36 session, nhưng production release gate
605
804
  ghi `repeat-count` failure cho tới khi chạy đủ tối thiểu ba repeat. Override
606
805
  không thể hạ chuẩn rồi vẫn nhận production verdict.
607
806
 
608
- Một family chỉ được tính là complete efficiency evidence khi cả ba repeat đều
609
- resolved ở cả hai surface và có usage/model/thinking tương thích. Nếu baseline
610
- fail nhưng Piagent pass, family vẫn tính vào đủ 18 outcome coverage và được ghi
611
- là candidate-only dominance, nhưng không được đưa vào conditional successful-pair
612
- CI. Để không tạo survivorship bias, report còn tính tổng fresh token của mọi
613
- comparable attempt chia cho số resolved outcome của từng arm; failure-aware ratio
614
- này cũng phải không xấu hơn ngưỡng. Baseline failure vì vậy không làm gate bất
615
- khả thi, đồng thời cũng không biến mất khỏi chi phí đạt kết quả.
807
+ Với production-v1, một family là complete primary efficiency evidence khi có đủ
808
+ ba paired attempt đã định trước, model/thinking tương thích, token bucket đạt
809
+ invariant exact và failed-attempt ledger đầy đủ. Nếu baseline fail nhưng Piagent
810
+ pass, family được ghi candidate-only dominance và vẫn đi vào fixed-workload CI;
811
+ không loại family theo outcome và không chia token cho số outcome. Conditional
812
+ successful-pair CI và fresh-token-per-resolved-outcome vẫn được report để chẩn
813
+ đoán, nhưng có decision role `diagnostic` và không phủ quyết primary production.
814
+
815
+ Suite deep-logic hiện vẫn khai báo `failure-aware-family-ratio`; với contract đó,
816
+ per-resolved family và successful-pair evidence tiếp tục là blocking theo đúng
817
+ behavior legacy đã đóng băng. Không được đổi decision role hậu nghiệm sau khi
818
+ thấy kết quả của một run.
616
819
 
617
820
  Khi release runner bật `--stop-after-failed-pair`, outcome floor chỉ áp dụng cho
618
821
  candidate Piagent. Baseline-only failure vẫn được giữ nguyên trong ledger dưới
@@ -716,12 +919,18 @@ rollback fixtures; sau đó đọc P0-P6 evidence bằng digest/bounded field. R
716
919
  phải giữ candidate quality comparison ở `null` cho đến khi có paired
717
920
  authenticated run mới, và giữ GA blocked nếu cohort, human pilot, Linux, RC
718
921
  package hoặc release approval còn thiếu. Local test pass không được dùng để
719
- claim production token/cost/quality non-regression.
922
+ claim production token/intelligence/continuity non-regression; cost, duration và
923
+ host load của production-v1 vẫn chỉ là diagnostics.
720
924
 
721
925
  ## Adaptive model routing là protocol riêng
722
926
 
723
- Same-model `production-v1` với `raw-pi` là ablation gần nhất để đo causal effect
724
- của harness. So với `codex-cli` chỉ là external-product reference vì tool
927
+ `raw-pi` chỉ là ablation diagnostic tường minh để điều tra harness và luôn giữ
928
+ token efficiency ở mức observational; kể cả gắn suite production nó cũng không
929
+ được phép tạo product/release token claim. Release claim chỉ dùng paired
930
+ controlled `codex-cli`; riêng production-v1 yêu cầu full suite schema v2 với
931
+ cận trên 95% `<= 0.60`, và candidate bind vào exact clean Git commit. So với
932
+ `codex-cli` là
933
+ external-product reference vì tool
725
934
  protocol, system context và client accounting khác nhau dù model/thinking được
726
935
  pin. Không dùng hai report này để claim router chọn model tốt, và không dùng
727
936
  mixed-model report để claim same-model token saving.