@zaip-ai/cli 3.3.0 → 3.4.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 (263) hide show
  1. package/dist/services/adapters.d.ts +1 -1
  2. package/dist/services/adapters.d.ts.map +1 -1
  3. package/dist/services/adapters.js +4 -3
  4. package/dist/services/adapters.js.map +1 -1
  5. package/dist/services/agent-catalog-upgrade.d.ts +3 -0
  6. package/dist/services/agent-catalog-upgrade.d.ts.map +1 -0
  7. package/dist/services/agent-catalog-upgrade.js +35 -0
  8. package/dist/services/agent-catalog-upgrade.js.map +1 -0
  9. package/dist/services/install-agents-template.d.ts.map +1 -1
  10. package/dist/services/install-agents-template.js +22 -22
  11. package/dist/services/install-agents-template.js.map +1 -1
  12. package/dist/services/install-template-policy.d.ts +3 -0
  13. package/dist/services/install-template-policy.d.ts.map +1 -0
  14. package/dist/services/install-template-policy.js +21 -0
  15. package/dist/services/install-template-policy.js.map +1 -0
  16. package/dist/services/logger.test.js +12 -2
  17. package/dist/services/logger.test.js.map +1 -1
  18. package/dist/services/sqlite-bootstrap.d.ts +1 -0
  19. package/dist/services/sqlite-bootstrap.d.ts.map +1 -1
  20. package/dist/services/sqlite-bootstrap.js +10 -1
  21. package/dist/services/sqlite-bootstrap.js.map +1 -1
  22. package/package.json +2 -2
  23. package/templates/.agents/config/agents/discovery.json +1 -1
  24. package/templates/.agents/dashboard/.zaip-managed.json +260 -116
  25. package/templates/.agents/dashboard/apps/frontend/dist/assets/{CostCalculationGuidePage-BBFDrn64.js → CostCalculationGuidePage-C5NgEcVh.js} +1 -1
  26. package/templates/.agents/dashboard/apps/frontend/dist/assets/{DashboardHelpDialog-Cd-qo9w7.js → DashboardHelpDialog-CCMVnkkI.js} +1 -1
  27. package/templates/.agents/dashboard/apps/frontend/dist/assets/{PricingSettingsDialog-J7L5m8lk.js → PricingSettingsDialog-CGYcJ5EB.js} +1 -1
  28. package/templates/.agents/dashboard/apps/frontend/dist/assets/{ProjectSettingsPage-BpsAFy0g.js → ProjectSettingsPage-DVCPPV75.js} +1 -1
  29. package/templates/.agents/dashboard/apps/frontend/dist/assets/{TraceabilityWorkspace-BzVtGLWS.js → TraceabilityWorkspace-CqK3Psfy.js} +1 -1
  30. package/templates/.agents/dashboard/apps/frontend/dist/assets/{cost-monitor-PoJA2PI1.css → cost-monitor-BsMfGfQi.css} +1 -1
  31. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor-j3aUYH5G.js +68 -0
  32. package/templates/.agents/dashboard/apps/frontend/dist/assets/{icons-vendor-CWzf_RiP.js → icons-vendor-x8xxL9yW.js} +1 -1
  33. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cl5EWx8R.js +2 -0
  34. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cwylbh_N.css +1 -0
  35. package/templates/.agents/dashboard/apps/frontend/dist/assets/{react-vendor-CtHdbZk3.js → react-vendor-CNOXIJHN.js} +1 -1
  36. package/templates/.agents/dashboard/apps/frontend/dist/assets/{traceability-BKrDH2TR.js → traceability-CcpbpT1s.js} +1 -1
  37. package/templates/.agents/dashboard/apps/frontend/dist/index.html +7 -7
  38. package/templates/.agents/dashboard/apps/frontend/package.json +1 -1
  39. package/templates/.agents/dashboard/apps/frontend/src/App.tsx +12 -1
  40. package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.test.tsx +33 -0
  41. package/templates/.agents/dashboard/apps/frontend/src/WorkspaceStatus.tsx +58 -0
  42. package/templates/.agents/dashboard/apps/frontend/src/app-work-board-options.ts +41 -0
  43. package/templates/.agents/dashboard/apps/frontend/src/dashboard-runtime-status.ts +25 -0
  44. package/templates/.agents/dashboard/apps/frontend/src/snapshot-coherence.test.ts +1 -1
  45. package/templates/.agents/dashboard/apps/frontend/src/use-app-cost-loaders.ts +5 -1
  46. package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.test.ts +140 -0
  47. package/templates/.agents/dashboard/apps/frontend/src/use-app-work-board.ts +28 -41
  48. package/templates/.agents/dashboard/apps/frontend/src/use-runtime-status.ts +38 -0
  49. package/templates/.agents/dashboard/apps/frontend/src/workspace-status.css +33 -0
  50. package/templates/.agents/dashboard/modules/cost-monitor/package.json +1 -1
  51. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.test.ts +25 -3
  52. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CompactLifecycleCostTable.tsx +17 -19
  53. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostFilters.tsx +13 -167
  54. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostGroupsTable.tsx +2 -9
  55. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.test.ts +8 -8
  56. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostMonitorPage.tsx +29 -52
  57. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTableLoading.test.ts +1 -1
  58. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables-keeps-legacy-codex-identity-fields-blank.test.ts +2 -2
  59. package/templates/.agents/dashboard/modules/cost-monitor/src/react/CostTables.test.ts +4 -27
  60. package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.test.ts +2 -2
  61. package/templates/.agents/dashboard/modules/cost-monitor/src/react/MacroCostTable.tsx +4 -3
  62. package/templates/.agents/dashboard/modules/cost-monitor/src/react/agent-model-presentation.test.ts +26 -0
  63. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-embedded.css +7 -0
  64. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-loaders.ts +173 -0
  65. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-props.ts +47 -0
  66. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-monitor-page-selectors.ts +1 -7
  67. package/templates/.agents/dashboard/modules/cost-monitor/src/react/cost-page-range.ts +3 -9
  68. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.test.ts +44 -83
  69. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-monitor-projection.ts +11 -111
  70. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.test.ts +47 -181
  71. package/templates/.agents/dashboard/modules/cost-monitor/src/server/build-cost-summary-projection.ts +63 -91
  72. package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-monitor-unavailable.test.ts +55 -0
  73. package/templates/.agents/dashboard/modules/cost-monitor/src/server/cost-summary-duration.test.ts +189 -0
  74. package/templates/.agents/dashboard/modules/operations/package.json +1 -1
  75. package/templates/.agents/dashboard/modules/operations/src/react/OperationsEntityFilters.tsx +82 -0
  76. package/templates/.agents/dashboard/modules/operations/src/react/OperationsPage.tsx +22 -31
  77. package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.test.tsx +13 -1
  78. package/templates/.agents/dashboard/modules/operations/src/react/PagedWorkList.tsx +16 -3
  79. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.test.ts +11 -27
  80. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportAction.tsx +44 -193
  81. package/templates/.agents/dashboard/modules/operations/src/react/export/ExcelExportColumns.ts +186 -0
  82. package/templates/.agents/dashboard/modules/operations/src/react/export/excel-agent-participations.test.ts +28 -0
  83. package/templates/.agents/dashboard/modules/operations/src/react/export/export-layout.test.ts +2 -1
  84. package/templates/.agents/dashboard/modules/operations/src/react/operations-export-duration.ts +13 -0
  85. package/templates/.agents/dashboard/modules/operations/src/react/operations-filter-panel.css +4 -0
  86. package/templates/.agents/dashboard/modules/operations/src/react/use-operation-filter-feedback.ts +18 -0
  87. package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.test.ts +11 -0
  88. package/templates/.agents/dashboard/modules/operations/src/react/work-board-model.ts +10 -2
  89. package/templates/.agents/dashboard/modules/operations/src/work-board-model.ts +1 -1
  90. package/templates/.agents/dashboard/modules/traceability/package.json +1 -1
  91. package/templates/.agents/dashboard/packages/branding/package.json +1 -1
  92. package/templates/.agents/dashboard/packages/contracts/package.json +1 -1
  93. package/templates/.agents/dashboard/packages/data-export/package.json +1 -1
  94. package/templates/.agents/dashboard/packages/local-runtime/dist/server.cjs +395 -341
  95. package/templates/.agents/dashboard/packages/local-runtime/dist/sqlite-read-model.cjs +346 -294
  96. package/templates/.agents/dashboard/packages/local-runtime/package.json +1 -1
  97. package/templates/.agents/dashboard/packages/local-runtime/scripts/rebuild-sqlite-read-model.mjs +2 -1
  98. package/templates/.agents/dashboard/packages/local-runtime/scripts/validate-sqlite-read-model.mjs +4 -2
  99. package/templates/.agents/dashboard/packages/local-runtime/server.mjs +395 -341
  100. package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.test.ts +95 -0
  101. package/templates/.agents/dashboard/packages/local-runtime/src/active-codex-telemetry.ts +102 -12
  102. package/templates/.agents/dashboard/packages/local-runtime/src/server-board.test.ts +75 -1
  103. package/templates/.agents/dashboard/packages/local-runtime/src/server-costs-routes.ts +10 -0
  104. package/templates/.agents/dashboard/packages/local-runtime/src/server-lifecycle-diagnostics.ts +50 -0
  105. package/templates/.agents/dashboard/packages/local-runtime/src/server-macro-population.test.ts +165 -0
  106. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-page-filters.ts +65 -0
  107. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.test.ts +111 -0
  108. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-pages.ts +53 -63
  109. package/templates/.agents/dashboard/packages/local-runtime/src/server-operations-runs-route.ts +19 -5
  110. package/templates/.agents/dashboard/packages/local-runtime/src/server-period-macro-metric.ts +11 -2
  111. package/templates/.agents/dashboard/packages/local-runtime/src/server-read-projections.ts +16 -9
  112. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-refresh.test.ts +46 -2
  113. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.test.ts +10 -2
  114. package/templates/.agents/dashboard/packages/local-runtime/src/server-snapshot-synchronization.ts +4 -3
  115. package/templates/.agents/dashboard/packages/local-runtime/src/server.test.ts +43 -1
  116. package/templates/.agents/dashboard/packages/local-runtime/src/server.ts +46 -11
  117. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-filter-matrix.test.ts +188 -0
  118. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-summary-details.test.ts +85 -0
  119. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-cost-summary-details.ts +147 -0
  120. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-first-fold-cache.ts +64 -54
  121. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-macro-classification.test.ts +172 -0
  122. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-materialize-projections.ts +1 -1
  123. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-projection.ts +2 -1
  124. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.test.ts +7 -7
  125. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-operations-work-list.ts +2 -1
  126. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-period-averages.ts +10 -1
  127. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-agent-dimension.ts +18 -82
  128. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-cached-cost-page.ts +169 -0
  129. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-developer.ts +205 -0
  130. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-entity-group.ts +13 -4
  131. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-filtered-dimension.ts +22 -23
  132. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-financial.ts +42 -209
  133. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-model-dimension.ts +18 -4
  134. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-provider-dimension.ts +9 -2
  135. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-summary.ts +76 -83
  136. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-query-view-page.ts +25 -161
  137. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-canonical.ts +18 -45
  138. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-counts-every-root-execution-day-returns.test.ts +2 -2
  139. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-filesystem.ts +16 -16
  140. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-multi-provider.test.ts +1 -1
  141. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-rebuild.ts +47 -22
  142. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model-schema.ts +3 -2
  143. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-read-model.test.ts +11 -0
  144. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-rebuild-result.ts +15 -0
  145. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-base-views.ts +4 -4
  146. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-dashboard-views.ts +15 -56
  147. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-schema-macro-classification.ts +48 -0
  148. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-summary-cursor.ts +15 -0
  149. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-token-active-allocation.ts +46 -0
  150. package/templates/.agents/dashboard/packages/local-runtime/src/sqlite-work-stages.ts +60 -0
  151. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-history.mjs +5 -1
  152. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-claims.test.mjs +7 -1
  153. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-launch-page.mjs +17 -2
  154. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-ownership.mjs +65 -0
  155. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-ownership.test.mjs +72 -0
  156. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard-processes.mjs +32 -9
  157. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.mjs +39 -45
  158. package/templates/.agents/dashboard/packages/local-runtime/start-dashboard.test.mjs +5 -2
  159. package/templates/.agents/dashboard/packages/ui/package.json +1 -1
  160. package/templates/.agents/dashboard/tests/e2e/package.json +1 -1
  161. package/templates/.agents/dashboard/tests/e2e/specs/dashboard-performance-matrix.spec.ts +1 -18
  162. package/templates/.agents/dashboard/tests/e2e/specs/export-row-identity.spec.ts +20 -0
  163. package/templates/.agents/dashboard/tests/e2e/specs/export-row-identity.ts +20 -0
  164. package/templates/.agents/design/.zaip-managed.json +82 -74
  165. package/templates/.agents/design/apps/catalog/dist/assets/index-0W0Gj_Gs.css +1 -0
  166. package/templates/.agents/design/apps/catalog/dist/assets/index-32GZO95T.js +72 -0
  167. package/templates/.agents/design/apps/catalog/dist/assets/{index-D_lfqoyx.js → index-BP8IxOxt.js} +3 -3
  168. package/templates/.agents/design/apps/catalog/dist/assets/{index-BOjCcUaU.js → index-QJsgr9Ht.js} +3 -3
  169. package/templates/.agents/design/apps/catalog/dist/index.html +2 -2
  170. package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-CvaciY0C.js +1 -0
  171. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{Color-6AOWCN3U-Cm-yJJz_.js → Color-6AOWCN3U-DwBV1A1Y.js} +1 -1
  172. package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-3dqK5g3e.js +142 -0
  173. package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-2OCgtT0I.js +1 -0
  174. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{DocsRenderer-JROSPFPF-Belk4jRr.js → DocsRenderer-JROSPFPF-CODg0rSl.js} +4 -4
  175. package/templates/.agents/design/apps/catalog/dist/storybook/assets/Primitives-BmeKjJW4.js +1 -0
  176. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{WithTooltip-7X4HQR7L-DoPvjkS1.js → WithTooltip-7X4HQR7L-C5MI-3uZ.js} +1 -1
  177. package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatus.stories-Tb_iQqVK.js +17 -0
  178. package/templates/.agents/design/apps/catalog/dist/storybook/assets/WorkspaceStatusSpecimen-CD54pw0-.js +1 -0
  179. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-DRQKCCAG-B1itKXEN.js → chunk-DRQKCCAG-KSn75jcy.js} +1 -1
  180. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{chunk-W22LQPXL-C-Eb5SPY.js → chunk-W22LQPXL-C4LS1Thf.js} +1 -1
  181. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{components-DnyKLwhj.js → components-DV1BRgMY.js} +5 -5
  182. package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-BU_68im1.js +1 -0
  183. package/templates/.agents/design/apps/catalog/dist/storybook/assets/iframe-0W0Gj_Gs.css +1 -0
  184. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{iframe-DcXBsFPz.js → iframe-CBbPFx5G.js} +4 -4
  185. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{react-18-CRM89QRf.js → react-18-C9IPGXtb.js} +1 -1
  186. package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-CEv2qkJT.js +1 -0
  187. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{syntaxhighlighter-YFXUGROL-B03jQGTF.js → syntaxhighlighter-YFXUGROL-ZgDQjyWI.js} +1 -1
  188. package/templates/.agents/design/apps/catalog/dist/storybook/assets/{theming-4ZyufAga.js → theming-Cx9-gH6l.js} +1 -1
  189. package/templates/.agents/design/apps/catalog/dist/storybook/iframe.html +2 -2
  190. package/templates/.agents/design/apps/catalog/dist/storybook/index.json +1 -1
  191. package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/a11y-2/manager-bundle.js +3 -3
  192. package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/docs-1/manager-bundle.js +4 -4
  193. package/templates/.agents/design/apps/catalog/dist/storybook/sb-addons/storybook-core-server-presets-0/common-manager-bundle.js +60 -60
  194. package/templates/.agents/design/apps/catalog/package.json +1 -1
  195. package/templates/.agents/design/apps/catalog/src/components/DashboardFiltersSpecimen.tsx +61 -0
  196. package/templates/.agents/design/apps/catalog/src/components/Primitives.tsx +24 -0
  197. package/templates/.agents/design/apps/catalog/src/components/WorkspaceStatusSpecimen.tsx +26 -0
  198. package/templates/.agents/design/apps/catalog/src/design-contract.test.ts +27 -13
  199. package/templates/.agents/design/apps/catalog/src/pages/ComponentsPage.tsx +38 -0
  200. package/templates/.agents/design/apps/catalog/src/pages/DesignSystemPage.tsx +15 -1
  201. package/templates/.agents/design/apps/catalog/src/stories/Components.stories.tsx +18 -0
  202. package/templates/.agents/design/apps/catalog/src/stories/DashboardFilters.stories.tsx +7 -0
  203. package/templates/.agents/design/apps/catalog/src/stories/WorkspaceStatus.stories.tsx +9 -0
  204. package/templates/.agents/design/apps/catalog/src/styles/components.css +83 -2
  205. package/templates/.agents/design/apps/catalog/src/styles.css +2 -0
  206. package/templates/.agents/design/packages/local-runtime/package.json +1 -1
  207. package/templates/.agents/design/tokens.json +32 -0
  208. package/templates/.agents/requirements/autonomous-assurance.md +1 -1
  209. package/templates/.agents/requirements/cloud-hostinger-autonomy.md +1 -1
  210. package/templates/.agents/requirements/comparative-audit.md +1 -1
  211. package/templates/.agents/requirements/context-engine.md +1 -1
  212. package/templates/.agents/requirements/cost-observability.md +1 -1
  213. package/templates/.agents/requirements/dashboard-launch.md +1 -1
  214. package/templates/.agents/requirements/data-export.md +1 -1
  215. package/templates/.agents/requirements/design-system.md +1 -1
  216. package/templates/.agents/requirements/execution-engine.md +1 -1
  217. package/templates/.agents/requirements/kanban-dashboard.md +1 -1
  218. package/templates/.agents/requirements/model-orchestration.md +1 -1
  219. package/templates/.agents/requirements/public-distribution.md +9 -3
  220. package/templates/.agents/requirements/software-architecture.md +1 -1
  221. package/templates/.agents/requirements/strategic-improvements.md +1 -1
  222. package/templates/.agents/requirements/work-lifecycle.md +1 -1
  223. package/templates/.agents/requirements/zaip-strategic-95.md +1 -1
  224. package/templates/.agents/rules/autonomy-decision.md +1 -0
  225. package/templates/.agents/rules/workflow.md +1 -1
  226. package/templates/.agents/runtime/VERSION +1 -1
  227. package/templates/.agents/runtime/bin/zaip.mjs +25 -24
  228. package/templates/.agents/runtime/checksums.sha256 +5 -5
  229. package/templates/.agents/runtime/manifest.json +1 -1
  230. package/templates/.agents/runtime/provenance.json +4 -4
  231. package/templates/.agents/runtime/sbom.cdx.json +1 -1
  232. package/templates/.agents/skills/zaip-skill-execution/SKILL.md +13 -0
  233. package/templates/.agents/skills/zaip-skill-execution/references/autonomous-continuation.md +17 -0
  234. package/templates/.agents/skills/zaip-skill-execution/references/correction-cycle.md +2 -2
  235. package/templates/.agents/skills/zaip-skill-github-deploy/SKILL.md +4 -2
  236. package/templates/.agents/skills/zaip-skill-github-deploy/references/deployment-workflow.md +4 -2
  237. package/templates/.agents/skills/zaip-skill-github-deploy/references/release-identity.md +2 -2
  238. package/templates/.agents/skills/zaip-skill-move-prd/SKILL.md +4 -0
  239. package/templates/.agents/skills/zaip-skill-move-spec/SKILL.md +4 -0
  240. package/templates/.agents/skills/zaip-skill-prd/SKILL.md +3 -3
  241. package/templates/.agents/skills/zaip-skill-release-qualification/SKILL.md +11 -8
  242. package/templates/.agents/skills/zaip-skill-release-qualification/references/local-preparation.md +13 -12
  243. package/templates/.agents/skills/zaip-skill-setup/SKILL.md +17 -2
  244. package/templates/.agents/skills/zaip-skill-setup/agents/openai.yaml +1 -1
  245. package/templates/.agents/skills/zaip-skill-spec/SKILL.md +2 -2
  246. package/templates/.agents/zaip-aios/VERSION +1 -1
  247. package/templates/template-manifest.json +392 -236
  248. package/templates/.agents/dashboard/apps/frontend/dist/assets/cost-monitor--iPcnZdx.js +0 -68
  249. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-Cmlx8OYH.css +0 -1
  250. package/templates/.agents/dashboard/apps/frontend/dist/assets/index-DfdlGa7c.js +0 -2
  251. package/templates/.agents/design/apps/catalog/dist/assets/index-BEmIE7WE.css +0 -1
  252. package/templates/.agents/design/apps/catalog/dist/assets/index-BJV597iq.js +0 -72
  253. package/templates/.agents/design/apps/catalog/dist/assets/index-B_WhrCZe.js +0 -72
  254. package/templates/.agents/design/apps/catalog/dist/assets/index-CqqYWY2f.js +0 -9
  255. package/templates/.agents/design/apps/catalog/dist/assets/index-CqtYXZfV.js +0 -72
  256. package/templates/.agents/design/apps/catalog/dist/assets/index-D9pj7Jlf.js +0 -9
  257. package/templates/.agents/design/apps/catalog/dist/assets/index-i_PO2k9R.js +0 -9
  258. package/templates/.agents/design/apps/catalog/dist/storybook/assets/CatalogShell-Cstn1UwA.js +0 -1
  259. package/templates/.agents/design/apps/catalog/dist/storybook/assets/Components.stories-D1WopB2L.js +0 -137
  260. package/templates/.agents/design/apps/catalog/dist/storybook/assets/DesignSystem.stories-DQ9PJ3N3.js +0 -1
  261. package/templates/.agents/design/apps/catalog/dist/storybook/assets/formatter-L2YTDE3Q-D0OSgxWz.js +0 -1
  262. package/templates/.agents/design/apps/catalog/dist/storybook/assets/iframe-BEmIE7WE.css +0 -1
  263. package/templates/.agents/design/apps/catalog/dist/storybook/assets/react-C3tkVMIp.js +0 -1
@@ -1,11 +1,14 @@
1
1
  import { isDateOnlyCostPage, readDateOnlyCostDimensionPage } from "./sqlite-cost-agent-page.js";
2
- import { filterCostInvocationProjection } from "./sqlite-cost-invocation-page.js";
3
2
  import {
4
3
  attachOperationsWorkListDevelopers,
5
4
  operationsWorkListPayloadPage,
6
5
  operationsWorkListSqlPage,
7
6
  } from "./sqlite-operations-work-list.js";
8
7
  import { readAgentDimension } from "./sqlite-query-agent-dimension.js";
8
+ import {
9
+ readCachedCostViewPage,
10
+ type SqliteViewPageInput,
11
+ } from "./sqlite-query-cached-cost-page.js";
9
12
  import type { SqliteQueryContext, SqliteViewPage } from "./sqlite-query-context.js";
10
13
  import { readEntityGroup } from "./sqlite-query-entity-group.js";
11
14
  import { readFilteredDimension } from "./sqlite-query-filtered-dimension.js";
@@ -17,164 +20,10 @@ import { type SqliteViewName, sqliteViewMetadata } from "./sqlite-read-model-typ
17
20
  export function queryUncachedViewPage(
18
21
  context: SqliteQueryContext,
19
22
  view: SqliteViewName,
20
- input: {
21
- from?: string | null;
22
- to?: string | null;
23
- query?: string;
24
- status?: string;
25
- risk?: string;
26
- provider?: string;
27
- model?: string;
28
- agent?: string;
29
- phase?: string;
30
- origin?: string;
31
- workType?: string;
32
- priority?: string;
33
- kind?: "all" | "all-tasks" | "task" | "standalone-task" | "prd" | "spec";
34
- offset?: number;
35
- limit?: number;
36
- },
23
+ input: SqliteViewPageInput,
37
24
  ): SqliteViewPage {
38
- const isUnfilteredAllTimeCostPage =
39
- !input.from &&
40
- !input.to &&
41
- !input.query &&
42
- !input.status &&
43
- !input.risk &&
44
- !input.provider &&
45
- !input.model &&
46
- !input.agent &&
47
- !input.phase &&
48
- !input.origin &&
49
- !input.workType &&
50
- !input.priority;
51
- const isDateOnlyCostInvocationPage =
52
- view === "cost_monitor_agent_invocations" &&
53
- !input.query &&
54
- !input.status &&
55
- !input.risk &&
56
- !input.provider &&
57
- !input.model &&
58
- !input.agent &&
59
- !input.phase &&
60
- !input.origin &&
61
- !input.workType &&
62
- !input.priority;
63
- if (isDateOnlyCostInvocationPage) {
64
- const projection = filterCostInvocationProjection(
65
- context.technicalPayloadRows("cost_agent_invocation_projection_v1"),
66
- input,
67
- );
68
- if (projection.length > 0) {
69
- const limit = Math.min(200, Math.max(1, input.limit ?? 100));
70
- const offset = Math.max(0, input.offset ?? 0);
71
- const rows = projection.slice(offset, offset + limit);
72
- return {
73
- data_source: "sqlite_read_model" as const,
74
- view,
75
- offset,
76
- limit,
77
- total_count: projection.length,
78
- has_more: offset + rows.length < projection.length,
79
- rows,
80
- };
81
- }
82
- }
83
- const remoteAggregateDimensions: Partial<Record<SqliteViewName, string>> = {
84
- cost_monitor_zaip_agents: "agent",
85
- cost_monitor_executions: "execution",
86
- cost_monitor_tasks: "task",
87
- cost_monitor_conversations: "conversation",
88
- };
89
- const remoteAggregateDimension = remoteAggregateDimensions[view];
90
- if (isUnfilteredAllTimeCostPage && remoteAggregateDimension !== undefined) {
91
- const projection = context
92
- .technicalPayloadRows("cost_dimension_aggregate_v1")
93
- .filter((row) => row.dimension === remoteAggregateDimension);
94
- const rows = projection
95
- .filter((row) => row.row_kind === "row")
96
- .map((row) =>
97
- view === "cost_monitor_zaip_agents"
98
- ? {
99
- key: row.key,
100
- label: row.label,
101
- persona: row.persona,
102
- job: row.job,
103
- latest_started_at: row.latest_started_at,
104
- invocation_count: row.invocation_count,
105
- task_count: row.task_count,
106
- total_duration: row.total_duration,
107
- duration_unknown: row.duration_unknown,
108
- duration_known: row.duration_known,
109
- source_event_count: row.source_event_count,
110
- total_tokens: row.total_tokens,
111
- total_cost_usd: row.total_cost_usd,
112
- total_cost_brl: row.total_cost_brl,
113
- }
114
- : {
115
- id: row.id,
116
- key: row.key,
117
- title: row.title,
118
- status: row.status,
119
- risk: row.risk,
120
- first_day: row.first_day,
121
- last_day: row.last_day,
122
- occurred_at: row.occurred_at,
123
- invocation_count: row.invocation_count,
124
- llm_call_count: row.llm_call_count,
125
- total_duration: row.total_duration,
126
- total_input_tokens: row.total_input_tokens,
127
- total_cached_input_tokens: row.total_cached_input_tokens,
128
- total_output_tokens: row.total_output_tokens,
129
- total_reasoning_tokens: row.total_reasoning_tokens,
130
- total_tokens: row.total_tokens,
131
- total_cost_usd: row.total_cost_usd,
132
- total_cost_brl: row.total_cost_brl,
133
- },
134
- )
135
- .sort(
136
- (left, right) =>
137
- Number(right.total_cost_brl ?? -1) - Number(left.total_cost_brl ?? -1) ||
138
- String(left.key ?? "").localeCompare(String(right.key ?? "")),
139
- ) as Array<Record<string, unknown>>;
140
- const totals = projection.find((row) => row.row_kind === "totals");
141
- if (rows.length > 0 && totals !== undefined) {
142
- const limit = Math.min(200, Math.max(1, input.limit ?? 50));
143
- const offset = Math.max(0, input.offset ?? 0);
144
- const page = rows.slice(offset, offset + limit);
145
- const publicTotals =
146
- view !== "cost_monitor_zaip_agents"
147
- ? {
148
- entity_count: totals.entity_count,
149
- invocation_count: totals.invocation_count,
150
- total_duration: totals.total_duration,
151
- total_tokens: totals.total_tokens,
152
- total_cost_usd: totals.total_cost_usd,
153
- total_cost_brl: totals.total_cost_brl,
154
- }
155
- : {
156
- invocation_count: totals.invocation_count,
157
- task_count: totals.task_count,
158
- total_duration: totals.total_duration,
159
- duration_unknown: totals.duration_unknown,
160
- duration_known: totals.duration_known,
161
- source_event_count: totals.source_event_count,
162
- total_tokens: totals.total_tokens,
163
- total_cost_usd: totals.total_cost_usd,
164
- total_cost_brl: totals.total_cost_brl,
165
- };
166
- return {
167
- data_source: "sqlite_read_model" as const,
168
- view,
169
- offset,
170
- limit,
171
- total_count: rows.length,
172
- has_more: offset + page.length < rows.length,
173
- totals: publicTotals,
174
- rows: page,
175
- };
176
- }
177
- }
25
+ const cachedCostPage = readCachedCostViewPage(context, view, input);
26
+ if (cachedCostPage !== null) return cachedCostPage;
178
27
  const cacheableUnfilteredViews: readonly SqliteViewName[] = [
179
28
  "operations_work_kanban",
180
29
  "operations_executions",
@@ -239,7 +88,20 @@ export function queryUncachedViewPage(
239
88
  };
240
89
  exact("i.zaip_agent", input.agent);
241
90
  exact("i.phase", input.phase);
242
- exact("i.status", input.status);
91
+ exact("COALESCE(t.status, i.status)", input.status);
92
+ exact("t.priority", input.priority);
93
+ exact("t.risk", input.risk);
94
+ exact("i.work_type", input.workType);
95
+ if (input.origin)
96
+ clauses.push(
97
+ input.origin === "prd"
98
+ ? "i.prd_id IS NOT NULL"
99
+ : input.origin === "spec"
100
+ ? "i.prd_id IS NULL AND i.spec_id IS NOT NULL"
101
+ : input.origin === "task"
102
+ ? "i.prd_id IS NULL AND i.spec_id IS NULL AND i.task_id IS NOT NULL"
103
+ : "i.prd_id IS NULL AND i.spec_id IS NULL AND i.task_id IS NULL",
104
+ );
243
105
  const usageSegmentClauses: string[] = [];
244
106
  if (input.provider) {
245
107
  if (input.provider === "unavailable") {
@@ -275,13 +137,15 @@ export function queryUncachedViewPage(
275
137
  const total_count = Number(
276
138
  (
277
139
  context.database
278
- .prepare(`SELECT COUNT(*) AS count FROM cost_monitor_agent_invocations i WHERE ${where}`)
140
+ .prepare(
141
+ `SELECT COUNT(*) AS count FROM cost_monitor_agent_invocations i LEFT JOIN tasks t ON t.id=i.task_id WHERE ${where}`,
142
+ )
279
143
  .get(...values) as { count: number }
280
144
  ).count,
281
145
  );
282
146
  const rows = context.database
283
147
  .prepare(
284
- `SELECT i.* FROM cost_monitor_agent_invocations i WHERE ${where} ORDER BY i.occurred_at DESC, i.agent_invocation_id DESC LIMIT ? OFFSET ?`,
148
+ `SELECT i.*, t.priority, t.risk, t.status AS task_status, t.title AS task_title FROM cost_monitor_agent_invocations i LEFT JOIN tasks t ON t.id=i.task_id WHERE ${where} ORDER BY i.occurred_at DESC, i.agent_invocation_id DESC LIMIT ? OFFSET ?`,
285
149
  )
286
150
  .all(...values, limit, offset) as Array<Record<string, unknown>>;
287
151
  return {
@@ -1,3 +1,4 @@
1
+ import { taskWorkStage } from "@zaip-ai/dashboard-operations/work-board-model";
1
2
  import {
2
3
  consolidatedValue,
3
4
  frontMatterRecord,
@@ -57,7 +58,9 @@ export type CanonicalEntity = {
57
58
  status: string | null;
58
59
  stage: string | null;
59
60
  risk: string | null;
61
+ priority: string | null;
60
62
  specId: string | null;
63
+ prdId: string | null;
61
64
  changeId: string | null;
62
65
  occurredAt: string | null;
63
66
  creationRunId: string | null;
@@ -233,9 +236,19 @@ export function readCanonicalEntities(
233
236
  id,
234
237
  title: scalar("title"),
235
238
  status: scalar("status"),
236
- stage: scalar("stage"),
239
+ stage:
240
+ kind === "task"
241
+ ? taskWorkStage({
242
+ status: scalar("status") as Parameters<typeof taskWorkStage>[0]["status"],
243
+ spec_id: scalar("spec_id"),
244
+ started_at: scalar("started_at"),
245
+ attempt_count: Number(scalar("attempt_count") ?? 0),
246
+ })
247
+ : scalar("stage"),
237
248
  risk: scalar("risk"),
249
+ priority: scalar("priority"),
238
250
  specId: scalar("spec_id"),
251
+ prdId: scalar("prd_id"),
239
252
  changeId: scalar("change_id"),
240
253
  occurredAt: scalar("created_at") ?? scalar("started_at") ?? scalar("recorded_at"),
241
254
  creationRunId: scalar("creation_run_id"),
@@ -694,50 +707,10 @@ export function usagePricingAudit(
694
707
  };
695
708
  }
696
709
 
697
- export type TemporalInterval = { activityRowId: string; startMs: number; endMs: number };
698
-
699
- /**
700
- * Splits every observed interval at every activity boundary and São Paulo day
701
- * boundary. Each elementary segment is divided equally among the token-active
702
- * activities covering it, making the materialized fact additive by activity,
703
- * day, and every parent dimension.
704
- */
705
- export function allocateAttributedTokenActiveMs(intervals: readonly TemporalInterval[]) {
706
- const boundaries = new Set<number>();
707
- for (const interval of intervals) {
708
- boundaries.add(interval.startMs);
709
- boundaries.add(interval.endMs);
710
- for (let cursor = interval.startMs; cursor < interval.endMs; ) {
711
- const nextDay =
712
- Date.parse(`${saoPauloDay(new Date(cursor).toISOString())}T03:00:00.000Z`) + 86_400_000;
713
- if (nextDay >= interval.endMs) break;
714
- boundaries.add(nextDay);
715
- cursor = nextDay;
716
- }
717
- }
718
- const points = [...boundaries].sort((left, right) => left - right);
719
- const allocated = new Map<string, { activityRowId: string; day: string; value: number }>();
720
- for (let index = 0; index < points.length - 1; index += 1) {
721
- const startMs = points[index]!;
722
- const endMs = points[index + 1]!;
723
- const active = intervals.filter(
724
- (interval) => interval.startMs < endMs && interval.endMs > startMs,
725
- );
726
- if (active.length === 0 || endMs <= startMs) continue;
727
- const share = (endMs - startMs) / active.length;
728
- const day = saoPauloDay(new Date(startMs).toISOString());
729
- for (const interval of active) {
730
- const key = `${interval.activityRowId}:${day}`;
731
- const previous = allocated.get(key);
732
- allocated.set(key, {
733
- activityRowId: interval.activityRowId,
734
- day,
735
- value: (previous?.value ?? 0) + share,
736
- });
737
- }
738
- }
739
- return [...allocated.values()];
740
- }
710
+ export {
711
+ allocateAttributedTokenActiveMs,
712
+ type TemporalInterval,
713
+ } from "./sqlite-token-active-allocation.js";
741
714
 
742
715
  /** A dashboard API boundary can be a date or an ISO instant. Normalize both
743
716
  * to the same Sao Paulo calendar key used by Cost Monitor SQL buckets. */
@@ -662,8 +662,8 @@ describe("SQLite dashboard read model", () => {
662
662
  });
663
663
  }
664
664
  expect(filesystem.viewPage("cost_monitor_tasks", { workType: "new", limit: 1 })).toMatchObject({
665
- total_count: 0,
666
- rows: [],
665
+ total_count: 2,
666
+ rows: [expect.objectContaining({ id: "TASK-B", total_tokens: 4 })],
667
667
  });
668
668
  expect(filesystem.firstFoldAllTime()).toBe(allTime);
669
669
  filesystem.close();
@@ -5,6 +5,7 @@ import { attachAgentProductivity } from "./sqlite-agent-productivity.js";
5
5
  import {
6
6
  readFirstFoldAllTime,
7
7
  readFirstFoldBoardAllTime,
8
+ readFirstFoldMacroMetrics,
8
9
  readFirstFoldMonthlyQuick,
9
10
  readFirstFoldTopTasksAllTime,
10
11
  readFirstFoldViewport,
@@ -45,6 +46,7 @@ import {
45
46
  sqliteViewMetadata,
46
47
  } from "./sqlite-read-model-types.js";
47
48
  import { installLegacyViewAliases } from "./sqlite-snapshot-cache.js";
49
+ import { encodeSummaryCursor, parseSummaryCursor } from "./sqlite-summary-cursor.js";
48
50
  export class SqliteReadModelFileSystem extends WorkspaceFileSystem {
49
51
  private readonly executionDurationCache = new Map<string, Map<string, number>>();
50
52
  private dailyAggregateRowsCache: Array<Record<string, number | string | null>> | null = null;
@@ -305,6 +307,10 @@ export class SqliteReadModelFileSystem extends WorkspaceFileSystem {
305
307
  return this.firstFoldAllTimeCache;
306
308
  }
307
309
 
310
+ firstFoldMacroMetrics(): SqliteFirstFoldAllTime["macro_metrics"] {
311
+ return this.firstFoldAllTimeCache?.macro_metrics ?? readFirstFoldMacroMetrics(this.database);
312
+ }
313
+
308
314
  firstFoldBoardAllTime(): SqliteFirstFoldAllTimeBoard {
309
315
  if (this.firstFoldAllTimeBoardCache !== null) return this.firstFoldAllTimeBoardCache;
310
316
  this.firstFoldAllTimeBoardCache = readFirstFoldBoardAllTime(this.database, () => {
@@ -438,6 +444,7 @@ export class SqliteReadModelFileSystem extends WorkspaceFileSystem {
438
444
  }
439
445
 
440
446
  invocationCostRows(filter: {
447
+ query?: string;
441
448
  from: string | null;
442
449
  to: string | null;
443
450
  providers?: readonly string[];
@@ -450,6 +457,10 @@ export class SqliteReadModelFileSystem extends WorkspaceFileSystem {
450
457
  prds?: readonly string[];
451
458
  executions?: readonly string[];
452
459
  changes?: readonly string[];
460
+ priorities?: readonly string[];
461
+ risks?: readonly string[];
462
+ origins?: readonly string[];
463
+ workTypes?: readonly string[];
453
464
  }) {
454
465
  return queryInvocationCostRows(this.queryContext(), filter);
455
466
  }
@@ -471,6 +482,7 @@ export class SqliteReadModelFileSystem extends WorkspaceFileSystem {
471
482
 
472
483
  /** Complete canonical Run population for global Cost Monitor aggregates. */
473
484
  activityCostRows(filter: {
485
+ query?: string;
474
486
  from: string | null;
475
487
  to: string | null;
476
488
  providers?: readonly string[];
@@ -483,6 +495,10 @@ export class SqliteReadModelFileSystem extends WorkspaceFileSystem {
483
495
  prds?: readonly string[];
484
496
  executions?: readonly string[];
485
497
  changes?: readonly string[];
498
+ priorities?: readonly string[];
499
+ risks?: readonly string[];
500
+ origins?: readonly string[];
501
+ workTypes?: readonly string[];
486
502
  }) {
487
503
  return queryActivityCostRows(this.queryContext(), filter);
488
504
  }
@@ -744,19 +760,3 @@ export class SqliteReadModelFileSystem extends WorkspaceFileSystem {
744
760
  };
745
761
  }
746
762
  }
747
-
748
- function encodeSummaryCursor(occurredAt: string, id: string): string {
749
- return encodeURIComponent(JSON.stringify([occurredAt, id]));
750
- }
751
-
752
- function parseSummaryCursor(cursor: string | null): [string, string] | null {
753
- if (cursor === null) return null;
754
- try {
755
- const parsed = JSON.parse(decodeURIComponent(cursor));
756
- return Array.isArray(parsed) && typeof parsed[0] === "string" && typeof parsed[1] === "string"
757
- ? [parsed[0], parsed[1]]
758
- : null;
759
- } catch {
760
- return null;
761
- }
762
- }
@@ -247,7 +247,7 @@ describe("SQLite dashboard read model multi-provider", () => {
247
247
  validation_count: null,
248
248
  evidence_count: null,
249
249
  });
250
- expect(filesystem.viewPage(view, { workType: "new" }).total_count).toBe(0);
250
+ expect(filesystem.viewPage(view, { workType: "new" }).total_count).toBeGreaterThan(0);
251
251
  }
252
252
  expect(filesystem.viewPage("cost_monitor_zaip_agents", { priority: "high" })).toMatchObject({
253
253
  total_count: 0,
@@ -30,31 +30,25 @@ import {
30
30
  validateSqliteReadModelSchema,
31
31
  } from "./sqlite-read-model-schema.js";
32
32
  import { sourceFingerprint } from "./sqlite-read-model-source-fingerprint.js";
33
+ import type { SqliteRebuildResult } from "./sqlite-rebuild-result.js";
33
34
  import { readSnapshotFileCount } from "./sqlite-snapshot-cache.js";
35
+ import { deriveCanonicalWorkStages } from "./sqlite-work-stages.js";
34
36
  export async function rebuildSqliteReadModel(
35
37
  workspaceRoot: string,
36
38
  options: { forceCanonical?: boolean; preferExisting?: boolean } = {},
37
- ): Promise<{
38
- files: number;
39
- path: string;
40
- cache: "generation" | "seed" | "stale_seed" | "rebuilt";
41
- fingerprint_ms: number;
42
- materialize_ms: number;
43
- refresh: {
44
- reused_sources: number;
45
- processed_sources: number;
46
- added_sources: number;
47
- changed_sources: number;
48
- removed_sources: number;
49
- canonical_runs_refolded: number;
50
- };
51
- }> {
39
+ ): Promise<SqliteRebuildResult> {
52
40
  const path = sqliteReadModelPath(workspaceRoot);
53
- // Bind immediately from the last complete transaction. The serving process
54
- // checks canonical freshness in its worker before declaring this current.
41
+ // A reusable snapshot still has to match its canonical fingerprint. This
42
+ // avoids advertising every launch as stale while preserving the stale seed
43
+ // path for a changed source or an incompatible database.
55
44
  if (options.preferExisting && !options.forceCanonical) {
56
45
  try {
57
46
  validateSqliteReadModelSchema(path);
47
+ const fingerprintStartedAt = performance.now();
48
+ const sourceSnapshot = await sourceFingerprint(workspaceRoot, {
49
+ previous: persistedSourceCheckpoint(path),
50
+ });
51
+ const fingerprint = `${sourceSnapshot.fingerprint}\ncurrent_day=${saoPauloDay(new Date().toISOString())}`;
58
52
  const database = new DatabaseSync(path, { readOnly: true });
59
53
  try {
60
54
  if (hasReusableSnapshotPayloads(database)) {
@@ -63,15 +57,38 @@ export async function rebuildSqliteReadModel(
63
57
  "SELECT value FROM zaip_vw_read_model_metadata WHERE key = 'source_file_count'",
64
58
  )
65
59
  .get() as { value: string };
60
+ const files = readSnapshotFileCount(
61
+ path,
62
+ fingerprint,
63
+ readModelSchemaVersion,
64
+ hasReusableSnapshotPayloads,
65
+ );
66
+ if (files !== null) {
67
+ return {
68
+ files,
69
+ path,
70
+ cache: "generation",
71
+ fingerprint_ms: Math.round(performance.now() - fingerprintStartedAt),
72
+ materialize_ms: 0,
73
+ refresh: {
74
+ reused_sources: sourceSnapshot.reusedFiles,
75
+ processed_sources: sourceSnapshot.hashedFiles,
76
+ added_sources: 0,
77
+ changed_sources: 0,
78
+ removed_sources: 0,
79
+ canonical_runs_refolded: 0,
80
+ },
81
+ };
82
+ }
66
83
  return {
67
84
  files: Number(row.value),
68
85
  path,
69
86
  cache: "stale_seed",
70
- fingerprint_ms: 0,
87
+ fingerprint_ms: Math.round(performance.now() - fingerprintStartedAt),
71
88
  materialize_ms: 0,
72
89
  refresh: {
73
- reused_sources: 0,
74
- processed_sources: 0,
90
+ reused_sources: sourceSnapshot.reusedFiles,
91
+ processed_sources: sourceSnapshot.hashedFiles,
75
92
  added_sources: 0,
76
93
  changed_sources: 0,
77
94
  removed_sources: 0,
@@ -397,7 +414,7 @@ export async function rebuildSqliteReadModel(
397
414
  CREATE TEMP TABLE files (path TEXT PRIMARY KEY, content TEXT NOT NULL, mtime_ms REAL NOT NULL, size_bytes INTEGER NOT NULL, content_sha256 TEXT NOT NULL, artifact_kind TEXT, artifact_id TEXT, artifact_occurred_at TEXT, artifact_occurred_day_sp TEXT, artifact_task_id TEXT, artifact_change_id TEXT, artifact_run_id TEXT);
398
415
  CREATE TEMP TABLE read_model_source_state (source_path TEXT PRIMARY KEY, source_hash TEXT NOT NULL, mtime_ms TEXT NOT NULL, ctime_ms TEXT NOT NULL, size_bytes INTEGER NOT NULL, file_identity TEXT NOT NULL, source_kind TEXT NOT NULL, last_processed_at TEXT NOT NULL);
399
416
  CREATE TEMP TABLE read_model_metadata (key TEXT PRIMARY KEY, value TEXT NOT NULL);
400
- CREATE TEMP TABLE canonical_work_items (entity_kind TEXT NOT NULL, id TEXT NOT NULL, title TEXT, status TEXT, stage TEXT, risk TEXT, spec_id TEXT, change_id TEXT, creation_run_id TEXT, completed_run_id TEXT, occurred_at TEXT NOT NULL, occurred_day_sp TEXT NOT NULL, PRIMARY KEY(entity_kind, id));
417
+ CREATE TEMP TABLE canonical_work_items (entity_kind TEXT NOT NULL, id TEXT NOT NULL, title TEXT, status TEXT, stage TEXT, risk TEXT, priority TEXT, spec_id TEXT, prd_id TEXT, change_id TEXT, creation_run_id TEXT, completed_run_id TEXT, occurred_at TEXT NOT NULL, occurred_day_sp TEXT NOT NULL, PRIMARY KEY(entity_kind, id));
401
418
  CREATE TEMP TABLE canonical_executions (id TEXT PRIMARY KEY, status TEXT, kind TEXT, origin_type TEXT, origin_id TEXT, created_at TEXT NOT NULL, occurred_day_sp TEXT NOT NULL, finished_at TEXT, source_path TEXT NOT NULL);
402
419
  CREATE TEMP TABLE canonical_changes (id TEXT PRIMARY KEY, title TEXT NOT NULL, status TEXT NOT NULL, risk TEXT NOT NULL, source_type TEXT NOT NULL, source_id TEXT NOT NULL, source_spec_id TEXT, source_prd_id TEXT, requirement_ids_json TEXT NOT NULL, acceptance_ids_json TEXT NOT NULL, task_ids_json TEXT NOT NULL, result TEXT, created_at TEXT NOT NULL, occurred_day_sp TEXT NOT NULL, source_path TEXT NOT NULL);
403
420
  CREATE TEMP TABLE canonical_decisions (id TEXT PRIMARY KEY, title TEXT NOT NULL, origin TEXT NOT NULL, scope_type TEXT NOT NULL, scope_id TEXT NOT NULL, created_at TEXT NOT NULL, occurred_day_sp TEXT NOT NULL, source_path TEXT NOT NULL);
@@ -599,7 +616,7 @@ export async function rebuildSqliteReadModel(
599
616
  if (entity.creationRunId) changedCreationRunIds.add(entity.creationRunId);
600
617
  reportLaunchProgress("projection_entities", 75, "Entidades canônicas interpretadas.");
601
618
  const insertCanonicalWorkItem = database.prepare(
602
- "INSERT INTO canonical_work_items(entity_kind, id, title, status, stage, risk, spec_id, change_id, creation_run_id, completed_run_id, occurred_at, occurred_day_sp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
619
+ "INSERT INTO canonical_work_items(entity_kind, id, title, status, stage, risk, priority, spec_id, prd_id, change_id, creation_run_id, completed_run_id, occurred_at, occurred_day_sp) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
603
620
  );
604
621
  for (const entity of canonicalEntities.values()) {
605
622
  if (
@@ -615,7 +632,9 @@ export async function rebuildSqliteReadModel(
615
632
  entity.status,
616
633
  entity.stage,
617
634
  entity.risk,
635
+ entity.priority,
618
636
  entity.specId,
637
+ entity.prdId,
619
638
  entity.changeId,
620
639
  entity.creationRunId,
621
640
  entity.completedRunId,
@@ -700,6 +719,12 @@ export async function rebuildSqliteReadModel(
700
719
  entity.sourcePath,
701
720
  );
702
721
  reportLaunchProgress("projection_runs_started", 77, "Construindo fatos das invocações.");
722
+ deriveCanonicalWorkStages(canonicalEntities, canonicalLifecycle.changes);
723
+ const updateWorkStage = database.prepare(
724
+ "UPDATE canonical_work_items SET stage=? WHERE entity_kind=? AND id=?",
725
+ );
726
+ for (const entity of canonicalEntities.values())
727
+ updateWorkStage.run(entity.stage, entity.kind, entity.id);
703
728
  const runMaterialization = materializeCanonicalRuns({
704
729
  database,
705
730
  previousActivities,
@@ -4,9 +4,10 @@ import { DatabaseSync } from "node:sqlite";
4
4
  import { hasRequiredFirstFoldPayloads } from "./sqlite-first-fold-persistence.js";
5
5
  import type { SqliteReadModelSourceCheckpoint } from "./sqlite-read-model-source-fingerprint.js";
6
6
  export const dbRelativePath = ".local/sqlite/zaip-aios-dashboard.sqlite";
7
- // Schema 80 requires the persisted macro classification fields used by period views.
7
+ // Schema 83 adds canonical priority, Run work type and reconciled macro stages.
8
8
  // Old snapshots must rebuild even when their canonical hashes still match.
9
- export const readModelSchemaVersion = "80";
9
+ // Refresh persisted first-fold summaries after factual duration/coverage semantics change.
10
+ export const readModelSchemaVersion = "84";
10
11
  export const requiredPersistedTables = [
11
12
  "zaip_aios_activities",
12
13
  "zaip_dim_llm_model",
@@ -87,6 +87,17 @@ describe("SQLite dashboard read model", () => {
87
87
  filesystem.close();
88
88
  }
89
89
  });
90
+ it("reuses an unchanged verified fingerprint as the current generation", async () => {
91
+ const root = await createSqliteTestRoot();
92
+ roots.push(root);
93
+ await mkdir(join(root, ".agents/config"), { recursive: true });
94
+ await writeFile(join(root, ".agents/config/project.yaml"), "zaip:\n enabled: true\n");
95
+ vi.spyOn(Date, "now").mockReturnValue(Date.now() + 5_000);
96
+ await rebuildSqliteReadModel(root);
97
+ await expect(rebuildSqliteReadModel(root, { preferExisting: true })).resolves.toMatchObject({
98
+ cache: "generation",
99
+ });
100
+ });
90
101
  it("rolls back a failed refresh including first-fold payloads while a reader remains open", async () => {
91
102
  const root = await createSqliteTestRoot();
92
103
  roots.push(root);
@@ -0,0 +1,15 @@
1
+ export type SqliteRebuildResult = {
2
+ files: number;
3
+ path: string;
4
+ cache: "generation" | "seed" | "stale_seed" | "rebuilt";
5
+ fingerprint_ms: number;
6
+ materialize_ms: number;
7
+ refresh: {
8
+ reused_sources: number;
9
+ processed_sources: number;
10
+ added_sources: number;
11
+ changed_sources: number;
12
+ removed_sources: number;
13
+ canonical_runs_refolded: number;
14
+ };
15
+ };
@@ -25,7 +25,7 @@ export const baseViewSql = `
25
25
  CREATE VIEW files AS SELECT json_extract(payload_json, '$.path') AS path, json_extract(payload_json, '$.content') AS content, json_extract(payload_json, '$.mtime_ms') AS mtime_ms, json_extract(payload_json, '$.size_bytes') AS size_bytes, json_extract(payload_json, '$.content_sha256') AS content_sha256, json_extract(payload_json, '$.artifact_kind') AS artifact_kind, json_extract(payload_json, '$.artifact_id') AS artifact_id, json_extract(payload_json, '$.artifact_occurred_at') AS artifact_occurred_at, json_extract(payload_json, '$.artifact_occurred_day_sp') AS artifact_occurred_day_sp, json_extract(payload_json, '$.artifact_task_id') AS artifact_task_id, json_extract(payload_json, '$.artifact_change_id') AS artifact_change_id, json_extract(payload_json, '$.artifact_run_id') AS artifact_run_id FROM zaip_aios_activities INDEXED BY zaip_activities_file_path WHERE payload_type='file';
26
26
  CREATE VIEW read_model_source_state AS SELECT json_extract(payload_json, '$.source_path') AS source_path, json_extract(payload_json, '$.source_hash') AS source_hash, json_extract(payload_json, '$.mtime_ms') AS mtime_ms, json_extract(payload_json, '$.ctime_ms') AS ctime_ms, json_extract(payload_json, '$.size_bytes') AS size_bytes, json_extract(payload_json, '$.file_identity') AS file_identity, json_extract(payload_json, '$.source_kind') AS source_kind, json_extract(payload_json, '$.last_processed_at') AS last_processed_at FROM zaip_aios_activities WHERE payload_type='source_state';
27
27
  CREATE VIEW read_model_metadata AS SELECT json_extract(payload_json, '$.key') AS key, json_extract(payload_json, '$.value') AS value FROM zaip_aios_activities WHERE payload_type='metadata';
28
- CREATE VIEW canonical_work_items AS SELECT json_extract(payload_json, '$.entity_kind') AS entity_kind, json_extract(payload_json, '$.id') AS id, json_extract(payload_json, '$.title') AS title, json_extract(payload_json, '$.status') AS status, json_extract(payload_json, '$.stage') AS stage, json_extract(payload_json, '$.risk') AS risk, json_extract(payload_json, '$.spec_id') AS spec_id, json_extract(payload_json, '$.change_id') AS change_id, json_extract(payload_json, '$.creation_run_id') AS creation_run_id, json_extract(payload_json, '$.completed_run_id') AS completed_run_id, json_extract(payload_json, '$.occurred_at') AS occurred_at, json_extract(payload_json, '$.occurred_day_sp') AS occurred_day_sp FROM zaip_aios_activities WHERE payload_type='work_item';
28
+ CREATE VIEW canonical_work_items AS SELECT json_extract(payload_json, '$.entity_kind') AS entity_kind, json_extract(payload_json, '$.id') AS id, json_extract(payload_json, '$.title') AS title, json_extract(payload_json, '$.status') AS status, json_extract(payload_json, '$.stage') AS stage, json_extract(payload_json, '$.risk') AS risk, json_extract(payload_json, '$.priority') AS priority, json_extract(payload_json, '$.spec_id') AS spec_id, json_extract(payload_json, '$.prd_id') AS prd_id, json_extract(payload_json, '$.change_id') AS change_id, json_extract(payload_json, '$.creation_run_id') AS creation_run_id, json_extract(payload_json, '$.completed_run_id') AS completed_run_id, json_extract(payload_json, '$.occurred_at') AS occurred_at, json_extract(payload_json, '$.occurred_day_sp') AS occurred_day_sp FROM zaip_aios_activities WHERE payload_type='work_item';
29
29
  CREATE VIEW canonical_executions AS SELECT json_extract(payload_json, '$.id') AS id, json_extract(payload_json, '$.status') AS status, json_extract(payload_json, '$.kind') AS kind, json_extract(payload_json, '$.origin_type') AS origin_type, json_extract(payload_json, '$.origin_id') AS origin_id, json_extract(payload_json, '$.created_at') AS created_at, json_extract(payload_json, '$.occurred_day_sp') AS occurred_day_sp, json_extract(payload_json, '$.finished_at') AS finished_at, json_extract(payload_json, '$.source_path') AS source_path FROM zaip_aios_activities WHERE payload_type='execution';
30
30
  CREATE VIEW canonical_changes AS SELECT json_extract(payload_json, '$.id') AS id, json_extract(payload_json, '$.title') AS title, json_extract(payload_json, '$.status') AS status, json_extract(payload_json, '$.risk') AS risk, json_extract(payload_json, '$.source_type') AS source_type, json_extract(payload_json, '$.source_id') AS source_id, json_extract(payload_json, '$.source_spec_id') AS source_spec_id, json_extract(payload_json, '$.source_prd_id') AS source_prd_id, json_extract(payload_json, '$.requirement_ids_json') AS requirement_ids_json, json_extract(payload_json, '$.acceptance_ids_json') AS acceptance_ids_json, json_extract(payload_json, '$.task_ids_json') AS task_ids_json, json_extract(payload_json, '$.result') AS result, json_extract(payload_json, '$.created_at') AS created_at, json_extract(payload_json, '$.occurred_day_sp') AS occurred_day_sp, json_extract(payload_json, '$.source_path') AS source_path FROM zaip_aios_activities WHERE payload_type='change';
31
31
  CREATE VIEW canonical_decisions AS SELECT json_extract(payload_json, '$.id') AS id, json_extract(payload_json, '$.title') AS title, json_extract(payload_json, '$.origin') AS origin, json_extract(payload_json, '$.scope_type') AS scope_type, json_extract(payload_json, '$.scope_id') AS scope_id, json_extract(payload_json, '$.created_at') AS created_at, json_extract(payload_json, '$.occurred_day_sp') AS occurred_day_sp, json_extract(payload_json, '$.source_path') AS source_path FROM zaip_aios_activities WHERE payload_type='decision';
@@ -63,10 +63,10 @@ export const baseViewSql = `
63
63
  CREATE VIEW agent_runs AS SELECT * FROM activities WHERE activity_source_kind = 'agent_run';
64
64
  CREATE VIEW root_runs AS SELECT * FROM activities WHERE run_role = 'root';
65
65
  CREATE VIEW sub_runs AS SELECT * FROM activities WHERE run_role = 'subrun';
66
- CREATE VIEW invocations AS SELECT activity_row_id, activity_key, version_activity_id, source_occurred_at, root_agent_run_id AS root_agent_invocation_id, parent_agent_run_id AS parent_agent_invocation_id, execution_id, task_id, spec_id, prd_id, change_id, conversation_id, run_id, occurred_at, occurred_day_sp, invocation_kind, delegation_depth, zaip_agent, zaip_agent_persona, zaip_agent_job, zaip_agent_role, client, provider, model, phase, purpose, status, source_started_at, source_finished_at, attributed_token_active_ms, attributed_token_active_ms AS duration_ms, CASE WHEN attributed_token_active_ms IS NOT NULL THEN 'observed' ELSE 'unavailable' END AS duration_provenance, CASE WHEN attributed_token_active_ms IS NOT NULL THEN 'attributed_token_active' ELSE NULL END AS duration_fact_provenance, input_tokens, cached_input_tokens, output_tokens, reasoning_tokens, total_tokens, token_source, cost_usd, cost_brl, cost_method, pricing_model, pricing_source, fx_rate, service_tier, reasoning_effort, source_event_count, usage_event_count, llm_call_count, agent_run_id AS agent_invocation_id FROM agent_runs;
66
+ CREATE VIEW invocations AS SELECT activity_row_id, activity_key, version_activity_id, source_occurred_at, root_agent_run_id AS root_agent_invocation_id, parent_agent_run_id AS parent_agent_invocation_id, execution_id, task_id, spec_id, prd_id, change_id, conversation_id, run_id, occurred_at, occurred_day_sp, invocation_kind, delegation_depth, zaip_agent, zaip_agent_persona, zaip_agent_job, zaip_agent_role, client, provider, model, work_type, phase, purpose, status, source_started_at, source_finished_at, attributed_token_active_ms, attributed_token_active_ms AS duration_ms, CASE WHEN attributed_token_active_ms IS NOT NULL THEN 'observed' ELSE 'unavailable' END AS duration_provenance, CASE WHEN attributed_token_active_ms IS NOT NULL THEN 'attributed_token_active' ELSE NULL END AS duration_fact_provenance, input_tokens, cached_input_tokens, output_tokens, reasoning_tokens, total_tokens, token_source, cost_usd, cost_brl, cost_method, pricing_model, pricing_source, fx_rate, service_tier, reasoning_effort, source_event_count, usage_event_count, llm_call_count, agent_run_id AS agent_invocation_id FROM agent_runs;
67
67
  CREATE VIEW invocation_usage AS SELECT agent_invocation_id, agent_invocation_id AS usage_index, provider, model, service_tier, reasoning_effort, input_tokens, cached_input_tokens, uncached_input_tokens, output_tokens, reasoning_tokens, visible_output_tokens, total_tokens, input_rate_usd_per_million, cached_input_rate_usd_per_million, output_rate_usd_per_million, reasoning_rate_usd_per_million, context_input_multiplier, context_output_multiplier, speed_cost_multiplier, pricing_scenario, standard_cost_usd, speed_uplift_usd, input_cost_usd, cached_input_cost_usd, output_cost_usd, reasoning_cost_usd, calculated_cost_usd, recorded_cost_usd, cost_variance_usd, cost_usd, cost_brl, cost_method, pricing_model, pricing_source, fx_rate FROM invocation_usage_segments;
68
- CREATE VIEW work_items AS SELECT entity_kind, id, title, status, risk, occurred_at, occurred_day_sp FROM canonical_work_items UNION ALL SELECT 'task', task_id, COALESCE(MAX(title), task_id), MAX(work_item_status), MAX(risk), MIN(occurred_at), MIN(occurred_day_sp) FROM activities WHERE task_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM canonical_work_items c WHERE c.entity_kind='task' AND c.id=activities.task_id) GROUP BY task_id UNION ALL SELECT 'spec', spec_id, COALESCE(MAX(title), spec_id), MAX(work_item_status), MAX(risk), MIN(occurred_at), MIN(occurred_day_sp) FROM activities WHERE spec_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM canonical_work_items c WHERE c.entity_kind='spec' AND c.id=activities.spec_id) GROUP BY spec_id UNION ALL SELECT 'prd', prd_id, COALESCE(MAX(title), prd_id), MAX(work_item_status), MAX(risk), MIN(occurred_at), MIN(occurred_day_sp) FROM activities WHERE prd_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM canonical_work_items c WHERE c.entity_kind='prd' AND c.id=activities.prd_id) GROUP BY prd_id;
69
- CREATE VIEW tasks AS SELECT id, title, status, risk, occurred_at, occurred_day_sp FROM work_items WHERE entity_kind = 'task';
68
+ CREATE VIEW work_items AS SELECT entity_kind, id, title, status, risk, priority, occurred_at, occurred_day_sp FROM canonical_work_items UNION ALL SELECT 'task', task_id, COALESCE(MAX(title), task_id), MAX(work_item_status), MAX(risk), NULL, MIN(occurred_at), MIN(occurred_day_sp) FROM activities WHERE task_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM canonical_work_items c WHERE c.entity_kind='task' AND c.id=activities.task_id) GROUP BY task_id UNION ALL SELECT 'spec', spec_id, COALESCE(MAX(title), spec_id), MAX(work_item_status), MAX(risk), NULL, MIN(occurred_at), MIN(occurred_day_sp) FROM activities WHERE spec_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM canonical_work_items c WHERE c.entity_kind='spec' AND c.id=activities.spec_id) GROUP BY spec_id UNION ALL SELECT 'prd', prd_id, COALESCE(MAX(title), prd_id), MAX(work_item_status), MAX(risk), NULL, MIN(occurred_at), MIN(occurred_day_sp) FROM activities WHERE prd_id IS NOT NULL AND NOT EXISTS (SELECT 1 FROM canonical_work_items c WHERE c.entity_kind='prd' AND c.id=activities.prd_id) GROUP BY prd_id;
69
+ CREATE VIEW tasks AS SELECT id, title, status, risk, priority, occurred_at, occurred_day_sp FROM work_items WHERE entity_kind = 'task';
70
70
  CREATE VIEW specs AS SELECT id, title, status, risk, occurred_at, occurred_day_sp FROM work_items WHERE entity_kind = 'spec';
71
71
  CREATE VIEW prds AS SELECT id, title, status, risk, occurred_at, occurred_day_sp FROM work_items WHERE entity_kind = 'prd';
72
72
  CREATE VIEW executions AS