self-evolving-workflow 0.0.0-stage → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +27 -0
- package/README.md +90 -2
- package/dist/agent-memory-prompts.d.ts +13 -0
- package/dist/agent-memory-prompts.js +55 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +6 -0
- package/dist/closeout.d.ts +105 -0
- package/dist/closeout.js +479 -0
- package/dist/code.d.ts +39 -0
- package/dist/code.js +124 -0
- package/dist/common.d.ts +9 -0
- package/dist/common.js +42 -0
- package/dist/context-envelope.d.ts +59 -0
- package/dist/context-envelope.js +23 -0
- package/dist/host-adapters.d.ts +34 -0
- package/dist/host-adapters.js +151 -0
- package/dist/http.d.ts +3 -0
- package/dist/http.js +90 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +13 -0
- package/dist/knowledge-cli.d.ts +183 -0
- package/dist/knowledge-cli.js +654 -0
- package/dist/knowledge-reads.d.ts +71 -0
- package/dist/knowledge-reads.js +193 -0
- package/dist/memory.d.ts +97 -0
- package/dist/memory.js +250 -0
- package/dist/retrospective.d.ts +57 -0
- package/dist/retrospective.js +248 -0
- package/dist/search.d.ts +36 -0
- package/dist/search.js +112 -0
- package/dist/skill-addition.d.ts +25 -0
- package/dist/skill-addition.js +89 -0
- package/dist/skill-design.d.ts +96 -0
- package/dist/skill-design.js +226 -0
- package/dist/skill-replay.d.ts +55 -0
- package/dist/skill-replay.js +451 -0
- package/dist/skill-route.d.ts +30 -0
- package/dist/skill-route.js +75 -0
- package/dist/transcript-evidence.d.ts +3 -0
- package/dist/transcript-evidence.js +58 -0
- package/dist/upstream/chunker.d.ts +24 -0
- package/dist/upstream/chunker.js +96 -0
- package/dist/upstream/file-protocol.d.ts +45 -0
- package/dist/upstream/file-protocol.js +117 -0
- package/dist/upstream/frontmatter.d.ts +47 -0
- package/dist/upstream/frontmatter.js +86 -0
- package/dist/upstream/graph-search.d.ts +33 -0
- package/dist/upstream/graph-search.js +67 -0
- package/dist/upstream/l1-extraction.d.ts +26 -0
- package/dist/upstream/l1-extraction.js +405 -0
- package/dist/upstream/llm.d.ts +8 -0
- package/dist/upstream/llm.js +1 -0
- package/dist/upstream/merge.d.ts +50 -0
- package/dist/upstream/merge.js +153 -0
- package/dist/upstream/prompts.d.ts +53 -0
- package/dist/upstream/prompts.js +185 -0
- package/dist/upstream/search-utils.d.ts +34 -0
- package/dist/upstream/search-utils.js +55 -0
- package/dist/upstream/slug.d.ts +26 -0
- package/dist/upstream/slug.js +103 -0
- package/dist/upstream/template.d.ts +29 -0
- package/dist/upstream/template.js +80 -0
- package/dist/upstream/tokenize.d.ts +4 -0
- package/dist/upstream/tokenize.js +29 -0
- package/dist/wiki-change.d.ts +76 -0
- package/dist/wiki-change.js +299 -0
- package/dist/wiki-entry.d.ts +26 -0
- package/dist/wiki-entry.js +93 -0
- package/dist/wiki-ingest.d.ts +12 -0
- package/dist/wiki-ingest.js +126 -0
- package/dist/wiki-migration.d.ts +16 -0
- package/dist/wiki-migration.js +268 -0
- package/dist/wiki-tokens.d.ts +1 -0
- package/dist/wiki-tokens.js +46 -0
- package/dist/wiki.d.ts +103 -0
- package/dist/wiki.js +330 -0
- package/dist/workflow-cli.d.ts +2 -0
- package/dist/workflow-cli.js +258 -0
- package/dist/workflow-install.d.ts +36 -0
- package/dist/workflow-install.js +148 -0
- package/dist/workflow-knowledge.d.ts +16 -0
- package/dist/workflow-knowledge.js +24 -0
- package/dist/workflow-mcp.d.ts +2 -0
- package/dist/workflow-mcp.js +144 -0
- package/dist/workflow-names.d.ts +4 -0
- package/dist/workflow-names.js +18 -0
- package/dist/workflow-runtime.d.ts +622 -0
- package/dist/workflow-runtime.js +627 -0
- package/dist/workflow-skills.d.ts +48 -0
- package/dist/workflow-skills.js +141 -0
- package/package.json +76 -4
- package/skills/ew-odyssey/SKILL.md +237 -0
- package/skills/ew-odyssey/references/audit-artifacts.md +7 -0
- package/skills/ew-odyssey/references/odyssey-base-codex.md +3 -0
- package/skills/ew-odyssey/references/odyssey-base.md +278 -0
- package/skills/ew-odyssey/references/odyssey-debug.codex.md +305 -0
- package/skills/ew-odyssey/references/odyssey-debug.md +283 -0
- package/skills/ew-odyssey/references/odyssey-defensive.codex.md +395 -0
- package/skills/ew-odyssey/references/odyssey-defensive.md +369 -0
- package/skills/ew-odyssey/references/odyssey-improve.codex.md +270 -0
- package/skills/ew-odyssey/references/odyssey-improve.md +248 -0
- package/skills/ew-odyssey/references/odyssey-planex.codex.md +352 -0
- package/skills/ew-odyssey/references/odyssey-planex.md +312 -0
- package/skills/ew-odyssey/references/odyssey-review.codex.md +283 -0
- package/skills/ew-odyssey/references/odyssey-review.md +251 -0
- package/skills/ew-odyssey/references/odyssey-security.md +249 -0
- package/skills/ew-odyssey/references/odyssey-ui.codex.md +294 -0
- package/skills/ew-odyssey/references/odyssey-ui.md +250 -0
- package/skills/ew-odyssey/references/prepare/odyssey-debug.md +105 -0
- package/skills/ew-odyssey/references/prepare/odyssey-defensive.md +121 -0
- package/skills/ew-odyssey/references/prepare/odyssey-improve.md +93 -0
- package/skills/ew-odyssey/references/prepare/odyssey-planex.md +104 -0
- package/skills/ew-odyssey/references/prepare/odyssey-review.md +98 -0
- package/skills/ew-odyssey/references/prepare/odyssey-security.md +94 -0
- package/skills/ew-odyssey/references/prepare/odyssey-ui.md +87 -0
- package/skills/ew-orchestrate/SKILL.md +236 -0
- package/skills/ew-orchestrate/references/auto-policy.md +165 -0
- package/skills/ew-orchestrate/references/companion-route.md +52 -0
- package/skills/ew-orchestrate/references/ew-orchestrate.md +27 -0
- package/skills/ew-orchestrate/references/goal.md +53 -0
- package/skills/ew-orchestrate/references/knowledge-route.md +163 -0
- package/skills/ew-orchestrate/references/orchestrator-run-loop.md +36 -0
- package/skills/ew-orchestrate/references/planning.md +137 -0
- package/skills/ew-orchestrate/steps/ew-analyze/SKILL.md +62 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/boundary-grill.md +50 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/issue-gaps-analyze.md +59 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/prepare.md +42 -0
- package/skills/ew-orchestrate/steps/ew-analyze/references/workflow.md +401 -0
- package/skills/ew-orchestrate/steps/ew-brainstorm/SKILL.md +32 -0
- package/skills/ew-orchestrate/steps/ew-companion/SKILL.md +9 -0
- package/skills/ew-orchestrate/steps/ew-execute/SKILL.md +71 -0
- package/skills/ew-orchestrate/steps/ew-execute/references/prepare.md +69 -0
- package/skills/ew-orchestrate/steps/ew-execute/references/workflow.md +373 -0
- package/skills/ew-orchestrate/steps/ew-plan/SKILL.md +102 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/boundary-grill.md +50 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/prepare.md +51 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/tdd.md +53 -0
- package/skills/ew-orchestrate/steps/ew-plan/references/workflow.md +278 -0
- package/skills/ew-orchestrate/steps/ew-review/SKILL.md +44 -0
- package/skills/ew-orchestrate/steps/ew-review/references/odyssey-base-codex.md +3 -0
- package/skills/ew-orchestrate/steps/ew-review/references/prepare.md +76 -0
- package/skills/ew-orchestrate/steps/ew-review/references/workflow.md +283 -0
- package/skills/ew-skill-design/SKILL.md +28 -0
- package/skills/ew-skill-design/references/package-contract.md +28 -0
- package/skills/ew-skill-design/references/validation.md +7 -0
- package/skills/team-swarm/SKILL.md +231 -0
- package/skills/team-swarm/references/mcp-coordination.md +10 -0
- package/skills/team-swarm/roles/analyst/role.md +181 -0
- package/skills/team-swarm/roles/ant/role.md +149 -0
- package/skills/team-swarm/roles/coordinator/commands/converge.md +154 -0
- package/skills/team-swarm/roles/coordinator/commands/init-swarm.md +134 -0
- package/skills/team-swarm/roles/coordinator/commands/iterate.md +202 -0
- package/skills/team-swarm/roles/coordinator/role.md +228 -0
- package/skills/team-swarm/roles/scorer/role.md +150 -0
- package/skills/team-swarm/scripts/aco.py +646 -0
- package/skills/team-swarm/scripts/pheromone.py +144 -0
- package/skills/team-swarm/scripts/scoring.py +111 -0
- package/skills/team-swarm/scripts/test_aco.py +606 -0
- package/skills/team-swarm/specs/ant-output-schema.md +127 -0
- package/skills/team-swarm/specs/convergence-criteria.md +108 -0
- package/skills/team-swarm/specs/pheromone-schema.md +125 -0
- package/skills/team-swarm/specs/swarm-config-template.json +71 -0
- package/skills/team-swarm/specs/swarm-protocol.md +123 -0
- package/skills/workflow-closeout/SKILL.md +10 -0
- package/skills/workflow-evolve/SKILL.md +79 -0
- package/skills/workflow-evolve/references/agy-gate.md +27 -0
- package/skills/workflow-evolve/references/auto-loop.md +20 -0
- package/skills/workflow-evolve/references/history-review.md +14 -0
- package/skills/workflow-evolve/scripts/codex-memory-replay.mjs +76 -0
- package/skills/workflow-evolve/scripts/codex-replay.mjs +1 -0
- package/skills/workflow-evolve/scripts/evolve-loop.mjs +259 -0
- package/skills/workflow-evolve/scripts/memory-codex-mcp.mjs +124 -0
- package/workflows/index.json +23 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# Ant Output Schema
|
|
4
|
+
|
|
5
|
+
**The critical contract.** Every ant MUST write a JSON file matching this schema. Pheromone updates depend on it. Schema violation = ant output discarded + worker error reported.
|
|
6
|
+
|
|
7
|
+
## File Path
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
{run_dir}/outputs/ant-<iteration>-<ant_id>.json
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Example: `{run_dir}/outputs/ant-3-2.json` (ant id 2 in iteration 3)
|
|
14
|
+
|
|
15
|
+
## Schema
|
|
16
|
+
|
|
17
|
+
```json
|
|
18
|
+
{
|
|
19
|
+
"_meta": {
|
|
20
|
+
"kind": "swarm-ant-result",
|
|
21
|
+
"schema": "swarm-ant-result/1.0",
|
|
22
|
+
"role": "evidence"
|
|
23
|
+
},
|
|
24
|
+
"schema_version": "1.0",
|
|
25
|
+
"ant_id": "ANT-3-2",
|
|
26
|
+
"iteration": 3,
|
|
27
|
+
"assignment": {
|
|
28
|
+
"start_node": "node_a",
|
|
29
|
+
"max_path_length": 5
|
|
30
|
+
},
|
|
31
|
+
"path": ["node_a", "node_c", "node_f"],
|
|
32
|
+
"path_decisions": [
|
|
33
|
+
{
|
|
34
|
+
"from": "node_a",
|
|
35
|
+
"to": "node_c",
|
|
36
|
+
"rationale": "<one-line reason>",
|
|
37
|
+
"guided_by": "pheromone | heuristic | evidence",
|
|
38
|
+
"pheromone_weight": 0.30,
|
|
39
|
+
"deviation_from_hint": false
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"from": "node_c",
|
|
43
|
+
"to": "node_f",
|
|
44
|
+
"rationale": "<one-line reason>",
|
|
45
|
+
"guided_by": "evidence",
|
|
46
|
+
"deviation_from_hint": true
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"self_score": 0.78,
|
|
50
|
+
"self_confidence": 0.6,
|
|
51
|
+
"cost_tokens": 1200,
|
|
52
|
+
"cost_seconds": 18,
|
|
53
|
+
"evidence": [
|
|
54
|
+
"src/foo.ts:42",
|
|
55
|
+
"tests/foo.spec.ts:18"
|
|
56
|
+
],
|
|
57
|
+
"candidate_solution": {
|
|
58
|
+
"type": "<string|object|file_ref>",
|
|
59
|
+
"summary": "<one-line>",
|
|
60
|
+
"content": "<actual artifact content OR a path>"
|
|
61
|
+
},
|
|
62
|
+
"blockers": [],
|
|
63
|
+
"notes": "<optional free text, NOT used by pheromone update>"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Required Fields (Validation)
|
|
68
|
+
|
|
69
|
+
| Field | Type | Required | Constraint |
|
|
70
|
+
|-------|------|----------|------------|
|
|
71
|
+
| `_meta` | object | yes | complete artifact metadata; `kind` = `swarm-ant-result`, `schema` = `swarm-ant-result/1.0` |
|
|
72
|
+
| `schema_version` | string | yes | must be `"1.0"` |
|
|
73
|
+
| `ant_id` | string | yes | matches assignment |
|
|
74
|
+
| `iteration` | int | yes | matches assignment |
|
|
75
|
+
| `path` | array of string | yes | len >= 1, all nodes ∈ task_space.nodes |
|
|
76
|
+
| `path_decisions` | array | yes | len = len(path) - 1 |
|
|
77
|
+
| `self_score` | float | yes | 0.0 ≤ x ≤ 1.0 |
|
|
78
|
+
| `self_confidence` | float | yes | 0.0 ≤ x ≤ 1.0 |
|
|
79
|
+
| `cost_tokens` | int | no | recommended for budget tracking |
|
|
80
|
+
| `evidence` | array of string | yes | min 1 entry (forces grounding) |
|
|
81
|
+
| `candidate_solution` | object | yes | non-empty `summary` |
|
|
82
|
+
|
|
83
|
+
## Two-Layer Scoring
|
|
84
|
+
|
|
85
|
+
| Score | Source | Purpose |
|
|
86
|
+
|-------|--------|---------|
|
|
87
|
+
| `self_score` | Ant LLM self-report | Cheap early-stop signal; tracked but NOT used for pheromone update |
|
|
88
|
+
| `self_confidence` | Ant LLM self-report | Used to weight self_score when no verified_score is available |
|
|
89
|
+
| `verified_score` | scoring.py OR scorer role | **Authoritative input to pheromone update.** Written to separate file: `{run_dir}/work/team/scores/iter-k-scores.json` |
|
|
90
|
+
|
|
91
|
+
If `verified_score` is missing for an ant (scorer disabled), pheromone update falls back to:
|
|
92
|
+
```
|
|
93
|
+
effective_score = self_score * self_confidence * config.scoring.self_score_discount # default 0.5
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## verified_scores File
|
|
97
|
+
|
|
98
|
+
When scorer runs (script or LLM), produces:
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"iteration": 3,
|
|
103
|
+
"scorer_type": "script | llm",
|
|
104
|
+
"scores": {
|
|
105
|
+
"ANT-3-1": { "verified_score": 0.82, "rationale": "..." },
|
|
106
|
+
"ANT-3-2": { "verified_score": 0.45, "rationale": "..." }
|
|
107
|
+
},
|
|
108
|
+
"computed_at": "2026-05-25T14:30:00Z"
|
|
109
|
+
}
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Hallucination Detection
|
|
113
|
+
|
|
114
|
+
`aco.py update` compares `self_score` vs `verified_score` per ant:
|
|
115
|
+
- `|self_score - verified_score| > 0.4` → flagged as `hallucination_suspected`
|
|
116
|
+
- Repeat offenders (≥ 3 across iterations) → `aco.py` reduces deposit on their paths by 50%
|
|
117
|
+
|
|
118
|
+
## Validation in Ant's Phase 4
|
|
119
|
+
|
|
120
|
+
Ant MUST self-validate before writing:
|
|
121
|
+
1. JSON parses cleanly
|
|
122
|
+
2. All required fields present
|
|
123
|
+
3. `path` nodes exist in task-space.json
|
|
124
|
+
4. `path_decisions` length = `len(path) - 1`
|
|
125
|
+
5. Numeric ranges within bounds
|
|
126
|
+
|
|
127
|
+
Validation failure → retry once → if still failing, report `partial_completion` to coordinator.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# Convergence Criteria
|
|
4
|
+
|
|
5
|
+
When does the swarm stop iterating? Defines stop conditions computed by `aco.py converged`.
|
|
6
|
+
|
|
7
|
+
## Stop Conditions (any-of)
|
|
8
|
+
|
|
9
|
+
The swarm stops when **any** of the configured criteria triggers:
|
|
10
|
+
|
|
11
|
+
| Criterion | Default | Description |
|
|
12
|
+
|-----------|---------|-------------|
|
|
13
|
+
| `max_iterations` | 5 | Hard cap on iteration count |
|
|
14
|
+
| `stagnation` | patience = 2 | Best score unchanged for N iterations |
|
|
15
|
+
| `entropy_floor` | 0.5 | Pheromone Shannon entropy drops below threshold (matrix highly concentrated) |
|
|
16
|
+
| `budget_tokens` | 100000 | Total token cost exceeds budget |
|
|
17
|
+
| `target_score` | 0.95 | Best verified_score crosses target |
|
|
18
|
+
|
|
19
|
+
## Configuration
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"convergence": {
|
|
24
|
+
"max_iterations": 5,
|
|
25
|
+
"stagnation": { "enabled": true, "patience": 2, "min_delta": 0.01 },
|
|
26
|
+
"entropy_floor": { "enabled": true, "threshold": 0.5 },
|
|
27
|
+
"budget_tokens": { "enabled": false, "max": 100000 },
|
|
28
|
+
"target_score": { "enabled": true, "value": 0.95 }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Output Schema (aco.py converged)
|
|
34
|
+
|
|
35
|
+
```json
|
|
36
|
+
{
|
|
37
|
+
"converged": true,
|
|
38
|
+
"iteration": 4,
|
|
39
|
+
"reason": "stagnation",
|
|
40
|
+
"metrics": {
|
|
41
|
+
"best_score": 0.78,
|
|
42
|
+
"mean_score": 0.62,
|
|
43
|
+
"entropy": 1.85,
|
|
44
|
+
"iterations_completed": 4,
|
|
45
|
+
"iterations_since_best_change": 2,
|
|
46
|
+
"total_tokens_used": 42000
|
|
47
|
+
},
|
|
48
|
+
"triggered_by": ["stagnation"],
|
|
49
|
+
"recommendation": "best solution is stable; recommend report"
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Selection Logic
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
def check_convergence(history, config):
|
|
57
|
+
triggered = []
|
|
58
|
+
|
|
59
|
+
if iteration >= config.max_iterations:
|
|
60
|
+
triggered.append("max_iterations")
|
|
61
|
+
|
|
62
|
+
if config.stagnation.enabled:
|
|
63
|
+
recent = history[-config.stagnation.patience-1:]
|
|
64
|
+
if len(recent) > config.stagnation.patience:
|
|
65
|
+
deltas = [abs(recent[i].best - recent[i-1].best)
|
|
66
|
+
for i in range(1, len(recent))]
|
|
67
|
+
if all(d < config.stagnation.min_delta for d in deltas):
|
|
68
|
+
triggered.append("stagnation")
|
|
69
|
+
|
|
70
|
+
if config.entropy_floor.enabled and current_entropy < threshold:
|
|
71
|
+
triggered.append("entropy_floor")
|
|
72
|
+
|
|
73
|
+
if config.budget_tokens.enabled and total_tokens > config.budget_tokens.max:
|
|
74
|
+
triggered.append("budget_tokens")
|
|
75
|
+
|
|
76
|
+
if config.target_score.enabled and best_score >= config.target_score.value:
|
|
77
|
+
triggered.append("target_score")
|
|
78
|
+
|
|
79
|
+
return {"converged": len(triggered) > 0, "triggered_by": triggered}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Entropy Calculation
|
|
83
|
+
|
|
84
|
+
Shannon entropy of normalized pheromone distribution:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
p_i = tau_i / sum(tau) for each active edge
|
|
88
|
+
H = -sum(p_i * log2(p_i))
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
- High H → diverse exploration (early stage)
|
|
92
|
+
- Low H → concentrated on few paths (converging)
|
|
93
|
+
- H < threshold + best score plateau → safe to stop
|
|
94
|
+
|
|
95
|
+
## Why Multi-Criterion
|
|
96
|
+
|
|
97
|
+
Single criterion is fragile:
|
|
98
|
+
- `max_iterations` alone wastes budget if converged early
|
|
99
|
+
- `stagnation` alone may stop too early on noisy scoring
|
|
100
|
+
- `entropy_floor` alone may trigger before useful solutions emerge
|
|
101
|
+
|
|
102
|
+
Combination = early termination when safe, but always bounded by `max_iterations`.
|
|
103
|
+
|
|
104
|
+
## Anti-Patterns
|
|
105
|
+
|
|
106
|
+
- DO NOT use `stagnation` with `patience < 2` — noise will trigger false stops
|
|
107
|
+
- DO NOT disable `max_iterations` — runaway risk
|
|
108
|
+
- DO NOT set `target_score` without verified scoring — self_score is too optimistic
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
# Pheromone Schema
|
|
4
|
+
|
|
5
|
+
Pheromone matrix structure, update formula, evaporation rule. Authoritative spec for `pheromone/current.json` and history snapshots.
|
|
6
|
+
|
|
7
|
+
## File Layout
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
{run_dir}/work/team/pheromone/
|
|
11
|
+
├── current.json # latest state, overwritten each iteration
|
|
12
|
+
├── history/
|
|
13
|
+
│ ├── 1.json # snapshot after iteration 1
|
|
14
|
+
│ ├── 2.json
|
|
15
|
+
│ └── ...
|
|
16
|
+
└── init.json # snapshot of initial state (immutable)
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Schema (pheromone/current.json)
|
|
20
|
+
|
|
21
|
+
```json
|
|
22
|
+
{
|
|
23
|
+
"version": "1.0",
|
|
24
|
+
"iteration": 3,
|
|
25
|
+
"n_nodes": 42,
|
|
26
|
+
"matrix_type": "edge_weighted_sparse",
|
|
27
|
+
"tau": {
|
|
28
|
+
"<node_a>::<node_b>": 0.85,
|
|
29
|
+
"<node_a>::<node_c>": 1.20,
|
|
30
|
+
"<node_x>::<node_y>": 0.13
|
|
31
|
+
},
|
|
32
|
+
"node_tau": {
|
|
33
|
+
"<node_a>": 0.92,
|
|
34
|
+
"<node_b>": 1.05
|
|
35
|
+
},
|
|
36
|
+
"metadata": {
|
|
37
|
+
"alpha": 1.0,
|
|
38
|
+
"beta": 2.0,
|
|
39
|
+
"rho": 0.2,
|
|
40
|
+
"q": 1.0,
|
|
41
|
+
"tau_init": 1.0,
|
|
42
|
+
"tau_min": 0.01,
|
|
43
|
+
"tau_max": 10.0
|
|
44
|
+
},
|
|
45
|
+
"stats": {
|
|
46
|
+
"mean": 0.91,
|
|
47
|
+
"max": 2.34,
|
|
48
|
+
"min": 0.05,
|
|
49
|
+
"entropy": 3.21,
|
|
50
|
+
"n_edges_active": 87
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Field Semantics
|
|
56
|
+
|
|
57
|
+
| Field | Type | Meaning |
|
|
58
|
+
|-------|------|---------|
|
|
59
|
+
| `matrix_type` | enum | `edge_weighted_sparse` (default), `node_weighted`, `full_dense` |
|
|
60
|
+
| `tau` | dict | Edge pheromone, key `"a::b"` (undirected uses lexical order) |
|
|
61
|
+
| `node_tau` | dict | Node-level pheromone (used when matrix_type = node_weighted) |
|
|
62
|
+
| `metadata.alpha` | float | Pheromone weight in selection probability |
|
|
63
|
+
| `metadata.beta` | float | Heuristic weight in selection probability |
|
|
64
|
+
| `metadata.rho` | float | Evaporation rate (0..1), applied each iteration |
|
|
65
|
+
| `metadata.q` | float | Deposit constant |
|
|
66
|
+
| `metadata.tau_min/max` | float | MMAS bounds — prevents premature convergence/explosion |
|
|
67
|
+
| `stats.entropy` | float | Shannon entropy of normalized tau — convergence signal |
|
|
68
|
+
|
|
69
|
+
## Update Formula
|
|
70
|
+
|
|
71
|
+
After iteration k completes, for each ant a in iteration:
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
delta_tau_a(edge) = q * verified_score_a if edge in path_a, else 0
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
Then:
|
|
78
|
+
|
|
79
|
+
```
|
|
80
|
+
tau(edge) = (1 - rho) * tau(edge) + sum_over_ants(delta_tau_a(edge))
|
|
81
|
+
tau(edge) = clip(tau(edge), tau_min, tau_max)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
**Elitist strategy** (always on): the best path of all time deposits extra `q * best_score` on its edges before clipping.
|
|
85
|
+
|
|
86
|
+
## Selection Probability (used in `aco.py select`)
|
|
87
|
+
|
|
88
|
+
For ant at node i choosing neighbor j from candidate set N(i):
|
|
89
|
+
|
|
90
|
+
```
|
|
91
|
+
p(i -> j) = (tau(i,j)^alpha * eta(i,j)^beta) / sum_{k in N(i)}(tau(i,k)^alpha * eta(i,k)^beta)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
where `eta` is a heuristic value from config (e.g., inverse-distance, prior knowledge). Default `eta = 1.0` if not provided.
|
|
95
|
+
|
|
96
|
+
## Path-Hints vs Full-Path
|
|
97
|
+
|
|
98
|
+
`aco.py select` does NOT prescribe a complete path — it returns **path-hints**: weighted starting nodes + edge probabilities. The ant (LLM) then makes the actual node-by-node choices, with freedom to deviate based on its own evidence. This preserves LLM judgment while keeping search guided.
|
|
99
|
+
|
|
100
|
+
```json
|
|
101
|
+
{
|
|
102
|
+
"ant_id": "ANT-3-2",
|
|
103
|
+
"start_node": "node_a",
|
|
104
|
+
"edge_preferences": {
|
|
105
|
+
"node_a::node_b": 0.45,
|
|
106
|
+
"node_a::node_c": 0.30,
|
|
107
|
+
"node_a::node_d": 0.25
|
|
108
|
+
},
|
|
109
|
+
"max_path_length": 5
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Initialization
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
tau_init for all edges = config.aco.tau_init (default 1.0)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
If `task_space.nodes` is `auto_discover_from: <glob>`, init.py discovers nodes by globbing and initializes a full uniform matrix.
|
|
120
|
+
|
|
121
|
+
## History & Reproducibility
|
|
122
|
+
|
|
123
|
+
- `init.json` — frozen snapshot of initial state (never overwritten)
|
|
124
|
+
- `history/k.json` — full pheromone state after iteration k (for convergence-curve analysis)
|
|
125
|
+
- All updates are deterministic given (prior state + ant artifacts + config)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_comment": "User-facing config template. Coordinator generates this from task description in Phase 1. Fields prefixed with _ are documentation, omit from real config.",
|
|
3
|
+
|
|
4
|
+
"swarm": {
|
|
5
|
+
"_comment": "Top-level swarm parameters",
|
|
6
|
+
"n_ants": 5,
|
|
7
|
+
"max_iterations": 5,
|
|
8
|
+
"elite_keep": 3
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
"aco": {
|
|
12
|
+
"_comment": "ACO algorithm hyperparameters - defaults are sane",
|
|
13
|
+
"alpha": 1.0,
|
|
14
|
+
"beta": 2.0,
|
|
15
|
+
"rho": 0.2,
|
|
16
|
+
"q": 1.0,
|
|
17
|
+
"tau_init": 1.0,
|
|
18
|
+
"tau_min": 0.01,
|
|
19
|
+
"tau_max": 10.0
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
"task_space": {
|
|
23
|
+
"_comment": "Define the search space. Use EITHER 'nodes' (explicit) OR 'auto_discover_from' (glob).",
|
|
24
|
+
"type": "graph",
|
|
25
|
+
"nodes": ["node_a", "node_b", "node_c"],
|
|
26
|
+
"_alt_auto_discover": "auto_discover_from: 'src/**/*.ts'",
|
|
27
|
+
"max_path_length": 5,
|
|
28
|
+
"start_nodes": "any",
|
|
29
|
+
"edges": "complete"
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
"scoring": {
|
|
33
|
+
"_comment": "How verified_score is computed. mode = script | llm | fallback",
|
|
34
|
+
"mode": "fallback",
|
|
35
|
+
"_alt_script": "script_path: '../my-scoring-rule.py' (file must define def score(ant_artifact) -> float)",
|
|
36
|
+
"_alt_llm": "rubric: 'custom scoring rubric text for scorer role'",
|
|
37
|
+
"self_score_discount": 0.5
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
"ant_prompt": {
|
|
41
|
+
"_comment": "What the ant actually tries to achieve. This is the bridge between task semantics and ACO mechanics.",
|
|
42
|
+
"objective": "Find the file with the highest density of suspicious code patterns",
|
|
43
|
+
"evidence_requirements": [
|
|
44
|
+
"At least 1 file:line reference per node visited",
|
|
45
|
+
"Concrete code snippet showing the suspicious pattern"
|
|
46
|
+
],
|
|
47
|
+
"tools_hint": "Use Grep + Read for code-based exploration"
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
"convergence": {
|
|
51
|
+
"_comment": "Stop conditions - any-of triggers convergence",
|
|
52
|
+
"max_iterations": 5,
|
|
53
|
+
"stagnation": {
|
|
54
|
+
"enabled": true,
|
|
55
|
+
"patience": 2,
|
|
56
|
+
"min_delta": 0.01
|
|
57
|
+
},
|
|
58
|
+
"entropy_floor": {
|
|
59
|
+
"enabled": true,
|
|
60
|
+
"threshold": 0.5
|
|
61
|
+
},
|
|
62
|
+
"budget_tokens": {
|
|
63
|
+
"enabled": false,
|
|
64
|
+
"max": 100000
|
|
65
|
+
},
|
|
66
|
+
"target_score": {
|
|
67
|
+
"enabled": true,
|
|
68
|
+
"value": 0.95
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
|
|
2
|
+
> **Plan tracking**: codex 无 TaskCreate/TaskUpdate/TodoWrite 任务板。进度清单用 `update_plan({ explanation?, plan: [{ step, status }] })` 维护(整体提交步骤数组,status: `pending` | `in_progress` | `completed`),权威状态始终在 session 工件中;依赖/认领(addBlockedBy/owner)是工件字段,不是工具参数。
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Swarm Protocol
|
|
6
|
+
|
|
7
|
+
Master protocol document for team-swarm: defines how the LLM coordinator and Python ACO controller interface, how ants explore the task space, and how exploration results flow back to update pheromone state.
|
|
8
|
+
|
|
9
|
+
## Design Philosophy
|
|
10
|
+
|
|
11
|
+
| Principle | Rationale |
|
|
12
|
+
|-----------|-----------|
|
|
13
|
+
| **Outer loop = script, inner loop = LLM** | Optimization math is cheap and deterministic; LLM evaluation is expensive and noisy. Separate them. |
|
|
14
|
+
| **Coordinator is a hybrid** | LLM coordinator translates user intent + dispatches workers; Python script makes all numeric decisions (selection, update, convergence). |
|
|
15
|
+
| **Schema-locked ant output** | LLM output → algorithm input bridge demands strict JSON contract. Free-text outputs cannot feed pheromone updates. |
|
|
16
|
+
| **Two-layer scoring** | `self_score` (LLM self-report) is fast but optimistic. `verified_score` (script or LLM scorer) is the only authoritative input to pheromone update. |
|
|
17
|
+
| **Universal task space** | Coordinator does not bake in any domain. User provides `swarm-config.json` with task space + scoring rule. |
|
|
18
|
+
|
|
19
|
+
## Three-Component Architecture
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
+-----------------------------------------------------+
|
|
23
|
+
| LLM Coordinator (roles/coordinator/role.md) |
|
|
24
|
+
| - Parses user task → emits swarm-config.json |
|
|
25
|
+
| - Phase 3 main loop: calls script, spawns workers |
|
|
26
|
+
| - Translates worker callbacks back into script ops |
|
|
27
|
+
+--------+--------------------------------------------+
|
|
28
|
+
| Bash subprocess
|
|
29
|
+
v
|
|
30
|
+
+-----------------------------------------------------+
|
|
31
|
+
| Python ACO Controller (scripts/aco.py) |
|
|
32
|
+
| - CLI subcommands: init/select/update/converged |
|
|
33
|
+
| - Owns pheromone matrix + elite tracker |
|
|
34
|
+
| - Pure functions of session state files |
|
|
35
|
+
+-----------------------------------------------------+
|
|
36
|
+
^ |
|
|
37
|
+
| reads {run_dir}/outputs/ant-*.json | writes pheromone/*.json
|
|
38
|
+
| v
|
|
39
|
+
+-----------------------------------------------------+
|
|
40
|
+
| LLM Workers (team-worker agents) |
|
|
41
|
+
| - ant: explores assigned path, writes JSON |
|
|
42
|
+
| - scorer: assigns verified_score (optional) |
|
|
43
|
+
| - analyst: final synthesis of elite solutions |
|
|
44
|
+
+-----------------------------------------------------+
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Iteration Lifecycle
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
[Coordinator] init phase
|
|
51
|
+
└─> python aco.py --session {run_dir}/work/team --run-dir <run_dir> init
|
|
52
|
+
└─> writes pheromone/current.json + task-space.json
|
|
53
|
+
|
|
54
|
+
[Coordinator] iteration k (k = 1..K):
|
|
55
|
+
├─> python aco.py --session {run_dir}/work/team --run-dir <run_dir> select --iter k
|
|
56
|
+
│ └─> returns N ant assignments (paths to explore)
|
|
57
|
+
├─> update_plan × N ant tasks
|
|
58
|
+
├─> spawn N × team-worker(ant) in background
|
|
59
|
+
└─> STOP (await all callbacks)
|
|
60
|
+
|
|
61
|
+
[Callback] all ants done → handleIterationComplete
|
|
62
|
+
├─> (optional) spawn scorer worker → verified_scores.json
|
|
63
|
+
├─> python aco.py --session {run_dir}/work/team --run-dir <run_dir> update --iter k
|
|
64
|
+
│ └─> reads {run_dir}/outputs/ant-k-*.json + verified_scores
|
|
65
|
+
│ └─> updates pheromone + elite + history
|
|
66
|
+
├─> python aco.py --session {run_dir}/work/team --run-dir <run_dir> converged
|
|
67
|
+
│ └─> {converged: true|false, reason: ...}
|
|
68
|
+
└─> converged → Phase 4; else → iteration k+1
|
|
69
|
+
|
|
70
|
+
[Coordinator] Phase 4: converge
|
|
71
|
+
├─> python aco.py --session {run_dir}/work/team --run-dir <run_dir> report → stdout JSON saved as outputs/swarm-report.json
|
|
72
|
+
├─> spawn analyst worker → best-solution.md
|
|
73
|
+
└─> completion action (Archive/Keep/Export)
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Script ↔ Coordinator Contract
|
|
77
|
+
|
|
78
|
+
All scripts MUST:
|
|
79
|
+
- Read from `{run_dir}/work/team/...` (session path passed via `--session` flag)
|
|
80
|
+
- Write JSON to stdout for coordinator parsing (no prose)
|
|
81
|
+
- Use exit code 0 = success, 1 = error, 2 = config invalid
|
|
82
|
+
- Commit each update with its input digest before writing the derived pheromone, best result, history and trails. Replaying the same iteration with identical inputs returns the stored result. A changed replay fails. The next controller invocation restores an interrupted projection from the committed receipt.
|
|
83
|
+
|
|
84
|
+
| Subcommand | Input | Output (stdout JSON) | Side effects |
|
|
85
|
+
|------------|-------|---------------------|--------------|
|
|
86
|
+
| `init` | swarm-config.json | `{status, pheromone_path, n_nodes}` | writes pheromone/current.json, task-space.json |
|
|
87
|
+
| `select --iter k` | pheromone/current.json, swarm-config.json | `{iteration, assignments: [{ant_id, start_node, ...}]}` | saves `assignments/k.json` for a Run |
|
|
88
|
+
| `update --iter k` | {run_dir}/outputs/ant-k-*.json, saved assignment batch when available, `scores/iter-k-scores.json` in LLM mode | `{iteration, mean_score, best_score, delta, elite_updated}` | commits an iteration receipt and projects state, history, trails and best solution |
|
|
89
|
+
| `converged` | history/, best.json, config | `{converged: bool, reason: str, metrics: {...}}` | none |
|
|
90
|
+
| `report` | best.json, history/ | full JSON: `{_meta: {kind: swarm-report, schema: swarm-report/1.0, role: attachment}, best, top_k, convergence_curve, ...}` | none |
|
|
91
|
+
|
|
92
|
+
Run-scoped `select` saves `assignments/k.json` and returns the same batch on replay. An LLM score file covers the accepted artifacts for the same iteration. `update --allow-score-fallback` uses discounted self-scores for the entire LLM iteration. The fallback choice is part of the replay inputs.
|
|
93
|
+
|
|
94
|
+
## Data Flow Boundaries
|
|
95
|
+
|
|
96
|
+
| Boundary | Owner | Format |
|
|
97
|
+
|----------|-------|--------|
|
|
98
|
+
| User intent → config | LLM coordinator | swarm-config.json |
|
|
99
|
+
| Pheromone state | Python script | pheromone/current.json |
|
|
100
|
+
| Ant assignment → ant prompt | LLM coordinator (templated) | injected into role-spec at spawn |
|
|
101
|
+
| Ant exploration → artifact | LLM ant | {run_dir}/outputs/ant-k-id.json (schema-locked) |
|
|
102
|
+
| Artifact → pheromone update | Python script | reads artifacts, computes delta tau |
|
|
103
|
+
| Elite solutions → human report | LLM analyst | {run_dir}/outputs/best-solution.md |
|
|
104
|
+
|
|
105
|
+
## Why Hybrid Coordinator (Not Pure Script)
|
|
106
|
+
|
|
107
|
+
- User input is natural language → needs LLM to map to swarm-config
|
|
108
|
+
- Worker spawning, message routing, session management → all framework-bound to LLM coordinator
|
|
109
|
+
- Script as a sub-tool keeps the same team-* lifecycle (spawn-and-stop, callback-driven)
|
|
110
|
+
- Same pattern as `evolve delegate` — Bash-callable subprocess from inside an LLM role
|
|
111
|
+
|
|
112
|
+
## Universality
|
|
113
|
+
|
|
114
|
+
`team-swarm` is task-agnostic. Specialization happens via:
|
|
115
|
+
1. `swarm-config.json#task_space` — defines what nodes/edges/paths mean
|
|
116
|
+
2. `swarm-config.json#scoring` — defines how to compute verified_score
|
|
117
|
+
3. `swarm-config.json#ant_prompt` — defines what ant should actually do at each node
|
|
118
|
+
|
|
119
|
+
Example domains the same skill handles:
|
|
120
|
+
- Code exploration (nodes = files/modules, score = suspicious code density)
|
|
121
|
+
- Test case generation (nodes = code paths, score = coverage delta)
|
|
122
|
+
- Refactor strategy search (nodes = refactor moves, score = complexity reduction)
|
|
123
|
+
- Hyperparameter tuning (nodes = param choices, score = metric improvement)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workflow-closeout
|
|
3
|
+
description: 兼容入口。将 Session、Skill 收尾沉淀、Wiki 审查和发布统一路由到 Evolve 知识路由。
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Evolve 知识路由兼容入口
|
|
7
|
+
|
|
8
|
+
所有操作先读取 [Evolve 知识路由](../ew-orchestrate/references/knowledge-route.md)。该文件统一规定 Wiki 条目属性、Closeout 证据、候选审查、迁移和发布顺序。
|
|
9
|
+
|
|
10
|
+
旧宿主仍调用 `workflow-closeout` 时,继续使用同一 Agent Memory Closeout CLI 和 Wiki。零候选、延期和待补证都通过处理回执结束本次操作。
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: workflow-evolve
|
|
3
|
+
description: Analyze a Skill execution history, run a real Codex plus Agent Memory regression, and iteratively improve the Skill through an Agy-confirmed replay loop.
|
|
4
|
+
argument-hint: <skill-entry> --iterations <n> --scenarios <file> [--session <id>|--execution <id>] [--auto]
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Bash
|
|
7
|
+
- Edit
|
|
8
|
+
- Glob
|
|
9
|
+
- Grep
|
|
10
|
+
- Read
|
|
11
|
+
- Write
|
|
12
|
+
- request_user_input
|
|
13
|
+
- update_plan
|
|
14
|
+
- wait_agent
|
|
15
|
+
session-mode: run
|
|
16
|
+
required_links:
|
|
17
|
+
- references/auto-loop.md
|
|
18
|
+
- references/history-review.md
|
|
19
|
+
- references/agy-gate.md
|
|
20
|
+
contract:
|
|
21
|
+
contract_version: 2.1
|
|
22
|
+
consumes: []
|
|
23
|
+
produces:
|
|
24
|
+
- path: outputs/evolution-report.json
|
|
25
|
+
kind: workflow-evolution-report
|
|
26
|
+
schema: workflow-evolution/1.0
|
|
27
|
+
role: primary
|
|
28
|
+
alias: latest-workflow-evolution
|
|
29
|
+
required: true
|
|
30
|
+
gates:
|
|
31
|
+
entry:
|
|
32
|
+
- explicit iteration count is a positive integer
|
|
33
|
+
- target Skill package is committed and replayable
|
|
34
|
+
exit:
|
|
35
|
+
- every applied round has an Agy confirmation receipt
|
|
36
|
+
- baseline and candidate scenarios pass
|
|
37
|
+
- failed applications are rolled back
|
|
38
|
+
version: 0.2.0
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
# Workflow Evolution
|
|
42
|
+
|
|
43
|
+
Use this Skill when a completed Session/Run or standalone Skill execution needs evidence-based improvement. The Skill keeps the existing Git worktree replay model, adds a real Codex and Agent Memory task, and runs a bounded loop whose changes are gated by Agy.
|
|
44
|
+
|
|
45
|
+
The entry requires `--iterations <n>`. `--auto` enables unattended apply and rollback after the Agy gate while retaining history, replay and confirmation checks. With interactive apply, the loop stops after a confirmed replay and leaves the receipt ready for the next authorized action.
|
|
46
|
+
|
|
47
|
+
Follow [the automatic loop](references/auto-loop.md) for argument parsing, state, retries and stop conditions. Follow [history review](references/history-review.md) before drafting a change. Follow [the Agy gate](references/agy-gate.md) before replay and apply.
|
|
48
|
+
|
|
49
|
+
## Entry contract
|
|
50
|
+
|
|
51
|
+
```text
|
|
52
|
+
workflow-evolve <skill-entry>
|
|
53
|
+
--iterations <positive integer>
|
|
54
|
+
--scenarios <JSON file with one baseline failure and one baseline pass>
|
|
55
|
+
[--runner <replay runner>]
|
|
56
|
+
--session <Session ID> | --execution <Skill execution ID> | --history <JSON transcript>
|
|
57
|
+
[--project <project ID>] [--max-retries <n>] [--auto]
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The default runner is `scripts/codex-memory-replay.mjs`. It invokes `codex exec` in read-only mode and opens Skill documents from the selected Git commit. The runner calls the bundled Agent Memory CLI and returns the document hashes and a `knowledge-reads/1.0` receipt. Set `AGENT_MEMORY_DB` to an absolute database path when replay should use existing memories. Each replay uses a fresh search trace.
|
|
61
|
+
|
|
62
|
+
## Required evidence
|
|
63
|
+
|
|
64
|
+
- Prepare the target Skill package as a clean commit before replay. `agent-memory evolve replay` creates isolated baseline and candidate worktrees from that commit.
|
|
65
|
+
- Supply either a committed Session/Run, a standalone Skill execution ID, or an explicit transcript file. The history review records the source and the extracted signals used for the draft.
|
|
66
|
+
- Preserve the Agy discussion and confirmation JSON for every round. Apply each draft after its Agy response carries `approved: true`.
|
|
67
|
+
|
|
68
|
+
## Automatic invocation
|
|
69
|
+
|
|
70
|
+
```powershell
|
|
71
|
+
node skills/workflow-evolve/scripts/evolve-loop.mjs `
|
|
72
|
+
--skill skills/workflow-evolve/SKILL.md `
|
|
73
|
+
--iterations 3 `
|
|
74
|
+
--scenarios .workflow/evolution/scenarios.json `
|
|
75
|
+
--session <session-id> `
|
|
76
|
+
--auto
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The script writes one state file and one directory per round under `.workflow/evolution/<timestamp>/`. Pass `--run-dir <run_dir>` for an Evolve Run. The script writes the final result to that Run’s `outputs/evolution-report.json`.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Agy gate
|
|
2
|
+
|
|
3
|
+
Every round has two Agy calls.
|
|
4
|
+
|
|
5
|
+
## Discussion response
|
|
6
|
+
|
|
7
|
+
The first call receives the baseline observations and history review. It must return JSON with this shape.
|
|
8
|
+
|
|
9
|
+
```json
|
|
10
|
+
{
|
|
11
|
+
"approved": true,
|
|
12
|
+
"priority": "high|normal|low",
|
|
13
|
+
"instruction": "one concise Skill instruction",
|
|
14
|
+
"when": "optional trigger for normal or low priority guidance",
|
|
15
|
+
"evidence": ["receipt or verification reference"],
|
|
16
|
+
"rationale": "why the change is attributable and minimal",
|
|
17
|
+
"needs_revision": []
|
|
18
|
+
}
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`approved` means the suggestion is ready to turn into a draft. Agy must set it to `false` when the evidence is missing, the change is broader than the observed failure, or the request needs a new Skill contract. Contract changes route to `ew-skill-design` after the loop.
|
|
22
|
+
|
|
23
|
+
## Confirmation response
|
|
24
|
+
|
|
25
|
+
The second call receives the draft and the complete replay receipt. It must return `approved`, `reason` and `required_changes`. It approves only when every baseline pass remains green, every requested failure is fixed, the candidate loaded the expected Skill documents, and the evidence is traceable to the reviewed execution.
|
|
26
|
+
|
|
27
|
+
The loop stores both responses under the round directory. `--auto` applies a receipt after this second call returns `approved: true`. Agy owns the evaluation decision for each proposed change.
|