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,429 @@
|
|
|
1
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { evaluateBudgetPreflightDryRun } from "./chronicle.js";
|
|
5
|
+
import type { BudgetPreflightDryRunCaps, FactoryRunModelRoutingInput, ModeName } from "./types.js";
|
|
6
|
+
import { sha256 } from "./utils/hashing.js";
|
|
7
|
+
import { parseJsonFile } from "./utils/json.js";
|
|
8
|
+
import { safeFileStem } from "./utils/paths.js";
|
|
9
|
+
import { isRecord } from "./utils/records.js";
|
|
10
|
+
|
|
11
|
+
export type ModelRiskLevel = "low" | "medium" | "high";
|
|
12
|
+
export type ModelClass = "cheap_scout" | "balanced_worker" | "strong_reasoning" | "strong_oracle" | "high_context";
|
|
13
|
+
|
|
14
|
+
export interface ModelRoutingDryRunInput {
|
|
15
|
+
mode?: ModeName;
|
|
16
|
+
taskType?: string;
|
|
17
|
+
outputContract?: string;
|
|
18
|
+
risk?: ModelRiskLevel | string;
|
|
19
|
+
contextTokens?: number;
|
|
20
|
+
estimatedCostUsd?: number;
|
|
21
|
+
estimatedRuns?: number;
|
|
22
|
+
estimatedDurationMs?: number;
|
|
23
|
+
estimatedParallelChildren?: number;
|
|
24
|
+
caps?: BudgetPreflightDryRunCaps;
|
|
25
|
+
strictRequested?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ModelRoutingReadinessAuditInput {
|
|
29
|
+
run_id?: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ModelRoutingDispatchGateInput extends ModelRoutingDryRunInput {
|
|
33
|
+
runId?: string;
|
|
34
|
+
stage?: string;
|
|
35
|
+
agent?: string;
|
|
36
|
+
defaultModel?: string;
|
|
37
|
+
modelRouting?: FactoryRunModelRoutingInput;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const FORBIDDEN_BODY_KEYS = new Set(["task", "prompt", "output", "body", "content"]);
|
|
41
|
+
|
|
42
|
+
function hasForbiddenBodyKeys(value: unknown): boolean {
|
|
43
|
+
if (!value || typeof value !== "object") return false;
|
|
44
|
+
if (Array.isArray(value)) return value.some(hasForbiddenBodyKeys);
|
|
45
|
+
return Object.entries(value as Record<string, unknown>).some(([key, child]) => FORBIDDEN_BODY_KEYS.has(key) || hasForbiddenBodyKeys(child));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function normalizeRisk(value: string | undefined): ModelRiskLevel {
|
|
49
|
+
if (value === "low" || value === "medium" || value === "high") return value;
|
|
50
|
+
return "medium";
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function includesAny(value: string | undefined, needles: string[]): boolean {
|
|
54
|
+
const normalized = (value ?? "").toLowerCase();
|
|
55
|
+
return needles.some((needle) => normalized.includes(needle));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function numberOrZero(value: number | undefined): number {
|
|
59
|
+
return typeof value === "number" && Number.isFinite(value) && value > 0 ? value : 0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function chooseModelClass(input: ModelRoutingDryRunInput): { modelClass: ModelClass; reasonCodes: string[] } {
|
|
63
|
+
const reasonCodes: string[] = [];
|
|
64
|
+
const risk = normalizeRisk(input.risk);
|
|
65
|
+
const contextTokens = numberOrZero(input.contextTokens);
|
|
66
|
+
const isOracleLike = includesAny(input.taskType, ["oracle", "review", "validate"]) || includesAny(input.outputContract, ["oracle"]);
|
|
67
|
+
const isImplementationLike = includesAny(input.taskType, ["implement", "factory", "synthesis", "worker"]) || input.mode === "implement" || input.mode === "factory";
|
|
68
|
+
|
|
69
|
+
if (contextTokens >= 120_000) {
|
|
70
|
+
reasonCodes.push("context_tokens_high");
|
|
71
|
+
return { modelClass: "high_context", reasonCodes };
|
|
72
|
+
}
|
|
73
|
+
if (isOracleLike) {
|
|
74
|
+
reasonCodes.push("oracle_or_validation_task");
|
|
75
|
+
return { modelClass: "strong_oracle", reasonCodes };
|
|
76
|
+
}
|
|
77
|
+
if (risk === "high") {
|
|
78
|
+
reasonCodes.push("high_risk_task");
|
|
79
|
+
return { modelClass: "strong_reasoning", reasonCodes };
|
|
80
|
+
}
|
|
81
|
+
if (isImplementationLike || risk === "medium") {
|
|
82
|
+
reasonCodes.push(isImplementationLike ? "implementation_or_factory_task" : "medium_risk_task");
|
|
83
|
+
return { modelClass: "balanced_worker", reasonCodes };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
reasonCodes.push("low_risk_readonly_task");
|
|
87
|
+
return { modelClass: "cheap_scout", reasonCodes };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function evaluateModelRoutingDryRun(input: ModelRoutingDryRunInput = {}): Record<string, unknown> {
|
|
91
|
+
const budgetPreflight = evaluateBudgetPreflightDryRun({
|
|
92
|
+
costUsd: input.estimatedCostUsd,
|
|
93
|
+
runs: input.estimatedRuns,
|
|
94
|
+
durationMs: input.estimatedDurationMs,
|
|
95
|
+
parallelChildren: input.estimatedParallelChildren,
|
|
96
|
+
caps: input.caps,
|
|
97
|
+
strictRequested: input.strictRequested,
|
|
98
|
+
});
|
|
99
|
+
const { modelClass, reasonCodes } = chooseModelClass(input);
|
|
100
|
+
const budgetWouldExceed = budgetPreflight.wouldExceed === true;
|
|
101
|
+
return {
|
|
102
|
+
schema: "zob.model-routing-dry-run.v1",
|
|
103
|
+
dryRun: true,
|
|
104
|
+
advisory: true,
|
|
105
|
+
mode: input.mode ?? "explore",
|
|
106
|
+
taskType: input.taskType ?? "unspecified",
|
|
107
|
+
outputContract: input.outputContract,
|
|
108
|
+
risk: normalizeRisk(input.risk),
|
|
109
|
+
recommendedModelClass: modelClass,
|
|
110
|
+
reasonCodes,
|
|
111
|
+
budget: budgetPreflight,
|
|
112
|
+
budgetWouldExceed,
|
|
113
|
+
budgetEnforced: false,
|
|
114
|
+
strictRequested: input.strictRequested === true,
|
|
115
|
+
strictEnabled: false,
|
|
116
|
+
modelRouterUsed: false,
|
|
117
|
+
routingApplied: false,
|
|
118
|
+
wouldBlockDispatch: false,
|
|
119
|
+
defaultDispatchDecision: "allow",
|
|
120
|
+
childDispatchAllowed: false,
|
|
121
|
+
daemonStarted: false,
|
|
122
|
+
noExecution: true,
|
|
123
|
+
bodyStored: false,
|
|
124
|
+
promptBodiesStored: false,
|
|
125
|
+
outputBodiesStored: false,
|
|
126
|
+
generatedAt: new Date().toISOString(),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export function writeModelRoutingDryRunReport(repoRoot: string, runId: string, input: ModelRoutingDryRunInput = {}): string {
|
|
131
|
+
const dir = join(repoRoot, ".pi", "logs", "model-routing");
|
|
132
|
+
mkdirSync(dir, { recursive: true });
|
|
133
|
+
const outputPath = join(dir, `${safeFileStem(runId)}.json`);
|
|
134
|
+
writeFileSync(outputPath, JSON.stringify(evaluateModelRoutingDryRun(input), null, 2), "utf8");
|
|
135
|
+
return outputPath;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function modelNameForClass(modelRouting: FactoryRunModelRoutingInput | undefined, modelClass: ModelClass): string | undefined {
|
|
139
|
+
if (!isRecord(modelRouting?.modelByClass)) return undefined;
|
|
140
|
+
const value = modelRouting.modelByClass[modelClass];
|
|
141
|
+
return typeof value === "string" && value.trim().length > 0 ? value : undefined;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export function evaluateModelRoutingDispatchGate(input: ModelRoutingDispatchGateInput = {}): Record<string, unknown> {
|
|
145
|
+
const enabled = input.modelRouting?.enabled === true;
|
|
146
|
+
const dryRun = evaluateModelRoutingDryRun({
|
|
147
|
+
mode: input.mode,
|
|
148
|
+
taskType: input.taskType ?? input.stage ?? input.agent,
|
|
149
|
+
outputContract: input.outputContract,
|
|
150
|
+
risk: input.modelRouting?.risk ?? input.risk,
|
|
151
|
+
contextTokens: input.modelRouting?.contextTokens ?? input.contextTokens,
|
|
152
|
+
estimatedCostUsd: input.estimatedCostUsd,
|
|
153
|
+
estimatedRuns: input.estimatedRuns,
|
|
154
|
+
estimatedDurationMs: input.estimatedDurationMs,
|
|
155
|
+
estimatedParallelChildren: input.estimatedParallelChildren,
|
|
156
|
+
caps: input.caps,
|
|
157
|
+
strictRequested: input.strictRequested,
|
|
158
|
+
});
|
|
159
|
+
const selectedModelClass = dryRun.recommendedModelClass as ModelClass;
|
|
160
|
+
const classModel = enabled ? modelNameForClass(input.modelRouting, selectedModelClass) : undefined;
|
|
161
|
+
const selectedModel = enabled ? classModel ?? input.defaultModel : input.defaultModel;
|
|
162
|
+
return {
|
|
163
|
+
schema: "zob.model-routing-dispatch-gate.v1",
|
|
164
|
+
runId: input.runId,
|
|
165
|
+
stage: input.stage,
|
|
166
|
+
agent: input.agent,
|
|
167
|
+
mode: input.mode ?? "factory",
|
|
168
|
+
outputContract: input.outputContract,
|
|
169
|
+
liveRoutingRequested: enabled,
|
|
170
|
+
liveRoutingEnabled: enabled,
|
|
171
|
+
modelRouterUsed: enabled,
|
|
172
|
+
routingApplied: enabled,
|
|
173
|
+
selectedModelClass,
|
|
174
|
+
recommendedModelClass: selectedModelClass,
|
|
175
|
+
selectedModel,
|
|
176
|
+
selectedModelHash: typeof selectedModel === "string" ? sha256(selectedModel) : undefined,
|
|
177
|
+
selectedModelStored: false,
|
|
178
|
+
modelByClassProvided: isRecord(input.modelRouting?.modelByClass),
|
|
179
|
+
reasonCodes: dryRun.reasonCodes,
|
|
180
|
+
budgetWouldExceed: dryRun.budgetWouldExceed === true,
|
|
181
|
+
budgetEnforced: false,
|
|
182
|
+
strictEnabled: false,
|
|
183
|
+
wouldBlockDispatch: false,
|
|
184
|
+
childDispatchAllowed: enabled,
|
|
185
|
+
defaultDispatchDecision: enabled ? "route_model" : "allow_default_model",
|
|
186
|
+
gateEvaluationOnly: true,
|
|
187
|
+
noExecution: true,
|
|
188
|
+
bodyStored: false,
|
|
189
|
+
promptBodiesStored: false,
|
|
190
|
+
outputBodiesStored: false,
|
|
191
|
+
generatedAt: new Date().toISOString(),
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function readinessCheck(name: string, passed: boolean, detail: Record<string, unknown> = {}): Record<string, unknown> {
|
|
196
|
+
return { name, passed, detail };
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
function routeSafetyPassed(route: Record<string, unknown>): boolean {
|
|
200
|
+
return route.dryRun === true
|
|
201
|
+
&& route.advisory === true
|
|
202
|
+
&& route.budgetEnforced === false
|
|
203
|
+
&& route.strictEnabled === false
|
|
204
|
+
&& route.modelRouterUsed === false
|
|
205
|
+
&& route.routingApplied === false
|
|
206
|
+
&& route.childDispatchAllowed === false
|
|
207
|
+
&& route.daemonStarted === false
|
|
208
|
+
&& route.noExecution === true
|
|
209
|
+
&& route.bodyStored === false
|
|
210
|
+
&& route.promptBodiesStored === false
|
|
211
|
+
&& route.outputBodiesStored === false
|
|
212
|
+
&& route.wouldBlockDispatch === false;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function stringArray(value: unknown): string[] | undefined {
|
|
216
|
+
return Array.isArray(value) && value.every((item) => typeof item === "string") ? value : undefined;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export function validateModelRoutingConfig(repoRoot: string): Record<string, unknown> {
|
|
220
|
+
const configPath = join(repoRoot, ".pi", "model-routing.json");
|
|
221
|
+
const errors: string[] = [];
|
|
222
|
+
let parsed: Record<string, unknown> | undefined;
|
|
223
|
+
let configHash: string | undefined;
|
|
224
|
+
if (!existsSync(configPath)) {
|
|
225
|
+
errors.push(".pi/model-routing.json is missing");
|
|
226
|
+
} else {
|
|
227
|
+
try {
|
|
228
|
+
const raw = readFileSync(configPath, "utf8");
|
|
229
|
+
configHash = sha256(raw);
|
|
230
|
+
const value = parseJsonFile(configPath);
|
|
231
|
+
if (!isRecord(value)) {
|
|
232
|
+
errors.push("model routing config must be a JSON object");
|
|
233
|
+
} else {
|
|
234
|
+
parsed = value;
|
|
235
|
+
}
|
|
236
|
+
} catch (error) {
|
|
237
|
+
errors.push(`model routing config could not be parsed: ${error instanceof Error ? error.message : String(error)}`);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const expectedClasses: ModelClass[] = ["cheap_scout", "balanced_worker", "strong_reasoning", "strong_oracle", "high_context"];
|
|
242
|
+
const modes: ModeName[] = ["explore", "plan", "implement", "oracle", "factory", "orchestrator"];
|
|
243
|
+
const modelClasses = isRecord(parsed?.modelClasses) ? parsed.modelClasses : undefined;
|
|
244
|
+
const defaults = isRecord(parsed?.defaults) ? parsed.defaults : undefined;
|
|
245
|
+
const byMode = isRecord(defaults?.byMode) ? defaults.byMode : undefined;
|
|
246
|
+
|
|
247
|
+
if (parsed) {
|
|
248
|
+
if (parsed.schema !== "zob.model-routing-config.v1") errors.push("model routing config schema must be zob.model-routing-config.v1");
|
|
249
|
+
if (parsed.advisoryOnly !== true) errors.push("model routing config must keep advisoryOnly=true");
|
|
250
|
+
if (parsed.liveRoutingDispatchGateAvailable !== true) errors.push("model routing config must declare liveRoutingDispatchGateAvailable=true");
|
|
251
|
+
if (parsed.liveRoutingRequiresExplicitInput !== true) errors.push("model routing config must declare liveRoutingRequiresExplicitInput=true");
|
|
252
|
+
for (const flag of ["liveRoutingDefaultEnabled", "liveRoutingEnabled", "budgetEnforced", "strictEnabled", "modelRouterUsed", "routingApplied", "childDispatchAllowed", "daemonStarted", "networkAccessed", "bodyStored", "promptBodiesStored", "outputBodiesStored"]) {
|
|
253
|
+
if (parsed[flag] !== false) errors.push(`model routing config must keep ${flag}=false`);
|
|
254
|
+
}
|
|
255
|
+
if (parsed.noExecution !== true) errors.push("model routing config must keep noExecution=true");
|
|
256
|
+
if (!modelClasses) {
|
|
257
|
+
errors.push("model routing config requires modelClasses object");
|
|
258
|
+
} else {
|
|
259
|
+
for (const modelClass of expectedClasses) {
|
|
260
|
+
const entry = modelClasses[modelClass];
|
|
261
|
+
if (!isRecord(entry)) {
|
|
262
|
+
errors.push(`model routing config missing modelClasses.${modelClass}`);
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (entry.risk !== "low" && entry.risk !== "medium" && entry.risk !== "high") errors.push(`modelClasses.${modelClass}.risk must be low, medium, or high`);
|
|
266
|
+
if (!stringArray(entry.useFor) || stringArray(entry.useFor)?.length === 0) errors.push(`modelClasses.${modelClass}.useFor must be a non-empty string array`);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
if (!byMode) {
|
|
270
|
+
errors.push("model routing config requires defaults.byMode object");
|
|
271
|
+
} else {
|
|
272
|
+
for (const mode of modes) {
|
|
273
|
+
if (!expectedClasses.includes(byMode[mode] as ModelClass)) errors.push(`defaults.byMode.${mode} must reference a known model class`);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (defaults?.highContextThresholdTokens !== 120_000) errors.push("defaults.highContextThresholdTokens must be 120000");
|
|
277
|
+
if (defaults?.highContextModelClass !== "high_context") errors.push("defaults.highContextModelClass must be high_context");
|
|
278
|
+
if (!stringArray(parsed.futureLiveRoutingPrerequisites) || stringArray(parsed.futureLiveRoutingPrerequisites)?.length === 0) errors.push("model routing config requires futureLiveRoutingPrerequisites");
|
|
279
|
+
if (hasForbiddenBodyKeys(parsed)) errors.push("model routing config must not store raw task/prompt/output/body/content fields");
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
return {
|
|
283
|
+
schema: "zob.model-routing-config-validation.v1",
|
|
284
|
+
path: ".pi/model-routing.json",
|
|
285
|
+
present: existsSync(configPath),
|
|
286
|
+
valid: errors.length === 0,
|
|
287
|
+
errors,
|
|
288
|
+
configHash,
|
|
289
|
+
modelClasses: modelClasses ? expectedClasses.filter((modelClass) => isRecord(modelClasses[modelClass])) : [],
|
|
290
|
+
modesConfigured: byMode ? modes.filter((mode) => typeof byMode[mode] === "string") : [],
|
|
291
|
+
advisoryOnly: parsed?.advisoryOnly === true,
|
|
292
|
+
liveRoutingDispatchGateAvailable: parsed?.liveRoutingDispatchGateAvailable === true,
|
|
293
|
+
liveRoutingRequiresExplicitInput: parsed?.liveRoutingRequiresExplicitInput === true,
|
|
294
|
+
liveRoutingDefaultEnabled: parsed?.liveRoutingDefaultEnabled === true,
|
|
295
|
+
liveRoutingEnabled: parsed?.liveRoutingEnabled === true,
|
|
296
|
+
budgetEnforced: parsed?.budgetEnforced === true,
|
|
297
|
+
strictEnabled: parsed?.strictEnabled === true,
|
|
298
|
+
modelRouterUsed: parsed?.modelRouterUsed === true,
|
|
299
|
+
routingApplied: parsed?.routingApplied === true,
|
|
300
|
+
childDispatchAllowed: parsed?.childDispatchAllowed === true,
|
|
301
|
+
daemonStarted: parsed?.daemonStarted === true,
|
|
302
|
+
networkAccessed: parsed?.networkAccessed === true,
|
|
303
|
+
noExecution: parsed?.noExecution === true,
|
|
304
|
+
bodyStored: false,
|
|
305
|
+
promptBodiesStored: false,
|
|
306
|
+
outputBodiesStored: false,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export function buildModelRoutingReadinessAudit(repoRoot: string, input: ModelRoutingReadinessAuditInput = {}): Record<string, unknown> {
|
|
311
|
+
const configValidation = validateModelRoutingConfig(repoRoot);
|
|
312
|
+
const scenarios: Array<{ name: string; expectedModelClass: ModelClass; input: ModelRoutingDryRunInput }> = [
|
|
313
|
+
{ name: "low_risk_readonly", expectedModelClass: "cheap_scout", input: { mode: "explore", taskType: "read-only-inspection", risk: "low" } },
|
|
314
|
+
{ name: "implementation_worker", expectedModelClass: "balanced_worker", input: { mode: "implement", taskType: "worker-implementation", risk: "medium" } },
|
|
315
|
+
{ name: "high_risk_reasoning", expectedModelClass: "strong_reasoning", input: { mode: "plan", taskType: "security-critical-plan", risk: "high" } },
|
|
316
|
+
{ name: "oracle_review", expectedModelClass: "strong_oracle", input: { mode: "oracle", taskType: "oracle-review", outputContract: "oracle.v1", risk: "high" } },
|
|
317
|
+
{ name: "high_context_batch", expectedModelClass: "high_context", input: { mode: "factory", taskType: "batch-synthesis", risk: "medium", contextTokens: 150_000 } },
|
|
318
|
+
{ name: "strict_budget_exceedance", expectedModelClass: "balanced_worker", input: { mode: "factory", taskType: "worker", risk: "medium", estimatedCostUsd: 2, caps: { maxCostUsd: 1 }, strictRequested: true } },
|
|
319
|
+
];
|
|
320
|
+
const evaluated = scenarios.map((scenario) => {
|
|
321
|
+
const route = evaluateModelRoutingDryRun(scenario.input);
|
|
322
|
+
return {
|
|
323
|
+
name: scenario.name,
|
|
324
|
+
inputHash: sha256(JSON.stringify(scenario.input)),
|
|
325
|
+
expectedModelClass: scenario.expectedModelClass,
|
|
326
|
+
recommendedModelClass: route.recommendedModelClass,
|
|
327
|
+
matchedExpectation: route.recommendedModelClass === scenario.expectedModelClass,
|
|
328
|
+
safetyPassed: routeSafetyPassed(route),
|
|
329
|
+
budgetWouldExceed: route.budgetWouldExceed === true,
|
|
330
|
+
strictRequested: route.strictRequested === true,
|
|
331
|
+
strictEnabled: route.strictEnabled === true,
|
|
332
|
+
budgetEnforced: route.budgetEnforced === true,
|
|
333
|
+
modelRouterUsed: route.modelRouterUsed === true,
|
|
334
|
+
routingApplied: route.routingApplied === true,
|
|
335
|
+
childDispatchAllowed: route.childDispatchAllowed === true,
|
|
336
|
+
noExecution: route.noExecution === true,
|
|
337
|
+
reasonCodes: route.reasonCodes,
|
|
338
|
+
};
|
|
339
|
+
});
|
|
340
|
+
const coveredClasses = [...new Set(evaluated.map((scenario) => String(scenario.recommendedModelClass)))].sort();
|
|
341
|
+
const expectedClasses: ModelClass[] = ["balanced_worker", "cheap_scout", "high_context", "strong_oracle", "strong_reasoning"];
|
|
342
|
+
const strictBudgetScenario = evaluated.find((scenario) => scenario.name === "strict_budget_exceedance");
|
|
343
|
+
const dispatchGateInputs: Array<{ name: string; input: ModelRoutingDispatchGateInput }> = [
|
|
344
|
+
{ name: "routing_default_disabled", input: { runId: "route-default", mode: "factory" as ModeName, stage: "map", agent: "explore", outputContract: "explore.v1", modelRouting: { enabled: false, modelByClass: { cheap_scout: "scout-model" } } } },
|
|
345
|
+
{ name: "routing_applies_when_enabled", input: { runId: "route-enabled", mode: "factory" as ModeName, stage: "validate", agent: "oracle-merge", outputContract: "oracle-merge.v1", modelRouting: { enabled: true, modelByClass: { strong_oracle: "oracle-model" } } } },
|
|
346
|
+
{ name: "routing_high_context_class", input: { runId: "route-high-context", mode: "factory" as ModeName, stage: "reduce", agent: "synthesis", outputContract: "synthesis.v1", modelRouting: { enabled: true, contextTokens: 150_000, modelByClass: { high_context: "long-context-model" } } } },
|
|
347
|
+
];
|
|
348
|
+
const dispatchGateScenarios = dispatchGateInputs.map((scenario) => {
|
|
349
|
+
const route = evaluateModelRoutingDispatchGate(scenario.input);
|
|
350
|
+
return {
|
|
351
|
+
name: scenario.name,
|
|
352
|
+
inputHash: sha256(JSON.stringify(scenario.input)),
|
|
353
|
+
liveRoutingEnabled: route.liveRoutingEnabled,
|
|
354
|
+
modelRouterUsed: route.modelRouterUsed,
|
|
355
|
+
routingApplied: route.routingApplied,
|
|
356
|
+
selectedModelClass: route.selectedModelClass,
|
|
357
|
+
selectedModelHash: route.selectedModelHash,
|
|
358
|
+
selectedModelStored: route.selectedModelStored,
|
|
359
|
+
childDispatchAllowed: route.childDispatchAllowed,
|
|
360
|
+
noExecution: route.noExecution,
|
|
361
|
+
bodyStored: route.bodyStored,
|
|
362
|
+
promptBodiesStored: route.promptBodiesStored,
|
|
363
|
+
outputBodiesStored: route.outputBodiesStored,
|
|
364
|
+
};
|
|
365
|
+
});
|
|
366
|
+
const routingDefault = dispatchGateScenarios.find((scenario) => scenario.name === "routing_default_disabled");
|
|
367
|
+
const routingEnabled = dispatchGateScenarios.find((scenario) => scenario.name === "routing_applies_when_enabled");
|
|
368
|
+
const routingHighContext = dispatchGateScenarios.find((scenario) => scenario.name === "routing_high_context_class");
|
|
369
|
+
const checks = [
|
|
370
|
+
readinessCheck("dry_run_scenarios_safe", evaluated.every((scenario) => scenario.safetyPassed === true), { scenarioCount: evaluated.length }),
|
|
371
|
+
readinessCheck("model_class_coverage", expectedClasses.every((modelClass) => coveredClasses.includes(modelClass)), { coveredClasses, expectedClasses }),
|
|
372
|
+
readinessCheck("scenario_expectations_match", evaluated.every((scenario) => scenario.matchedExpectation === true), { mismatches: evaluated.filter((scenario) => scenario.matchedExpectation !== true).map((scenario) => scenario.name) }),
|
|
373
|
+
readinessCheck("strict_budget_request_inert", strictBudgetScenario?.budgetWouldExceed === true && strictBudgetScenario.strictRequested === true && strictBudgetScenario.strictEnabled === false && strictBudgetScenario.budgetEnforced === false, { scenario: strictBudgetScenario?.name }),
|
|
374
|
+
readinessCheck("dry_run_live_routing_disabled", evaluated.every((scenario) => scenario.modelRouterUsed === false && scenario.routingApplied === false && scenario.childDispatchAllowed === false && scenario.noExecution === true), { scenarioCount: evaluated.length }),
|
|
375
|
+
readinessCheck("model_config_valid_for_future_live_routing", configValidation.present === true && configValidation.valid === true, { configPath: ".pi/model-routing.json", configHash: configValidation.configHash, errors: configValidation.errors }),
|
|
376
|
+
readinessCheck("live_routing_dispatch_gate_applies_when_enabled", routingEnabled?.liveRoutingEnabled === true && routingEnabled.modelRouterUsed === true && routingEnabled.routingApplied === true && routingEnabled.childDispatchAllowed === true && routingEnabled.selectedModelClass === "strong_oracle" && routingHighContext?.selectedModelClass === "high_context", { enabled: routingEnabled, highContext: routingHighContext }),
|
|
377
|
+
readinessCheck("live_routing_default_disabled", routingDefault?.liveRoutingEnabled === false && routingDefault.modelRouterUsed === false && routingDefault.routingApplied === false && routingDefault.childDispatchAllowed === false, { defaultScenario: routingDefault?.name }),
|
|
378
|
+
readinessCheck("live_routing_integration_implemented", true, { reason: "explicit per-run model-class routing dispatch gate is available for agentic factory child dispatch" }),
|
|
379
|
+
readinessCheck("live_routing_global_default_enabled", false, { reason: "global/default live model routing remains disabled until operator approval and broader autonomy gates are proven" }),
|
|
380
|
+
];
|
|
381
|
+
const failedChecks = checks.filter((check) => check.passed !== true).map((check) => check.name);
|
|
382
|
+
const auditPassed = checks
|
|
383
|
+
.filter((check) => check.name !== "live_routing_global_default_enabled")
|
|
384
|
+
.every((check) => check.passed === true);
|
|
385
|
+
const report = {
|
|
386
|
+
schema: "zob.model-routing-readiness-audit.v1",
|
|
387
|
+
runId: input.run_id,
|
|
388
|
+
auditPassed,
|
|
389
|
+
readiness: failedChecks.length === 0 ? "live_routing_enabled_globally" : "live_routing_gate_available_default_blocked",
|
|
390
|
+
liveRoutingBlocked: failedChecks.length > 0,
|
|
391
|
+
liveRoutingNoShip: true,
|
|
392
|
+
liveRoutingBlockers: [
|
|
393
|
+
"global/default live routing remains disabled",
|
|
394
|
+
"live routing requires explicit per-run model_routing.enabled=true",
|
|
395
|
+
"strict budget gate and oracle review are required before enabling live routing by default",
|
|
396
|
+
...(configValidation.valid === true ? [] : [".pi/model-routing.json is missing or invalid"]),
|
|
397
|
+
"operator approval is required before routing all live dispatch by default",
|
|
398
|
+
],
|
|
399
|
+
checks,
|
|
400
|
+
failedChecks,
|
|
401
|
+
scenarios: evaluated,
|
|
402
|
+
dispatchGateScenarios,
|
|
403
|
+
config: configValidation,
|
|
404
|
+
liveRoutingDispatchGateAvailable: true,
|
|
405
|
+
liveRoutingRequiresExplicitInput: true,
|
|
406
|
+
budgetEnforced: false,
|
|
407
|
+
strictEnabled: false,
|
|
408
|
+
modelRouterUsed: false,
|
|
409
|
+
routingApplied: false,
|
|
410
|
+
childDispatchAllowed: false,
|
|
411
|
+
daemonStarted: false,
|
|
412
|
+
networkAccessed: false,
|
|
413
|
+
noExecution: true,
|
|
414
|
+
bodyStored: false,
|
|
415
|
+
promptBodiesStored: false,
|
|
416
|
+
outputBodiesStored: false,
|
|
417
|
+
generatedAt: new Date().toISOString(),
|
|
418
|
+
};
|
|
419
|
+
if (hasForbiddenBodyKeys(report)) throw new Error("Model routing readiness audit would store forbidden body keys");
|
|
420
|
+
return report;
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
export function writeModelRoutingReadinessAuditReport(repoRoot: string, runId = "model-routing-readiness", input: ModelRoutingReadinessAuditInput = {}): string {
|
|
424
|
+
const dir = join(repoRoot, ".pi", "logs", "model-routing");
|
|
425
|
+
mkdirSync(dir, { recursive: true });
|
|
426
|
+
const outputPath = join(dir, `${safeFileStem(runId)}.json`);
|
|
427
|
+
writeFileSync(outputPath, JSON.stringify(buildModelRoutingReadinessAudit(repoRoot, { ...input, run_id: runId }), null, 2), "utf8");
|
|
428
|
+
return outputPath;
|
|
429
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Scope du dossier
|
|
2
|
+
|
|
3
|
+
- Orchestration plan-only, supervised smoke/read-only, room artifacts et widget readers.
|
|
4
|
+
- Ce dossier ne contient pas de registrations Pi; le runtime expose les tools.
|
|
5
|
+
|
|
6
|
+
# Invariants
|
|
7
|
+
|
|
8
|
+
- `plan_only` ne doit jamais écrire `DONE.sentinel`.
|
|
9
|
+
- `supervised_smoke` ne lance aucun child live.
|
|
10
|
+
- `supervised_readonly` reste parent-owned et read-only.
|
|
11
|
+
- Les plans redacted et mirror `.pi/coms` doivent rester identiques.
|
|
12
|
+
- Préserver noms d'artefacts, statuts et messages d'erreur.
|
|
13
|
+
|
|
14
|
+
# Imports
|
|
15
|
+
|
|
16
|
+
- Peut importer topology, safety, output-contracts, telemetry, child-runner selon besoin.
|
|
17
|
+
- Interdit: importer depuis `index.ts`.
|
|
18
|
+
- Imports relatifs runtime avec suffixe `.js`.
|
|
19
|
+
|
|
20
|
+
# Validation locale
|
|
21
|
+
|
|
22
|
+
- `npm run check -- --pretty false`.
|
|
23
|
+
- `npm run smoke:harness` après toute tranche orchestration.
|