Skip to content

Commit 63a752d

Browse files
authored
Merge pull request #250 from LeXwDeX/feat/dag-routing
fix(dag): make workflow routing deterministic
2 parents da5f852 + eaf22bc commit 63a752d

14 files changed

Lines changed: 455 additions & 367 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# AHE 提示词修订 — DAG Orchestration Router
2+
3+
## 1. 范围与职责
4+
5+
让父对话从实时模板库选择一个主参考和自治档位,再把必要的跨领域保障组合进同一个 YAML DAG。
6+
7+
## 2. 组件地图(修改前)
8+
9+
- 常驻 Router 决定是否使用 DAG 和积木顺序,但不知道配置仓库已经收敛为七个领域及 `full`/`lite`
10+
- 配置仓库 README 保存了档位规则,但 README 不在运行时模板发布包内。
11+
- `guide(topic="patterns")` 仍提供 Deep Review、Large Engineering 等另一套路线名称。
12+
- `workflow(action="list")` 只显示名称、标题和大小,隐藏了模板的目标。
13+
14+
## 3. 评估笔记
15+
16+
YAML 字段契约和文件式 authoring 已经明确;缺口在选择信息的所有权和可见性。修订不增加 Schema、积木种类或运行时状态,只删除平行路由语言并让现有模板目标进入选择面。
17+
18+
## 4. 失败模式类
19+
20+
### P1 — 路由权威分裂
21+
22+
- 证据:新模板目录只在配置 README 中,常驻 Router 和 patterns guide 使用两套旧分类。
23+
- 根因:模板目录更新没有同步到模型真正常驻的工作流指导层。
24+
- 组件层级:工作流指导。
25+
26+
### P2 — 参考库被新建路径绕过
27+
28+
- 证据:`/dag-flow` 明示优先 fresh blocks;用户反馈表现为模型猜测 YAML 和路线。
29+
- 根因:命令入口没有先读取实时模板目录。
30+
- 组件层级:命令工作流指导。
31+
32+
### P3 — 候选信息不足
33+
34+
- 证据:`list` 输出缺少 `config.objective`,必须逐个 `read` 才能判断目标。
35+
- 根因:工具输出契约没有携带模板已经声明的选择证据。
36+
- 组件层级:工具输出契约。
37+
38+
### P4 — lite 子节点越权选路
39+
40+
- 证据:七个 lite 模板曾要求第一个子节点自行“升级 full”,但子节点既不拥有路由权,也不能阻止后续写入。
41+
- 根因:档位前提只写成自然语言提示,没有连接到现有 verdict condition 与父会话 wake。
42+
- 组件层级:配置模板拓扑、配置 CI 契约。
43+
44+
## 5. 变更清单
45+
46+
### chg-1 — 一个主参考加一条风险升级规则
47+
48+
- 失败证据:P1。
49+
- 根因:常驻 Router 不认识领域交付物和档位边界。
50+
- 针对性修复:按最终交付物选择一个主参考;仅在全部低风险条件成立时使用 `lite`,任一高风险信号选择 `full`
51+
- 预测影响:领域和档位选择稳定;风险是边界任务升级为 `full`,由模板裁剪抵消成本。
52+
- 组件层级:工作流指导。
53+
54+
### chg-2 — patterns 只处理跨领域冲突
55+
56+
- 失败证据:P1。
57+
- 根因:按需 guide 又定义了一套完整路线。
58+
- 针对性修复:删除六个旧 playbook;只说明如何在一个主参考中加入最小 secondary assurance。
59+
- 预测影响:同一目标不再拼接两套完整路线或启动多个 workflow。
60+
- 组件层级:按需工作流指导。
61+
62+
### chg-3 — 库优先并显示 objective
63+
64+
- 失败证据:P2、P3。
65+
- 根因:命令偏向从零生成,候选列表缺少目标。
66+
- 针对性修复:常驻 Router 先 `list`、再 `read``/dag-flow` 只委托 Router;列表显示每个模板的 `objective`
67+
- 预测影响:已发布参考会先于自由生成被采用;无匹配参考时仍可使用 blocks 逃生口。
68+
- 组件层级:命令工作流指导、工具输出契约。
69+
70+
### chg-4 — lite 前提失效时先阻断
71+
72+
- 失败证据:P4。
73+
- 根因:子节点同时承担取证和重新选路,且没有结构化停止条件。
74+
- 针对性修复:七个 lite 模板在取证后增加 reporting review gate;所有后续路径均受 gate 支配,非 `ACCEPT` 会唤醒父会话并跳过后续。子节点和按需 guide 只要求 verdict、证据及 required actions;父 Router 在 workflow 完成后决定是否用新节点 ID `extend`
75+
- 预测影响:运行中发现迁移、并发、安全或发布边界时不会继续写入,也不会由子节点猜测 full 路线。
76+
- 组件层级:配置模板拓扑、配置 CI 契约。
77+
78+
### chg-5 — Router 单独拥有执行模式与控制选择
79+
80+
- 失败证据:按需 policy/interface guides 重复 direct、task、workflow 选择规则,并曾要求 child 输出 `next_action`
81+
- 根因:路由规则被放进三个组件,加载按需 guide 会覆盖 resident Router 的较新判断。
82+
- 针对性修复:policy/interface 只引用 Router 并保留各自的 tier、YAML、checkpoint 与恢复契约;工具字段和示例只接受 `list` 返回的精确名称或 YAML 路径;catalog 拒绝 child 中的 route 名、`next_action` 和具体控制操作。
83+
- 预测影响:加载任何 guide 不会改变已选择的执行模式;child 只能报告证据和 required actions。
84+
- 组件层级:resident Router、按需 guides、配置 CI 契约。
85+
86+
## 6. 证伪计划
87+
88+
- 小型明确功能应选 development-lite;出现跨模块迁移时应翻转为 development-full。
89+
- 可复现单点缺陷应选 debug-lite;未知根因或并发/持久化边界应翻转为 debug-full。
90+
- 需要修改代码的安全问题应保持 development/debug 主参考并加入安全保障;只要安全报告时才以 security-audit 为主。
91+
- 删除 gate→qualification 边、把 writer 放在 gate 前、绕过 gate 支配链或让 child 选择 full route 时,catalog 契约测试必须失败。
92+
- 删除 `list` 的 objective 输出后,列表契约测试必须失败;删除 Router 的领域或风险规则后,提示词契约测试必须失败。
93+
- 删除 lite gate 的 parent report、让后续节点绕过 gate,或重新加入子节点选路文本时,配置目录门禁必须失败。
94+
- 若实测仍跳过模板库,先回滚并重写 chg-3 的入口约束,不在 Router 叠加更多同义规则。

packages/core/src/plugin/command/dag-flow.txt

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ Otherwise apply the resident Orchestration Router and route the
99
request through one consolidated graph. `/dag-flow` explicitly selects DAG
1010
execution; the router still owns any material Decision Checkpoint.
1111

12-
Prefer composable blocks for a fresh flow. Load
13-
`workflow(action="guide", topic="blocks")` only if the block contract is not
14-
already in context. Write one-off work to a task-local YAML file and pass its
15-
`spec_path`; a matching saved workflow name is also a valid `spec_path`. Preserve
16-
the task, user constraints, named roles, read-only limits, acceptance checks,
17-
and confirmed decisions in the objective and block instructions.
12+
Apply the Router's selected reference or fresh-block path. Preserve the task,
13+
user constraints, named roles, read-only limits, acceptance checks, and
14+
confirmed decisions in the objective and block instructions, then pass the
15+
task-local YAML file's `spec_path`.
1816

1917
Validate the YAML path, then call the workflow tool with `action=start` in the
2018
first response after the route is ready. Printing a plan or YAML does not start it. Never invent
Lines changed: 55 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -1,140 +1,55 @@
1-
# Orchestration Domains
2-
3-
Productized workflow playbooks for recurring heavy-task domains. Each playbook
4-
composes the existing primitives — profiles, review lifecycle, actionable
5-
checkpoints, bounded repair, and the pause-first replan protocol — into a
6-
repeatable graph shape. Resolve every role below as a capability slot per Role
7-
Resolution: prefer a configured agent whose contract matches (an explore-style
8-
scout, a reasoner-style logic prober, a review-style verdict gate, a
9-
verify-style test runner), fall back to `explore`, `build`, or `general`.
10-
11-
Every playbook is a mix of the two accuracy axes from the Tiered Orchestration
12-
Doctrine — **breadth** (concurrent independent slices, standard tier) and
13-
**depth** (verdict-gated iteration, advanced-tier judge) — at a different
14-
ratio. Each heading names its ratio. Place decomposition, gate, verification,
15-
and arbitration nodes on the advanced tier (`required: true` or a
16-
`review`/`review-*` worker); leave the fan-out volume on the standard tier.
17-
18-
## The Simulated Audit Loop
19-
20-
Iteration in a DAG is NOT a cyclic edge and NOT a harness loop. It is a
21-
verdict-driven replan wave — the depth axis in its pure form:
22-
23-
1. An audit node declares `output_schema` with a normalized `verdict` and
24-
`report_to_parent: true`.
25-
2. On `REJECT` or `REVISE`, the wake delivers findings to the parent. Per the
26-
Verdict Disposal Contract the parent MUST act in that turn: it issues
27-
`control(pause)`, then `control(replan)` appending a correction node and a
28-
NEW audit node under NEW ids (terminal nodes are immutable), wires
29-
`depends_on` forward, then `control(resume)`. If the audit node was the
30-
terminal leaf, `extend` a fresh audit wave instead.
31-
3. Repeat until the audit returns `ACCEPT`. The loop is bounded by
32-
`max_node_replan_attempts` and `max_total_nodes` — on ceiling breach stop
33-
with `BLOCKED` and report the residual findings instead of retrying the
34-
identical plan.
35-
36-
Every playbook below that says "audit loop" means exactly this mechanism.
37-
38-
## Playbook: Deep Review
39-
40-
Ratio: breadth then depth. Multi-role adversarial review of whether a code
41-
structure or design is sound, scaled by the Depth Ladder.
42-
43-
- **Breadth wave** — fan out 3+ reviewers with genuinely conflicting mandates:
44-
a prosecutor (argues the structure is wrong — coupling, hidden invariants,
45-
failure modes), a defender (argues the current shape is justified —
46-
constraints, history, cost of change), and dimension specialists
47-
(architecture, correctness, testability) as scope demands. Every reviewer
48-
MUST cite file:line evidence and list what it could not confirm as
49-
`unverified_claims`.
50-
- **Verification wave (mandatory for module scope and larger)** — one or more
51-
verify-style nodes check the disputed and `unverified_claims` items against
52-
the actual code before any verdict. This is what separates a review from a
53-
poll of opinions; skipping it lets an unproven assertion become a finding.
54-
- **Arbitration (advanced tier)** — fan in to one arbiter that rules
55-
finding-by-finding on the VERIFIED evidence, not merely concatenating
56-
reviews, and emits the actionable checkpoint shape (`verdict`, `findings`,
57-
`required_actions`, `next_action`).
58-
- Pre-implementation structure reviews are `design` phase. Reviewing an actual
59-
change requires the diff-phase hard contract:
60-
`implementation → verification(PASS) → diff review` with fingerprint echo.
61-
- **Depth wave** — on `REVISE`/`REJECT`, drive corrections and concurrent
62-
deep-dives into the confirmed problem areas through the audit loop. The
63-
arbiter's report is the start of this wave, never the end of the task.
64-
65-
## Playbook: Deep Speculation
66-
67-
Ratio: breadth of parallel probes, then depth through the revision loop.
68-
Prophesy a whole design document — stress-test it end to end and emit an
69-
automated verdict with zero human gates in the middle.
70-
71-
- Internalized grill method, run as graph roles instead of user Q&A: parallel
72-
nodes over the same document — a logic simulator (walk the described system,
73-
surface contradictions and boundary gaps), an adversarial interrogator
74-
(produce the hardest material questions: hidden assumptions, falsifiers,
75-
failure modes, evidence quality), and an alternatives prober (steelman one
76-
competing shape).
77-
- A responder node answers the interrogation strictly from the document plus
78-
codebase evidence, marking each question ANSWERED / GAP / CONTRADICTION.
79-
- An arbiter synthesizes everything into a structured prophecy: verdict,
80-
ranked risks, unresolved gaps, and a concrete revision list — then the audit
81-
loop applies revisions and re-speculates until ACCEPT.
82-
- Fully automated: no admission QA rounds with the user mid-flight. Reserve
83-
interactive `GRILL` admission for before the workflow starts.
84-
85-
## Playbook: Large Engineering
86-
87-
Ratio: iterated breadth and depth — parallel packages, each gated, plus a
88-
final audited review. Turn an execution document (todo list, work ledger, or
89-
spec) into audited, parallel-safe delivery.
90-
91-
1. **Deep analysis** — scout nodes map the affected surface; an analyst node
92-
decomposes the document into work packages with explicit dependency edges
93-
and disjoint write sets (the tickets: each package states its blocking
94-
edges, not a bare list).
95-
2. **Orchestrate** — compile the packages into a graph: independent packages
96-
fan out in parallel, dependent ones serialize, propose-then-assemble where
97-
write sets may overlap.
98-
3. **Audit the plan** — a plan-audit node checks the decomposition itself:
99-
missing edges, false parallelism, unstated assumptions, acceptance criteria
100-
per package. `REJECT` re-orchestrates via the audit loop until the plan
101-
passes.
102-
4. **Execute** — run the audited graph with the develop-profile phases each
103-
package still needs; verification consumes each implementation before any
104-
diff review.
105-
5. **Final adversarial review** — the Deep Review playbook over the assembled
106-
result, with its own audit loop.
107-
6. **Deliverable** — a final assembler emits the outcome report: shipped
108-
packages, evidence, residual risks.
109-
110-
## Playbook: Solution Bake-off
111-
112-
Ratio: pure breadth — N samples of the same goal, one advanced-tier judge.
113-
N competing approaches implemented or prototyped in parallel against the same
114-
acceptance criteria; a verify-style node exercises each candidate; one arbiter
115-
picks the winner on evidence and records why the losers lost.
116-
117-
## Playbook: Root-Cause Diagnosis
118-
119-
Ratio: breadth of hypotheses first, then depth on the leading survivor.
120-
Fan out one node per plausible hypothesis, each tasked to falsify its own
121-
hypothesis with concrete evidence; an arbiter eliminates, ranks survivors, and
122-
either declares the root cause or replans a deeper probe wave on the leading
123-
survivor.
124-
125-
## Playbook: Audit Sweeps
126-
127-
Ratio: pure breadth per sweep cell, with the audit loop supplying depth on
128-
hits. The same fan-out/arbiter/audit-loop shape covers recurring sweep
129-
domains: security surface audit (per-surface reviewers: input handling,
130-
authz, secrets, dependencies), regression matrix fan-out (one verify node per
131-
axis cell), and docs-code drift audit (per-document checkers comparing claims
132-
against the code, with fix waves through the audit loop).
133-
134-
## Choosing and Combining
135-
136-
Playbooks compose inside one live DAG: Large Engineering embeds Deep Review at
137-
its gate; Deep Speculation can front-load any of them. Selection still obeys
138-
Execution Mode Selection and the Depth Ladder — its wave count meets the
139-
ladder's minimum for the target size, and explicit user constraints always
140-
override the playbook shape.
1+
# Cross-domain Workflow Composition
2+
3+
The resident Orchestration Router and the live workflow library own route and
4+
`full`/`lite` selection. This guide resolves only requests where several domain
5+
references appear relevant. Keep one primary reference and one workflow.
6+
7+
## Pick the backbone by the final artifact
8+
9+
- The requested deliverable is a product decision: keep product planning as
10+
the backbone; technical feasibility is evidence, not a second design route.
11+
- The requested deliverable is an implementation-ready design: keep technical
12+
design as the backbone; product context supplies constraints.
13+
- The requested deliverable is changed code: keep project development as the
14+
backbone unless an unknown defect first requires causal diagnosis.
15+
- The requested deliverable is a defect repair: keep debug and repair as the
16+
backbone; the repair, regression proof, and review stay in that graph.
17+
- The requested deliverable is a verdict: use code review for a pinned
18+
implementation change, security or performance audit for those evidence
19+
domains, and technical design when the object is a proposed system or
20+
migration.
21+
22+
Security, performance, and review are secondary assurance when the requested
23+
artifact remains implementation or repair. They become primary only when the
24+
requested artifact is their report or verdict. A secondary concern is never a
25+
second workflow for the same objective.
26+
27+
## Add the smallest assurance slice
28+
29+
Read the primary reference first. Read a secondary reference only to identify
30+
the minimum evidence lane or gate that changes acceptance. Put those blocks in
31+
one task-local YAML and retarget every copied instruction to the same scope and
32+
acceptance criteria. Do not append a complete second reference.
33+
34+
- A security-sensitive feature keeps the development backbone and adds scoped
35+
threat, authorization, secret, or supply-chain checks before final review.
36+
- A security defect keeps the debug backbone and adds exploitability and
37+
boundary verification around the causal repair.
38+
- A performance repair keeps the debug or development backbone and adds a
39+
repeatable baseline plus before/after measurement.
40+
- A review of a dependency or release change keeps the review backbone and adds
41+
only the relevant upstream provenance and reachability evidence.
42+
43+
Reuse one exploration result across consumers. Keep one verification fan-in
44+
for the final implementation fingerprint and one final review or synthesis;
45+
duplicate explore, verify, and verdict blocks are evidence drift, not extra
46+
assurance. Unordered writers still share one workspace, so give them disjoint
47+
write sets or serialize them with real dependencies.
48+
49+
## Preserve lifecycle contracts
50+
51+
Composition does not redefine block fields, verdicts, repair, or recovery.
52+
Load `guide(topic="blocks")` for YAML shapes and block semantics, and
53+
`guide(topic="policy")` for admission, verdict disposal, pause-first replan,
54+
and bounded repair. A non-ACCEPT verdict remains actionable in the same wake
55+
turn; do not invent a domain-specific retry loop.

0 commit comments

Comments
 (0)