atlas-workflow 0.9.2 → 0.9.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.
Files changed (84) hide show
  1. package/README.md +5 -2
  2. package/VERSION +1 -1
  3. package/build/bump-version.mjs +6 -21
  4. package/build/cli/atlas-init.mjs +92 -5
  5. package/hosts/opencode/.opencode/atlas/VERSION +1 -1
  6. package/hosts/opencode/.opencode/atlas/orchestrator/README.md +1 -1
  7. package/hosts/opencode/.opencode/atlas/orchestrator/references/host-adapters.md +13 -12
  8. package/hosts/opencode/.opencode/atlas/orchestrator/skills/atlas-workflow-orchestrator/SKILL.md +2 -0
  9. package/hosts/opencode/.opencode/atlas/packages/mcp-server/README.md +1 -1
  10. package/hosts/opencode/.opencode/atlas/packages/mcp-server/package.json +1 -1
  11. package/hosts/opencode/.opencode/atlas/packages/mcp-server/server.js +69 -7
  12. package/hosts/opencode/.opencode/skills/atlas-workflow-orchestrator/SKILL.md +2 -0
  13. package/hosts/pi/atlas/VERSION +1 -1
  14. package/hosts/pi/atlas/orchestrator/README.md +1 -1
  15. package/hosts/pi/atlas/orchestrator/references/host-adapters.md +13 -12
  16. package/hosts/pi/atlas/orchestrator/skills/atlas-workflow-orchestrator/SKILL.md +2 -0
  17. package/hosts/pi/atlas/packages/mcp-server/README.md +1 -1
  18. package/hosts/pi/atlas/packages/mcp-server/package.json +1 -1
  19. package/hosts/pi/atlas/packages/mcp-server/server.js +69 -7
  20. package/hosts/pi/skills/atlas-workflow-orchestrator/SKILL.md +2 -0
  21. package/hosts/zcode/.zcode-plugin/plugin.json +27 -0
  22. package/hosts/zcode/agents/atlas-direct-execute.md +31 -0
  23. package/hosts/zcode/agents/atlas-findings-repair.md +39 -0
  24. package/hosts/zcode/agents/atlas-plan-execute.md +33 -0
  25. package/hosts/zcode/agents/atlas-slice-review.md +27 -0
  26. package/hosts/zcode/agents/atlas-task-validator.md +138 -0
  27. package/hosts/zcode/packages/mcp-server/README.md +29 -0
  28. package/hosts/zcode/packages/mcp-server/VERSION +1 -0
  29. package/hosts/zcode/packages/mcp-server/package.json +15 -0
  30. package/hosts/zcode/packages/mcp-server/server.js +3897 -0
  31. package/hosts/zcode/packages/orchestrator/README.md +270 -0
  32. package/hosts/zcode/packages/orchestrator/commands/workflow.md +37 -0
  33. package/hosts/zcode/packages/orchestrator/defaults/paths.md +21 -0
  34. package/hosts/zcode/packages/orchestrator/references/host-adapters.md +106 -0
  35. package/hosts/zcode/packages/orchestrator/references/qa_s13_matrix.md +141 -0
  36. package/hosts/zcode/packages/orchestrator/references/subagent_dispatch.md +42 -0
  37. package/hosts/zcode/packages/orchestrator/skills/atlas-workflow-orchestrator/SKILL.md +391 -0
  38. package/hosts/zcode/packages/templates/BACKLOG_MESTRE_TEMPLATE.md +855 -0
  39. package/hosts/zcode/packages/templates/BOUNDARY_PRD_PLAN.md +93 -0
  40. package/hosts/zcode/packages/templates/PERGUNTAS_EM_ABERTO_TEMPLATE.md +139 -0
  41. package/hosts/zcode/packages/templates/PLAN_TEMPLATE.md +146 -0
  42. package/hosts/zcode/packages/templates/PRD_TEMPLATE.md +150 -0
  43. package/hosts/zcode/packages/templates/STATE_FILE_SCHEMA.md +56 -0
  44. package/hosts/zcode/skills/_shared/references/stack-profiles.md +36 -0
  45. package/hosts/zcode/skills/_shared/scripts/document_quality.mjs +252 -0
  46. package/hosts/zcode/skills/atlas-backlog-generator/SKILL.md +93 -0
  47. package/hosts/zcode/skills/atlas-backlog-generator/agents/openai.yaml +4 -0
  48. package/hosts/zcode/skills/atlas-direct-execute/SKILL.md +221 -0
  49. package/hosts/zcode/skills/atlas-direct-execute/agents/openai.yaml +7 -0
  50. package/hosts/zcode/skills/atlas-findings-repair/SKILL.md +158 -0
  51. package/hosts/zcode/skills/atlas-findings-repair/agents/openai.yaml +7 -0
  52. package/hosts/zcode/skills/atlas-plan-execute/SKILL.md +175 -0
  53. package/hosts/zcode/skills/atlas-plan-execute/agents/openai.yaml +7 -0
  54. package/hosts/zcode/skills/atlas-plan-execute/references/plan-contract.md +88 -0
  55. package/hosts/zcode/skills/atlas-plan-execute/references/quality-gates.md +60 -0
  56. package/hosts/zcode/skills/atlas-plan-execute/scripts/check_budget_state.py +96 -0
  57. package/hosts/zcode/skills/atlas-plan-execute/scripts/extract_plan_contract.py +191 -0
  58. package/hosts/zcode/skills/atlas-plan-execute/scripts/validate_gate_result.py +56 -0
  59. package/hosts/zcode/skills/atlas-plan-handoff/SKILL.md +183 -0
  60. package/hosts/zcode/skills/atlas-plan-handoff/agents/openai.yaml +7 -0
  61. package/hosts/zcode/skills/atlas-prd-interview/SKILL.md +82 -0
  62. package/hosts/zcode/skills/atlas-prd-interview/agents/openai.yaml +7 -0
  63. package/hosts/zcode/skills/atlas-slice-review/SKILL.md +156 -0
  64. package/hosts/zcode/skills/atlas-slice-review/agents/openai.yaml +4 -0
  65. package/hosts/zcode/skills/atlas-slice-review/references/review-contract.md +58 -0
  66. package/hosts/zcode/skills/atlas-slice-review/references/scenario-lenses.md +57 -0
  67. package/hosts/zcode/skills/atlas-slice-review/scripts/classify_findings.mjs +60 -0
  68. package/hosts/zcode/skills/atlas-slice-review/scripts/classify_findings.py +24 -0
  69. package/hosts/zcode/skills/atlas-slice-review/scripts/extract_review_slice.py +158 -0
  70. package/hosts/zcode/skills/atlas-sprint-prd-generator/SKILL.md +77 -0
  71. package/hosts/zcode/skills/atlas-sprint-prd-generator/agents/openai.yaml +7 -0
  72. package/hosts/zcode/skills/atlas-task-validator/SKILL.md +173 -0
  73. package/hosts/zcode/skills/atlas-task-validator/agents/openai.yaml +7 -0
  74. package/hosts/zcode/skills/atlas-workflow-orchestrator/SKILL.md +391 -0
  75. package/package.json +1 -1
  76. package/plugins/atlas-workflow-orchestrator/.codex-plugin/plugin.json +1 -1
  77. package/plugins/atlas-workflow-orchestrator/VERSION +1 -1
  78. package/plugins/atlas-workflow-orchestrator/orchestrator/README.md +1 -1
  79. package/plugins/atlas-workflow-orchestrator/orchestrator/references/host-adapters.md +13 -12
  80. package/plugins/atlas-workflow-orchestrator/orchestrator/skills/atlas-workflow-orchestrator/SKILL.md +2 -0
  81. package/plugins/atlas-workflow-orchestrator/packages/mcp-server/README.md +1 -1
  82. package/plugins/atlas-workflow-orchestrator/packages/mcp-server/package.json +1 -1
  83. package/plugins/atlas-workflow-orchestrator/packages/mcp-server/server.js +69 -7
  84. package/plugins/atlas-workflow-orchestrator/skills/atlas-workflow-orchestrator/SKILL.md +2 -0
@@ -0,0 +1,158 @@
1
+ ---
2
+ name: atlas-findings-repair
3
+ description: Skill `atlas-findings-repair`. Corrige findings P0/P1/P2 retornados por `atlas-task-validator` dentro do boundary já executado, sem reabrir o plano completo. Use quando o orquestrador receber `fail` do validator (topologia sibling, única em todos os hosts) e precisar de um reparo enxuto, bounded e sem reusar `atlas-plan-execute`.
4
+ ---
5
+
6
+ # Atlas Findings Repair
7
+
8
+ Use esta skill apenas no caminho de recuperação pós-validator. Ela **não** substitui `atlas-plan-execute` nem `atlas-direct-execute`; serve só para corrigir findings bloqueantes já emitidos pelo `atlas-task-validator`.
9
+
10
+ ## Finalidade
11
+
12
+ Corrigir findings P0/P1/P2 dentro do boundary atual com o menor contexto possível:
13
+
14
+ - sem replanejar
15
+ - sem carregar skill de execução
16
+ - sem criar novas tasks
17
+ - sem ampliar o escopo
18
+ - sem despachar validator
19
+
20
+ O orquestrador é dono do ciclo sibling em todos os hosts:
21
+
22
+ 1. executor inicial entrega `state_path`
23
+ 2. orquestrador roda `atlas-task-validator`
24
+ 3. se `fail`, orquestrador trava o ciclo em `repair_required`
25
+ 4. orquestrador chama `atlas_lock_validator(action=repair_start, state_path=...)`
26
+ 5. orquestrador despacha `atlas-findings-repair` com o pacote retornado pelo lock
27
+ 6. esta skill corrige e devolve `repair_complete`
28
+ 7. orquestrador fecha o lock com `repair_run_id`
29
+ 8. orquestrador roda o **2º e último** validator
30
+
31
+ ## Entrada obrigatória
32
+
33
+ Receba do orquestrador:
34
+
35
+ - `state_path`
36
+ - findings estruturados do validator
37
+ - `validator_attempt`
38
+ - `repair_run_id`
39
+ - `repair_budget: 1`
40
+
41
+ Leia `atlas_run_state` como fonte primária do estado da run. O `state_path` continua sendo a fronteira canônica da slice.
42
+
43
+ ## Regras duras
44
+
45
+ 1. **Não carregar `atlas-plan-execute` nem `atlas-direct-execute`.**
46
+ 2. **Não reabrir o plano inteiro.** Corrija só o que os findings exigem.
47
+ 3. **Não aumentar boundary** sem evidência estrita de dependência técnica inevitável.
48
+ 4. **Não corrigir observações/P3 por capricho.** O foco é fechamento do `fail`.
49
+ 5. **Não despachar validator, review ou qualquer subagente.** O orquestrador faz isso.
50
+ 6. **Não iniciar terceiro ciclo.** Esta skill existe só entre validator 1 e validator 2.
51
+ 7. **Não trocar o `state_path`.** Atualize o arquivo original em lugar; redirecionar o boundary invalida a correlação do repair.
52
+ 8. **Não inventar correlação.** IDs devem existir no packet recebido, sem duplicatas; todo arquivo tocado pertence a pelo menos um `repair_evidence` recebido e nenhum arquivo extra é permitido.
53
+
54
+ ## Fluxo
55
+
56
+ ### 1. Ler o boundary
57
+
58
+ Abra o `state_path` e extraia:
59
+
60
+ - `files_changed`
61
+ - `diff_stat`
62
+ - `plan_path`
63
+ - `boundary_refs`
64
+
65
+ Leia do plano apenas o mínimo necessário:
66
+
67
+ - Section 2 — invariantes
68
+ - Section 6 — contratos técnicos
69
+ - Section 8 — checklist
70
+
71
+ Capture também `base_sha`, `head_sha`, `task_evidence`, `repair_evidence`, `worktree_baseline` e `worktree_final` do state.
72
+
73
+ ### 2. Ler os findings recebidos
74
+
75
+ Trabalhe somente com findings de severidade:
76
+
77
+ - `P0`
78
+ - `P1`
79
+ - `P2`
80
+
81
+ Cada finding novo deve ter `id`, `failure_mode`, `evidence`, `recommendation` e `fix_validation`. `msg` é compatibilidade deprecated e não substitui esses campos.
82
+
83
+ Se o pacote vier vazio, inconsistente ou sem finding reparável, pare em `blocked`.
84
+
85
+ ### 3. Montar contrato mínimo de reparo
86
+
87
+ Antes de editar, reduza o trabalho a:
88
+
89
+ - finding alvo
90
+ - arquivos a tocar
91
+ - invariante em risco
92
+ - check focado
93
+ - budget de reparo
94
+
95
+ ### 4. Corrigir de forma bounded
96
+
97
+ Permissões:
98
+
99
+ - corrigir arquivos do boundary
100
+ - tocar arquivo adjacente apenas quando necessário para satisfazer contrato/invariante
101
+
102
+ Proibições:
103
+
104
+ - cleanup oportunista
105
+ - refactor largo
106
+ - nova feature
107
+ - mudança fora da causa do finding
108
+
109
+ ### 5. Rodar gates focados
110
+
111
+ Rode só validações coerentes com o diff:
112
+
113
+ - teste alvo
114
+ - lint/analyze/typecheck do pacote afetado
115
+ - `git diff --check`
116
+
117
+ Se o finding persistir por falta de decisão de produto, dependência externa ou widening de escopo, pare em `blocked`.
118
+
119
+ ### 6. Atualizar evidência
120
+
121
+ Ao terminar:
122
+
123
+ - atualize `files_changed` com todo arquivo tocado, inclusive novo/adjacente
124
+ - recompute `head_sha` (`git rev-parse HEAD`) e `diff_stat`; preserve `base_sha`
125
+ - preserve `worktree_baseline` e recapture `worktree_final` após o repair; derive o boundary completo do delta entre snapshots
126
+ - acrescente `repair_evidence[]` no shape `{finding_id, files_touched, checks_run, status}`
127
+ - garanta que cada `repair_evidence.files_touched` esteja em `files_changed`
128
+ - mantenha a mesma slice
129
+ - não invente novo run state paralelo
130
+
131
+ ### 7. Devolver resultado ao orquestrador
132
+
133
+ Retorne saída curta e estruturada com:
134
+
135
+ - `status: repair_complete | blocked`
136
+ - `repair_run_id`
137
+ - `state_path`
138
+ - `files_touched`
139
+ - `checks_run`
140
+ - `repairs`: array `{finding_id, files_touched, checks_run, status: resolved|blocked}`
141
+ - `residual_risk` (se houver)
142
+
143
+ O orquestrador chamará `atlas_lock_validator(action=repair_complete, repair_run_id=..., state_path=<mesmo path original>)` e só então poderá despachar o validator final.
144
+ Antes disso, ele deve ter aberto o slot com `atlas_lock_validator(action=repair_start, state_path=...)`; `repair_run_id` é obrigatório no fechamento.
145
+
146
+ ## Stop conditions
147
+
148
+ Pare e reporte `blocked` quando:
149
+
150
+ - finding exige reabrir decisão fechada
151
+ - finding exige ampliar escopo além da slice
152
+ - mesmo erro repete sem sinal novo
153
+ - correção depende de ambiente ausente
154
+ - pacote de findings não é confiável
155
+
156
+ ## Resultado esperado
157
+
158
+ Esta skill deve ser menor e mais barata que um executor completo, mas ainda disciplinada. Ela repara findings; ela **não** “continua a execução”.
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "Atlas Findings Repair"
3
+ short_description: "Repair-only post-validator fixer for bounded findings"
4
+ default_prompt: "Use $atlas-findings-repair to fix the blocking validator findings inside the current slice boundary without reloading the full executor."
5
+
6
+ policy:
7
+ allow_implicit_invocation: true
@@ -0,0 +1,175 @@
1
+ ---
2
+ name: atlas-plan-execute
3
+ description: Executa planos produzidos por `atlas-plan-handoff` task-a-task com gates finitos e self-repair local pré-handoff (lint/tests/diff — máximo 2 passes por task). Ao concluir todas as tasks da slice, escreve o state file, para toda mutação e retorna `validator_handoff_required` ao orquestrador para validação fria sibling via `atlas-task-validator`. O orquestrador consome o veredito e decide sobre repair ou fechamento — este executor nunca valida o próprio trabalho nem processa resultado do validador. Use quando o cliente precisar implementar um plano sem derivar dos invariantes.
4
+ ---
5
+
6
+ # Atlas Plan Execute
7
+
8
+ Use this skill to turn a `atlas-plan-handoff` artifact into a controlled execution loop.
9
+
10
+ Prefer finite, stage-based execution over continuous self-critique. The goal is to finish the task with high confidence, not to keep polishing indefinitely.
11
+
12
+ ---
13
+
14
+ ## Execution Model
15
+
16
+ Operate as a bounded state machine:
17
+ `ready` → `implementing` → `gating` → `repairing` (self-repair LOCAL, gates pré-handoff) → `task_done` → `validator_handoff_required` (or `blocked`).
18
+
19
+ `repairing` cobre exclusivamente falhas de gates locais (lint, analyze, tests, diff-check) introduzidas pelo diff corrente — máximo 2 passes por task. O executor não entra em `repairing` pós-validação; qualquer repair pós-veredito é de responsabilidade do orquestrador via `atlas-findings-repair`. Após `task_done` para todas as tasks da slice, o executor escreve o state file e transita para `validator_handoff_required` — não existe `slice_validating` nem `slice_done` no escopo deste executor.
20
+
21
+ ## State persistence
22
+
23
+ Use `atlas_run_state` as the primary source of run state. Do not read or write run ledger files directly. If the MCP is unavailable, report the gate as unprovable and abort instead of continuing with a silent file fallback.
24
+
25
+ ## Executor liveness checkpoints
26
+
27
+ Depois de carregar esta skill e antes de qualquer discovery longo, emita um checkpoint MCP:
28
+
29
+ ```json
30
+ atlas_lock_dispatch({
31
+ "action": "checkpoint",
32
+ "phase": "plan_execute",
33
+ "event": "executor_started"
34
+ })
35
+ ```
36
+
37
+ Em seguida, emita checkpoints materiais conforme avança:
38
+
39
+ - `skill_loaded` — skill carregada e contrato reconhecido.
40
+ - `plan_loaded` — plano/PRD de entrada lido.
41
+ - `handoff_accepted` — `plan_path`, `state_path` alvo, boundary e tasks aceitos.
42
+ - `task_started` — primeira task começou.
43
+ - `first_write` — primeira mutação de workspace feita.
44
+ - `state_path_created` — state file escrito antes de devolver `validator_handoff_required`.
45
+
46
+ Se não conseguir emitir checkpoint por MCP, retorne `blocked`: liveness não é comprovável. Não fique em discovery/preflight interno sem checkpoint. O orquestrador trata ausência de checkpoint como `stalled` via Gate G12.
47
+
48
+ ## Plan path resolution
49
+
50
+ Resolve plan paths in this order:
51
+
52
+ 1. `.atlas/plans/`
53
+ 2. `.cursor/plans/` with a deprecation warning
54
+ 3. `.codex/plans/` with a deprecation warning
55
+
56
+ New or rewritten plan artifacts must use `.atlas/plans/`.
57
+
58
+ ## Host adapter
59
+
60
+ This skill is host-agnostic. To resolve any host-specific verb (subagent dispatch, native todo tool, plan paths), call the MCP tool `atlas_capabilities` first and use the returned descriptor. Canonical reference: `packages/orchestrator/references/host-adapters.md`. Do not hardcode a host name in reasoning — read it from the descriptor.
61
+
62
+ ## Native todo mirror
63
+
64
+ When entering `implementing` for the first time in a slice, mirror the plan tasks into the native todo surface named by `atlas_capabilities.todo_tool` (e.g. `TodoWrite` on Claude Code, `tasks` on Codex App). If `todo_tool` is `null`, proceed without a mirror — do not invent a tool.
65
+
66
+ The plan is the SSoT. Map `ready` to `pending`, `implementing`/`gating` to `in_progress`, and `task_done` to `completed`. If todo state diverges, sync from the plan to todo, never from todo back to the plan. Do not create parallel todos that are not derived from plan task IDs.
67
+
68
+ ## Review gate
69
+
70
+ `atlas-slice-review` is dispatched only when `--review` is present in the user command or executor arguments. Without `--review`, the orchestrator closes the slice upon receiving `pass` or `pass_with_observations` from the validator — this executor is not involved in that decision and never observes the validator verdict directly.
71
+
72
+ ## Entrada via modo `execute` (PRD D1/D13)
73
+
74
+ Esta skill aceita entrada pelo modo `execute` do orquestrador: um `PLAN_*.md` pronto de pipeline curta, apontado diretamente e já reverificado na entrada (`atlas_verify_artifact` + TC) pelo orquestrador. **A entrada `execute` é o mesmo executor, com as mesmas garantias** — o contrato não muda: o state file (`.atlas/state/<run_id>/<slice>.json`) permanece **obrigatório** e o `atlas-task-validator` (validador frio, só `state_path`) permanece **obrigatório** antes do relatório final. Não há caminho de execução sem state file nem sem validador, em nenhum modo de entrada.
75
+
76
+ ---
77
+
78
+ ## Required Workflow
79
+
80
+ ### 1. Load the plan as an execution contract
81
+ First, emit `executor_started`, then `skill_loaded`, before doing any long scan.
82
+
83
+ Read the `atlas-plan-handoff` artifact. Extract at minimum:
84
+ * **Execution metadata**: Prefix, mode, and validator options.
85
+ * **Executive translation and PRD links** (from Section 1 — include path to PRD; cite `PRD §3` D* IDs, do not paste the full D* table).
86
+ * **Execution invariants** (from Section 2).
87
+ * **Current state at sprint opening** (from Section 4 — not Section 2).
88
+ * **Pitfalls** (from Section 3).
89
+ * **All execution tasks TNN** (from Section 5).
90
+ * **Technical contracts** (from Section 6).
91
+ * **Slices of execution** (from Section 7).
92
+ * **Checklist for the validator** (from Section 8).
93
+
94
+ Treat headings as semantic. If the plan uses equivalent wording but carries the same contract, continue. If the plan is missing the substance, stop and report.
95
+ The old Gate of Readiness (§15) and Handoff Prompt (§16) are **no longer required** in the compact template.
96
+ If optional Section 9 (open questions / real blockers — **not** PRD §7 Apêndice/Referências) has active blocking items, stop execution and request clarification.
97
+
98
+ When Section 8 checklist is thin, read **PRD §4–6** from the PRD path in the plan header for business acceptance.
99
+
100
+ After the plan is loaded, emit `plan_loaded`. After validating the execution boundary and `state_path` target, emit `handoff_accepted`.
101
+
102
+ ### 2. Create a task-scoped execution contract
103
+ Before editing code, write a short task contract for the current task only (objective, files, invariants, local checks, and repair budget).
104
+
105
+ ### 3. Implement in the smallest coherent slice
106
+ Do not implement the entire feature before validating anything. Prefer one task at a time. Follow closed decisions from the plan.
107
+
108
+ Before the first concrete task, emit `task_started`. After the first workspace mutation, emit `first_write`.
109
+
110
+ ### 4. Run a focused quality gate after each task slice
111
+ Run only the checks that are relevant to the current diff and task risks (linter, analyze of the affected package, or tests).
112
+
113
+ ### 5. Repair only what the current diff introduced
114
+ If the gate fails, classify the outcome as `fixable` (maximum 2 repair passes per task) or `blocked`.
115
+
116
+ ### 6. Enforce hard stop conditions
117
+ Stop repair and move to `blocked` when budget is exhausted, the same failure repeats twice, or the fix requires reopening closed plan decisions.
118
+
119
+ ### 7. Close the task with evidence
120
+ Mark a task complete and move to the next. Once all tasks are `completed`, write the state file and transition to `validator_handoff_required`.
121
+
122
+ ### 8. Write the state file and hand off to the orchestrator
123
+ After all tasks in the current slice are complete, write the state file boundary. The cold validation runs as an isolated **sibling** dispatched by the orchestrator — never by this executor (see below).
124
+
125
+ #### State file boundary
126
+
127
+ Create `.atlas/state/<run_id>/<slice>.json` following `packages/templates/STATE_FILE_SCHEMA.md`:
128
+
129
+ ```json
130
+ {
131
+ "run_id": "<run_id>",
132
+ "slice": "<slice id>",
133
+ "base_sha": "<base commit explícito do plano/handoff>",
134
+ "head_sha": "<git rev-parse HEAD ao fechar a execução>",
135
+ "contract_kind": "plan",
136
+ "tasks": ["T01"],
137
+ "files_changed": ["relative/path.ext"],
138
+ "diff_stat": "N files, +X -Y",
139
+ "plan_path": ".atlas/plans/<id>.plan.md",
140
+ "boundary_refs": ["§2.I1", "§6.1", "§8"],
141
+ "obligations": [],
142
+ "invariants": [{"id": "I1", "requirement": "<invariante>", "expected_evidence": ["<path/check>"]}],
143
+ "scenario_probes": [{"id": "S1", "scenario": "<cenário>", "expected": "<resultado>"}],
144
+ "risk_probes": [{"id": "R1", "risk": "<risco>", "probe": "<pergunta verificável>"}],
145
+ "validation_map": [{"obligation_ids": [], "checks": ["<comando>"], "status": "passed"}],
146
+ "task_evidence": [{"task": "T01", "files": ["relative/path.ext"], "checks": ["<comando>"], "result": "passed"}],
147
+ "repair_evidence": [],
148
+ "worktree_baseline": [{"path": "relative/preexisting.ext", "status": "M", "sha256": "<64 hex>"}],
149
+ "worktree_final": [{"path": "relative/preexisting.ext", "status": "M", "sha256": "<64 hex>"}],
150
+ "executed_at": "ISO8601",
151
+ "executor_skill": "atlas-plan-execute"
152
+ }
153
+ ```
154
+
155
+ Capture `base_sha` da referência explícita do plano/handoff; nunca infira pelo nome da branch. Antes da primeira mutação, capture `worktree_baseline`; imediatamente antes do handoff, capture `worktree_final`. `files_changed` e `task_evidence` representam exatamente `base_sha...head_sha` + delta entre snapshots. Dirty preexistente byte/status-idêntico fica fora; qualquer alteração posterior entra.
156
+
157
+ Validation is always **sibling**, on every host. The validator is registered as a real subagent on every host, but this executor **never** dispatches it and never validates its own work. After tasks and local gates pass and the state file is written, this executor **stops mutation** and returns `validator_handoff_required` with the `state_path`. The orchestrator dispatches `atlas-task-validator` as the next isolated sibling phase, locks it via `atlas_lock_validator`, and — if the verdict is `fail` — dispatches `atlas-findings-repair` (not this executor) before the **2nd and last** validator.
158
+
159
+ After writing the state file and before returning, emit `state_path_created` with the same `state_path`.
160
+ Without this exact checkpoint, `atlas_lock_validator(start)` blocks in G12 and the orchestrator cannot dispatch the cold validator.
161
+
162
+ The only handoff input is `state_path`. Do not paste the contract, diff, or task list inline. The validator reads everything it needs from the state file and the plan it points to. (`atlas_capabilities` is the runtime source of truth for the dispatch mechanism the orchestrator uses — see `references/host-adapters.md`.)
163
+
164
+ **Finish all local work before the handoff — then stop idle.** Finish every local gate (lint, analyze, tests, `git diff --check`, diff-stat) and write the state file **before** returning the handoff. After returning `validator_handoff_required`, the executor must not mutate anything: the orchestrator now owns the slice, and any mutation here would change what the sibling validator reads and breaks determinism (same failure class as the orchestrator's G9).
165
+
166
+ ### 9. The orchestrator consumes the verdict
167
+ This executor does not parse the validator output — the **orchestrator** does, deciding only from `verdict`:
168
+
169
+ - `pass` / `pass_with_observations`: terminal — close the slice. Observations and `boundary_violations` returned alongside a non-`fail` verdict are reported residuals, never a trigger for another validator dispatch.
170
+ - `fail`: the orchestrator opens `repair_start`, dispatches `atlas-findings-repair`, closes with `repair_run_id`, then runs the **2nd and last** validator (max 2 cycles total). This executor is not reused for the retry.
171
+
172
+ Never decide by substring matching prose. Once the slice is closed, do not edit code, tests, or boundary files just to satisfy an observation; that reopens the slice and forces an avoidable re-validation. Real follow-up from an observation goes to the final report or a backlog item, not into an extra in-slice change.
173
+
174
+ ### 10. Report executor handoff
175
+ Report only completed tasks, local validations, files changed, and `validator_handoff_required` with `state_path`. Validator verdict/cycles and final residuals belong exclusively to the orchestrator's final report.
@@ -0,0 +1,7 @@
1
+ interface:
2
+ display_name: "Atlas Plan Execute"
3
+ short_description: "Bounded plan execution with gates (atlas-plan-execute)"
4
+ default_prompt: "Use $atlas-plan-execute to execute this handoff plan task by task with explicit invariants, focused validation, bounded self-repair, and clear stop conditions."
5
+
6
+ policy:
7
+ allow_implicit_invocation: true
@@ -0,0 +1,88 @@
1
+ # Plan Contract
2
+
3
+ Input plans must follow `atlas-plan-handoff` and align with `PLAN_TEMPLATE.md` / `BOUNDARY_PRD_PLAN.md` (compact template, sections 1–8). Locate both in the Atlas Workflow plugin bundle at `packages/templates/`; do not use workspace-local templates as primary sources.
4
+
5
+ If `packages/templates/PLAN_TEMPLATE.md` or `packages/templates/BOUNDARY_PRD_PLAN.md` is absent from the bundle, stop with a clear `Template canônico ausente: <nome-do-template>` error. Do not fall back silently to old local, vault, or global copies.
6
+
7
+ Legacy 15-section plans (handoff prompt, architecture impact block in PRD, etc.) are **not** the target format.
8
+
9
+ ## Required execution metadata
10
+
11
+ Near the top of the artifact:
12
+
13
+ - `Plan prefix: atlas`
14
+ - `Execution mode: sequencial (T01→TN)` | `orchestrated-per-slice`
15
+ - `Executor skill: atlas-plan-execute`
16
+ - `Internal validator: atlas-task-validator`
17
+ - `External review: atlas-slice-review` (optional)
18
+
19
+ ## Required plan sections (match by meaning)
20
+
21
+ | § | Purpose |
22
+ |---|---------|
23
+ | 1 | Executive translation (`Tradução executiva`) — scope link to PRD, reference module, diffs vs mirror |
24
+ | 2 | Execution invariants (derived from `PRD §3` — cite D* IDs, do not paste full table) |
25
+ | 3 | Pitfalls (anti-pattern → fix) |
26
+ | 4 | State at sprint opening (3–6 bullets; not a global file inventory) |
27
+ | 5 | Execution tasks `#### T01.` … `TNN` |
28
+ | 6 | Technical contracts (only where PRD → code is ambiguous) |
29
+ | 8 | Validation and validator checklist (derived from `PRD §6` + §2 invariants) |
30
+
31
+ Section 7 (Slices) is required only when `execution_mode: orchestrated-per-slice`.
32
+
33
+ **Not required:** handoff prompt, planner readiness gate, full `project-rules` rules dump, full PRD scope copy, global touched-files inventory.
34
+
35
+ **Optional:** section 9 open questions / real blockers (executor must stop if active blockers remain).
36
+
37
+ ## Minimum task shape (section 5)
38
+
39
+ Each `#### TNN.` should include when applicable:
40
+
41
+ - `Objetivo` / `Objective`
42
+ - `Referência` (module or pattern — not a long path laundry list)
43
+ - `Pré-condições` / `Preconditions`
44
+ - `Mudança esperada` / `Expected change`
45
+ - `Invariantes preservados`
46
+ - `Não mudar` / `Não fazer` / `Do not do`
47
+ - `Dependências` / `Dependencies`
48
+ - `Riscos` (if not obvious)
49
+ - `Critério de done` / `Done criteria`
50
+ - `Validação local` / `Task-local validation` (command with package path)
51
+ - `Quality gates` (optional on critical tasks)
52
+ - `Casos mínimos` (test tasks only)
53
+
54
+ Paths may appear in **Referência** or **Validação local**; prefer module-level pointers per boundary policy.
55
+
56
+ ## Executor consumption map
57
+
58
+ | Contract need | Plan section |
59
+ |---------------|--------------|
60
+ | Translation, PRD links, reference module | §1 |
61
+ | Execution invariants | §2 |
62
+ | Pitfalls | §3 |
63
+ | Current codebase state | §4 |
64
+ | Tasks, done criteria, local validation | §5 |
65
+ | Technical contracts | §6 |
66
+ | Slice boundaries | §7 (orchestrated mode) |
67
+ | Validator checklist | §8 |
68
+ | Business acceptance (when §8 is thin) | PRD §4–6 (read PRD path from plan header) |
69
+
70
+ ## Why this matters
71
+
72
+ Prefix and mode are part of the execution contract, not chat memory.
73
+
74
+ If `Plan prefix` or `Execution mode` is missing, stop — do not guess the chain.
75
+
76
+ Thin tasks (`refactor bootstrap` only) are not ready for gated execution; ask for a denser plan.
77
+
78
+ Pitfalls, contracts, and invariants are binding — not commentary.
79
+
80
+ ## Parsing notes
81
+
82
+ The bundled `extract_plan_contract.py` uses heading heuristics:
83
+
84
+ - `#` … `####` headings
85
+ - task headings `#### T01. …`
86
+ - bullet lines `- …`
87
+
88
+ Normalize non-standard plans before execution or extend the parser aliases.
@@ -0,0 +1,60 @@
1
+ # Quality Gates
2
+
3
+ Choose the lightest gate that still protects the current task.
4
+
5
+ ## Gate selection order
6
+
7
+ 1. Prove the task with deterministic checks.
8
+ 2. Add semantic review against plan invariants.
9
+ 3. Add targeted runtime verification only when behavior changed in a way static checks cannot prove.
10
+ 4. Escalate to broader validation only when the task blast radius justifies it.
11
+
12
+ ## Common gate matrix
13
+
14
+ ### Pure refactor
15
+
16
+ - targeted tests for touched modules
17
+ - typecheck or analyze for touched package
18
+ - diff scan for forbidden scope expansion
19
+
20
+ ### Contract or DTO change
21
+
22
+ - compilation or typecheck
23
+ - serialization or mapper tests if available
24
+ - search for all consumers of renamed or reshaped fields
25
+ - compare with plan constraints and declared contract
26
+ - verify generated artifacts or localization files named by the plan before wiring consumers
27
+
28
+ ### UI-only change
29
+
30
+ - component, widget, or snapshot tests when available
31
+ - targeted runtime verification for changed flow
32
+ - search for accessibility or localization regressions if the repo has such rules
33
+ - verify role/permission gating when the plan distinguishes who can see or mutate related resources
34
+
35
+ ### State management or orchestration change
36
+
37
+ - focused tests around the changed store, controller, or service
38
+ - validation of loading, error, and success transitions
39
+ - explicit invariant review so closed architectural decisions are not violated
40
+ - rapid repeat-action or stale async check when the slice changes user-triggered operations
41
+
42
+ ### Data migration or cleanup
43
+
44
+ - migration-specific validation
45
+ - idempotency or rollback reasoning
46
+ - stronger stop conditions if external systems are involved
47
+
48
+ ## What not to do
49
+
50
+ - Do not run every available check after every edit.
51
+ - Do not promote unrelated warnings into mandatory work.
52
+ - Do not claim semantic safety from lint alone.
53
+ - Do not keep retrying the same failing check with no code or environment change.
54
+ - Do not repair by weakening a permission matrix, source-of-truth decision, or explicit negative scope.
55
+
56
+ ## Failure classification
57
+
58
+ - `pass`: checks passed and no unresolved high-severity invariant break remains
59
+ - `fixable`: a current-diff issue is clear and repair budget remains
60
+ - `blocked`: repair would require scope change, external dependency, environment fix, or repeated speculative retries
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env python3
2
+ """Track bounded repair attempts for a gated execution task."""
3
+
4
+ from __future__ import annotations
5
+
6
+ import argparse
7
+ import json
8
+ import pathlib
9
+ from dataclasses import dataclass, asdict
10
+
11
+
12
+ @dataclass
13
+ class BudgetState:
14
+ task_id: str
15
+ max_attempts: int = 2
16
+ max_same_failure: int = 2
17
+ attempts: int = 0
18
+ same_failure_count: int = 0
19
+ last_failure_key: str = ""
20
+ blocked: bool = False
21
+
22
+
23
+ def load_state(path: pathlib.Path) -> BudgetState:
24
+ if not path.exists():
25
+ raise FileNotFoundError(f"State file not found: {path}")
26
+ return BudgetState(**json.loads(path.read_text(encoding="utf-8")))
27
+
28
+
29
+ def save_state(path: pathlib.Path, state: BudgetState) -> None:
30
+ path.parent.mkdir(parents=True, exist_ok=True)
31
+ path.write_text(json.dumps(asdict(state), indent=2) + "\n", encoding="utf-8")
32
+
33
+
34
+ def cmd_init(args: argparse.Namespace) -> int:
35
+ state = BudgetState(
36
+ task_id=args.task_id,
37
+ max_attempts=args.max_attempts,
38
+ max_same_failure=args.max_same_failure,
39
+ )
40
+ save_state(pathlib.Path(args.state_file), state)
41
+ print(json.dumps(asdict(state), indent=2))
42
+ return 0
43
+
44
+
45
+ def cmd_record(args: argparse.Namespace) -> int:
46
+ path = pathlib.Path(args.state_file)
47
+ state = load_state(path)
48
+ state.attempts += 1
49
+
50
+ if args.failure_key:
51
+ if args.failure_key == state.last_failure_key:
52
+ state.same_failure_count += 1
53
+ else:
54
+ state.last_failure_key = args.failure_key
55
+ state.same_failure_count = 1
56
+
57
+ if state.attempts >= state.max_attempts or state.same_failure_count >= state.max_same_failure:
58
+ state.blocked = True
59
+
60
+ save_state(path, state)
61
+ print(json.dumps(asdict(state), indent=2))
62
+ return 0
63
+
64
+
65
+ def cmd_status(args: argparse.Namespace) -> int:
66
+ state = load_state(pathlib.Path(args.state_file))
67
+ print(json.dumps(asdict(state), indent=2))
68
+ return 0
69
+
70
+
71
+ def main() -> int:
72
+ parser = argparse.ArgumentParser(description=__doc__)
73
+ subparsers = parser.add_subparsers(dest="command", required=True)
74
+
75
+ init_parser = subparsers.add_parser("init")
76
+ init_parser.add_argument("state_file")
77
+ init_parser.add_argument("task_id")
78
+ init_parser.add_argument("--max-attempts", type=int, default=2)
79
+ init_parser.add_argument("--max-same-failure", type=int, default=2)
80
+ init_parser.set_defaults(func=cmd_init)
81
+
82
+ record_parser = subparsers.add_parser("record")
83
+ record_parser.add_argument("state_file")
84
+ record_parser.add_argument("--failure-key", default="")
85
+ record_parser.set_defaults(func=cmd_record)
86
+
87
+ status_parser = subparsers.add_parser("status")
88
+ status_parser.add_argument("state_file")
89
+ status_parser.set_defaults(func=cmd_status)
90
+
91
+ args = parser.parse_args()
92
+ return args.func(args)
93
+
94
+
95
+ if __name__ == "__main__":
96
+ raise SystemExit(main())