zob-harness 0.1.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.
- package/.pi/adapters/registry.json +103 -0
- package/.pi/agents/architecture-cartographer.md +53 -0
- package/.pi/agents/chief-vision.md +39 -0
- package/.pi/agents/clarifier.md +58 -0
- package/.pi/agents/context-steward.md +52 -0
- package/.pi/agents/doc-steward.md +34 -0
- package/.pi/agents/explore.md +49 -0
- package/.pi/agents/factory.md +41 -0
- package/.pi/agents/implementer.md +44 -0
- package/.pi/agents/librarian.md +32 -0
- package/.pi/agents/oracle-merge.md +50 -0
- package/.pi/agents/oracle.md +55 -0
- package/.pi/agents/pattern-miner.md +53 -0
- package/.pi/agents/planner.md +39 -0
- package/.pi/agents/project-dna-golden-evaluator.md +32 -0
- package/.pi/agents/project-dna-ontology-steward.md +30 -0
- package/.pi/agents/project-dna-oracle.md +56 -0
- package/.pi/agents/project-dna-orchestrator.md +60 -0
- package/.pi/agents/project-dna-query-steward.md +38 -0
- package/.pi/agents/project-dna-safety-preflight.md +54 -0
- package/.pi/agents/project-dna-test-linker.md +27 -0
- package/.pi/agents/qa.md +38 -0
- package/.pi/agents/refactor-cartographer.md +28 -0
- package/.pi/agents/refactor-mover.md +31 -0
- package/.pi/agents/refactor-oracle.md +49 -0
- package/.pi/agents/repo-scout.md +60 -0
- package/.pi/agents/sample-architect.md +48 -0
- package/.pi/agents/specifier.md +57 -0
- package/.pi/agents/symbol-range-curator.md +41 -0
- package/.pi/agents/synthesis.md +52 -0
- package/.pi/agents/temp-agent-creator.md +35 -0
- package/.pi/autonomy-policy.json +67 -0
- package/.pi/budget-policy.json +54 -0
- package/.pi/capabilities/zob-public-runtime-capabilities.json +1700 -0
- package/.pi/chains/explore-plan-oracle.json +78 -0
- package/.pi/chains/explore-spec-clarify-plan-oracle.json +64 -0
- package/.pi/chains/explore-spec-plan-oracle.json +53 -0
- package/.pi/chains/spec-clarify-plan-oracle.json +53 -0
- package/.pi/chains/spec-factory-oracle.json +42 -0
- package/.pi/chains/spec-plan-oracle.json +42 -0
- package/.pi/compute-profiles/defaults.json +19 -0
- package/.pi/compute-profiles/overrides.json +13 -0
- package/.pi/compute-profiles/risk-rules.json +16 -0
- package/.pi/daemon-policy.json +80 -0
- package/.pi/damage-control-rules.json +45 -0
- package/.pi/extensions/zob-child-safety/index.ts +212 -0
- package/.pi/extensions/zob-harness/AGENTS.md +28 -0
- package/.pi/extensions/zob-harness/index.ts +391 -0
- package/.pi/extensions/zob-harness/src/AGENTS.md +25 -0
- package/.pi/extensions/zob-harness/src/agents.ts +82 -0
- package/.pi/extensions/zob-harness/src/autonomous-runtime.ts +2912 -0
- package/.pi/extensions/zob-harness/src/autonomy-readiness.ts +778 -0
- package/.pi/extensions/zob-harness/src/budget-policy.ts +308 -0
- package/.pi/extensions/zob-harness/src/capabilities.ts +249 -0
- package/.pi/extensions/zob-harness/src/child-runner.ts +249 -0
- package/.pi/extensions/zob-harness/src/chronicle.ts +262 -0
- package/.pi/extensions/zob-harness/src/compute-profile.ts +602 -0
- package/.pi/extensions/zob-harness/src/compute-workflow-shape.ts +168 -0
- package/.pi/extensions/zob-harness/src/coms-v2/AGENTS.md +16 -0
- package/.pi/extensions/zob-harness/src/coms-v2/envelope.ts +121 -0
- package/.pi/extensions/zob-harness/src/coms-v2/identity.ts +53 -0
- package/.pi/extensions/zob-harness/src/coms-v2/ledger-bridge.ts +67 -0
- package/.pi/extensions/zob-harness/src/coms-v2/local-transport.ts +147 -0
- package/.pi/extensions/zob-harness/src/coms-v2/pending-replies.ts +80 -0
- package/.pi/extensions/zob-harness/src/coms-v2/policy.ts +125 -0
- package/.pi/extensions/zob-harness/src/coms-v2/presence.ts +55 -0
- package/.pi/extensions/zob-harness/src/coms-v2/registry.ts +113 -0
- package/.pi/extensions/zob-harness/src/coms-v2/response-capture.ts +50 -0
- package/.pi/extensions/zob-harness/src/coms-v2/transcript-capture.ts +164 -0
- package/.pi/extensions/zob-harness/src/coms-v2/types.ts +149 -0
- package/.pi/extensions/zob-harness/src/coms-v2/zpeer-profile.ts +140 -0
- package/.pi/extensions/zob-harness/src/coms-v2/zpeer.ts +452 -0
- package/.pi/extensions/zob-harness/src/constants.ts +108 -0
- package/.pi/extensions/zob-harness/src/context-gbrain.ts +465 -0
- package/.pi/extensions/zob-harness/src/daemon-policy.ts +223 -0
- package/.pi/extensions/zob-harness/src/daemon-readiness.ts +134 -0
- package/.pi/extensions/zob-harness/src/daemon-runtime.ts +393 -0
- package/.pi/extensions/zob-harness/src/factory/AGENTS.md +24 -0
- package/.pi/extensions/zob-harness/src/factory/agentic-plan.ts +65 -0
- package/.pi/extensions/zob-harness/src/factory/quarantine.ts +319 -0
- package/.pi/extensions/zob-harness/src/factory/run.ts +520 -0
- package/.pi/extensions/zob-harness/src/factory/validation.ts +454 -0
- package/.pi/extensions/zob-harness/src/factory-selector.ts +318 -0
- package/.pi/extensions/zob-harness/src/full-autonomy-test.ts +226 -0
- package/.pi/extensions/zob-harness/src/git-ops.ts +868 -0
- package/.pi/extensions/zob-harness/src/goal-room.ts +178 -0
- package/.pi/extensions/zob-harness/src/goal-runtime.ts +1569 -0
- package/.pi/extensions/zob-harness/src/goal-todo-imports.ts +111 -0
- package/.pi/extensions/zob-harness/src/goal-todo-types.ts +231 -0
- package/.pi/extensions/zob-harness/src/goal-todos.ts +1410 -0
- package/.pi/extensions/zob-harness/src/goal.ts +152 -0
- package/.pi/extensions/zob-harness/src/governed-requests.ts +436 -0
- package/.pi/extensions/zob-harness/src/interactive-autonomy.ts +595 -0
- package/.pi/extensions/zob-harness/src/launch-apply.ts +313 -0
- package/.pi/extensions/zob-harness/src/merge-queue.ts +290 -0
- package/.pi/extensions/zob-harness/src/mission-control.ts +573 -0
- package/.pi/extensions/zob-harness/src/model-availability.ts +52 -0
- package/.pi/extensions/zob-harness/src/model-routing.ts +429 -0
- package/.pi/extensions/zob-harness/src/orchestration/AGENTS.md +23 -0
- package/.pi/extensions/zob-harness/src/orchestration/adaptive-delegation.ts +547 -0
- package/.pi/extensions/zob-harness/src/orchestration/adaptive-workflow.ts +585 -0
- package/.pi/extensions/zob-harness/src/orchestration/lead-plan.ts +192 -0
- package/.pi/extensions/zob-harness/src/orchestration/plan.ts +168 -0
- package/.pi/extensions/zob-harness/src/orchestration/room.ts +346 -0
- package/.pi/extensions/zob-harness/src/orchestration/run.ts +134 -0
- package/.pi/extensions/zob-harness/src/orchestration/supervised-readonly.ts +1147 -0
- package/.pi/extensions/zob-harness/src/orchestration/widget-readers.ts +132 -0
- package/.pi/extensions/zob-harness/src/output-contracts.ts +656 -0
- package/.pi/extensions/zob-harness/src/project-dna.ts +533 -0
- package/.pi/extensions/zob-harness/src/promotion/AGENTS.md +24 -0
- package/.pi/extensions/zob-harness/src/promotion/candidate.ts +336 -0
- package/.pi/extensions/zob-harness/src/promotion/coms.ts +127 -0
- package/.pi/extensions/zob-harness/src/promotion/documentation.ts +142 -0
- package/.pi/extensions/zob-harness/src/promotion/factory.ts +107 -0
- package/.pi/extensions/zob-harness/src/promotion/ledger.ts +2 -0
- package/.pi/extensions/zob-harness/src/promotion/temp-agent.ts +151 -0
- package/.pi/extensions/zob-harness/src/promotion/types.ts +149 -0
- package/.pi/extensions/zob-harness/src/promotion/validate.ts +6 -0
- package/.pi/extensions/zob-harness/src/promotion/write-lane.ts +162 -0
- package/.pi/extensions/zob-harness/src/prompt-packs.ts +239 -0
- package/.pi/extensions/zob-harness/src/queue.ts +386 -0
- package/.pi/extensions/zob-harness/src/rules.ts +225 -0
- package/.pi/extensions/zob-harness/src/runtime/AGENTS.md +26 -0
- package/.pi/extensions/zob-harness/src/runtime/adaptive-zmode.ts +116 -0
- package/.pi/extensions/zob-harness/src/runtime/auto-compaction.ts +715 -0
- package/.pi/extensions/zob-harness/src/runtime/commands.ts +1315 -0
- package/.pi/extensions/zob-harness/src/runtime/compaction-policy.ts +516 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-click-markers.ts +141 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-feed.ts +415 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-markdown.ts +97 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-monitor.ts +553 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-mouse.ts +205 -0
- package/.pi/extensions/zob-harness/src/runtime/delegation-overlay.ts +434 -0
- package/.pi/extensions/zob-harness/src/runtime/events.ts +736 -0
- package/.pi/extensions/zob-harness/src/runtime/goal-todo-overlay.ts +214 -0
- package/.pi/extensions/zob-harness/src/runtime/mode-intent.ts +144 -0
- package/.pi/extensions/zob-harness/src/runtime/plan-capture.ts +270 -0
- package/.pi/extensions/zob-harness/src/runtime/state.ts +403 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-autonomous.ts +117 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-compute.ts +136 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-coms.ts +365 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-context.ts +70 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-delegation.ts +1854 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-factory.ts +810 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-goal-room.ts +46 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-governed-requests.ts +38 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-merge-queue.ts +61 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-mission-control.ts +77 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-orchestration.ts +106 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-project-dna.ts +123 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-worker-pool.ts +93 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-workspace-claims.ts +62 -0
- package/.pi/extensions/zob-harness/src/runtime/tools-zcommit.ts +147 -0
- package/.pi/extensions/zob-harness/src/runtime/widget.ts +353 -0
- package/.pi/extensions/zob-harness/src/runtime/zobHarness.ts +60 -0
- package/.pi/extensions/zob-harness/src/safety.ts +338 -0
- package/.pi/extensions/zob-harness/src/sandbox.ts +1508 -0
- package/.pi/extensions/zob-harness/src/schemas-project-dna.ts +47 -0
- package/.pi/extensions/zob-harness/src/schemas.ts +695 -0
- package/.pi/extensions/zob-harness/src/telemetry.ts +373 -0
- package/.pi/extensions/zob-harness/src/topology/AGENTS.md +22 -0
- package/.pi/extensions/zob-harness/src/topology/chains.ts +236 -0
- package/.pi/extensions/zob-harness/src/topology/coms.ts +211 -0
- package/.pi/extensions/zob-harness/src/topology/orchestration-profiles.ts +204 -0
- package/.pi/extensions/zob-harness/src/topology/teams.ts +113 -0
- package/.pi/extensions/zob-harness/src/types/core.ts +47 -0
- package/.pi/extensions/zob-harness/src/types.ts +939 -0
- package/.pi/extensions/zob-harness/src/utils/AGENTS.md +22 -0
- package/.pi/extensions/zob-harness/src/utils/formatting.ts +34 -0
- package/.pi/extensions/zob-harness/src/utils/hashing.ts +11 -0
- package/.pi/extensions/zob-harness/src/utils/json.ts +28 -0
- package/.pi/extensions/zob-harness/src/utils/paths.ts +54 -0
- package/.pi/extensions/zob-harness/src/utils/records.ts +25 -0
- package/.pi/extensions/zob-harness/src/utils/resources.ts +38 -0
- package/.pi/extensions/zob-harness/src/worker-pool.ts +672 -0
- package/.pi/extensions/zob-harness/src/workspace-claims.ts +297 -0
- package/.pi/extensions/zob-switch/index.ts +180 -0
- package/.pi/factories/budget-preflight-dry-run/batch-manifest.json +59 -0
- package/.pi/factories/budget-preflight-dry-run/factory.json +94 -0
- package/.pi/factories/budget-preflight-dry-run/pilot-manifest.json +50 -0
- package/.pi/factories/budget-preflight-dry-run/smoke-manifest.json +43 -0
- package/.pi/factories/code-review-matrix/batch-manifest.json +61 -0
- package/.pi/factories/code-review-matrix/factory.json +163 -0
- package/.pi/factories/code-review-matrix/pilot-manifest.json +41 -0
- package/.pi/factories/code-review-matrix/smoke-manifest.json +35 -0
- package/.pi/factories/factory-forge/batch-manifest.json +56 -0
- package/.pi/factories/factory-forge/factory.json +84 -0
- package/.pi/factories/factory-forge/pilot-manifest.json +32 -0
- package/.pi/factories/factory-forge/smoke-manifest.json +19 -0
- package/.pi/factories/opencode-pattern-canonizer/batch-manifest.json +54 -0
- package/.pi/factories/opencode-pattern-canonizer/factory.json +86 -0
- package/.pi/factories/opencode-pattern-canonizer/pilot-manifest.json +39 -0
- package/.pi/factories/opencode-pattern-canonizer/smoke-manifest.json +26 -0
- package/.pi/factories/project-dna/README.md +182 -0
- package/.pi/factories/project-dna/batch-manifest.json +37 -0
- package/.pi/factories/project-dna/example-project-dna-manifest-v2.json +80 -0
- package/.pi/factories/project-dna/example-project-dna-manifest.json +58 -0
- package/.pi/factories/project-dna/factory.json +131 -0
- package/.pi/factories/project-dna/golden-cases-smoke.json +62 -0
- package/.pi/factories/project-dna/pi-agentic-ontology.json +88 -0
- package/.pi/factories/project-dna/pilot-manifest.json +32 -0
- package/.pi/factories/project-dna/schemas/benchmark-suite.schema.json +27 -0
- package/.pi/factories/project-dna/schemas/code-knowledge-graph.schema.json +97 -0
- package/.pi/factories/project-dna/schemas/context-pack.schema.json +43 -0
- package/.pi/factories/project-dna/schemas/golden-case.schema.json +36 -0
- package/.pi/factories/project-dna/schemas/manifest-v2.schema.json +128 -0
- package/.pi/factories/project-dna/schemas/manifest.schema.json +77 -0
- package/.pi/factories/project-dna/schemas/ontology.schema.json +45 -0
- package/.pi/factories/project-dna/schemas/project-fingerprint.schema.json +28 -0
- package/.pi/factories/project-dna/schemas/query-steward-report.schema.json +52 -0
- package/.pi/factories/project-dna/smoke-manifest.json +27 -0
- package/.pi/factories/roadmap-smoke-lots/batch-manifest.json +49 -0
- package/.pi/factories/roadmap-smoke-lots/factory.json +89 -0
- package/.pi/factories/roadmap-smoke-lots/pilot-manifest.json +50 -0
- package/.pi/factories/roadmap-smoke-lots/smoke-manifest.json +35 -0
- package/.pi/git-policy.json +120 -0
- package/.pi/mission-control/zob_coms_transport.json +64 -0
- package/.pi/model-catalog.example.json +345 -0
- package/.pi/model-economy.example.json +196 -0
- package/.pi/model-routing.json +86 -0
- package/.pi/orchestrations/adaptive-chief-vision.json +193 -0
- package/.pi/orchestrations/ceo-feature-build.json +182 -0
- package/.pi/orchestrations/readonly-dynamic-smoke.json +75 -0
- package/.pi/output-contracts/agent-event.v1.json +19 -0
- package/.pi/output-contracts/base.v1.json +24 -0
- package/.pi/output-contracts/brain-lookup.v1.json +21 -0
- package/.pi/output-contracts/clarification.v1.json +21 -0
- package/.pi/output-contracts/context-pack.v1.json +20 -0
- package/.pi/output-contracts/context-request.v1.json +21 -0
- package/.pi/output-contracts/context-steward.v1.json +19 -0
- package/.pi/output-contracts/context-writeback-proposal.v1.json +18 -0
- package/.pi/output-contracts/delegation-request.v1.json +21 -0
- package/.pi/output-contracts/explore.v1.json +52 -0
- package/.pi/output-contracts/factory.v1.json +48 -0
- package/.pi/output-contracts/guidance-steward.v1.json +18 -0
- package/.pi/output-contracts/implement.v1.json +40 -0
- package/.pi/output-contracts/launch-authorization.v1.json +21 -0
- package/.pi/output-contracts/lead-plan.v1.json +22 -0
- package/.pi/output-contracts/mission-readiness.v1.json +20 -0
- package/.pi/output-contracts/oracle-merge.v1.json +44 -0
- package/.pi/output-contracts/oracle-request.v1.json +20 -0
- package/.pi/output-contracts/oracle.v1.json +44 -0
- package/.pi/output-contracts/orchestration-profile.v1.json +22 -0
- package/.pi/output-contracts/plan.v1.json +48 -0
- package/.pi/output-contracts/prompt-pack.v1.json +20 -0
- package/.pi/output-contracts/qa.v1.json +40 -0
- package/.pi/output-contracts/research.v1.json +36 -0
- package/.pi/output-contracts/spec.v1.json +22 -0
- package/.pi/output-contracts/synthesis.v1.json +44 -0
- package/.pi/output-contracts/temp-agent-card.v1.json +23 -0
- package/.pi/output-contracts/todo-child-result.v1.json +20 -0
- package/.pi/output-contracts/todo-child-result.v2.json +22 -0
- package/.pi/output-contracts/todo-claim-validation.v1.json +22 -0
- package/.pi/output-contracts/todo-split-request.v1.json +20 -0
- package/.pi/prompts/adaptive-workflow.md +63 -0
- package/.pi/prompts/autonomous-runtime.md +15 -0
- package/.pi/prompts/benchmark-contender.md +15 -0
- package/.pi/prompts/benchmark-judge.md +19 -0
- package/.pi/prompts/clarify-spec.md +20 -0
- package/.pi/prompts/compute-plan.md +36 -0
- package/.pi/prompts/compute-preview.md +42 -0
- package/.pi/prompts/contract.md +29 -0
- package/.pi/prompts/explore.md +13 -0
- package/.pi/prompts/factory-run.md +36 -0
- package/.pi/prompts/factory.md +20 -0
- package/.pi/prompts/implement.md +27 -0
- package/.pi/prompts/model-catalog.md +68 -0
- package/.pi/prompts/model-economy.md +64 -0
- package/.pi/prompts/oracle-merge.md +18 -0
- package/.pi/prompts/oracle.md +13 -0
- package/.pi/prompts/orchestrator.md +48 -0
- package/.pi/prompts/parallel-review.md +21 -0
- package/.pi/prompts/plan.md +21 -0
- package/.pi/prompts/project-dna.md +90 -0
- package/.pi/prompts/refactor-oracle.md +23 -0
- package/.pi/prompts/refactor-slice.md +24 -0
- package/.pi/prompts/research.md +20 -0
- package/.pi/prompts/spec.md +19 -0
- package/.pi/prompts/synthesis.md +18 -0
- package/.pi/rules/always.md +38 -0
- package/.pi/rules/docs.md +32 -0
- package/.pi/rules/factory.md +44 -0
- package/.pi/rules/oracle.md +34 -0
- package/.pi/rules/orchestration.md +44 -0
- package/.pi/rules/project.md +34 -0
- package/.pi/rules/prompts.md +43 -0
- package/.pi/rules/runtime.md +43 -0
- package/.pi/rules/sandbox.md +43 -0
- package/.pi/settings.json +28 -0
- package/.pi/skills/zob-agentic-access/SKILL.md +20 -0
- package/.pi/skills/zob-autonomous-runtime/SKILL.md +41 -0
- package/.pi/skills/zob-commit/SKILL.md +79 -0
- package/.pi/skills/zob-compaction-policy/SKILL.md +92 -0
- package/.pi/skills/zob-compute-profile/SKILL.md +108 -0
- package/.pi/skills/zob-coms-safety/SKILL.md +54 -0
- package/.pi/skills/zob-coms-v2-live/SKILL.md +47 -0
- package/.pi/skills/zob-delegation-routing/SKILL.md +82 -0
- package/.pi/skills/zob-factory/SKILL.md +28 -0
- package/.pi/skills/zob-goal-todo-tree/SKILL.md +279 -0
- package/.pi/skills/zob-harness/SKILL.md +68 -0
- package/.pi/skills/zob-mission-control-coms/SKILL.md +39 -0
- package/.pi/skills/zob-oracle/SKILL.md +21 -0
- package/.pi/skills/zob-owner-pool-drill-writer/SKILL.md +244 -0
- package/.pi/skills/zob-owner-pool-launcher/SKILL.md +261 -0
- package/.pi/skills/zob-project-dna/SKILL.md +275 -0
- package/.pi/skills/zob-sandbox/SKILL.md +29 -0
- package/.pi/skills/zob-spec/SKILL.md +25 -0
- package/.pi/skills/zob-split-refactor/SKILL.md +39 -0
- package/.pi/skills/zob-tool-router/SKILL.md +104 -0
- package/.pi/teams/zob-core.json +122 -0
- package/AGENTS.md +89 -0
- package/CONTRIBUTING.md +56 -0
- package/LICENSE +21 -0
- package/README.md +360 -0
- package/SECURITY.md +35 -0
- package/SOURCE_INDEX.md +46 -0
- package/package.json +135 -0
- package/scripts/README.md +57 -0
- package/scripts/autonomy/mission-readiness-secret-smoke.mjs +90 -0
- package/scripts/compute-profile/plan-workflow.mjs +85 -0
- package/scripts/compute-profile/preview.mjs +242 -0
- package/scripts/compute-profile/regression-smoke.mjs +38 -0
- package/scripts/compute-profile/summarize.mjs +72 -0
- package/scripts/compute-profile/validate-policy.mjs +50 -0
- package/scripts/compute-profile/validate-preview.mjs +95 -0
- package/scripts/compute-profile/validate-workflow.mjs +58 -0
- package/scripts/git-ops/commit-policy-smoke.mjs +221 -0
- package/scripts/goal-todo/child-goal-ref-smoke.mjs +252 -0
- package/scripts/harness-switch/static-smoke.mjs +43 -0
- package/scripts/model-catalog/validate-economy.mjs +223 -0
- package/scripts/model-catalog/validate.mjs +199 -0
- package/scripts/package-surface/validate-script-refs.mjs +190 -0
- package/scripts/path-policy/validate-smoke.mjs +103 -0
- package/scripts/project-dna/bench-smoke.mjs +217 -0
- package/scripts/project-dna/build-capsules.mjs +207 -0
- package/scripts/project-dna/build-sample-spec.mjs +140 -0
- package/scripts/project-dna/emit-golden-cases.mjs +75 -0
- package/scripts/project-dna/emit-ontology.mjs +75 -0
- package/scripts/project-dna/generate-sample.mjs +302 -0
- package/scripts/project-dna/oracle-review-smoke.mjs +157 -0
- package/scripts/project-dna/plan-workflow.mjs +289 -0
- package/scripts/project-dna/query-context.mjs +276 -0
- package/scripts/project-dna/query-steward.mjs +149 -0
- package/scripts/project-dna/scan.mjs +553 -0
- package/scripts/project-dna/validate-5of5.mjs +159 -0
- package/scripts/project-dna/validate-golden-cases.mjs +78 -0
- package/scripts/project-dna/validate-ontology.mjs +97 -0
- package/scripts/project-dna/validate-sample-project.mjs +105 -0
- package/scripts/project-dna/validate-scaffold.mjs +383 -0
- package/scripts/project-dna/validate-scan-artifacts.mjs +187 -0
- package/scripts/project-dna/validate-workflow.mjs +166 -0
- package/scripts/start-pi.sh +4 -0
- package/scripts/worker-pool/static-smoke.mjs +54 -0
- package/scripts/zpeer-local-e2e-smoke.mjs +395 -0
- package/scripts/zpeer-static-smoke.mjs +129 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
|
|
3
|
+
import { DEFAULT_RULES } from "./constants.js";
|
|
4
|
+
import { validateOutputContractId } from "./output-contracts.js";
|
|
5
|
+
import { sha256 } from "./utils/hashing.js";
|
|
6
|
+
import { pathMatches, resolveRepoPath } from "./utils/paths.js";
|
|
7
|
+
import { isRecord } from "./utils/records.js";
|
|
8
|
+
|
|
9
|
+
export type PromptPackRole = "orchestrator" | "factory-selector" | "worker-implementer" | "oracle";
|
|
10
|
+
|
|
11
|
+
export interface PromptPackContextPolicy {
|
|
12
|
+
contextScopeId: string;
|
|
13
|
+
maxContextTokens: number;
|
|
14
|
+
allowedSources: string[];
|
|
15
|
+
forbiddenSources: string[];
|
|
16
|
+
citationsRequired: true;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface PromptPackEventPolicy {
|
|
20
|
+
emitStatusOnStart: true;
|
|
21
|
+
emitStatusOnAttentionNeeded: true;
|
|
22
|
+
emitTodoClaimOnDone: true;
|
|
23
|
+
eventContract: "agent-event.v1";
|
|
24
|
+
todoClaimReducerRequired: true;
|
|
25
|
+
parentOwnedActions: true;
|
|
26
|
+
directTodoMutationAllowed: false;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PromptPackDefinition {
|
|
30
|
+
schema: "zob.prompt-pack.v1";
|
|
31
|
+
roleId: PromptPackRole;
|
|
32
|
+
purposeHash: string;
|
|
33
|
+
promptRefs: string[];
|
|
34
|
+
skillRefs: string[];
|
|
35
|
+
docRefs: string[];
|
|
36
|
+
outputContract: string;
|
|
37
|
+
contextPolicy: PromptPackContextPolicy;
|
|
38
|
+
eventPolicy: PromptPackEventPolicy;
|
|
39
|
+
launchAuthorizationRequired: true;
|
|
40
|
+
oracleRequiredForCompletion: boolean;
|
|
41
|
+
bodyStored: false;
|
|
42
|
+
promptBodiesStored: false;
|
|
43
|
+
outputBodiesStored: false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface PromptPackEvalResult {
|
|
47
|
+
roleId: PromptPackRole;
|
|
48
|
+
passed: boolean;
|
|
49
|
+
failedChecks: string[];
|
|
50
|
+
refsChecked: string[];
|
|
51
|
+
outputContract: string;
|
|
52
|
+
maxContextTokens: number;
|
|
53
|
+
bodyStored: false;
|
|
54
|
+
promptBodiesStored: false;
|
|
55
|
+
outputBodiesStored: false;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface PromptPackReport {
|
|
59
|
+
schema: "zob.prompt-pack-eval.v1";
|
|
60
|
+
status: "passed" | "failed";
|
|
61
|
+
runId: string;
|
|
62
|
+
packs: PromptPackDefinition[];
|
|
63
|
+
evals: PromptPackEvalResult[];
|
|
64
|
+
failedChecks: string[];
|
|
65
|
+
no_ship: boolean;
|
|
66
|
+
bodyStored: false;
|
|
67
|
+
promptBodiesStored: false;
|
|
68
|
+
outputBodiesStored: false;
|
|
69
|
+
generatedAt: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
const BODY_LIKE_KEYS = new Set(["body", "task", "prompt", "output", "content", "message", "text", "rationale", "diff", "patch", "raw"]);
|
|
73
|
+
|
|
74
|
+
function forbiddenPlaintextPaths(value: unknown, path = "root"): string[] {
|
|
75
|
+
if (!value || typeof value !== "object") return [];
|
|
76
|
+
if (Array.isArray(value)) return value.flatMap((item, index) => forbiddenPlaintextPaths(item, `${path}[${index}]`));
|
|
77
|
+
return Object.entries(value as Record<string, unknown>).flatMap(([key, child]) => [
|
|
78
|
+
...(BODY_LIKE_KEYS.has(key) ? [`${path}.${key}`] : []),
|
|
79
|
+
...forbiddenPlaintextPaths(child, `${path}.${key}`),
|
|
80
|
+
]);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function contextPolicy(roleId: PromptPackRole, maxContextTokens: number): PromptPackContextPolicy {
|
|
84
|
+
return {
|
|
85
|
+
contextScopeId: `factory-agent-${roleId}`,
|
|
86
|
+
maxContextTokens,
|
|
87
|
+
allowedSources: ["repo-docs", "repo-prompts", "repo-skills", "project-dna-smoke"],
|
|
88
|
+
forbiddenSources: [".env", "**/.env*", "~/.ssh", "~/.aws", "raw-conversation-history", "secrets"],
|
|
89
|
+
citationsRequired: true,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function eventPolicy(): PromptPackEventPolicy {
|
|
94
|
+
return {
|
|
95
|
+
emitStatusOnStart: true,
|
|
96
|
+
emitStatusOnAttentionNeeded: true,
|
|
97
|
+
emitTodoClaimOnDone: true,
|
|
98
|
+
eventContract: "agent-event.v1",
|
|
99
|
+
todoClaimReducerRequired: true,
|
|
100
|
+
parentOwnedActions: true,
|
|
101
|
+
directTodoMutationAllowed: false,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function pack(roleId: PromptPackRole, purpose: string, promptRefs: string[], skillRefs: string[], docRefs: string[], outputContract: string, maxContextTokens: number, oracleRequiredForCompletion: boolean): PromptPackDefinition {
|
|
106
|
+
return {
|
|
107
|
+
schema: "zob.prompt-pack.v1",
|
|
108
|
+
roleId,
|
|
109
|
+
purposeHash: sha256(purpose),
|
|
110
|
+
promptRefs,
|
|
111
|
+
skillRefs,
|
|
112
|
+
docRefs,
|
|
113
|
+
outputContract,
|
|
114
|
+
contextPolicy: contextPolicy(roleId, maxContextTokens),
|
|
115
|
+
eventPolicy: eventPolicy(),
|
|
116
|
+
launchAuthorizationRequired: true,
|
|
117
|
+
oracleRequiredForCompletion,
|
|
118
|
+
bodyStored: false,
|
|
119
|
+
promptBodiesStored: false,
|
|
120
|
+
outputBodiesStored: false,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function defaultFactoryAgentPromptPacks(): PromptPackDefinition[] {
|
|
125
|
+
return [
|
|
126
|
+
pack(
|
|
127
|
+
"orchestrator",
|
|
128
|
+
"Route a launch-authorized general factory agent run through plan, coms, TODO claims, validation, and oracle gates.",
|
|
129
|
+
[".pi/prompts/adaptive-workflow.md", ".pi/prompts/autonomous-runtime.md", ".pi/prompts/factory.md"],
|
|
130
|
+
[".pi/skills/zob-harness/SKILL.md", ".pi/skills/zob-delegation-routing/SKILL.md", ".pi/skills/zob-goal-todo-tree/SKILL.md", ".pi/skills/zob-coms-v2-live/SKILL.md", ".pi/skills/zob-coms-safety/SKILL.md"],
|
|
131
|
+
["docs/ZOB_GENERAL_FACTORY_AGENT_L4_L6_MASTER_PLAN.md", "docs/AUTONOMY_LEVELS.md", "docs/ZOB_ROOM_AND_ORCHESTRATOR_TARGET.md"],
|
|
132
|
+
"lead-plan.v1",
|
|
133
|
+
8000,
|
|
134
|
+
true,
|
|
135
|
+
),
|
|
136
|
+
pack(
|
|
137
|
+
"factory-selector",
|
|
138
|
+
"Select an existing factory or forge a quarantined candidate under launch authorization and strict budget gates.",
|
|
139
|
+
[".pi/prompts/factory.md", ".pi/prompts/spec.md"],
|
|
140
|
+
[".pi/skills/zob-factory/SKILL.md", ".pi/skills/zob-sandbox/SKILL.md", ".pi/skills/zob-compute-profile/SKILL.md"],
|
|
141
|
+
["docs/ZOB_SOFTWARE_FACTORY_MODE.md", "docs/AUTONOMOUS_SUPER_FACTORY_GOAL.md", "docs/HARNESS_CAPABILITY_MATRIX.md"],
|
|
142
|
+
"factory.v1",
|
|
143
|
+
6000,
|
|
144
|
+
true,
|
|
145
|
+
),
|
|
146
|
+
pack(
|
|
147
|
+
"worker-implementer",
|
|
148
|
+
"Perform bounded in-scope implementation slices, emit status events, and return TODO claims with evidence rather than mutating parent TODO state.",
|
|
149
|
+
[".pi/prompts/implement.md", ".pi/prompts/adaptive-workflow.md"],
|
|
150
|
+
[".pi/skills/zob-harness/SKILL.md", ".pi/skills/zob-sandbox/SKILL.md", ".pi/skills/zob-coms-v2-live/SKILL.md"],
|
|
151
|
+
["docs/OPERATING_MODEL.md", "docs/ARCHITECTURE.md", "docs/ZOB_GENERAL_FACTORY_AGENT_L4_L6_MASTER_PLAN.md"],
|
|
152
|
+
"implement.v1",
|
|
153
|
+
6000,
|
|
154
|
+
false,
|
|
155
|
+
),
|
|
156
|
+
pack(
|
|
157
|
+
"oracle",
|
|
158
|
+
"Skeptically review claims, source freshness, no-ship state, and final release readiness for L4/L5/L6 autonomy.",
|
|
159
|
+
[".pi/prompts/autonomous-runtime.md", ".pi/prompts/spec.md"],
|
|
160
|
+
[".pi/skills/zob-oracle/SKILL.md", ".pi/skills/zob-autonomous-runtime/SKILL.md", ".pi/skills/zob-coms-safety/SKILL.md"],
|
|
161
|
+
["docs/AUTONOMY_LEVELS.md", "docs/HARNESS_CAPABILITY_MATRIX.md", "docs/ZOB_GENERAL_FACTORY_AGENT_L4_L6_MASTER_PLAN.md"],
|
|
162
|
+
"oracle.v1",
|
|
163
|
+
7000,
|
|
164
|
+
true,
|
|
165
|
+
),
|
|
166
|
+
];
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function validateRefs(repoRoot: string, refs: string[], label: string): string[] {
|
|
170
|
+
const errors: string[] = [];
|
|
171
|
+
for (const ref of refs) {
|
|
172
|
+
const resolved = resolveRepoPath(repoRoot, ref);
|
|
173
|
+
errors.push(...resolved.errors.map((error) => `${label}:${error}`));
|
|
174
|
+
if (resolved.errors.length === 0 && !existsSync(resolved.path)) errors.push(`${label}:missing:${ref}`);
|
|
175
|
+
for (const protectedPattern of DEFAULT_RULES.zeroAccessPaths) {
|
|
176
|
+
if (pathMatches(ref, protectedPattern, repoRoot, repoRoot)) errors.push(`${label}:zero_access:${protectedPattern}`);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return errors;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export function validatePromptPack(repoRoot: string, promptPack: PromptPackDefinition): PromptPackEvalResult {
|
|
183
|
+
const failedChecks: string[] = [];
|
|
184
|
+
if (promptPack.schema !== "zob.prompt-pack.v1") failedChecks.push("schema");
|
|
185
|
+
if (!promptPack.purposeHash || promptPack.purposeHash.length !== 64) failedChecks.push("purpose_hash");
|
|
186
|
+
failedChecks.push(...validateRefs(repoRoot, promptPack.promptRefs, "prompt_refs"));
|
|
187
|
+
failedChecks.push(...validateRefs(repoRoot, promptPack.skillRefs, "skill_refs"));
|
|
188
|
+
failedChecks.push(...validateRefs(repoRoot, promptPack.docRefs, "doc_refs"));
|
|
189
|
+
failedChecks.push(...validateOutputContractId(promptPack.outputContract).map((error) => `output_contract:${error}`));
|
|
190
|
+
failedChecks.push(...validateOutputContractId(promptPack.eventPolicy.eventContract).map((error) => `event_contract:${error}`));
|
|
191
|
+
if (promptPack.contextPolicy.maxContextTokens <= 0 || promptPack.contextPolicy.maxContextTokens > 8000) failedChecks.push("max_context_tokens");
|
|
192
|
+
if (promptPack.contextPolicy.citationsRequired !== true) failedChecks.push("citations_required");
|
|
193
|
+
if (promptPack.eventPolicy.todoClaimReducerRequired !== true || promptPack.eventPolicy.directTodoMutationAllowed !== false || promptPack.eventPolicy.parentOwnedActions !== true) failedChecks.push("event_policy_parent_owned");
|
|
194
|
+
if (promptPack.launchAuthorizationRequired !== true) failedChecks.push("launch_authorization_required");
|
|
195
|
+
if (promptPack.bodyStored !== false || promptPack.promptBodiesStored !== false || promptPack.outputBodiesStored !== false) failedChecks.push("body_free_flags");
|
|
196
|
+
failedChecks.push(...forbiddenPlaintextPaths(promptPack).map((path) => `body_like_key:${path}`));
|
|
197
|
+
return {
|
|
198
|
+
roleId: promptPack.roleId,
|
|
199
|
+
passed: failedChecks.length === 0,
|
|
200
|
+
failedChecks,
|
|
201
|
+
refsChecked: [...promptPack.promptRefs, ...promptPack.skillRefs, ...promptPack.docRefs],
|
|
202
|
+
outputContract: promptPack.outputContract,
|
|
203
|
+
maxContextTokens: promptPack.contextPolicy.maxContextTokens,
|
|
204
|
+
bodyStored: false,
|
|
205
|
+
promptBodiesStored: false,
|
|
206
|
+
outputBodiesStored: false,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export function buildPromptPackReport(repoRoot: string, runId = "factory-agent-prompt-pack-smoke"): PromptPackReport {
|
|
211
|
+
const packs = defaultFactoryAgentPromptPacks();
|
|
212
|
+
const evals = packs.map((promptPack) => validatePromptPack(repoRoot, promptPack));
|
|
213
|
+
const failedChecks = evals.flatMap((result) => result.failedChecks.map((check) => `${result.roleId}:${check}`));
|
|
214
|
+
const report: PromptPackReport = {
|
|
215
|
+
schema: "zob.prompt-pack-eval.v1",
|
|
216
|
+
status: failedChecks.length === 0 ? "passed" : "failed",
|
|
217
|
+
runId,
|
|
218
|
+
packs,
|
|
219
|
+
evals,
|
|
220
|
+
failedChecks,
|
|
221
|
+
no_ship: failedChecks.length > 0,
|
|
222
|
+
bodyStored: false,
|
|
223
|
+
promptBodiesStored: false,
|
|
224
|
+
outputBodiesStored: false,
|
|
225
|
+
generatedAt: new Date().toISOString(),
|
|
226
|
+
};
|
|
227
|
+
const bodyViolations = promptPackBodyFreeViolations(report);
|
|
228
|
+
if (bodyViolations.length > 0) {
|
|
229
|
+
report.status = "failed";
|
|
230
|
+
report.no_ship = true;
|
|
231
|
+
report.failedChecks.push(...bodyViolations.map((path) => `report_body_like_key:${path}`));
|
|
232
|
+
}
|
|
233
|
+
return report;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export function promptPackBodyFreeViolations(value: unknown): string[] {
|
|
237
|
+
if (!isRecord(value) && !Array.isArray(value)) return [];
|
|
238
|
+
return forbiddenPlaintextPaths(value);
|
|
239
|
+
}
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { basename, join, resolve } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { evaluateStrictBudgetDispatchGate } from "./budget-policy.js";
|
|
5
|
+
import { classifyChildStopCondition, evaluateBudgetPreflightDryRun } from "./chronicle.js";
|
|
6
|
+
import { DEFAULT_RULES } from "./constants.js";
|
|
7
|
+
import { incrementCounter, normalizeDailyTelemetryDate, stringFrom } from "./telemetry.js";
|
|
8
|
+
import type { ChildStopCondition, FactoryRunBudgetInput, QueueState, QueueTickResult, ReadOnlyQueueJob, ReadOnlyQueueJobType } from "./types.js";
|
|
9
|
+
import { sha256 } from "./utils/hashing.js";
|
|
10
|
+
import { parseJsonFile } from "./utils/json.js";
|
|
11
|
+
import { expandHome, isSafeArtifactName, pathMatches, safeFileStem } from "./utils/paths.js";
|
|
12
|
+
import { isRecord } from "./utils/records.js";
|
|
13
|
+
|
|
14
|
+
export const READ_ONLY_QUEUE_JOB_TYPES: ReadOnlyQueueJobType[] = ["docs_watch", "repo_audit_readonly", "todo_risk_report", "session_analysis"];
|
|
15
|
+
const QUEUE_STATES: QueueState[] = ["pending", "running", "done", "failed"];
|
|
16
|
+
const DISALLOWED_QUEUE_JOB_TYPE_WORDS = /(?:write|edit|fix|patch|autofix|github|browser|cloud|deploy|publish|commit)/i;
|
|
17
|
+
const DISALLOWED_QUEUE_ADAPTERS = new Set(["write", "edit", "github", "browser", "cloud", "web", "deploy", "publish"]);
|
|
18
|
+
const FORBIDDEN_QUEUE_JOB_BODY_KEYS = new Set(["task", "prompt", "output", "body", "content"]);
|
|
19
|
+
const QUEUE_DAEMON_LEASE_MS = 30_000;
|
|
20
|
+
const QUEUE_DAEMON_MAX_WORKERS = 1;
|
|
21
|
+
const QUEUE_DAEMON_MAX_RETRIES = 1;
|
|
22
|
+
|
|
23
|
+
export function getQueuePaths(repoRoot: string): Record<QueueState | "root" | "ledger", string> {
|
|
24
|
+
const root = join(repoRoot, ".pi", "queue");
|
|
25
|
+
return {
|
|
26
|
+
root,
|
|
27
|
+
pending: join(root, "pending"),
|
|
28
|
+
running: join(root, "running"),
|
|
29
|
+
done: join(root, "done"),
|
|
30
|
+
failed: join(root, "failed"),
|
|
31
|
+
ledger: join(root, "ledger.jsonl"),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function ensureQueueDirs(repoRoot: string): Record<QueueState | "root" | "ledger", string> {
|
|
36
|
+
const paths = getQueuePaths(repoRoot);
|
|
37
|
+
for (const state of QUEUE_STATES) mkdirSync(paths[state], { recursive: true });
|
|
38
|
+
return paths;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function isReadOnlyQueueJob(value: unknown): value is ReadOnlyQueueJob {
|
|
42
|
+
return isRecord(value) && typeof value.id === "string" && typeof value.type === "string";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function queueJobPathSafeName(jobId: string): string {
|
|
46
|
+
return `${safeFileStem(jobId)}.json`;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function queueKillSwitchPath(repoRoot: string): string {
|
|
50
|
+
return join(getQueuePaths(repoRoot).root, "KILL_SWITCH");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function queueHeartbeatPath(repoRoot: string): string {
|
|
54
|
+
return join(getQueuePaths(repoRoot).root, "heartbeat.json");
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function buildQueueLease(jobId: string | undefined, jobType: string | undefined): Record<string, unknown> {
|
|
58
|
+
const now = Date.now();
|
|
59
|
+
return {
|
|
60
|
+
schema: "zob.queue-daemon-lease.v1",
|
|
61
|
+
leaseId: sha256(`${jobId ?? "unknown"}:${jobType ?? "unknown"}:${now}`).slice(0, 24),
|
|
62
|
+
jobId,
|
|
63
|
+
jobType,
|
|
64
|
+
claimedAt: new Date(now).toISOString(),
|
|
65
|
+
heartbeatAt: new Date(now).toISOString(),
|
|
66
|
+
expiresAt: new Date(now + QUEUE_DAEMON_LEASE_MS).toISOString(),
|
|
67
|
+
leaseMs: QUEUE_DAEMON_LEASE_MS,
|
|
68
|
+
maxWorkers: QUEUE_DAEMON_MAX_WORKERS,
|
|
69
|
+
bodyStored: false,
|
|
70
|
+
promptBodiesStored: false,
|
|
71
|
+
outputBodiesStored: false,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function writeQueueHeartbeat(repoRoot: string, lease: Record<string, unknown>, status: string): Record<string, unknown> {
|
|
76
|
+
const heartbeat = {
|
|
77
|
+
schema: "zob.queue-daemon-heartbeat.v1",
|
|
78
|
+
leaseId: lease.leaseId,
|
|
79
|
+
jobId: lease.jobId,
|
|
80
|
+
status,
|
|
81
|
+
heartbeatAt: new Date().toISOString(),
|
|
82
|
+
staleAfterMs: QUEUE_DAEMON_LEASE_MS,
|
|
83
|
+
killSwitchPath: ".pi/queue/KILL_SWITCH",
|
|
84
|
+
maxWorkers: QUEUE_DAEMON_MAX_WORKERS,
|
|
85
|
+
bodyStored: false,
|
|
86
|
+
promptBodiesStored: false,
|
|
87
|
+
outputBodiesStored: false,
|
|
88
|
+
};
|
|
89
|
+
writeFileSync(queueHeartbeatPath(repoRoot), JSON.stringify(heartbeat, null, 2), "utf8");
|
|
90
|
+
return heartbeat;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function retryPolicyForJob(job: ReadOnlyQueueJob | undefined): Record<string, unknown> {
|
|
94
|
+
const attempts = typeof job?.attempts === "number" && Number.isFinite(job.attempts) && job.attempts >= 0 ? Math.floor(job.attempts) : 0;
|
|
95
|
+
const maxRetries = typeof job?.maxRetries === "number" && Number.isFinite(job.maxRetries) && job.maxRetries >= 0 ? Math.min(Math.floor(job.maxRetries), QUEUE_DAEMON_MAX_RETRIES) : QUEUE_DAEMON_MAX_RETRIES;
|
|
96
|
+
return {
|
|
97
|
+
schema: "zob.queue-daemon-retry-policy.v1",
|
|
98
|
+
attempts,
|
|
99
|
+
maxRetries,
|
|
100
|
+
retriesCapped: true,
|
|
101
|
+
retryAllowed: attempts < maxRetries,
|
|
102
|
+
bodyStored: false,
|
|
103
|
+
promptBodiesStored: false,
|
|
104
|
+
outputBodiesStored: false,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function recoverStaleRunningJobs(repoRoot: string): number {
|
|
109
|
+
const paths = ensureQueueDirs(repoRoot);
|
|
110
|
+
let recovered = 0;
|
|
111
|
+
const now = Date.now();
|
|
112
|
+
for (const file of readdirSync(paths.running).filter((entry) => entry.endsWith(".json")).sort()) {
|
|
113
|
+
const runningPath = join(paths.running, file);
|
|
114
|
+
let record: unknown;
|
|
115
|
+
try {
|
|
116
|
+
record = parseJsonFile(runningPath);
|
|
117
|
+
} catch {
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
const lease = isRecord(record) && isRecord(record.lease) ? record.lease : undefined;
|
|
121
|
+
const expiresAt = typeof lease?.expiresAt === "string" ? Date.parse(lease.expiresAt) : Number.NaN;
|
|
122
|
+
if (!Number.isFinite(expiresAt) || now < expiresAt) continue;
|
|
123
|
+
const stalePayload = {
|
|
124
|
+
...(isRecord(record) ? record : {}),
|
|
125
|
+
schema: "zob.queue-job-result.v1",
|
|
126
|
+
status: "failed",
|
|
127
|
+
stopCondition: "timeout",
|
|
128
|
+
staleLeaseRecovered: true,
|
|
129
|
+
recoveredAt: new Date(now).toISOString(),
|
|
130
|
+
budgetEnforced: false,
|
|
131
|
+
promptBodiesStored: false,
|
|
132
|
+
outputBodiesStored: false,
|
|
133
|
+
};
|
|
134
|
+
const finalPath = finalizeQueueJob(repoRoot, runningPath, "failed", stalePayload);
|
|
135
|
+
writeQueueLifecycleEvent(repoRoot, { event: "stale_recovered", jobFile: file, finalPath, stopCondition: "timeout", leaseId: lease?.leaseId });
|
|
136
|
+
recovered += 1;
|
|
137
|
+
}
|
|
138
|
+
return recovered;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function normalizeQueueJobPaths(job: ReadOnlyQueueJob): string[] {
|
|
142
|
+
return job.paths?.length ? job.paths : ["."];
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
function validateQueueJobPath(repoRoot: string, path: string): string[] {
|
|
146
|
+
const errors: string[] = [];
|
|
147
|
+
const resolved = resolve(repoRoot, expandHome(path));
|
|
148
|
+
const root = resolve(repoRoot);
|
|
149
|
+
if (resolved !== root && !resolved.startsWith(`${root}/`)) errors.push(`path must stay inside repo root: ${path}`);
|
|
150
|
+
for (const protectedPattern of [...DEFAULT_RULES.zeroAccessPaths, ...DEFAULT_RULES.readOnlyPaths]) {
|
|
151
|
+
if (pathMatches(path, protectedPattern, repoRoot, repoRoot)) errors.push(`protected path is not allowed in read-only queue jobs: ${protectedPattern}`);
|
|
152
|
+
}
|
|
153
|
+
return errors;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function findForbiddenQueueJobBodyKeys(value: unknown, prefix = "job"): string[] {
|
|
157
|
+
if (!value || typeof value !== "object") return [];
|
|
158
|
+
if (Array.isArray(value)) return value.flatMap((child, index) => findForbiddenQueueJobBodyKeys(child, `${prefix}[${index}]`));
|
|
159
|
+
return Object.entries(value as Record<string, unknown>).flatMap(([key, child]) => {
|
|
160
|
+
const path = `${prefix}.${key}`;
|
|
161
|
+
return [...(FORBIDDEN_QUEUE_JOB_BODY_KEYS.has(key) ? [path] : []), ...findForbiddenQueueJobBodyKeys(child, path)];
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function validateReadOnlyQueueJob(repoRoot: string, job: unknown): string[] {
|
|
166
|
+
const errors: string[] = [];
|
|
167
|
+
const forbiddenBodyKeys = findForbiddenQueueJobBodyKeys(job);
|
|
168
|
+
if (forbiddenBodyKeys.length > 0) errors.push(`queue job must not contain raw task/prompt/output/body/content fields: ${forbiddenBodyKeys.join(", ")}`);
|
|
169
|
+
if (!isReadOnlyQueueJob(job)) return errors.length > 0 ? errors : ["queue job must be an object with string id and type"];
|
|
170
|
+
if (job.schema !== undefined && job.schema !== "zob.queue-job.v1") errors.push("queue job schema must be zob.queue-job.v1");
|
|
171
|
+
if (!isSafeArtifactName(job.id)) errors.push(`queue job id must be path-safe: ${job.id}`);
|
|
172
|
+
if (!READ_ONLY_QUEUE_JOB_TYPES.includes(job.type as ReadOnlyQueueJobType)) errors.push(`unsupported read-only queue job type: ${job.type}`);
|
|
173
|
+
if (DISALLOWED_QUEUE_JOB_TYPE_WORDS.test(job.type)) errors.push(`unsafe queue job type is not allowed: ${job.type}`);
|
|
174
|
+
if (job.readOnly !== true) errors.push("queue job must declare readOnly=true");
|
|
175
|
+
if (job.adapters !== undefined && (!Array.isArray(job.adapters) || !job.adapters.every((adapter) => typeof adapter === "string"))) errors.push("queue job adapters must be strings when provided");
|
|
176
|
+
for (const adapter of job.adapters ?? []) {
|
|
177
|
+
if (DISALLOWED_QUEUE_ADAPTERS.has(adapter.toLowerCase())) errors.push(`unsafe queue adapter is not allowed: ${adapter}`);
|
|
178
|
+
}
|
|
179
|
+
if (job.paths !== undefined && (!Array.isArray(job.paths) || !job.paths.every((path) => typeof path === "string"))) errors.push("queue job paths must be strings when provided");
|
|
180
|
+
if (Array.isArray(job.paths)) for (const path of normalizeQueueJobPaths(job)) errors.push(...validateQueueJobPath(repoRoot, path));
|
|
181
|
+
if (job.attempts !== undefined && (!Number.isInteger(job.attempts) || job.attempts < 0)) errors.push("queue job attempts must be a nonnegative integer when provided");
|
|
182
|
+
if (job.maxRetries !== undefined && (!Number.isInteger(job.maxRetries) || job.maxRetries < 0 || job.maxRetries > QUEUE_DAEMON_MAX_RETRIES)) errors.push(`queue job maxRetries must be between 0 and ${QUEUE_DAEMON_MAX_RETRIES}`);
|
|
183
|
+
return errors;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function writeQueueLifecycleEvent(repoRoot: string, event: Record<string, unknown>): string {
|
|
187
|
+
const paths = ensureQueueDirs(repoRoot);
|
|
188
|
+
const safeEvent = {
|
|
189
|
+
schema: "zob.queue-lifecycle-event.v1",
|
|
190
|
+
timestamp: new Date().toISOString(),
|
|
191
|
+
budgetEnforced: false,
|
|
192
|
+
promptBodiesStored: false,
|
|
193
|
+
outputBodiesStored: false,
|
|
194
|
+
...event,
|
|
195
|
+
};
|
|
196
|
+
appendFileSync(paths.ledger, `${JSON.stringify(safeEvent)}\n`, "utf8");
|
|
197
|
+
return paths.ledger;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function readQueueJobFile(path: string): unknown {
|
|
201
|
+
return parseJsonFile(path);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function queueBudgetResult(job: ReadOnlyQueueJob): Record<string, unknown> {
|
|
205
|
+
const budget = job.budget;
|
|
206
|
+
return evaluateBudgetPreflightDryRun({
|
|
207
|
+
costUsd: budget?.observedCostUsd,
|
|
208
|
+
runs: budget?.observedRuns,
|
|
209
|
+
durationMs: budget?.observedDurationMs,
|
|
210
|
+
parallelChildren: budget?.observedParallelChildren,
|
|
211
|
+
caps: budget,
|
|
212
|
+
strictRequested: budget?.strictRequested,
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function queueStrictBudgetGate(job: ReadOnlyQueueJob): Record<string, unknown> {
|
|
217
|
+
const budget = job.budget;
|
|
218
|
+
const strictBudget: FactoryRunBudgetInput = {
|
|
219
|
+
...(budget?.maxCostUsd !== undefined ? { maxCostUsd: budget.maxCostUsd } : {}),
|
|
220
|
+
...(budget?.maxRuns !== undefined ? { maxRuns: budget.maxRuns } : {}),
|
|
221
|
+
...(budget?.maxDurationMs !== undefined ? { maxDurationMs: budget.maxDurationMs } : {}),
|
|
222
|
+
...(budget?.maxParallelChildren !== undefined ? { maxParallelChildren: budget.maxParallelChildren } : {}),
|
|
223
|
+
strictRequested: budget?.strictRequested,
|
|
224
|
+
strictEnabled: budget?.strictEnabled,
|
|
225
|
+
estimatedCostUsd: budget?.estimatedCostUsd ?? budget?.observedCostUsd,
|
|
226
|
+
estimatedRuns: budget?.estimatedRuns ?? budget?.observedRuns,
|
|
227
|
+
estimatedDurationMs: budget?.estimatedDurationMs ?? budget?.observedDurationMs,
|
|
228
|
+
estimatedParallelChildren: budget?.estimatedParallelChildren ?? budget?.observedParallelChildren,
|
|
229
|
+
};
|
|
230
|
+
return evaluateStrictBudgetDispatchGate({
|
|
231
|
+
runId: job.id,
|
|
232
|
+
mode: "queue-daemon",
|
|
233
|
+
execution: "deterministic_metadata_only",
|
|
234
|
+
taskCount: 1,
|
|
235
|
+
selectedItems: 1,
|
|
236
|
+
budget: strictBudget,
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function runReadOnlyQueueJobHandler(repoRoot: string, job: ReadOnlyQueueJob, strictBudgetGate: Record<string, unknown>): Record<string, unknown> {
|
|
241
|
+
const inspectedPaths = normalizeQueueJobPaths(job);
|
|
242
|
+
return {
|
|
243
|
+
schema: "zob.queue-job-result.v1",
|
|
244
|
+
jobId: job.id,
|
|
245
|
+
jobType: job.type,
|
|
246
|
+
status: "done",
|
|
247
|
+
readOnly: true,
|
|
248
|
+
liveChildExecution: false,
|
|
249
|
+
handlerMode: "deterministic_metadata_only",
|
|
250
|
+
plannedActions: {
|
|
251
|
+
docs_watch: "Inspect documentation drift and summarize changed docs without edits.",
|
|
252
|
+
repo_audit_readonly: "Audit repository structure and safety signals without edits.",
|
|
253
|
+
todo_risk_report: "Report TODO/FIXME risk locations without edits.",
|
|
254
|
+
session_analysis: "Summarize local telemetry/session ledgers without prompt/output bodies.",
|
|
255
|
+
}[job.type as ReadOnlyQueueJobType],
|
|
256
|
+
inspectedPaths,
|
|
257
|
+
pathHashes: inspectedPaths.map((path) => ({ path, hash: sha256(resolve(repoRoot, path)) })),
|
|
258
|
+
budget: queueBudgetResult(job),
|
|
259
|
+
strictBudgetGate,
|
|
260
|
+
stop: classifyChildStopCondition({ assistantTurnSeen: true, outputHash: sha256(`${job.id}:${job.type}:metadata`), outputCaptured: true, outputValidated: true, evidenceChecked: true }),
|
|
261
|
+
budgetEnforced: strictBudgetGate.budgetEnforced === true,
|
|
262
|
+
promptBodiesStored: false,
|
|
263
|
+
outputBodiesStored: false,
|
|
264
|
+
generatedAt: new Date().toISOString(),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
function finalizeQueueJob(repoRoot: string, runningPath: string, state: "done" | "failed", payload: Record<string, unknown>): string {
|
|
269
|
+
const paths = ensureQueueDirs(repoRoot);
|
|
270
|
+
const finalPath = join(paths[state], basename(runningPath));
|
|
271
|
+
writeFileSync(runningPath, JSON.stringify(payload, null, 2), "utf8");
|
|
272
|
+
renameSync(runningPath, finalPath);
|
|
273
|
+
return finalPath;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export function runQueueDaemonTick(repoRoot: string): QueueTickResult {
|
|
277
|
+
const paths = ensureQueueDirs(repoRoot);
|
|
278
|
+
const killSwitchPresent = existsSync(queueKillSwitchPath(repoRoot));
|
|
279
|
+
if (killSwitchPresent) {
|
|
280
|
+
const killSwitch = { path: ".pi/queue/KILL_SWITCH", present: true, stopCondition: "blocked", bodyStored: false, promptBodiesStored: false, outputBodiesStored: false };
|
|
281
|
+
writeQueueLifecycleEvent(repoRoot, { event: "kill_switch_blocked", claimed: false, stopCondition: "blocked" });
|
|
282
|
+
return { schema: "zob.queue-tick-result.v1", claimed: false, status: "failed", errors: ["queue daemon kill switch present"], stopCondition: "blocked", killSwitch, maxWorkers: QUEUE_DAEMON_MAX_WORKERS, budgetEnforced: false, promptBodiesStored: false, outputBodiesStored: false };
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
const staleRecovered = recoverStaleRunningJobs(repoRoot);
|
|
286
|
+
const pending = readdirSync(paths.pending).filter((file) => file.endsWith(".json")).sort();
|
|
287
|
+
if (pending.length === 0) {
|
|
288
|
+
writeQueueLifecycleEvent(repoRoot, { event: "idle", claimed: false, staleRecovered });
|
|
289
|
+
return { schema: "zob.queue-tick-result.v1", claimed: false, status: "idle", errors: [], stopCondition: "none", staleRecovered, maxWorkers: QUEUE_DAEMON_MAX_WORKERS, budgetEnforced: false, promptBodiesStored: false, outputBodiesStored: false };
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
const pendingPath = join(paths.pending, pending[0]);
|
|
293
|
+
const runningPath = join(paths.running, pending[0]);
|
|
294
|
+
renameSync(pendingPath, runningPath);
|
|
295
|
+
writeQueueLifecycleEvent(repoRoot, { event: "claimed", jobFile: pending[0], claimedPath: runningPath, maxWorkers: QUEUE_DAEMON_MAX_WORKERS, staleRecovered });
|
|
296
|
+
|
|
297
|
+
let job: unknown;
|
|
298
|
+
try {
|
|
299
|
+
job = readQueueJobFile(runningPath);
|
|
300
|
+
} catch (error) {
|
|
301
|
+
const errors = [`could not parse queue job: ${error instanceof Error ? error.message : String(error)}`];
|
|
302
|
+
const finalPath = finalizeQueueJob(repoRoot, runningPath, "failed", { schema: "zob.queue-job-result.v1", status: "failed", errors, budgetEnforced: false, promptBodiesStored: false, outputBodiesStored: false });
|
|
303
|
+
writeQueueLifecycleEvent(repoRoot, { event: "failed", jobFile: pending[0], errors, stopCondition: "failed_preflight" });
|
|
304
|
+
return { schema: "zob.queue-tick-result.v1", claimed: true, status: "failed", claimedPath: runningPath, finalPath, errors, stopCondition: "failed_preflight", staleRecovered, maxWorkers: QUEUE_DAEMON_MAX_WORKERS, budgetEnforced: false, promptBodiesStored: false, outputBodiesStored: false };
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const errors = validateReadOnlyQueueJob(repoRoot, job);
|
|
308
|
+
const jobId = isReadOnlyQueueJob(job) ? job.id : undefined;
|
|
309
|
+
const jobType = isReadOnlyQueueJob(job) ? job.type : undefined;
|
|
310
|
+
if (errors.length > 0 || !isReadOnlyQueueJob(job)) {
|
|
311
|
+
const finalPath = finalizeQueueJob(repoRoot, runningPath, "failed", { schema: "zob.queue-job-result.v1", jobId, jobType, status: "failed", errors, stopCondition: "failed_preflight", budgetEnforced: false, promptBodiesStored: false, outputBodiesStored: false });
|
|
312
|
+
writeQueueLifecycleEvent(repoRoot, { event: "failed", jobId, jobType, jobFile: pending[0], errors, stopCondition: "failed_preflight" });
|
|
313
|
+
return { schema: "zob.queue-tick-result.v1", claimed: true, jobId, jobType, status: "failed", claimedPath: runningPath, finalPath, errors, stopCondition: "failed_preflight", staleRecovered, maxWorkers: QUEUE_DAEMON_MAX_WORKERS, retryPolicy: retryPolicyForJob(isReadOnlyQueueJob(job) ? job : undefined), budgetEnforced: false, promptBodiesStored: false, outputBodiesStored: false };
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
const strictBudgetGate = queueStrictBudgetGate(job);
|
|
317
|
+
if (strictBudgetGate.wouldBlockDispatch === true) {
|
|
318
|
+
const finalPath = finalizeQueueJob(repoRoot, runningPath, "failed", { schema: "zob.queue-job-result.v1", jobId: job.id, jobType: job.type, status: "failed", errors: ["strict budget gate blocked queue daemon job before handler"], stopCondition: "blocked", strictBudgetGate, budgetEnforced: strictBudgetGate.budgetEnforced === true, promptBodiesStored: false, outputBodiesStored: false });
|
|
319
|
+
writeQueueLifecycleEvent(repoRoot, { event: "strict_budget_blocked", jobId: job.id, jobType: job.type, jobFile: pending[0], finalPath, stopCondition: "blocked", strictBudgetGate });
|
|
320
|
+
return { schema: "zob.queue-tick-result.v1", claimed: true, jobId: job.id, jobType: job.type, status: "failed", claimedPath: runningPath, finalPath, errors: ["strict budget gate blocked queue daemon job before handler"], stopCondition: "blocked", strictBudgetGate, staleRecovered, maxWorkers: QUEUE_DAEMON_MAX_WORKERS, retryPolicy: retryPolicyForJob(job), budgetEnforced: strictBudgetGate.budgetEnforced === true, promptBodiesStored: false, outputBodiesStored: false };
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
const lease = buildQueueLease(job.id, job.type);
|
|
324
|
+
const heartbeat = writeQueueHeartbeat(repoRoot, lease, "running");
|
|
325
|
+
writeFileSync(runningPath, JSON.stringify({ ...job, lease, heartbeat, scheduler: { schema: "zob.queue-daemon-scheduler.v1", maxWorkers: QUEUE_DAEMON_MAX_WORKERS, claimAtMostOneJobPerTick: true, boundedRetries: true, bodyStored: false, promptBodiesStored: false, outputBodiesStored: false } }, null, 2), "utf8");
|
|
326
|
+
writeQueueLifecycleEvent(repoRoot, { event: "heartbeat", jobId: job.id, jobType: job.type, leaseId: lease.leaseId, heartbeatAt: heartbeat.heartbeatAt });
|
|
327
|
+
|
|
328
|
+
const result: Record<string, unknown> = { ...runReadOnlyQueueJobHandler(repoRoot, job, strictBudgetGate), lease, heartbeat, retryPolicy: retryPolicyForJob(job), maxWorkers: QUEUE_DAEMON_MAX_WORKERS };
|
|
329
|
+
const stopCondition = isRecord(result.stop) && typeof result.stop.stopCondition === "string" ? (result.stop.stopCondition as ChildStopCondition) : "none";
|
|
330
|
+
const finalPath = finalizeQueueJob(repoRoot, runningPath, stopCondition === "none" ? "done" : "failed", result);
|
|
331
|
+
writeQueueLifecycleEvent(repoRoot, { event: stopCondition === "none" ? "done" : "failed", jobId: job.id, jobType: job.type, jobFile: pending[0], finalPath, stopCondition, leaseId: lease.leaseId });
|
|
332
|
+
return { schema: "zob.queue-tick-result.v1", claimed: true, jobId: job.id, jobType: job.type, status: stopCondition === "none" ? "done" : "failed", claimedPath: runningPath, finalPath, errors: [], stopCondition, lease, heartbeat, staleRecovered, maxWorkers: QUEUE_DAEMON_MAX_WORKERS, retryPolicy: retryPolicyForJob(job), strictBudgetGate, budgetEnforced: strictBudgetGate.budgetEnforced === true, promptBodiesStored: false, outputBodiesStored: false };
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
function countQueueFiles(dir: string): number {
|
|
336
|
+
return existsSync(dir) ? readdirSync(dir).filter((file) => file.endsWith(".json")).length : 0;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function readQueueLedger(repoRoot: string): Array<Record<string, unknown>> {
|
|
340
|
+
const ledger = getQueuePaths(repoRoot).ledger;
|
|
341
|
+
if (!existsSync(ledger)) return [];
|
|
342
|
+
return readFileSync(ledger, "utf8")
|
|
343
|
+
.split("\n")
|
|
344
|
+
.map((line) => line.trim())
|
|
345
|
+
.filter(Boolean)
|
|
346
|
+
.map((line) => {
|
|
347
|
+
try {
|
|
348
|
+
const parsed = JSON.parse(line) as unknown;
|
|
349
|
+
return isRecord(parsed) ? parsed : undefined;
|
|
350
|
+
} catch {
|
|
351
|
+
return undefined;
|
|
352
|
+
}
|
|
353
|
+
})
|
|
354
|
+
.filter((entry): entry is Record<string, unknown> => Boolean(entry));
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
export function buildQueueDashboardSummary(repoRoot: string, date?: string): Record<string, unknown> {
|
|
358
|
+
const paths = ensureQueueDirs(repoRoot);
|
|
359
|
+
const ledger = readQueueLedger(repoRoot);
|
|
360
|
+
const byEvent: Record<string, number> = {};
|
|
361
|
+
const byJobType: Record<string, number> = {};
|
|
362
|
+
for (const entry of ledger) {
|
|
363
|
+
incrementCounter(byEvent, stringFrom(entry.event));
|
|
364
|
+
incrementCounter(byJobType, stringFrom(entry.jobType));
|
|
365
|
+
}
|
|
366
|
+
const day = normalizeDailyTelemetryDate(date);
|
|
367
|
+
const dailyPath = join(repoRoot, ".pi", "logs", "summaries", `${day}.json`);
|
|
368
|
+
const daily = existsSync(dailyPath) && isRecord(parseJsonFile(dailyPath)) ? (parseJsonFile(dailyPath) as Record<string, unknown>) : undefined;
|
|
369
|
+
return {
|
|
370
|
+
schema: "zob.queue-dashboard-summary.v1",
|
|
371
|
+
generatedAt: new Date().toISOString(),
|
|
372
|
+
queue: {
|
|
373
|
+
pending: countQueueFiles(paths.pending),
|
|
374
|
+
running: countQueueFiles(paths.running),
|
|
375
|
+
done: countQueueFiles(paths.done),
|
|
376
|
+
failed: countQueueFiles(paths.failed),
|
|
377
|
+
},
|
|
378
|
+
lifecycle: { events: ledger.length, byEvent, byJobType, latest: ledger.slice(-5) },
|
|
379
|
+
telemetry: daily ? { date: day, totals: daily.totals, statusCounts: daily.statusCounts, bodySafety: daily.bodySafety } : { date: day, missing: true },
|
|
380
|
+
budgetEnforced: false,
|
|
381
|
+
autoStartDaemon: false,
|
|
382
|
+
continuousLoop: false,
|
|
383
|
+
promptBodiesStored: false,
|
|
384
|
+
outputBodiesStored: false,
|
|
385
|
+
};
|
|
386
|
+
}
|