ultimate-pi 0.11.0 → 0.12.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 (122) hide show
  1. package/.agents/skills/harness-debate-plan/SKILL.md +44 -0
  2. package/.agents/skills/harness-decisions/SKILL.md +1 -1
  3. package/.agents/skills/harness-orchestration/SKILL.md +54 -28
  4. package/.agents/skills/harness-plan/SKILL.md +15 -20
  5. package/.pi/agents/harness/adversary.md +0 -1
  6. package/.pi/agents/harness/evaluator.md +0 -1
  7. package/.pi/agents/harness/executor.md +1 -2
  8. package/.pi/agents/harness/incident-recorder.md +0 -1
  9. package/.pi/agents/harness/meta-optimizer.md +0 -1
  10. package/.pi/agents/harness/planning/decompose.md +3 -4
  11. package/.pi/agents/harness/planning/execution-plan-author.md +30 -0
  12. package/.pi/agents/harness/planning/hypothesis-validator.md +23 -0
  13. package/.pi/agents/harness/planning/hypothesis.md +3 -4
  14. package/.pi/agents/harness/planning/plan-adversary.md +10 -42
  15. package/.pi/agents/harness/planning/plan-evaluator.md +18 -0
  16. package/.pi/agents/harness/planning/review-integrator.md +23 -0
  17. package/.pi/agents/harness/planning/scout-graphify.md +11 -5
  18. package/.pi/agents/harness/planning/scout-semantic.md +11 -6
  19. package/.pi/agents/harness/planning/scout-structure.md +12 -6
  20. package/.pi/agents/harness/planning/sprint-contract-auditor.md +18 -0
  21. package/.pi/agents/harness/planning/stack-researcher.md +24 -0
  22. package/.pi/agents/harness/tie-breaker.md +0 -1
  23. package/.pi/agents/harness/trace-librarian.md +0 -1
  24. package/.pi/extensions/debate-orchestrator.ts +90 -53
  25. package/.pi/extensions/harness-plan-approval.ts +2 -2
  26. package/.pi/extensions/harness-run-context.ts +145 -5
  27. package/.pi/extensions/harness-subagents.ts +2 -2
  28. package/.pi/extensions/lib/harness-posthog.ts +6 -1
  29. package/.pi/extensions/lib/harness-spawn-budget.ts +75 -0
  30. package/.pi/extensions/lib/harness-subagent-auth.ts +123 -0
  31. package/.pi/extensions/lib/{harness-subagents/harness-subagent-policy.ts → harness-subagent-policy.ts} +3 -6
  32. package/.pi/extensions/lib/harness-subagent-precheck.ts +95 -0
  33. package/.pi/extensions/lib/harness-subagents-bridge.ts +176 -0
  34. package/.pi/extensions/lib/plan-approval/create-plan.ts +4 -7
  35. package/.pi/extensions/lib/plan-approval/plan-review.ts +1 -1
  36. package/.pi/extensions/lib/plan-approval/types.ts +7 -1
  37. package/.pi/extensions/lib/plan-debate-envelope.ts +84 -0
  38. package/.pi/extensions/lib/{harness-subagents/spawn-policy.ts → spawn-policy.ts} +1 -0
  39. package/.pi/extensions/policy-gate.ts +1 -1
  40. package/.pi/extensions/review-integrity.ts +48 -29
  41. package/.pi/harness/agents.manifest.json +37 -25
  42. package/.pi/harness/docs/adrs/0032-harness-command-orchestration.md +4 -3
  43. package/.pi/harness/docs/adrs/0033-parent-orchestrated-planning.md +1 -1
  44. package/.pi/harness/docs/adrs/0035-plan-phase-review-gate.md +27 -0
  45. package/.pi/harness/evals/smoke/fixtures/plan-phase/minimal-med/artifacts/review-round-r1.yaml +25 -0
  46. package/.pi/harness/evals/smoke/fixtures/plan-phase/minimal-med/artifacts/review-round-r4.yaml +26 -0
  47. package/.pi/harness/evals/smoke/fixtures/plan-phase/minimal-med/artifacts/sprint-audit-r4.yaml +5 -0
  48. package/.pi/harness/evals/smoke/fixtures/plan-phase/minimal-med/plan-packet.yaml +196 -0
  49. package/.pi/harness/evals/smoke/fixtures/plan-phase/minimal-med/plan-review.md +14 -0
  50. package/.pi/harness/evals/smoke/fixtures/plan-phase/minimal-med/research-brief.yaml +32 -0
  51. package/.pi/harness/evals/smoke/run-context.fixture.json +1 -1
  52. package/.pi/harness/evals/smoke/smoke-harness-plan.mjs +88 -0
  53. package/.pi/harness/specs/harness-posthog-event.schema.json +6 -1
  54. package/.pi/harness/specs/plan-execution-plan-brief.schema.json +13 -0
  55. package/.pi/harness/specs/plan-execution-plan.schema.json +255 -0
  56. package/.pi/harness/specs/plan-packet.schema.json +14 -5
  57. package/.pi/harness/specs/plan-review-round-draft.schema.json +68 -0
  58. package/.pi/harness/specs/plan-sprint-audit-turn.schema.json +29 -0
  59. package/.pi/harness/specs/plan-stack-brief.schema.json +65 -0
  60. package/.pi/harness/specs/plan-validation-turn.schema.json +42 -0
  61. package/.pi/harness/specs/round-result.schema.json +16 -9
  62. package/.pi/lib/debate-orchestrator-types.ts +38 -0
  63. package/.pi/lib/harness-agent-discovery.mjs +81 -0
  64. package/.pi/lib/harness-run-context.ts +64 -38
  65. package/.pi/lib/harness-yaml.mjs +73 -0
  66. package/.pi/lib/harness-yaml.ts +90 -0
  67. package/.pi/prompts/harness-auto.md +13 -11
  68. package/.pi/prompts/harness-critic.md +2 -2
  69. package/.pi/prompts/harness-eval.md +3 -3
  70. package/.pi/prompts/harness-incident.md +2 -2
  71. package/.pi/prompts/harness-plan.md +79 -93
  72. package/.pi/prompts/harness-review.md +2 -2
  73. package/.pi/prompts/harness-router-tune.md +1 -1
  74. package/.pi/prompts/harness-run.md +2 -2
  75. package/.pi/prompts/harness-setup.md +15 -6
  76. package/.pi/prompts/harness-trace.md +2 -2
  77. package/.pi/scripts/harness-agents-manifest.mjs +1 -1
  78. package/.pi/scripts/harness-verify.mjs +28 -19
  79. package/.pi/scripts/validate-plan-dag.mjs +258 -0
  80. package/.pi/scripts/vendor-sync-pi-subagents.sh +19 -0
  81. package/CHANGELOG.md +12 -0
  82. package/THIRD_PARTY_NOTICES.md +8 -0
  83. package/biome.json +2 -2
  84. package/package.json +6 -4
  85. package/.pi/agents/harness/planner.md +0 -13
  86. package/.pi/agents/harness/planning/hypothesis-eval.md +0 -59
  87. package/.pi/agents/harness/planning/planner.md +0 -20
  88. package/.pi/extensions/lib/harness-subagents/agent-loader.ts +0 -126
  89. package/.pi/extensions/lib/harness-subagents/agent-manifest.ts +0 -119
  90. package/.pi/extensions/lib/harness-subagents/agent-parser.ts +0 -87
  91. package/.pi/extensions/lib/harness-subagents/blackboard-tool.ts +0 -118
  92. package/.pi/extensions/lib/harness-subagents/blackboard.ts +0 -175
  93. package/.pi/extensions/lib/harness-subagents/parent-ask-user-bridge.ts +0 -10
  94. package/.pi/extensions/lib/harness-subagents/parent-harness-ui-bridge.ts +0 -137
  95. package/.pi/extensions/lib/harness-subagents/parent-harness-ui-hooks.ts +0 -77
  96. package/.pi/extensions/lib/harness-subagents/types-blackboard.ts +0 -27
  97. package/.pi/extensions/lib/harness-subagents/vendored/agent-manager.ts +0 -558
  98. package/.pi/extensions/lib/harness-subagents/vendored/agent-runner.ts +0 -666
  99. package/.pi/extensions/lib/harness-subagents/vendored/agent-types.ts +0 -175
  100. package/.pi/extensions/lib/harness-subagents/vendored/context.ts +0 -59
  101. package/.pi/extensions/lib/harness-subagents/vendored/cross-extension-rpc.ts +0 -134
  102. package/.pi/extensions/lib/harness-subagents/vendored/custom-agents.ts +0 -5
  103. package/.pi/extensions/lib/harness-subagents/vendored/default-agents.ts +0 -123
  104. package/.pi/extensions/lib/harness-subagents/vendored/env.ts +0 -43
  105. package/.pi/extensions/lib/harness-subagents/vendored/group-join.ts +0 -144
  106. package/.pi/extensions/lib/harness-subagents/vendored/index.ts +0 -2460
  107. package/.pi/extensions/lib/harness-subagents/vendored/invocation-config.ts +0 -52
  108. package/.pi/extensions/lib/harness-subagents/vendored/memory.ts +0 -182
  109. package/.pi/extensions/lib/harness-subagents/vendored/model-resolver.ts +0 -92
  110. package/.pi/extensions/lib/harness-subagents/vendored/output-file.ts +0 -115
  111. package/.pi/extensions/lib/harness-subagents/vendored/prompts.ts +0 -103
  112. package/.pi/extensions/lib/harness-subagents/vendored/schedule-store.ts +0 -177
  113. package/.pi/extensions/lib/harness-subagents/vendored/schedule.ts +0 -416
  114. package/.pi/extensions/lib/harness-subagents/vendored/settings.ts +0 -210
  115. package/.pi/extensions/lib/harness-subagents/vendored/skill-loader.ts +0 -108
  116. package/.pi/extensions/lib/harness-subagents/vendored/types.ts +0 -187
  117. package/.pi/extensions/lib/harness-subagents/vendored/ui/agent-widget.ts +0 -639
  118. package/.pi/extensions/lib/harness-subagents/vendored/ui/conversation-viewer.ts +0 -324
  119. package/.pi/extensions/lib/harness-subagents/vendored/ui/schedule-menu.ts +0 -110
  120. package/.pi/extensions/lib/harness-subagents/vendored/usage.ts +0 -71
  121. package/.pi/extensions/lib/harness-subagents/vendored/worktree.ts +0 -195
  122. /package/.pi/extensions/{00-ultimate-pi-system-prompt.ts → custom-system-prompt.ts} +0 -0
@@ -1,154 +1,140 @@
1
1
  ---
2
- description: Transform a vague task into a rigorous hypothesis via decomposition + DARWIN synthesis, then a strict PlanPacket.
2
+ description: PM-grade harness plan scouts, ExecutionPlan, DAG validation, Review Gate debate, approval.
3
3
  argument-hint: "\"<task>\" [--risk low|med|high] [--budget <amount>] [--quick]"
4
4
  ---
5
5
 
6
6
  # harness-plan
7
7
 
8
- Parent orchestrator run planning in **this session**. Subagents explore, decompose, hypothesize, and review; you own `ask_user`, `approve_plan`, and `create_plan`. Never `write` or `edit` `plan-packet.json` use **`create_plan`** only.
8
+ You are the **planning PM** for this harness run. Produce an execution baseline (`plan-packet.yaml` + `plan-review.md`), not strategy theater. Parent owns `ask_user`, `approve_plan`, `create_plan`, debate bus commands, and YAML writes under `.pi/harness/runs/<run_id>/`.
9
9
 
10
- Allowed `subagent_type` values (copy exactly):
10
+ Never `write`/`edit` the final canonical packet except via **`write_harness_yaml`** for run artifacts and **`create_plan`** after approval. Do not paste JSON into `.yaml` files — subagents emit JSON; you convert via `write_harness_yaml`.
11
+
12
+ ## Allowed subagents
11
13
 
12
14
  - `harness/planning/scout-graphify`
13
15
  - `harness/planning/scout-structure`
14
- - `harness/planning/scout-semantic`
16
+ - `harness/planning/scout-semantic` (skip when `--quick`)
15
17
  - `harness/planning/decompose`
16
18
  - `harness/planning/hypothesis`
19
+ - `harness/planning/stack-researcher`
20
+ - `harness/planning/execution-plan-author`
21
+ - `harness/planning/hypothesis-validator` (debate R1 only)
22
+ - `harness/planning/plan-evaluator`
17
23
  - `harness/planning/plan-adversary`
18
- - `harness/planning/hypothesis-eval`
19
-
20
- Do **not** spawn `harness/planner` or `harness/planning/planner`.
24
+ - `harness/planning/sprint-contract-auditor`
25
+ - `harness/planning/review-integrator`
21
26
 
22
- ## Step 0 Parse arguments
27
+ Read **harness-debate-plan** skill before Review Gate rounds.
23
28
 
24
- Read `$ARGUMENTS`:
29
+ ## Performance rules
25
30
 
26
- - task statement (required) **THE QUESTION**
27
- - optional: `--risk low|med|high`, `--budget <amount>`, `--quick`
31
+ 1. Use `subagent` with `agentScope: "both"` and parallel `tasks` where lanes are independent.
32
+ 2. Each `subagent` call blocks until subprocesses finish — batch parallel scouts in one `tasks` array.
33
+ 3. Cap: **12** harness subagent invocations per parent session (extension-enforced).
34
+ 4. Compact task text: embed `HarnessSpawnContext` JSON + lane-specific instructions only.
28
35
 
29
- If task is missing:
36
+ ## Step 0 — Parse `$ARGUMENTS`
30
37
 
31
- `Usage: /harness-plan "<task>" [--risk low|med|high] [--budget <amount>] [--quick]`
38
+ - task (required)
39
+ - `--risk low|med|high`, `--budget`, `--quick`
32
40
 
33
- `--quick` skips `harness/planning/scout-semantic` only — never skip graphify, structure, decompose, hypothesis, or approval.
41
+ `--quick` skips **scout-semantic** and post-run adversary only — **never** skip graphify, structure, decompose, hypothesis, stack research, execution plan, DAG validation, or **4-round plan debate**.
34
42
 
35
43
  ## Active plan context
36
44
 
37
- Use injected context only **do not** read `.pi/harness/specs/*.schema.json` from disk.
45
+ Use `[HarnessActivePlan]` / `[HarnessRunContext]` only. On revise: preserve `plan_id` / `task_id`. Canonical paths: `plan-packet.yaml`, `research-brief.yaml`, `artifacts/*.yaml`.
46
+
47
+ ## Phase 1 — Parallel scouts
38
48
 
39
- If `[HarnessActivePlan]` is present:
49
+ ```json
50
+ {
51
+ "agentScope": "both",
52
+ "tasks": [
53
+ { "agent": "harness/planning/scout-graphify", "task": "<HarnessSpawnContext + graphify lane>", "timeoutMs": 90000 },
54
+ { "agent": "harness/planning/scout-structure", "task": "<HarnessSpawnContext + structure lane>", "timeoutMs": 90000 }
55
+ ]
56
+ }
57
+ ```
40
58
 
41
- - Treat as **revise/amend** unless `/harness-new-run` was used.
42
- - Set `mode: revise` in `HarnessSpawnContext` from `[HarnessRunContext]`.
43
- - **Preserve `plan_id` and `task_id`** from the existing packet when amending.
44
- - Scouts focus on delta vs existing `plan_packet_path`; full re-scout only if scope changed materially.
59
+ Add `harness/planning/scout-semantic` to `tasks` unless `--quick`. Require graphify + structure success.
45
60
 
46
- Otherwise use `HarnessSpawnContext` from `[HarnessRunContext]` with `mode: create`.
61
+ ## Phase 2 & 3 Decompose + hypothesis (parallel)
47
62
 
48
- ## Phase 1 Parallel scouts (required)
63
+ One `subagent` call with `tasks` for `harness/planning/decompose` and `harness/planning/hypothesis`. Parse `PlanDecompositionBrief` and `PlanHypothesisBrief` from outputs. Persist with `write_harness_yaml` → `artifacts/decomposition.yaml` and `artifacts/hypothesis.yaml`.
49
64
 
50
- 1. Copy `HarnessSpawnContext` from `[HarnessRunContext]` (adjust `risk_level`, `quick`, `mode` from `$ARGUMENTS`).
51
- 2. Spawn scouts with **`inherit_context: false`**. Prefer parallel: `run_in_background: true` on each `Agent` call, then `get_subagent_result` for all.
65
+ ## Phase 4 Draft shell + fork
52
66
 
53
- ```
54
- Agent({ subagent_type: "harness/planning/scout-graphify", prompt: "<task + HarnessSpawnContext + scout JSON schema>", run_in_background: true })
55
- Agent({ subagent_type: "harness/planning/scout-structure", prompt: "…", run_in_background: true })
56
- ```
67
+ Build draft `PlanPacket` (`contract_version: "1.1.0"`):
57
68
 
58
- Skip `harness/planning/scout-semantic` when `--quick` or `quick: true`.
69
+ - `scope`, `assumptions`, `acceptance_checks`, `risk_level`, `rollback_plan`
70
+ - `execution_plan` placeholder until Phase 4b
59
71
 
60
- 3. Parse each scout’s fenced `json` (`lane`, `status`, `findings`, `key_paths`, `open_questions`).
61
- 4. **Partial failure:** require successful **graphify + structure** lanes. Semantic is optional. If a required lane fails, continue with `plan_status: partial` and document gaps in `assumptions`.
62
- 5. If JSON parse fails for a lane, summarize free-text output and add an assumption that the lane was unstructured.
72
+ `ask_user` when `dialectical_fork` is material.
63
73
 
64
- ## Phase 2 Decompose (DeepMind-style)
74
+ Initialize `research-brief.yaml` with decomposition + hypothesis (`write_harness_yaml`).
65
75
 
66
- 1. Spawn once with merged scout JSON:
76
+ ## Phase 4a Stack research
67
77
 
68
78
  ```
69
- Agent({ subagent_type: "harness/planning/decompose", prompt: "<HarnessSpawnContext + task + all scout lane JSON>", inherit_context: false })
79
+ subagent({ agentScope: "both", agent: "harness/planning/stack-researcher", task: "<HarnessSpawnContext + stack research brief>" })
70
80
  ```
71
81
 
72
- 2. Parse `PlanDecompositionBrief` JSON (`problem_restatement`, `core_tension`, `tensions`, `prior_art`, etc.).
73
- 3. On parse failure: one retry with “output valid JSON only”; if still failing, abort with `plan_status: needs_clarification`.
74
-
75
- ## Phase 3 — Hypothesis (DARWIN)
82
+ `write_harness_yaml` `artifacts/stack.yaml`; merge into `research-brief.yaml` `stack`.
76
83
 
77
- 1. Spawn once:
84
+ ## Phase 4b — Execution plan author
78
85
 
79
86
  ```
80
- Agent({ subagent_type: "harness/planning/hypothesis", prompt: "<HarnessSpawnContext + task + PlanDecompositionBrief + scout summaries>", inherit_context: false })
87
+ subagent({ agentScope: "both", agent: "harness/planning/execution-plan-author", task: "<HarnessSpawnContext + execution plan brief>" })
81
88
  ```
82
89
 
83
- 2. Parse `PlanHypothesisBrief` JSON (`primary`, `dialectical_fork`, `alternatives`, `recommended_next_steps`).
84
- 3. **Revision cap:** at most **one** re-spawn of `hypothesis` if Phase 6 eval requests revision (see below).
90
+ Merge `execution_plan` into draft `plan-packet.yaml` (`write_harness_yaml`). Save `artifacts/execution-plan-draft.yaml` the same way.
85
91
 
86
- ## Phase 4Draft PlanPacket + fork clarification (parent)
92
+ ## Phase 4cDAG validation (hard gate)
87
93
 
88
- Map hypothesis → [`PlanPacket`](.pi/harness/specs/plan-packet.schema.json):
89
-
90
- | Field | Source |
91
- |-------|--------|
92
- | `scope` | `problem_restatement` (narrowed) + `primary.claim` + `primary.mechanism` (implementation-ready) |
93
- | `assumptions` | `core_tension`, `prior_art.dead_ends`, scout `open_questions`, chosen fork path (if any) |
94
- | `acceptance_checks` | Each `primary.prediction` and `primary.experiment` as verifiable checklist items (min 1) |
95
- | `risk_level` | From `$ARGUMENTS` or infer from fork uncertainty / blast radius |
96
-
97
- Build complete draft: `plan_id`, `task_id`, `scope`, `assumptions`, `risk_level`, `acceptance_checks`, `rollback_plan` (`revert_commit_ready: true`, artifacts filled).
98
-
99
- Call **`ask_user`** when `dialectical_fork` is material (Path A vs B materially different) **before** Phase 5 reviews.
94
+ ```bash
95
+ node .pi/scripts/validate-plan-dag.mjs --packet .pi/harness/runs/<run_id>/plan-packet.yaml --write
96
+ ```
100
97
 
101
- Assemble `research_brief` for approval:
98
+ Must **pass** before debate. On fail: fix via author or parent patches, re-run.
102
99
 
103
- ```json
104
- {
105
- "decomposition": { /* PlanDecompositionBrief */ },
106
- "hypothesis": { /* PlanHypothesisBrief */ },
107
- "eval": null
108
- }
109
- ```
100
+ ## Phase 5 — Review Gate debate (4 rounds, even with `--quick`)
110
101
 
111
- ## Phase 5 — Parallel reviews
102
+ 1. `/harness-debate-open plan-<run_id>`
103
+ 2. For rounds 1–4 (`debate_round_focus`: spec, wbs, schedule, quality):
112
104
 
113
- Spawn in parallel (`run_in_background: true`):
105
+ | Round | Extra spawns (before integrator) |
106
+ |-------|----------------------------------|
107
+ | 1 | `hypothesis-validator` (blind: task + hypothesis only) → `plan-evaluator` → `plan-adversary` |
108
+ | 2 | `plan-evaluator` → `plan-adversary` (optional `sprint-contract-auditor` if done_criteria thin) |
109
+ | 3 | `plan-evaluator` → `plan-adversary` |
110
+ | 4 | `plan-evaluator` → `plan-adversary` → **`sprint-contract-auditor` (required)** |
114
111
 
115
- ```
116
- Agent({ subagent_type: "harness/planning/plan-adversary", prompt: "<HarnessSpawnContext + draft PlanPacket + scout summaries + decomposition human_summary>", inherit_context: false })
117
- Agent({ subagent_type: "harness/planning/hypothesis-eval", prompt: "<original task ONLY + PlanHypothesisBrief JSON — no decomposition, no PlanPacket>", inherit_context: false })
118
- ```
112
+ Then `review-integrator` → `write_harness_yaml` → `artifacts/review-round-r{N}.yaml` → build bus envelope → `/harness-debate-round '<json>'`.
119
113
 
120
- 1. Parse `PlanAdversaryBrief` merge `mitigations` into scope, assumptions, or `acceptance_checks`.
121
- 2. Parse `PlanHypothesisEval` — set `research_brief.eval`.
122
- 3. If `revision_recommended` or testability &lt; 70 or `relevance.passes` is false: re-spawn `hypothesis` once with eval rationale, update PlanPacket + `research_brief.hypothesis`, then re-run **hypothesis-eval** only (not adversary unless PlanPacket changed materially).
114
+ 3. `/harness-debate-consensus` after round 4.
123
115
 
124
- Cap: **at most 2** plan-adversary spawns and **at most 2** `approve_plan` rounds per invocation.
116
+ **R1 blind rule:** hypothesis-validator prompt must exclude decomposition, scouts, PlanPacket, prior debate.
125
117
 
126
- ## Phase 6 Approval + persistence (parent)
118
+ If R1 `revision_recommended` or `relevance.passes === false`: one `hypothesis` re-spawn, update brief, continue.
127
119
 
128
- 1. Call **`approve_plan`** with `plan_packet`, `human_summary` (primary claim + fork if any), and `research_brief`.
129
- 2. On **Approve** only, call **`create_plan`** with the **same** `plan_packet`.
130
- 3. If `create_plan` fails, tell the user to fix validation errors or run `/harness-plan-commit` after approval is recorded.
131
- 4. Confirm `[HarnessRunContext]` `plan_ready: true` before handoff.
120
+ **Blockers:** `policy_decision: block` do not `approve_plan`. `human_required` `ask_user` before approval.
132
121
 
133
- On **Cancel** or Esc: `plan_status: needs_clarification`; do **not** call `create_plan`.
122
+ ## Phase 5b Revise packet
134
123
 
135
- On **Request changes**: revise draft and re-run phases 4–6 only (re-scout/decompose/hypothesis only if scope changed).
124
+ Apply `recommended_packet_patches` from last integrator round. Re-run `validate-plan-dag.mjs`. If >30% work items changed, one partial re-round on affected focus.
136
125
 
137
- ## Recovery and ownership
126
+ Set `research_brief.eval` from R1 `hypothesis-validator` output.
138
127
 
139
- - Plan only in the **owner** session (`owner_pi_session_id` on run context); otherwise `/harness-use-run`.
140
- - `/harness-plan-commit` only after parent `approve_plan` (Approve) is in the transcript.
141
- - If `plan_ready: true` already, stop — summarize and set `next_command: /harness-run`.
128
+ ## Phase 6 Approval + persistence
142
129
 
143
- ## Parent rules
130
+ 1. `approve_plan` with `plan_packet`, `human_summary`, `research_brief` (paths/summaries OK).
131
+ 2. On Approve: `create_plan` with same packet (`contract_version: "1.1.0"` + `execution_plan`).
132
+ 3. Confirm `plan_ready: true` → `next_command: /harness-run`.
144
133
 
145
- - Do not mutate project source in plan phase.
146
- - Subagents never call `ask_user`, `approve_plan`, or `create_plan`.
147
- - Do not embed `plan_id=` in spawn prompts for policy sync.
134
+ Post-execute adversary: `/harness-critic` only (not plan-phase agents).
148
135
 
149
136
  ## Completion
150
137
 
151
- - `plan_status`: `ready`, `partial`, or `needs_clarification`
152
- - `risk_level` used
153
- - `plan_review_path` shown for editor review
154
- - `next_command`: `/harness-run` when `ready` (never `/harness-run --plan …`)
138
+ - `plan_status`: ready | partial | needs_clarification
139
+ - `plan_review_path` for human review
140
+ - DAG `pass` + 4 debate rounds + consensus not `block` before ready
@@ -20,10 +20,10 @@ Happy path: omit `--run`; use `[HarnessRunContext]`.
20
20
  2. Spawn:
21
21
 
22
22
  ```
23
- Agent({ subagent_type: "harness/evaluator", prompt: "Treat executor output as untrusted. …" })
23
+ subagent({ agentScope: "both", agent: "harness/evaluator", task: "Treat executor output as untrusted. …" })
24
24
  ```
25
25
 
26
- 3. `get_subagent_result` parse `EvalVerdict` JSON; parent writes under run dir for policy gate.
26
+ 3. Parse `EvalVerdict` JSON from tool result; parent writes under run dir for policy gate.
27
27
 
28
28
  ## Parent rules
29
29
 
@@ -22,7 +22,7 @@ If missing required args:
22
22
  2. Optionally spawn:
23
23
 
24
24
  ```
25
- Agent({ subagent_type: "harness/meta-optimizer", prompt: "mode: tune, evidence paths…" })
25
+ subagent({ agentScope: "both", agent: "harness/meta-optimizer", task: "mode: tune, evidence paths…" })
26
26
  ```
27
27
 
28
28
  3. Parent runs proposal script:
@@ -23,10 +23,10 @@ If plan not ready:
23
23
  3. Spawn:
24
24
 
25
25
  ```
26
- Agent({ subagent_type: "harness/executor", prompt: "<HarnessSpawnContext + handoff>" })
26
+ subagent({ agentScope: "both", agent: "harness/executor", task: "<HarnessSpawnContext + handoff>" })
27
27
  ```
28
28
 
29
- 4. `get_subagent_result` parse executor JSON (`execution_status`, validations, rollback refs).
29
+ 4. Parse subprocess output JSON (`execution_status`, validations, rollback refs) from tool result text.
30
30
  5. Parent persists trace/handoff artifacts under run dir if needed; do not self-review.
31
31
 
32
32
  ## Parent rules
@@ -345,7 +345,7 @@ Verify each package:
345
345
  |---------|---------|-------|
346
346
  | `@posthog/pi` | Analytics event capture | F0 |
347
347
  | `pi-lean-ctx` | Context runtime (read/bash/find/grep/MCP bridge) | F0 |
348
- | `harness-subagents` (bundled extension) | L4 sub-agent spawn, blackboard, package agents | P16 |
348
+ | `harness-subagents` (bundled extension) | L4 `subagent` tool, subprocess spawns, package agents | P16 |
349
349
  | Vendored `pi-vcc` (`vendor/pi-vcc`, `.pi/extensions/ultimate-pi-vcc.ts`) | VCC compaction / `vcc_recall` — env-only: `HARNESS_VCC_COMPACTION` (default on), `HARNESS_VCC_DEBUG` | Shipped |
350
350
  | `pi-model-router` | Vendored (`vendor/`); activates after `.pi/model-router.json` exists | F0 |
351
351
 
@@ -383,11 +383,11 @@ Manual override: **`/router profile auto`** anytime after reload if they changed
383
383
 
384
384
  ## Step 3.6 — Harness agents (package-resolved)
385
385
 
386
- `harness-subagents` loads agents from the installed **`ultimate-pi`** package (`$UP_PKG/.pi/agents/**`) with namespaced ids (`harness/planner`, `pi-pi/agent-expert`). **Do not copy** agents into the project unless you want a deliberate override.
386
+ `harness-subagents` loads agents from the installed **`ultimate-pi`** package (`$UP_PKG/.pi/agents/**`) with namespaced ids (`harness/executor`, `harness/planning/scout-graphify`, `pi-pi/agent-expert`). **Do not copy** agents into the project unless you want a deliberate override.
387
387
 
388
388
  **Slash commands are orchestrators:** `/harness-plan`, `/harness-run`, etc. spawn `harness/*` agents via the `Agent` tool — bootstrap stays **script-first**; only optionally spawn `harness/sentrux-bootstrap` for Sentrux (see Step 4.2).
389
389
 
390
- Optional per-repo overrides: place `.md` files at the **same relative path** (e.g. `.pi/agents/harness/planning/scout-graphify.md` overrides the package scout). Deprecated: `harness/planner.md` — use `harness/planning/` agents instead.
390
+ Optional per-repo overrides: place `.md` files at the **same relative path** (e.g. `.pi/agents/harness/planning/scout-graphify.md` overrides the package scout).
391
391
 
392
392
  Verify manifest drift after `pi update ultimate-pi`:
393
393
 
@@ -478,16 +478,25 @@ Template keys (placeholders — user fills secrets): `HARNESS_TELEMETRY_ENABLED`
478
478
 
479
479
  ### 4.1 — .gitignore Entries
480
480
 
481
- Ensure `.gitignore` contains:
481
+ Ensure `.gitignore` contains harness runtime entries (see repo root `.gitignore` — **do not** ignore `.pi/harness/specs/`; JSON schemas are shared contracts):
482
+
482
483
  ```
483
484
  .env
484
485
  .web/
485
486
  .searxng/
486
487
  .raw/
487
488
  .vault-meta/
488
- .pi/harness/critics/
489
+ .pi/harness/active-run.json
490
+ .pi/harness/release-readiness-report.md
489
491
  .pi/harness/plans/
490
- .pi/harness/specs/
492
+ .pi/harness/critics/
493
+ .pi/harness/runs/**
494
+ !.pi/harness/runs/README.md
495
+ .pi/harness/incidents/*
496
+ !.pi/harness/incidents/README.md
497
+ .pi/harness/debates/*
498
+ !.pi/harness/debates/README.md
499
+ .pi/harness/router/proposals/*
491
500
 
492
501
  # Model router config (user-specific — generated from env)
493
502
  .pi/model-router.json
@@ -20,10 +20,10 @@ Happy path: omit `--run`.
20
20
  2. Spawn:
21
21
 
22
22
  ```
23
- Agent({ subagent_type: "harness/trace-librarian", prompt: "…" })
23
+ subagent({ agentScope: "both", agent: "harness/trace-librarian", task: "…" })
24
24
  ```
25
25
 
26
- 3. `get_subagent_result` — present timeline and artifact index to user.
26
+ 3. Present timeline and artifact index from tool result to user.
27
27
 
28
28
  ## Completion
29
29
 
@@ -14,7 +14,7 @@ import {
14
14
  isSafeAgentId,
15
15
  sha256Content,
16
16
  walkAgentsDir,
17
- } from "../../test/harness-subagents-loader.core.mjs";
17
+ } from "../lib/harness-agent-discovery.mjs";
18
18
 
19
19
  const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
20
20
  const MANIFEST_PATH = join(ROOT, ".pi", "harness", "agents.manifest.json");
@@ -202,32 +202,41 @@ async function main() {
202
202
  if (!(await fileExists(runCtxLib))) fail("missing lib/harness-run-context.ts");
203
203
  ok("lib/harness-run-context.ts");
204
204
 
205
- const vendoredIndex = join(
205
+ const subagentsVendor = join(
206
+ ROOT,
207
+ "vendor",
208
+ "pi-subagents",
209
+ "src",
210
+ "subagents.ts",
211
+ );
212
+ if (!(await fileExists(subagentsVendor))) {
213
+ fail("missing vendor/pi-subagents/src/subagents.ts");
214
+ }
215
+ const bridgePath = join(
206
216
  ROOT,
207
217
  ".pi",
208
218
  "extensions",
209
219
  "lib",
210
- "harness-subagents",
211
- "vendored",
212
- "index.ts",
220
+ "harness-subagents-bridge.ts",
213
221
  );
214
- const vendoredSrc = await readFile(vendoredIndex, "utf-8");
215
- const runCtxImport = vendoredSrc.match(
216
- /from ["']([^"']*harness-run-context\.js)["']/,
217
- );
218
- if (!runCtxImport) {
219
- fail("vendored/index.ts must import harness-run-context.js");
222
+ if (!(await fileExists(bridgePath))) {
223
+ fail("missing harness-subagents-bridge.ts");
220
224
  }
221
- const runCtxImportPath = resolve(
222
- dirname(vendoredIndex),
223
- runCtxImport[1].replace(/\.js$/, ".ts"),
224
- );
225
- if (runCtxImportPath !== runCtxLib) {
226
- fail(
227
- `vendored/index.ts harness-run-context import resolves to ${runCtxImportPath}, expected ${runCtxLib}`,
228
- );
225
+ const bridgeSrc = await readFile(bridgePath, "utf-8");
226
+ if (!bridgeSrc.includes("precheckHarnessSubagentSpawn")) {
227
+ fail("harness-subagents-bridge must run precheckHarnessSubagentSpawn");
228
+ }
229
+ if (!bridgeSrc.includes("packageRoot")) {
230
+ fail("harness-subagents-bridge must pass packageRoot for agent discovery");
231
+ }
232
+ const subagentsSrc = await readFile(subagentsVendor, "utf-8");
233
+ if (!subagentsSrc.includes("discoverAgents")) {
234
+ fail("vendor subagents.ts must implement discoverAgents");
235
+ }
236
+ if (!subagentsSrc.includes("packageRoot")) {
237
+ fail("vendor subagents.ts must pass packageRoot into discovery");
229
238
  }
230
- ok("vendored/index.ts harness-run-context import path");
239
+ ok("vendor pi-subagents + harness bridge");
231
240
 
232
241
  const policyGateSrc = await readFile(
233
242
  join(ROOT, ".pi", "extensions", "policy-gate.ts"),