zob-harness 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/.pi/capabilities/zob-public-runtime-capabilities.json +4 -4
  2. package/.pi/extensions/zob-child-safety/AGENTS.md +12 -0
  3. package/.pi/extensions/zob-child-safety/index.ts +4 -105
  4. package/.pi/extensions/zob-child-safety/src/AGENTS.md +10 -0
  5. package/.pi/extensions/zob-child-safety/src/policy.ts +106 -0
  6. package/.pi/extensions/zob-harness/AGENTS.md +2 -0
  7. package/.pi/extensions/zob-harness/index.ts +94 -94
  8. package/.pi/extensions/zob-harness/src/AGENTS.md +4 -0
  9. package/.pi/extensions/zob-harness/src/core/AGENTS.md +24 -0
  10. package/.pi/extensions/zob-harness/src/{constants.ts → core/constants.ts} +10 -1
  11. package/.pi/extensions/zob-harness/src/core/utils/AGENTS.md +23 -0
  12. package/.pi/extensions/zob-harness/src/{utils → core/utils}/formatting.ts +1 -1
  13. package/.pi/extensions/zob-harness/src/{utils → core/utils}/records.ts +1 -1
  14. package/.pi/extensions/zob-harness/src/{utils → core/utils}/resources.ts +1 -1
  15. package/.pi/extensions/zob-harness/src/domains/AGENTS.md +23 -0
  16. package/.pi/extensions/zob-harness/src/domains/autonomy/AGENTS.md +21 -0
  17. package/.pi/extensions/zob-harness/src/{autonomous-runtime.ts → domains/autonomy/autonomous-runtime.ts} +22 -22
  18. package/.pi/extensions/zob-harness/src/{autonomy-readiness.ts → domains/autonomy/autonomy-readiness.ts} +18 -18
  19. package/.pi/extensions/zob-harness/src/{daemon-policy.ts → domains/autonomy/daemon-policy.ts} +6 -6
  20. package/.pi/extensions/zob-harness/src/{daemon-readiness.ts → domains/autonomy/daemon-readiness.ts} +7 -7
  21. package/.pi/extensions/zob-harness/src/{daemon-runtime.ts → domains/autonomy/daemon-runtime.ts} +2 -2
  22. package/.pi/extensions/zob-harness/src/{full-autonomy-test.ts → domains/autonomy/full-autonomy-test.ts} +4 -4
  23. package/.pi/extensions/zob-harness/src/{interactive-autonomy.ts → domains/autonomy/interactive-autonomy.ts} +2 -2
  24. package/.pi/extensions/zob-harness/src/{compute-profile.ts → domains/compute/compute-profile.ts} +3 -3
  25. package/.pi/extensions/zob-harness/src/{compute-workflow-shape.ts → domains/compute/compute-workflow-shape.ts} +3 -3
  26. package/.pi/extensions/zob-harness/src/domains/coms/AGENTS.md +21 -0
  27. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/envelope.ts +2 -2
  28. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/identity.ts +3 -3
  29. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/ledger-bridge.ts +2 -2
  30. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/local-transport.ts +1 -1
  31. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/policy.ts +3 -3
  32. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/presence.ts +1 -1
  33. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/registry.ts +3 -3
  34. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/response-capture.ts +1 -1
  35. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/transcript-capture.ts +2 -2
  36. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/zpeer-profile.ts +3 -3
  37. package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/zpeer.ts +3 -3
  38. package/.pi/extensions/zob-harness/src/{mission-control.ts → domains/coms/mission-control.ts} +8 -8
  39. package/.pi/extensions/zob-harness/src/{zagents.ts → domains/coms/zagents.ts} +86 -4
  40. package/.pi/extensions/zob-harness/src/domains/context/AGENTS.md +20 -0
  41. package/.pi/extensions/zob-harness/src/{context-gbrain.ts → domains/context/context-gbrain.ts} +4 -4
  42. package/.pi/extensions/zob-harness/src/domains/delegation/AGENTS.md +21 -0
  43. package/.pi/extensions/zob-harness/src/{agents.ts → domains/delegation/agents.ts} +2 -2
  44. package/.pi/extensions/zob-harness/src/{capabilities.ts → domains/delegation/capabilities.ts} +6 -6
  45. package/.pi/extensions/zob-harness/src/{child-runner.ts → domains/delegation/child-runner.ts} +8 -8
  46. package/.pi/extensions/zob-harness/src/{output-contracts.ts → domains/delegation/output-contracts.ts} +1 -1
  47. package/.pi/extensions/zob-harness/src/{prompt-packs.ts → domains/delegation/prompt-packs.ts} +4 -4
  48. package/.pi/extensions/zob-harness/src/domains/factory/AGENTS.md +21 -0
  49. package/.pi/extensions/zob-harness/src/{factory → domains/factory}/agentic-plan.ts +1 -1
  50. package/.pi/extensions/zob-harness/src/{factory-selector.ts → domains/factory/factory-selector.ts} +4 -4
  51. package/.pi/extensions/zob-harness/src/{factory → domains/factory}/quarantine.ts +5 -5
  52. package/.pi/extensions/zob-harness/src/{factory → domains/factory}/run.ts +5 -5
  53. package/.pi/extensions/zob-harness/src/{factory → domains/factory}/validation.ts +10 -10
  54. package/.pi/extensions/zob-harness/src/domains/git/AGENTS.md +20 -0
  55. package/.pi/extensions/zob-harness/src/{git-ops.ts → domains/git/git-ops.ts} +3 -3
  56. package/.pi/extensions/zob-harness/src/domains/goal/AGENTS.md +22 -0
  57. package/.pi/extensions/zob-harness/src/{goal-room.ts → domains/goal/goal-room.ts} +7 -7
  58. package/.pi/extensions/zob-harness/src/{goal-todo-imports.ts → domains/goal/goal-todo-imports.ts} +1 -1
  59. package/.pi/extensions/zob-harness/src/{goal-todo-types.ts → domains/goal/goal-todo-types.ts} +1 -1
  60. package/.pi/extensions/zob-harness/src/{goal-todos.ts → domains/goal/goal-todos.ts} +4 -4
  61. package/.pi/extensions/zob-harness/src/{goal.ts → domains/goal/goal.ts} +1 -1
  62. package/.pi/extensions/zob-harness/src/domains/governance/AGENTS.md +21 -0
  63. package/.pi/extensions/zob-harness/src/{budget-policy.ts → domains/governance/budget-policy.ts} +6 -6
  64. package/.pi/extensions/zob-harness/src/{governed-requests.ts → domains/governance/governed-requests.ts} +7 -7
  65. package/.pi/extensions/zob-harness/src/{launch-apply.ts → domains/governance/launch-apply.ts} +4 -4
  66. package/.pi/extensions/zob-harness/src/{merge-queue.ts → domains/governance/merge-queue.ts} +6 -6
  67. package/.pi/extensions/zob-harness/src/{rules.ts → domains/governance/rules.ts} +7 -7
  68. package/.pi/extensions/zob-harness/src/{safety.ts → domains/governance/safety.ts} +3 -3
  69. package/.pi/extensions/zob-harness/src/{sandbox.ts → domains/governance/sandbox.ts} +5 -5
  70. package/.pi/extensions/zob-harness/src/{worker-pool.ts → domains/governance/worker-pool.ts} +7 -7
  71. package/.pi/extensions/zob-harness/src/{workspace-claims.ts → domains/governance/workspace-claims.ts} +6 -6
  72. package/.pi/extensions/zob-harness/src/domains/models/AGENTS.md +20 -0
  73. package/.pi/extensions/zob-harness/src/{model-availability.ts → domains/models/model-availability.ts} +1 -1
  74. package/.pi/extensions/zob-harness/src/{model-routing.ts → domains/models/model-routing.ts} +6 -6
  75. package/.pi/extensions/zob-harness/src/domains/orchestration/AGENTS.md +21 -0
  76. package/.pi/extensions/zob-harness/src/{orchestration → domains/orchestration}/adaptive-delegation.ts +8 -8
  77. package/.pi/extensions/zob-harness/src/{orchestration → domains/orchestration}/adaptive-workflow.ts +4 -4
  78. package/.pi/extensions/zob-harness/src/{orchestration → domains/orchestration}/lead-plan.ts +5 -5
  79. package/.pi/extensions/zob-harness/src/{orchestration → domains/orchestration}/plan.ts +5 -5
  80. package/.pi/extensions/zob-harness/src/{orchestration → domains/orchestration}/room.ts +4 -4
  81. package/.pi/extensions/zob-harness/src/{orchestration → domains/orchestration}/run.ts +6 -6
  82. package/.pi/extensions/zob-harness/src/{orchestration → domains/orchestration}/supervised-readonly.ts +6 -6
  83. package/.pi/extensions/zob-harness/src/{orchestration → domains/orchestration}/widget-readers.ts +2 -2
  84. package/.pi/extensions/zob-harness/src/domains/project-dna/AGENTS.md +19 -0
  85. package/.pi/extensions/zob-harness/src/{project-dna.ts → domains/project-dna/project-dna.ts} +4 -4
  86. package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/candidate.ts +5 -5
  87. package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/coms.ts +3 -3
  88. package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/documentation.ts +4 -4
  89. package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/factory.ts +2 -2
  90. package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/temp-agent.ts +4 -4
  91. package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/write-lane.ts +3 -3
  92. package/.pi/extensions/zob-harness/src/domains/telemetry/AGENTS.md +19 -0
  93. package/.pi/extensions/zob-harness/src/{chronicle.ts → domains/telemetry/chronicle.ts} +3 -3
  94. package/.pi/extensions/zob-harness/src/{queue.ts → domains/telemetry/queue.ts} +7 -7
  95. package/.pi/extensions/zob-harness/src/{telemetry.ts → domains/telemetry/telemetry.ts} +4 -4
  96. package/.pi/extensions/zob-harness/src/{topology → domains/topology}/chains.ts +10 -10
  97. package/.pi/extensions/zob-harness/src/{topology → domains/topology}/coms.ts +3 -3
  98. package/.pi/extensions/zob-harness/src/{topology → domains/topology}/orchestration-profiles.ts +8 -8
  99. package/.pi/extensions/zob-harness/src/{topology → domains/topology}/teams.ts +8 -8
  100. package/.pi/extensions/zob-harness/src/runtime/adaptive-zmode.ts +2 -2
  101. package/.pi/extensions/zob-harness/src/runtime/auto-compaction.ts +2 -2
  102. package/.pi/extensions/zob-harness/src/runtime/commands.ts +49 -27
  103. package/.pi/extensions/zob-harness/src/runtime/compaction-policy.ts +2 -2
  104. package/.pi/extensions/zob-harness/src/runtime/delegation-feed.ts +1 -1
  105. package/.pi/extensions/zob-harness/src/runtime/delegation-monitor.ts +1 -1
  106. package/.pi/extensions/zob-harness/src/runtime/events.ts +52 -37
  107. package/.pi/extensions/zob-harness/src/{goal-runtime.ts → runtime/goal-runtime.ts} +9 -9
  108. package/.pi/extensions/zob-harness/src/runtime/goal-todo-overlay.ts +1 -1
  109. package/.pi/extensions/zob-harness/src/runtime/plan-capture.ts +2 -2
  110. package/.pi/extensions/zob-harness/src/runtime/state.ts +15 -13
  111. package/.pi/extensions/zob-harness/src/runtime/tools-autonomous.ts +2 -2
  112. package/.pi/extensions/zob-harness/src/runtime/tools-compute.ts +3 -3
  113. package/.pi/extensions/zob-harness/src/runtime/tools-coms.ts +15 -12
  114. package/.pi/extensions/zob-harness/src/runtime/tools-context.ts +2 -2
  115. package/.pi/extensions/zob-harness/src/runtime/tools-delegation.ts +13 -13
  116. package/.pi/extensions/zob-harness/src/runtime/tools-factory.ts +19 -19
  117. package/.pi/extensions/zob-harness/src/runtime/tools-goal-room.ts +3 -3
  118. package/.pi/extensions/zob-harness/src/runtime/tools-governed-requests.ts +3 -3
  119. package/.pi/extensions/zob-harness/src/runtime/tools-merge-queue.ts +3 -3
  120. package/.pi/extensions/zob-harness/src/runtime/tools-mission-control.ts +3 -3
  121. package/.pi/extensions/zob-harness/src/runtime/tools-orchestration.ts +9 -9
  122. package/.pi/extensions/zob-harness/src/runtime/tools-project-dna.ts +2 -2
  123. package/.pi/extensions/zob-harness/src/runtime/tools-worker-pool.ts +3 -3
  124. package/.pi/extensions/zob-harness/src/runtime/tools-workspace-claims.ts +3 -3
  125. package/.pi/extensions/zob-harness/src/runtime/tools-zcommit.ts +3 -3
  126. package/.pi/extensions/zob-harness/src/runtime/widget.ts +25 -8
  127. package/.pi/extensions/zob-harness/src/runtime/zobHarness.ts +1 -1
  128. package/.pi/extensions/zob-harness/src/types.ts +2 -2
  129. package/.pi/extensions/zob-switch/AGENTS.md +9 -0
  130. package/.pi/extensions/zob-switch/index.ts +9 -121
  131. package/.pi/extensions/zob-switch/src/AGENTS.md +8 -0
  132. package/.pi/extensions/zob-switch/src/autocomplete.ts +12 -0
  133. package/.pi/extensions/zob-switch/src/paths.ts +8 -0
  134. package/.pi/extensions/zob-switch/src/settings.ts +25 -0
  135. package/.pi/extensions/zob-switch/src/snapshot.ts +34 -0
  136. package/.pi/extensions/zob-switch/src/state.ts +57 -0
  137. package/.pi/factories/agentic-spec-team/README.md +35 -0
  138. package/.pi/factories/agentic-spec-team/batch-manifest.json +11 -0
  139. package/.pi/factories/agentic-spec-team/example-agentic-spec-manifest.json +19 -0
  140. package/.pi/factories/agentic-spec-team/factory.json +98 -0
  141. package/.pi/factories/agentic-spec-team/pilot-manifest.json +11 -0
  142. package/.pi/factories/agentic-spec-team/schemas/final-report.schema.json +15 -0
  143. package/.pi/factories/agentic-spec-team/schemas/manifest.schema.json +14 -0
  144. package/.pi/factories/agentic-spec-team/schemas/question.schema.json +18 -0
  145. package/.pi/factories/agentic-spec-team/schemas/source-register.schema.json +11 -0
  146. package/.pi/factories/agentic-spec-team/schemas/traceability.schema.json +11 -0
  147. package/.pi/factories/agentic-spec-team/smoke-manifest.json +11 -0
  148. package/.pi/skills/zob-agentic-spec-team/SKILL.md +145 -0
  149. package/.pi/skills/zob-split-refactor/SKILL.md +1 -1
  150. package/.pi/skills/zob-zagent-creator/SKILL.md +256 -12
  151. package/.pi/zagents/bdd-writer.json +20 -0
  152. package/.pi/zagents/data-profile-analyst.json +20 -0
  153. package/.pi/zagents/domain-modeler.json +20 -0
  154. package/.pi/zagents/planner-handoff-writer.json +20 -0
  155. package/.pi/zagents/prompts/agentic-spec-run-role.md +30 -0
  156. package/.pi/zagents/source-intake-steward.json +20 -0
  157. package/.pi/zagents/spec-chief.json +21 -0
  158. package/.pi/zagents/spec-oracle.json +20 -0
  159. package/.pi/zagents/spec-writer.json +20 -0
  160. package/.pi/zagents/ux-flow-analyst.json +20 -0
  161. package/.pi/zteams/agentic-spec-run.json +42 -0
  162. package/.pi/zteams/agentic-spec-run.tmux.sh +134 -0
  163. package/SOURCE_INDEX.md +1 -1
  164. package/package.json +9 -1
  165. package/scripts/README.md +1 -1
  166. package/scripts/agentic-spec-team/validate-bdd.mjs +13 -0
  167. package/scripts/agentic-spec-team/validate-final-report.mjs +14 -0
  168. package/scripts/agentic-spec-team/validate-manifest.mjs +14 -0
  169. package/scripts/agentic-spec-team/validate-oracle-ready.mjs +13 -0
  170. package/scripts/agentic-spec-team/validate-question-loop.mjs +15 -0
  171. package/scripts/agentic-spec-team/validate-run.mjs +11 -0
  172. package/scripts/agentic-spec-team/validate-source-register.mjs +17 -0
  173. package/scripts/agentic-spec-team/validate-traceability.mjs +20 -0
  174. package/scripts/agentic-spec-team/validate-workgraph.mjs +13 -0
  175. package/scripts/autonomy/mission-readiness-secret-smoke.mjs +5 -5
  176. package/scripts/git-ops/commit-policy-smoke.mjs +5 -4
  177. package/scripts/goal-todo/child-goal-ref-smoke.mjs +2 -2
  178. package/scripts/path-policy/validate-smoke.mjs +3 -3
  179. package/scripts/project-dna/AGENTS.md +39 -0
  180. package/scripts/project-dna/{validate-scaffold.mjs → validation/validate-scaffold.mjs} +7 -7
  181. package/scripts/spec-run.mjs +365 -0
  182. package/scripts/worker-pool/static-smoke.mjs +5 -5
  183. package/scripts/zagent-static-smoke.mjs +35 -6
  184. package/scripts/zpeer-local-e2e-smoke.mjs +6 -5
  185. package/scripts/zpeer-static-smoke.mjs +17 -17
  186. /package/.pi/extensions/zob-harness/src/{types → core/types}/core.ts +0 -0
  187. /package/.pi/extensions/zob-harness/src/{utils → core/utils}/hashing.ts +0 -0
  188. /package/.pi/extensions/zob-harness/src/{utils → core/utils}/json.ts +0 -0
  189. /package/.pi/extensions/zob-harness/src/{utils → core/utils}/paths.ts +0 -0
  190. /package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/AGENTS.md +0 -0
  191. /package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/pending-replies.ts +0 -0
  192. /package/.pi/extensions/zob-harness/src/{coms-v2 → domains/coms/coms-v2}/types.ts +0 -0
  193. /package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/ledger.ts +0 -0
  194. /package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/types.ts +0 -0
  195. /package/.pi/extensions/zob-harness/src/{promotion → domains/promotion}/validate.ts +0 -0
  196. /package/.pi/extensions/zob-harness/src/{schemas-project-dna.ts → runtime/schemas-project-dna.ts} +0 -0
  197. /package/.pi/extensions/zob-harness/src/{schemas.ts → runtime/schemas.ts} +0 -0
  198. /package/scripts/project-dna/{bench-smoke.mjs → benchmark/bench-smoke.mjs} +0 -0
  199. /package/scripts/project-dna/{build-capsules.mjs → capsules/build-capsules.mjs} +0 -0
  200. /package/scripts/project-dna/{emit-golden-cases.mjs → emit/emit-golden-cases.mjs} +0 -0
  201. /package/scripts/project-dna/{emit-ontology.mjs → emit/emit-ontology.mjs} +0 -0
  202. /package/scripts/project-dna/{oracle-review-smoke.mjs → oracle/oracle-review-smoke.mjs} +0 -0
  203. /package/scripts/project-dna/{query-context.mjs → query/query-context.mjs} +0 -0
  204. /package/scripts/project-dna/{query-steward.mjs → query/query-steward.mjs} +0 -0
  205. /package/scripts/project-dna/{build-sample-spec.mjs → sample/build-sample-spec.mjs} +0 -0
  206. /package/scripts/project-dna/{generate-sample.mjs → sample/generate-sample.mjs} +0 -0
  207. /package/scripts/project-dna/{validate-sample-project.mjs → sample/validate-sample-project.mjs} +0 -0
  208. /package/scripts/project-dna/{scan.mjs → scan/scan.mjs} +0 -0
  209. /package/scripts/project-dna/{validate-scan-artifacts.mjs → scan/validate-scan-artifacts.mjs} +0 -0
  210. /package/scripts/project-dna/{validate-5of5.mjs → validation/validate-5of5.mjs} +0 -0
  211. /package/scripts/project-dna/{validate-golden-cases.mjs → validation/validate-golden-cases.mjs} +0 -0
  212. /package/scripts/project-dna/{validate-ontology.mjs → validation/validate-ontology.mjs} +0 -0
  213. /package/scripts/project-dna/{plan-workflow.mjs → workflow/plan-workflow.mjs} +0 -0
  214. /package/scripts/project-dna/{validate-workflow.mjs → workflow/validate-workflow.mjs} +0 -0
@@ -2,15 +2,15 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSy
2
2
  import { join } from "node:path";
3
3
 
4
4
  import { buildAutonomousRuntimeDryRun, validateAutonomousReadOnlySmokeRunArtifacts, validateAutonomousRuntimeDryRunArtifacts } from "./autonomous-runtime.js";
5
- import { buildCapabilityIndex } from "./capabilities.js";
6
- import { buildContextGbrainReadinessAudit } from "./context-gbrain.js";
7
- import { loadFactoryDefinition, loadFactoryInputManifest, validateFactoryStages } from "./factory/validation.js";
8
- import { validateStrictGoalSpecAnchor } from "./goal.js";
9
- import { validateDelegationWriteScope } from "./safety.js";
10
- import { sha256 } from "./utils/hashing.js";
11
- import { parseJsonFile } from "./utils/json.js";
12
- import { safeFileStem } from "./utils/paths.js";
13
- import { isRecord } from "./utils/records.js";
5
+ import { buildCapabilityIndex } from "../delegation/capabilities.js";
6
+ import { buildContextGbrainReadinessAudit } from "../context/context-gbrain.js";
7
+ import { loadFactoryDefinition, loadFactoryInputManifest, validateFactoryStages } from "../factory/validation.js";
8
+ import { validateStrictGoalSpecAnchor } from "../goal/goal.js";
9
+ import { validateDelegationWriteScope } from "../governance/safety.js";
10
+ import { sha256 } from "../../core/utils/hashing.js";
11
+ import { parseJsonFile } from "../../core/utils/json.js";
12
+ import { safeFileStem } from "../../core/utils/paths.js";
13
+ import { isRecord } from "../../core/utils/records.js";
14
14
 
15
15
  export interface AutonomyReadinessAuditInput {
16
16
  run_id?: string;
@@ -43,16 +43,16 @@ const REGISTERED_FACTORY_SOURCE_FINGERPRINT_BASE_FILES = [
43
43
  ".pi/model-routing.json",
44
44
  ".pi/extensions/zob-harness/index.ts",
45
45
  ".pi/extensions/zob-harness/src/runtime/tools-factory.ts",
46
- ".pi/extensions/zob-harness/src/budget-policy.ts",
47
- ".pi/extensions/zob-harness/src/model-routing.ts",
48
- ".pi/extensions/zob-harness/src/schemas.ts",
46
+ ".pi/extensions/zob-harness/src/domains/governance/budget-policy.ts",
47
+ ".pi/extensions/zob-harness/src/domains/models/model-routing.ts",
48
+ ".pi/extensions/zob-harness/src/runtime/schemas.ts",
49
49
  ".pi/extensions/zob-harness/src/types.ts",
50
- ".pi/extensions/zob-harness/src/telemetry.ts",
51
- ".pi/extensions/zob-harness/src/factory/run.ts",
52
- ".pi/extensions/zob-harness/src/factory/agentic-plan.ts",
53
- ".pi/extensions/zob-harness/src/factory/validation.ts",
54
- ".pi/extensions/zob-harness/src/child-runner.ts",
55
- ".pi/extensions/zob-harness/src/output-contracts.ts",
50
+ ".pi/extensions/zob-harness/src/domains/telemetry/telemetry.ts",
51
+ ".pi/extensions/zob-harness/src/domains/factory/run.ts",
52
+ ".pi/extensions/zob-harness/src/domains/factory/agentic-plan.ts",
53
+ ".pi/extensions/zob-harness/src/domains/factory/validation.ts",
54
+ ".pi/extensions/zob-harness/src/domains/delegation/child-runner.ts",
55
+ ".pi/extensions/zob-harness/src/domains/delegation/output-contracts.ts",
56
56
  ];
57
57
 
58
58
  function uniqueSorted(items: string[]): string[] {
@@ -1,12 +1,12 @@
1
1
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
 
4
- import { READ_ONLY_QUEUE_JOB_TYPES } from "./queue.js";
5
- import type { ChildStopCondition } 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";
4
+ import { READ_ONLY_QUEUE_JOB_TYPES } from "../telemetry/queue.js";
5
+ import type { ChildStopCondition } from "../../types.js";
6
+ import { sha256 } from "../../core/utils/hashing.js";
7
+ import { parseJsonFile } from "../../core/utils/json.js";
8
+ import { safeFileStem } from "../../core/utils/paths.js";
9
+ import { isRecord } from "../../core/utils/records.js";
10
10
 
11
11
  export interface DaemonPolicyReadinessAuditInput {
12
12
  run_id?: string;
@@ -1,14 +1,14 @@
1
1
  import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
 
4
- import { evaluateBudgetPreflightDryRun } from "./chronicle.js";
4
+ import { evaluateBudgetPreflightDryRun } from "../telemetry/chronicle.js";
5
5
  import { validateDaemonPolicyConfig } from "./daemon-policy.js";
6
- import { evaluateModelRoutingDryRun } from "./model-routing.js";
7
- import { buildQueueDashboardSummary, ensureQueueDirs, READ_ONLY_QUEUE_JOB_TYPES, validateReadOnlyQueueJob } from "./queue.js";
8
- import { sha256 } from "./utils/hashing.js";
9
- import { parseJsonFile } from "./utils/json.js";
10
- import { safeFileStem } from "./utils/paths.js";
11
- import { isRecord } from "./utils/records.js";
6
+ import { evaluateModelRoutingDryRun } from "../models/model-routing.js";
7
+ import { buildQueueDashboardSummary, ensureQueueDirs, READ_ONLY_QUEUE_JOB_TYPES, validateReadOnlyQueueJob } from "../telemetry/queue.js";
8
+ import { sha256 } from "../../core/utils/hashing.js";
9
+ import { parseJsonFile } from "../../core/utils/json.js";
10
+ import { safeFileStem } from "../../core/utils/paths.js";
11
+ import { isRecord } from "../../core/utils/records.js";
12
12
 
13
13
  export interface DaemonReadinessDryRunInput {
14
14
  run_id?: string;
@@ -1,6 +1,6 @@
1
1
  import type { InteractiveAutonomyMode, InteractiveLaunchAuthorization, MissionReadinessReport } from "./interactive-autonomy.js";
2
- import type { RuntimeGoal, RuntimeGoalStatus } from "./goal-runtime.js";
3
- import type { GoalTodoNode, GoalTodoState, GoalTodoStatus } from "./goal-todos.js";
2
+ import type { RuntimeGoal, RuntimeGoalStatus } from "../../runtime/goal-runtime.js";
3
+ import type { GoalTodoNode, GoalTodoState, GoalTodoStatus } from "../goal/goal-todos.js";
4
4
 
5
5
  export const DAEMON_RUNTIME_STATUSES = [
6
6
  "off",
@@ -1,10 +1,10 @@
1
1
  import { mkdirSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
 
4
- import { loadFactorySelectorCandidates, selectFactoryForDemands, type FactorySelectorResult } from "./factory-selector.js";
5
- import { buildControlledWorkerPoolPlan, evaluateLaunchAuthorizedApplyGate, type ControlledWorkerPoolPlan, type LaunchAuthorizedApplyGate } from "./launch-apply.js";
6
- import { sha256 } from "./utils/hashing.js";
7
- import { safeFileStem } from "./utils/paths.js";
4
+ import { loadFactorySelectorCandidates, selectFactoryForDemands, type FactorySelectorResult } from "../factory/factory-selector.js";
5
+ import { buildControlledWorkerPoolPlan, evaluateLaunchAuthorizedApplyGate, type ControlledWorkerPoolPlan, type LaunchAuthorizedApplyGate } from "../governance/launch-apply.js";
6
+ import { sha256 } from "../../core/utils/hashing.js";
7
+ import { safeFileStem } from "../../core/utils/paths.js";
8
8
 
9
9
  export interface FullAutonomyTestInput {
10
10
  runId?: string;
@@ -1,8 +1,8 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
 
4
- import { sha256 } from "./utils/hashing.js";
5
- import { isRecord } from "./utils/records.js";
4
+ import { sha256 } from "../../core/utils/hashing.js";
5
+ import { isRecord } from "../../core/utils/records.js";
6
6
 
7
7
  export const INTERACTIVE_AUTONOMY_MODES = ["off", "open", "controlled", "adaptive"] as const;
8
8
  export type InteractiveAutonomyMode = typeof INTERACTIVE_AUTONOMY_MODES[number];
@@ -1,9 +1,9 @@
1
1
  import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
2
2
  import { basename, extname, join, relative, resolve } from "node:path";
3
3
 
4
- import { sha256 } from "./utils/hashing.js";
5
- import { resolveRepoPath, safeFileStem, safeRunId } from "./utils/paths.js";
6
- import { isRecord } from "./utils/records.js";
4
+ import { sha256 } from "../../core/utils/hashing.js";
5
+ import { resolveRepoPath, safeFileStem, safeRunId } from "../../core/utils/paths.js";
6
+ import { isRecord } from "../../core/utils/records.js";
7
7
 
8
8
  export type ComputeRequestedProfile = "auto" | "low" | "medium" | "high" | "xhigh" | "max";
9
9
  export type ComputeEffectiveProfile = Exclude<ComputeRequestedProfile, "auto">;
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from "node:fs";
2
- import { sha256 } from "./utils/hashing.js";
3
- import { resolveRepoPath } from "./utils/paths.js";
4
- import { isRecord } from "./utils/records.js";
2
+ import { sha256 } from "../../core/utils/hashing.js";
3
+ import { resolveRepoPath } from "../../core/utils/paths.js";
4
+ import { isRecord } from "../../core/utils/records.js";
5
5
  import { resolveComputeProfile, type ComputeDomain, type ComputeEffectiveProfile, type ComputePreviewInput, type ComputeRequestedProfile } from "./compute-profile.js";
6
6
 
7
7
  export interface ComputeWorkflowShapeInput extends ComputePreviewInput {
@@ -0,0 +1,21 @@
1
+ # Coms domain guardrail
2
+
3
+ ## Scope
4
+
5
+ - Hash-only/local communication domains, Mission Control metadata, governed request extraction, topology-facing coms helpers, and coms-v2 compatibility.
6
+
7
+ ## MUST DO
8
+
9
+ - Preserve hash-only/body-free ledgers, stale/offline peer blockers, bounded awaits, and topology guards.
10
+ - Keep Goal Room parent-visible as canonical for coordination decisions.
11
+
12
+ ## MUST NOT
13
+
14
+ - Do not persist raw prompts, outputs, rationale, diffs, patches, or message bodies.
15
+ - Do not introduce hidden worker-to-worker direct chat or network transport.
16
+ - Do not import from `index.ts` or `index.js`.
17
+
18
+ ## Validation
19
+
20
+ - `npm run check -- --pretty false`.
21
+ - `npm run smoke:harness` plus coms-specific smoke if coms transport paths move.
@@ -1,5 +1,5 @@
1
- import { sha256 } from "../utils/hashing.js";
2
- import { isRecord } from "../utils/records.js";
1
+ import { sha256 } from "../../../core/utils/hashing.js";
2
+ import { isRecord } from "../../../core/utils/records.js";
3
3
 
4
4
  const FORBIDDEN_PERSISTED_KEYS = new Set(["body", "task", "prompt", "output", "content", "message", "rationale", "text", "diff", "patch"]);
5
5
  const ENVELOPE_TYPES = new Set(["ping", "pong", "prompt", "ack", "response", "error"]);
@@ -1,8 +1,8 @@
1
1
  import { basename } from "node:path";
2
2
 
3
- import type { TeamDefinition, TeamLead, TeamWorker } from "../types.js";
4
- import { sha256 } from "../utils/hashing.js";
5
- import { safeFileStem } from "../utils/paths.js";
3
+ import type { TeamDefinition, TeamLead, TeamWorker } from "../../../types.js";
4
+ import { sha256 } from "../../../core/utils/hashing.js";
5
+ import { safeFileStem } from "../../../core/utils/paths.js";
6
6
  import type { ZobComsV2Policy, ZobLivePeerCard, ZobLiveRoleType } from "./types.js";
7
7
 
8
8
  const PROCESS_STARTED_AT = new Date().toISOString();
@@ -1,5 +1,5 @@
1
- import type { TeamDefinition } from "../types.js";
2
- import { appendZobComsMessage, replyZobComsMessage, transitionZobComsStatus } from "../topology/coms.js";
1
+ import type { TeamDefinition } from "../../../types.js";
2
+ import { appendZobComsMessage, replyZobComsMessage, transitionZobComsStatus } from "../../topology/coms.js";
3
3
  import type { ZobLiveEnvelope } from "./envelope.js";
4
4
 
5
5
  export function appendLiveSendRequestedRef(repoRoot: string, definition: TeamDefinition, envelope: ZobLiveEnvelope): Record<string, unknown> {
@@ -3,7 +3,7 @@ import { tmpdir } from "node:os";
3
3
  import { dirname, join } from "node:path";
4
4
  import { createConnection, createServer, type Server, type Socket } from "node:net";
5
5
 
6
- import { safeFileStem } from "../utils/paths.js";
6
+ import { safeFileStem } from "../../../core/utils/paths.js";
7
7
  import { buildZobLiveErrorEnvelope, parseZobLiveEnvelopeLine, validateZobLiveEnvelope, type ZobLiveEnvelope } from "./envelope.js";
8
8
 
9
9
  export interface ZobLocalTransportServer {
@@ -1,9 +1,9 @@
1
1
  import { join } from "node:path";
2
2
 
3
3
  import type { ZobComsTranscriptMode, ZobComsTranscriptRetentionClass, ZobComsTransportMode, ZobComsV2Policy } from "./types.js";
4
- import { sha256 } from "../utils/hashing.js";
5
- import { readJsonObjectIfPresent } from "../utils/json.js";
6
- import { isRecord } from "../utils/records.js";
4
+ import { sha256 } from "../../../core/utils/hashing.js";
5
+ import { readJsonObjectIfPresent } from "../../../core/utils/json.js";
6
+ import { isRecord } from "../../../core/utils/records.js";
7
7
 
8
8
  const TRANSPORT_POLICY_RELATIVE_PATH = ".pi/mission-control/zob_coms_transport.json";
9
9
  const MODES = new Set<ZobComsTransportMode>(["off", "observe_only", "required_local", "required_network", "break_glass_ledger_only"]);
@@ -1,4 +1,4 @@
1
- import { sha256 } from "../utils/hashing.js";
1
+ import { sha256 } from "../../../core/utils/hashing.js";
2
2
  import { readZobLiveRegistrySnapshot } from "./registry.js";
3
3
  import { readZobComsV2Policy } from "./policy.js";
4
4
  import type { ZobLivePeerCard, ZobLivePresenceSummary } from "./types.js";
@@ -2,9 +2,9 @@ import { existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from
2
2
  import { homedir } from "node:os";
3
3
  import { dirname, join } from "node:path";
4
4
 
5
- import { loadTeamDefinition, validateTeamDefinition } from "../topology/teams.js";
6
- import { isRecord } from "../utils/records.js";
7
- import { safeFileStem } from "../utils/paths.js";
5
+ import { loadTeamDefinition, validateTeamDefinition } from "../../topology/teams.js";
6
+ import { isRecord } from "../../../core/utils/records.js";
7
+ import { safeFileStem } from "../../../core/utils/paths.js";
8
8
  import { buildCurrentZobLivePeerCard, buildZobComsProjectId } from "./identity.js";
9
9
  import { readZobComsV2Policy, zobComsRegistryEnabled } from "./policy.js";
10
10
  import type { ZobLivePeerCard, ZobLivePeerStatus, ZobLiveRegistrySnapshot } from "./types.js";
@@ -1,4 +1,4 @@
1
- import { sha256 } from "../utils/hashing.js";
1
+ import { sha256 } from "../../../core/utils/hashing.js";
2
2
  import { buildZobLiveEnvelope, type ZobLiveEnvelope } from "./envelope.js";
3
3
 
4
4
  export interface ZobLiveResponseCapture {
@@ -2,8 +2,8 @@ import { mkdirSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
 
4
4
  import type { ZobComsTranscriptCapturePolicy } from "./types.js";
5
- import { sha256 } from "../utils/hashing.js";
6
- import { safeFileStem } from "../utils/paths.js";
5
+ import { sha256 } from "../../../core/utils/hashing.js";
6
+ import { safeFileStem } from "../../../core/utils/paths.js";
7
7
 
8
8
  export type ZobComsRedactedCaptureKind = "live_prompt" | "live_response" | "live_exchange";
9
9
 
@@ -4,9 +4,9 @@ import { join } from "node:path";
4
4
 
5
5
  import { buildZobComsProjectId } from "./identity.js";
6
6
  import type { ZobLivePeerCard, ZpeerRoomMembership } from "./types.js";
7
- import { sha256 } from "../utils/hashing.js";
8
- import { isRecord } from "../utils/records.js";
9
- import { safeFileStem } from "../utils/paths.js";
7
+ import { sha256 } from "../../../core/utils/hashing.js";
8
+ import { isRecord } from "../../../core/utils/records.js";
9
+ import { safeFileStem } from "../../../core/utils/paths.js";
10
10
 
11
11
  const PROFILE_SCHEMA = "zob.zpeer-local-profile.v1";
12
12
  const NEW_CARRYOVER_SCHEMA = "zob.zpeer-new-carryover.v1";
@@ -6,10 +6,10 @@ import { buildZobLiveEnvelope } from "./envelope.js";
6
6
  import { sendZobLocalEnvelope } from "./local-transport.js";
7
7
  import { readZobLiveRegistryAllProjectsSnapshot, writeZobLivePeerCard, writeZobLivePeerCardToProjectId } from "./registry.js";
8
8
  import type { ZobLivePeerCard, ZobLivePeerStatus, ZpeerRoomMembership, ZpeerRoomMembershipRole } from "./types.js";
9
- import { validateZobComsEdge } from "../topology/coms.js";
10
- import { loadTeamDefinition, validateTeamDefinition } from "../topology/teams.js";
9
+ import { validateZobComsEdge } from "../../topology/coms.js";
10
+ import { loadTeamDefinition, validateTeamDefinition } from "../../topology/teams.js";
11
11
  import { loadZteamManifest, zteamAllowsZpeerContact } from "../zagents.js";
12
- import { sha256 } from "../utils/hashing.js";
12
+ import { sha256 } from "../../../core/utils/hashing.js";
13
13
 
14
14
  const DEFAULT_ROOM_ID = "default";
15
15
  const ALIAS_PATTERN = /^[a-zA-Z][a-zA-Z0-9_-]{1,31}$/;
@@ -5,14 +5,14 @@ import { buildZobLivePresenceSummary, redactZobLivePeerForMissionControl } from
5
5
  import { readZobComsV2Policy } from "./coms-v2/policy.js";
6
6
  import { zpeerMembershipsForPeer } from "./coms-v2/zpeer.js";
7
7
  import { readZobLiveRegistrySnapshot } from "./coms-v2/registry.js";
8
- import { buildQueueDashboardSummary } from "./queue.js";
9
- import type { TeamDefinition } from "./types.js";
10
- import { summarizePromotionCandidates } from "./promotion/candidate.js";
11
- import { buildZobComsMessage, listZobComsMessages, validateZobComsEdge, validateZobComsMessage } from "./topology/coms.js";
12
- import { sha256 } from "./utils/hashing.js";
13
- import { readJsonl, readJsonObjectIfPresent } from "./utils/json.js";
14
- import { safeFileStem } from "./utils/paths.js";
15
- import { isRecord } from "./utils/records.js";
8
+ import { buildQueueDashboardSummary } from "../telemetry/queue.js";
9
+ import type { TeamDefinition } from "../../types.js";
10
+ import { summarizePromotionCandidates } from "../promotion/candidate.js";
11
+ import { buildZobComsMessage, listZobComsMessages, validateZobComsEdge, validateZobComsMessage } from "../topology/coms.js";
12
+ import { sha256 } from "../../core/utils/hashing.js";
13
+ import { readJsonl, readJsonObjectIfPresent } from "../../core/utils/json.js";
14
+ import { safeFileStem } from "../../core/utils/paths.js";
15
+ import { isRecord } from "../../core/utils/records.js";
16
16
 
17
17
  export const MISSION_CONTROL_COMMANDS = ["pause", "resume", "reprioritize", "request_context", "request_oracle", "stop", "approve", "replan"] as const;
18
18
 
@@ -1,10 +1,11 @@
1
1
  import { existsSync, readFileSync, readdirSync } from "node:fs";
2
2
  import { basename, join, relative, resolve } from "node:path";
3
3
 
4
+ import type { ModeName } from "../../core/types/core.js";
4
5
  import { safeZpeerAlias, safeZpeerRoomId } from "./coms-v2/zpeer.js";
5
- import { parseJsonFile } from "./utils/json.js";
6
- import { isSafeArtifactName } from "./utils/paths.js";
7
- import { isRecord } from "./utils/records.js";
6
+ import { parseJsonFile } from "../../core/utils/json.js";
7
+ import { isSafeArtifactName } from "../../core/utils/paths.js";
8
+ import { isRecord } from "../../core/utils/records.js";
8
9
 
9
10
  const ZAGENTS_DIR = ".pi/zagents";
10
11
  const ZTEAMS_DIR = ".pi/zteams";
@@ -12,6 +13,7 @@ const ZAGENT_PROMPTS_DIR = ".pi/zagents/prompts";
12
13
  const ZAGENT_SCHEMA_ID = "zob.zagent.v1";
13
14
  const ZTEAM_SCHEMA_ID = "zob.zteam.v1";
14
15
  const SAFE_ID_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9_.-]{0,79}$/;
16
+ const ZAGENT_MODE_NAMES = new Set<ModeName>(["explore", "plan", "implement", "oracle", "factory", "orchestrator", "vanilla"]);
15
17
 
16
18
  export const ZAGENT_MANIFEST_SCHEMA = {
17
19
  schema: ZAGENT_SCHEMA_ID,
@@ -65,6 +67,7 @@ export interface ZAgentManifest {
65
67
  communicationPolicy?: ZAgentCommunicationPolicy;
66
68
  contextRefs?: ZAgentContextRefInput[];
67
69
  model?: string;
70
+ defaultMode?: ModeName;
68
71
  tools?: string[];
69
72
  metadata?: Record<string, unknown>;
70
73
  localOnly: true;
@@ -269,6 +272,19 @@ function validateRoomBindings(rooms: ZAgentRoomRef[] | undefined, label: string)
269
272
  return errors;
270
273
  }
271
274
 
275
+
276
+ function safePiModelPattern(value: string | undefined): string | undefined {
277
+ const trimmed = value?.trim();
278
+ if (!trimmed || trimmed.length > 160) return undefined;
279
+ if (trimmed.includes("\0") || trimmed.includes("\n") || trimmed.includes("\r") || trimmed.includes("..")) return undefined;
280
+ if (trimmed.startsWith("/") || trimmed.startsWith("~")) return undefined;
281
+ return /^[a-zA-Z0-9._:/+@-]+$/.test(trimmed) ? trimmed : undefined;
282
+ }
283
+
284
+ function isZagentModeName(value: unknown): value is ModeName {
285
+ return typeof value === "string" && ZAGENT_MODE_NAMES.has(value as ModeName);
286
+ }
287
+
272
288
  function validateCommunicationPolicy(policy: unknown, label: string): string[] {
273
289
  const errors: string[] = [];
274
290
  if (policy === undefined) return errors;
@@ -305,6 +321,7 @@ function isZAgentManifest(value: unknown): value is ZAgentManifest {
305
321
  && isCommunicationPolicy(value.communicationPolicy)
306
322
  && (value.contextRefs === undefined || (Array.isArray(value.contextRefs) && value.contextRefs.every(isContextRef)))
307
323
  && (value.model === undefined || typeof value.model === "string")
324
+ && (value.defaultMode === undefined || isZagentModeName(value.defaultMode))
308
325
  && (value.tools === undefined || isStringArray(value.tools))
309
326
  && (value.metadata === undefined || isRecord(value.metadata))
310
327
  && value.localOnly === true
@@ -371,6 +388,12 @@ export function validateZagentManifest(repoRoot: string, manifest: unknown, mani
371
388
  errors.push(...validateRoomBindings(rooms, "zagent.rooms"));
372
389
  errors.push(...validateActiveRoom(manifest.activeRoom, bindings, "zagent"));
373
390
  errors.push(...validateCommunicationPolicy(manifest.communicationPolicy, "zagent.communicationPolicy"));
391
+ if (typeof manifest.model === "string" && safePiModelPattern(manifest.model) !== manifest.model.trim()) {
392
+ errors.push(`zagent.model must be a safe Pi --model pattern: ${manifest.model}`);
393
+ }
394
+ if (manifest.defaultMode !== undefined && !isZagentModeName(manifest.defaultMode)) {
395
+ errors.push(`zagent.defaultMode must be one of ${[...ZAGENT_MODE_NAMES].join(",")}: ${String(manifest.defaultMode)}`);
396
+ }
374
397
  if (typeof manifest.promptRef === "string") {
375
398
  const prompt = resolveZagentPromptRef(repoRoot, manifest.promptRef);
376
399
  errors.push(...prompt.errors);
@@ -476,6 +499,64 @@ export function listZteamManifests(repoRoot: string): ZTeamLoaded[] {
476
499
  return listJsonFiles(projectZteamsDir(repoRoot)).map((path) => loadZteamManifest(repoRoot, basename(path, ".json")));
477
500
  }
478
501
 
502
+ export interface ZAgentResolvedTeamMembership {
503
+ teamId: string;
504
+ alias?: string;
505
+ role?: string;
506
+ rooms: ZAgentRoomBinding[];
507
+ }
508
+
509
+ function zteamMemberMatchesZagent(member: ZTeamMemberManifest | ZTeamAgentManifest, zagentId: string): boolean {
510
+ return zteamMemberAgentId(member) === zagentId;
511
+ }
512
+
513
+ export function resolveZagentTeamMemberships(repoRoot: string, zagentId: string): ZAgentResolvedTeamMembership[] {
514
+ const memberships: ZAgentResolvedTeamMembership[] = [];
515
+ for (const loaded of listZteamManifests(repoRoot)) {
516
+ if (loaded.errors.length > 0) continue;
517
+ const teamRooms = normalizeZagentRoomBindings(loaded.manifest.rooms, loaded.manifest.defaultRoom, loaded.manifest.activeRoom);
518
+ const members = [...(loaded.manifest.members ?? []), ...(loaded.manifest.agents ?? [])];
519
+ for (const member of members) {
520
+ if (!zteamMemberMatchesZagent(member, zagentId)) continue;
521
+ const memberRooms = zteamMemberRooms(member, loaded.manifest.defaultRoom);
522
+ const rooms = memberRooms.length > 0 ? memberRooms : teamRooms;
523
+ memberships.push({
524
+ teamId: loaded.manifest.id,
525
+ alias: member.alias,
526
+ role: member.role,
527
+ rooms,
528
+ });
529
+ }
530
+ }
531
+ return memberships;
532
+ }
533
+
534
+ export function resolveZagentRuntimeRoomBindings(repoRoot: string, manifest: ZAgentManifest): { rooms: ZAgentRoomBinding[]; teamIds: string[] } {
535
+ const byRoom = new Map<string, ZAgentRoomBinding>();
536
+ const pushRoom = (room: ZAgentRoomBinding, defaults: { alias?: string; role?: string } = {}): void => {
537
+ const id = safeZpeerRoomId(room.id);
538
+ if (!id) return;
539
+ const existing = byRoom.get(id);
540
+ byRoom.set(id, {
541
+ ...existing,
542
+ ...room,
543
+ id,
544
+ alias: existing?.alias ?? room.alias ?? defaults.alias,
545
+ role: existing?.role ?? room.role ?? defaults.role,
546
+ active: existing?.active === true || room.active === true,
547
+ });
548
+ };
549
+
550
+ for (const room of normalizeZagentRoomBindings(manifest.rooms, manifest.defaultRoom, manifest.activeRoom)) pushRoom(room, { alias: manifest.alias });
551
+ const teamIds = new Set<string>(manifest.team ? [manifest.team] : []);
552
+ for (const membership of resolveZagentTeamMemberships(repoRoot, manifest.id)) {
553
+ teamIds.add(membership.teamId);
554
+ for (const room of membership.rooms) pushRoom(room, { alias: membership.alias ?? manifest.alias, role: membership.role });
555
+ }
556
+ const rooms = [...byRoom.values()];
557
+ return { rooms, teamIds: [...teamIds] };
558
+ }
559
+
479
560
  function policyAllowsZpeerContact(policy: ZAgentCommunicationPolicy | undefined, roomId?: string, alias?: string): boolean {
480
561
  if (!policy) return true;
481
562
  if (policy.zpeerContact === false || policy.allowZpeerContact === false) return false;
@@ -507,10 +588,11 @@ export function formatZagentList(agents: ZAgentLoaded[]): string {
507
588
  const alias = manifest.alias ? ` @${manifest.alias}` : "";
508
589
  const role = manifest.role ? ` role=${manifest.role}` : "";
509
590
  const team = manifest.team ? ` team=${manifest.team}` : "";
591
+ const mode = manifest.defaultMode ? ` defaultMode=${manifest.defaultMode}` : "";
510
592
  const rooms = normalizeZagentRoomBindings(manifest.rooms, manifest.defaultRoom, manifest.activeRoom);
511
593
  const roomText = rooms.length ? ` rooms=${rooms.map((room) => `${room.id}${room.active ? "*" : ""}`).join(",")}` : "";
512
594
  const status = errors.length === 0 ? "ok" : `errors=${errors.length}`;
513
- return `- ${manifest.id}${alias} [${status}]${team}${role}${roomText}${relPrompt} path=${relPath}`;
595
+ return `- ${manifest.id}${alias} [${status}]${team}${role}${mode}${roomText}${relPrompt} path=${relPath}`;
514
596
  }).join("\n");
515
597
  }
516
598
 
@@ -0,0 +1,20 @@
1
+ # Context domain guardrail
2
+
3
+ ## Scope
4
+
5
+ - Context/GBrain readiness, context scope validation, and writeback proposal helpers.
6
+
7
+ ## MUST DO
8
+
9
+ - Preserve bounded context, citations, forbidden-source checks, and proposal-only writeback semantics.
10
+ - Keep raw conversation/prompt bodies out of persisted metadata.
11
+
12
+ ## MUST NOT
13
+
14
+ - Do not import/embed/sync/write to external knowledge backends by moving code.
15
+ - Do not import from `index.ts` or `index.js`.
16
+
17
+ ## Validation
18
+
19
+ - `npm run check -- --pretty false`.
20
+ - Run context readiness checks when context behavior moves.
@@ -1,9 +1,9 @@
1
1
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
2
2
  import { join } from "node:path";
3
3
 
4
- import { sha256 } from "./utils/hashing.js";
5
- import { safeFileStem } from "./utils/paths.js";
6
- import { isRecord } from "./utils/records.js";
4
+ import { sha256 } from "../../core/utils/hashing.js";
5
+ import { safeFileStem } from "../../core/utils/paths.js";
6
+ import { isRecord } from "../../core/utils/records.js";
7
7
 
8
8
  const FORBIDDEN_CONTEXT_BODY_KEYS = new Set(["body", "task", "prompt", "output", "content", "message", "diff", "patch", "rawConversation", "conversationHistory"]);
9
9
  const CONTEXT_SCOPE_MAX_TOKENS_CAP = 8000;
@@ -416,7 +416,7 @@ export function buildContextGbrainReadinessAudit(repoRoot: string, input: { runI
416
416
  runId: String(scope.runId),
417
417
  observedProblemHash: sha256("context readiness observed problem"),
418
418
  newPatternHash: sha256("context readiness writeback pattern"),
419
- evidenceRefs: ["docs/AUTONOMOUS_SUPER_FACTORY_GOAL.md", ".pi/extensions/zob-harness/src/context-gbrain.ts"],
419
+ evidenceRefs: ["docs/AUTONOMOUS_SUPER_FACTORY_GOAL.md", ".pi/extensions/zob-harness/src/domains/context/context-gbrain.ts"],
420
420
  recommendedArtifact: ".pi/context/writeback-proposals.jsonl",
421
421
  });
422
422
  const forbiddenScope = { ...scope, allowedSources: ["zob-harness-docs", "raw-conversation-history"], forbiddenSources: ["raw-conversation-history", ".env"] };
@@ -0,0 +1,21 @@
1
+ # Delegation domain guardrail
2
+
3
+ ## Scope
4
+
5
+ - Agent discovery, child runner support, output contracts, delegation schemas, and child-output gates.
6
+
7
+ ## MUST DO
8
+
9
+ - Preserve six-part contract validation, child output contract ids, output gate behavior, model override checks, and path policy enforcement.
10
+ - Keep child prompt/output bodies out of persisted ledgers unless existing policy explicitly allows a redacted/hash-only artifact.
11
+
12
+ ## MUST NOT
13
+
14
+ - Do not rename specialist agents, output contract ids, gate markers, or failure-kind strings.
15
+ - Do not loosen write-scope, cwd, allowed_paths, forbidden_paths, or secret protections.
16
+ - Do not import from `index.ts` or `index.js`.
17
+
18
+ ## Validation
19
+
20
+ - `npm run check -- --pretty false`.
21
+ - `npm run smoke:harness` after child-runner, output-contract, safety-adjacent, or runtime-facing moves.
@@ -1,8 +1,8 @@
1
1
  import { existsSync, readFileSync, readdirSync } from "node:fs";
2
2
  import { basename, join } from "node:path";
3
3
  import { getAgentDir } from "@earendil-works/pi-coding-agent";
4
- import type { AgentScope, HarnessAgent } from "./types.js";
5
- import { readableZobResourcePaths } from "./utils/resources.js";
4
+ import type { AgentScope, HarnessAgent } from "../../types.js";
5
+ import { readableZobResourcePaths } from "../../core/utils/resources.js";
6
6
 
7
7
  function parseFrontmatter(raw: string): { frontmatter: Record<string, string>; body: string } {
8
8
  if (!raw.startsWith("---\n")) return { frontmatter: {}, body: raw };
@@ -3,12 +3,12 @@ import { basename, join, relative } from "node:path";
3
3
 
4
4
  import { discoverAgents } from "./agents.js";
5
5
  import { getOutputContractDefinitions } from "./output-contracts.js";
6
- import { loadChainDefinition, listChainDefinitions } from "./topology/chains.js";
7
- import { sha256 } from "./utils/hashing.js";
8
- import { parseJsonFile } from "./utils/json.js";
9
- import { safeFileStem } from "./utils/paths.js";
10
- import { isRecord } from "./utils/records.js";
11
- import { readableZobResourcePath, readableZobResourcePaths } from "./utils/resources.js";
6
+ import { loadChainDefinition, listChainDefinitions } from "../topology/chains.js";
7
+ import { sha256 } from "../../core/utils/hashing.js";
8
+ import { parseJsonFile } from "../../core/utils/json.js";
9
+ import { safeFileStem } from "../../core/utils/paths.js";
10
+ import { isRecord } from "../../core/utils/records.js";
11
+ import { readableZobResourcePath, readableZobResourcePaths } from "../../core/utils/resources.js";
12
12
 
13
13
  export interface ReuseScoutInput {
14
14
  query: string;
@@ -6,15 +6,15 @@ import { join } from "node:path";
6
6
  import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
7
7
 
8
8
  import { discoverAgents } from "./agents.js";
9
- import { SUPERVISED_READONLY_CHILD_TOOLS } from "./constants.js";
10
- import { validateExplicitModelOverride } from "./model-availability.js";
9
+ import { SUPERVISED_READONLY_CHILD_TOOLS } from "../../core/constants.js";
10
+ import { validateExplicitModelOverride } from "../models/model-availability.js";
11
11
  import { applyChildGates } from "./output-contracts.js";
12
- import { buildChildEnv } from "./safety.js";
13
- import { updateUsage, usageEmpty } from "./telemetry.js";
14
- import type { ChildResult, ChildThinkingLevel, HarnessAgent, SupervisedReadonlyDispatchContract, SupervisedReadonlyDispatcher } from "./types.js";
15
- import { sha256 } from "./utils/hashing.js";
16
- import { safeFileStem } from "./utils/paths.js";
17
- import { parseJsonLine, textFromMessage } from "./utils/records.js";
12
+ import { buildChildEnv } from "../governance/safety.js";
13
+ import { updateUsage, usageEmpty } from "../telemetry/telemetry.js";
14
+ import type { ChildResult, ChildThinkingLevel, HarnessAgent, SupervisedReadonlyDispatchContract, SupervisedReadonlyDispatcher } from "../../types.js";
15
+ import { sha256 } from "../../core/utils/hashing.js";
16
+ import { safeFileStem } from "../../core/utils/paths.js";
17
+ import { parseJsonLine, textFromMessage } from "../../core/utils/records.js";
18
18
 
19
19
  function getPiInvocation(args: string[]): { command: string; args: string[] } {
20
20
  const currentScript = process.argv[1];
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync, statSync } from "node:fs";
2
2
  import { extname, resolve, sep } from "node:path";
3
3
 
4
- import type { ChildResult, OutputContract, OutputRequirement } from "./types.js";
4
+ import type { ChildResult, OutputContract, OutputRequirement } from "../../types.js";
5
5
 
6
6
  const COMMON_OUTPUT_REQUIREMENTS: OutputRequirement[] = [
7
7
  {