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,520 @@
|
|
|
1
|
+
import { appendFileSync, existsSync, mkdirSync, readFileSync, unlinkSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
|
|
4
|
+
import { resolveComputeProfile } from "../compute-profile.js";
|
|
5
|
+
import { writeFactoryTelemetrySummary } from "../telemetry.js";
|
|
6
|
+
import type { FactoryAdaptiveDispatchGate, FactoryDefinition, FactoryInputManifest, FactoryManifestItem, FactoryRunInput, FactoryRunResult } from "../types.js";
|
|
7
|
+
import { sha256 } from "../utils/hashing.js";
|
|
8
|
+
import { resolveRepoPath, safeFileStem, safeRunId } from "../utils/paths.js";
|
|
9
|
+
import { buildFactoryAgenticPlan, detectCanonicalPatterns } from "./agentic-plan.js";
|
|
10
|
+
import { buildInitialAdaptiveDelegationGovernorState, normalizeAdaptiveDelegationPolicy } from "../orchestration/adaptive-delegation.js";
|
|
11
|
+
import { FACTORY_PHASE_SENTINELS, factoryPhaseSentinelForMode, loadFactoryDefinition, loadFactoryInputManifest, loadFactoryOracleReview, normalizeFactoryAdaptiveDispatchGate, summarizeFactoryOracleReview, validateFactoryRunInputs } from "./validation.js";
|
|
12
|
+
|
|
13
|
+
export function buildAgenticFactoryNoMockFinalGate(input: {
|
|
14
|
+
status: string;
|
|
15
|
+
tasks: number;
|
|
16
|
+
completed: number;
|
|
17
|
+
failed: number;
|
|
18
|
+
liveDispatches: number;
|
|
19
|
+
mockedDispatches: number;
|
|
20
|
+
outputContractsValidated: number;
|
|
21
|
+
childSessionPaths: number;
|
|
22
|
+
phaseSentinelWritten: boolean;
|
|
23
|
+
doneSentinelWritten: boolean;
|
|
24
|
+
}): { noMockReady: boolean; finalGate: Record<string, unknown> } {
|
|
25
|
+
const noMockReady = input.status === "passed"
|
|
26
|
+
&& input.tasks > 0
|
|
27
|
+
&& input.completed === input.tasks
|
|
28
|
+
&& input.failed === 0
|
|
29
|
+
&& input.liveDispatches === input.tasks
|
|
30
|
+
&& input.mockedDispatches === 0
|
|
31
|
+
&& input.outputContractsValidated === input.tasks
|
|
32
|
+
&& input.childSessionPaths === input.liveDispatches
|
|
33
|
+
&& input.phaseSentinelWritten === true
|
|
34
|
+
&& input.doneSentinelWritten === true;
|
|
35
|
+
const reason = noMockReady
|
|
36
|
+
? "all agentic factory stages completed through live_child_pi with output contracts, child sessions, phase sentinel, and DONE sentinel"
|
|
37
|
+
: input.failed > 0
|
|
38
|
+
? "one or more agentic factory stages failed"
|
|
39
|
+
: input.mockedDispatches > 0
|
|
40
|
+
? "mocked agentic factory dispatches were observed"
|
|
41
|
+
: input.liveDispatches !== input.tasks
|
|
42
|
+
? "not all agentic factory stages have live_child_pi evidence"
|
|
43
|
+
: input.outputContractsValidated !== input.tasks
|
|
44
|
+
? "not all agentic factory stage outputs passed output-contract validation"
|
|
45
|
+
: input.childSessionPaths !== input.liveDispatches
|
|
46
|
+
? "live child session paths are missing"
|
|
47
|
+
: !input.phaseSentinelWritten || !input.doneSentinelWritten
|
|
48
|
+
? "agentic factory sentinels are missing"
|
|
49
|
+
: "agentic factory lifecycle is incomplete for no-mock readiness";
|
|
50
|
+
return {
|
|
51
|
+
noMockReady,
|
|
52
|
+
finalGate: {
|
|
53
|
+
schema: "zob.agentic-factory-final-gate.v1",
|
|
54
|
+
status: noMockReady ? "passed_live_no_mock" : "not_ready",
|
|
55
|
+
passed: noMockReady,
|
|
56
|
+
no_ship: !noMockReady,
|
|
57
|
+
reason,
|
|
58
|
+
requiresLiveChildEvidence: true,
|
|
59
|
+
requiresNoMocks: true,
|
|
60
|
+
requiresOutputContracts: true,
|
|
61
|
+
requiresSentinels: true,
|
|
62
|
+
liveDispatches: input.liveDispatches,
|
|
63
|
+
mockedDispatches: input.mockedDispatches,
|
|
64
|
+
outputContractsValidated: input.outputContractsValidated === input.tasks && input.tasks > 0,
|
|
65
|
+
childSessionPaths: input.childSessionPaths,
|
|
66
|
+
phaseSentinelWritten: input.phaseSentinelWritten,
|
|
67
|
+
doneSentinelWritten: input.doneSentinelWritten,
|
|
68
|
+
bodyStored: false,
|
|
69
|
+
promptBodiesStored: false,
|
|
70
|
+
outputBodiesStored: false,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function factoryLedger(runDir: string, entry: Record<string, unknown>): void {
|
|
76
|
+
appendFileSync(join(runDir, "ledger.jsonl"), `${JSON.stringify({ ...entry, timestamp: new Date().toISOString() })}\n`, "utf8");
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const FACTORY_ADAPTIVE_ARTIFACTS = ["adaptive-delegation-policy.json", "delegation-governor-state.json", "delegation-requests.json", "delegation-decisions.json", "delegation-oracle-decisions.json", "delegation-dispatches.json", "adaptive-delegation-summary.md"];
|
|
80
|
+
|
|
81
|
+
function writeFactoryAdaptiveDelegationArtifacts(runDir: string, input: { runId: string; factoryName: string; mode: string; execution: string; originalGoalHash: string; adaptiveDelegation: ReturnType<typeof normalizeAdaptiveDelegationPolicy>; adaptiveFactoryDispatchGate?: FactoryAdaptiveDispatchGate }): string[] {
|
|
82
|
+
const { runId, factoryName, mode, execution, originalGoalHash, adaptiveDelegation, adaptiveFactoryDispatchGate } = input;
|
|
83
|
+
const liveFactoryAdaptiveRequested = adaptiveDelegation.dispatch === true;
|
|
84
|
+
const integration = liveFactoryAdaptiveRequested ? "p8_live_factory_dispatch_blocked_pending_registered_proof" : "p8_advisory_only";
|
|
85
|
+
const governorState = buildInitialAdaptiveDelegationGovernorState({ runId, rootGoalHash: originalGoalHash, policy: adaptiveDelegation });
|
|
86
|
+
writeFileSync(join(runDir, "adaptive-delegation-policy.json"), JSON.stringify(adaptiveDelegation, null, 2), "utf8");
|
|
87
|
+
writeFileSync(join(runDir, "delegation-governor-state.json"), JSON.stringify(governorState, null, 2), "utf8");
|
|
88
|
+
writeFileSync(join(runDir, "delegation-requests.json"), JSON.stringify({ schema: "zob.delegation-request-set.v1", runId, mode: adaptiveDelegation.mode, dispatch: adaptiveDelegation.dispatch, requests: [], extractionErrors: [], bodyStored: false, promptBodiesStored: false, outputBodiesStored: false }, null, 2), "utf8");
|
|
89
|
+
writeFileSync(join(runDir, "delegation-decisions.json"), JSON.stringify({ schema: "zob.governor-decision-set.v1", runId, decisions: [], bodyStored: false, promptBodiesStored: false, outputBodiesStored: false }, null, 2), "utf8");
|
|
90
|
+
writeFileSync(join(runDir, "delegation-oracle-decisions.json"), JSON.stringify({ schema: "zob.delegation-oracle-decision-set.v1", runId, oracleRequired: 0, oracleDispatchesExecuted: 0, oracleDispatchesCompleted: 0, oracleDispatchesFailed: 0, oracleDispatchesMocked: 0, oracleLiveChildPiDispatches: 0, oraclePasses: 0, oracleWarns: 0, oracleFails: 0, decisions: [], liveOracleDispatched: false, bodyStored: false, promptBodiesStored: false, outputBodiesStored: false }, null, 2), "utf8");
|
|
91
|
+
writeFileSync(join(runDir, "delegation-dispatches.json"), JSON.stringify({ schema: "zob.parent-dispatch-contract-set.v1", runId, dispatches: [], dispatchContractsQueued: 0, liveDispatches: 0, completed: 0, failed: 0, mockedDispatches: 0, liveChildPiDispatches: 0, adaptiveLiveDispatchEnabled: false, requestedLiveFactoryAdaptiveDispatch: liveFactoryAdaptiveRequested, reason: liveFactoryAdaptiveRequested ? "factory adaptive live dispatch requested but blocked pending registered proof activation" : "factory adaptive delegation P8 is advisory-only; no live adaptive dispatch is enabled", bodyStored: false, promptBodiesStored: false, outputBodiesStored: false }, null, 2), "utf8");
|
|
92
|
+
const artifacts = [...FACTORY_ADAPTIVE_ARTIFACTS];
|
|
93
|
+
if (adaptiveFactoryDispatchGate) {
|
|
94
|
+
writeFileSync(join(runDir, "factory-adaptive-dispatch-gate.json"), JSON.stringify(adaptiveFactoryDispatchGate, null, 2), "utf8");
|
|
95
|
+
artifacts.push("factory-adaptive-dispatch-gate.json");
|
|
96
|
+
}
|
|
97
|
+
writeFileSync(join(runDir, "adaptive-delegation-summary.md"), [`# Factory Adaptive Delegation Summary`, ``, `- runId: ${runId}`, `- factory: ${factoryName}`, `- mode: ${mode}`, `- execution: ${execution}`, `- enabled: ${adaptiveDelegation.enabled}`, `- adaptive_mode: ${adaptiveDelegation.mode}`, `- dispatch: ${adaptiveDelegation.dispatch}`, `- factory_integration: ${integration}`, `- live_dispatches: 0`, `- live_factory_adaptive_dispatch_enabled: false`, `- sentinel: not written by adaptive delegation`, ``].join("\n"), "utf8");
|
|
98
|
+
return artifacts;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function factoryAdaptiveValidation(input: { adaptiveDelegation: ReturnType<typeof normalizeAdaptiveDelegationPolicy>; artifacts: string[]; adaptiveFactoryDispatchGate?: FactoryAdaptiveDispatchGate }): Record<string, unknown> {
|
|
102
|
+
const { adaptiveDelegation, artifacts, adaptiveFactoryDispatchGate } = input;
|
|
103
|
+
if (!adaptiveDelegation.enabled) return { enabled: false };
|
|
104
|
+
const liveFactoryAdaptiveRequested = adaptiveDelegation.dispatch === true;
|
|
105
|
+
return {
|
|
106
|
+
schema: "zob.factory-adaptive-delegation-validation.v1",
|
|
107
|
+
enabled: true,
|
|
108
|
+
factoryIntegration: liveFactoryAdaptiveRequested ? "p8_live_factory_dispatch_blocked_pending_registered_proof" : "p8_advisory_only",
|
|
109
|
+
mode: adaptiveDelegation.mode,
|
|
110
|
+
dispatch: adaptiveDelegation.dispatch,
|
|
111
|
+
recordDecisionsOnly: adaptiveDelegation.recordDecisionsOnly,
|
|
112
|
+
configuredMaxDepth: adaptiveDelegation.configuredMaxDepth,
|
|
113
|
+
runtimeMaxDepth: adaptiveDelegation.runtimeMaxDepth,
|
|
114
|
+
maxTotalAgents: adaptiveDelegation.maxTotalAgents,
|
|
115
|
+
maxTotalAgentsWithOracle: adaptiveDelegation.maxTotalAgentsWithOracle,
|
|
116
|
+
parentOwnedDispatch: true,
|
|
117
|
+
childDirectDispatch: false,
|
|
118
|
+
requests: 0,
|
|
119
|
+
decisions: 0,
|
|
120
|
+
dispatchContractsQueued: 0,
|
|
121
|
+
adaptiveDispatchesExecuted: 0,
|
|
122
|
+
adaptiveOracleDispatchesExecuted: 0,
|
|
123
|
+
liveDispatches: 0,
|
|
124
|
+
liveOracleDispatches: 0,
|
|
125
|
+
advisoryOnly: !liveFactoryAdaptiveRequested,
|
|
126
|
+
requestedLiveFactoryAdaptiveDispatch: liveFactoryAdaptiveRequested,
|
|
127
|
+
adaptiveLiveDispatchEnabled: false,
|
|
128
|
+
liveFactoryAdaptiveDispatchEnabled: false,
|
|
129
|
+
activationGatePresent: adaptiveFactoryDispatchGate?.enabled === true,
|
|
130
|
+
adaptiveFactoryDispatchGate,
|
|
131
|
+
artifacts,
|
|
132
|
+
noExecution: true,
|
|
133
|
+
bodyStored: false,
|
|
134
|
+
promptBodiesStored: false,
|
|
135
|
+
outputBodiesStored: false,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function evaluateFactoryRequiredStages(
|
|
140
|
+
definition: FactoryDefinition,
|
|
141
|
+
runDir: string,
|
|
142
|
+
selectedItems: FactoryManifestItem[],
|
|
143
|
+
failed: number,
|
|
144
|
+
agenticPlanPresent: boolean,
|
|
145
|
+
checkpointsPresent: boolean,
|
|
146
|
+
outputsPresent: boolean,
|
|
147
|
+
validationWillBeWritten: boolean,
|
|
148
|
+
sentinelWillBeWritten: boolean,
|
|
149
|
+
): Array<{ stage: string; present: boolean; evidence: string }> {
|
|
150
|
+
const checks: Record<string, { present: boolean; evidence: string }> = {
|
|
151
|
+
initialized: { present: existsSync(join(runDir, "manifest.json")) && existsSync(join(runDir, "ledger.jsonl")), evidence: "manifest.json and ledger.jsonl" },
|
|
152
|
+
manifest_loaded: { present: existsSync(join(runDir, "manifest.json")), evidence: "manifest.json" },
|
|
153
|
+
agentic_plan_written: { present: agenticPlanPresent, evidence: "agentic-plan.json" },
|
|
154
|
+
item_processed: { present: selectedItems.length > 0 && failed === 0 && checkpointsPresent && outputsPresent, evidence: "outputs/*.json and checkpoints/*.checkpoint.json" },
|
|
155
|
+
patterns_canonicalized: { present: existsSync(join(runDir, "patterns.canonical.json")), evidence: "patterns.canonical.json" },
|
|
156
|
+
risks_canonicalized: { present: existsSync(join(runDir, "risks.canonical.json")), evidence: "risks.canonical.json" },
|
|
157
|
+
workflow_rules_written: { present: existsSync(join(runDir, "workflow-rules.md")), evidence: "workflow-rules.md" },
|
|
158
|
+
agent_instructions_written: { present: existsSync(join(runDir, "agent-instructions.md")), evidence: "agent-instructions.md" },
|
|
159
|
+
quality_gates_written: { present: existsSync(join(runDir, "quality-gates.json")), evidence: "quality-gates.json" },
|
|
160
|
+
dashboard_summary_written: { present: existsSync(join(runDir, "dashboard-summary.md")), evidence: "dashboard-summary.md" },
|
|
161
|
+
validation: { present: validationWillBeWritten, evidence: "validation.json" },
|
|
162
|
+
phase_sentinel: { present: sentinelWillBeWritten || Object.values(FACTORY_PHASE_SENTINELS).some((artifact) => existsSync(join(runDir, artifact))), evidence: "SMOKE_PASSED.sentinel/PILOT_PASSED.sentinel/BATCH_PASSED.sentinel" },
|
|
163
|
+
sentinel: { present: sentinelWillBeWritten || existsSync(join(runDir, "DONE.sentinel")), evidence: "DONE.sentinel" },
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
return (definition.requiredStages ?? []).map((stage) => ({ stage, ...(checks[stage] ?? { present: false, evidence: "unknown required stage" }) }));
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function runFactoryRun(repoRoot: string, input: FactoryRunInput): FactoryRunResult {
|
|
170
|
+
const startedAtMs = Date.now();
|
|
171
|
+
const startedAt = new Date(startedAtMs).toISOString();
|
|
172
|
+
const errors = validateFactoryRunInputs(repoRoot, input);
|
|
173
|
+
const runId = safeRunId(input.run_id, "factory");
|
|
174
|
+
const runDir = join(repoRoot, "reports", "factory-runs", runId);
|
|
175
|
+
if (existsSync(runDir) && !input.resume) errors.push(`Run directory already exists. Use resume=true or choose another run_id: ${runDir}`);
|
|
176
|
+
if (errors.length > 0) {
|
|
177
|
+
const endedAtMs = Date.now();
|
|
178
|
+
writeFactoryTelemetrySummary(repoRoot, {
|
|
179
|
+
runId,
|
|
180
|
+
factory: input.factory,
|
|
181
|
+
mode: input.mode ?? "unknown",
|
|
182
|
+
execution: input.execution ?? "deterministic",
|
|
183
|
+
status: "failed_preflight",
|
|
184
|
+
itemCount: 0,
|
|
185
|
+
processed: 0,
|
|
186
|
+
failed: 0,
|
|
187
|
+
expectedArtifacts: [],
|
|
188
|
+
generatedArtifacts: [],
|
|
189
|
+
stageCount: 0,
|
|
190
|
+
agenticTasks: 0,
|
|
191
|
+
failuresByStage: { preflight: errors.length },
|
|
192
|
+
retryCount: 0,
|
|
193
|
+
wallTimeMs: endedAtMs - startedAtMs,
|
|
194
|
+
startedAt,
|
|
195
|
+
endedAt: new Date(endedAtMs).toISOString(),
|
|
196
|
+
errors,
|
|
197
|
+
});
|
|
198
|
+
return { runId, runDir, status: "failed_preflight", processed: 0, failed: 0, artifacts: [], errors };
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const factory = loadFactoryDefinition(repoRoot, input.factory).definition as FactoryDefinition;
|
|
202
|
+
const manifestResult = loadFactoryInputManifest(repoRoot, input.input_manifest);
|
|
203
|
+
const manifest = manifestResult.manifest as FactoryInputManifest;
|
|
204
|
+
const mode = input.mode ?? factory.defaultMode ?? "smoke";
|
|
205
|
+
const execution = input.execution ?? "deterministic";
|
|
206
|
+
const adaptiveDelegation = normalizeAdaptiveDelegationPolicy(input.adaptive_delegation);
|
|
207
|
+
const adaptiveFactoryDispatchGate = normalizeFactoryAdaptiveDispatchGate(input.adaptive_factory_dispatch_gate);
|
|
208
|
+
const computeProfile = resolveComputeProfile(repoRoot, {
|
|
209
|
+
runId,
|
|
210
|
+
domain: "factory",
|
|
211
|
+
requestedProfile: input.compute_profile ?? "auto",
|
|
212
|
+
targetPath: input.input_manifest,
|
|
213
|
+
computeCaps: input.compute_caps,
|
|
214
|
+
riskHints: execution === "agentic" ? ["durable"] : [],
|
|
215
|
+
});
|
|
216
|
+
const persistedInput = adaptiveDelegation.enabled || adaptiveFactoryDispatchGate || input.compute_profile || input.compute_caps ? { ...input, adaptive_delegation: adaptiveDelegation, adaptive_factory_dispatch_gate: adaptiveFactoryDispatchGate, compute_profile_resolution: computeProfile } : input;
|
|
217
|
+
const modeLimit = mode === "smoke" ? 1 : mode === "pilot" ? 10 : manifest.items.length;
|
|
218
|
+
const limit = Math.min(input.max_items ?? modeLimit, modeLimit, manifest.items.length);
|
|
219
|
+
const selectedItems = manifest.items.slice(0, limit);
|
|
220
|
+
|
|
221
|
+
const checkpointsDir = join(runDir, "checkpoints");
|
|
222
|
+
const outputsDir = join(runDir, "outputs");
|
|
223
|
+
mkdirSync(checkpointsDir, { recursive: true });
|
|
224
|
+
mkdirSync(outputsDir, { recursive: true });
|
|
225
|
+
const sentinelPath = join(runDir, "DONE.sentinel");
|
|
226
|
+
if (existsSync(sentinelPath)) unlinkSync(sentinelPath);
|
|
227
|
+
for (const phaseSentinel of Object.values(FACTORY_PHASE_SENTINELS)) {
|
|
228
|
+
const phasePath = join(runDir, phaseSentinel);
|
|
229
|
+
if (existsSync(phasePath)) unlinkSync(phasePath);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
const expectedArtifacts = manifest.expectedArtifacts ?? factory.expectedArtifacts ?? [
|
|
233
|
+
"patterns.canonical.json",
|
|
234
|
+
"risks.canonical.json",
|
|
235
|
+
"workflow-rules.md",
|
|
236
|
+
"agent-instructions.md",
|
|
237
|
+
"quality-gates.json",
|
|
238
|
+
"dashboard-summary.md",
|
|
239
|
+
];
|
|
240
|
+
|
|
241
|
+
const artifacts: string[] = ["agentic-plan.json", "compute-profile-resolution.json"];
|
|
242
|
+
const patternCounts = new Map<string, number>();
|
|
243
|
+
const riskCounts = new Map<string, number>();
|
|
244
|
+
let failed = 0;
|
|
245
|
+
const promotionRequiresOracle = (mode === "pilot" || mode === "batch") && execution !== "plan_only";
|
|
246
|
+
const oracleReview = promotionRequiresOracle ? loadFactoryOracleReview(repoRoot, input.oracle_review_path).review : undefined;
|
|
247
|
+
const oracleReviewSummary = summarizeFactoryOracleReview(oracleReview);
|
|
248
|
+
const legacyOracleGate = input.oracle_gate ? {
|
|
249
|
+
verdict: input.oracle_gate.verdict,
|
|
250
|
+
no_ship: input.oracle_gate.no_ship,
|
|
251
|
+
evidence: input.oracle_gate.evidence,
|
|
252
|
+
reviewer: input.oracle_gate.reviewer ?? "unspecified",
|
|
253
|
+
} : undefined;
|
|
254
|
+
const pilotGate = mode === "pilot" && execution !== "plan_only" ? {
|
|
255
|
+
required: true,
|
|
256
|
+
passed: true,
|
|
257
|
+
smokeRunId: input.prerequisite_smoke_run_id,
|
|
258
|
+
oracleReviewPath: input.oracle_review_path,
|
|
259
|
+
oracleReview: oracleReviewSummary,
|
|
260
|
+
...(legacyOracleGate ? { oracleGate: legacyOracleGate } : {}),
|
|
261
|
+
} : undefined;
|
|
262
|
+
const batchGate = mode === "batch" && execution !== "plan_only" ? {
|
|
263
|
+
required: true,
|
|
264
|
+
passed: true,
|
|
265
|
+
pilotRunId: input.prerequisite_pilot_run_id,
|
|
266
|
+
oracleReviewPath: input.oracle_review_path,
|
|
267
|
+
oracleReview: oracleReviewSummary,
|
|
268
|
+
concurrencyCap: input.batch_concurrency,
|
|
269
|
+
...(legacyOracleGate ? { oracleGate: legacyOracleGate } : {}),
|
|
270
|
+
} : undefined;
|
|
271
|
+
|
|
272
|
+
writeFileSync(join(runDir, "manifest.json"), JSON.stringify({ factory, input: persistedInput, inputManifest: manifest, mode, execution, limit, sourceManifestPath: manifestResult.manifestPath, computeProfile, ...(pilotGate ? { pilotGate } : {}), ...(batchGate ? { batchGate } : {}) }, null, 2), "utf8");
|
|
273
|
+
writeFileSync(join(runDir, "compute-profile-resolution.json"), JSON.stringify(computeProfile, null, 2), "utf8");
|
|
274
|
+
const agenticPlan = buildFactoryAgenticPlan(repoRoot, factory, manifest, selectedItems, { runId, runDir, mode, checkpointsDir, outputsDir });
|
|
275
|
+
writeFileSync(join(runDir, "agentic-plan.json"), JSON.stringify(agenticPlan, null, 2), "utf8");
|
|
276
|
+
const adaptiveArtifacts = adaptiveDelegation.enabled ? writeFactoryAdaptiveDelegationArtifacts(runDir, { runId, factoryName: factory.name, mode, execution, originalGoalHash: sha256(`${factory.name}:${manifest.description ?? input.input_manifest}`), adaptiveDelegation, adaptiveFactoryDispatchGate }) : [];
|
|
277
|
+
artifacts.push(...adaptiveArtifacts);
|
|
278
|
+
factoryLedger(runDir, { event: "initialized", runId, factory: factory.name, mode, execution });
|
|
279
|
+
factoryLedger(runDir, { event: "manifest_loaded", items: manifest.items.length, selectedItems: selectedItems.length });
|
|
280
|
+
factoryLedger(runDir, { event: "agentic_plan_written", tasks: agenticPlan.tasks.length, stages: agenticPlan.stageCount });
|
|
281
|
+
if (adaptiveDelegation.enabled) factoryLedger(runDir, { event: "factory_adaptive_delegation_policy_written", artifacts: adaptiveArtifacts, dispatch: adaptiveDelegation.dispatch, liveDispatches: 0, sentinel: "not written" });
|
|
282
|
+
if (pilotGate) factoryLedger(runDir, { event: "pilot_gate_passed", smokeRunId: pilotGate.smokeRunId, oracleReviewPath: pilotGate.oracleReviewPath, oracleVerdict: oracleReview?.verdict, noShip: oracleReview?.no_ship, reviewer: oracleReview?.reviewer ?? "unspecified" });
|
|
283
|
+
if (batchGate) factoryLedger(runDir, { event: "batch_gate_passed", pilotRunId: batchGate.pilotRunId, oracleReviewPath: batchGate.oracleReviewPath, oracleVerdict: oracleReview?.verdict, noShip: oracleReview?.no_ship, reviewer: oracleReview?.reviewer ?? "unspecified", concurrencyCap: batchGate.concurrencyCap });
|
|
284
|
+
|
|
285
|
+
if (execution === "plan_only") {
|
|
286
|
+
writeFileSync(join(runDir, "final-report.md"), [`# Factory Run Report`, ``, `- runId: ${runId}`, `- factory: ${factory.name}`, `- status: planned`, `- execution: plan_only`, `- planned_tasks: ${agenticPlan.tasks.length}`, `- sentinel: not written`, ``].join("\n"), "utf8");
|
|
287
|
+
const validation = {
|
|
288
|
+
runId,
|
|
289
|
+
factory: factory.name,
|
|
290
|
+
mode,
|
|
291
|
+
execution,
|
|
292
|
+
processed: 0,
|
|
293
|
+
failed: 0,
|
|
294
|
+
expectedArtifacts,
|
|
295
|
+
artifactsPresent: expectedArtifacts.map((artifact) => ({ artifact, exists: false })),
|
|
296
|
+
completionArtifactsPresent: ["manifest.json", "ledger.jsonl", "agentic-plan.json", "final-report.md"].map((artifact) => ({ artifact, exists: existsSync(join(runDir, artifact)) })),
|
|
297
|
+
agenticPlan: { exists: existsSync(join(runDir, "agentic-plan.json")), tasks: agenticPlan.tasks.length, stages: agenticPlan.stageCount },
|
|
298
|
+
computeProfile,
|
|
299
|
+
adaptiveDelegation: factoryAdaptiveValidation({ adaptiveDelegation, artifacts: adaptiveArtifacts, adaptiveFactoryDispatchGate }),
|
|
300
|
+
requiredStagesPresent: evaluateFactoryRequiredStages(factory, runDir, selectedItems, 0, existsSync(join(runDir, "agentic-plan.json")), false, false, true, false),
|
|
301
|
+
checkpointsPresent: false,
|
|
302
|
+
outputsPresent: false,
|
|
303
|
+
status: "planned",
|
|
304
|
+
};
|
|
305
|
+
writeFileSync(join(runDir, "validation.json"), JSON.stringify(validation, null, 2), "utf8");
|
|
306
|
+
const plannedArtifacts = ["agentic-plan.json", "compute-profile-resolution.json", ...adaptiveArtifacts, "final-report.md", "validation.json"];
|
|
307
|
+
const endedAtMs = Date.now();
|
|
308
|
+
writeFactoryTelemetrySummary(repoRoot, {
|
|
309
|
+
runId,
|
|
310
|
+
runDir,
|
|
311
|
+
factory: factory.name,
|
|
312
|
+
mode,
|
|
313
|
+
execution,
|
|
314
|
+
status: "planned",
|
|
315
|
+
itemCount: selectedItems.length,
|
|
316
|
+
processed: 0,
|
|
317
|
+
failed: 0,
|
|
318
|
+
expectedArtifacts,
|
|
319
|
+
generatedArtifacts: plannedArtifacts,
|
|
320
|
+
stageCount: factory.stages?.length ?? 0,
|
|
321
|
+
agenticTasks: agenticPlan.tasks.length,
|
|
322
|
+
failuresByStage: {},
|
|
323
|
+
retryCount: 0,
|
|
324
|
+
wallTimeMs: endedAtMs - startedAtMs,
|
|
325
|
+
startedAt,
|
|
326
|
+
endedAt: new Date(endedAtMs).toISOString(),
|
|
327
|
+
errors: [],
|
|
328
|
+
});
|
|
329
|
+
plannedArtifacts.push("telemetry.json");
|
|
330
|
+
factoryLedger(runDir, { event: "planned", tasks: agenticPlan.tasks.length, sentinel: "not written" });
|
|
331
|
+
return { runId, runDir, status: "planned", processed: 0, failed: 0, artifacts: plannedArtifacts, errors: [] };
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
for (const item of selectedItems) {
|
|
335
|
+
const resolved = resolveRepoPath(repoRoot, item.path);
|
|
336
|
+
const itemOutputPath = join(outputsDir, `${safeFileStem(item.id)}.json`);
|
|
337
|
+
if (resolved.errors.length > 0 || !existsSync(resolved.path)) {
|
|
338
|
+
failed += 1;
|
|
339
|
+
const output = { id: item.id, path: item.path, status: "failed", errors: [...resolved.errors, existsSync(resolved.path) ? undefined : "input file not found"].filter(Boolean) };
|
|
340
|
+
writeFileSync(itemOutputPath, JSON.stringify(output, null, 2), "utf8");
|
|
341
|
+
factoryLedger(runDir, { event: "item_failed", id: item.id, path: item.path, errors: output.errors });
|
|
342
|
+
continue;
|
|
343
|
+
}
|
|
344
|
+
const text = readFileSync(resolved.path, "utf8");
|
|
345
|
+
const fingerprint = sha256(text);
|
|
346
|
+
const detectedPatterns = detectCanonicalPatterns(text);
|
|
347
|
+
for (const pattern of detectedPatterns) {
|
|
348
|
+
patternCounts.set(pattern, (patternCounts.get(pattern) ?? 0) + 1);
|
|
349
|
+
if (pattern.startsWith("failure.")) riskCounts.set(pattern, (riskCounts.get(pattern) ?? 0) + 1);
|
|
350
|
+
}
|
|
351
|
+
const output = { id: item.id, path: item.path, status: "done", fingerprint, detectedPatterns, bytes: Buffer.byteLength(text, "utf8") };
|
|
352
|
+
writeFileSync(itemOutputPath, JSON.stringify(output, null, 2), "utf8");
|
|
353
|
+
writeFileSync(join(checkpointsDir, `${safeFileStem(item.id)}.checkpoint.json`), JSON.stringify({ id: item.id, status: "done", output: itemOutputPath, fingerprint }, null, 2), "utf8");
|
|
354
|
+
factoryLedger(runDir, { event: "item_processed", id: item.id, path: item.path, detectedPatterns, fingerprint });
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
const patterns = [...patternCounts.entries()].map(([id, count]) => ({ id, count })).sort((left, right) => right.count - left.count || left.id.localeCompare(right.id));
|
|
358
|
+
const risks = [...riskCounts.entries()].map(([id, count]) => ({ id, count })).sort((left, right) => right.count - left.count || left.id.localeCompare(right.id));
|
|
359
|
+
|
|
360
|
+
const isFactoryForge = factory.name === "factory-forge";
|
|
361
|
+
const generatedFactoryName = isFactoryForge ? safeFileStem(String(selectedItems[0]?.metadata?.generatedName ?? "generated-smoke-factory")) : undefined;
|
|
362
|
+
const quarantineRelativePath = generatedFactoryName ? `quarantine/${generatedFactoryName}` : undefined;
|
|
363
|
+
const quarantineDir = generatedFactoryName ? join(runDir, "quarantine", generatedFactoryName) : undefined;
|
|
364
|
+
const factoryForgeMetadata = isFactoryForge && generatedFactoryName && quarantineDir ? {
|
|
365
|
+
status: "quarantined",
|
|
366
|
+
generatedName: generatedFactoryName,
|
|
367
|
+
quarantineStatus: "quarantined",
|
|
368
|
+
quarantinePath: quarantineRelativePath,
|
|
369
|
+
generatedFactoryRegistered: false,
|
|
370
|
+
autoActivation: false,
|
|
371
|
+
manualActivationRequired: true,
|
|
372
|
+
sentinelScope: "run-validation-only",
|
|
373
|
+
scaffoldArtifacts: [
|
|
374
|
+
`${quarantineRelativePath}/factory.json`,
|
|
375
|
+
`${quarantineRelativePath}/smoke-manifest.json`,
|
|
376
|
+
`${quarantineRelativePath}/README.md`,
|
|
377
|
+
],
|
|
378
|
+
} : undefined;
|
|
379
|
+
|
|
380
|
+
const artifactWriters: Record<string, string> = {
|
|
381
|
+
"patterns.canonical.json": JSON.stringify({ factory: factory.name, runId, patterns }, null, 2),
|
|
382
|
+
"risks.canonical.json": JSON.stringify({ factory: factory.name, runId, risks }, null, 2),
|
|
383
|
+
"workflow-rules.md": [`# Workflow Rules`, ``, ...patterns.map((pattern) => `- ${pattern.id}: observed ${pattern.count} time(s).`), ``].join("\n"),
|
|
384
|
+
"agent-instructions.md": [`# Agent Instructions`, ``, `Use six-part contracts, evidence, oracle reviews, sentinels, and bounded scope for factory-generated work.`, ``].join("\n"),
|
|
385
|
+
"quality-gates.json": JSON.stringify({ factory: factory.name, runId, gates: ["contract_valid", "output_contract_valid", "evidence_present", "sentinel_present"], mode }, null, 2),
|
|
386
|
+
"dashboard-summary.md": [`# Factory Dashboard Summary`, ``, `- runId: ${runId}`, `- factory: ${factory.name}`, `- mode: ${mode}`, `- processed: ${selectedItems.length - failed}`, `- failed: ${failed}`, `- patterns: ${patterns.length}`, ``].join("\n"),
|
|
387
|
+
"factory-forge-summary.json": JSON.stringify({ factory: factory.name, runId, status: "generated", quarantine: factoryForgeMetadata }, null, 2),
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
for (const artifact of expectedArtifacts) {
|
|
391
|
+
const content = artifactWriters[artifact] ?? JSON.stringify({ artifact, factory: factory.name, runId, status: "generated" }, null, 2);
|
|
392
|
+
writeFileSync(join(runDir, artifact), content, "utf8");
|
|
393
|
+
artifacts.push(artifact);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
if (factoryForgeMetadata && quarantineDir) {
|
|
397
|
+
mkdirSync(quarantineDir, { recursive: true });
|
|
398
|
+
writeFileSync(join(quarantineDir, "factory.json"), JSON.stringify({
|
|
399
|
+
name: generatedFactoryName,
|
|
400
|
+
version: "0.0.0-quarantined",
|
|
401
|
+
status: "quarantined",
|
|
402
|
+
autoActivation: false,
|
|
403
|
+
manualActivationRequired: true,
|
|
404
|
+
description: "Quarantined deterministic scaffold generated by factory-forge smoke run. Manual review and activation required.",
|
|
405
|
+
defaultMode: "smoke",
|
|
406
|
+
requiredStages: ["manifest_loaded", "agentic_plan_written", "item_processed", "validation", "sentinel"],
|
|
407
|
+
expectedArtifacts: ["README.md"],
|
|
408
|
+
stages: [],
|
|
409
|
+
}, null, 2), "utf8");
|
|
410
|
+
writeFileSync(join(quarantineDir, "smoke-manifest.json"), JSON.stringify({
|
|
411
|
+
factory: generatedFactoryName,
|
|
412
|
+
description: "Quarantined smoke manifest scaffold. Not registered under .pi/factories.",
|
|
413
|
+
items: [{ id: "activated-readme", path: `.pi/factories/${generatedFactoryName}/README.md` }],
|
|
414
|
+
expectedArtifacts: ["README.md"],
|
|
415
|
+
}, null, 2), "utf8");
|
|
416
|
+
writeFileSync(join(quarantineDir, "README.md"), [`# ${generatedFactoryName}`, ``, `Status: quarantined`, `Auto-activation: false`, `Manual activation required: true`, `Sentinel scope: run-validation-only`, ``].join("\n"), "utf8");
|
|
417
|
+
artifacts.push(...factoryForgeMetadata.scaffoldArtifacts);
|
|
418
|
+
factoryLedger(runDir, { event: "factory_forge_scaffold_quarantined", generatedName: generatedFactoryName, quarantinePath: quarantineRelativePath, autoActivation: false });
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
const expectedArtifactsPresent = expectedArtifacts.every((artifact) => existsSync(join(runDir, artifact)));
|
|
422
|
+
const checkpointsPresent = selectedItems.every((item) => existsSync(join(checkpointsDir, `${safeFileStem(item.id)}.checkpoint.json`)));
|
|
423
|
+
const outputsPresent = selectedItems.every((item) => existsSync(join(outputsDir, `${safeFileStem(item.id)}.json`)));
|
|
424
|
+
const agenticPlanPresent = existsSync(join(runDir, "agentic-plan.json"));
|
|
425
|
+
const baseLocalValidationPassed = failed === 0 && expectedArtifactsPresent && checkpointsPresent && outputsPresent && agenticPlanPresent;
|
|
426
|
+
const preliminaryValidationStatus = baseLocalValidationPassed ? (execution === "deterministic" ? "passed" : "planned") : "failed";
|
|
427
|
+
const requiredStagesPresent = evaluateFactoryRequiredStages(factory, runDir, selectedItems, failed, agenticPlanPresent, checkpointsPresent, outputsPresent, true, preliminaryValidationStatus === "passed");
|
|
428
|
+
const requiredStagesPassed = requiredStagesPresent.every((stage) => stage.present || ((stage.stage === "sentinel" || stage.stage === "phase_sentinel") && execution !== "deterministic"));
|
|
429
|
+
const localValidationPassed = baseLocalValidationPassed && requiredStagesPassed;
|
|
430
|
+
const validationStatus = localValidationPassed ? (execution === "deterministic" ? "passed" : "planned") : "failed";
|
|
431
|
+
const phaseSentinel = factoryPhaseSentinelForMode(mode);
|
|
432
|
+
writeFileSync(join(runDir, "final-report.md"), [`# Factory Run Report`, ``, `- runId: ${runId}`, `- factory: ${factory.name}`, `- status: ${validationStatus}`, `- execution: ${execution}`, `- processed: ${selectedItems.length - failed}`, `- failed: ${failed}`, `- phase_sentinel: ${validationStatus === "passed" ? phaseSentinel : "not written"}`, `- sentinel: ${validationStatus === "passed" ? "DONE.sentinel" : "not written"}`, ``].join("\n"), "utf8");
|
|
433
|
+
artifacts.push("final-report.md");
|
|
434
|
+
const validation = {
|
|
435
|
+
runId,
|
|
436
|
+
factory: factory.name,
|
|
437
|
+
mode,
|
|
438
|
+
execution,
|
|
439
|
+
processed: selectedItems.length - failed,
|
|
440
|
+
failed,
|
|
441
|
+
expectedArtifacts,
|
|
442
|
+
artifactsPresent: expectedArtifacts.map((artifact) => ({ artifact, exists: existsSync(join(runDir, artifact)) })),
|
|
443
|
+
completionArtifactsPresent: ["manifest.json", "ledger.jsonl", "agentic-plan.json", "final-report.md", phaseSentinel, "DONE.sentinel"].map((artifact) => ({ artifact, exists: existsSync(join(runDir, artifact)) })),
|
|
444
|
+
phaseSentinel: { mode, artifact: phaseSentinel, written: false, validationRequired: true },
|
|
445
|
+
sentinelWritten: false,
|
|
446
|
+
agenticPlan: { exists: agenticPlanPresent, tasks: agenticPlan.tasks.length, stages: agenticPlan.stageCount },
|
|
447
|
+
requiredStagesPresent,
|
|
448
|
+
checkpointsPresent,
|
|
449
|
+
outputsPresent,
|
|
450
|
+
...(pilotGate ? { pilotGate } : {}),
|
|
451
|
+
...(batchGate ? { batchGate } : {}),
|
|
452
|
+
...(factoryForgeMetadata ? { factoryForge: factoryForgeMetadata } : {}),
|
|
453
|
+
computeProfile,
|
|
454
|
+
adaptiveDelegation: factoryAdaptiveValidation({ adaptiveDelegation, artifacts: adaptiveArtifacts, adaptiveFactoryDispatchGate }),
|
|
455
|
+
status: validationStatus,
|
|
456
|
+
};
|
|
457
|
+
writeFileSync(join(runDir, "validation.json"), JSON.stringify(validation, null, 2), "utf8");
|
|
458
|
+
artifacts.push("validation.json");
|
|
459
|
+
factoryLedger(runDir, { event: "validation", status: validation.status, failed, artifacts: expectedArtifacts });
|
|
460
|
+
|
|
461
|
+
const writeRunTelemetry = (status: string, telemetryErrors: string[]): void => {
|
|
462
|
+
const failuresByStage: Record<string, number> = {};
|
|
463
|
+
if (failed > 0) failuresByStage.item_processed = failed;
|
|
464
|
+
if (status === "failed_validation") failuresByStage.validation = 1;
|
|
465
|
+
const endedAtMs = Date.now();
|
|
466
|
+
writeFactoryTelemetrySummary(repoRoot, {
|
|
467
|
+
runId,
|
|
468
|
+
runDir,
|
|
469
|
+
factory: factory.name,
|
|
470
|
+
mode,
|
|
471
|
+
execution,
|
|
472
|
+
status,
|
|
473
|
+
itemCount: selectedItems.length,
|
|
474
|
+
processed: validation.processed,
|
|
475
|
+
failed,
|
|
476
|
+
expectedArtifacts,
|
|
477
|
+
generatedArtifacts: [...artifacts],
|
|
478
|
+
stageCount: factory.stages?.length ?? 0,
|
|
479
|
+
agenticTasks: agenticPlan.tasks.length,
|
|
480
|
+
failuresByStage,
|
|
481
|
+
retryCount: 0,
|
|
482
|
+
wallTimeMs: endedAtMs - startedAtMs,
|
|
483
|
+
startedAt,
|
|
484
|
+
endedAt: new Date(endedAtMs).toISOString(),
|
|
485
|
+
errors: telemetryErrors,
|
|
486
|
+
});
|
|
487
|
+
artifacts.push("telemetry.json");
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
if (validation.status === "passed") {
|
|
491
|
+
const phaseSentinelPath = join(runDir, phaseSentinel);
|
|
492
|
+
writeFileSync(phaseSentinelPath, `${mode} passed ${new Date().toISOString()}\n`, "utf8");
|
|
493
|
+
artifacts.push(phaseSentinel);
|
|
494
|
+
factoryLedger(runDir, { event: "phase_sentinel", mode, sentinel: phaseSentinel, after: "validation" });
|
|
495
|
+
writeFileSync(sentinelPath, `done ${new Date().toISOString()}\n`, "utf8");
|
|
496
|
+
artifacts.push("DONE.sentinel");
|
|
497
|
+
const validationWithSentinels = {
|
|
498
|
+
...validation,
|
|
499
|
+
phaseSentinel: { mode, artifact: phaseSentinel, written: true, validationRequired: true },
|
|
500
|
+
sentinelWritten: true,
|
|
501
|
+
completionArtifactsPresent: ["manifest.json", "ledger.jsonl", "agentic-plan.json", "final-report.md", phaseSentinel, "DONE.sentinel"].map((artifact) => ({ artifact, exists: existsSync(join(runDir, artifact)) })),
|
|
502
|
+
};
|
|
503
|
+
writeFileSync(join(runDir, "validation.json"), JSON.stringify(validationWithSentinels, null, 2), "utf8");
|
|
504
|
+
factoryLedger(runDir, { event: "done", sentinel: "DONE.sentinel" });
|
|
505
|
+
writeRunTelemetry("done", []);
|
|
506
|
+
return { runId, runDir, status: "done", processed: validation.processed, failed, artifacts, errors: [] };
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if (validation.status === "planned") {
|
|
510
|
+
factoryLedger(runDir, { event: "planned", sentinel: "not written", execution });
|
|
511
|
+
writeRunTelemetry("planned", []);
|
|
512
|
+
return { runId, runDir, status: "planned", processed: validation.processed, failed, artifacts, errors: [] };
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
factoryLedger(runDir, { event: "failed_validation" });
|
|
516
|
+
writeRunTelemetry("failed_validation", ["Factory validation failed"]);
|
|
517
|
+
return { runId, runDir, status: "failed_validation", processed: validation.processed, failed, artifacts, errors: ["Factory validation failed"] };
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
export { factoryLedger };
|