agentic-engineering-harness 0.6.13 → 0.6.15

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 (68) hide show
  1. package/dist/agents/outputContracts.d.ts +44 -1
  2. package/dist/agents/outputContracts.js +12 -2
  3. package/dist/agents/outputContracts.js.map +1 -1
  4. package/dist/agents/reviewLifecycle.js +54 -14
  5. package/dist/agents/reviewLifecycle.js.map +1 -1
  6. package/dist/agents/waveExecutor.d.ts +2 -13
  7. package/dist/audit/run.d.ts +7 -0
  8. package/dist/audit/run.js +198 -32
  9. package/dist/audit/run.js.map +1 -1
  10. package/dist/core/run.js +103 -28
  11. package/dist/core/run.js.map +1 -1
  12. package/dist/main.js +95 -29
  13. package/dist/main.js.map +1 -1
  14. package/dist/operations/artifacts.d.ts +13 -0
  15. package/dist/operations/artifacts.js +45 -0
  16. package/dist/operations/artifacts.js.map +1 -0
  17. package/dist/operations/change.d.ts +11 -0
  18. package/dist/operations/change.js +144 -0
  19. package/dist/operations/change.js.map +1 -0
  20. package/dist/operations/completion.d.ts +4 -1
  21. package/dist/operations/completion.js +69 -89
  22. package/dist/operations/completion.js.map +1 -1
  23. package/dist/operations/controller.d.ts +8 -5
  24. package/dist/operations/controller.js +270 -131
  25. package/dist/operations/controller.js.map +1 -1
  26. package/dist/operations/leadBinding.d.ts +2 -0
  27. package/dist/operations/leadBinding.js +22 -0
  28. package/dist/operations/leadBinding.js.map +1 -0
  29. package/dist/operations/liveness.d.ts +1 -0
  30. package/dist/operations/liveness.js +2 -0
  31. package/dist/operations/liveness.js.map +1 -0
  32. package/dist/operations/livenessV2.d.ts +34 -0
  33. package/dist/operations/livenessV2.js +339 -0
  34. package/dist/operations/livenessV2.js.map +1 -0
  35. package/dist/operations/mcp.d.ts +1 -0
  36. package/dist/operations/mcp.js +84 -57
  37. package/dist/operations/mcp.js.map +1 -1
  38. package/dist/operations/monitorProcess.d.ts +8 -0
  39. package/dist/operations/monitorProcess.js +33 -0
  40. package/dist/operations/monitorProcess.js.map +1 -0
  41. package/dist/operations/portfolio.d.ts +35 -0
  42. package/dist/operations/portfolio.js +158 -0
  43. package/dist/operations/portfolio.js.map +1 -0
  44. package/dist/operations/state.d.ts +174 -17
  45. package/dist/operations/state.js +178 -163
  46. package/dist/operations/state.js.map +1 -1
  47. package/dist/operations/supervisor.d.ts +38 -0
  48. package/dist/operations/supervisor.js +248 -0
  49. package/dist/operations/supervisor.js.map +1 -0
  50. package/dist/operations/wakeBudget.d.ts +15 -0
  51. package/dist/operations/wakeBudget.js +142 -0
  52. package/dist/operations/wakeBudget.js.map +1 -0
  53. package/dist/paseo/launchSpec.d.ts +4 -0
  54. package/dist/paseo/launchSpec.js +31 -37
  55. package/dist/paseo/launchSpec.js.map +1 -1
  56. package/dist/paseo/sdk.d.ts +5 -0
  57. package/dist/paseo/sdk.js +35 -87
  58. package/dist/paseo/sdk.js.map +1 -1
  59. package/dist/paseo/start.d.ts +1 -1
  60. package/dist/paseo/start.js +38 -87
  61. package/dist/paseo/start.js.map +1 -1
  62. package/dist/workers/agentPrompt.d.ts +2 -0
  63. package/dist/workers/agentPrompt.js +135 -190
  64. package/dist/workers/agentPrompt.js.map +1 -1
  65. package/docs/OPERATION_SUPERVISION.md +198 -0
  66. package/package.json +1 -1
  67. package/presets/agents/orchestration.jsonc +14 -4
  68. package/skills/engineering-workflow/SKILL.md +149 -104
@@ -0,0 +1,198 @@
1
+ # Durable operation supervision
2
+
3
+ AEH separates the user-facing conversation from operation-local semantic work and deterministic lifecycle authority.
4
+
5
+ ## Responsibility hierarchy
6
+
7
+ ```text
8
+ User
9
+ |
10
+ AEH Lead user / portfolio plane
11
+ |
12
+ +-- Operation A Supervisor one semantic operation context
13
+ | +-- planner
14
+ | +-- implementers
15
+ | +-- reviewers
16
+ | `-- oracle / remediation
17
+ |
18
+ +-- Operation B Supervisor
19
+ | `-- ...
20
+ |
21
+ `-- Operation C Supervisor
22
+
23
+ Deterministic controller + OperationRecord run across the hierarchy.
24
+ ```
25
+
26
+ The lead owns user intent, priorities, cross-operation dependencies, true exception decisions and final user-facing acceptance. The lead should not multiplex every child-agent timeline.
27
+
28
+ The operation supervisor owns semantic coordination and consolidation for one operation. It may merge semantically duplicate findings, identify conflicts and request bounded follow-up, but it cannot overrule deterministic state, validation or normative artifacts.
29
+
30
+ The controller owns lifecycle, stage transitions, participant state, seals, validators, rollback, quality gates, delivery and terminalization. `OperationRecord` is the durable source of lifecycle truth.
31
+
32
+ ## OperationRecord v2
33
+
34
+ Every detached operation has `.harness/operations/<id>.json` with:
35
+
36
+ - `revision` and `lastProgressAt`;
37
+ - `lead` binding/generation/acknowledged revision;
38
+ - supervisor generations (`ACTIVE`, `DRAINING`, `ARCHIVED`);
39
+ - stage state;
40
+ - bounded participants and parent supervisor generation;
41
+ - compact progress counts;
42
+ - wake/delivery metadata;
43
+ - final result pointers.
44
+
45
+ Large content is externalized:
46
+
47
+ ```text
48
+ .harness/operations/<id>/
49
+ events.ndjson
50
+ agents/*.json
51
+ consolidations/*.json
52
+ supervisors/*.json
53
+ ```
54
+
55
+ The three durable layers have different meanings:
56
+
57
+ - OperationRecord: current state snapshot.
58
+ - events.ndjson: how the operation reached that state.
59
+ - AuditReport/RunResult/agent/consolidation artifacts: evidence and final products.
60
+
61
+ Agent conversation history is not required to reconstruct an operation.
62
+
63
+ ## Revision and acknowledgement
64
+
65
+ Meaningful durable progress increments `revision`. A lead wake being accepted by Paseo is not considered consumption of the result. The currently bound lead must read `aeh_operation_status`, which acknowledges that exact durable revision.
66
+
67
+ This distinction prevents the failure mode:
68
+
69
+ ```text
70
+ operation terminal
71
+ -> prompt accepted by Paseo
72
+ -> lead turn/provider/UI fails before result is read
73
+ -> operation appears delivered forever
74
+ ```
75
+
76
+ The detached monitor continues until the terminal revision is acknowledged, and re-wakes the lead after the configured interval when necessary.
77
+
78
+ ## Layered liveness
79
+
80
+ AEH deliberately does not depend on one messaging channel:
81
+
82
+ 1. Paseo parent/child notifications are a fast lifecycle signal.
83
+ 2. Terminal completion send uses bounded retry.
84
+ 3. A detached non-LLM monitor observes durable state after the controller can exit.
85
+
86
+ The monitor wakes on:
87
+
88
+ - unseen meaningful progress after the quiet interval;
89
+ - blocked state;
90
+ - lack of durable progress beyond the stall threshold;
91
+ - terminal state not acknowledged by the current lead.
92
+
93
+ A stall targets the operation supervisor first. Missing/busy/unreachable supervisor recovery escalates to the lead.
94
+
95
+ Healthy non-terminal progress wakes are internal. They should not generate chat noise.
96
+
97
+ ## Supervisor context generations
98
+
99
+ Supervisors are proactively replaced rather than compacted as their canonical Paseo context approaches the configured handoff threshold.
100
+
101
+ ```text
102
+ generation N ACTIVE
103
+ -> durable supervisor checkpoint
104
+ -> generation N DRAINING
105
+ -> generation N+1 ACTIVE
106
+ ```
107
+
108
+ No live child is reparented. Children already running under generation N remain there. New children use N+1. Once every child tied to N is terminal, AEH archives N. An archive failure remains visible instead of being represented as success.
109
+
110
+ The new generation recovers from OperationRecord + supervisor checkpoint + relevant artifacts, not transcript replay.
111
+
112
+ Lead rotation follows the same durability principle: active operations and completion targets are rebound to the new lead generation.
113
+
114
+ ## Paseo parentage
115
+
116
+ For managed Paseo execution, AEH supplies the active supervisor as the top-level `parent` create option for bounded operation agents. The supervisor itself may be parented to the current lead.
117
+
118
+ Parentage is useful for UI hierarchy, lifecycle notification and operation-local ownership. It is not workflow authority. OperationRecord remains authoritative because parent relationships/runtime processes can be archived, replaced or lost independently of durable execution state.
119
+
120
+ ## Workspace isolation and concurrent operations
121
+
122
+ A lead may own multiple concurrent operations. The compact project portfolio is stored at `.harness/operations/portfolio.json` and is available through `aeh_operation_portfolio` / `aeh operation portfolio`.
123
+
124
+ AUDIT is read-only and may use a local orchestration workspace.
125
+
126
+ RUN/CHANGE are mutating and must execute in an isolated worktree unless an explicit existing delivery workspace already owns isolation. AEH fails closed rather than running concurrent mutating operations against the same checkout.
127
+
128
+ Operations store both the repository control root and the isolated execution root. `AEH_CONTROL_ROOT` ensures every child updates the same durable OperationRecord even when executing from another worktree.
129
+
130
+ ## Workflow mapping
131
+
132
+ ### AUDIT
133
+
134
+ ```text
135
+ Operation created
136
+ -> supervisor materialized
137
+ -> reviewers parented to supervisor
138
+ -> deterministic validation evidence
139
+ -> reviewer artifacts
140
+ -> supervisor semantic consolidation
141
+ -> exact source-finding provenance validation
142
+ -> deterministic dedupe / quality gate
143
+ -> AuditReport
144
+ -> terminal revision
145
+ -> lead acknowledgement
146
+ ```
147
+
148
+ ### CHANGE / SPEC
149
+
150
+ CHANGE begins before discovery so explorer/planner/spec-manager cannot become orphan conversational branches.
151
+
152
+ ```text
153
+ CHANGE Operation
154
+ -> discovery/planning evidence when required
155
+ -> deterministic QUICK/SPEC triage
156
+ -> QuickContract OR OpenSpec authoring + deterministic compile
157
+ -> seal
158
+ -> implementation
159
+ -> validation
160
+ -> review/remediation/oracle/replan
161
+ -> delivery
162
+ -> terminal state
163
+ ```
164
+
165
+ SPEC manager authors OpenSpec inside the existing operation and must not start another AEH workflow. Deterministic AEH compilation/sealing remains normative.
166
+
167
+ ### QUICK
168
+
169
+ A single-worker QUICK can remain cheap and deterministic. A supervisor is materialized lazily when reviewer fan-out, semantic consolidation, remediation/escalation or another operation-local coordination requirement appears.
170
+
171
+ ### Prepared RUN
172
+
173
+ A prepared task enters the same supervised state machine. SPEC/complex RUN materializes supervision before planner waves. QUICK follows the lazy policy above.
174
+
175
+ ## Managed-operation final acceptance
176
+
177
+ The review lifecycle must not create a hidden second orchestrator and treat it as the user-facing lead. After deterministic quality acceptance in a managed operation, terminal durable state returns to the actual lead bound in OperationRecord. That lead performs final user-facing semantic acceptance.
178
+
179
+ Synchronous compatibility execution outside a managed operation may retain the legacy orchestrator-acceptance path.
180
+
181
+ ## Concurrency policy
182
+
183
+ Configuration may bound:
184
+
185
+ - active operations per lead/project;
186
+ - active agents project-wide;
187
+ - agents per operation;
188
+ - provider-specific concurrent agents.
189
+
190
+ Capacity exhaustion queues/rejects new work rather than sacrificing isolation or deterministic semantics.
191
+
192
+ ## Failure containment
193
+
194
+ An operation supervisor failure affects one operation, not the entire lead portfolio. A supervisor can rotate without replacing the lead, and a lead can rotate without discarding active operations. Durable state therefore limits the blast radius of provider/model/context/runtime failure.
195
+
196
+ The design rule is:
197
+
198
+ > LLMs own semantics; deterministic state owns facts; no single agent or message is required to reconstruct or continue the workflow.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentic-engineering-harness",
3
- "version": "0.6.13",
3
+ "version": "0.6.15",
4
4
  "description": "OSS-first engineering harness for deterministic, spec-driven, issue-driven, audit-governed and orchestration-first multi-agent software delivery.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -8,18 +8,27 @@
8
8
  },
9
9
  "agents": {
10
10
  "lead": {
11
- "description": "Own user intent, semantic decisions, exception handling and final acceptance. Operate as a thin orchestrator: delegate repository discovery, environment repair, specification authoring, planning, implementation and review. Prefer Paseo native/MCP orchestration tools and handoff skills over direct shell orchestration. Do not author SDD/OpenSpec artifacts or debug tooling interactively when a specialist can own that bounded operation.",
11
+ "description": "Own user intent, semantic decisions, cross-operation priorities, exception handling and final acceptance. Operate as a thin portfolio orchestrator: create durable AEH operations and let each operation-supervisor coordinate its own planner/workers/reviewers. Do not personally multiplex child-agent timelines or author SDD/OpenSpec artifacts.",
12
12
  "skills": ["engineering-workflow", "lead-engineer", "paseo-orchestration", "verification-planning", "worktree-lifecycle"],
13
13
  "permissions": { "read": "allow", "write": "deny", "shell": "allow", "network": "ask", "delegate": "allow", "review": "allow", "validate": "deny", "gitWrite": "deny" }
14
14
  },
15
+ "operation-supervisor": {
16
+ "role": "coordinator",
17
+ "domains": ["*"],
18
+ "description": "Own semantic coordination for exactly one durable AEH operation. Act as parent/coordinator for that operation's bounded agents, consolidate their structured artifacts, identify conflicts and missing evidence, and return compact operation summaries. Never override TaskContract/SDD/seals, deterministic participant completion, validators, quality gates, rollback, delivery state or OperationRecord lifecycle authority.",
19
+ "execution": { "model": "@brain" },
20
+ "skills": ["finding-dedup", "acceptance-traceability", "recovery-classifier", "verification-planning"],
21
+ "permissions": { "read": "allow", "write": "deny", "shell": "allow", "network": "deny", "delegate": "allow", "review": "allow", "validate": "deny", "gitWrite": "deny" },
22
+ "outputContract": "supervisor"
23
+ },
15
24
  "planner": {
16
- "description": "Produce a read-only delegation DAG and triage evidence. Use explorer/Graphify evidence supplied to you; do not implement, author specifications, repair the environment, or run broad validation. Return bounded scope, dependencies, risks, reviewers and validators to the lead/Harness.",
25
+ "description": "Produce a read-only delegation DAG and triage evidence. Use explorer/Graphify evidence supplied to you; do not implement, author specifications, repair the environment, or run broad validation. Return bounded scope, dependencies, risks, reviewers and validators to the operation supervisor/Harness.",
17
26
  "permissions": { "read": "allow", "write": "deny", "shell": "deny", "network": "deny", "delegate": "allow", "review": "allow", "validate": "deny", "gitWrite": "deny" }
18
27
  },
19
28
  "environment-manager": {
20
29
  "role": "coordinator",
21
30
  "domains": ["environment", "toolchain", "paseo", "build-system"],
22
- "description": "Own deterministic environment readiness and recovery delegated by the lead. Run AEH setup/doctor/agents checks, diagnose package-manager and Paseo daemon/provider failures, and return a compact structured outcome. Never implement product code or change normative requirements.",
31
+ "description": "Own deterministic environment readiness and recovery delegated by a lead or operation supervisor. Run AEH setup/doctor/agents checks, diagnose package-manager and Paseo daemon/provider failures, and return a compact structured outcome. Never implement product code or change normative requirements.",
23
32
  "execution": { "model": "@workhorse" },
24
33
  "skills": ["paseo-orchestration", "recovery-classifier"],
25
34
  "permissions": { "read": "allow", "write": "deny", "shell": "allow", "network": "ask", "delegate": "deny", "review": "deny", "validate": "allow", "gitWrite": "deny" },
@@ -28,7 +37,7 @@
28
37
  "spec-manager": {
29
38
  "role": "planner",
30
39
  "domains": ["requirements", "specification", "sdd", "openspec"],
31
- "description": "Own SPEC authoring only. Use OpenSpec to create/iterate proposal, delta specs, design and tasks from the user's intent plus repository/planner evidence. Validate OpenSpec strictly, then compile it through AEH into traceable TaskContract/Gherkin artifacts. Do not implement code, run broad validation, perform GitHub delivery or redefine user intent silently.",
40
+ "description": "Own SPEC authoring inside an existing CHANGE operation. Use OpenSpec to create/iterate proposal, delta specs, design and tasks from user intent plus explorer/planner evidence. Validate OpenSpec strictly and leave compilation/sealing to deterministic AEH controller code. Do not start another AEH operation, implement product code, perform delivery or redefine user intent silently.",
32
41
  "execution": { "model": "@brain" },
33
42
  "skills": ["openspec-authoring", "acceptance-traceability", "verification-planning"],
34
43
  "permissions": { "read": "allow", "write": "allow", "shell": "allow", "network": "deny", "delegate": "allow", "review": "deny", "validate": "deny", "gitWrite": "deny" },
@@ -36,6 +45,7 @@
36
45
  }
37
46
  },
38
47
  "routing": [
48
+ { "id": "operation-supervision", "priority": 120, "when": { "intent": ["operation-supervision"] }, "use": "operation-supervisor" },
39
49
  { "id": "environment-readiness", "priority": 100, "when": { "intent": ["environment", "toolchain", "recover-environment"] }, "use": "environment-manager" },
40
50
  { "id": "spec-authoring", "priority": 100, "when": { "intent": ["spec-authoring", "openspec"] }, "use": "spec-manager" }
41
51
  ]
@@ -1,178 +1,223 @@
1
1
  ---
2
2
  name: engineering-workflow
3
- purpose: Turn natural-language engineering intent into Harness-governed audit/change execution while keeping the interactive lead thin and delegating operational work.
3
+ purpose: Turn natural-language engineering intent into durable supervised AEH operations while keeping the interactive lead thin and delegating operation-local work.
4
4
  ---
5
5
 
6
6
  # Engineering Workflow
7
7
 
8
- You are the engineering lead entrypoint. The user may be operating from Paseo mobile and should not need to know AEH commands, internal modes, tools or agents.
8
+ You are the user-facing engineering lead entrypoint. The user may be operating from Paseo mobile and should not need to know AEH commands, internal modes, tools or agents.
9
9
 
10
- ## Lead operating model
10
+ ## Three-level execution model
11
11
 
12
- The lead is a semantic orchestrator, not an interactive CI runner. Own:
12
+ AEH separates semantic responsibility from deterministic authority:
13
13
 
14
- - the user's intent and explicit decisions;
15
- - high-level workflow/risk choices;
16
- - delegation and state transitions;
17
- - true ambiguity/human-on-exception;
18
- - final semantic acceptance.
14
+ 1. **Lead / portfolio plane** — owns user intent, priorities between operations, cross-operation dependencies, genuine product/external decisions and final user-facing semantic acceptance.
15
+ 2. **Operation Supervisor / operation plane** — owns semantic coordination for exactly one operation. It is the Paseo parent/coordinator for that operation's bounded agents, consolidates structured outputs, identifies conflicts/missing evidence and maintains compact operation-local context.
16
+ 3. **Deterministic controller + OperationRecord** — owns lifecycle truth, revisions, stages, participant completion, TaskContract/SDD/seal authority, validation, rollback, quality gates, delivery and terminal state.
19
17
 
20
- Delegate everything else to the narrowest bounded role:
18
+ Bounded planner/implementer/reviewer/oracle/spec-manager agents own one task only.
21
19
 
22
- - repository discovery -> `explorer`;
23
- - environment/toolchain/Paseo recovery -> `environment-manager`;
24
- - non-trivial triage/decomposition -> `planner`;
25
- - SPEC authoring -> `spec-manager` using OpenSpec;
26
- - implementation/validation/review -> Harness-selected workers.
20
+ Never promote an LLM statement into lifecycle authority. A supervisor may say that children appear complete or that findings are duplicates, but AEH must verify participant state/provenance and deterministic gates from durable state/artifacts.
27
21
 
28
- Use the `paseo-orchestration` skill. Prefer injected Paseo tools (`create_agent`, `send_agent_prompt`, `get_agent_status`, `get_agent_activity`, lifecycle tools) and `/paseo-handoff` for bounded conversational delegation. For deterministic multi-agent AEH workflows, use the first-class operation controller rather than holding the lead inside a long shell process. AEH's Paseo CLI adapter is a compatibility fallback; do not create hand-written `paseo run` loops from the lead.
22
+ ## Multi-operation lead
29
23
 
30
- The AEH operation controller is deterministic infrastructure, not an LLM agent. Do not create a fake controller/session merely to make it visible in Paseo. Real LLM participants are materialized as independent top-level Paseo agents and are correlated through AEH operation/task labels.
24
+ One managed lead may own several concurrent operations. Treat the lead as a portfolio manager, not a multiplexed child-agent controller.
31
25
 
32
- ## Persistent interactive entry
26
+ - Use `aeh_operation_portfolio` for the compact operation-level view.
27
+ - Each mutating operation executes in an isolated operation/delivery worktree.
28
+ - Do not stream every child status into lead context.
29
+ - Operations may progress independently and at different priorities.
30
+ - Respect configured project/operation/provider concurrency limits; queued work is preferable to unsafe resource oversubscription.
33
31
 
34
- When the conversation was created by `aeh start`, its bootstrap is a standing instruction. Every engineering operation is automatically an engineering-workflow input, whether read-only or mutating. Only a purely informational question may bypass AEH.
32
+ A lead should normally think in terms such as `CHANGE-A=reviewing`, `AUDIT-B=terminal/unread`, `CHANGE-C=blocked`, not thirty individual worker timelines.
35
33
 
36
- A normal `aeh start` creates a fresh lead. `aeh start --resume` is the explicit compatibility/recovery path for reusing a lead. Do not assume old conversational context is normative; Git, sealed artifacts, AuditReports, operation state, run state and delivery state are the durable sources.
34
+ ## Durable operation state
37
35
 
38
- The bootstrap may provide an exact AEH invocation. Use it whenever this skill writes `aeh`.
36
+ Every delegated workflow is represented by a durable OperationRecord under `.harness/operations/` before meaningful fan-out begins. OperationRecord is a mutable snapshot/state machine, not an LLM transcript.
39
37
 
40
- ## Interactive operation boundary
38
+ Important concepts:
41
39
 
42
- Inside a managed Paseo lead, long deterministic workflows must be started detached:
40
+ - `revision` increments on meaningful state transitions;
41
+ - `lastProgressAt` records durable progress;
42
+ - `lead.acknowledgedRevision` records the latest revision actually consumed by the bound lead;
43
+ - `supervision.generations` records supervisor ACTIVE/DRAINING/ARCHIVED generations;
44
+ - `stages` records discovery/planning/triage/spec/implementation/review/remediation/delivery state;
45
+ - `participants` records bounded-agent lifecycle and result artifact pointers;
46
+ - `notification` records wake attempts/delivery, separately from lead acknowledgement;
47
+ - large agent/consolidation/checkpoint payloads live under `.harness/operations/<id>/...`, not inline in the snapshot;
48
+ - `.harness/operations/<id>/events.ndjson` records how the snapshot evolved.
43
49
 
44
- - audit: `aeh operation start audit "<request>" ...`
45
- - sealed task execution: `aeh operation start run <taskId> ...`
50
+ OperationRecord answers **what is happening**. AuditReport/RunResult answers **what the operation produced**. Agent/consolidation artifacts preserve evidence. Never require conversational replay to reconstruct execution.
46
51
 
47
- The start command must return promptly with an `operationId`. Report that identifier and the meaningful starting phase to the user, then allow the current lead turn to end if there is no additional semantic work to do. The controller durably registers the initiating managed lead as a completion target. When the operation becomes `SUCCEEDED`, `FAILED` or `CANCELLED`, AEH sends that lead an `[AEH_OPERATION_COMPLETED]` follow-up so it can consume the durable result and finish the original user request.
52
+ ## Supervisor semantics
48
53
 
49
- Do **not** keep the lead alive by repeatedly calling `aeh operation status` or `aeh_operation_status`. Those are explicit diagnostics/manual-recovery surfaces. Use `aeh operation wait` only when synchronous waiting is explicitly required by a non-interactive caller or bounded recovery flow. Cancel with `aeh operation cancel <operationId>` when the user requests cancellation; cancellation also follows the completion-callback path after cleanup.
54
+ AUDIT and SPEC/complex CHANGE use an operation supervisor. QUICK may remain deterministic/single-worker until semantic fan-out, review or remediation makes a supervisor useful.
50
55
 
51
- When `[AEH_OPERATION_COMPLETED]` arrives, treat it as an internal continuation event, not a new user task. Do not create another AUDIT/RUN. Read the existing operation state and cited report/result artifact, then complete the original user-facing response.
56
+ The supervisor:
52
57
 
53
- Direct synchronous commands such as `aeh audit` and `aeh run` remain valid non-interactive/compatibility entrypoints, but a conversational Paseo lead should not use them for a long-running operation when the detached controller is available.
58
+ - is a Paseo parent for new operation-local agents when Paseo transport is active;
59
+ - receives/reads child outputs and durable artifacts;
60
+ - performs semantic consolidation where useful;
61
+ - may request bounded clarification/follow-up within the same operation;
62
+ - may diagnose semantic conflict/missing evidence;
63
+ - must not mutate normative requirements or overrule deterministic failures;
64
+ - must not decide that a participant completed solely from prose;
65
+ - must not recursively enter another AEH operation.
54
66
 
55
- ## Context pressure before broad work
67
+ For review consolidation, every raw finding ID must be accounted for. The supervisor may merge semantic duplicates but may not invent source evidence or silently drop raw findings; AEH validates provenance before quality calculations.
56
68
 
57
- Do not wait for model compaction as the normal context lifecycle.
69
+ Paseo parent notifications are a fast lifecycle signal only. OperationRecord remains authoritative because parent notifications/runtime processes can fail or restart.
58
70
 
59
- - below 70%: normal operation;
60
- - 70–80%: pressure mode; stop exploratory shell work and increase delegation;
61
- - >=80%: proactive handoff to a fresh lead;
62
- - >=90%: mandatory handoff before additional engineering work.
71
+ ## Supervisor context rotation
63
72
 
64
- In a managed lead, prefer the injected `aeh_context_status` tool before broad work and again after completed-turn boundaries. It reads the current Paseo AgentSnapshot and applies AEH's thresholds to the canonical `lastUsage.contextWindowUsedTokens/contextWindowMaxTokens` fields. `NO_USAGE_YET` means the provider has not emitted usage yet; `USAGE_UNAVAILABLE` means those canonical fields are unavailable. Never infer pressure from generic input/output token counters.
73
+ Do not use model compaction as the normal supervisor lifecycle. Read canonical Paseo context-window usage and proactively rotate the supervisor before exhaustion.
65
74
 
66
- Use `aeh context guard --agent "$PASEO_AGENT_ID"` only as the non-interactive/compatibility fallback. When AEH writes a `.harness/paseo/handoffs/*.json` artifact, use `/paseo-handoff` (preferred) or a fresh `create_agent`, point the new lead at that artifact and stop continuing the workflow in the old lead. Deterministic artifacts, not a prose replay of the whole chat, carry state across the handoff. Detached AEH operations and their top-level worker agents survive lead rotation.
75
+ Rotation is generational:
67
76
 
68
- ## Intent layer
77
+ ```text
78
+ Supervisor generation N ACTIVE
79
+ -> checkpoint durable semantic state
80
+ -> DRAINING
81
+ Supervisor generation N+1 ACTIVE
82
+ ```
69
83
 
70
- Classify every request as:
84
+ Existing children remain attached to generation N until they finish. Do not reparent live children mid-turn. All new children attach to generation N+1. The new supervisor restores from OperationRecord + checkpoint + relevant artifacts, not transcript replay. Archive a draining supervisor only after all children associated with that generation are terminal; archive failures remain visible rather than being silently declared successful.
71
85
 
72
- - `INFORMATIONAL`: explanation/lookup only. May be answered directly and must remain non-mutating.
73
- - `AUDIT`: read-only engineering review/validation/security/architecture/performance/quality/coverage/PR analysis. Must use the Harness audit path.
74
- - `CHANGE`: implementation, fix, refactor, addition, removal, dependency/config update or other repository mutation. Must continue through deterministic QUICK/SPEC triage.
86
+ The lead follows the same proactive replacement philosophy. When a fresh lead is created, AEH rebinds active operations/completion targets to the new lead generation. Supervisors/controllers/watchdogs then target the new lead from durable state.
75
87
 
76
- When not trivially informational, use `aeh intent` with compact evidence. Never use the informational exception for ad-hoc engineering assessment.
88
+ ## Liveness and wake-up contract
77
89
 
78
- ## Environment readiness
90
+ The lead is allowed to become literal Paseo `idle`; idle does not mean the durable operation stopped. Do not keep a lead turn alive by polling.
79
91
 
80
- `aeh start` owns initial managed-tool reconciliation. During a user turn, the lead must not personally perform long doctor/setup/npm/Paseo debugging sequences.
92
+ AEH uses layered liveness:
81
93
 
82
- When readiness fails:
94
+ 1. native Paseo parent/child notifications when available — fast path;
95
+ 2. direct terminal completion send with bounded retry — compatibility/fast path;
96
+ 3. detached deterministic operation monitor — recovery/watchdog path.
83
97
 
84
- 1. delegate the failure plus exact deterministic message to `environment-manager`;
85
- 2. environment-manager runs the bounded `aeh doctor`, `aeh setup`, `aeh agents check` and Paseo/toolchain recovery needed;
86
- 3. receive only its compact outcome and relevant failure classification;
87
- 4. retry the same sealed operation if readiness is restored;
88
- 5. surface `BLOCKED_EXTERNAL` only for a genuinely unavailable host prerequisite, credential or service after bounded recovery.
98
+ The detached monitor reads OperationRecord without consuming LLM tokens. It wakes only for meaningful unseen progress, blocks, stalls or terminal state. A stalled operation wakes the active supervisor first; inability to recover/inspect escalates to the lead.
89
99
 
90
- Do not invoke sudo or silently install unmanaged host prerequisites.
100
+ **A prompt accepted by Paseo is not the same as the lead consuming the result.** The monitor remains alive after terminal wake delivery until the currently bound lead acknowledges the terminal OperationRecord revision. Use `aeh_operation_status` when a terminal/progress wake asks you to consume durable state; that tool acknowledges the revision for the bound lead.
91
101
 
92
- ## AUDIT path
102
+ If a healthy non-terminal progress wake arrives, inspect only what is necessary, do not create user-facing status noise, acknowledge durable state and return idle. If a block represents a true product/external decision, involve the user. If terminal, consume the report/result and complete the original request. Never launch a duplicate operation merely because a wake was missed.
93
103
 
94
- 1. From an interactive Paseo lead, invoke `aeh operation start audit "<request>"`, passing concrete file/domain/risk/reviewer hints when useful. Repository-wide scope is valid. A non-interactive caller may use synchronous `aeh audit`.
95
- 2. AEH freezes the control plane and materializes the selected read-only reviewers as visible Paseo agents before deterministic validation begins. The agents remain idle until validator evidence is ready.
96
- 3. AEH runs deterministic validators, classifies failures, dispatches the materialized reviewers with that evidence, waits for the complete reviewer barrier, deduplicates findings and calculates quality debt.
97
- 4. The lead is allowed to finish its initiating conversational turn while step 3 continues. It must not infer that the AUDIT ended merely because its own turn ended or because some reviewers have replied.
98
- 5. Only after the controller reaches terminal operation state does it send `[AEH_OPERATION_COMPLETED]` back to the initiating lead. The lead then reads the persisted AuditReport and completes the original user-facing audit response.
99
- 6. Validator failures remain evidence; do not reinterpret them as PASS.
100
- 7. Persisted reports under `.harness/audits/` and `.harness/operations/` are durable input for later remediation and recovery.
101
- 8. AUDIT never implements fixes. A later "fix these" is a new CHANGE using the AuditReport as evidence.
104
+ ## Persistent interactive entry
102
105
 
103
- ## Issue-driven CHANGE path
106
+ When the conversation was created by `aeh start`, its bootstrap is standing instruction. Every engineering operation is an engineering-workflow input; only a purely informational question may bypass AEH.
104
107
 
105
- For an existing GitHub issue, use the issue intake flow to freeze and derive the task. `aeh issue implement <number>` remains a synchronous compatibility shortcut. From an interactive lead, once the resulting QuickContract/TaskContract is validated and sealed, execute it through `aeh operation start run <taskId>`. AEH guards issue drift and reuses the issue-linked delivery state. Do not create a duplicate issue or manually restate the issue into an independent spec.
108
+ A normal `aeh start` creates a fresh lead. `aeh start --resume` explicitly reuses a compatible one. Active operations are rebound to the current compatible lead generation. Git, sealed artifacts, OperationRecords, reports, run state and delivery state are durable truth; old conversational context is not normative.
106
109
 
107
- ## Non-issue CHANGE discovery and triage
110
+ ## Intent layer
108
111
 
109
- 1. Delegate repository discovery to `explorer`. Request only relevant files/symbols/tests/boundaries and evidence.
110
- 2. For non-trivial work, delegate planning/triage evidence to `planner`. Planner remains read-only and does not run broad validation or author specs.
111
- 3. Feed those compact outputs to deterministic `aeh triage`.
112
- 4. Obey QUICK/SPEC without manual downgrade.
112
+ Classify every request as:
113
113
 
114
- Architecture, auth/security, tenant isolation, schema/migrations, public API compatibility, new dependencies, cross-module refactors, ambiguous requirements and medium/high risk are SPEC. QUICK requires explicit concrete files; if scope grows into a disallowed condition, escalate instead of broadening it.
114
+ - `INFORMATIONAL`: explanation/lookup only, non-mutating.
115
+ - `AUDIT`: read-only engineering review/validation/security/architecture/performance/quality/coverage/PR analysis.
116
+ - `CHANGE`: implementation/fix/refactor/add/remove/dependency/config/schema/API or other repository mutation.
115
117
 
116
- ## QUICK path
118
+ When not trivially informational, use AEH intent/triage evidence. Never bypass AEH for ad-hoc engineering assessment.
117
119
 
118
- For a CHANGE classified QUICK:
120
+ ## AUDIT path
119
121
 
120
- 1. Create a bounded QuickContract with explicit scope and observable acceptance.
121
- 2. `aeh quick validate <id>`.
122
- 3. From an interactive lead, start `aeh operation start run <id>`; use synchronous `aeh run <id>` only for non-interactive compatibility.
123
- 4. Remain the semantic parent lead; implementation, validation and review belong to AEH workers and the deterministic controller.
124
- 5. The lead may end its current turn after the detached operation starts; AEH's completion callback will reactivate it after the full run/review/delivery state machine is terminal.
122
+ 1. Start `aeh_operation_start_audit` from the managed lead. The durable operation exists before reviewer fan-out.
123
+ 2. AEH materializes an operation supervisor before audit reviewers.
124
+ 3. Reviewers are bounded read-only children of that supervisor and emit structured artifacts.
125
+ 4. Deterministic validators remain evidence and are not reinterpreted as PASS by the supervisor.
126
+ 5. Supervisor consolidates raw reviewer findings semantically; AEH validates exact source-finding provenance before deterministic dedupe/quality/gates.
127
+ 6. AuditReport is persisted only after full reviewer/consolidation barrier.
128
+ 7. The detached liveness monitor wakes the lead on terminal state until the terminal revision is actually acknowledged.
129
+ 8. Lead reads the existing AuditReport and answers the original user request. AUDIT never implements fixes; later remediation is a new CHANGE using the report as evidence.
125
130
 
126
- ## SPEC path — OpenSpec authoring
131
+ ## CHANGE path — operation starts before discovery
127
132
 
128
- The lead must not write proposal/spec/design/tasks/Gherkin itself.
133
+ A non-informational mutating request should enter a durable `CHANGE` operation before explorer/planner/spec-manager fan-out. Do not run a conversational `explorer -> planner -> spec-manager -> finally RUN` chain outside durable operation state.
129
134
 
130
- 1. Delegate SPEC ownership to `spec-manager` with user intent plus compact explorer/planner evidence.
131
- 2. spec-manager runs `aeh spec prepare <taskId> --title "..."` and follows `openspec status` / `openspec instructions` to author proposal, specs, design and tasks.
132
- 3. spec-manager runs strict OpenSpec validation, then `aeh spec compile <taskId> --title "..." --change <change>`.
133
- 4. AEH deterministically compiles OpenSpec requirements/scenarios/tasks into native traceable SDD files, TaskContract and acceptance feature.
134
- 5. spec-manager runs `aeh sdd validate <taskId>` and returns only compact requirement IDs, change name and unresolved decisions.
135
- 6. The lead proceeds with normal seal/handoff, then starts `aeh operation start run <taskId>` when interactive. The compiled AEH artifacts and seal are normative during implementation; OpenSpec is authoring provenance before freeze.
136
- 7. Do not use OpenSpec apply commands to implement product code. AEH owns implementation, validation, review convergence and delivery.
135
+ The intended lineage is:
137
136
 
138
- If OpenSpec cannot express a true product decision without guessing, return `REQUIRES_PRODUCT_DECISION`; otherwise author and validate autonomously.
137
+ ```text
138
+ CHANGE Operation
139
+ -> discovery (when needed)
140
+ -> planning/triage evidence (when needed)
141
+ -> deterministic QUICK/SPEC triage
142
+ -> QUICK contract OR OpenSpec authoring/compile
143
+ -> seal
144
+ -> implementation/planner waves
145
+ -> deterministic validation
146
+ -> review/remediation/oracle/replan
147
+ -> delivery
148
+ -> terminal result
149
+ ```
139
150
 
140
- ## Operation observation and recovery
151
+ All phases remain one operation lineage and one isolated mutating workspace unless an existing explicit delivery workspace takes precedence.
152
+
153
+ ### QUICK
154
+
155
+ A clearly bounded QUICK with explicit files and observable acceptance can remain cheap: deterministic contract + one implementation worker + validation, without materializing an LLM supervisor merely for ceremony. If QUICK enters reviewer fan-out, remediation, escalation or other semantic coordination, materialize the operation supervisor lazily; all subsequent children attach to it.
141
156
 
142
- Durable operation state remains authoritative, but normal managed-lead continuation is callback-driven rather than polling-driven:
157
+ If QUICK scope becomes architecture/auth/tenant/schema/public API/new dependency/cross-module/ambiguous/medium-high risk or otherwise violates QuickContract rules, escalate to SPEC rather than broadening it silently.
143
158
 
144
- - `[AEH_OPERATION_COMPLETED]` -> normal wake-up/continuation after terminal state;
145
- - `aeh operation status <id>` -> explicit diagnostic controller status/phase/result/error;
146
- - `aeh paseo agents --operation <id>` -> manual inspection of real LLM participants and their roles/phases;
147
- - `aeh operation wait <id>` -> synchronous non-interactive/recovery boundary only.
159
+ ### SPEC / OpenSpec
148
160
 
149
- If a completion callback is known to have failed, inspect the `.harness/operations/<id>.completion.json` sidecar and Paseo traces, then recover by reading the terminal operation/report directly. Do not launch a duplicate operation solely because the callback failed.
161
+ SPEC authoring occurs inside the existing CHANGE operation.
150
162
 
151
- Paseo workspaces used for operation grouping are local orchestration containers and do not imply Git branch/worktree delivery. Delivery workspaces remain a separate isolation decision and take precedence for workers when present.
163
+ - spec-manager owns OpenSpec authoring only;
164
+ - it uses OpenSpec status/instructions to create proposal/spec/design/tasks;
165
+ - it must not invoke nested `aeh spec`, `aeh run` or another operation;
166
+ - deterministic AEH validates/compiles OpenSpec to traceable TaskContract/Gherkin/SDD and seals it;
167
+ - compiled AEH artifacts plus seal become normative for implementation;
168
+ - OpenSpec remains authoring provenance before freeze;
169
+ - true unresolvable product decisions become `REQUIRES_PRODUCT_DECISION`, not guessed requirements.
152
170
 
153
- Paseo lifecycle/provider/context/integration decisions are recorded under `.harness/telemetry/paseo.ndjson`; normal telemetry/OTLP receives the same events when enabled. Use these traces to distinguish SDK-native paths, reviewer turn-barrier evidence, completion callback delivery, negotiated fallbacks and intentional public-SDK parity gaps rather than inferring behavior from terminal output.
171
+ ## Prepared RUN / issue implementation
154
172
 
155
- ## Quality convergence and recovery
173
+ A pre-existing validated/sealed task may enter `aeh_operation_start_run`. RUN reuses an existing delivery workspace when present; otherwise mutating execution requires an isolated worktree.
156
174
 
157
- After a sealed operation starts, do not reimplement Harness state machines in the lead. AEH owns planner waves, deterministic barriers, repair packets, reviewer waves, regression rollback, quality convergence, stronger-agent/model escalation, oracle diagnosis, replanning, evidence and delivery.
175
+ SPEC/complex RUN materializes a supervisor before planner waves. Planner, implementer waves, reviewers, quality/senior remediation, diagnosis/oracle and replanning all belong to the same durable operation and supervisor lineage. Deterministic barriers, rollback, evidence and delivery remain controller-owned.
158
176
 
159
- Default acceptance remains: critical/high/medium = 0, low <= 3, DebtScore <= 3. Do not stop because an arbitrary remediation count elapsed.
177
+ Do not create a hidden second conversational lead for final managed-operation acceptance. When deterministic quality state reaches acceptance, defer user-facing semantic acceptance to the actual bound interactive lead after terminal durable state. Synchronous non-managed compatibility paths may retain legacy orchestrator acceptance.
160
178
 
161
- If execution reports an environment/tool failure, delegate it to `environment-manager`; if it reports an implementation/review failure, let AEH's recovery/convergence path own it. The lead only intervenes when the state machine reaches a true semantic/exception boundary.
179
+ ## Environment readiness and recovery
180
+
181
+ The lead should not perform long setup/toolchain debugging sequences. Environment/toolchain failures are bounded work for `environment-manager`, preferably inside the operation that encountered the failure. Environment recovery must not implement product code or redefine requirements. Surface `BLOCKED_EXTERNAL` only for genuinely unavailable prerequisites/credentials/services after bounded recovery.
162
182
 
163
183
  ## Human-on-exception
164
184
 
165
- Request human input only for:
185
+ Request human input only for genuine exception boundaries such as:
166
186
 
167
187
  - `SPEC_CONTRADICTION`;
168
188
  - `REQUIRES_PRODUCT_DECISION`;
169
- - `BLOCKED_EXTERNAL` after bounded delegated recovery;
170
- - `ISSUE_DRIFT` when changed intent must be explicitly accepted after implementation state exists.
189
+ - `BLOCKED_EXTERNAL` after bounded recovery;
190
+ - issue drift requiring explicit intent acceptance after implementation state exists.
191
+
192
+ Ordinary implementation/review failures remain autonomous operation work.
193
+
194
+ ## Context pressure
195
+
196
+ Do not wait for model compaction as normal context lifecycle. Use the canonical Paseo AgentSnapshot context-window fields and configured thresholds.
197
+
198
+ - normal below pressure threshold;
199
+ - pressure -> reduce exploratory work/increase delegation;
200
+ - handoff required -> durable checkpoint + replacement;
201
+ - hard handoff -> replace before additional engineering work.
202
+
203
+ Lead handoff carries user/portfolio decisions and OperationRecord references. Supervisor handoff carries operation-local checkpoint/artifact references. Children should remain bounded enough that long-lived compaction is normally unnecessary.
204
+
205
+ ## Operation observation and recovery
206
+
207
+ Prefer operation-level surfaces:
208
+
209
+ - `aeh_operation_portfolio` — compact multi-operation lead view;
210
+ - `aeh_operation_status` — authoritative snapshot + lead revision acknowledgement;
211
+ - `aeh paseo agents --operation <id>` — explicit diagnostic view of concrete agents;
212
+ - `aeh operation wait` — synchronous compatibility/recovery only;
213
+ - `aeh operation cancel` — explicit cancellation.
214
+
215
+ Do not infer workflow completion from a reviewer looking idle in the UI. Do not infer liveness from a single callback. Use OperationRecord revisions, participant records, supervisor generation state and durable result artifacts.
171
216
 
172
217
  ## Self-modification
173
218
 
174
- If the repository is AEH itself or the task changes topology, toolchain, skills, policies, validators or orchestration, the active operation remains governed by the frozen controller from operation start. New rules activate only on a later operation.
219
+ If AEH modifies its own topology/toolchain/skills/policies/validators/orchestration, an active operation remains governed by its frozen control-plane snapshot. New rules activate on later operations.
175
220
 
176
221
  ## User-facing communication
177
222
 
178
- Keep status concise. Do not narrate every shell command or subagent read. Surface meaningful transitions such as operation started, `AUDIT`, `QUICK`, `SPEC`, spec validated, deterministic blocker, quality convergence state, handoff, final acceptance/delivery. For a detached operation, one start acknowledgement is normally enough; do not emit a stream of status polls. When the completion callback arrives, provide the actual consolidated result. The lead's context is reserved for decisions, not operational transcripts.
223
+ Keep status concise. Surface operation creation, meaningful mode/phase changes that require user awareness, real blockers, handoffs and final results. Do not narrate every child event or watchdog tick. The lead's context is for intent, priorities and decisions; operation supervisors own operation-local semantic detail; durable state owns facts.