@elvis1513/auto-coding-skill 3.0.4 → 4.1.0
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/README.md +159 -328
- package/cli/assets/agents/explorer.toml +1 -1
- package/cli/assets/agents/fixer.toml +4 -4
- package/cli/assets/agents/reviewer.toml +12 -12
- package/cli/assets/skill/SKILL.md +135 -234
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +291 -5
- package/cli/assets/skill/data/templates/ENGINEERING.md +164 -292
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +133 -14
- package/cli/assets/skill/scripts/ap.py +884 -221
- package/cli/assets/skill/scripts/scaffold_templates.py +40 -5
- package/cli/src/index.js +180 -93
- package/cli/tests/ap_concurrency_test.py +109 -24
- package/cli/tests/ap_profiles_test.py +81 -41
- package/cli/tests/index.test.js +114 -77
- package/package.json +2 -2
- package/cli/assets/skill/data/templates/docs/tasks/closure-log.md +0 -17
- package/cli/assets/skill/data/templates/docs/tasks/taskbook.md +0 -30
|
@@ -79,6 +79,11 @@ def base_config(isolation: str | object = "adaptive") -> dict:
|
|
|
79
79
|
"no_change_scope": "changed",
|
|
80
80
|
"rules": [],
|
|
81
81
|
},
|
|
82
|
+
"risk": {
|
|
83
|
+
"rules": [
|
|
84
|
+
{"name": "test-review", "paths": ["**"], "review": "required"},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
82
87
|
"structure": {"enabled": False, "enforcement": "advisory"},
|
|
83
88
|
"verification": {
|
|
84
89
|
"target_env_required": False,
|
|
@@ -109,7 +114,9 @@ def base_config(isolation: str | object = "adaptive") -> dict:
|
|
|
109
114
|
class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
110
115
|
def make_repo(
|
|
111
116
|
self,
|
|
112
|
-
isolation: str | object = "
|
|
117
|
+
isolation: str | object = "worktree",
|
|
118
|
+
*,
|
|
119
|
+
require_review: bool = True,
|
|
113
120
|
) -> tuple[Path, Path, Path]:
|
|
114
121
|
temp = tempfile.TemporaryDirectory(prefix="autocoding-concurrency-")
|
|
115
122
|
self.addCleanup(temp.cleanup)
|
|
@@ -125,6 +132,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
125
132
|
git(repo, "config", "user.name", "Auto Coding Test")
|
|
126
133
|
|
|
127
134
|
config = base_config(isolation)
|
|
135
|
+
if not require_review:
|
|
136
|
+
config["risk"]["rules"] = []
|
|
128
137
|
if "concurrency" in config:
|
|
129
138
|
config["concurrency"]["worktree_root"] = str(worktrees)
|
|
130
139
|
engineering = repo / "docs" / "ENGINEERING.md"
|
|
@@ -193,7 +202,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
193
202
|
return current_path
|
|
194
203
|
self.fail(f"no worktree registered for {wanted}")
|
|
195
204
|
|
|
196
|
-
def start_task(self, repo: Path, task_id: str) -> Path:
|
|
205
|
+
def start_task(self, repo: Path, task_id: str, owned_path: str = ".") -> Path:
|
|
197
206
|
result = self.ap(
|
|
198
207
|
repo,
|
|
199
208
|
"task-start",
|
|
@@ -201,7 +210,9 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
201
210
|
"--base",
|
|
202
211
|
"origin/dev",
|
|
203
212
|
"--owned-path",
|
|
204
|
-
|
|
213
|
+
owned_path,
|
|
214
|
+
"--isolated",
|
|
215
|
+
"--review-required",
|
|
205
216
|
)
|
|
206
217
|
worktree = self.task_worktree(repo, task_id)
|
|
207
218
|
self.assertIn(task_id, result.stdout + result.stderr)
|
|
@@ -358,19 +369,42 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
358
369
|
),
|
|
359
370
|
"task-start must persist a task manifest in the Git common directory",
|
|
360
371
|
)
|
|
361
|
-
|
|
362
|
-
|
|
372
|
+
self.assertFalse(
|
|
373
|
+
(worktree / "docs" / "tasks" / "active" / "START-1.md").exists(),
|
|
374
|
+
"4.0 machine state must not create tracked active-task documents",
|
|
363
375
|
)
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
"
|
|
371
|
-
"
|
|
372
|
-
|
|
373
|
-
|
|
376
|
+
|
|
377
|
+
def test_clean_serial_task_uses_direct_branch_and_no_diff_is_noop(self) -> None:
|
|
378
|
+
_, repo, remote = self.make_repo("adaptive", require_review=False)
|
|
379
|
+
worktrees_before = git_output(repo, "worktree", "list", "--porcelain")
|
|
380
|
+
start = self.ap(
|
|
381
|
+
repo,
|
|
382
|
+
"task-start",
|
|
383
|
+
"DIRECT-1",
|
|
384
|
+
"--base",
|
|
385
|
+
"origin/dev",
|
|
386
|
+
"--owned-path",
|
|
387
|
+
"shared.txt",
|
|
388
|
+
)
|
|
389
|
+
self.assertIn("execution_mode=direct", start.stdout)
|
|
390
|
+
self.assertEqual(worktrees_before, git_output(repo, "worktree", "list", "--porcelain"))
|
|
391
|
+
self.assert_local_branch(repo, "codex/DIRECT-1", False)
|
|
392
|
+
status = json.loads(self.ap(repo, "task-status", "DIRECT-1", "--json").stdout)["tasks"][0]
|
|
393
|
+
self.assertEqual("direct", status["execution_mode"])
|
|
394
|
+
self.assertFalse((repo / "docs" / "tasks" / "active" / "DIRECT-1.md").exists())
|
|
395
|
+
|
|
396
|
+
(repo / "shared.txt").write_text("direct\n", encoding="utf-8")
|
|
397
|
+
pushed = self.ap(repo, "commit-push", "DIRECT-1", "--msg", "DIRECT-1: update")
|
|
398
|
+
self.assertIn("execution_mode=direct", pushed.stdout)
|
|
399
|
+
self.assertEqual("direct", git_output(remote, "show", "refs/heads/dev:shared.txt"))
|
|
400
|
+
self.assertFalse(self.registry_manifest_path(repo, "DIRECT-1").exists())
|
|
401
|
+
|
|
402
|
+
before = git_output(repo, "rev-parse", "HEAD")
|
|
403
|
+
self.ap(repo, "task-start", "DIRECT-NOOP", "--owned-path", "shared.txt")
|
|
404
|
+
noop = self.ap(repo, "commit-push", "DIRECT-NOOP", "--msg", "DIRECT-NOOP: none")
|
|
405
|
+
self.assertIn("NOOP", noop.stdout)
|
|
406
|
+
self.assertEqual(before, git_output(repo, "rev-parse", "HEAD"))
|
|
407
|
+
self.assertFalse(self.registry_manifest_path(repo, "DIRECT-NOOP").exists())
|
|
374
408
|
|
|
375
409
|
def test_schema_one_task_status_fails_closed_with_migration_recovery(self) -> None:
|
|
376
410
|
_, repo, _ = self.make_repo()
|
|
@@ -667,8 +701,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
667
701
|
|
|
668
702
|
def test_control_commands_are_rejected_from_another_task_worktree(self) -> None:
|
|
669
703
|
_, repo, _ = self.make_repo()
|
|
670
|
-
first = self.start_task(repo, "CROSS-1")
|
|
671
|
-
second = self.start_task(repo, "CROSS-2")
|
|
704
|
+
first = self.start_task(repo, "CROSS-1", "cross/one")
|
|
705
|
+
second = self.start_task(repo, "CROSS-2", "cross/two")
|
|
672
706
|
|
|
673
707
|
commands = [
|
|
674
708
|
("task-integrate", "CROSS-1"),
|
|
@@ -701,6 +735,58 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
701
735
|
}
|
|
702
736
|
self.assertEqual(before, after)
|
|
703
737
|
|
|
738
|
+
def test_task_start_rejects_overlapping_active_owned_paths(self) -> None:
|
|
739
|
+
_, repo, _ = self.make_repo()
|
|
740
|
+
first = self.start_task(repo, "OWNER-1", "backend")
|
|
741
|
+
result = self.ap(
|
|
742
|
+
repo,
|
|
743
|
+
"task-start",
|
|
744
|
+
"OWNER-2",
|
|
745
|
+
"--base",
|
|
746
|
+
"origin/dev",
|
|
747
|
+
"--owned-path",
|
|
748
|
+
"backend/api",
|
|
749
|
+
"--isolated",
|
|
750
|
+
check=False,
|
|
751
|
+
)
|
|
752
|
+
self.assertNotEqual(0, result.returncode)
|
|
753
|
+
self.assertIn("overlap active task OWNER-1", result.stdout + result.stderr)
|
|
754
|
+
self.assertTrue(first.exists())
|
|
755
|
+
self.assertFalse(self.registry_manifest_path(repo, "OWNER-2").exists())
|
|
756
|
+
self.assert_local_branch(repo, "codex/OWNER-2", False)
|
|
757
|
+
|
|
758
|
+
def test_task_start_rejects_terminal_ledger_lifecycle_and_multi_writer(self) -> None:
|
|
759
|
+
_, repo, _ = self.make_repo()
|
|
760
|
+
terminal = self.ap(
|
|
761
|
+
repo,
|
|
762
|
+
"task-start",
|
|
763
|
+
"LEDGER-END",
|
|
764
|
+
"--base",
|
|
765
|
+
"origin/dev",
|
|
766
|
+
"--owned-path",
|
|
767
|
+
"docs/tasks/closure-log.md",
|
|
768
|
+
check=False,
|
|
769
|
+
)
|
|
770
|
+
self.assertNotEqual(0, terminal.returncode)
|
|
771
|
+
self.assertIn("terminal maintenance", terminal.stdout + terminal.stderr)
|
|
772
|
+
self.assertFalse(self.registry_manifest_path(repo, "LEDGER-END").exists())
|
|
773
|
+
|
|
774
|
+
multi = self.ap(
|
|
775
|
+
repo,
|
|
776
|
+
"task-start",
|
|
777
|
+
"MULTI-1",
|
|
778
|
+
"--base",
|
|
779
|
+
"origin/dev",
|
|
780
|
+
"--owned-path",
|
|
781
|
+
"frontend",
|
|
782
|
+
"--writers",
|
|
783
|
+
"2",
|
|
784
|
+
check=False,
|
|
785
|
+
)
|
|
786
|
+
self.assertNotEqual(0, multi.returncode)
|
|
787
|
+
self.assertIn("exactly one writer lease", multi.stdout + multi.stderr)
|
|
788
|
+
self.assertFalse(self.registry_manifest_path(repo, "MULTI-1").exists())
|
|
789
|
+
|
|
704
790
|
def test_missing_task_manifest_is_rejected_in_linked_worktree(self) -> None:
|
|
705
791
|
_, repo, remote = self.make_repo("worktree")
|
|
706
792
|
worktree = self.start_task(repo, "NO-MANIFEST")
|
|
@@ -752,8 +838,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
752
838
|
|
|
753
839
|
def test_commit_push_requires_matching_manifest_and_isolated_worktree(self) -> None:
|
|
754
840
|
_, repo, remote = self.make_repo()
|
|
755
|
-
worktree = self.start_task(repo, "ISOLATED-1")
|
|
756
|
-
second_worktree = self.start_task(repo, "ISOLATED-2")
|
|
841
|
+
worktree = self.start_task(repo, "ISOLATED-1", "task-only.txt")
|
|
842
|
+
second_worktree = self.start_task(repo, "ISOLATED-2", "second-task-only.txt")
|
|
757
843
|
(worktree / "task-only.txt").write_text("task change\n", encoding="utf-8")
|
|
758
844
|
(second_worktree / "second-task-only.txt").write_text(
|
|
759
845
|
"second task change\n",
|
|
@@ -780,7 +866,6 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
780
866
|
self.assertIn("worktree", (primary.stdout + primary.stderr).lower())
|
|
781
867
|
|
|
782
868
|
second_status = git(second_worktree, "status", "--short").stdout
|
|
783
|
-
self.assertIn("?? docs/tasks/active/", second_status)
|
|
784
869
|
self.assertIn("?? second-task-only.txt", second_status)
|
|
785
870
|
self.approve_task(worktree, "ISOLATED-1")
|
|
786
871
|
self.approve_task(second_worktree, "ISOLATED-2")
|
|
@@ -920,8 +1005,8 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
920
1005
|
|
|
921
1006
|
def test_task_deletion_is_isolated_and_committed_only_on_its_task_branch(self) -> None:
|
|
922
1007
|
_, repo, remote = self.make_repo()
|
|
923
|
-
deleting = self.start_task(repo, "DELETE-1")
|
|
924
|
-
observer = self.start_task(repo, "DELETE-2")
|
|
1008
|
+
deleting = self.start_task(repo, "DELETE-1", "shared.txt")
|
|
1009
|
+
observer = self.start_task(repo, "DELETE-2", "observer.txt")
|
|
925
1010
|
(deleting / "shared.txt").unlink()
|
|
926
1011
|
(observer / "observer.txt").write_text("observer\n", encoding="utf-8")
|
|
927
1012
|
|
|
@@ -939,7 +1024,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
939
1024
|
def test_task_finish_refuses_dirty_or_unmerged_tasks(self) -> None:
|
|
940
1025
|
_, repo, _ = self.make_repo()
|
|
941
1026
|
|
|
942
|
-
dirty_worktree = self.start_task(repo, "DIRTY-1")
|
|
1027
|
+
dirty_worktree = self.start_task(repo, "DIRTY-1", "dirty.txt")
|
|
943
1028
|
(dirty_worktree / "dirty.txt").write_text("not committed\n", encoding="utf-8")
|
|
944
1029
|
dirty = self.ap(repo, "task-finish", "DIRTY-1", check=False)
|
|
945
1030
|
self.assertNotEqual(0, dirty.returncode)
|
|
@@ -947,7 +1032,7 @@ class AutoCodingConcurrencyTests(unittest.TestCase):
|
|
|
947
1032
|
self.assert_local_branch(repo, "codex/DIRTY-1", True)
|
|
948
1033
|
self.assertTrue((dirty_worktree / "dirty.txt").exists())
|
|
949
1034
|
|
|
950
|
-
unmerged_worktree = self.start_task(repo, "UNMERGED-1")
|
|
1035
|
+
unmerged_worktree = self.start_task(repo, "UNMERGED-1", "unmerged.txt")
|
|
951
1036
|
(unmerged_worktree / "unmerged.txt").write_text("committed only on task\n", encoding="utf-8")
|
|
952
1037
|
git(unmerged_worktree, "add", "unmerged.txt")
|
|
953
1038
|
git(unmerged_worktree, "commit", "-qm", "unmerged task commit")
|
|
@@ -50,9 +50,9 @@ def base_config() -> dict:
|
|
|
50
50
|
},
|
|
51
51
|
"gate": {
|
|
52
52
|
"default_scope": "auto",
|
|
53
|
-
"fallback_scope": "
|
|
54
|
-
"full_on_unknown":
|
|
55
|
-
"no_change_scope": "
|
|
53
|
+
"fallback_scope": "changed",
|
|
54
|
+
"full_on_unknown": False,
|
|
55
|
+
"no_change_scope": "changed",
|
|
56
56
|
"rules": [],
|
|
57
57
|
},
|
|
58
58
|
"structure": {"enabled": False, "enforcement": "advisory"},
|
|
@@ -233,7 +233,10 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
233
233
|
self.assertEqual(["src/frontend/LoginPage.tsx"], plan["classification_files"])
|
|
234
234
|
self.assertTrue(plan["intent_provided"])
|
|
235
235
|
self.assertEqual(["auth", "release_or_tooling", "ui"], plan["intent_categories"])
|
|
236
|
-
self.
|
|
236
|
+
self.assertTrue(plan["needs_browser"])
|
|
237
|
+
self.assertEqual(["reviewer"], plan["recommended_agents"])
|
|
238
|
+
self.assertNotIn("browser_debugger", plan["recommended_agents"])
|
|
239
|
+
self.assertNotIn("docs_researcher", plan["recommended_agents"])
|
|
237
240
|
self.assertNotIn("新增登录鉴权页面并发布", str(plan))
|
|
238
241
|
|
|
239
242
|
def test_ordinary_code_resolves_standard(self) -> None:
|
|
@@ -243,32 +246,63 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
243
246
|
self.assertEqual("standard", plan["profile"])
|
|
244
247
|
self.assertEqual("changed", plan["selected_scope"])
|
|
245
248
|
self.assertEqual("dev", plan["effective_mode"])
|
|
246
|
-
self.assertEqual([
|
|
249
|
+
self.assertEqual([], plan["recommended_agents"])
|
|
247
250
|
agent_plan = plan["agent_plan"]
|
|
248
|
-
self.assertEqual("
|
|
249
|
-
self.assertEqual(
|
|
250
|
-
["decomposition", "discovery", "design", "delivery", "closure"],
|
|
251
|
-
[stage["id"] for stage in agent_plan["stages"]],
|
|
252
|
-
)
|
|
251
|
+
self.assertEqual("main-only", agent_plan["strategy"])
|
|
252
|
+
self.assertEqual(["delivery"], [stage["id"] for stage in agent_plan["stages"]])
|
|
253
253
|
self.assertTrue(agent_plan["policies"]["one_writer_per_worktree"])
|
|
254
|
-
self.assertEqual("explicit-
|
|
254
|
+
self.assertEqual("explicit-only-for-isolated-or-delegated-work", agent_plan["policies"]["path_ownership"])
|
|
255
255
|
self.assertEqual(
|
|
256
256
|
"integrate-before-dependent-start",
|
|
257
257
|
agent_plan["policies"]["dependency_policy"],
|
|
258
258
|
)
|
|
259
|
-
self.assertEqual("
|
|
260
|
-
self.assertEqual("diff-fingerprint", agent_plan["policies"]["review_binding"])
|
|
259
|
+
self.assertEqual("main", agent_plan["policies"]["review_feedback_owner"])
|
|
260
|
+
self.assertEqual("diff-fingerprint-when-required", agent_plan["policies"]["review_binding"])
|
|
261
261
|
self.assertEqual("main", agent_plan["policies"]["lifecycle_owner"])
|
|
262
262
|
self.assertIn("owned_paths", agent_plan["assignment_contract"]["writer"])
|
|
263
263
|
self.assertIn("diff_fingerprint", agent_plan["assignment_contract"]["reviewer"])
|
|
264
264
|
self.assertIn("diff_fingerprint", agent_plan["result_contract"])
|
|
265
265
|
delivery = next(stage for stage in agent_plan["stages"] if stage["id"] == "delivery")
|
|
266
|
-
self.assertEqual("
|
|
267
|
-
self.
|
|
268
|
-
|
|
269
|
-
|
|
266
|
+
self.assertEqual("serial", delivery["mode"])
|
|
267
|
+
self.assertFalse(plan["review_required"])
|
|
268
|
+
|
|
269
|
+
def test_execution_mode_is_none_direct_isolated_or_parallel(self) -> None:
|
|
270
|
+
repo, cfg = self.make_repo()
|
|
271
|
+
self.assertEqual("none", self.plan(repo, cfg)["execution_mode"])
|
|
272
|
+
direct = self.plan(repo, cfg, planned_paths=["src/widget.py"])
|
|
273
|
+
self.assertEqual("direct", direct["execution_mode"])
|
|
274
|
+
dirty = repo / "existing.txt"
|
|
275
|
+
dirty.write_text("user change\n", encoding="utf-8")
|
|
276
|
+
isolated = self.plan(repo, cfg, planned_paths=["src/widget.py"])
|
|
277
|
+
self.assertEqual("isolated", isolated["execution_mode"])
|
|
278
|
+
dirty.unlink()
|
|
279
|
+
parallel = self.plan(
|
|
280
|
+
repo,
|
|
281
|
+
cfg,
|
|
282
|
+
planned_paths=["src/widget.py"],
|
|
283
|
+
parallel_writers=2,
|
|
270
284
|
)
|
|
271
|
-
self.
|
|
285
|
+
self.assertEqual("isolated", parallel["execution_mode"])
|
|
286
|
+
self.assertTrue(parallel["review_required"])
|
|
287
|
+
self.assertIn("fixer", parallel["recommended_agents"])
|
|
288
|
+
|
|
289
|
+
def test_validation_routes_collect_all_commands_and_reject_unmapped_code(self) -> None:
|
|
290
|
+
repo, cfg = self.make_repo()
|
|
291
|
+
cfg["commands"] = {"one": "true", "two": "true"}
|
|
292
|
+
cfg["validation"] = {
|
|
293
|
+
"on_unmapped": "error",
|
|
294
|
+
"routes": [
|
|
295
|
+
{"name": "all-src", "paths": ["src/**"], "commands": ["one", "two"]},
|
|
296
|
+
{"name": "python", "paths": ["**/*.py"], "commands": ["two"]},
|
|
297
|
+
],
|
|
298
|
+
}
|
|
299
|
+
plan = ap._validation_plan(cfg, ["src/widget.py"])
|
|
300
|
+
self.assertEqual(["one", "two"], plan["commands"])
|
|
301
|
+
self.assertEqual(["all-src", "python"], plan["matched_routes"])
|
|
302
|
+
ap._validate_validation_plan(cfg, plan)
|
|
303
|
+
with self.assertRaises(APError) as context:
|
|
304
|
+
ap._validate_validation_plan(cfg, ap._validation_plan(cfg, ["contracts/api.yaml"]))
|
|
305
|
+
self.assertIn("no validation route", str(context.exception))
|
|
272
306
|
|
|
273
307
|
def test_test_only_change_resolves_micro(self) -> None:
|
|
274
308
|
repo, cfg = self.make_repo("tests/widget_test.py")
|
|
@@ -292,27 +326,28 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
292
326
|
self.assertEqual("high-risk", plan["profile"])
|
|
293
327
|
self.assertEqual("changed", plan["selected_scope"])
|
|
294
328
|
self.assertEqual("dev", plan["effective_mode"])
|
|
295
|
-
self.
|
|
329
|
+
self.assertFalse(plan["needs_dd"])
|
|
330
|
+
self.assertTrue(plan["review_required"])
|
|
296
331
|
self.assertIn("reviewer", plan["recommended_agents"])
|
|
297
332
|
self.assertFalse(plan["needs_jenkins"])
|
|
298
333
|
self.assertFalse(plan["needs_target"])
|
|
299
334
|
|
|
300
|
-
def
|
|
335
|
+
def test_ui_api_reports_capabilities_without_auto_dispatch(self) -> None:
|
|
301
336
|
repo, cfg = self.make_repo("src/api/settings-page.tsx")
|
|
302
337
|
plan = self.plan(repo, cfg)
|
|
303
|
-
|
|
304
|
-
self.assertEqual(
|
|
305
|
-
self.assertEqual(
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
]
|
|
315
|
-
self.assertEqual(
|
|
338
|
+
self.assertTrue(plan["needs_browser"])
|
|
339
|
+
self.assertEqual([], plan["recommended_agents"])
|
|
340
|
+
self.assertEqual("main-only", plan["agent_plan"]["strategy"])
|
|
341
|
+
self.assertEqual(["main"], plan["agent_plan"]["stages"][0]["roles"])
|
|
342
|
+
|
|
343
|
+
def test_terminal_ledger_maintenance_creates_no_lifecycle_plan(self) -> None:
|
|
344
|
+
repo, cfg = self.make_repo()
|
|
345
|
+
plan = self.plan(repo, cfg, planned_paths=["docs/tasks/closure-log.md"])
|
|
346
|
+
self.assertTrue(plan["terminal_maintenance"])
|
|
347
|
+
self.assertEqual("none", plan["execution_mode"])
|
|
348
|
+
self.assertFalse(plan["review_required"])
|
|
349
|
+
self.assertFalse(plan["design_required"])
|
|
350
|
+
self.assertEqual([], plan["recommended_agents"])
|
|
316
351
|
|
|
317
352
|
def test_requested_verify_mode_is_rejected(self) -> None:
|
|
318
353
|
repo, cfg = self.make_repo("src/widget.py")
|
|
@@ -511,16 +546,21 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
511
546
|
|
|
512
547
|
migrated, body = ap._read_frontmatter_markdown(engineering)
|
|
513
548
|
self.assertNotIn("full_on", migrated["gate"])
|
|
514
|
-
self.
|
|
515
|
-
self.
|
|
549
|
+
self.assertEqual([], migrated["gate"]["rules"])
|
|
550
|
+
self.assertEqual("high-risk", migrated["risk"]["rules"][0]["profile"])
|
|
551
|
+
self.assertEqual(["gate_full"], migrated["validation"]["routes"][-1]["commands"])
|
|
516
552
|
self.assertEqual("true", migrated["commands"]["gate_full"])
|
|
517
553
|
self.assertNotIn("must run the full gate", body)
|
|
518
554
|
|
|
519
555
|
def test_upgrade_unknown_policy_conflict_fails_before_any_write(self) -> None:
|
|
520
556
|
repo, _ = self.make_repo()
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
557
|
+
engineering = repo / "docs" / "ENGINEERING.md"
|
|
558
|
+
engineering.write_text(
|
|
559
|
+
engineering.read_text(encoding="utf-8")
|
|
560
|
+
+ "High-risk work must run the full gate.\n",
|
|
561
|
+
encoding="utf-8",
|
|
562
|
+
)
|
|
563
|
+
before = engineering.read_text(encoding="utf-8")
|
|
524
564
|
args = argparse.Namespace(repo=str(repo), write=True, dry_run=False, json=False)
|
|
525
565
|
with mock.patch.object(
|
|
526
566
|
ap,
|
|
@@ -529,8 +569,8 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
529
569
|
):
|
|
530
570
|
with self.assertRaises(APError) as context:
|
|
531
571
|
ap.cmd_upgrade(args)
|
|
532
|
-
self.assertIn("
|
|
533
|
-
self.assertEqual(before,
|
|
572
|
+
self.assertIn("docs/ENGINEERING.md", str(context.exception))
|
|
573
|
+
self.assertEqual(before, engineering.read_text(encoding="utf-8"))
|
|
534
574
|
self.assertFalse((repo / ".agents").exists())
|
|
535
575
|
|
|
536
576
|
def test_doctor_ignores_managed_blocks_but_rejects_unknown_external_rule(self) -> None:
|
|
@@ -568,7 +608,7 @@ class AutoCodingProfileTests(unittest.TestCase):
|
|
|
568
608
|
repo, _ = self.make_repo(config=cfg)
|
|
569
609
|
with self.assertRaises(APError) as context:
|
|
570
610
|
ap.cmd_doctor(argparse.Namespace(repo=str(repo)))
|
|
571
|
-
self.assertIn("
|
|
611
|
+
self.assertIn("validation.routes", str(context.exception))
|
|
572
612
|
|
|
573
613
|
def test_doctor_requires_direct_access_password_even_with_env_reference(self) -> None:
|
|
574
614
|
cfg = base_config()
|