edify-agents-cli 0.2.0__py3-none-any.whl

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 (102) hide show
  1. edify/__init__.py +19 -0
  2. edify/__main__.py +6 -0
  3. edify/_toml.py +286 -0
  4. edify/agents.py +261 -0
  5. edify/anim.py +499 -0
  6. edify/assets/commands/build.md +64 -0
  7. edify/assets/commands/plan.md +68 -0
  8. edify/assets/commands/spec.md +63 -0
  9. edify/assets/commands/tasks.md +65 -0
  10. edify/assets/commands/verify.md +67 -0
  11. edify/assets/formats/plan.example.md +455 -0
  12. edify/assets/formats/plan.format.md +128 -0
  13. edify/assets/formats/spec.example.md +483 -0
  14. edify/assets/formats/spec.format.md +116 -0
  15. edify/assets/formats/tasks.example.md +712 -0
  16. edify/assets/formats/tasks.format.md +199 -0
  17. edify/assets/harvest/harvest.md +91 -0
  18. edify/assets/harvest/sources.md +295 -0
  19. edify/assets/harvest/vocab.md +52 -0
  20. edify/assets/manifest.md +30 -0
  21. edify/assets/mcp/default-registry.md +66 -0
  22. edify/assets/skills/adversary.md +61 -0
  23. edify/assets/skills/debugger.md +64 -0
  24. edify/assets/skills/implementer-general.md +53 -0
  25. edify/assets/skills/implementer-go.md +63 -0
  26. edify/assets/skills/implementer-node.md +61 -0
  27. edify/assets/skills/implementer-postgres.md +63 -0
  28. edify/assets/skills/implementer-python.md +65 -0
  29. edify/assets/skills/implementer-react.md +65 -0
  30. edify/assets/skills/planner.md +58 -0
  31. edify/assets/skills/test-writer-node.md +64 -0
  32. edify/assets/skills/test-writer-python.md +60 -0
  33. edify/assets/skills/verifier.md +67 -0
  34. edify/assets/templates/CLAUDE.md +18 -0
  35. edify/assets.py +77 -0
  36. edify/cli.py +681 -0
  37. edify/commands/__init__.py +1 -0
  38. edify/commands/check_cmd.py +72 -0
  39. edify/commands/doctor_cmd.py +206 -0
  40. edify/commands/feedback_cmd.py +90 -0
  41. edify/commands/governance_cmd.py +65 -0
  42. edify/commands/graph_cmd.py +156 -0
  43. edify/commands/harvest_cmd.py +538 -0
  44. edify/commands/init_cmd.py +333 -0
  45. edify/commands/init_new_cmd.py +151 -0
  46. edify/commands/license_cmd.py +80 -0
  47. edify/commands/mcp_cmd.py +159 -0
  48. edify/commands/self_cmd.py +185 -0
  49. edify/commands/setup_cmd.py +79 -0
  50. edify/commands/skills_cmd.py +177 -0
  51. edify/commands/upgrade_cmd.py +178 -0
  52. edify/context.py +57 -0
  53. edify/conventions.py +275 -0
  54. edify/detect.py +313 -0
  55. edify/distribution.py +40 -0
  56. edify/errors.py +66 -0
  57. edify/feedback.py +207 -0
  58. edify/formats/__init__.py +11 -0
  59. edify/formats/check.py +573 -0
  60. edify/formats/document.py +238 -0
  61. edify/formats/finding.py +50 -0
  62. edify/formats/fix.py +114 -0
  63. edify/formats/mcp.py +126 -0
  64. edify/formats/plan.py +151 -0
  65. edify/formats/skill.py +139 -0
  66. edify/formats/spec.py +164 -0
  67. edify/formats/tasks.py +321 -0
  68. edify/governance.py +316 -0
  69. edify/graph/__init__.py +11 -0
  70. edify/graph/extract.py +351 -0
  71. edify/graph/ignore.py +107 -0
  72. edify/graph/langs/__init__.py +93 -0
  73. edify/graph/langs/ctags.py +145 -0
  74. edify/graph/langs/markdown.py +41 -0
  75. edify/graph/langs/patterns.py +361 -0
  76. edify/graph/langs/python_ast.py +154 -0
  77. edify/graph/langs/sqlish.py +86 -0
  78. edify/graph/model.py +102 -0
  79. edify/graph/queries.py +211 -0
  80. edify/graph/store.py +157 -0
  81. edify/harvest/__init__.py +28 -0
  82. edify/harvest/ledger.py +191 -0
  83. edify/harvest/screen.py +236 -0
  84. edify/harvest/sources.py +298 -0
  85. edify/host.py +345 -0
  86. edify/interview.py +354 -0
  87. edify/library.py +176 -0
  88. edify/licensing/__init__.py +30 -0
  89. edify/licensing/ed25519.py +154 -0
  90. edify/licensing/projects.py +223 -0
  91. edify/licensing/tier.py +172 -0
  92. edify/licensing/token.py +149 -0
  93. edify/paths.py +282 -0
  94. edify/selfinstall.py +244 -0
  95. edify/skills.py +108 -0
  96. edify/tsv.py +109 -0
  97. edify/ui.py +334 -0
  98. edify_agents_cli-0.2.0.dist-info/METADATA +408 -0
  99. edify_agents_cli-0.2.0.dist-info/RECORD +102 -0
  100. edify_agents_cli-0.2.0.dist-info/WHEEL +4 -0
  101. edify_agents_cli-0.2.0.dist-info/entry_points.txt +2 -0
  102. edify_agents_cli-0.2.0.dist-info/licenses/LICENSE +21 -0
edify/formats/check.py ADDED
@@ -0,0 +1,573 @@
1
+ """`edify check` — the rule engine.
2
+
3
+ Every rule here is a rule the formats state. Nothing blocks: the
4
+ command prints what is wrong and a person or a CI job decides what that means.
5
+ `--exit-code` exists so a customer who needs a hard block can own one, which is the
6
+ honest scope: advisory means advisory.
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import re
12
+ from pathlib import Path
13
+
14
+ from ..graph.queries import resolve_ref
15
+ from ..graph.store import GraphStore
16
+ from ..paths import Layout
17
+ from . import mcp as mcp_format
18
+ from . import plan as plan_format
19
+ from . import skill as skill_format
20
+ from . import spec as spec_format
21
+ from . import tasks as tasks_format
22
+ from .document import citations
23
+ from .finding import Finding, Level, sort_findings
24
+
25
+ # A phase-2 done-check has to assert failure. "passes" on arrival means the task
26
+ # tested something that already existed, or tested nothing.
27
+ _ASSERTS_FAILURE = re.compile(r"\b(fail|failing|red|0 passing|no passing)\b", re.IGNORECASE)
28
+ _ASSERTS_PASS = re.compile(r"\b(pass|passes|passing|green|succeeds?)\b", re.IGNORECASE)
29
+
30
+
31
+ def check_repository(layout: Layout, store: GraphStore | None = None) -> list[Finding]:
32
+ """Everything under `specs/`, plus the installed skills and the registry."""
33
+ findings: list[Finding] = []
34
+ graph = store if (store and store.exists()) else None
35
+
36
+ if layout.specs.is_dir():
37
+ for feature_dir in sorted(p for p in layout.specs.iterdir() if p.is_dir()):
38
+ findings.extend(check_feature(layout, feature_dir, graph))
39
+
40
+ findings.extend(check_skills(layout))
41
+ findings.extend(check_mcp(layout))
42
+ return sort_findings(findings)
43
+
44
+
45
+ def check_feature(layout: Layout, feature_dir: Path, graph: GraphStore | None) -> list[Finding]:
46
+ findings: list[Finding] = []
47
+ spec_path = feature_dir / "spec.md"
48
+ plan_path = feature_dir / "plan.md"
49
+ tasks_path = feature_dir / "tasks.md"
50
+
51
+ parsed_spec = None
52
+ parsed_plan = None
53
+
54
+ if spec_path.is_file():
55
+ parsed_spec = spec_format.parse(spec_path, layout.rel(spec_path))
56
+ findings.extend(check_spec(parsed_spec))
57
+ if plan_path.is_file():
58
+ parsed_plan = plan_format.parse(plan_path, layout.rel(plan_path))
59
+ findings.extend(check_plan(parsed_plan, graph))
60
+ if tasks_path.is_file():
61
+ parsed_tasks = tasks_format.parse(tasks_path, layout.rel(tasks_path))
62
+ findings.extend(check_tasks(parsed_tasks, parsed_spec, parsed_plan, graph, layout))
63
+ return findings
64
+
65
+
66
+ # ---------------------------------------------------------------------------
67
+ # spec.md
68
+ # ---------------------------------------------------------------------------
69
+
70
+
71
+ def check_spec(spec: spec_format.Spec) -> list[Finding]:
72
+ out: list[Finding] = []
73
+ rel = spec.rel
74
+
75
+ for name in spec_format.REQUIRED_SECTIONS:
76
+ if spec.doc.section(name) is None:
77
+ out.append(
78
+ Finding(Level.ERROR, rel, 1, "spec-missing-section", f"no `## {name.title()}` section")
79
+ )
80
+
81
+ if not spec.requirements:
82
+ out.append(Finding(Level.ERROR, rel, 1, "spec-no-requirements", "no requirements table"))
83
+ if not spec.assertions:
84
+ out.append(Finding(Level.ERROR, rel, 1, "spec-no-assertions", "no assertions table"))
85
+
86
+ known = spec.assertion_ids()
87
+ for req in spec.requirements:
88
+ if not req.assertions:
89
+ out.append(
90
+ Finding(
91
+ Level.ERROR,
92
+ rel,
93
+ req.line,
94
+ "spec-requirement-unasserted",
95
+ f"{req.id} has no assertion — a requirement with no assertion is a wish",
96
+ )
97
+ )
98
+ for aid in req.assertions:
99
+ if known and aid not in known:
100
+ out.append(
101
+ Finding(
102
+ Level.ERROR, rel, req.line, "spec-unknown-assertion",
103
+ f"{req.id} names {aid}, which is not in the assertions table",
104
+ )
105
+ )
106
+
107
+ for assertion in spec.assertions:
108
+ if not assertion.kind:
109
+ out.append(
110
+ Finding(
111
+ Level.ERROR, rel, assertion.line, "spec-assertion-no-kind",
112
+ f"{assertion.id} declares no verification kind",
113
+ hint="one of: " + ", ".join(spec_format.VERIFICATION_KINDS),
114
+ )
115
+ )
116
+ elif assertion.kind not in spec_format.VERIFICATION_KINDS:
117
+ out.append(
118
+ Finding(
119
+ Level.ERROR, rel, assertion.line, "spec-assertion-bad-kind",
120
+ f"{assertion.id} declares `{assertion.kind}`, which is not on the ladder",
121
+ hint="one of: " + ", ".join(spec_format.VERIFICATION_KINDS),
122
+ )
123
+ )
124
+ if assertion.citation:
125
+ out.extend(_citation_findings(rel, assertion.citation, assertion.line, "spec-citation-no-range"))
126
+
127
+ served = {aid for req in spec.requirements for aid in req.assertions}
128
+ if served:
129
+ for assertion in spec.assertions:
130
+ if assertion.id not in served:
131
+ out.append(
132
+ Finding(
133
+ Level.WARN, rel, assertion.line, "spec-orphan-assertion",
134
+ f"{assertion.id} serves no requirement",
135
+ )
136
+ )
137
+
138
+ for item in spec.checklist:
139
+ if not item.status.strip() or set(item.status.strip()) <= {"-", "—"}:
140
+ out.append(
141
+ Finding(
142
+ Level.WARN, rel, item.line, "spec-checklist-open",
143
+ f"{item.id} is open — the human gate is what this row is for",
144
+ )
145
+ )
146
+ return out
147
+
148
+
149
+ def _citation_findings(rel: str, text: str, line: int, code: str) -> list[Finding]:
150
+ """Every reference is a file and a line, or the literal `new` (P3)."""
151
+ if text.strip().lower() in ("new", "-", "—", ""):
152
+ return []
153
+ out: list[Finding] = []
154
+ for citation in citations(text, first_line=line):
155
+ if not citation.has_range:
156
+ out.append(
157
+ Finding(
158
+ Level.WARN, rel, line, code,
159
+ f"`{citation.path}` is cited without a line range",
160
+ hint="`src/import.py` and `src/import.py:88-114` look equally correct in review; only the second lets an agent start work",
161
+ )
162
+ )
163
+ return out
164
+
165
+
166
+ # ---------------------------------------------------------------------------
167
+ # plan.md
168
+ # ---------------------------------------------------------------------------
169
+
170
+
171
+ def check_plan(plan: plan_format.Plan, graph: GraphStore | None) -> list[Finding]:
172
+ out: list[Finding] = []
173
+ rel = plan.rel
174
+
175
+ if not plan.decisions:
176
+ out.append(
177
+ Finding(Level.WARN, rel, 1, "plan-no-decisions", "no technology decisions table")
178
+ )
179
+
180
+ for decision in plan.decisions:
181
+ if not decision.version or decision.version in ("-", "—"):
182
+ out.append(
183
+ Finding(
184
+ Level.ERROR, rel, decision.line, "plan-decision-no-version",
185
+ f"{decision.id} names no exact version",
186
+ hint="`2.3`, not `^2.3` and not `latest` — this is what the docs server is pointed at",
187
+ )
188
+ )
189
+ elif re.search(r"[\^~*]|latest", decision.version, re.IGNORECASE):
190
+ out.append(
191
+ Finding(
192
+ Level.ERROR, rel, decision.line, "plan-decision-loose-version",
193
+ f"{decision.id} has a range, not a version: `{decision.version}`",
194
+ )
195
+ )
196
+ if decision.is_default and "default" not in decision.text.lower():
197
+ out.append(
198
+ Finding(
199
+ Level.WARN, rel, decision.line, "plan-decision-no-alternative",
200
+ f"{decision.id} names no alternative it beat — say it is a default rather than dressing it as a decision",
201
+ )
202
+ )
203
+
204
+ for seed in plan.seeds:
205
+ if not seed.has_range:
206
+ out.append(
207
+ Finding(
208
+ Level.WARN, rel, seed.line, "plan-seed-no-range",
209
+ f"context seed `{seed.path}` has no line range",
210
+ hint="a seed without a range transfers its cost to /tasks, which is the reason the plan exists",
211
+ )
212
+ )
213
+ elif graph is not None and resolve_ref(graph, seed.path) is None:
214
+ out.append(
215
+ Finding(
216
+ Level.WARN, rel, seed.line, "plan-seed-unresolved",
217
+ f"`{seed.path}` does not resolve against the graph",
218
+ )
219
+ )
220
+ return out
221
+
222
+
223
+ # ---------------------------------------------------------------------------
224
+ # tasks.md
225
+ # ---------------------------------------------------------------------------
226
+
227
+
228
+ def check_tasks(
229
+ tasks: tasks_format.Tasks,
230
+ spec: spec_format.Spec | None,
231
+ plan: plan_format.Plan | None,
232
+ graph: GraphStore | None,
233
+ layout: Layout,
234
+ ) -> list[Finding]:
235
+ out: list[Finding] = []
236
+ rel = tasks.rel
237
+
238
+ if not tasks.tasks:
239
+ out.append(Finding(Level.ERROR, rel, 1, "tasks-empty", "no task blocks"))
240
+ return out
241
+
242
+ known_ids = {t.id for t in tasks.tasks}
243
+ spec_ids: set[str] = set()
244
+ if spec is not None:
245
+ spec_ids = spec.requirement_ids() | spec.assertion_ids() | spec.checklist_ids()
246
+
247
+ for task in tasks.tasks:
248
+ out.extend(_check_task(task, tasks, spec, graph, layout, known_ids, spec_ids))
249
+
250
+ out.extend(_check_phases(tasks))
251
+ out.extend(_check_coverage(tasks, spec))
252
+ out.extend(_check_phase_two(tasks, spec, plan))
253
+ return out
254
+
255
+
256
+ def _check_task(
257
+ task: tasks_format.Task,
258
+ tasks: tasks_format.Tasks,
259
+ spec: spec_format.Spec | None,
260
+ graph: GraphStore | None,
261
+ layout: Layout,
262
+ known_ids: set[str],
263
+ spec_ids: set[str],
264
+ ) -> list[Finding]:
265
+ out: list[Finding] = []
266
+ rel = tasks.rel
267
+
268
+ if task.phase is None:
269
+ out.append(Finding(Level.ERROR, rel, task.line, "task-no-phase", f"{task.id} declares no phase"))
270
+ if not task.role:
271
+ out.append(Finding(Level.ERROR, rel, task.line, "task-no-role", f"{task.id} declares no role"))
272
+ if not task.discharges:
273
+ out.append(
274
+ Finding(
275
+ Level.ERROR, rel, task.line, "task-discharges-nothing",
276
+ f"{task.id} discharges nothing — this is where scope creep enters",
277
+ )
278
+ )
279
+ for did in task.discharges:
280
+ if spec_ids and did not in spec_ids:
281
+ out.append(
282
+ Finding(
283
+ Level.WARN, rel, task.line, "task-unknown-discharge",
284
+ f"{task.id} discharges {did}, which is not in the spec",
285
+ )
286
+ )
287
+ if not task.steps:
288
+ out.append(Finding(Level.ERROR, rel, task.line, "task-no-steps", f"{task.id} has no steps"))
289
+ if not task.done_when:
290
+ out.append(
291
+ Finding(Level.ERROR, rel, task.line, "task-no-done-check", f"{task.id} has no done-check")
292
+ )
293
+ if not task.files and task.phase != 7:
294
+ out.append(
295
+ Finding(Level.WARN, rel, task.line, "task-no-files", f"{task.id} names no files")
296
+ )
297
+ if not task.patterns and task.phase not in (7,):
298
+ out.append(
299
+ Finding(
300
+ Level.WARN, rel, task.line, "task-no-pattern",
301
+ f"{task.id} points at no existing pattern",
302
+ hint="say `no precedent in this codebase` explicitly rather than leaving it blank",
303
+ )
304
+ )
305
+
306
+ for dep in task.depends_on + task.parallel_with:
307
+ if dep not in known_ids:
308
+ out.append(
309
+ Finding(Level.ERROR, rel, task.line, "task-unknown-dependency", f"{task.id} names unknown task {dep}")
310
+ )
311
+
312
+ for ref in task.files:
313
+ action = ref.action.strip().lower()
314
+ if action not in tasks_format.FILE_ACTIONS:
315
+ out.append(
316
+ Finding(
317
+ Level.ERROR, rel, ref.line, "task-bad-action",
318
+ f"{task.id} file action `{ref.action}` is not new|edit|delete",
319
+ )
320
+ )
321
+ if action == "edit" and not ref.has_range:
322
+ out.append(
323
+ Finding(
324
+ Level.WARN, rel, ref.line, "task-whole-file-edit",
325
+ f"{task.id} edits `{ref.path}` with no line range",
326
+ hint="a whole-file reference passes any shape check, inflates overlap, and makes the builder open lines it did not need",
327
+ )
328
+ )
329
+ if action in ("edit", "delete") and not (layout.root / ref.path).exists():
330
+ out.append(
331
+ Finding(
332
+ Level.ERROR, rel, ref.line, "task-file-missing",
333
+ f"{task.id} {action}s `{ref.path}`, which is not on disk",
334
+ )
335
+ )
336
+ if action == "new" and (layout.root / ref.path).exists():
337
+ out.append(
338
+ Finding(
339
+ Level.WARN, rel, ref.line, "task-new-file-exists",
340
+ f"{task.id} marks `{ref.path}` as new, but it already exists",
341
+ )
342
+ )
343
+
344
+ for pattern in task.patterns:
345
+ if "no precedent" in pattern.lower():
346
+ continue
347
+ for citation in citations(pattern, first_line=task.line):
348
+ if not citation.has_range:
349
+ out.append(
350
+ Finding(
351
+ Level.WARN, rel, task.line, "task-pattern-no-range",
352
+ f"{task.id} points at `{citation.path}` with no line range",
353
+ )
354
+ )
355
+ elif graph is not None and resolve_ref(graph, citation.path) is None:
356
+ out.append(
357
+ Finding(
358
+ Level.WARN, rel, task.line, "task-pattern-unresolved",
359
+ f"{task.id} points at `{citation.path}`, which does not resolve against the graph",
360
+ )
361
+ )
362
+
363
+ for check in task.done_when:
364
+ if check.strip().lower() in ("tests pass", "it works", "the endpoint works", "done"):
365
+ out.append(
366
+ Finding(
367
+ Level.WARN, rel, task.line, "task-vague-done-check",
368
+ f"{task.id} done-check `{check}` is not a command or an observable outcome",
369
+ )
370
+ )
371
+ return out
372
+
373
+
374
+ def _check_phases(tasks: tasks_format.Tasks) -> list[Finding]:
375
+ out: list[Finding] = []
376
+ rel = tasks.rel
377
+ declared = {p.number for p in tasks.phases}
378
+ used = {t.phase for t in tasks.tasks if t.phase is not None}
379
+
380
+ for number in sorted(used - declared):
381
+ out.append(
382
+ Finding(Level.WARN, rel, 1, "tasks-phase-undeclared", f"phase {number} has tasks but no row in `## Phases`")
383
+ )
384
+ for phase in tasks.phases:
385
+ if not phase.exit_check.strip() or set(phase.exit_check.strip()) <= {"-", "—"}:
386
+ out.append(
387
+ Finding(
388
+ Level.ERROR, rel, phase.line, "phase-no-exit-check",
389
+ f"phase {phase.number} has no exit check",
390
+ hint="an exit check that is not a command anyone can run is not an exit check",
391
+ )
392
+ )
393
+ for tid in phase.task_ids:
394
+ task = tasks.by_id(tid)
395
+ if task is None:
396
+ out.append(
397
+ Finding(Level.ERROR, rel, phase.line, "phase-unknown-task", f"phase {phase.number} lists unknown task {tid}")
398
+ )
399
+ elif task.phase is not None and task.phase != phase.number:
400
+ out.append(
401
+ Finding(
402
+ Level.ERROR, rel, phase.line, "phase-task-mismatch",
403
+ f"`## Phases` puts {tid} in phase {phase.number}; its block says phase {task.phase}",
404
+ )
405
+ )
406
+ return out
407
+
408
+
409
+ def _check_coverage(tasks: tasks_format.Tasks, spec: spec_format.Spec | None) -> list[Finding]:
410
+ out: list[Finding] = []
411
+ rel = tasks.rel
412
+ if not tasks.coverage:
413
+ out.append(
414
+ Finding(Level.ERROR, rel, 1, "tasks-no-coverage", "no `## Coverage` table")
415
+ )
416
+ return out
417
+
418
+ for row in tasks.coverage:
419
+ if not row.discharged.strip():
420
+ out.append(
421
+ Finding(
422
+ Level.ERROR, rel, row.line, "coverage-empty-cell",
423
+ f"{row.source} is discharged by nothing",
424
+ hint="task ids, `waived` with a reason on the same line, or `proof-only`",
425
+ )
426
+ )
427
+ elif "waived" in row.discharged.lower() and len(row.discharged.strip()) < 12:
428
+ out.append(
429
+ Finding(
430
+ Level.WARN, rel, row.line, "coverage-waived-no-reason",
431
+ f"{row.source} is waived with no reason on the same line",
432
+ )
433
+ )
434
+
435
+ if spec is not None:
436
+ covered = {r.source.strip().strip("`*") for r in tasks.coverage}
437
+ for missing in sorted((spec.requirement_ids() | spec.checklist_ids()) - covered):
438
+ out.append(
439
+ Finding(
440
+ Level.ERROR, rel, 1, "coverage-missing-row",
441
+ f"{missing} is in the spec and has no row in `## Coverage`",
442
+ )
443
+ )
444
+ return out
445
+
446
+
447
+ def _check_phase_two(
448
+ tasks: tasks_format.Tasks,
449
+ spec: spec_format.Spec | None,
450
+ plan: plan_format.Plan | None,
451
+ ) -> list[Finding]:
452
+ """Phase 2 leaves the repository red, entirely and correctly."""
453
+ out: list[Finding] = []
454
+ rel = tasks.rel
455
+ phase_two = tasks.in_phase(2)
456
+
457
+ if spec is not None and spec.assertions and not phase_two:
458
+ out.append(
459
+ Finding(
460
+ Level.ERROR, rel, 1, "phase2-missing",
461
+ "the spec has assertions and there is no phase 2",
462
+ hint="every assertion becomes a failing executable test before any core logic exists",
463
+ )
464
+ )
465
+
466
+ for task in phase_two:
467
+ for check in task.done_when:
468
+ if _ASSERTS_FAILURE.search(check):
469
+ break
470
+ else:
471
+ if task.done_when:
472
+ out.append(
473
+ Finding(
474
+ Level.ERROR, rel, task.line, "phase2-asserts-pass",
475
+ f"{task.id} is in phase 2 and its done-check does not assert failure",
476
+ hint="`reports 6 failing tests, 0 passing` — not `tests pass`",
477
+ )
478
+ )
479
+ if not task.verification:
480
+ out.append(
481
+ Finding(
482
+ Level.WARN, rel, task.line, "phase2-no-verification-kinds",
483
+ f"{task.id} names no verification kinds",
484
+ hint="a task that quietly writes an example test where the spec asked for a property test is a silent downgrade",
485
+ )
486
+ )
487
+ for kind in task.verification:
488
+ if kind not in spec_format.VERIFICATION_KINDS:
489
+ out.append(
490
+ Finding(
491
+ Level.ERROR, rel, task.line, "phase2-bad-kind",
492
+ f"{task.id} names verification kind `{kind}`, which is not on the ladder",
493
+ )
494
+ )
495
+ elif kind in spec_format.BUDGETED_KINDS and (plan is None or not plan.verification_budget):
496
+ out.append(
497
+ Finding(
498
+ Level.WARN, rel, task.line, "phase2-unbudgeted-kind",
499
+ f"{task.id} uses `{kind}`, which plan.md does not budget",
500
+ hint="an unbudgeted model check silently becomes an example test during the build",
501
+ )
502
+ )
503
+
504
+ if spec is not None and phase_two:
505
+ asserted = {aid for t in phase_two for aid in t.discharges}
506
+ for missing in sorted(spec.assertion_ids() - asserted):
507
+ out.append(
508
+ Finding(
509
+ Level.ERROR, rel, 1, "phase2-assertion-untested",
510
+ f"assertion {missing} has no phase-2 task writing it as a failing test",
511
+ )
512
+ )
513
+
514
+ # A phase-3+ task whose done-check asserts failure is the inverse mistake.
515
+ for task in tasks.tasks:
516
+ if task.phase is not None and task.phase >= 3:
517
+ for check in task.done_when:
518
+ if _ASSERTS_FAILURE.search(check) and not _ASSERTS_PASS.search(check):
519
+ out.append(
520
+ Finding(
521
+ Level.WARN, rel, task.line, "task-asserts-failure-late",
522
+ f"{task.id} is in phase {task.phase} and its done-check asserts failure",
523
+ )
524
+ )
525
+ break
526
+ return out
527
+
528
+
529
+ # ---------------------------------------------------------------------------
530
+ # skills and servers
531
+ # ---------------------------------------------------------------------------
532
+
533
+
534
+ def check_skills(layout: Layout) -> list[Finding]:
535
+ out: list[Finding] = []
536
+ directory = layout.skills_dir
537
+ if not directory.is_dir():
538
+ return out
539
+
540
+ seen: dict[str, str] = {}
541
+ for skill in skill_format.load_all(directory, layout.root):
542
+ rel = skill.rel
543
+ for code, message, line in skill_format.validate(skill):
544
+ level = Level.WARN if code in ("skill-over-budget", "skill-unknown-field") else Level.ERROR
545
+ out.append(Finding(level, rel, line, code, message))
546
+ if skill.name:
547
+ if skill.name in seen:
548
+ out.append(
549
+ Finding(Level.ERROR, rel, 1, "skill-duplicate-name", f"`{skill.name}` is also declared in {seen[skill.name]}")
550
+ )
551
+ seen[skill.name] = rel
552
+
553
+ if not layout.skills_index.is_file():
554
+ out.append(
555
+ Finding(
556
+ Level.WARN, layout.rel(layout.skills_index), 1, "skills-no-index",
557
+ "no index.tsv — spawns cannot resolve a skill",
558
+ hint="run `edify skills index`",
559
+ )
560
+ )
561
+ return out
562
+
563
+
564
+ def check_mcp(layout: Layout) -> list[Finding]:
565
+ out: list[Finding] = []
566
+ if not layout.mcp.is_file():
567
+ return out
568
+ registry = mcp_format.parse(layout.mcp)
569
+ rel = layout.rel(layout.mcp)
570
+ for code, message, line in mcp_format.validate(registry):
571
+ level = Level.WARN if code in ("mcp-unscoped",) else Level.ERROR
572
+ out.append(Finding(level, rel, line, code, message))
573
+ return out