@piagent/platform 1.5.5 → 1.6.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 (323) hide show
  1. package/CHANGELOG.md +166 -0
  2. package/README.md +25 -21
  3. package/README.vi.md +34 -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 +92 -0
  24. package/benchmarks/production-v1/suite.json +46 -3
  25. package/catalog/capabilities.json +18 -18
  26. package/docs/authority-manifest.md +1 -1
  27. package/docs/auto-delegation-policy.md +38 -73
  28. package/docs/command-reference-vietnamese.md +27 -35
  29. package/docs/context-engine.md +12 -4
  30. package/docs/context-window-policy.md +37 -1
  31. package/docs/distribution-standard.md +7 -7
  32. package/docs/en/architecture.md +27 -13
  33. package/docs/languages.json +4 -4
  34. package/docs/model-options.md +8 -5
  35. package/docs/operator-manual-vietnamese.md +27 -45
  36. package/docs/project-adapters.md +2 -2
  37. package/docs/publishing-for-teams.md +10 -0
  38. package/docs/quality-benchmark.md +427 -62
  39. package/docs/release-install-policy.md +10 -9
  40. package/docs/runtime-harness-standard.md +3 -3
  41. package/docs/runtime-policy-design.md +4 -4
  42. package/docs/runtime-quality-baseline.md +13 -6
  43. package/docs/security-threat-model.md +2 -2
  44. package/docs/subagent-orchestration-capabilities.md +19 -51
  45. package/docs/subagents-and-multiagent.md +21 -47
  46. package/docs/task-implementation-contract.md +3 -3
  47. package/docs/task-lifecycle-vietnamese.md +3 -3
  48. package/docs/team-onboarding.md +2 -2
  49. package/docs/usage-observability.md +7 -2
  50. package/docs/vi/architecture.md +27 -13
  51. package/docs-site/architecture.html +1 -1
  52. package/docs-site/benchmark.html +89 -95
  53. package/docs-site/commands.html +1 -1
  54. package/docs-site/content/benchmark.html +88 -94
  55. package/docs-site/content/en/benchmark.html +134 -90
  56. package/docs-site/content/en/index.html +19 -19
  57. package/docs-site/content/en/runtime.html +4 -4
  58. package/docs-site/content/en/whats-new.html +12 -1
  59. package/docs-site/content/en/workflows.html +2 -2
  60. package/docs-site/content/index.html +19 -19
  61. package/docs-site/content/runtime.html +4 -4
  62. package/docs-site/content/whats-new.html +12 -1
  63. package/docs-site/content/workflows.html +2 -2
  64. package/docs-site/context-engine.html +1 -1
  65. package/docs-site/en/architecture.html +1 -1
  66. package/docs-site/en/benchmark.html +135 -91
  67. package/docs-site/en/commands.html +1 -1
  68. package/docs-site/en/context-engine.html +1 -1
  69. package/docs-site/en/index.html +20 -20
  70. package/docs-site/en/mcp-approval.html +1 -1
  71. package/docs-site/en/mcp-auth.html +1 -1
  72. package/docs-site/en/mcp-servers.html +1 -1
  73. package/docs-site/en/mcp.html +1 -1
  74. package/docs-site/en/permissions.html +1 -1
  75. package/docs-site/en/profiles.html +1 -1
  76. package/docs-site/en/quickstart.html +1 -1
  77. package/docs-site/en/runtime.html +5 -5
  78. package/docs-site/en/scope.html +1 -1
  79. package/docs-site/en/security.html +1 -1
  80. package/docs-site/en/team.html +1 -1
  81. package/docs-site/en/whats-new.html +13 -2
  82. package/docs-site/en/workflows.html +3 -3
  83. package/docs-site/index.html +20 -20
  84. package/docs-site/mcp-approval.html +1 -1
  85. package/docs-site/mcp-auth.html +1 -1
  86. package/docs-site/mcp-servers.html +1 -1
  87. package/docs-site/mcp.html +1 -1
  88. package/docs-site/permissions.html +1 -1
  89. package/docs-site/profiles.html +1 -1
  90. package/docs-site/quickstart.html +1 -1
  91. package/docs-site/runtime.html +5 -5
  92. package/docs-site/scope.html +1 -1
  93. package/docs-site/security.html +1 -1
  94. package/docs-site/team.html +1 -1
  95. package/docs-site/whats-new.html +13 -2
  96. package/docs-site/workflows.html +3 -3
  97. package/evals/fixtures/benchmark-assurance-evidence.invalid.json +1 -1
  98. package/evals/fixtures/benchmark-assurance-evidence.valid.json +1 -1
  99. package/evals/fixtures/codex-relative-efficiency-v1.invalid.json +4 -0
  100. package/evals/fixtures/codex-relative-efficiency-v1.valid.json +94 -0
  101. package/evals/fixtures/helper-request.invalid.json +1 -1
  102. package/evals/fixtures/helper-request.valid.json +1 -1
  103. package/evals/fixtures/piagent-webui/session-live-state-v1.invalid.json +18 -0
  104. package/evals/fixtures/piagent-webui/session-live-state-v1.valid.json +27 -0
  105. package/evals/fixtures/piagent-webui/subagent-tree-v1.valid.json +7 -0
  106. package/evals/fixtures/task-authority-snapshot.valid.json +4 -4
  107. package/evals/fs4-readiness-matrix.v1.json +2 -2
  108. package/evals/fs5-causal-arm.v1.json +3 -3
  109. package/evals/fs5-pilot-protocol.v1.json +3 -3
  110. package/evals/fs5-pilot-protocol.v2.json +8 -8
  111. package/evals/fs5-pilot-protocol.v3.json +8 -8
  112. package/evals/fs5-pilot-protocol.v4.json +7 -6
  113. package/evals/fs5-pilot-protocol.v5.json +9 -7
  114. package/evals/private-holdout-v1/public-exposure.v1.json +1 -1
  115. package/evals/runtime-conformance-v1/README.md +43 -0
  116. package/evals/runtime-conformance-v1/evaluate-paid-canary.mjs +198 -0
  117. package/evals/runtime-conformance-v1/lane.json +57 -0
  118. package/evals/runtime-conformance-v1/paid-canary.json +31 -0
  119. package/evals/runtime-conformance-v1/runner.mjs +456 -0
  120. package/package.json +3 -1
  121. package/packages/piagent-core/README.md +13 -4
  122. package/packages/piagent-core/benchmark/benchmark-assurance.js +4 -1
  123. package/packages/piagent-core/benchmark/benchmark-bootstrap.js +91 -9
  124. package/packages/piagent-core/benchmark/benchmark-claim-restrictions.js +38 -7
  125. package/packages/piagent-core/benchmark/benchmark-cli.js +7 -7
  126. package/packages/piagent-core/benchmark/benchmark-codex-relative-efficiency.js +698 -0
  127. package/packages/piagent-core/benchmark/benchmark-codex.js +3 -1
  128. package/packages/piagent-core/benchmark/benchmark-comparison.js +271 -2
  129. package/packages/piagent-core/benchmark/benchmark-core.js +736 -664
  130. package/packages/piagent-core/benchmark/benchmark-execution-guard.js +7 -5
  131. package/packages/piagent-core/benchmark/benchmark-forensics.js +441 -4
  132. package/packages/piagent-core/benchmark/benchmark-host-readiness.js +639 -0
  133. package/packages/piagent-core/benchmark/benchmark-matrix.js +22 -4
  134. package/packages/piagent-core/benchmark/benchmark-normalized-cost.js +317 -0
  135. package/packages/piagent-core/benchmark/benchmark-preflight.js +5 -1
  136. package/packages/piagent-core/benchmark/benchmark-process.js +6 -5
  137. package/packages/piagent-core/benchmark/benchmark-provider-free-evidence.js +345 -0
  138. package/packages/piagent-core/benchmark/benchmark-provider-wire.js +126 -0
  139. package/packages/piagent-core/benchmark/benchmark-record-validation.js +252 -0
  140. package/packages/piagent-core/benchmark/benchmark-report.js +130 -12
  141. package/packages/piagent-core/benchmark/benchmark-resume-recovery.js +14 -0
  142. package/packages/piagent-core/benchmark/benchmark-runner-policy.js +26 -0
  143. package/packages/piagent-core/benchmark/benchmark-runtime-causal.js +244 -0
  144. package/packages/piagent-core/benchmark/benchmark-stage-diagnostic.js +979 -0
  145. package/packages/piagent-core/benchmark/benchmark-statistics.js +64 -0
  146. package/packages/piagent-core/benchmark/benchmark-stop-policy.js +8 -5
  147. package/packages/piagent-core/benchmark/benchmark-suite-identity.js +31 -0
  148. package/packages/piagent-core/benchmark/benchmark-suite-runtime.js +13 -9
  149. package/packages/piagent-core/benchmark/benchmark-suite.js +149 -2
  150. package/packages/piagent-core/benchmark/benchmark-summary-support.js +380 -0
  151. package/packages/piagent-core/benchmark/benchmark-timing-diagnostics.js +971 -0
  152. package/packages/piagent-core/benchmark/benchmark-usage.js +322 -0
  153. package/packages/piagent-core/benchmark/benchmark-workflow.js +166 -0
  154. package/packages/piagent-core/capabilities/runtime-integrity.js +3 -0
  155. package/packages/piagent-core/docs/context-efficiency-improvement-plan.md +1080 -0
  156. package/packages/piagent-core/extensions/acceptance-behavior-proof.js +806 -0
  157. package/packages/piagent-core/extensions/acceptance-contract-semantics.js +83 -69
  158. package/packages/piagent-core/extensions/acceptance-error-classes.js +160 -0
  159. package/packages/piagent-core/extensions/acceptance-executable-evidence.js +12 -9
  160. package/packages/piagent-core/extensions/acceptance-receipt.js +123 -59
  161. package/packages/piagent-core/extensions/acceptance-state-machine-evidence.js +518 -0
  162. package/packages/piagent-core/extensions/acceptance-test-binding-evidence.js +60 -0
  163. package/packages/piagent-core/extensions/context-efficiency-metrics.js +302 -0
  164. package/packages/piagent-core/extensions/context-efficiency-report.js +167 -0
  165. package/packages/piagent-core/extensions/context-engine.js +149 -156
  166. package/packages/piagent-core/extensions/context-evidence.js +48 -0
  167. package/packages/piagent-core/extensions/context-import-links.js +296 -0
  168. package/packages/piagent-core/extensions/context-index-policy.js +4 -0
  169. package/packages/piagent-core/extensions/context-query-paths.js +57 -0
  170. package/packages/piagent-core/extensions/context-telemetry-integrity.js +65 -0
  171. package/packages/piagent-core/extensions/criterion-context-pack.js +435 -7
  172. package/packages/piagent-core/extensions/criterion-graph.js +82 -9
  173. package/packages/piagent-core/extensions/fallback-base-policy.ts +101 -0
  174. package/packages/piagent-core/extensions/guard-types.ts +6 -0
  175. package/packages/piagent-core/extensions/javascript-regex-evidence.js +32 -0
  176. package/packages/piagent-core/extensions/piagent-guard.ts +420 -260
  177. package/packages/piagent-core/extensions/task-contract-view.js +17 -3
  178. package/packages/piagent-core/extensions/task-lifecycle.js +39 -2
  179. package/packages/piagent-core/extensions/task-state.js +109 -142
  180. package/packages/piagent-core/extensions/verification-intelligence.js +52 -13
  181. package/packages/piagent-core/extensions/workspace-evidence-roots.js +193 -0
  182. package/packages/piagent-core/package.json +1 -1
  183. package/packages/piagent-core/policies/base-policy.json +44 -2
  184. package/packages/piagent-core/policy/authority-manifest.v1.json +3 -3
  185. package/packages/piagent-core/prompts/be-to-fe.md +2 -8
  186. package/packages/piagent-core/prompts/plan.md +1 -1
  187. package/packages/piagent-core/prompts/platform-improve.md +2 -6
  188. package/packages/piagent-core/prompts/review.md +2 -7
  189. package/packages/piagent-core/prompts/scout.md +1 -1
  190. package/packages/piagent-core/prompts/task.md +4 -3
  191. package/packages/piagent-core/runtime/context/context-delivery.ts +103 -0
  192. package/packages/piagent-core/runtime/context/context-delta-shadow.ts +53 -0
  193. package/packages/piagent-core/runtime/context/context-efficiency-format.ts +47 -0
  194. package/packages/piagent-core/runtime/context/context-evidence-qualification.ts +32 -0
  195. package/packages/piagent-core/runtime/context/prefix-telemetry.ts +47 -0
  196. package/packages/piagent-core/runtime/context/repository-memory-hints.ts +27 -0
  197. package/packages/piagent-core/runtime/hooks/agent-prompt-telemetry.ts +56 -0
  198. package/packages/piagent-core/runtime/hooks/agent-start-hook.ts +162 -102
  199. package/packages/piagent-core/runtime/hooks/completion-hook.ts +12 -12
  200. package/packages/piagent-core/runtime/hooks/input-hook.ts +17 -1
  201. package/packages/piagent-core/runtime/hooks/session-hooks.ts +22 -2
  202. package/packages/piagent-core/runtime/hooks/session-start-hook.ts +107 -3
  203. package/packages/piagent-core/runtime/hooks/tool-result-content-guards.ts +95 -0
  204. package/packages/piagent-core/runtime/hooks/tool-result-hook.ts +134 -166
  205. package/packages/piagent-core/runtime/hooks/tool-result-value-helpers.ts +66 -0
  206. package/packages/piagent-core/runtime/inspection/activity-event-adapter.ts +4 -2
  207. package/packages/piagent-core/runtime/inspection/activity-recovery.ts +104 -0
  208. package/packages/piagent-core/runtime/inspection/bounded-emission-guard.ts +286 -0
  209. package/packages/piagent-core/runtime/inspection/runtime-event-store.ts +37 -7
  210. package/packages/piagent-core/runtime/inspection/task-compaction-history.ts +1 -1
  211. package/packages/piagent-core/runtime/inspection/task-handoff-history.ts +1 -1
  212. package/packages/piagent-core/runtime/inspection/task-subagent-tree.ts +27 -4
  213. package/packages/piagent-core/runtime/inspection/tool-failure-classification.ts +70 -0
  214. package/packages/piagent-core/runtime/inspection/webui-snapshot.ts +73 -9
  215. package/packages/piagent-core/runtime/model/authenticated-catalog.ts +17 -9
  216. package/packages/piagent-core/runtime/model/openai-codex-reasoning.ts +83 -0
  217. package/packages/piagent-core/runtime/model/provider-wire-fingerprint.ts +238 -0
  218. package/packages/piagent-core/runtime/orchestration/helper-lifecycle.ts +16 -12
  219. package/packages/piagent-core/runtime/orchestration/minimal-delegation-policy.ts +71 -0
  220. package/packages/piagent-core/runtime/orchestration/owned-work-budget.ts +28 -20
  221. package/packages/piagent-core/runtime/orchestration/role-policy.ts +27 -9
  222. package/packages/piagent-core/runtime/orchestration/subagent-tool-policy.ts +329 -0
  223. package/packages/piagent-core/runtime/policy/block-remedy.ts +0 -4
  224. package/packages/piagent-core/runtime/product/activity-inspector.ts +7 -2
  225. package/packages/piagent-core/runtime/product/efficiency-metrics.ts +7 -2
  226. package/packages/piagent-core/runtime/quality/edit-freshness-guard.ts +102 -0
  227. package/packages/piagent-core/runtime/quality/exact-output-contract.ts +22 -11
  228. package/packages/piagent-core/runtime/quality/performance-assurance-signals.ts +23 -0
  229. package/packages/piagent-core/runtime/quality/performance-assurance.ts +9 -5
  230. package/packages/piagent-core/runtime/recovery/continuation-budget.ts +1 -1
  231. package/packages/piagent-core/runtime/recovery/edit-recovery-context.ts +113 -0
  232. package/packages/piagent-core/runtime/recovery/edit-recovery-delivery.ts +42 -0
  233. package/packages/piagent-core/runtime/recovery/handoff-projection.ts +4 -1
  234. package/packages/piagent-core/runtime/recovery/pristine-task-policy-refresh.ts +91 -0
  235. package/packages/piagent-core/runtime/recovery/recovery-policy.ts +7 -4
  236. package/packages/piagent-core/runtime/recovery/resume-state.ts +112 -14
  237. package/packages/piagent-core/runtime/recovery/semantic-repair-handshake.ts +60 -13
  238. package/packages/piagent-core/runtime/recovery/semantic-repair-runtime.ts +55 -2
  239. package/packages/piagent-core/runtime/recovery/task-evidence-coverage-refresh.ts +217 -0
  240. package/packages/piagent-core/runtime/registration/context-commands.ts +82 -7
  241. package/packages/piagent-core/runtime/registration/knowledge-tools.ts +9 -5
  242. package/packages/piagent-core/runtime/registration/operator-request-intake.ts +49 -0
  243. package/packages/piagent-core/runtime/registration/policy-tools.ts +50 -15
  244. package/packages/piagent-core/runtime/registration/session-commands.ts +1 -1
  245. package/packages/piagent-core/runtime/registration/task-completion-tools.ts +61 -25
  246. package/packages/piagent-core/runtime/registration/task-evidence-tools.ts +21 -12
  247. package/packages/piagent-core/runtime/registration/task-start-guidance.ts +169 -0
  248. package/packages/piagent-core/runtime/registration/task-start-manifest.ts +54 -0
  249. package/packages/piagent-core/runtime/registration/task-start-retry-helpers.ts +37 -0
  250. package/packages/piagent-core/runtime/registration/task-start-tool.ts +108 -103
  251. package/packages/piagent-core/runtime/runtime-limits.ts +16 -2
  252. package/packages/piagent-core/runtime/session/adaptive-context-analysis.ts +461 -0
  253. package/packages/piagent-core/runtime/session/adaptive-context-governor.ts +464 -0
  254. package/packages/piagent-core/runtime/session/adaptive-context-ledger.ts +265 -0
  255. package/packages/piagent-core/runtime/session/message-signals.ts +7 -3
  256. package/packages/piagent-core/runtime/session/operator-request-carry.ts +44 -0
  257. package/packages/piagent-core/runtime/session/runtime-state.ts +161 -5
  258. package/packages/piagent-core/runtime/session/source-checkout-read-grants.ts +35 -0
  259. package/packages/piagent-core/runtime/session/system-prompt.ts +76 -14
  260. package/packages/piagent-core/runtime/session/task-contract-presentation.ts +39 -0
  261. package/packages/piagent-core/runtime/tools/apply-patch-tool.ts +500 -0
  262. package/packages/piagent-core/runtime/tools/phase-tools.ts +8 -8
  263. package/packages/piagent-core/runtime/tools/tool-groups.ts +12 -2
  264. package/packages/piagent-core/runtime/trajectory/trajectory-runtime.ts +2 -1
  265. package/packages/piagent-core/runtime/verification/exact-verifier-reuse.ts +101 -0
  266. package/packages/piagent-core/runtime/workflows/runtime-intake-compaction.ts +164 -0
  267. package/packages/piagent-core/runtime/workflows/task-intake.ts +207 -38
  268. package/packages/piagent-core/security/sensitive-data.js +13 -218
  269. package/packages/piagent-core/security/sensitive-project-file.js +42 -0
  270. package/packages/piagent-core/security/sensitive-source-expression.js +330 -0
  271. package/packages/piagent-core/security/sensitive-source-formats.js +394 -0
  272. package/packages/piagent-core/security/sensitive-text.js +234 -0
  273. package/packages/piagent-core/subagents/piagent-oracle.md +5 -3
  274. package/packages/piagent-core/subagents/piagent-planner.md +6 -4
  275. package/packages/piagent-core/subagents/piagent-reviewer.md +5 -3
  276. package/packages/piagent-core/subagents/piagent-scout.md +4 -2
  277. package/packages/piagent-core/subagents/piagent-worker.md +7 -5
  278. package/packages/piagent-webui/dist/client/assets/{MarkdownMessage-rD9WJKxs.js → MarkdownMessage-B4XehTCU.js} +1 -1
  279. package/packages/piagent-webui/dist/client/assets/index-CgOEyRPG.js +176 -0
  280. package/packages/piagent-webui/dist/client/index.html +1 -1
  281. package/packages/piagent-webui/extension/piagent-webui.ts +3 -1
  282. package/packages/piagent-webui/extension/same-session-bridge.ts +1 -1
  283. package/packages/piagent-webui/extension/session-stream-adapter.ts +33 -10
  284. package/packages/piagent-webui/gateway/gateway-events.ts +109 -5
  285. package/packages/piagent-webui/gateway/gateway-service.ts +3 -0
  286. package/packages/piagent-webui/gateway/gateway-session-stream.ts +122 -20
  287. package/packages/piagent-webui/gateway/session-command-controller.ts +18 -3
  288. package/packages/piagent-webui/gateway/session-effective-options.ts +47 -0
  289. package/packages/piagent-webui/gateway/session-live-state.ts +21 -0
  290. package/packages/piagent-webui/gateway/session-operation-lifecycle.ts +237 -0
  291. package/packages/piagent-webui/gateway/session-operation-retry-control.ts +38 -0
  292. package/packages/piagent-webui/gateway/session-operation-start.ts +5 -1
  293. package/packages/piagent-webui/gateway/session-operation-watchdog.ts +165 -0
  294. package/packages/piagent-webui/gateway/session-runtime-factory.ts +45 -0
  295. package/packages/piagent-webui/gateway/session-runtime-supervisor.ts +141 -125
  296. package/packages/piagent-webui/ownership/session-lease-store.ts +5 -2
  297. package/packages/piagent-webui/server/core-inspection-provider.ts +2 -1
  298. package/packages/piagent-webui/server/loopback-server.ts +8 -0
  299. package/packages/piagent-webui/server/transcript-projection.ts +113 -9
  300. package/packages/piagent-webui/shared/text-visibility.ts +10 -0
  301. package/schemas/codex-relative-efficiency-v1.schema.json +155 -0
  302. package/schemas/piagent-webui/catalog-v1.json +9 -0
  303. package/schemas/piagent-webui/gateway-protocol-v1.schema.json +53 -3
  304. package/schemas/piagent-webui/runtime-event-v2.schema.json +15 -5
  305. package/schemas/piagent-webui/session-live-state-v1.schema.json +76 -0
  306. package/schemas/piagent-webui/subagent-tree-v1.schema.json +11 -1
  307. package/schemas/project-profile.schema.json +1 -1
  308. package/schemas/task-contract.schema.json +27 -1
  309. package/scripts/benchmark-runner-core.mjs +367 -363
  310. package/scripts/benchmark-runner-finalization.mjs +313 -0
  311. package/scripts/benchmark-runner-host-readiness.mjs +94 -0
  312. package/scripts/benchmark-runner-support.mjs +200 -0
  313. package/scripts/benchmark-session.mjs +95 -41
  314. package/scripts/configure-model-scope.sh +4 -3
  315. package/scripts/configure-subagents.sh +42 -34
  316. package/scripts/helper-evaluation.mjs +2 -2
  317. package/scripts/install-global.sh +2 -2
  318. package/scripts/pi-usage-history.mjs +37 -10
  319. package/scripts/setup.sh +2 -2
  320. package/scripts/team-doctor.sh +1 -1
  321. package/scripts/verify-local.sh +10 -1
  322. package/templates/global/settings.json +2 -1
  323. package/packages/piagent-webui/dist/client/assets/index-BZRFw1u6.js +0 -174
package/CHANGELOG.md CHANGED
@@ -4,6 +4,172 @@ This file records release-facing changes for Pi Agent Platform. Copy the relevan
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## v1.6.1 - 2026-08-26
8
+
9
+ ### Runtime continuity and truthful WebUI state
10
+
11
+ - Kept queued same-session work under one operation identity and prevented a
12
+ pending durable task from emitting a completed message or a success bubble.
13
+ Final-looking drafts remain hidden until the task reaches a terminal state,
14
+ preserving user-message then assistant-response ordering without a stale
15
+ processing indicator.
16
+ - Reconciled Activity from canonical tool evidence. Handled multi-target search
17
+ warnings finish normally, nested result envelopes are classified correctly,
18
+ and rejected or evidence-free helper calls remain visible as failures instead
19
+ of later replaying as passed.
20
+ - Captured the latest real operator request for model-owned task startup while
21
+ bounding and redacting the durable copy, so attachments and workflow wrappers
22
+ no longer replace the user's actual intent.
23
+
24
+ ### Safe external source review
25
+
26
+ - Detects GitHub, GitLab and Bitbucket references and activates only the minimal
27
+ source-checkout surface needed for a review. A successful checkout grants
28
+ session-scoped read access to that exact canonical tree, with an eight-source
29
+ bound and automatic cleanup at session end.
30
+ - Preserved protections around shared caches, sibling paths, symlink escape,
31
+ credentials, `.env`, `.git` and all mutation paths. Read-only inspection may
32
+ use bounded `read`, `grep`, `find` and `ls` flows without widening the project
33
+ mutation contract.
34
+
35
+ ### Solo-first cost and context controls
36
+
37
+ - Added direct subagent preflight with a one-helper ceiling, bounded calls,
38
+ turns and runtime, read-only role enforcement, no automatic retry/fork/worker
39
+ expansion, and truthful durable helper usage. Repeated helper results are
40
+ compacted without changing the model or thinking level.
41
+ - Hardened adaptive context accounting, exact verifier reuse, task-evidence
42
+ refresh and bounded runtime emission so token-saving decisions fail closed
43
+ when evidence is incomplete and cannot be relabeled as a Codex-relative cost
44
+ claim.
45
+
46
+ ### Benchmark assurance
47
+
48
+ - Added provider-free runtime-conformance and Codex-relative efficiency gates,
49
+ bound token/cost evidence to exact workload and provider attempts, and kept
50
+ the historical v1.6.0 production result explicitly separate from any new
51
+ subscription-spend or 30–40% cost claim.
52
+ - Preserved the 108-session production gate as an operator-authorized quota
53
+ step; this release ships runtime and benchmark safeguards without claiming a
54
+ new provider-backed result.
55
+
56
+ ## v1.6.0 - 2026-08-24
57
+
58
+ ### Context efficiency and source safety
59
+
60
+ - Replaced overlapping automatic discovery and criterion snapshots with one
61
+ criterion-aware initial pack. It prioritizes explicit targets and their
62
+ linked tests, excludes unrelated graph-only files, uses bounded snippets for
63
+ large files and records content/payload receipts for every injected item.
64
+ - Corrected context-efficiency accounting so exact repeated reads are measured
65
+ only within a session/task/model/thinking partition, missing evidence remains
66
+ visible as unavailable, fallback rereads do not reward retrieval ranking, and
67
+ tool-schema share is reported against the complete system-plus-tool prefix.
68
+ Duplicate-output and retrieval-confidence rates now exclude unclassified
69
+ historical rows and expose their partial coverage instead of treating them
70
+ as zero waste. The aggregate context-waste score is now `null` unless every
71
+ weighted telemetry lane is complete; partial data is labeled only as a
72
+ diagnostic estimate.
73
+ - Sanitized automatic source snapshots before provider injection while
74
+ preserving pure dynamic credential references. Sensitive literals, including
75
+ short values and numeric fallbacks, are redacted in common source syntax and
76
+ structured YAML, XML, HTML, CSS and Objective-C inputs with line-count-
77
+ preserving receipts. A redacted item retains only a digest of the sanitized
78
+ text; neither the raw-content digest nor another guessable verifier for the
79
+ original bytes is persisted. Sanitization of deeply nested calls is bounded.
80
+ - Preserved one planned criterion source and its focused test when retrieval is
81
+ unavailable or stale, and retained complete per-item receipts for automatic,
82
+ command and tool-delivered context packs.
83
+ - Cleared task identity, repeated-result state and pending context delivery at
84
+ terminal boundaries while preserving terminal-turn usage attribution. A new
85
+ request or workflow in the same session now starts clean, including after a
86
+ missing binding or terminal session restart.
87
+
88
+ ### Forty-percent benchmark contract and spend control
89
+
90
+ - Raised the canonical production-v1 contract to require a fixed-workload,
91
+ family-clustered fresh-token upper-95 ratio at or below `0.60`. The estimator
92
+ includes all three predeclared attempts per surface in every family, including
93
+ exact provider-started failed-attempt usage, and does not condition token
94
+ measurement on task outcome. Every declared scenario/repeat must still have
95
+ an exact finite grade pair with no Piagent quality regression, and all Piagent
96
+ sessions must satisfy the independent continuity gates.
97
+ - Added a separate GPT-5.6 Luna API-equivalent text-token cost diagnostic. It
98
+ prices exact text-token buckets, remains distinct from OAuth/provider billing,
99
+ and does not block the token-focused production claim.
100
+ - Added duration comparison globally, by workload band and by family as
101
+ observational evidence. The canonical contract allows Piagent to be slower
102
+ when fresh-token, paired-intelligence and task-continuity gates still pass.
103
+ - Froze production-v1 to Luna Medium and a ledger-bound S0/12/36/72/108 spend
104
+ sequence. Only S108 is claim-eligible; every earlier pause recomputes a
105
+ provider-free diagnostic and prints the exact bounded resume command.
106
+ - Bound seed, surfaces, model, thinking, repeats, zero retries, paired terminal
107
+ stop and clean source identity before paid work. Reserved built-in suite IDs
108
+ cannot be impersonated by external suites, including through direct report
109
+ summarization.
110
+ - Added a privacy-safe causal context receipt for every Piagent measurement.
111
+ The receipt binds telemetry provenance, current prompt/terminal order and the
112
+ exact offer/delivery/injection lifecycle before dropping paths, hashes and
113
+ identifiers. Missing, malformed, orphaned or mismatched evidence preserves
114
+ the paid ledger row but blocks S12 advancement and the final token claim.
115
+ S12 now reports aggregate pack tokens, zero-selection reasons, managed-prefix
116
+ compaction, successful direct fallback reads and shell-call exposure.
117
+ - Reconstructs a missing terminal stop from the accepted ledger before any paid
118
+ resume, so a crash between the durable append and stop marker cannot spend the
119
+ rest of an authorized window.
120
+ - Finalizes a complete ledger or valid final post-guard WAL without live auth,
121
+ provider preflight or installed Pi/Codex executables. Finalization rehashes the
122
+ current candidate, suite, runtime-dependency tree and ledger while reusing the
123
+ frozen command/auth/preflight identities bound to the accepted measurements.
124
+ - Preserved the completed 108-session r3 ledger as observational evidence under
125
+ its original successful-pair contract. It is not retroactively promoted: only
126
+ a new provider run on the exact final candidate, after this estimand and suite
127
+ digest are frozen, can approve a 40% claim.
128
+
129
+ ### Runtime intelligence and context integrity
130
+
131
+ - Bound context evidence to the exact turn, session and task run that observed
132
+ it. Planning selections no longer masquerade as delivered context, and stale
133
+ evidence cannot cross a task boundary or complete a later task.
134
+ - Added bounded context-efficiency telemetry, delivery qualification, prefix
135
+ accounting and provider-wire fingerprints without exposing prompts,
136
+ credentials or raw provider payloads.
137
+ - Preserved authenticated Codex model identifiers and supported reasoning
138
+ levels end to end. New installations default visibly to GPT-5.6 Sol with
139
+ High thinking while still allowing the user to choose another available
140
+ model for any message or session.
141
+ - Added one fail-closed CAP-12 correction after a current exact verifier when
142
+ the model discovers an omission in a file it already authored in the same
143
+ task/run/session. The runtime opens repair only after an exact structured
144
+ mutation succeeds, permits no second source edit, and requires the exact
145
+ verifier again before completion.
146
+
147
+ ### WebUI continuity and operator clarity
148
+
149
+ - Added a canonical live-state bootstrap and replay-gap recovery path so reloads
150
+ and multiple browser tabs agree on the running operation before reporting the
151
+ Gateway as live.
152
+ - Added inactivity, absolute-runtime, termination and projection watchdogs.
153
+ Concurrent Stop requests share one termination, and uncertain ownership is
154
+ quarantined instead of being projected as an idle session.
155
+ - Kept the conversation surface success-only: drafts, tool failures, retries,
156
+ completion-gate work in progress and abort details stay in Activity. Empty or
157
+ non-rendering provider output can no longer create a blank success bubble.
158
+ - Made operation settlement first-terminal-wins and retained recent failures
159
+ independently from high-volume event traffic, preventing a retry or catalog
160
+ refresh from presenting contradictory outcomes.
161
+
162
+ ### Deeper benchmark and assurance contracts
163
+
164
+ - Expanded the deep-logic benchmark with a multi-package temporal billing close
165
+ problem, stricter held-out variants, provider-wire checks, usage provenance,
166
+ statistical comparison gates and explicit Codex CLI controls.
167
+ - Hardened benchmark accounting so unknown usage, infrastructure retries or an
168
+ unmatched provider attempt cannot support a token or production claim.
169
+ - A provider-backed token-reduction claim is published only when a complete
170
+ zero-retry 108-session run passes on the exact clean tagged candidate. An
171
+ interrupted, historical or different-SHA run remains diagnostic evidence.
172
+
7
173
  ## v1.5.5 - 2026-08-21
8
174
 
9
175
  ### WebUI command execution hotfix
package/README.md CHANGED
@@ -112,22 +112,26 @@ Removal targets what is registered in Pi's settings rather than what the current
112
112
  data, platform, reliability, and security. It compares Piagent with Raw Pi or
113
113
  controlled `codex-cli`, grades hidden acceptance/safety/workflow evidence,
114
114
  reports category/lifecycle/profile bands and 95% token-ratio confidence, and
115
- reads exact JSONL usage plus privacy-safe tool histograms. Production runs
116
- retry only zero-usage startup failures and disclose every retry separately.
117
- - `deep-logic-v1` adds six large, generated-variant families for interacting
118
- state, orchestration, policy, context-graph, stream-recovery, and
119
- transactional-config invariants. It keeps the current Pi model by default
120
- and uses two repeats (24 paired sessions). A separate provider-free WebUI
115
+ reads exact JSONL usage plus privacy-safe tool histograms. Production claims
116
+ require zero retries; diagnostic retry overrides remain visible and fail the gate.
117
+ - `deep-logic-v1` adds seven large, generated-variant families for interacting
118
+ state, orchestration, policy, context-graph, stream-recovery,
119
+ transactional-config, and exact temporal-billing invariants. It locks
120
+ Piagent/`codex-cli` to Luna/medium and uses three repeats (42 paired sessions) with token, duration,
121
+ full-suite, and zero-retry gates. A separate provider-free WebUI
121
122
  parity gate proves the 10 workflow and 32 runtime-control paths before any
122
123
  model quota is used.
123
- - The v1.2.12 production snapshot resolved 54/54 Piagent tasks, scored 10.00 for
124
- quality/safety/reliability, 9.58 for workflow, 10.00 for efficiency, and 9.92
125
- overall. Against controlled `codex-cli` on the same `gpt-5.6-sol`/`xhigh`
126
- matrix, Piagent used 51.11% fewer paired fresh tokens with a 95% ratio interval
127
- of `0.3809..0.6276`; see the [benchmark evidence](https://piagent.io.vn/benchmark)
128
- and [methodology](docs/quality-benchmark.md). This is immutable historical
129
- evidence; current production gates additionally require every task and score
130
- band to exceed 9.5, so aggregate 9.58 alone is no longer sufficient.
124
+ - The public `v1.6.0` production-v1 run
125
+ `production-v1-20260824T040017Z-05b7cf`, on exact commit
126
+ `3bba8f0b3ff521bc2a355e1f6bef6d1bbdc09511` with GPT-5.6 Luna Medium,
127
+ measured 108 sessions. Piagent resolved 54/54 tasks versus 48/54 for
128
+ `codex-cli`. Its primary fixed-workload family fresh-token ratio was `0.3857`
129
+ (61.43% lower), with a 95% interval of `0.3073..0.4840`; the upper bound
130
+ supports the conservative statement of at least 51.60% fewer fresh tokens on
131
+ this predeclared workload and exact release. Usage was exact for all 108
132
+ sessions and no retry occurred. See the
133
+ [benchmark evidence](https://piagent.io.vn/benchmark) and
134
+ [methodology](docs/quality-benchmark.md).
131
135
  - Built-in profiles for frontend, backend, fullstack, BE-readonly/FE-write, data, DevOps, mobile, docs, Python, and Node TypeScript.
132
136
  - Versioned capability packs with deterministic catalog, profile resolution, integrity lock, and permission checks.
133
137
 
@@ -137,7 +141,7 @@ Project profiles can declare a runtime `permissionProfile`:
137
141
 
138
142
  | Profile | Use when | Guard behavior |
139
143
  |---|---|---|
140
- | `read-only` | Scout, audit, review | Allows `read`, `grep`, `find`, `ls`, and piagent state tools; blocks shell, write/edit, and unknown tools. |
144
+ | `read-only` | Scout, audit, review | Allows `read`, `grep`, `find`, `ls`, and piagent state tools; blocks shell, `write`/`edit`/`apply_patch`, and unknown tools. |
141
145
  | `workspace-write` | Normal implementation | Default profile. Keeps current protected-path, shell, capability, task, and verify gates. |
142
146
  | `trusted-full-access` | Trusted local automation | Expands workspace tool/scope autonomy, but still enforces protected paths, secret redaction, capability lock integrity, and destructive/external confirmation. |
143
147
 
@@ -156,9 +160,9 @@ Inside an active Pi session, use `/permission` for the menu or a session-local s
156
160
 
157
161
  Legacy aliases still work: `/permission-status`, `/read-only`, `/workspace-write`, and `/full-access`. Full-access also accepts a task after the command. The guard switches the current session to `trusted-full-access`, then forwards the remaining text as the next user request.
158
162
 
159
- ## Solo-first orchestration
163
+ ## Parent-direct orchestration
160
164
 
161
- Pi Agent Platform supports subagents, but the default operating model is solo-first: one parent agent owns the task contract, uses explicit review lenses, and only calls bounded subagents when scout/planning/review work is independent enough to justify the extra token/tool cost.
165
+ The parent model owns reasoning, implementation, and verification. Helpers are off by default. With explicit opt-in, runtime may dispatch one fresh read-only helper only when it proves two independent lanes and at least 30% projected net token saving after handoff and merge. Workers, retries, nested helpers, and parallel helpers remain disabled.
162
166
 
163
167
  Inside Pi:
164
168
 
@@ -166,7 +170,7 @@ Inside Pi:
166
170
  /piagent-orchestration
167
171
  ```
168
172
 
169
- This shows the active mode, max subagents, review lenses, Field Guide path, and writer policy without triggering a model follow-up.
173
+ This shows the active mode, one-helper ceiling, review lenses, Field Guide path, writer policy, and dispatch/skip evidence without triggering a model follow-up.
170
174
 
171
175
  For bounded source work, runtime creates the session-bound contract before the
172
176
  model starts and injects its path scope plus concise verifier. Broad, high-risk,
@@ -267,9 +271,9 @@ Keep provider keys in environment variables, never in committed config. Switchin
267
271
 
268
272
  ## Subagents
269
273
 
270
- `piagent-setup` installs `pi-subagents` with the `safe` preset and `pi-web-access` for web-backed researcher runs unless disabled. Daily task prompts stay solo-first: they delegate bounded scout, planning, research, and review work only when it is independent enough to be worth the cost, and the final handoff states whether subagents were used and why.
274
+ `piagent-setup` installs the optional `pi-subagents` compatibility runtime with a clamped `safe` preset. Daily tasks stay parent-direct; builtin agents and workers are disabled, and explicit helper mode still requires the measured 30% gate. The inspector states dispatch/skip reasons and projected saving.
271
275
 
272
- `/subagents-doctor` runs a health check; `/run piagent-scout "…"` and its planner, worker, and reviewer counterparts dispatch work. See [Subagents and multi-agent](docs/subagents-and-multiagent.md).
276
+ `/subagents-doctor` runs a health check. See [Subagents and multi-agent](docs/subagents-and-multiagent.md) for the one read-only helper opt-in contract.
273
277
 
274
278
  ## Repository layout
275
279
 
@@ -359,7 +363,7 @@ This repository intentionally excludes:
359
363
 
360
364
  ## Maturity
361
365
 
362
- The current package version is read from package metadata and release tags. Personal machines may follow the unpinned package source when accepting ongoing updates; production/team quickstarts and committed project settings should pin an explicit tag such as `v1.5.5` or a reviewed commit.
366
+ The current package version is read from package metadata and release tags. Personal machines may follow the unpinned package source when accepting ongoing updates; production/team quickstarts and committed project settings should pin an explicit tag such as `v1.6.1` or a reviewed commit.
363
367
 
364
368
  Ready for:
365
369
 
package/README.vi.md CHANGED
@@ -29,6 +29,7 @@ Trong session Pi đầu tiên của project, chạy `/onboard`. Hằng ngày, d
29
29
  - Mỗi task dùng một session có tên rõ ràng.
30
30
  - Slash command chỉ chạy handler đã đăng ký; agent không phải scout lại command.
31
31
  - Prompt hướng dẫn model, còn policy quan trọng được enforce tại runtime.
32
+ - Permission `read-only` chỉ cho phép kiểm tra; shell và các tool ghi `write`/`edit`/`apply_patch` đều bị chặn.
32
33
  - MCP config không chứa token hoặc OAuth credential.
33
34
  - Task source-changing cần scope, verify evidence và final gate.
34
35
  - Local state nằm trong `.pi/piagent-state/`, có owner-only permission và bounded retention.
@@ -46,6 +47,20 @@ chưa ship solver hoặc automatic parent routing. Host execution là mặc đ
46
47
  yêu cầu isolation backend chưa có adapter, mutation bị block thay vì âm thầm
47
48
  fallback về host.
48
49
 
50
+ ## Điều phối parent-direct
51
+
52
+ Parent model tự sở hữu suy luận, implementation và verification. Helper mặc định
53
+ tắt. Khi operator chủ động bật, runtime chỉ được dispatch tối đa một helper
54
+ read-only dùng context fresh nếu chứng minh có hai lane độc lập và tổng token dự
55
+ kiến sau handoff/merge giảm ít nhất 30%. Worker, retry, nested helper và parallel
56
+ helper đều bị tắt.
57
+
58
+ Trong Pi, `/piagent-orchestration` hiển thị mode hiện tại, trần một helper,
59
+ review lens, writer policy và bằng chứng dispatch/skip mà không tạo model turn.
60
+ `piagent-setup` chỉ cài `pi-subagents` như runtime tương thích tùy chọn với preset
61
+ `safe` đã bị clamp; `/subagents-doctor` dùng để kiểm tra health. Chi tiết nằm tại
62
+ [Subagents và multi-agent](docs/subagents-and-multiagent.md).
63
+
49
64
  ## Web search và vision
50
65
 
51
66
  Web research và đọc ảnh là hai capability tách biệt. Tích hợp `pi-web-access`
@@ -157,14 +172,28 @@ npm run benchmark:deep -- --dry-run
157
172
  npm run benchmark:deep
158
173
  ```
159
174
 
160
- `deep-logic-v1` có 6 scenario difficulty `large`, 2 repeat và 2 surface (24
161
- model session), phủ event reconciliation, fair dependency scheduling, layered
162
- policy, graph-aware context, resumable stream và transactional config. `--dry-run`
163
- chỉ validate kế hoạch, không dùng quota.
175
+ `deep-logic-v1` có 7 scenario difficulty `large`, khóa Piagent/`codex-cli` ở
176
+ Luna/medium và chạy 3 repeat trên 2 surface (42 model session). Suite phủ event
177
+ reconciliation, fair dependency scheduling, layered policy, graph-aware context,
178
+ resumable stream, transactional config và temporal usage billing chính xác; claim chỉ được phép khi đủ full suite,
179
+ token và duration gate, đồng thời không có retry. Retry diagnostic vẫn được ghi
180
+ rõ nhưng làm release gate fail. `--dry-run` chỉ validate kế hoạch, không dùng
181
+ quota.
182
+
183
+ Run production-v1 public của `v1.6.0`,
184
+ `production-v1-20260824T040017Z-05b7cf`, được đo trên đúng commit
185
+ `3bba8f0b3ff521bc2a355e1f6bef6d1bbdc09511` bằng GPT-5.6 Luna Medium với
186
+ 108 session. Piagent hoàn thành 54/54 task, so với 48/54 của `codex-cli`. Tỷ lệ
187
+ fresh token theo family fixed-workload chính là `0,3857` (thấp hơn 61,43%), với
188
+ khoảng tin cậy 95% `0,3073..0,4840`; cận trên cho phép phát biểu thận trọng rằng
189
+ Piagent dùng ít hơn ít nhất 51,60% fresh token trên đúng workload đã khai báo
190
+ trước và đúng release này. Usage của cả 108 session đều exact và không có retry.
191
+ Xem [bằng chứng benchmark](https://piagent.io.vn/benchmark) và
192
+ [phương pháp](docs/quality-benchmark.md).
164
193
 
165
194
  Gate này chạy architecture check, test, typecheck, capability validation, runtime smoke và docs consistency trước khi release.
166
195
 
167
- Bản phát hành hiện tại là `v1.5.5`. Với team hoặc production, hãy pin tag này
196
+ Bản phát hành hiện tại là `v1.6.1`. Với team hoặc production, hãy pin tag này
168
197
  hoặc một commit đã review thay vì dựa vào nguồn package không cố định.
169
198
 
170
199
  ## Security
@@ -42,12 +42,10 @@
42
42
  "test -s README.md"
43
43
  ],
44
44
  "source": [
45
- "npm run type-check",
46
- "npm run lint",
47
- "npm test"
45
+ "node -e \"const s=require('./package.json').scripts||{}; const n=['type-check','typecheck','lint','test']; if(!n.some(k=>s[k])){console.error('No Node source verifier is configured');process.exit(2)}\" && npm run type-check --if-present && npm run typecheck --if-present && npm run lint --if-present && npm test --if-present"
48
46
  ],
49
47
  "runtime": [
50
- "npm run test:e2e"
48
+ "node -e \"const s=require('./package.json').scripts||{}; if(!s['test:e2e']){console.error('No web frontend runtime verifier is configured');process.exit(2)}\" && npm run test:e2e"
51
49
  ]
52
50
  },
53
51
  "mcpCapabilities": [
@@ -79,6 +79,12 @@
79
79
  "packages/piagent-webui/ownership"
80
80
  ]
81
81
  },
82
+ {
83
+ "name": "webui-shared",
84
+ "roots": [
85
+ "packages/piagent-webui/shared"
86
+ ]
87
+ },
82
88
  {
83
89
  "name": "webui-build",
84
90
  "roots": [
@@ -133,11 +139,13 @@
133
139
  ],
134
140
  "webui-client": [
135
141
  "webui-client",
136
- "webui-contracts"
142
+ "webui-contracts",
143
+ "webui-shared"
137
144
  ],
138
145
  "webui-server": [
139
146
  "webui-server",
140
147
  "webui-contracts",
148
+ "webui-shared",
141
149
  "runtime",
142
150
  "core",
143
151
  "security",
@@ -156,6 +164,7 @@
156
164
  "webui-ownership",
157
165
  "webui-server",
158
166
  "webui-contracts",
167
+ "webui-shared",
159
168
  "runtime",
160
169
  "core",
161
170
  "security"
@@ -163,13 +172,17 @@
163
172
  "webui-ownership": [
164
173
  "webui-ownership"
165
174
  ],
175
+ "webui-shared": [
176
+ "webui-shared"
177
+ ],
166
178
  "webui-build": [
167
179
  "webui-build",
168
180
  "webui-contracts",
169
181
  "webui-client",
170
182
  "webui-server",
171
183
  "webui-gateway",
172
- "webui-ownership"
184
+ "webui-ownership",
185
+ "webui-shared"
173
186
  ],
174
187
  "entrypoints": [
175
188
  "entrypoints",
@@ -181,7 +194,8 @@
181
194
  "benchmark",
182
195
  "webui-gateway",
183
196
  "webui-ownership",
184
- "webui-server"
197
+ "webui-server",
198
+ "webui-shared"
185
199
  ]
186
200
  },
187
201
  "lineBudgets": {
@@ -199,6 +213,7 @@
199
213
  "webui-extension": 500,
200
214
  "webui-gateway": 500,
201
215
  "webui-ownership": 500,
216
+ "webui-shared": 200,
202
217
  "webui-build": 500,
203
218
  "entrypoints": 800
204
219
  },
@@ -0,0 +1,122 @@
1
+ # Deep Logic Specialist Protocol
2
+
3
+ ## Mục tiêu
4
+
5
+ `deep-logic-v1` là benchmark paired giữa Piagent và Codex CLI cho cùng model,
6
+ cùng effort, cùng fixture và cùng hidden variant. Suite dùng để đo ba điều cùng
7
+ lúc:
8
+
9
+ 1. logic cuối cùng phải đúng và không giảm so với baseline;
10
+ 2. tiến trình phải ổn định, không retry/unknown usage;
11
+ 3. Piagent chỉ được nhận lợi thế khi dùng ít fresh token hơn.
12
+
13
+ Benchmark không so với Raw Pi. Raw Pi chỉ là diagnostic ablation và không đủ
14
+ điều kiện tạo token-saving claim cho sản phẩm.
15
+
16
+ ## Execution contract cố định
17
+
18
+ | Thuộc tính | Giá trị bắt buộc |
19
+ |---|---|
20
+ | Candidate | `piagent` |
21
+ | Baseline | controlled `codex-cli` |
22
+ | Model | `openai-codex/gpt-5.6-luna` |
23
+ | Thinking | `medium` |
24
+ | Codex mode | `controlled` |
25
+ | Repeat | 3 mỗi family |
26
+ | Family | 7 |
27
+ | Tổng model session | 42 |
28
+ | Infrastructure retry | 0 |
29
+ | Timeout | 1.200 giây/session |
30
+
31
+ Suite từ chối model, thinking, surface hoặc Codex mode khác trước khi gọi
32
+ provider. Chạy chọn lẻ scenario chỉ dùng để chẩn đoán; không đủ full-suite claim.
33
+
34
+ ## Specialist family mới
35
+
36
+ `temporal-usage-billing-close` mô phỏng đóng kỳ cước usage thật, trải qua ba
37
+ module backend/UI. Nó buộc solver xử lý đồng thời:
38
+
39
+ - plan có hiệu lực theo timeline và boundary half-open;
40
+ - tier lũy tiến, reset đúng lúc đổi plan, cô lập tenant/meter;
41
+ - reversal độc lập thứ tự input và chống double/forward reversal;
42
+ - phép nhân/sum bằng `BigInt`, không mất chính xác trên `2^53`;
43
+ - round-half-to-even đúng một lần khi đóng invoice;
44
+ - canonical JSON và SHA-256 audit digest cho nested allocation;
45
+ - output Terminal/WebUI giống nhau;
46
+ - validation fail-closed, chống prototype pollution và không mutate input.
47
+
48
+ Hidden grader có 14 nhóm kiểm tra hành vi:
49
+
50
+ 1. period và timeline normalization;
51
+ 2. timeline validation fail-closed;
52
+ 3. exact tier boundary và một event đi qua nhiều tier;
53
+ 4. plan boundary và tier reset;
54
+ 5. tenant/meter isolation;
55
+ 6. reversal trước rating;
56
+ 7. reversal reference/tenant/time/cardinality;
57
+ 8. permutation-independent canonical output;
58
+ 9. `BigInt` exactness;
59
+ 10. round-half-to-even;
60
+ 11. invoice total, shape và nested digest;
61
+ 12. event validation và deep immutability;
62
+ 13. non-JSON/poison rejection;
63
+ 14. Terminal/WebUI summary parity.
64
+
65
+ Variant riêng cho từng repeat thay tenant, meter, plan id, tier boundary và
66
+ price. Grader kiểm tra hành vi, không kiểm tra regex/source shape.
67
+
68
+ ## Token accounting
69
+
70
+ Mỗi accepted hoặc failed attempt ghi các trường sau:
71
+
72
+ | Trường | Ý nghĩa |
73
+ |---|---|
74
+ | `input` | fresh input, đã loại cache read và cache write |
75
+ | `output` | toàn bộ output của provider |
76
+ | `reasoning` | phần nằm trong `output`, không cộng lần hai |
77
+ | `cacheRead` | input lấy từ provider cache |
78
+ | `cacheWrite` | input ghi vào provider cache |
79
+ | `fresh` | `input + output`, dùng làm tỷ lệ claim |
80
+ | `total` | `input + cacheRead + cacheWrite + output` |
81
+
82
+ Nguồn đo phải là `pi-session-jsonl` hoặc `codex-turn-completed`. Dòng JSON hỏng,
83
+ field token thiếu, tổng không khớp hoặc provider-started attempt không có usage
84
+ đều fail closed; số không biết dùng trạng thái unknown, không giả thành 0.
85
+
86
+ Report xuất:
87
+
88
+ - từng run: model, thinking, source, mọi token field, tool count và duration;
89
+ - median theo surface;
90
+ - tổng token accepted, failed và all attempts;
91
+ - exact/unknown attempt completeness;
92
+ - paired geometric-mean fresh-token ratio;
93
+ - 95% CI cluster theo scenario family, không giả repeat là family độc lập;
94
+ - failure-aware fresh tokens trên mỗi resolved outcome.
95
+
96
+ ## Gate
97
+
98
+ Piagent chỉ pass suite khi đồng thời:
99
+
100
+ - quality ≥ 9,5; safety = 10; reliability/workflow/category ≥ 9,5;
101
+ - mọi task/band score lớn hơn 9,5 và không có paired regression;
102
+ - đủ 7 family × 3 repeat trên cả hai surface;
103
+ - fresh-token ratio upper 95% CI ≤ 0,80;
104
+ - duration point ratio ≤ 1,00 và upper 95% CI ≤ 1,10;
105
+ - không retry, không unknown usage, provider-wire model/effort/prefix ổn định;
106
+ - source là exact clean Git commit.
107
+
108
+ ## Lệnh
109
+
110
+ Validate miễn phí, không gọi model:
111
+
112
+ ```bash
113
+ npm run benchmark:deep -- --dry-run
114
+ ```
115
+
116
+ Chạy paid benchmark đầy đủ sau khi operator xác nhận quota:
117
+
118
+ ```bash
119
+ npm run benchmark:deep
120
+ ```
121
+
122
+ Kết quả nằm trong `report.json`, `report.html`, `summary.txt` và `runs.jsonl`.