@elvis1513/auto-coding-skill 3.0.0 → 3.0.2
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 +126 -54
- package/cli/assets/agents/browser-debugger.toml +5 -7
- package/cli/assets/agents/docs-researcher.toml +3 -5
- package/cli/assets/agents/explorer.toml +5 -10
- package/cli/assets/agents/fixer.toml +19 -17
- package/cli/assets/agents/reviewer.toml +14 -10
- package/cli/assets/skill/SKILL.md +116 -49
- package/cli/assets/skill/data/contracts/orchestration-v1.schema.json +475 -0
- package/cli/assets/skill/data/policies/workflow-migrations-v1.json +371 -0
- package/cli/assets/skill/data/templates/ENGINEERING.md +170 -81
- package/cli/assets/skill/data/templates/bridges/AGENTS.md +8 -4
- package/cli/assets/skill/data/templates/docs/tasks/closure-log.md +7 -6
- package/cli/assets/skill/data/templates/docs/tasks/taskbook.md +11 -4
- package/cli/assets/skill/scripts/ap.py +1389 -570
- package/cli/src/index.js +749 -51
- package/cli/tests/ap_concurrency_test.py +466 -79
- package/cli/tests/ap_profiles_test.py +339 -98
- package/cli/tests/index.test.js +499 -15
- package/package.json +3 -3
|
@@ -34,7 +34,7 @@ from scaffold_templates import scaffold_groups, templates_for
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
_JENKINS_CRUMB_CACHE: dict[str, dict[str, str]] = {}
|
|
37
|
-
_INVALID_PLACEHOLDERS = {"N/A", "TODO", "TBD", "CHANGEME", "CHANGE_ME", "FILL_ME", "FILL-ME", "PLACEHOLDER", "XXX"}
|
|
37
|
+
_INVALID_PLACEHOLDERS = {"N/A", "TODO", "TBD", "CHANGEME", "CHANGE_ME", "FILL_ME", "FILL-ME", "PLACEHOLDER", "XXX", "NULL", "~"}
|
|
38
38
|
_GENERATED_NOISE_PATTERNS = [
|
|
39
39
|
".local/auto-coding-skill/**",
|
|
40
40
|
"__pycache__/**",
|
|
@@ -44,6 +44,41 @@ _GENERATED_NOISE_PATTERNS = [
|
|
|
44
44
|
".DS_Store",
|
|
45
45
|
"**/.DS_Store",
|
|
46
46
|
]
|
|
47
|
+
_AGENT_CONTRACT_VERSION = 1
|
|
48
|
+
_AGENT_CONTRACT_SCHEMA = "data/contracts/orchestration-v1.schema.json"
|
|
49
|
+
_WORKFLOW_MIGRATION_POLICY = Path("data/policies/workflow-migrations-v1.json")
|
|
50
|
+
_FALLBACK_WORKFLOW_MIGRATION_POLICY = {
|
|
51
|
+
"schema_version": 1,
|
|
52
|
+
"managed_versions": {"agents": "3.0.2", "engineering": "3.0.2"},
|
|
53
|
+
"known_official_engineering_body_sha256": [
|
|
54
|
+
"d1306cc626e8baf8c83c953b760fd771066de2bf125168eca3a7b7d6ff2b87a2",
|
|
55
|
+
"305931c6edef770033a4f1970b00e5fb1c1728351856a173dbfa497daf563021",
|
|
56
|
+
"198d675361337bc272880154266b3eb1f50e3f82f3c6ab04b2e559cd18d8c7b4",
|
|
57
|
+
],
|
|
58
|
+
"known_official_fragments": [],
|
|
59
|
+
"conflict_rules": [
|
|
60
|
+
{
|
|
61
|
+
"id": "mandatory-high-risk-full",
|
|
62
|
+
"paths": ["AGENTS.md", "docs/ENGINEERING.md"],
|
|
63
|
+
"pattern": r"^(?:.*(?:high[- ]risk|高风险).*(?:must|required|requires|必须|需).*(?:full(?:[ -]gate)?|gate_full|verify|验证).*)$",
|
|
64
|
+
"flags": "im",
|
|
65
|
+
"message": "normal development must not require a full/verify gate",
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "mandatory-change-full",
|
|
69
|
+
"paths": ["AGENTS.md", "docs/ENGINEERING.md"],
|
|
70
|
+
"pattern": r"^(?:.*(?:changes?|变更).*(?:require|required|requires|必须).*(?:full(?:[ -]gate)?|gate_full).*)$",
|
|
71
|
+
"flags": "im",
|
|
72
|
+
"message": "changed files must not automatically require a full gate",
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
"dependency_recovery": {
|
|
76
|
+
"allowed_gate": "gate_changed",
|
|
77
|
+
"requires_locked_dependency": True,
|
|
78
|
+
"retry_same_gate_only": True,
|
|
79
|
+
"forbid_full_gate_recovery": True,
|
|
80
|
+
},
|
|
81
|
+
}
|
|
47
82
|
_DEFAULT_DISPOSABLE_IGNORED_PATTERNS = [
|
|
48
83
|
".local/auto-coding-skill",
|
|
49
84
|
".local/auto-coding-skill/**",
|
|
@@ -139,11 +174,7 @@ def _evidence_log_path(repo: Path, cfg: dict) -> Path:
|
|
|
139
174
|
docs_cfg = cfg.get("docs") or {}
|
|
140
175
|
task_dir = _text(docs_cfg.get("task_evidence_dir")) or "docs/tasks/evidence"
|
|
141
176
|
return Path(repo, task_dir, f"{manifest['task_id']}.jsonl")
|
|
142
|
-
|
|
143
|
-
return Path(repo, ".local/auto-coding-skill/evidence.jsonl")
|
|
144
|
-
docs_cfg = cfg.get("docs") or {}
|
|
145
|
-
rel = _text(docs_cfg.get("evidence_log")) or "docs/tasks/evidence.jsonl"
|
|
146
|
-
return Path(repo, rel)
|
|
177
|
+
return Path(repo, ".local/auto-coding-skill/evidence.jsonl")
|
|
147
178
|
|
|
148
179
|
|
|
149
180
|
def _gate_profile_path(repo: Path, cfg: dict) -> Path:
|
|
@@ -563,21 +594,9 @@ def _inferred_gate_commands(repo: Path) -> dict[str, str]:
|
|
|
563
594
|
scripts = payload.get("scripts") or {}
|
|
564
595
|
if not isinstance(scripts, dict):
|
|
565
596
|
return {}
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
"npm run test:changed"
|
|
570
|
-
if isinstance(scripts.get("test:changed"), str) and scripts["test:changed"].strip()
|
|
571
|
-
else "npm test"
|
|
572
|
-
)
|
|
573
|
-
inferred["gate_standard"] = (
|
|
574
|
-
"npm run test:standard"
|
|
575
|
-
if isinstance(scripts.get("test:standard"), str) and scripts["test:standard"].strip()
|
|
576
|
-
else "npm test"
|
|
577
|
-
)
|
|
578
|
-
if isinstance(scripts.get("test:full"), str) and scripts["test:full"].strip():
|
|
579
|
-
inferred["gate_full"] = "npm run test:full"
|
|
580
|
-
return inferred
|
|
597
|
+
if isinstance(scripts.get("test:changed"), str) and scripts["test:changed"].strip():
|
|
598
|
+
return {"gate_changed": "npm run test:changed"}
|
|
599
|
+
return {}
|
|
581
600
|
|
|
582
601
|
|
|
583
602
|
def _initialize_engineering_defaults(path: Path, repo: Path) -> None:
|
|
@@ -590,15 +609,86 @@ def _initialize_engineering_defaults(path: Path, repo: Path) -> None:
|
|
|
590
609
|
1,
|
|
591
610
|
)
|
|
592
611
|
for key, gate_command in _inferred_gate_commands(repo).items():
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
612
|
+
for default_value in ['""', '"git diff --check"']:
|
|
613
|
+
candidate = updated.replace(
|
|
614
|
+
f" {key}: {default_value}",
|
|
615
|
+
f" {key}: {json.dumps(gate_command)}",
|
|
616
|
+
1,
|
|
617
|
+
)
|
|
618
|
+
if candidate != updated:
|
|
619
|
+
updated = candidate
|
|
620
|
+
break
|
|
598
621
|
if updated != text:
|
|
599
622
|
path.write_text(updated, encoding="utf-8")
|
|
600
623
|
|
|
601
624
|
|
|
625
|
+
def _migrate_fast_development_defaults(cfg: dict, repo: Path) -> list[str]:
|
|
626
|
+
changed: list[str] = []
|
|
627
|
+
|
|
628
|
+
workflow_cfg = cfg.setdefault("workflow", {})
|
|
629
|
+
if not isinstance(workflow_cfg, dict):
|
|
630
|
+
workflow_cfg = {}
|
|
631
|
+
cfg["workflow"] = workflow_cfg
|
|
632
|
+
if _text(workflow_cfg.get("mode")).lower() != "dev":
|
|
633
|
+
workflow_cfg["mode"] = "dev"
|
|
634
|
+
changed.append("workflow.mode")
|
|
635
|
+
if _text(workflow_cfg.get("completion")).lower() != "push":
|
|
636
|
+
workflow_cfg["completion"] = "push"
|
|
637
|
+
changed.append("workflow.completion")
|
|
638
|
+
|
|
639
|
+
commands_cfg = cfg.setdefault("commands", {})
|
|
640
|
+
if not isinstance(commands_cfg, dict):
|
|
641
|
+
commands_cfg = {}
|
|
642
|
+
cfg["commands"] = commands_cfg
|
|
643
|
+
current_changed_gate = _text(commands_cfg.get("gate_changed"))
|
|
644
|
+
if current_changed_gate in {"", "npm test"}:
|
|
645
|
+
replacement = _inferred_gate_commands(repo).get("gate_changed", "git diff --check")
|
|
646
|
+
if current_changed_gate != replacement:
|
|
647
|
+
commands_cfg["gate_changed"] = replacement
|
|
648
|
+
changed.append("commands.gate_changed")
|
|
649
|
+
|
|
650
|
+
gate_cfg = cfg.setdefault("gate", {})
|
|
651
|
+
if not isinstance(gate_cfg, dict):
|
|
652
|
+
gate_cfg = {}
|
|
653
|
+
cfg["gate"] = gate_cfg
|
|
654
|
+
for key in ["default_scope", "fallback_scope", "no_change_scope"]:
|
|
655
|
+
if _text(gate_cfg.get(key)).lower() != "changed":
|
|
656
|
+
gate_cfg[key] = "changed"
|
|
657
|
+
changed.append(f"gate.{key}")
|
|
658
|
+
if _bool_config(gate_cfg.get("full_on_unknown"), False):
|
|
659
|
+
gate_cfg["full_on_unknown"] = False
|
|
660
|
+
changed.append("gate.full_on_unknown")
|
|
661
|
+
if "full_on" in gate_cfg:
|
|
662
|
+
del gate_cfg["full_on"]
|
|
663
|
+
changed.append("gate.full_on")
|
|
664
|
+
raw_rules = gate_cfg.get("rules")
|
|
665
|
+
if isinstance(raw_rules, list):
|
|
666
|
+
migrated_rules: list = []
|
|
667
|
+
for index, rule in enumerate(raw_rules):
|
|
668
|
+
if not isinstance(rule, dict):
|
|
669
|
+
migrated_rules.append(rule)
|
|
670
|
+
continue
|
|
671
|
+
migrated_rule = dict(rule)
|
|
672
|
+
for legacy_key in ["scope", "commands"]:
|
|
673
|
+
if legacy_key in migrated_rule:
|
|
674
|
+
del migrated_rule[legacy_key]
|
|
675
|
+
changed.append(f"gate.rules[{index}].{legacy_key}")
|
|
676
|
+
if migrated_rule:
|
|
677
|
+
migrated_rules.append(migrated_rule)
|
|
678
|
+
if migrated_rules != raw_rules:
|
|
679
|
+
gate_cfg["rules"] = migrated_rules
|
|
680
|
+
|
|
681
|
+
concurrency_cfg = cfg.setdefault("concurrency", {})
|
|
682
|
+
if not isinstance(concurrency_cfg, dict):
|
|
683
|
+
concurrency_cfg = {}
|
|
684
|
+
cfg["concurrency"] = concurrency_cfg
|
|
685
|
+
if _text(concurrency_cfg.get("isolation")).lower() != "worktree":
|
|
686
|
+
concurrency_cfg["isolation"] = "worktree"
|
|
687
|
+
changed.append("concurrency.isolation")
|
|
688
|
+
|
|
689
|
+
return changed
|
|
690
|
+
|
|
691
|
+
|
|
602
692
|
def cmd_scaffold(args: argparse.Namespace) -> None:
|
|
603
693
|
repo = Path(args.repo).resolve()
|
|
604
694
|
group = str(args.group or "").strip().lower()
|
|
@@ -671,8 +761,8 @@ def cmd_install(args: argparse.Namespace) -> None:
|
|
|
671
761
|
layout = "full" if args.full else "minimal"
|
|
672
762
|
print(f"[install] OK: {layout} scaffold installed into {repo}")
|
|
673
763
|
print(
|
|
674
|
-
"[install] Next:
|
|
675
|
-
"
|
|
764
|
+
"[install] Next: fill every access.* URL, username, and password in "
|
|
765
|
+
"docs/ENGINEERING.md, run doctor, and commit that file into Git."
|
|
676
766
|
)
|
|
677
767
|
|
|
678
768
|
|
|
@@ -682,6 +772,7 @@ def cmd_upgrade(args: argparse.Namespace) -> None:
|
|
|
682
772
|
write = bool(args.write) and not bool(args.dry_run)
|
|
683
773
|
source_root = _find_skill_asset_root(repo)
|
|
684
774
|
templates = source_root / "data" / "templates"
|
|
775
|
+
template_engineering = templates / "ENGINEERING.md"
|
|
685
776
|
actions: list[dict] = []
|
|
686
777
|
|
|
687
778
|
def add_action(kind: str, path: Path, action: str, detail: str = "") -> None:
|
|
@@ -692,6 +783,25 @@ def cmd_upgrade(args: argparse.Namespace) -> None:
|
|
|
692
783
|
"detail": detail,
|
|
693
784
|
})
|
|
694
785
|
|
|
786
|
+
# Complete policy discovery before the first write. Known official fragments
|
|
787
|
+
# are safe migration inputs; every remaining match is project-owned and must
|
|
788
|
+
# be handled explicitly instead of being overwritten by a partial upgrade.
|
|
789
|
+
workflow_plans = _workflow_policy_plans(repo)
|
|
790
|
+
workflow_issues = [issue for plan in workflow_plans for issue in plan["issues"]]
|
|
791
|
+
if workflow_issues:
|
|
792
|
+
raise APError(
|
|
793
|
+
"Upgrade preflight found unknown workflow policy conflicts; no files were written:\n- "
|
|
794
|
+
+ "\n- ".join(workflow_issues)
|
|
795
|
+
)
|
|
796
|
+
workflow_plan_by_path = {plan["path"]: plan for plan in workflow_plans}
|
|
797
|
+
engineering_plan = workflow_plan_by_path["docs/ENGINEERING.md"]
|
|
798
|
+
if engineering_plan.get("official_body_hash") and template_engineering.exists():
|
|
799
|
+
current = engineering_plan["original"]
|
|
800
|
+
frontmatter = _frontmatter_span(current, "docs/ENGINEERING.md")
|
|
801
|
+
_, template_body = _read_frontmatter_markdown(template_engineering)
|
|
802
|
+
body_start = frontmatter[1] if frontmatter else 0
|
|
803
|
+
engineering_plan["output"] = current[:body_start] + template_body
|
|
804
|
+
|
|
695
805
|
tool_files = [
|
|
696
806
|
(
|
|
697
807
|
source_root / "data" / "templates" / "tools" / "ap.py",
|
|
@@ -743,6 +853,14 @@ def cmd_upgrade(args: argparse.Namespace) -> None:
|
|
|
743
853
|
if write:
|
|
744
854
|
copy_tree(source_root, project_skill)
|
|
745
855
|
|
|
856
|
+
agents_plan = workflow_plan_by_path["AGENTS.md"]
|
|
857
|
+
agents_path = repo / "AGENTS.md"
|
|
858
|
+
if agents_plan["output"] != agents_plan["original"]:
|
|
859
|
+
migrated = ", ".join(item["id"] for item in agents_plan["migrations"])
|
|
860
|
+
add_action("policy", agents_path, "migrate", migrated)
|
|
861
|
+
if write:
|
|
862
|
+
agents_path.write_text(agents_plan["output"], encoding="utf-8")
|
|
863
|
+
|
|
746
864
|
docs_template = templates / "docs"
|
|
747
865
|
for rel in _CORE_DOC_TEMPLATES:
|
|
748
866
|
src = docs_template / rel
|
|
@@ -759,14 +877,26 @@ def cmd_upgrade(args: argparse.Namespace) -> None:
|
|
|
759
877
|
add_action("doc", dst, "ok")
|
|
760
878
|
|
|
761
879
|
engineering = repo / "docs" / "ENGINEERING.md"
|
|
762
|
-
template_engineering = templates / "ENGINEERING.md"
|
|
763
880
|
if engineering.exists() and template_engineering.exists():
|
|
764
|
-
|
|
881
|
+
planned_engineering = engineering_plan["output"] or engineering.read_text(encoding="utf-8")
|
|
882
|
+
current_cfg, body = _parse_frontmatter_markdown_text(planned_engineering, engineering)
|
|
765
883
|
template_cfg, _ = _read_frontmatter_markdown(template_engineering)
|
|
766
884
|
merged_cfg = json.loads(json.dumps(current_cfg))
|
|
767
885
|
added_keys = _deep_merge_missing(merged_cfg, template_cfg)
|
|
768
|
-
|
|
769
|
-
|
|
886
|
+
migrated_keys = _migrate_fast_development_defaults(merged_cfg, repo)
|
|
887
|
+
body_migrated = planned_engineering != engineering_plan["original"]
|
|
888
|
+
if added_keys or migrated_keys or body_migrated:
|
|
889
|
+
detail_parts = []
|
|
890
|
+
if added_keys:
|
|
891
|
+
detail_parts.append("add " + ", ".join(added_keys))
|
|
892
|
+
if migrated_keys:
|
|
893
|
+
detail_parts.append("migrate " + ", ".join(migrated_keys))
|
|
894
|
+
if body_migrated:
|
|
895
|
+
detail_parts.append(
|
|
896
|
+
"remove known legacy workflow "
|
|
897
|
+
+ ", ".join(item["id"] for item in engineering_plan["migrations"])
|
|
898
|
+
)
|
|
899
|
+
add_action("config", engineering, "merge", "; ".join(detail_parts))
|
|
770
900
|
if write:
|
|
771
901
|
_write_frontmatter_markdown(engineering, merged_cfg, body)
|
|
772
902
|
else:
|
|
@@ -852,9 +982,9 @@ def cmd_gen_summary(args: argparse.Namespace) -> None:
|
|
|
852
982
|
|
|
853
983
|
---
|
|
854
984
|
|
|
855
|
-
## 1.
|
|
985
|
+
## 1. 目标与开发闭环
|
|
856
986
|
- 目标:TODO
|
|
857
|
-
-
|
|
987
|
+
- 开发结论:DEV-CLOSED / BLOCKED — TODO
|
|
858
988
|
|
|
859
989
|
## 2. 变更概览
|
|
860
990
|
### Git change snapshot
|
|
@@ -871,14 +1001,13 @@ def cmd_gen_summary(args: argparse.Namespace) -> None:
|
|
|
871
1001
|
- 变更记录位置:`{api_change_log}`
|
|
872
1002
|
|
|
873
1003
|
## 4. 质量证据
|
|
874
|
-
-
|
|
875
|
-
-
|
|
1004
|
+
- 本地快速门禁:changed gate + diff-check — TODO
|
|
1005
|
+
- 项目 Git hooks:commit/push 时执行
|
|
876
1006
|
- 结构化证据:docs/tasks/evidence.jsonl — TODO
|
|
877
1007
|
- 门禁画像:.local/auto-coding-skill/gate-profile.jsonl — TODO
|
|
878
|
-
-
|
|
879
|
-
-
|
|
880
|
-
-
|
|
881
|
-
- 回归矩阵(如有):`{regression_matrix}`
|
|
1008
|
+
- 目标分支推送:TODO
|
|
1009
|
+
- Jenkins / 构建 / 部署 / 实际验收:项目负责人推送后处理
|
|
1010
|
+
- 可选诊断(如明确要求):`{regression_matrix}`
|
|
882
1011
|
|
|
883
1012
|
## 5. 风险与回滚
|
|
884
1013
|
- 风险:TODO
|
|
@@ -1020,10 +1149,290 @@ def _files_differ(a: Path, b: Path) -> bool:
|
|
|
1020
1149
|
return _file_sha256(a) != _file_sha256(b)
|
|
1021
1150
|
|
|
1022
1151
|
|
|
1023
|
-
def
|
|
1152
|
+
def _load_workflow_migration_policy(repo: Path) -> dict:
|
|
1153
|
+
policy_path = _find_skill_asset_root(repo) / _WORKFLOW_MIGRATION_POLICY
|
|
1154
|
+
if policy_path.exists():
|
|
1155
|
+
try:
|
|
1156
|
+
policy = json.loads(policy_path.read_text(encoding="utf-8"))
|
|
1157
|
+
except (OSError, UnicodeDecodeError, json.JSONDecodeError) as exc:
|
|
1158
|
+
raise APError(f"Invalid workflow migration policy: {policy_path}: {exc}") from exc
|
|
1159
|
+
else:
|
|
1160
|
+
# Keep installed runtimes fail-closed during a rolling package update. The
|
|
1161
|
+
# packaged policy is authoritative once present; this fallback intentionally
|
|
1162
|
+
# knows no removable fragments, so only an explicit policy can auto-migrate.
|
|
1163
|
+
policy = json.loads(json.dumps(_FALLBACK_WORKFLOW_MIGRATION_POLICY))
|
|
1164
|
+
|
|
1165
|
+
if not isinstance(policy, dict) or policy.get("schema_version") != 1:
|
|
1166
|
+
raise APError(f"Unsupported workflow migration policy schema: {policy_path}")
|
|
1167
|
+
for field in [
|
|
1168
|
+
"known_official_engineering_body_sha256",
|
|
1169
|
+
"known_official_fragments",
|
|
1170
|
+
"conflict_rules",
|
|
1171
|
+
]:
|
|
1172
|
+
if not isinstance(policy.get(field), list):
|
|
1173
|
+
raise APError(f"Workflow migration policy field must be a list: {field}")
|
|
1174
|
+
for index, fragment in enumerate(policy["known_official_fragments"]):
|
|
1175
|
+
if not isinstance(fragment, dict):
|
|
1176
|
+
raise APError(f"Workflow migration policy fragment[{index}] must be an object")
|
|
1177
|
+
if fragment.get("match") not in {"exact-line", "exact-block"}:
|
|
1178
|
+
raise APError(f"Workflow migration policy fragment[{index}] has invalid match mode")
|
|
1179
|
+
if not _text(fragment.get("id")) or not isinstance(fragment.get("paths"), list):
|
|
1180
|
+
raise APError(f"Workflow migration policy fragment[{index}] is incomplete")
|
|
1181
|
+
if not isinstance(fragment.get("text"), str) or not fragment["text"].strip():
|
|
1182
|
+
raise APError(f"Workflow migration policy fragment[{index}] has empty text")
|
|
1183
|
+
if "replacement" in fragment and not isinstance(fragment.get("replacement"), str):
|
|
1184
|
+
raise APError(f"Workflow migration policy fragment[{index}] replacement must be text")
|
|
1185
|
+
for index, rule in enumerate(policy["conflict_rules"]):
|
|
1186
|
+
if not isinstance(rule, dict):
|
|
1187
|
+
raise APError(f"Workflow migration policy conflict_rules[{index}] must be an object")
|
|
1188
|
+
flags = _text(rule.get("flags"))
|
|
1189
|
+
if set(flags) - {"i", "m"}:
|
|
1190
|
+
raise APError(f"Workflow migration policy conflict_rules[{index}] has invalid flags")
|
|
1191
|
+
if not _text(rule.get("id")) or not isinstance(rule.get("paths"), list):
|
|
1192
|
+
raise APError(f"Workflow migration policy conflict_rules[{index}] is incomplete")
|
|
1193
|
+
try:
|
|
1194
|
+
re.compile(_text(rule.get("pattern")), _workflow_regex_flags(flags))
|
|
1195
|
+
except re.error as exc:
|
|
1196
|
+
raise APError(
|
|
1197
|
+
f"Workflow migration policy conflict_rules[{index}] has invalid regex: {exc}"
|
|
1198
|
+
) from exc
|
|
1199
|
+
return policy
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
def _workflow_regex_flags(raw: str) -> int:
|
|
1203
|
+
flags = 0
|
|
1204
|
+
if "i" in raw:
|
|
1205
|
+
flags |= re.IGNORECASE
|
|
1206
|
+
if "m" in raw:
|
|
1207
|
+
flags |= re.MULTILINE
|
|
1208
|
+
return flags
|
|
1209
|
+
|
|
1210
|
+
|
|
1211
|
+
def _blank_text_span(text: str, start: int, end: int) -> str:
|
|
1212
|
+
return text[:start] + "".join("\n" if char == "\n" else " " for char in text[start:end]) + text[end:]
|
|
1213
|
+
|
|
1214
|
+
|
|
1215
|
+
def _merge_text_spans(spans: list[tuple[int, int]]) -> list[tuple[int, int]]:
|
|
1216
|
+
merged: list[tuple[int, int]] = []
|
|
1217
|
+
for start, end in sorted(spans):
|
|
1218
|
+
if start >= end:
|
|
1219
|
+
continue
|
|
1220
|
+
if merged and start <= merged[-1][1]:
|
|
1221
|
+
merged[-1] = (merged[-1][0], max(merged[-1][1], end))
|
|
1222
|
+
else:
|
|
1223
|
+
merged.append((start, end))
|
|
1224
|
+
return merged
|
|
1225
|
+
|
|
1226
|
+
|
|
1227
|
+
def _managed_document_span(text: str, kind: str, rel: str) -> Optional[tuple[int, int]]:
|
|
1228
|
+
token = f"auto-coding-skill:managed-{kind}"
|
|
1229
|
+
raw_starts = text.count(f"{token}:start")
|
|
1230
|
+
raw_ends = text.count(f"{token}:end")
|
|
1231
|
+
if raw_starts == 0 and raw_ends == 0:
|
|
1232
|
+
return None
|
|
1233
|
+
start_re = re.compile(
|
|
1234
|
+
rf"<!--\s*{re.escape(token)}:start(?:\s+version=[0-9]+\.[0-9]+\.[0-9]+)?\s*-->"
|
|
1235
|
+
)
|
|
1236
|
+
end_re = re.compile(rf"<!--\s*{re.escape(token)}:end\s*-->")
|
|
1237
|
+
starts = list(start_re.finditer(text))
|
|
1238
|
+
ends = list(end_re.finditer(text))
|
|
1239
|
+
if raw_starts != 1 or raw_ends != 1 or len(starts) != 1 or len(ends) != 1:
|
|
1240
|
+
raise APError(f"Malformed managed {kind} markers in {rel}")
|
|
1241
|
+
if starts[0].start() >= ends[0].start():
|
|
1242
|
+
raise APError(f"Out-of-order managed {kind} markers in {rel}")
|
|
1243
|
+
return starts[0].start(), ends[0].end()
|
|
1244
|
+
|
|
1245
|
+
|
|
1246
|
+
def _frontmatter_span(text: str, rel: str) -> Optional[tuple[int, int]]:
|
|
1247
|
+
if not text.startswith("---\n"):
|
|
1248
|
+
return None
|
|
1249
|
+
match = re.match(r"^---\n[\s\S]*?\n---(?:\n|$)", text)
|
|
1250
|
+
if not match:
|
|
1251
|
+
raise APError(f"Malformed Markdown frontmatter in {rel}")
|
|
1252
|
+
return 0, match.end()
|
|
1253
|
+
|
|
1254
|
+
|
|
1255
|
+
def _known_fragment_spans(
|
|
1256
|
+
visible: str,
|
|
1257
|
+
rel: str,
|
|
1258
|
+
policy: dict,
|
|
1259
|
+
) -> list[tuple[int, int, str, int, str, str]]:
|
|
1260
|
+
found: list[tuple[int, int, str, int, str, str]] = []
|
|
1261
|
+
for fragment in policy.get("known_official_fragments") or []:
|
|
1262
|
+
if rel not in fragment.get("paths", []):
|
|
1263
|
+
continue
|
|
1264
|
+
fragment_id = _text(fragment.get("id"))
|
|
1265
|
+
replacement = str(fragment.get("replacement") or "")
|
|
1266
|
+
match_mode = _text(fragment.get("match"))
|
|
1267
|
+
expected = str(fragment.get("text") or "").replace("\r\n", "\n")
|
|
1268
|
+
if fragment.get("match") == "exact-line":
|
|
1269
|
+
cursor = 0
|
|
1270
|
+
for line in visible.splitlines(keepends=True):
|
|
1271
|
+
content = line.rstrip("\n")
|
|
1272
|
+
if content.strip() == expected.strip():
|
|
1273
|
+
found.append((cursor, cursor + len(line), fragment_id, visible.count("\n", 0, cursor) + 1, replacement, match_mode))
|
|
1274
|
+
cursor += len(line)
|
|
1275
|
+
continue
|
|
1276
|
+
cursor = 0
|
|
1277
|
+
while True:
|
|
1278
|
+
start = visible.find(expected, cursor)
|
|
1279
|
+
if start < 0:
|
|
1280
|
+
break
|
|
1281
|
+
end = start + len(expected)
|
|
1282
|
+
found.append((start, end, fragment_id, visible.count("\n", 0, start) + 1, replacement, match_mode))
|
|
1283
|
+
cursor = end
|
|
1284
|
+
return found
|
|
1285
|
+
|
|
1286
|
+
|
|
1287
|
+
def _workflow_document_plan(repo: Path, rel: str, policy: dict) -> dict:
|
|
1288
|
+
path = repo / rel
|
|
1024
1289
|
if not path.exists():
|
|
1025
|
-
return {
|
|
1026
|
-
|
|
1290
|
+
return {"path": rel, "original": "", "output": "", "migrations": [], "issues": []}
|
|
1291
|
+
original = path.read_text(encoding="utf-8").replace("\r\n", "\n")
|
|
1292
|
+
protected: list[tuple[int, int]] = []
|
|
1293
|
+
if rel == "docs/ENGINEERING.md":
|
|
1294
|
+
frontmatter = _frontmatter_span(original, rel)
|
|
1295
|
+
if frontmatter:
|
|
1296
|
+
protected.append(frontmatter)
|
|
1297
|
+
managed = _managed_document_span(original, "workflow", rel)
|
|
1298
|
+
else:
|
|
1299
|
+
managed = _managed_document_span(original, "agents", rel)
|
|
1300
|
+
if managed:
|
|
1301
|
+
protected.append(managed)
|
|
1302
|
+
|
|
1303
|
+
visible = original
|
|
1304
|
+
for start, end in protected:
|
|
1305
|
+
visible = _blank_text_span(visible, start, end)
|
|
1306
|
+
|
|
1307
|
+
official_body_hash = ""
|
|
1308
|
+
if rel == "docs/ENGINEERING.md" and managed is None:
|
|
1309
|
+
body_start = protected[0][1] if protected else 0
|
|
1310
|
+
body = original[body_start:]
|
|
1311
|
+
digest = hashlib.sha256(body.encode("utf-8")).hexdigest()
|
|
1312
|
+
if digest in set(policy.get("known_official_engineering_body_sha256") or []):
|
|
1313
|
+
official_body_hash = digest
|
|
1314
|
+
visible = _blank_text_span(visible, body_start, len(visible))
|
|
1315
|
+
|
|
1316
|
+
known = _known_fragment_spans(visible, rel, policy)
|
|
1317
|
+
known_spans = _merge_text_spans([(start, end) for start, end, _, _, _, _ in known])
|
|
1318
|
+
scan_text = visible
|
|
1319
|
+
for start, end in known_spans:
|
|
1320
|
+
scan_text = _blank_text_span(scan_text, start, end)
|
|
1321
|
+
|
|
1322
|
+
issues: list[str] = []
|
|
1323
|
+
candidates = _workflow_scan_candidates(scan_text)
|
|
1324
|
+
seen_issues: set[tuple[str, int]] = set()
|
|
1325
|
+
for rule in policy.get("conflict_rules") or []:
|
|
1326
|
+
if rel not in rule.get("paths", []):
|
|
1327
|
+
continue
|
|
1328
|
+
regex = re.compile(_text(rule.get("pattern")), _workflow_regex_flags(_text(rule.get("flags"))))
|
|
1329
|
+
for candidate, line in candidates:
|
|
1330
|
+
match = regex.search(candidate)
|
|
1331
|
+
if not match or (_text(rule.get("id")), line) in seen_issues:
|
|
1332
|
+
continue
|
|
1333
|
+
seen_issues.add((_text(rule.get("id")), line))
|
|
1334
|
+
snippet = " ".join(match.group(0).strip().split())[:180]
|
|
1335
|
+
message = _text(rule.get("message")) or "conflicts with the fast development workflow"
|
|
1336
|
+
issues.append(f"{rel}:{line} [{_text(rule.get('id'))}] {message}: {snippet}")
|
|
1337
|
+
|
|
1338
|
+
output = original
|
|
1339
|
+
for start, end, _, _, replacement, match_mode in sorted(known, reverse=True):
|
|
1340
|
+
if replacement and match_mode == "exact-line" and output[start:end].endswith("\n"):
|
|
1341
|
+
replacement = replacement + "\n"
|
|
1342
|
+
output = output[:start] + replacement + output[end:]
|
|
1343
|
+
migrations = [
|
|
1344
|
+
{"id": fragment_id, "line": line}
|
|
1345
|
+
for _, _, fragment_id, line, _, _ in known
|
|
1346
|
+
]
|
|
1347
|
+
if official_body_hash:
|
|
1348
|
+
migrations.append({"id": f"official-body:{official_body_hash}", "line": 1})
|
|
1349
|
+
return {
|
|
1350
|
+
"path": rel,
|
|
1351
|
+
"original": original,
|
|
1352
|
+
"output": output,
|
|
1353
|
+
"migrations": migrations,
|
|
1354
|
+
"issues": issues,
|
|
1355
|
+
"official_body_hash": official_body_hash,
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
|
|
1359
|
+
def _workflow_policy_plans(repo: Path, policy: Optional[dict] = None) -> list[dict]:
|
|
1360
|
+
effective = policy or _load_workflow_migration_policy(repo)
|
|
1361
|
+
return [
|
|
1362
|
+
_workflow_document_plan(repo, "AGENTS.md", effective),
|
|
1363
|
+
_workflow_document_plan(repo, "docs/ENGINEERING.md", effective),
|
|
1364
|
+
]
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
def _workflow_scan_candidates(text: str) -> list[tuple[str, int]]:
|
|
1368
|
+
lines = text.split("\n")
|
|
1369
|
+
candidates: list[tuple[str, int]] = [(line, index + 1) for index, line in enumerate(lines)]
|
|
1370
|
+
for index, line in enumerate(lines):
|
|
1371
|
+
if not line.strip():
|
|
1372
|
+
continue
|
|
1373
|
+
if re.match(r"^\s*(?:[-+*]|\d+\.)\s+", line):
|
|
1374
|
+
end = index + 1
|
|
1375
|
+
while end < len(lines) and re.match(r"^\s{2,}\S", lines[end]) and not re.match(
|
|
1376
|
+
r"^\s*(?:[-+*]|\d+\.)\s+", lines[end]
|
|
1377
|
+
):
|
|
1378
|
+
end += 1
|
|
1379
|
+
if end > index + 1:
|
|
1380
|
+
candidates.append((" ".join(lines[index:end]), index + 1))
|
|
1381
|
+
continue
|
|
1382
|
+
if re.match(r"^\s*(?:#|\||```|~~~)", line):
|
|
1383
|
+
continue
|
|
1384
|
+
end = index + 1
|
|
1385
|
+
while end < len(lines) and lines[end].strip() and not re.match(
|
|
1386
|
+
r"^\s*(?:#|\||```|~~~|[-+*]|\d+\.)\s*", lines[end]
|
|
1387
|
+
):
|
|
1388
|
+
end += 1
|
|
1389
|
+
if end > index + 1:
|
|
1390
|
+
candidates.append((" ".join(lines[index:end]), index + 1))
|
|
1391
|
+
return candidates
|
|
1392
|
+
|
|
1393
|
+
|
|
1394
|
+
def _legacy_gate_config_issues(cfg: dict) -> list[str]:
|
|
1395
|
+
issues: list[str] = []
|
|
1396
|
+
gate_cfg = cfg.get("gate") or {}
|
|
1397
|
+
if not isinstance(gate_cfg, dict):
|
|
1398
|
+
return ["docs/ENGINEERING.md frontmatter gate must be a mapping"]
|
|
1399
|
+
if "full_on" in gate_cfg:
|
|
1400
|
+
issues.append("docs/ENGINEERING.md frontmatter gate.full_on is legacy automatic full escalation; run ap.py upgrade")
|
|
1401
|
+
if _bool_config(gate_cfg.get("full_on_unknown"), False):
|
|
1402
|
+
issues.append("docs/ENGINEERING.md frontmatter gate.full_on_unknown=true is legacy automatic full escalation; run ap.py upgrade")
|
|
1403
|
+
rules = gate_cfg.get("rules") or []
|
|
1404
|
+
if isinstance(rules, list):
|
|
1405
|
+
for index, rule in enumerate(rules):
|
|
1406
|
+
if not isinstance(rule, dict):
|
|
1407
|
+
continue
|
|
1408
|
+
for key in ["scope", "commands"]:
|
|
1409
|
+
if key in rule:
|
|
1410
|
+
issues.append(
|
|
1411
|
+
f"docs/ENGINEERING.md frontmatter gate.rules[{index}].{key} is legacy automatic gate escalation; run ap.py upgrade"
|
|
1412
|
+
)
|
|
1413
|
+
return issues
|
|
1414
|
+
|
|
1415
|
+
|
|
1416
|
+
def _workflow_policy_issues(repo: Path, cfg: Optional[dict] = None) -> list[str]:
|
|
1417
|
+
issues: list[str] = []
|
|
1418
|
+
for plan in _workflow_policy_plans(repo):
|
|
1419
|
+
issues.extend(plan["issues"])
|
|
1420
|
+
for migration in plan["migrations"]:
|
|
1421
|
+
issues.append(
|
|
1422
|
+
f"{plan['path']}:{migration['line']} [{migration['id']}] known legacy workflow rule; "
|
|
1423
|
+
"run `ap.py upgrade --dry-run` then `ap.py upgrade --write`"
|
|
1424
|
+
)
|
|
1425
|
+
issues.extend(_legacy_gate_config_issues(cfg if cfg is not None else _load_cfg(repo)))
|
|
1426
|
+
return issues
|
|
1427
|
+
|
|
1428
|
+
|
|
1429
|
+
def _require_workflow_policy_clean(repo: Path, cfg: Optional[dict] = None) -> None:
|
|
1430
|
+
issues = _workflow_policy_issues(repo, cfg)
|
|
1431
|
+
if issues:
|
|
1432
|
+
raise APError("Workflow policy conflicts block normal development:\n- " + "\n- ".join(issues))
|
|
1433
|
+
|
|
1434
|
+
|
|
1435
|
+
def _parse_frontmatter_markdown_text(text: str, path: Path) -> tuple[dict, str]:
|
|
1027
1436
|
m = re.match(r"^---\s*\n(.*?)\n---\s*(\n|$)(.*)$", text, flags=re.DOTALL)
|
|
1028
1437
|
if not m:
|
|
1029
1438
|
raise APError(f"Markdown frontmatter not found: {path}")
|
|
@@ -1033,6 +1442,12 @@ def _read_frontmatter_markdown(path: Path) -> tuple[dict, str]:
|
|
|
1033
1442
|
return data, m.group(3)
|
|
1034
1443
|
|
|
1035
1444
|
|
|
1445
|
+
def _read_frontmatter_markdown(path: Path) -> tuple[dict, str]:
|
|
1446
|
+
if not path.exists():
|
|
1447
|
+
return {}, ""
|
|
1448
|
+
return _parse_frontmatter_markdown_text(path.read_text(encoding="utf-8"), path)
|
|
1449
|
+
|
|
1450
|
+
|
|
1036
1451
|
def _write_frontmatter_markdown(path: Path, data: dict, body: str) -> None:
|
|
1037
1452
|
if yaml is None:
|
|
1038
1453
|
raise APError("PyYAML not installed. Install dependencies with: pip install pyyaml requests")
|
|
@@ -1067,8 +1482,8 @@ def _workflow_mode(cfg: dict, args: Optional[argparse.Namespace] = None) -> str:
|
|
|
1067
1482
|
explicit = str(getattr(args, "mode", "") or "").strip().lower() if args else ""
|
|
1068
1483
|
configured = str(((cfg.get("workflow") or {}).get("mode")) or "dev").strip().lower()
|
|
1069
1484
|
mode = explicit or configured or "dev"
|
|
1070
|
-
if mode
|
|
1071
|
-
raise APError("workflow.mode must be 'dev'
|
|
1485
|
+
if mode != "dev":
|
|
1486
|
+
raise APError("workflow.mode must be 'dev'; external verification is owner-managed after push.")
|
|
1072
1487
|
return mode
|
|
1073
1488
|
|
|
1074
1489
|
|
|
@@ -1086,8 +1501,10 @@ def _concurrency_cfg(cfg: dict) -> dict:
|
|
|
1086
1501
|
|
|
1087
1502
|
def _task_isolation(cfg: dict) -> str:
|
|
1088
1503
|
isolation = _text(_concurrency_cfg(cfg).get("isolation")).lower() or "worktree"
|
|
1089
|
-
if isolation
|
|
1090
|
-
raise APError(
|
|
1504
|
+
if isolation != "worktree":
|
|
1505
|
+
raise APError(
|
|
1506
|
+
"concurrency.isolation must be worktree; shared-checkout/legacy writes are no longer supported"
|
|
1507
|
+
)
|
|
1091
1508
|
return isolation
|
|
1092
1509
|
|
|
1093
1510
|
|
|
@@ -1180,6 +1597,16 @@ def _validate_task_manifest(repo: Path, manifest: dict, expected_task_id: str =
|
|
|
1180
1597
|
raise APError(
|
|
1181
1598
|
f"Task registry identity mismatch: expected={expected_task_id}, manifest={task_id}"
|
|
1182
1599
|
)
|
|
1600
|
+
try:
|
|
1601
|
+
schema = int(manifest.get("schema") or 1)
|
|
1602
|
+
except (TypeError, ValueError) as exc:
|
|
1603
|
+
raise APError(f"Task {task_id} has an invalid manifest schema.") from exc
|
|
1604
|
+
if schema < 2:
|
|
1605
|
+
raise APError(
|
|
1606
|
+
f"Task {task_id} is a legacy schema-1 task. This runtime cannot safely infer or claim "
|
|
1607
|
+
"owned_paths for an in-flight task. Finish or clean it with the previously installed "
|
|
1608
|
+
"runtime before running autocoding sync, or restore the 3.0.0 runtime."
|
|
1609
|
+
)
|
|
1183
1610
|
task_uuid = _text(manifest.get("task_uuid"))
|
|
1184
1611
|
if not re.fullmatch(r"[0-9a-f]{32}", task_uuid):
|
|
1185
1612
|
raise APError(f"Invalid task manifest UUID for {task_id}; refusing Git operations.")
|
|
@@ -1215,6 +1642,33 @@ def _validate_task_manifest(repo: Path, manifest: dict, expected_task_id: str =
|
|
|
1215
1642
|
raise APError(
|
|
1216
1643
|
f"Task worktree must be outside its control checkout for {task_id}: {worktree}"
|
|
1217
1644
|
)
|
|
1645
|
+
owned_paths = manifest.get("owned_paths")
|
|
1646
|
+
if not isinstance(owned_paths, list) or not owned_paths or not all(
|
|
1647
|
+
isinstance(item, str) and item for item in owned_paths
|
|
1648
|
+
):
|
|
1649
|
+
raise APError(f"Task {task_id} has no valid owned_paths; refusing lifecycle operations.")
|
|
1650
|
+
depends_on = manifest.get("depends_on")
|
|
1651
|
+
prerequisite_shas = manifest.get("prerequisite_shas")
|
|
1652
|
+
if not isinstance(depends_on, list) or not isinstance(prerequisite_shas, dict):
|
|
1653
|
+
raise APError(f"Task {task_id} has an invalid dependency contract.")
|
|
1654
|
+
if set(depends_on) != set(prerequisite_shas):
|
|
1655
|
+
raise APError(f"Task {task_id} dependency IDs and prerequisite SHAs do not match.")
|
|
1656
|
+
for dependency, sha in prerequisite_shas.items():
|
|
1657
|
+
_validate_task_id(str(dependency))
|
|
1658
|
+
if not re.fullmatch(r"(?:[0-9a-f]{40}|[0-9a-f]{64})", _text(sha)):
|
|
1659
|
+
raise APError(f"Task {task_id} has an invalid prerequisite SHA for {dependency}.")
|
|
1660
|
+
lease = manifest.get("writer_lease")
|
|
1661
|
+
if not isinstance(lease, dict) or not _text(lease.get("holder")):
|
|
1662
|
+
raise APError(f"Task {task_id} has an invalid writer lease.")
|
|
1663
|
+
if int(lease.get("generation") or 0) < 1 or _text(lease.get("state")) != "active":
|
|
1664
|
+
raise APError(f"Task {task_id} writer lease is not active.")
|
|
1665
|
+
review = manifest.get("review")
|
|
1666
|
+
if not isinstance(review, dict) or _text(review.get("verdict")) not in {
|
|
1667
|
+
"pending",
|
|
1668
|
+
"approved",
|
|
1669
|
+
"changes-requested",
|
|
1670
|
+
}:
|
|
1671
|
+
raise APError(f"Task {task_id} has an invalid review contract.")
|
|
1218
1672
|
return manifest
|
|
1219
1673
|
|
|
1220
1674
|
|
|
@@ -1415,6 +1869,167 @@ def _task_commit_paths(repo: Path) -> list[str]:
|
|
|
1415
1869
|
return [path for path in _working_tree_paths(repo) if not _is_generated_noise_path(path)]
|
|
1416
1870
|
|
|
1417
1871
|
|
|
1872
|
+
def _normalize_owned_path(value: object) -> str:
|
|
1873
|
+
raw = _text(value).replace("\\", "/")
|
|
1874
|
+
while raw.startswith("./"):
|
|
1875
|
+
raw = raw[2:]
|
|
1876
|
+
normalized = posixpath.normpath(raw)
|
|
1877
|
+
if (
|
|
1878
|
+
not raw
|
|
1879
|
+
or raw.startswith("/")
|
|
1880
|
+
or normalized == ".."
|
|
1881
|
+
or normalized.startswith("../")
|
|
1882
|
+
or normalized == ".git"
|
|
1883
|
+
or normalized.startswith(".git/")
|
|
1884
|
+
):
|
|
1885
|
+
raise APError(f"Owned paths must be safe repository-relative paths: {value!r}")
|
|
1886
|
+
return normalized
|
|
1887
|
+
|
|
1888
|
+
|
|
1889
|
+
def _path_is_owned(path: str, owned_paths: list[str]) -> bool:
|
|
1890
|
+
normalized = _normalize_owned_path(path)
|
|
1891
|
+
return any(
|
|
1892
|
+
owner == "." or normalized == owner or normalized.startswith(owner.rstrip("/") + "/")
|
|
1893
|
+
for owner in owned_paths
|
|
1894
|
+
)
|
|
1895
|
+
|
|
1896
|
+
|
|
1897
|
+
def _task_managed_paths(cfg: dict, manifest: dict) -> list[str]:
|
|
1898
|
+
docs_cfg = cfg.get("docs") or {}
|
|
1899
|
+
task_id = _validate_task_id(_text(manifest.get("task_id")))
|
|
1900
|
+
return sorted(
|
|
1901
|
+
{
|
|
1902
|
+
f"{(_text(docs_cfg.get('active_task_dir')) or 'docs/tasks/active').rstrip('/')}/{task_id}.md",
|
|
1903
|
+
f"{(_text(docs_cfg.get('task_closure_dir')) or 'docs/tasks/closures').rstrip('/')}/{task_id}.md",
|
|
1904
|
+
f"{(_text(docs_cfg.get('task_evidence_dir')) or 'docs/tasks/evidence').rstrip('/')}/{task_id}.jsonl",
|
|
1905
|
+
}
|
|
1906
|
+
)
|
|
1907
|
+
|
|
1908
|
+
|
|
1909
|
+
def _task_changed_paths_from_base(repo: Path, base_sha: str) -> list[str]:
|
|
1910
|
+
paths = set(
|
|
1911
|
+
_checked_git_z_paths(
|
|
1912
|
+
repo,
|
|
1913
|
+
["git", "diff", "--name-only", "-z", "--diff-filter=ACDMRTUXB", base_sha, "--"],
|
|
1914
|
+
"task diff paths",
|
|
1915
|
+
)
|
|
1916
|
+
)
|
|
1917
|
+
paths.update(
|
|
1918
|
+
_checked_git_z_paths(
|
|
1919
|
+
repo,
|
|
1920
|
+
["git", "ls-files", "--others", "--exclude-standard", "-z"],
|
|
1921
|
+
"task untracked paths",
|
|
1922
|
+
)
|
|
1923
|
+
)
|
|
1924
|
+
return sorted(path.replace("\\", "/") for path in paths if not _is_generated_noise_path(path))
|
|
1925
|
+
|
|
1926
|
+
|
|
1927
|
+
def _task_unowned_paths(repo: Path, cfg: dict, manifest: dict) -> list[str]:
|
|
1928
|
+
owned = [_normalize_owned_path(item) for item in manifest.get("owned_paths") or []]
|
|
1929
|
+
managed = set(_task_managed_paths(cfg, manifest))
|
|
1930
|
+
return [
|
|
1931
|
+
path
|
|
1932
|
+
for path in _task_changed_paths_from_base(repo, _text(manifest.get("base_sha")))
|
|
1933
|
+
if path not in managed and not _path_is_owned(path, owned)
|
|
1934
|
+
]
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
def _task_review_fingerprint(repo: Path, manifest: dict, cfg: Optional[dict] = None) -> str:
|
|
1938
|
+
base_sha = _text(manifest.get("base_sha"))
|
|
1939
|
+
owned = [_normalize_owned_path(item) for item in manifest.get("owned_paths") or []]
|
|
1940
|
+
managed = set(_task_managed_paths(cfg or _load_cfg(repo), manifest))
|
|
1941
|
+
paths = [
|
|
1942
|
+
path
|
|
1943
|
+
for path in _task_changed_paths_from_base(repo, base_sha)
|
|
1944
|
+
if path not in managed and _path_is_owned(path, owned)
|
|
1945
|
+
]
|
|
1946
|
+
digest = hashlib.sha256()
|
|
1947
|
+
digest.update(f"contract:{_AGENT_CONTRACT_VERSION}\nbase:{base_sha}\n".encode("utf-8"))
|
|
1948
|
+
for rel in paths:
|
|
1949
|
+
digest.update(f"path:{rel}\0".encode("utf-8", errors="surrogateescape"))
|
|
1950
|
+
path = repo / rel
|
|
1951
|
+
try:
|
|
1952
|
+
mode = path.lstat().st_mode
|
|
1953
|
+
except OSError:
|
|
1954
|
+
digest.update(b"missing\0")
|
|
1955
|
+
continue
|
|
1956
|
+
digest.update(f"mode:{mode:o}\0".encode("ascii"))
|
|
1957
|
+
if path.is_symlink():
|
|
1958
|
+
digest.update(os.readlink(path).encode("utf-8", errors="surrogateescape"))
|
|
1959
|
+
elif path.is_file():
|
|
1960
|
+
digest.update(path.read_bytes())
|
|
1961
|
+
else:
|
|
1962
|
+
digest.update(b"non-file")
|
|
1963
|
+
digest.update(b"\0")
|
|
1964
|
+
return digest.hexdigest()
|
|
1965
|
+
|
|
1966
|
+
|
|
1967
|
+
def _invalidate_task_review(manifest: dict, reason: str) -> None:
|
|
1968
|
+
manifest["review"] = {
|
|
1969
|
+
"verdict": "pending",
|
|
1970
|
+
"diff_base": _text(manifest.get("base_sha")),
|
|
1971
|
+
"diff_head": "",
|
|
1972
|
+
"diff_fingerprint": "",
|
|
1973
|
+
"reviewer": "",
|
|
1974
|
+
"reviewed_at": "",
|
|
1975
|
+
"reason": reason,
|
|
1976
|
+
}
|
|
1977
|
+
|
|
1978
|
+
|
|
1979
|
+
def _actor_id(args: argparse.Namespace, field: str = "writer") -> str:
|
|
1980
|
+
explicit = _text(getattr(args, field, ""))
|
|
1981
|
+
runtime_actor = _text(os.environ.get("CODEX_THREAD_ID"))
|
|
1982
|
+
if explicit and runtime_actor and explicit != runtime_actor:
|
|
1983
|
+
raise APError(
|
|
1984
|
+
f"Explicit --{field.replace('_', '-')} does not match CODEX_THREAD_ID; "
|
|
1985
|
+
"actor identity cannot be overridden."
|
|
1986
|
+
)
|
|
1987
|
+
actor = runtime_actor or explicit
|
|
1988
|
+
if not actor:
|
|
1989
|
+
raise APError(f"A stable --{field.replace('_', '-')} or CODEX_THREAD_ID is required.")
|
|
1990
|
+
if any(char in actor for char in "\0\r\n"):
|
|
1991
|
+
raise APError("Actor identity contains invalid characters.")
|
|
1992
|
+
return actor
|
|
1993
|
+
|
|
1994
|
+
|
|
1995
|
+
def _require_current_writer(manifest: dict, args: argparse.Namespace) -> str:
|
|
1996
|
+
actor = _actor_id(args, "writer")
|
|
1997
|
+
lease = manifest.get("writer_lease") or {}
|
|
1998
|
+
if _text(lease.get("state")) != "active" or actor != _text(lease.get("holder")):
|
|
1999
|
+
raise APError(
|
|
2000
|
+
f"Writer lease mismatch: current={actor}, holder={_text(lease.get('holder')) or '(missing)'}."
|
|
2001
|
+
)
|
|
2002
|
+
return actor
|
|
2003
|
+
|
|
2004
|
+
|
|
2005
|
+
def _require_dependencies(repo: Path, manifest: dict, ancestor_ref: str) -> None:
|
|
2006
|
+
for dependency in manifest.get("depends_on") or []:
|
|
2007
|
+
sha = _text((manifest.get("prerequisite_shas") or {}).get(dependency))
|
|
2008
|
+
if run(
|
|
2009
|
+
["git", "merge-base", "--is-ancestor", sha, ancestor_ref],
|
|
2010
|
+
cwd=repo,
|
|
2011
|
+
check=False,
|
|
2012
|
+
).returncode != 0:
|
|
2013
|
+
raise APError(
|
|
2014
|
+
f"Prerequisite {dependency} at {sha} is not integrated into {ancestor_ref}."
|
|
2015
|
+
)
|
|
2016
|
+
|
|
2017
|
+
|
|
2018
|
+
def _require_approved_review(repo: Path, cfg: dict, manifest: dict) -> str:
|
|
2019
|
+
unowned = _task_unowned_paths(repo, cfg, manifest)
|
|
2020
|
+
if unowned:
|
|
2021
|
+
raise APError("Changes outside task owned_paths:\n- " + "\n- ".join(unowned))
|
|
2022
|
+
fingerprint = _task_review_fingerprint(repo, manifest)
|
|
2023
|
+
review = manifest.get("review") or {}
|
|
2024
|
+
if _text(review.get("verdict")) != "approved":
|
|
2025
|
+
raise APError("Task review must be approved before commit-push or integration.")
|
|
2026
|
+
if _text(review.get("diff_fingerprint")) != fingerprint:
|
|
2027
|
+
raise APError("Approved review fingerprint is stale for the current owned diff.")
|
|
2028
|
+
if _text(review.get("diff_base")) != _text(manifest.get("base_sha")):
|
|
2029
|
+
raise APError("Approved review base is stale for the current task base.")
|
|
2030
|
+
return fingerprint
|
|
2031
|
+
|
|
2032
|
+
|
|
1418
2033
|
def _unstaged_task_paths(repo: Path) -> list[str]:
|
|
1419
2034
|
paths = set(
|
|
1420
2035
|
_checked_git_z_paths(
|
|
@@ -1433,16 +2048,15 @@ def _unstaged_task_paths(repo: Path) -> list[str]:
|
|
|
1433
2048
|
return sorted(path for path in paths if not _is_generated_noise_path(path))
|
|
1434
2049
|
|
|
1435
2050
|
|
|
1436
|
-
def _require_task_context(repo: Path, cfg: dict, task_id: str) ->
|
|
2051
|
+
def _require_task_context(repo: Path, cfg: dict, task_id: str) -> dict:
|
|
2052
|
+
_task_isolation(cfg)
|
|
1437
2053
|
manifest = _active_task_manifest(repo)
|
|
1438
2054
|
if not manifest:
|
|
1439
2055
|
if _git_dir(repo) != _git_common_dir(repo):
|
|
1440
2056
|
raise APError(
|
|
1441
|
-
"This linked worktree has no registered task manifest.
|
|
2057
|
+
"This linked worktree has no registered task manifest. "
|
|
1442
2058
|
"return to the primary checkout and create or recover the task with task-start."
|
|
1443
2059
|
)
|
|
1444
|
-
if _task_isolation(cfg) == "legacy":
|
|
1445
|
-
return None
|
|
1446
2060
|
raise APError(
|
|
1447
2061
|
"This project requires an isolated task worktree. "
|
|
1448
2062
|
f"Run `python3 docs/tools/autopipeline/ap.py task-start {task_id}` from the main checkout, "
|
|
@@ -1559,6 +2173,48 @@ def _require_explicit_field(missing: List[str], field: str, value: object) -> No
|
|
|
1559
2173
|
missing.append(f"{field} (must be explicitly filled, not blank/TODO)")
|
|
1560
2174
|
|
|
1561
2175
|
|
|
2176
|
+
_REQUIRED_ACCESS_FIELDS = [
|
|
2177
|
+
"access.project.frontend.url",
|
|
2178
|
+
"access.project.frontend.username",
|
|
2179
|
+
"access.project.frontend.password",
|
|
2180
|
+
"access.project.backend.url",
|
|
2181
|
+
"access.project.backend.username",
|
|
2182
|
+
"access.project.backend.password",
|
|
2183
|
+
"access.jenkins.frontend.url",
|
|
2184
|
+
"access.jenkins.frontend.username",
|
|
2185
|
+
"access.jenkins.frontend.password",
|
|
2186
|
+
"access.jenkins.backend.url",
|
|
2187
|
+
"access.jenkins.backend.username",
|
|
2188
|
+
"access.jenkins.backend.password",
|
|
2189
|
+
"access.gitlab.url",
|
|
2190
|
+
"access.gitlab.username",
|
|
2191
|
+
"access.gitlab.password",
|
|
2192
|
+
"access.nexus.frontend.url",
|
|
2193
|
+
"access.nexus.frontend.username",
|
|
2194
|
+
"access.nexus.frontend.password",
|
|
2195
|
+
]
|
|
2196
|
+
|
|
2197
|
+
|
|
2198
|
+
def _nested_config_value(cfg: dict, field: str) -> object:
|
|
2199
|
+
value: object = cfg
|
|
2200
|
+
for part in field.split("."):
|
|
2201
|
+
if not isinstance(value, dict):
|
|
2202
|
+
return None
|
|
2203
|
+
value = value.get(part)
|
|
2204
|
+
return value
|
|
2205
|
+
|
|
2206
|
+
|
|
2207
|
+
def _access_config_issues(cfg: dict) -> list[str]:
|
|
2208
|
+
issues: list[str] = []
|
|
2209
|
+
for field in _REQUIRED_ACCESS_FIELDS:
|
|
2210
|
+
value = _nested_config_value(cfg, field)
|
|
2211
|
+
if not isinstance(value, str) or not _is_explicit_fill(value):
|
|
2212
|
+
issues.append(f"{field} (must be an explicitly filled string, not blank/TODO)")
|
|
2213
|
+
for field in [name for name in _REQUIRED_ACCESS_FIELDS if name.endswith(".url")]:
|
|
2214
|
+
_validate_url_field(issues, field, _nested_config_value(cfg, field))
|
|
2215
|
+
return issues
|
|
2216
|
+
|
|
2217
|
+
|
|
1562
2218
|
def _has_secret_reference(section_cfg: dict, field: str) -> bool:
|
|
1563
2219
|
return _is_explicit_fill(section_cfg.get(field)) or _is_explicit_fill(section_cfg.get(f"{field}_env"))
|
|
1564
2220
|
|
|
@@ -1596,7 +2252,7 @@ def _resolve_secret(section_name: str, section_cfg: dict, field: str) -> str:
|
|
|
1596
2252
|
|
|
1597
2253
|
_GATE_SCOPES = {"auto", "changed", "standard", "full"}
|
|
1598
2254
|
_WORKFLOW_PROFILES = {"auto", "micro", "standard", "high-risk"}
|
|
1599
|
-
_PROFILE_GATE_SCOPE = {"micro": "changed", "standard": "
|
|
2255
|
+
_PROFILE_GATE_SCOPE = {"micro": "changed", "standard": "changed", "high-risk": "changed"}
|
|
1600
2256
|
_PROFILE_RANK = {"micro": 0, "standard": 1, "high-risk": 2}
|
|
1601
2257
|
_SCOPE_RANK = {"changed": 0, "standard": 1, "full": 2}
|
|
1602
2258
|
_DOC_PATH_PATTERNS = ["*.md", "docs/**"]
|
|
@@ -1831,44 +2487,16 @@ def _has_changed_gate(cfg: dict, gate_cfg: dict, paths: list[str]) -> bool:
|
|
|
1831
2487
|
|
|
1832
2488
|
def _select_gate_scope(cfg: dict, requested_scope: str, paths: list[str]) -> tuple[str, list[str], list[dict]]:
|
|
1833
2489
|
gate_cfg = _gate_cfg(cfg)
|
|
1834
|
-
scope = (requested_scope or _text(gate_cfg.get("default_scope")) or "
|
|
2490
|
+
scope = (requested_scope or _text(gate_cfg.get("default_scope")) or "changed").lower()
|
|
1835
2491
|
if scope not in _GATE_SCOPES:
|
|
1836
2492
|
raise APError("gate scope must be one of: " + ", ".join(sorted(_GATE_SCOPES)))
|
|
1837
2493
|
|
|
1838
2494
|
matching_rules = _matching_gate_rules(paths, gate_cfg)
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
if any(_path_matches(path, _gate_full_patterns(gate_cfg)) for path in paths):
|
|
1845
|
-
return "full", ["changed files match full-gate patterns"], matching_rules
|
|
1846
|
-
|
|
1847
|
-
if scope != "auto":
|
|
1848
|
-
return scope, [f"requested scope: {scope}"], matching_rules
|
|
1849
|
-
|
|
1850
|
-
if not paths:
|
|
1851
|
-
fallback = _text(gate_cfg.get("no_change_scope")) or "standard"
|
|
1852
|
-
if fallback not in {"changed", "standard", "full"}:
|
|
1853
|
-
fallback = "standard"
|
|
1854
|
-
return fallback, ["no changed files detected"], matching_rules
|
|
1855
|
-
|
|
1856
|
-
if "standard" in rule_scopes:
|
|
1857
|
-
return "standard", ["matched gate rule with scope=standard"], matching_rules
|
|
1858
|
-
|
|
1859
|
-
if _docs_only(paths):
|
|
1860
|
-
return "changed", ["docs-only change"], matching_rules
|
|
1861
|
-
|
|
1862
|
-
if _has_changed_gate(cfg, gate_cfg, paths):
|
|
1863
|
-
return "changed", ["matched changed-gate command or rule"], matching_rules
|
|
1864
|
-
|
|
1865
|
-
fallback = _text(gate_cfg.get("fallback_scope")) or "standard"
|
|
1866
|
-
if fallback not in {"changed", "standard", "full"}:
|
|
1867
|
-
fallback = "standard"
|
|
1868
|
-
if fallback == "changed" and _text(gate_cfg.get("full_on_unknown")).lower() in {"1", "true", "yes", "on"}:
|
|
1869
|
-
fallback = "full"
|
|
1870
|
-
reasons.append("no changed-gate command/rule matched")
|
|
1871
|
-
return fallback, reasons, matching_rules
|
|
2495
|
+
requested = "auto" if scope == "auto" else scope
|
|
2496
|
+
reason = "local development gate is fixed to changed/quick scope"
|
|
2497
|
+
if requested not in {"auto", "changed"}:
|
|
2498
|
+
reason += f"; ignored requested scope={requested}"
|
|
2499
|
+
return "changed", [reason], matching_rules
|
|
1872
2500
|
|
|
1873
2501
|
|
|
1874
2502
|
def _impact_summary(
|
|
@@ -1922,12 +2550,13 @@ def _print_impact(summary: dict, as_json: bool = False) -> None:
|
|
|
1922
2550
|
print("[impact] changed: (none)")
|
|
1923
2551
|
|
|
1924
2552
|
|
|
1925
|
-
def _run_changed_gate(repo: Path, cfg: dict, paths: list[str]
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
if
|
|
1930
|
-
|
|
2553
|
+
def _run_changed_gate(repo: Path, cfg: dict, paths: list[str]) -> list[str]:
|
|
2554
|
+
# The generic scaffold uses this command as its whole fast gate. The
|
|
2555
|
+
# built-in diff check below covers working tree, index, and task commits, so
|
|
2556
|
+
# do not execute the narrower configured spelling first as a duplicate.
|
|
2557
|
+
if _configured_command(cfg, "gate_changed").strip() == "git diff --check":
|
|
2558
|
+
print("[gate] gate_changed is handled by the built-in diff check")
|
|
2559
|
+
return []
|
|
1931
2560
|
|
|
1932
2561
|
fallback_commands = ["gate_changed"]
|
|
1933
2562
|
if _docs_only(paths):
|
|
@@ -1940,13 +2569,13 @@ def _run_changed_gate(repo: Path, cfg: dict, paths: list[str], matching_rules: l
|
|
|
1940
2569
|
print("[gate] docs-only change with no changed-gate command configured; running built-in post checks only.")
|
|
1941
2570
|
return ["docs_only_builtin"]
|
|
1942
2571
|
|
|
1943
|
-
fallback = _run_first_configured_command(repo, cfg, ["quick_test"
|
|
2572
|
+
fallback = _run_first_configured_command(repo, cfg, ["quick_test"])
|
|
1944
2573
|
if fallback:
|
|
1945
2574
|
return [fallback]
|
|
1946
2575
|
|
|
1947
2576
|
raise APError(
|
|
1948
|
-
"Changed gate has no
|
|
1949
|
-
"
|
|
2577
|
+
"Changed gate has no fast command. Add commands.gate_changed or commands.quick_test. "
|
|
2578
|
+
"gate.rules commands are never executed by the automatic development flow."
|
|
1950
2579
|
)
|
|
1951
2580
|
|
|
1952
2581
|
|
|
@@ -1964,8 +2593,8 @@ def _run_full_gate(repo: Path, cfg: dict) -> list[str]:
|
|
|
1964
2593
|
command = _run_first_configured_command(repo, cfg, ["gate_full", "full_gate"])
|
|
1965
2594
|
if not command:
|
|
1966
2595
|
raise APError(
|
|
1967
|
-
"
|
|
1968
|
-
"commands.
|
|
2596
|
+
"Optional full diagnostic is under-configured. Add commands.gate_full or "
|
|
2597
|
+
"commands.full_gate when you explicitly want to run it."
|
|
1969
2598
|
)
|
|
1970
2599
|
return [command]
|
|
1971
2600
|
|
|
@@ -3365,13 +3994,17 @@ def _classify_paths(paths: list[str]) -> dict:
|
|
|
3365
3994
|
categories.add("docs")
|
|
3366
3995
|
if any(token in lower for token in ["domain", "service", "usecase", "repository", "infrastructure", "adapter", "shared", "utils"]):
|
|
3367
3996
|
categories.add("structure")
|
|
3997
|
+
return _classification_for_categories(categories, len(paths))
|
|
3998
|
+
|
|
3999
|
+
|
|
4000
|
+
def _classification_for_categories(categories: set[str], file_count: int) -> dict:
|
|
3368
4001
|
return {
|
|
3369
4002
|
"categories": sorted(categories),
|
|
3370
4003
|
"needs_dd": bool(
|
|
3371
4004
|
categories
|
|
3372
4005
|
& {"api", "db", "auth", "payment", "file_transfer", "gateway", "prod_config", "release_or_tooling"}
|
|
3373
4006
|
)
|
|
3374
|
-
or
|
|
4007
|
+
or file_count > 12,
|
|
3375
4008
|
"needs_adr": bool(categories & {"structure", "release_or_tooling"}) and not categories <= {"docs"},
|
|
3376
4009
|
"needs_browser": "ui" in categories,
|
|
3377
4010
|
"needs_jenkins": bool(
|
|
@@ -3383,6 +4016,29 @@ def _classify_paths(paths: list[str]) -> dict:
|
|
|
3383
4016
|
}
|
|
3384
4017
|
|
|
3385
4018
|
|
|
4019
|
+
def _classify_intent(intent: str) -> list[str]:
|
|
4020
|
+
value = _text(intent).lower()
|
|
4021
|
+
keyword_categories = {
|
|
4022
|
+
"db": ["database", "migration", "schema", "sql", "数据库", "数据迁移", "表结构"],
|
|
4023
|
+
"api": ["api", "controller", "endpoint", "接口", "控制器"],
|
|
4024
|
+
"auth": ["auth", "permission", "security", "登录", "认证", "鉴权", "权限", "安全"],
|
|
4025
|
+
"payment": ["payment", "billing", "checkout", "支付", "账单", "结算"],
|
|
4026
|
+
"file_transfer": ["upload", "download", "上传", "下载", "附件"],
|
|
4027
|
+
"gateway": ["gateway", "ingress", "nginx", "网关", "反向代理"],
|
|
4028
|
+
"prod_config": ["production config", "prod config", "生产配置"],
|
|
4029
|
+
"release_or_tooling": ["release", "deploy", "jenkins", "nexus", "发布", "部署", "构建"],
|
|
4030
|
+
"ui": ["frontend", "page", "component", "ui", "前端", "页面", "组件", "界面"],
|
|
4031
|
+
"test": ["test", "spec", "测试"],
|
|
4032
|
+
"docs": ["documentation", "docs", "文档"],
|
|
4033
|
+
"structure": ["refactor", "architecture", "重构", "架构", "分层"],
|
|
4034
|
+
}
|
|
4035
|
+
return sorted(
|
|
4036
|
+
category
|
|
4037
|
+
for category, keywords in keyword_categories.items()
|
|
4038
|
+
if any(keyword in value for keyword in keywords)
|
|
4039
|
+
)
|
|
4040
|
+
|
|
4041
|
+
|
|
3386
4042
|
def _normalize_workflow_profile(value: object, default: str = "auto") -> str:
|
|
3387
4043
|
profile = _text(value).lower() or default
|
|
3388
4044
|
if profile not in _WORKFLOW_PROFILES:
|
|
@@ -3395,17 +4051,197 @@ def _configured_workflow_profile(cfg: dict) -> str:
|
|
|
3395
4051
|
|
|
3396
4052
|
|
|
3397
4053
|
def _recommended_agents(profile: str, categories: set[str], classification: dict) -> list[str]:
|
|
4054
|
+
roles: list[str] = []
|
|
4055
|
+
for stage in _agent_execution_plan(profile, categories, classification)["stages"]:
|
|
4056
|
+
for role in stage["roles"]:
|
|
4057
|
+
if role != "main" and role not in roles:
|
|
4058
|
+
roles.append(role)
|
|
4059
|
+
return roles
|
|
4060
|
+
|
|
4061
|
+
|
|
4062
|
+
def _agent_contract_shape() -> tuple[dict, list[str]]:
|
|
4063
|
+
return (
|
|
4064
|
+
{
|
|
4065
|
+
"common": [
|
|
4066
|
+
"contract_version",
|
|
4067
|
+
"node_id",
|
|
4068
|
+
"task_id",
|
|
4069
|
+
"role",
|
|
4070
|
+
"base_sha",
|
|
4071
|
+
"scope",
|
|
4072
|
+
"depends_on",
|
|
4073
|
+
"acceptance",
|
|
4074
|
+
],
|
|
4075
|
+
"writer": ["task_branch", "worktree_path", "owned_paths"],
|
|
4076
|
+
"reviewer": [
|
|
4077
|
+
"task_id",
|
|
4078
|
+
"diff_base",
|
|
4079
|
+
"diff_head",
|
|
4080
|
+
"diff_fingerprint",
|
|
4081
|
+
"owning_fixer",
|
|
4082
|
+
],
|
|
4083
|
+
},
|
|
4084
|
+
[
|
|
4085
|
+
"contract_version",
|
|
4086
|
+
"node_id",
|
|
4087
|
+
"role",
|
|
4088
|
+
"task_id",
|
|
4089
|
+
"base_sha",
|
|
4090
|
+
"status",
|
|
4091
|
+
"summary",
|
|
4092
|
+
"depends_on",
|
|
4093
|
+
"owned_paths",
|
|
4094
|
+
"changed_paths",
|
|
4095
|
+
"diff_fingerprint",
|
|
4096
|
+
"evidence",
|
|
4097
|
+
"findings",
|
|
4098
|
+
"verdict",
|
|
4099
|
+
"risks",
|
|
4100
|
+
"next_owner",
|
|
4101
|
+
],
|
|
4102
|
+
)
|
|
4103
|
+
|
|
4104
|
+
|
|
4105
|
+
def _validate_agent_plan(plan: dict) -> dict:
|
|
4106
|
+
required = {
|
|
4107
|
+
"contract_version",
|
|
4108
|
+
"contract_schema",
|
|
4109
|
+
"strategy",
|
|
4110
|
+
"policies",
|
|
4111
|
+
"assignment_contract",
|
|
4112
|
+
"result_contract",
|
|
4113
|
+
"stages",
|
|
4114
|
+
"constraints",
|
|
4115
|
+
}
|
|
4116
|
+
missing = sorted(required - set(plan))
|
|
4117
|
+
if missing or plan.get("contract_version") != _AGENT_CONTRACT_VERSION:
|
|
4118
|
+
raise APError("Invalid agent plan contract: " + (", ".join(missing) or "version"))
|
|
4119
|
+
if plan.get("contract_schema") != _AGENT_CONTRACT_SCHEMA:
|
|
4120
|
+
raise APError("Invalid agent plan schema path.")
|
|
4121
|
+
if not all(
|
|
4122
|
+
isinstance(stage, dict)
|
|
4123
|
+
and {"id", "mode", "roles", "depends_on"} <= set(stage)
|
|
4124
|
+
for stage in plan.get("stages") or []
|
|
4125
|
+
):
|
|
4126
|
+
raise APError("Invalid agent plan stage contract.")
|
|
4127
|
+
return plan
|
|
4128
|
+
|
|
4129
|
+
|
|
4130
|
+
def _agent_execution_plan(profile: str, categories: set[str], classification: dict) -> dict:
|
|
4131
|
+
assignment_contract, result_contract = _agent_contract_shape()
|
|
3398
4132
|
if profile == "micro":
|
|
3399
|
-
return
|
|
3400
|
-
|
|
4133
|
+
return _validate_agent_plan({
|
|
4134
|
+
"contract_version": _AGENT_CONTRACT_VERSION,
|
|
4135
|
+
"contract_schema": _AGENT_CONTRACT_SCHEMA,
|
|
4136
|
+
"strategy": "main-only",
|
|
4137
|
+
"policies": {
|
|
4138
|
+
"one_writer_per_worktree": True,
|
|
4139
|
+
"path_ownership": "explicit-non-overlapping",
|
|
4140
|
+
"dependency_policy": "integrate-before-dependent-start",
|
|
4141
|
+
"review_feedback_owner": "main",
|
|
4142
|
+
"review_binding": "diff-fingerprint",
|
|
4143
|
+
"lifecycle_owner": "main",
|
|
4144
|
+
"gate_owner": "main",
|
|
4145
|
+
},
|
|
4146
|
+
"assignment_contract": assignment_contract,
|
|
4147
|
+
"result_contract": result_contract,
|
|
4148
|
+
"stages": [
|
|
4149
|
+
{
|
|
4150
|
+
"id": "delivery",
|
|
4151
|
+
"mode": "serial",
|
|
4152
|
+
"roles": ["main"],
|
|
4153
|
+
"depends_on": [],
|
|
4154
|
+
}
|
|
4155
|
+
],
|
|
4156
|
+
"constraints": [
|
|
4157
|
+
"Do not create subagents when the task has no independent work worth delegating.",
|
|
4158
|
+
"The main agent owns the fast gate, Git integration, push, and cleanup.",
|
|
4159
|
+
],
|
|
4160
|
+
})
|
|
4161
|
+
|
|
4162
|
+
discovery_roles = ["explorer"]
|
|
3401
4163
|
if categories & {"api", "release_or_tooling"}:
|
|
3402
|
-
|
|
3403
|
-
roles.append("fixer")
|
|
4164
|
+
discovery_roles.append("docs_researcher")
|
|
3404
4165
|
if classification.get("needs_browser"):
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
4166
|
+
discovery_roles.append("browser_debugger")
|
|
4167
|
+
|
|
4168
|
+
return _validate_agent_plan({
|
|
4169
|
+
"contract_version": _AGENT_CONTRACT_VERSION,
|
|
4170
|
+
"contract_schema": _AGENT_CONTRACT_SCHEMA,
|
|
4171
|
+
"strategy": "orchestrated-subagents",
|
|
4172
|
+
"policies": {
|
|
4173
|
+
"one_writer_per_worktree": True,
|
|
4174
|
+
"path_ownership": "explicit-non-overlapping",
|
|
4175
|
+
"dependency_policy": "integrate-before-dependent-start",
|
|
4176
|
+
"review_feedback_owner": "owning-fixer",
|
|
4177
|
+
"review_binding": "diff-fingerprint",
|
|
4178
|
+
"lifecycle_owner": "main",
|
|
4179
|
+
"gate_owner": "main",
|
|
4180
|
+
},
|
|
4181
|
+
"assignment_contract": assignment_contract,
|
|
4182
|
+
"result_contract": result_contract,
|
|
4183
|
+
"stages": [
|
|
4184
|
+
{
|
|
4185
|
+
"id": "decomposition",
|
|
4186
|
+
"mode": "serial",
|
|
4187
|
+
"roles": ["main"],
|
|
4188
|
+
"depends_on": [],
|
|
4189
|
+
},
|
|
4190
|
+
{
|
|
4191
|
+
"id": "discovery",
|
|
4192
|
+
"mode": "parallel",
|
|
4193
|
+
"roles": discovery_roles,
|
|
4194
|
+
"depends_on": ["decomposition"],
|
|
4195
|
+
},
|
|
4196
|
+
{
|
|
4197
|
+
"id": "design",
|
|
4198
|
+
"mode": "serial",
|
|
4199
|
+
"roles": ["main"],
|
|
4200
|
+
"depends_on": ["discovery"],
|
|
4201
|
+
},
|
|
4202
|
+
{
|
|
4203
|
+
"id": "delivery",
|
|
4204
|
+
"mode": "dependency-waves",
|
|
4205
|
+
"roles": ["fixer", "reviewer", "main"],
|
|
4206
|
+
"depends_on": ["design"],
|
|
4207
|
+
"scale": "one fixer per independent development unit in the current dependency layer",
|
|
4208
|
+
"wave_phases": [
|
|
4209
|
+
{
|
|
4210
|
+
"id": "implementation",
|
|
4211
|
+
"mode": "parallel-isolated",
|
|
4212
|
+
"roles": ["fixer"],
|
|
4213
|
+
},
|
|
4214
|
+
{
|
|
4215
|
+
"id": "review",
|
|
4216
|
+
"mode": "parallel-read-only",
|
|
4217
|
+
"roles": ["reviewer"],
|
|
4218
|
+
"feedback_to": "owning fixer",
|
|
4219
|
+
},
|
|
4220
|
+
{
|
|
4221
|
+
"id": "gate-integrate",
|
|
4222
|
+
"mode": "serial",
|
|
4223
|
+
"roles": ["main"],
|
|
4224
|
+
},
|
|
4225
|
+
],
|
|
4226
|
+
"next_wave": "start only after every prerequisite in the next layer is integrated",
|
|
4227
|
+
},
|
|
4228
|
+
{
|
|
4229
|
+
"id": "closure",
|
|
4230
|
+
"mode": "serial",
|
|
4231
|
+
"roles": ["main"],
|
|
4232
|
+
"depends_on": ["delivery"],
|
|
4233
|
+
},
|
|
4234
|
+
],
|
|
4235
|
+
"constraints": [
|
|
4236
|
+
"Delegate only independent bounded work and declare dependencies before dispatch.",
|
|
4237
|
+
"Every fixer owns exactly one registered task branch/worktree and an explicit path scope.",
|
|
4238
|
+
"Never run two writers in one worktree or let the main agent edit a fixer-owned worktree concurrently.",
|
|
4239
|
+
"Start a dependent write task only after its prerequisite has been integrated into the target branch.",
|
|
4240
|
+
"Subagents do not commit, push, integrate, or clean task branches.",
|
|
4241
|
+
"Reviewers inspect a stable diff; changes-requested returns to the owning fixer and any edit requires re-review.",
|
|
4242
|
+
"The main agent routes review feedback, runs the single fast gate for each write task, integrates in dependency order, pushes, and cleans branches.",
|
|
4243
|
+
],
|
|
4244
|
+
})
|
|
3409
4245
|
|
|
3410
4246
|
|
|
3411
4247
|
def _resolve_execution_plan(
|
|
@@ -3417,6 +4253,8 @@ def _resolve_execution_plan(
|
|
|
3417
4253
|
requested_mode: str = "",
|
|
3418
4254
|
base_ref: str = "",
|
|
3419
4255
|
changed_paths: Optional[list[str]] = None,
|
|
4256
|
+
planned_paths: Optional[list[str]] = None,
|
|
4257
|
+
intent: str = "",
|
|
3420
4258
|
) -> dict:
|
|
3421
4259
|
impact = _impact_summary(
|
|
3422
4260
|
cfg,
|
|
@@ -3426,21 +4264,29 @@ def _resolve_execution_plan(
|
|
|
3426
4264
|
changed_paths=changed_paths,
|
|
3427
4265
|
)
|
|
3428
4266
|
paths = list(impact.get("changed_files") or [])
|
|
3429
|
-
|
|
4267
|
+
normalized_planned_paths = sorted(
|
|
4268
|
+
{_normalize_owned_path(item) for item in (planned_paths or []) if _text(item)}
|
|
4269
|
+
)
|
|
4270
|
+
classification_inputs = [*paths, *normalized_planned_paths]
|
|
4271
|
+
classification = _classify_paths(classification_inputs)
|
|
4272
|
+
intent_categories = _classify_intent(intent)
|
|
4273
|
+
merged_categories = set(classification["categories"]) | set(intent_categories)
|
|
4274
|
+
classification = _classification_for_categories(merged_categories, len(classification_inputs))
|
|
3430
4275
|
categories = set(classification["categories"])
|
|
3431
|
-
matching_rules = _matching_gate_rules(
|
|
4276
|
+
matching_rules = _matching_gate_rules(classification_inputs, _gate_cfg(cfg))
|
|
3432
4277
|
configured_profile = _configured_workflow_profile(cfg)
|
|
3433
4278
|
requested_profile_value = _normalize_workflow_profile(requested_profile) if requested_profile else ""
|
|
3434
4279
|
configured_mode = _workflow_mode(cfg)
|
|
3435
4280
|
requested_mode_value = _text(requested_mode).lower()
|
|
3436
|
-
if requested_mode_value and requested_mode_value
|
|
3437
|
-
raise APError("workflow.mode must be 'dev'
|
|
4281
|
+
if requested_mode_value and requested_mode_value != "dev":
|
|
4282
|
+
raise APError("workflow.mode must be 'dev'; use explicit diagnostic commands when requested.")
|
|
3438
4283
|
|
|
3439
4284
|
detected_profile = "standard"
|
|
3440
4285
|
profile_reasons: list[str] = []
|
|
3441
|
-
docs_only_paths = _docs_only(
|
|
3442
|
-
docs_or_tests_only = bool(
|
|
3443
|
-
(docs_only_paths and str(impact["selected_scope"]) != "full")
|
|
4286
|
+
docs_only_paths = _docs_only(classification_inputs)
|
|
4287
|
+
docs_or_tests_only = bool(classification_inputs) and (
|
|
4288
|
+
(docs_only_paths and str(impact["selected_scope"]) != "full")
|
|
4289
|
+
or _tests_only(classification_inputs)
|
|
3444
4290
|
)
|
|
3445
4291
|
if docs_or_tests_only and str(impact["selected_scope"]) != "full":
|
|
3446
4292
|
detected_profile = "micro"
|
|
@@ -3472,14 +4318,10 @@ def _resolve_execution_plan(
|
|
|
3472
4318
|
high_signals: list[str] = []
|
|
3473
4319
|
if categories & high_categories and not docs_or_tests_only:
|
|
3474
4320
|
high_signals.append("high-risk category: " + ", ".join(sorted(categories & high_categories)))
|
|
3475
|
-
if str(impact["selected_scope"]) == "full":
|
|
3476
|
-
high_signals.append("impact requires full gate")
|
|
3477
4321
|
if "high-risk" in rule_profiles:
|
|
3478
4322
|
high_signals.append("matched gate rule with profile=high-risk")
|
|
3479
|
-
if len(
|
|
4323
|
+
if len(classification_inputs) > 12 and not docs_or_tests_only:
|
|
3480
4324
|
high_signals.append("change spans more than 12 files")
|
|
3481
|
-
if requested_scope == "full":
|
|
3482
|
-
high_signals.append("full scope explicitly requested")
|
|
3483
4325
|
|
|
3484
4326
|
if high_signals:
|
|
3485
4327
|
detected_profile = "high-risk"
|
|
@@ -3501,34 +4343,27 @@ def _resolve_execution_plan(
|
|
|
3501
4343
|
if detected_profile == "high-risk" and effective_profile != "high-risk":
|
|
3502
4344
|
effective_profile = "high-risk"
|
|
3503
4345
|
profile_reasons.append("high-risk signals cannot be downgraded")
|
|
3504
|
-
effective_mode =
|
|
3505
|
-
if configured_mode == "verify":
|
|
3506
|
-
effective_mode = "verify"
|
|
3507
|
-
if effective_mode == "verify" and effective_profile != "high-risk":
|
|
3508
|
-
effective_profile = "high-risk"
|
|
3509
|
-
profile_reasons.append("verify mode requires high-risk execution")
|
|
4346
|
+
effective_mode = "dev"
|
|
3510
4347
|
if not profile_reasons:
|
|
3511
4348
|
profile_reasons.append(f"configured profile={configured_profile}")
|
|
3512
4349
|
|
|
3513
|
-
selected_scope =
|
|
3514
|
-
explicit_scope = _text(requested_scope).lower()
|
|
3515
|
-
if explicit_scope in _SCOPE_RANK and _SCOPE_RANK[explicit_scope] > _SCOPE_RANK[selected_scope]:
|
|
3516
|
-
selected_scope = explicit_scope
|
|
3517
|
-
if str(impact["selected_scope"]) == "full":
|
|
3518
|
-
selected_scope = "full"
|
|
3519
|
-
effective_mode = "verify" if effective_profile == "high-risk" else effective_mode
|
|
4350
|
+
selected_scope = "changed"
|
|
3520
4351
|
execution_reasons = list(impact.get("reasons") or [])
|
|
3521
|
-
|
|
3522
|
-
execution_reasons.append(f"profile={effective_profile} requires scope={selected_scope}")
|
|
4352
|
+
execution_reasons.append("Jenkins/build/deploy and owner acceptance happen after coding completion")
|
|
3523
4353
|
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
needs_jenkins = bool(classification["needs_jenkins"] and jenkins_required)
|
|
3527
|
-
needs_target = bool(classification["needs_target"] and target_env_required)
|
|
4354
|
+
needs_jenkins = False
|
|
4355
|
+
needs_target = False
|
|
3528
4356
|
needs_dd = bool(classification["needs_dd"] or effective_profile == "high-risk")
|
|
3529
4357
|
|
|
4358
|
+
agent_plan = _agent_execution_plan(effective_profile, categories, classification)
|
|
3530
4359
|
return {
|
|
3531
4360
|
**impact,
|
|
4361
|
+
"contract_version": _AGENT_CONTRACT_VERSION,
|
|
4362
|
+
"contract_schema": _AGENT_CONTRACT_SCHEMA,
|
|
4363
|
+
"planned_files": normalized_planned_paths,
|
|
4364
|
+
"classification_files": classification_inputs,
|
|
4365
|
+
"intent_provided": bool(_text(intent)),
|
|
4366
|
+
"intent_categories": intent_categories,
|
|
3532
4367
|
"reasons": execution_reasons,
|
|
3533
4368
|
"configured_profile": configured_profile,
|
|
3534
4369
|
"requested_profile": requested_profile_value or None,
|
|
@@ -3545,12 +4380,25 @@ def _resolve_execution_plan(
|
|
|
3545
4380
|
"needs_jenkins": needs_jenkins,
|
|
3546
4381
|
"needs_target": needs_target,
|
|
3547
4382
|
"recommended_agents": _recommended_agents(effective_profile, categories, classification),
|
|
4383
|
+
"agent_plan": agent_plan,
|
|
3548
4384
|
}
|
|
3549
4385
|
|
|
3550
4386
|
|
|
3551
4387
|
def cmd_classify(args: argparse.Namespace) -> None:
|
|
3552
4388
|
repo = Path(args.repo).resolve()
|
|
3553
4389
|
cfg = _load_cfg(repo)
|
|
4390
|
+
intent_parts = [_text(getattr(args, "intent", ""))]
|
|
4391
|
+
intent_file = _text(getattr(args, "intent_file", ""))
|
|
4392
|
+
if intent_file:
|
|
4393
|
+
path = Path(intent_file)
|
|
4394
|
+
if not path.is_absolute():
|
|
4395
|
+
path = repo / path
|
|
4396
|
+
try:
|
|
4397
|
+
if path.stat().st_size > 65536:
|
|
4398
|
+
raise APError("--intent-file is limited to 64 KiB.")
|
|
4399
|
+
intent_parts.append(path.read_text(encoding="utf-8"))
|
|
4400
|
+
except OSError as exc:
|
|
4401
|
+
raise APError(f"Cannot read --intent-file: {path}: {exc}") from exc
|
|
3554
4402
|
plan = _resolve_execution_plan(
|
|
3555
4403
|
cfg,
|
|
3556
4404
|
repo,
|
|
@@ -3558,17 +4406,13 @@ def cmd_classify(args: argparse.Namespace) -> None:
|
|
|
3558
4406
|
requested_profile=_text(getattr(args, "profile", "")).lower(),
|
|
3559
4407
|
requested_mode=_text(getattr(args, "mode", "")).lower(),
|
|
3560
4408
|
base_ref=_text(getattr(args, "base", "")),
|
|
4409
|
+
planned_paths=list(getattr(args, "planned_path", []) or []),
|
|
4410
|
+
intent="\n".join(part for part in intent_parts if part),
|
|
3561
4411
|
)
|
|
3562
4412
|
risk = {"micro": "P3", "standard": "P2", "high-risk": "P1"}[plan["profile"]]
|
|
3563
|
-
commands = [
|
|
3564
|
-
"python3 docs/tools/autopipeline/ap.py impact --scope auto",
|
|
3565
|
-
"python3 docs/tools/autopipeline/ap.py structure-check --scope auto",
|
|
3566
|
-
f"python3 docs/tools/autopipeline/ap.py light-gate --profile {plan['profile']} --explain",
|
|
3567
|
-
]
|
|
4413
|
+
commands: list[str] = []
|
|
3568
4414
|
if plan["needs_dd"]:
|
|
3569
4415
|
commands.append("python3 docs/tools/autopipeline/ap.py scaffold design --write")
|
|
3570
|
-
if plan["needs_jenkins"]:
|
|
3571
|
-
commands.append("python3 docs/tools/autopipeline/ap.py verify-jenkins")
|
|
3572
4416
|
result = {
|
|
3573
4417
|
**plan,
|
|
3574
4418
|
"risk": risk,
|
|
@@ -3583,6 +4427,13 @@ def cmd_classify(args: argparse.Namespace) -> None:
|
|
|
3583
4427
|
print(f"[classify] selected_scope={result['selected_scope']}")
|
|
3584
4428
|
print("[classify] categories=" + (", ".join(result["categories"]) or "(none)"))
|
|
3585
4429
|
print("[classify] agents=" + (", ".join(result["recommended_agents"]) or "(main agent only)"))
|
|
4430
|
+
print(f"[classify] agent_strategy={result['agent_plan']['strategy']}")
|
|
4431
|
+
for stage in result["agent_plan"]["stages"]:
|
|
4432
|
+
print(
|
|
4433
|
+
"[classify] agent_stage="
|
|
4434
|
+
f"{stage['id']} mode={stage['mode']} roles={','.join(stage['roles'])} "
|
|
4435
|
+
f"depends_on={','.join(stage['depends_on']) or '-'}"
|
|
4436
|
+
)
|
|
3586
4437
|
for key in ["needs_dd", "needs_adr", "needs_browser", "needs_jenkins", "needs_target"]:
|
|
3587
4438
|
print(f"[classify] {key}={result[key]}")
|
|
3588
4439
|
for command in commands:
|
|
@@ -3616,18 +4467,17 @@ def cmd_run(args: argparse.Namespace) -> None:
|
|
|
3616
4467
|
def cmd_light_gate(args: argparse.Namespace) -> None:
|
|
3617
4468
|
repo = Path(args.repo).resolve()
|
|
3618
4469
|
light_gate_start = time.time()
|
|
3619
|
-
cmd_doctor(
|
|
3620
|
-
argparse.Namespace(
|
|
3621
|
-
repo=str(repo),
|
|
3622
|
-
profile=_text(getattr(args, "profile", "")).lower(),
|
|
3623
|
-
mode=_text(getattr(args, "mode", "")).lower(),
|
|
3624
|
-
)
|
|
3625
|
-
)
|
|
3626
4470
|
cfg = _load_cfg(repo)
|
|
4471
|
+
requested_scope = _text(getattr(args, "scope", "")).lower()
|
|
4472
|
+
if requested_scope not in {"", "auto", "changed"}:
|
|
4473
|
+
raise APError(
|
|
4474
|
+
"light-gate only runs the changed-scope fast gate. "
|
|
4475
|
+
"Use 'ap.py run gate_standard' or 'ap.py run gate_full' for an explicit diagnostic."
|
|
4476
|
+
)
|
|
3627
4477
|
plan = _resolve_execution_plan(
|
|
3628
4478
|
cfg,
|
|
3629
4479
|
repo,
|
|
3630
|
-
requested_scope=
|
|
4480
|
+
requested_scope=requested_scope,
|
|
3631
4481
|
requested_profile=_text(getattr(args, "profile", "")).lower(),
|
|
3632
4482
|
requested_mode=_text(getattr(args, "mode", "")).lower(),
|
|
3633
4483
|
base_ref=_text(getattr(args, "base", "")),
|
|
@@ -3637,27 +4487,12 @@ def cmd_light_gate(args: argparse.Namespace) -> None:
|
|
|
3637
4487
|
for reason in plan["profile_reasons"]:
|
|
3638
4488
|
print(f"[impact] profile_reason: {reason}")
|
|
3639
4489
|
|
|
3640
|
-
selected_scope =
|
|
4490
|
+
selected_scope = "changed"
|
|
3641
4491
|
paths = list(plan.get("changed_files") or [])
|
|
3642
|
-
|
|
3643
|
-
executed: list[str] = []
|
|
3644
|
-
executed.extend(_run_structure_check_for_gate(repo, cfg, selected_scope, str(getattr(args, "base", "") or "")))
|
|
3645
|
-
|
|
3646
|
-
if selected_scope == "changed":
|
|
3647
|
-
executed.extend(_run_changed_gate(repo, cfg, paths, matching_rules))
|
|
3648
|
-
elif selected_scope == "full":
|
|
3649
|
-
executed.extend(_run_full_gate(repo, cfg))
|
|
3650
|
-
else:
|
|
3651
|
-
executed.extend(_run_standard_gate(repo, cfg))
|
|
4492
|
+
executed = _run_changed_gate(repo, cfg, paths)
|
|
3652
4493
|
|
|
3653
4494
|
_run_git_diff_check(repo, cfg)
|
|
3654
|
-
|
|
3655
|
-
executed.extend(["diff_check", "verify_api_docs"])
|
|
3656
|
-
if _verification_required(cfg, "jenkins", default=True):
|
|
3657
|
-
cmd_verify_jenkins(argparse.Namespace(repo=str(repo)))
|
|
3658
|
-
executed.append("verify_jenkins")
|
|
3659
|
-
else:
|
|
3660
|
-
executed.append("verify_jenkins_skipped")
|
|
4495
|
+
executed.append("diff_check")
|
|
3661
4496
|
duration_s = time.time() - light_gate_start
|
|
3662
4497
|
_record_gate_profile(repo, cfg, "light_gate", "pass", duration_s, scope=selected_scope, detail=", ".join(executed))
|
|
3663
4498
|
_record_evidence(
|
|
@@ -3835,9 +4670,6 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
3835
4670
|
cfg = _load_cfg(repo)
|
|
3836
4671
|
workflow_cfg = (cfg.get("workflow") or {})
|
|
3837
4672
|
project_cfg = (cfg.get("project") or {})
|
|
3838
|
-
commands = (cfg.get("commands") or {})
|
|
3839
|
-
target_cfg = (cfg.get("target_env") or {})
|
|
3840
|
-
jenkins_cfg = (cfg.get("jenkins") or {})
|
|
3841
4673
|
docs_cfg = (cfg.get("docs") or {})
|
|
3842
4674
|
runtime_cfg = (cfg.get("runtime") or {})
|
|
3843
4675
|
structure_cfg = _structure_cfg(cfg)
|
|
@@ -3845,18 +4677,22 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
3845
4677
|
|
|
3846
4678
|
missing: List[str] = []
|
|
3847
4679
|
validation_errors: List[str] = []
|
|
4680
|
+
validation_errors.extend(_workflow_policy_issues(repo, cfg))
|
|
3848
4681
|
|
|
3849
4682
|
mode = str(workflow_cfg.get("mode") or "dev").strip().lower()
|
|
3850
4683
|
profile = str(workflow_cfg.get("profile") or "auto").strip().lower()
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
|
|
3854
|
-
missing.append("workflow.mode (must be dev or verify)")
|
|
4684
|
+
completion = str(workflow_cfg.get("completion") or "").strip().lower()
|
|
4685
|
+
if mode != "dev":
|
|
4686
|
+
missing.append("workflow.mode (must be dev; external verification is owner-managed)")
|
|
3855
4687
|
if profile not in _WORKFLOW_PROFILES:
|
|
3856
4688
|
missing.append("workflow.profile (must be auto, micro, standard, or high-risk)")
|
|
4689
|
+
if completion != "push":
|
|
4690
|
+
missing.append("workflow.completion (must be push)")
|
|
3857
4691
|
isolation = _text(concurrency_cfg.get("isolation")).lower() or "worktree"
|
|
3858
|
-
if isolation
|
|
3859
|
-
validation_errors.append(
|
|
4692
|
+
if isolation != "worktree":
|
|
4693
|
+
validation_errors.append(
|
|
4694
|
+
"concurrency.isolation must be worktree; shared-checkout/legacy writes are no longer supported"
|
|
4695
|
+
)
|
|
3860
4696
|
branch_prefix = _text(concurrency_cfg.get("branch_prefix")) or "codex/"
|
|
3861
4697
|
if not branch_prefix.endswith("/"):
|
|
3862
4698
|
validation_errors.append("concurrency.branch_prefix must end with '/'")
|
|
@@ -3868,10 +4704,13 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
3868
4704
|
validation_errors.append("concurrency.branch_prefix does not form a valid Git branch")
|
|
3869
4705
|
if not str(project_cfg.get("name") or "").strip():
|
|
3870
4706
|
missing.append("project.name")
|
|
4707
|
+
missing.extend(_access_config_issues(cfg))
|
|
3871
4708
|
enforcement = _text(structure_cfg.get("enforcement")).lower()
|
|
3872
4709
|
if enforcement and enforcement not in {"advisory", "blocking"}:
|
|
3873
4710
|
validation_errors.append("structure.enforcement must be advisory or blocking")
|
|
3874
4711
|
gate_cfg = _gate_cfg(cfg)
|
|
4712
|
+
if "full_on" in gate_cfg:
|
|
4713
|
+
validation_errors.append("gate.full_on is legacy automatic full escalation; run ap.py upgrade")
|
|
3875
4714
|
raw_rules = gate_cfg.get("rules") or []
|
|
3876
4715
|
rules_valid = isinstance(raw_rules, list)
|
|
3877
4716
|
if not rules_valid:
|
|
@@ -3889,78 +4728,19 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
3889
4728
|
f"gate.rules[{index}].profile must be micro, standard, or high-risk"
|
|
3890
4729
|
)
|
|
3891
4730
|
rule_scope = _text(rule.get("scope")).lower()
|
|
3892
|
-
if
|
|
4731
|
+
if "scope" in rule:
|
|
3893
4732
|
rules_valid = False
|
|
3894
4733
|
validation_errors.append(
|
|
3895
|
-
f"gate.rules[{index}].scope
|
|
3896
|
-
)
|
|
3897
|
-
|
|
3898
|
-
if mode in {"dev", "verify"} and profile in _WORKFLOW_PROFILES and rules_valid:
|
|
3899
|
-
try:
|
|
3900
|
-
plan = _resolve_execution_plan(
|
|
3901
|
-
cfg,
|
|
3902
|
-
repo,
|
|
3903
|
-
requested_profile=_text(getattr(args, "profile", "")).lower(),
|
|
3904
|
-
requested_mode=_text(getattr(args, "mode", "")).lower(),
|
|
3905
|
-
)
|
|
3906
|
-
except APError as exc:
|
|
3907
|
-
validation_errors.append(str(exc))
|
|
3908
|
-
else:
|
|
3909
|
-
effective_profile = str(plan["profile"])
|
|
3910
|
-
changed_files = list(plan.get("changed_files") or [])
|
|
3911
|
-
matching_rules = _matching_gate_rules(changed_files, gate_cfg)
|
|
3912
|
-
rule_changed_gate = any(
|
|
3913
|
-
any(_configured_command(cfg, _command_name(ref)) for ref in _as_list(rule.get("commands")))
|
|
3914
|
-
for rule in matching_rules
|
|
4734
|
+
f"gate.rules[{index}].scope is legacy automatic gate escalation; run ap.py upgrade"
|
|
3915
4735
|
)
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
or _configured_command(cfg, "build")
|
|
3921
|
-
or rule_changed_gate
|
|
3922
|
-
or _docs_only(changed_files)
|
|
3923
|
-
)
|
|
3924
|
-
standard_gate = bool(
|
|
3925
|
-
_configured_command(cfg, "gate_standard")
|
|
3926
|
-
or _configured_command(cfg, "light_gate")
|
|
3927
|
-
or _configured_command(cfg, "quick_test")
|
|
3928
|
-
or _configured_command(cfg, "test")
|
|
3929
|
-
or _configured_command(cfg, "build")
|
|
3930
|
-
)
|
|
3931
|
-
full_gate = bool(
|
|
3932
|
-
_configured_command(cfg, "gate_full")
|
|
3933
|
-
or _configured_command(cfg, "full_gate")
|
|
4736
|
+
if "commands" in rule:
|
|
4737
|
+
rules_valid = False
|
|
4738
|
+
validation_errors.append(
|
|
4739
|
+
f"gate.rules[{index}].commands is legacy automatic gate escalation; run ap.py upgrade"
|
|
3934
4740
|
)
|
|
3935
|
-
|
|
3936
|
-
|
|
3937
|
-
|
|
3938
|
-
"or a matching gate rule command"
|
|
3939
|
-
)
|
|
3940
|
-
elif effective_profile == "standard" and not standard_gate:
|
|
3941
|
-
missing.append(
|
|
3942
|
-
"standard gate command: commands.gate_standard, light_gate, quick_test, test, or build"
|
|
3943
|
-
)
|
|
3944
|
-
elif effective_profile == "high-risk" and not full_gate:
|
|
3945
|
-
missing.append(
|
|
3946
|
-
"full gate command: commands.gate_full or commands.full_gate "
|
|
3947
|
-
"(required for high-risk/verify execution)"
|
|
3948
|
-
)
|
|
3949
|
-
if target_env_required:
|
|
3950
|
-
_require_explicit_field(missing, "target_env.health_base_url", target_cfg.get("health_base_url"))
|
|
3951
|
-
_require_explicit_field(missing, "target_env.health_path", target_cfg.get("health_path"))
|
|
3952
|
-
|
|
3953
|
-
if jenkins_required:
|
|
3954
|
-
_require_explicit_field(missing, "jenkins.base_url", jenkins_cfg.get("base_url"))
|
|
3955
|
-
_require_explicit_field(missing, "jenkins.ui_username", jenkins_cfg.get("ui_username"))
|
|
3956
|
-
_require_secret_reference(missing, "jenkins", jenkins_cfg, "ui_password")
|
|
3957
|
-
_require_explicit_field(missing, "jenkins.job_url", jenkins_cfg.get("job_url"))
|
|
3958
|
-
_require_explicit_field(missing, "jenkins.trigger_branch", jenkins_cfg.get("trigger_branch"))
|
|
3959
|
-
_require_explicit_field(missing, "jenkins.image_repository", jenkins_cfg.get("image_repository"))
|
|
3960
|
-
_require_explicit_field(missing, "jenkins.image_tag_strategy", jenkins_cfg.get("image_tag_strategy"))
|
|
3961
|
-
_require_explicit_field(missing, "jenkins.deploy_env", jenkins_cfg.get("deploy_env"))
|
|
3962
|
-
_require_explicit_field(missing, "jenkins.api_user", jenkins_cfg.get("api_user"))
|
|
3963
|
-
_require_secret_reference(missing, "jenkins", jenkins_cfg, "api_password")
|
|
4741
|
+
|
|
4742
|
+
if not (_configured_command(cfg, "gate_changed") or _configured_command(cfg, "quick_test")):
|
|
4743
|
+
missing.append("fast gate command: commands.gate_changed or commands.quick_test")
|
|
3964
4744
|
|
|
3965
4745
|
repo_docs = {
|
|
3966
4746
|
"docs.taskbook": Path(repo, str(docs_cfg.get("taskbook", "docs/tasks/taskbook.md"))),
|
|
@@ -3980,33 +4760,10 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
3980
4760
|
if not path.exists():
|
|
3981
4761
|
validation_errors.append(f"{key} missing on disk: {path}")
|
|
3982
4762
|
|
|
3983
|
-
_validate_url_field(validation_errors, "target_env.frontend_base_url", target_cfg.get("frontend_base_url"))
|
|
3984
|
-
_validate_url_field(validation_errors, "target_env.backend_base_url", target_cfg.get("backend_base_url"))
|
|
3985
|
-
_validate_url_field(validation_errors, "target_env.health_base_url", target_cfg.get("health_base_url"))
|
|
3986
|
-
_validate_path_field(validation_errors, "target_env.health_path", target_cfg.get("health_path"))
|
|
3987
|
-
_validate_url_field(validation_errors, "jenkins.base_url", jenkins_cfg.get("base_url"))
|
|
3988
|
-
_validate_url_field(validation_errors, "jenkins.job_url", jenkins_cfg.get("job_url"))
|
|
3989
|
-
|
|
3990
4763
|
runtime_enabled = any(str(runtime_cfg.get(key) or "").strip() for key in ["docker_compose_file", "docker_service", "health_base_url", "health_path"])
|
|
3991
4764
|
if runtime_enabled and not str(runtime_cfg.get("docker_compose_file") or "").strip():
|
|
3992
4765
|
validation_errors.append("runtime config is partially enabled but runtime.docker_compose_file is missing")
|
|
3993
4766
|
|
|
3994
|
-
ledger_result = _docs_ledger_check_result(repo, cfg)
|
|
3995
|
-
ledger_status = "skipped" if not ledger_result.get("enabled", True) else ("fail" if ledger_result.get("blocking") else "pass")
|
|
3996
|
-
_record_evidence(repo, cfg, "docs_ledger_check", ledger_status, ledger_result)
|
|
3997
|
-
for issue in ledger_result.get("blocking") or []:
|
|
3998
|
-
validation_errors.append(f"docs-ledger: {issue}")
|
|
3999
|
-
for warning in ledger_result.get("warnings") or []:
|
|
4000
|
-
print(f"[doctor] WARN docs-ledger: {warning}")
|
|
4001
|
-
|
|
4002
|
-
try:
|
|
4003
|
-
timeout_s = int(jenkins_cfg.get("deploy_timeout_sec") or 0)
|
|
4004
|
-
if (jenkins_required or _is_explicit_fill(jenkins_cfg.get("deploy_timeout_sec"))) and timeout_s <= 0:
|
|
4005
|
-
validation_errors.append("jenkins.deploy_timeout_sec must be a positive integer")
|
|
4006
|
-
except Exception:
|
|
4007
|
-
if jenkins_required or _is_explicit_fill(jenkins_cfg.get("deploy_timeout_sec")):
|
|
4008
|
-
validation_errors.append("jenkins.deploy_timeout_sec must be a positive integer")
|
|
4009
|
-
|
|
4010
4767
|
missing.extend(validation_errors)
|
|
4011
4768
|
|
|
4012
4769
|
if missing:
|
|
@@ -4018,7 +4775,7 @@ def cmd_doctor(args: argparse.Namespace) -> None:
|
|
|
4018
4775
|
cfg,
|
|
4019
4776
|
"doctor",
|
|
4020
4777
|
"pass",
|
|
4021
|
-
{"mode": mode, "
|
|
4778
|
+
{"mode": mode, "completion": completion, "access_fields": len(_REQUIRED_ACCESS_FIELDS)},
|
|
4022
4779
|
)
|
|
4023
4780
|
print("[doctor] OK")
|
|
4024
4781
|
|
|
@@ -4182,9 +4939,7 @@ def _validate_closure_result(effective_mode: str, result: str) -> None:
|
|
|
4182
4939
|
mode = _text(effective_mode).lower()
|
|
4183
4940
|
normalized_result = _text(result).upper()
|
|
4184
4941
|
if mode == "dev" and normalized_result == "PASS":
|
|
4185
|
-
raise APError("
|
|
4186
|
-
if mode == "verify" and normalized_result == "DEV-CLOSED":
|
|
4187
|
-
raise APError("DEV-CLOSED is only valid for dev mode; use PASS, PARTIAL, or FAIL for verify execution.")
|
|
4942
|
+
raise APError("Automatic coding closure uses DEV-CLOSED; owner acceptance is handled after push.")
|
|
4188
4943
|
|
|
4189
4944
|
|
|
4190
4945
|
def _validate_closure_evidence(result: str, verification_items: list[str]) -> None:
|
|
@@ -4241,20 +4996,20 @@ def cmd_record_closure(args: argparse.Namespace) -> None:
|
|
|
4241
4996
|
title = str(args.title or "").strip() or _infer_title(taskbook, task_id)
|
|
4242
4997
|
timestamp = _dt.datetime.now().strftime("%Y-%m-%d %H:%M")
|
|
4243
4998
|
commit_value = _resolve_git_short_sha(repo, args.commit)
|
|
4244
|
-
target_env = str(args.target_env or target_cfg.get("name") or "").strip() or "
|
|
4245
|
-
verification_text = "; ".join(verification_items) if verification_items else "
|
|
4999
|
+
target_env = str(args.target_env or target_cfg.get("name") or "").strip() or "owner-managed acceptance"
|
|
5000
|
+
verification_text = "; ".join(verification_items) if verification_items else "fast gate evidence not recorded"
|
|
4246
5001
|
follow_up = str(args.follow_up or "").strip() or "none"
|
|
4247
|
-
jenkins_build = str(args.jenkins or "").strip() or "
|
|
4248
|
-
structure_check = str(getattr(args, "structure_check", "") or "").strip() or "
|
|
5002
|
+
jenkins_build = str(args.jenkins or "").strip() or "owner-managed after push"
|
|
5003
|
+
structure_check = str(getattr(args, "structure_check", "") or "").strip() or "not part of the fast local gate"
|
|
4249
5004
|
lines = [
|
|
4250
5005
|
f"## {task_id} — {title} — {timestamp}",
|
|
4251
5006
|
f"- Task: {task_id}",
|
|
4252
5007
|
f"- Commit: {commit_value}",
|
|
4253
|
-
f"-
|
|
4254
|
-
f"-
|
|
4255
|
-
f"-
|
|
5008
|
+
f"- Fast Local Gate: {verification_text}",
|
|
5009
|
+
f"- External Build/Deploy: {jenkins_build}",
|
|
5010
|
+
f"- Owner Acceptance: {target_env}",
|
|
4256
5011
|
f"- Effective Profile: {profile}",
|
|
4257
|
-
f"- Structure
|
|
5012
|
+
f"- Optional Structure Diagnostic: {structure_check}",
|
|
4258
5013
|
f"- Result: {args.result}",
|
|
4259
5014
|
f"- Follow-up: {follow_up}",
|
|
4260
5015
|
]
|
|
@@ -5172,8 +5927,22 @@ def _create_active_task_doc(repo: Path, cfg: dict, manifest: dict) -> None:
|
|
|
5172
5927
|
f"- Base: `{manifest['base_ref']}` (`{manifest['base_sha'][:12]}`)",
|
|
5173
5928
|
f"- Target: `{manifest['remote']}/{manifest['target_branch']}`",
|
|
5174
5929
|
f"- Branch: `{manifest['task_branch']}`",
|
|
5930
|
+
f"- Worktree: `{manifest['worktree_path']}`",
|
|
5931
|
+
f"- Orchestrator: {manifest.get('owner') or 'TODO'}",
|
|
5932
|
+
f"- Owning fixer: {(manifest.get('writer_lease') or {}).get('holder') or 'TODO'}",
|
|
5933
|
+
"- Owned paths: " + ", ".join(f"`{item}`" for item in manifest.get("owned_paths") or []),
|
|
5934
|
+
"- Depends on integrated tasks: "
|
|
5935
|
+
+ (
|
|
5936
|
+
", ".join(
|
|
5937
|
+
f"`{item}`@`{(manifest.get('prerequisite_shas') or {}).get(item, '')[:12]}`"
|
|
5938
|
+
for item in manifest.get("depends_on") or []
|
|
5939
|
+
)
|
|
5940
|
+
or "none"
|
|
5941
|
+
),
|
|
5942
|
+
"- Reviewer / stable diff: TODO",
|
|
5943
|
+
"- Review verdict: pending",
|
|
5175
5944
|
"- Scope: TODO",
|
|
5176
|
-
"-
|
|
5945
|
+
"- Development acceptance: TODO",
|
|
5177
5946
|
"",
|
|
5178
5947
|
]
|
|
5179
5948
|
),
|
|
@@ -5218,6 +5987,14 @@ def cmd_task_start(args: argparse.Namespace) -> None:
|
|
|
5218
5987
|
repo = Path(args.repo).resolve()
|
|
5219
5988
|
ensure_git_repo(repo)
|
|
5220
5989
|
cfg = _load_cfg(repo)
|
|
5990
|
+
_require_workflow_policy_clean(repo, cfg)
|
|
5991
|
+
_task_isolation(cfg)
|
|
5992
|
+
access_issues = _access_config_issues(cfg)
|
|
5993
|
+
if access_issues:
|
|
5994
|
+
raise APError(
|
|
5995
|
+
"Project initialization is incomplete; fill docs/ENGINEERING.md before starting work:\n- "
|
|
5996
|
+
+ "\n- ".join(access_issues)
|
|
5997
|
+
)
|
|
5221
5998
|
task_id = _validate_task_id(args.task_id)
|
|
5222
5999
|
_require_control_checkout(repo)
|
|
5223
6000
|
remote, target_branch, base_ref = _task_remote_and_target(cfg, args)
|
|
@@ -5238,6 +6015,30 @@ def cmd_task_start(args: argparse.Namespace) -> None:
|
|
|
5238
6015
|
if not getattr(args, "no_fetch", False) and base_ref.startswith(f"{remote}/"):
|
|
5239
6016
|
_fetch_target(repo, remote, target_branch)
|
|
5240
6017
|
base_sha = _resolve_commit(repo, base_ref)
|
|
6018
|
+
owned_paths = sorted({_normalize_owned_path(item) for item in (args.owned_path or [])})
|
|
6019
|
+
if not owned_paths:
|
|
6020
|
+
raise APError("task-start requires at least one --owned-path.")
|
|
6021
|
+
depends_on: list[str] = []
|
|
6022
|
+
prerequisite_shas: dict[str, str] = {}
|
|
6023
|
+
for raw_dependency in args.depends_on or []:
|
|
6024
|
+
dependency, separator, sha = _text(raw_dependency).partition("=")
|
|
6025
|
+
dependency = _validate_task_id(dependency)
|
|
6026
|
+
if not separator or not re.fullmatch(r"(?:[0-9a-f]{40}|[0-9a-f]{64})", sha):
|
|
6027
|
+
raise APError("--depends-on must use TASK_ID=full_commit_SHA.")
|
|
6028
|
+
if dependency in prerequisite_shas and prerequisite_shas[dependency] != sha:
|
|
6029
|
+
raise APError(f"Conflicting prerequisite SHAs for {dependency}.")
|
|
6030
|
+
depends_on.append(dependency)
|
|
6031
|
+
prerequisite_shas[dependency] = sha
|
|
6032
|
+
depends_on = sorted(set(depends_on))
|
|
6033
|
+
dependency_contract = {
|
|
6034
|
+
"depends_on": depends_on,
|
|
6035
|
+
"prerequisite_shas": prerequisite_shas,
|
|
6036
|
+
}
|
|
6037
|
+
_require_dependencies(repo, dependency_contract, base_sha)
|
|
6038
|
+
owner = _text(getattr(args, "owner", "")) or _text(os.environ.get("CODEX_THREAD_ID"))
|
|
6039
|
+
if not owner:
|
|
6040
|
+
raise APError("task-start requires --owner or CODEX_THREAD_ID.")
|
|
6041
|
+
writer = _text(getattr(args, "writer", "")) or owner
|
|
5241
6042
|
prefix = _task_branch_prefix(cfg)
|
|
5242
6043
|
task_branch = f"{prefix}{task_id}"
|
|
5243
6044
|
check_ref = run(["git", "check-ref-format", "--branch", task_branch], cwd=repo, check=False)
|
|
@@ -5267,10 +6068,10 @@ def cmd_task_start(args: argparse.Namespace) -> None:
|
|
|
5267
6068
|
cwd=repo,
|
|
5268
6069
|
)
|
|
5269
6070
|
manifest = {
|
|
5270
|
-
"schema":
|
|
6071
|
+
"schema": 2,
|
|
5271
6072
|
"task_id": task_id,
|
|
5272
6073
|
"task_uuid": task_uuid,
|
|
5273
|
-
"owner":
|
|
6074
|
+
"owner": owner,
|
|
5274
6075
|
"base_ref": base_ref,
|
|
5275
6076
|
"base_sha": base_sha,
|
|
5276
6077
|
"remote": remote,
|
|
@@ -5282,6 +6083,24 @@ def cmd_task_start(args: argparse.Namespace) -> None:
|
|
|
5282
6083
|
"state": "active",
|
|
5283
6084
|
"created_at": _now_iso(),
|
|
5284
6085
|
"initial_untracked": [],
|
|
6086
|
+
"owned_paths": owned_paths,
|
|
6087
|
+
"depends_on": depends_on,
|
|
6088
|
+
"prerequisite_shas": prerequisite_shas,
|
|
6089
|
+
"writer_lease": {
|
|
6090
|
+
"holder": writer,
|
|
6091
|
+
"generation": 1,
|
|
6092
|
+
"state": "active",
|
|
6093
|
+
"acquired_at": _now_iso(),
|
|
6094
|
+
},
|
|
6095
|
+
"review": {
|
|
6096
|
+
"verdict": "pending",
|
|
6097
|
+
"diff_base": base_sha,
|
|
6098
|
+
"diff_head": "",
|
|
6099
|
+
"diff_fingerprint": "",
|
|
6100
|
+
"reviewer": "",
|
|
6101
|
+
"reviewed_at": "",
|
|
6102
|
+
"reason": "task started",
|
|
6103
|
+
},
|
|
5285
6104
|
"claimed_paths": [],
|
|
5286
6105
|
"remote_task_tip": "",
|
|
5287
6106
|
"common_submodule_config": common_submodule_config,
|
|
@@ -5350,6 +6169,9 @@ def _task_status_payload(repo: Path, manifest: dict) -> dict:
|
|
|
5350
6169
|
"local_branch_exists": bool(tip),
|
|
5351
6170
|
"tip": tip,
|
|
5352
6171
|
"merged_into_target": merged,
|
|
6172
|
+
"current_diff_fingerprint": _task_review_fingerprint(worktree, manifest)
|
|
6173
|
+
if worktree.exists()
|
|
6174
|
+
else "",
|
|
5353
6175
|
}
|
|
5354
6176
|
|
|
5355
6177
|
|
|
@@ -5381,6 +6203,138 @@ def cmd_task_status(args: argparse.Namespace) -> None:
|
|
|
5381
6203
|
)
|
|
5382
6204
|
|
|
5383
6205
|
|
|
6206
|
+
def _task_lifecycle_context(repo: Path, cfg: dict, task_id: str) -> tuple[Path, Path, dict]:
|
|
6207
|
+
active = _active_task_manifest(repo)
|
|
6208
|
+
if active:
|
|
6209
|
+
manifest = _require_task_context(repo, cfg, task_id)
|
|
6210
|
+
return Path(_text(manifest.get("control_worktree_path"))).resolve(), repo, manifest
|
|
6211
|
+
manifest = _load_task_manifest(repo, task_id)
|
|
6212
|
+
_require_control_checkout(repo, manifest)
|
|
6213
|
+
return repo, Path(_text(manifest.get("worktree_path"))).resolve(), manifest
|
|
6214
|
+
|
|
6215
|
+
|
|
6216
|
+
def cmd_task_review(args: argparse.Namespace) -> None:
|
|
6217
|
+
repo = Path(args.repo).resolve()
|
|
6218
|
+
ensure_git_repo(repo)
|
|
6219
|
+
cfg = _load_cfg(repo)
|
|
6220
|
+
task_id = _validate_task_id(args.task_id)
|
|
6221
|
+
control_repo, worktree, _ = _task_lifecycle_context(repo, cfg, task_id)
|
|
6222
|
+
timeout_s = float(_concurrency_cfg(cfg).get("lock_timeout_sec") or 30)
|
|
6223
|
+
with _repo_lock(control_repo, f"task-{task_id}", timeout_s=timeout_s):
|
|
6224
|
+
manifest = _load_task_manifest(control_repo, task_id)
|
|
6225
|
+
lifecycle_actor = _text(os.environ.get("CODEX_THREAD_ID"))
|
|
6226
|
+
if not lifecycle_actor or lifecycle_actor != _text(manifest.get("owner")):
|
|
6227
|
+
raise APError("Only the task lifecycle owner may record a review verdict.")
|
|
6228
|
+
if _text(manifest.get("state")) not in {"active", "pushed", "integration-raced"}:
|
|
6229
|
+
raise APError(f"Task {task_id} is not reviewable in state={manifest.get('state')}.")
|
|
6230
|
+
if not worktree.exists():
|
|
6231
|
+
raise APError(f"Task worktree is missing: {worktree}")
|
|
6232
|
+
worktree_cfg = _load_cfg(worktree)
|
|
6233
|
+
unowned = _task_unowned_paths(worktree, worktree_cfg, manifest)
|
|
6234
|
+
if unowned:
|
|
6235
|
+
raise APError("Changes outside task owned_paths:\n- " + "\n- ".join(unowned))
|
|
6236
|
+
fingerprint = _task_review_fingerprint(worktree, manifest)
|
|
6237
|
+
supplied = _text(args.diff_fingerprint)
|
|
6238
|
+
if supplied != fingerprint:
|
|
6239
|
+
raise APError(
|
|
6240
|
+
f"Review fingerprint mismatch: supplied={supplied or '(missing)'}, current={fingerprint}."
|
|
6241
|
+
)
|
|
6242
|
+
reviewer = _text(getattr(args, "reviewer", "")) or _text(os.environ.get("CODEX_THREAD_ID"))
|
|
6243
|
+
if not reviewer:
|
|
6244
|
+
raise APError("task-review requires --reviewer or CODEX_THREAD_ID.")
|
|
6245
|
+
manifest["review"] = {
|
|
6246
|
+
"verdict": args.verdict,
|
|
6247
|
+
"diff_base": _text(manifest.get("base_sha")),
|
|
6248
|
+
"diff_head": _resolve_commit(worktree, "HEAD"),
|
|
6249
|
+
"diff_fingerprint": fingerprint,
|
|
6250
|
+
"reviewer": reviewer,
|
|
6251
|
+
"reviewed_at": _now_iso(),
|
|
6252
|
+
"reason": "",
|
|
6253
|
+
}
|
|
6254
|
+
_save_task_manifest(control_repo, manifest)
|
|
6255
|
+
print(f"[task-review] task={task_id} verdict={args.verdict} fingerprint={fingerprint}")
|
|
6256
|
+
|
|
6257
|
+
|
|
6258
|
+
def cmd_task_handoff(args: argparse.Namespace) -> None:
|
|
6259
|
+
repo = Path(args.repo).resolve()
|
|
6260
|
+
ensure_git_repo(repo)
|
|
6261
|
+
cfg = _load_cfg(repo)
|
|
6262
|
+
task_id = _validate_task_id(args.task_id)
|
|
6263
|
+
control_repo, _, _ = _task_lifecycle_context(repo, cfg, task_id)
|
|
6264
|
+
actor = _text(os.environ.get("CODEX_THREAD_ID"))
|
|
6265
|
+
if not actor:
|
|
6266
|
+
raise APError("task-handoff requires CODEX_THREAD_ID for the current writer.")
|
|
6267
|
+
timeout_s = float(_concurrency_cfg(cfg).get("lock_timeout_sec") or 30)
|
|
6268
|
+
with _repo_lock(control_repo, f"task-{task_id}", timeout_s=timeout_s):
|
|
6269
|
+
manifest = _load_task_manifest(control_repo, task_id)
|
|
6270
|
+
if _text(manifest.get("state")) in {"integrated", "cleanup-pending"}:
|
|
6271
|
+
raise APError(f"Task {task_id} no longer accepts writer handoff.")
|
|
6272
|
+
lease = manifest.get("writer_lease") or {}
|
|
6273
|
+
generation = int(lease.get("generation") or 0)
|
|
6274
|
+
if _text(lease.get("holder")) != args.from_writer:
|
|
6275
|
+
raise APError("--from must match the current writer lease holder.")
|
|
6276
|
+
if actor not in {args.from_writer, _text(manifest.get("owner"))}:
|
|
6277
|
+
raise APError("Only the current writer or task lifecycle owner may hand off the task.")
|
|
6278
|
+
if args.generation is not None and args.generation != generation:
|
|
6279
|
+
raise APError(f"Writer lease generation changed: expected={args.generation}, current={generation}.")
|
|
6280
|
+
lease.update(
|
|
6281
|
+
{
|
|
6282
|
+
"holder": args.to_writer,
|
|
6283
|
+
"generation": generation + 1,
|
|
6284
|
+
"state": "active",
|
|
6285
|
+
"acquired_at": _now_iso(),
|
|
6286
|
+
}
|
|
6287
|
+
)
|
|
6288
|
+
manifest["writer_lease"] = lease
|
|
6289
|
+
_save_task_manifest(control_repo, manifest)
|
|
6290
|
+
print(f"[task-handoff] task={task_id} writer={args.to_writer} generation={generation + 1}")
|
|
6291
|
+
|
|
6292
|
+
|
|
6293
|
+
def cmd_task_resume(args: argparse.Namespace) -> None:
|
|
6294
|
+
repo = Path(args.repo).resolve()
|
|
6295
|
+
ensure_git_repo(repo)
|
|
6296
|
+
cfg = _load_cfg(repo)
|
|
6297
|
+
task_id = _validate_task_id(args.task_id)
|
|
6298
|
+
manifest = _load_task_manifest(repo, task_id)
|
|
6299
|
+
_require_control_checkout(repo, manifest)
|
|
6300
|
+
_require_current_writer(manifest, args)
|
|
6301
|
+
worktree = Path(_text(manifest.get("worktree_path"))).resolve()
|
|
6302
|
+
timeout_s = float(_concurrency_cfg(cfg).get("lock_timeout_sec") or 30)
|
|
6303
|
+
with (
|
|
6304
|
+
_repo_lock(repo, "integration", timeout_s=timeout_s),
|
|
6305
|
+
_repo_lock(repo, f"task-{task_id}", timeout_s=timeout_s),
|
|
6306
|
+
):
|
|
6307
|
+
manifest = _load_task_manifest(repo, task_id)
|
|
6308
|
+
_require_current_writer(manifest, args)
|
|
6309
|
+
if _text(manifest.get("state")) != "conflicted":
|
|
6310
|
+
raise APError(f"Task {task_id} is not awaiting conflict resume.")
|
|
6311
|
+
for marker in ("rebase-merge", "rebase-apply"):
|
|
6312
|
+
path = Path(run(["git", "rev-parse", "--git-path", marker], cwd=worktree).stdout.strip())
|
|
6313
|
+
if not path.is_absolute():
|
|
6314
|
+
path = worktree / path
|
|
6315
|
+
if path.exists():
|
|
6316
|
+
raise APError("Rebase is still in progress; resolve conflicts and run git rebase --continue first.")
|
|
6317
|
+
if _git_status(worktree):
|
|
6318
|
+
raise APError("Task worktree must be clean before task-resume.")
|
|
6319
|
+
target_sha = _text(manifest.get("rebase_target_sha"))
|
|
6320
|
+
if not target_sha or run(
|
|
6321
|
+
["git", "merge-base", "--is-ancestor", target_sha, "HEAD"],
|
|
6322
|
+
cwd=worktree,
|
|
6323
|
+
check=False,
|
|
6324
|
+
).returncode != 0:
|
|
6325
|
+
raise APError("Resolved task HEAD does not contain the recorded rebase target.")
|
|
6326
|
+
manifest["base_sha"] = target_sha
|
|
6327
|
+
manifest["base_ref"] = target_sha
|
|
6328
|
+
unowned = _task_unowned_paths(worktree, _load_cfg(worktree), manifest)
|
|
6329
|
+
if unowned:
|
|
6330
|
+
raise APError("Resolved rebase changed paths outside owned_paths:\n- " + "\n- ".join(unowned))
|
|
6331
|
+
_invalidate_task_review(manifest, "rebase conflict resolved; review again")
|
|
6332
|
+
manifest["state"] = "active"
|
|
6333
|
+
_save_task_manifest(repo, manifest)
|
|
6334
|
+
_push_current_task(worktree, manifest)
|
|
6335
|
+
print(f"[task-resume] task={task_id} state=pushed review=pending")
|
|
6336
|
+
|
|
6337
|
+
|
|
5384
6338
|
def cmd_task_submodule_sync(args: argparse.Namespace) -> None:
|
|
5385
6339
|
repo = Path(args.repo).resolve()
|
|
5386
6340
|
ensure_git_repo(repo)
|
|
@@ -5593,18 +6547,6 @@ def cmd_task_finish(args: argparse.Namespace) -> None:
|
|
|
5593
6547
|
)
|
|
5594
6548
|
|
|
5595
6549
|
|
|
5596
|
-
def _append_integration_closure(repo: Path, cfg: dict, manifest: dict, target_sha: str) -> None:
|
|
5597
|
-
path = _task_doc_path(repo, cfg, manifest, "closure")
|
|
5598
|
-
path.parent.mkdir(parents=True, exist_ok=True)
|
|
5599
|
-
if not path.exists():
|
|
5600
|
-
path.write_text(f"# Task Closure — {manifest['task_id']}\n", encoding="utf-8")
|
|
5601
|
-
with path.open("a", encoding="utf-8") as handle:
|
|
5602
|
-
handle.write("\n## Integration\n")
|
|
5603
|
-
handle.write(f"- Target: `{manifest['remote']}/{manifest['target_branch']}`\n")
|
|
5604
|
-
handle.write(f"- Base: `{target_sha}`\n")
|
|
5605
|
-
handle.write("- Gate: passed after rebase\n")
|
|
5606
|
-
|
|
5607
|
-
|
|
5608
6550
|
def cmd_task_integrate(args: argparse.Namespace) -> None:
|
|
5609
6551
|
repo = Path(args.repo).resolve()
|
|
5610
6552
|
ensure_git_repo(repo)
|
|
@@ -5612,6 +6554,7 @@ def cmd_task_integrate(args: argparse.Namespace) -> None:
|
|
|
5612
6554
|
task_id = _validate_task_id(args.task_id)
|
|
5613
6555
|
manifest = _load_task_manifest(repo, task_id)
|
|
5614
6556
|
_require_control_checkout(repo, manifest)
|
|
6557
|
+
_require_current_writer(manifest, args)
|
|
5615
6558
|
worktree = Path(_text(manifest.get("worktree_path")))
|
|
5616
6559
|
if repo.resolve() == worktree.resolve():
|
|
5617
6560
|
raise APError("Run task-integrate from the primary/control checkout, not from the task worktree.")
|
|
@@ -5622,6 +6565,7 @@ def cmd_task_integrate(args: argparse.Namespace) -> None:
|
|
|
5622
6565
|
_repo_lock(repo, f"task-{task_id}", timeout_s=timeout_s),
|
|
5623
6566
|
):
|
|
5624
6567
|
manifest = _load_task_manifest(repo, task_id)
|
|
6568
|
+
_require_current_writer(manifest, args)
|
|
5625
6569
|
worktree = Path(_text(manifest.get("worktree_path")))
|
|
5626
6570
|
if not worktree.exists():
|
|
5627
6571
|
raise APError(f"Task worktree is missing: {worktree}")
|
|
@@ -5636,7 +6580,7 @@ def cmd_task_integrate(args: argparse.Namespace) -> None:
|
|
|
5636
6580
|
check_common=True,
|
|
5637
6581
|
)
|
|
5638
6582
|
_save_task_manifest(repo, manifest)
|
|
5639
|
-
if _text(manifest.get("state")) not in {"pushed", "integration-raced"
|
|
6583
|
+
if _text(manifest.get("state")) not in {"pushed", "integration-raced"}:
|
|
5640
6584
|
raise APError(f"Task {task_id} must be committed and pushed before integration.")
|
|
5641
6585
|
dirty = _git_status(worktree)
|
|
5642
6586
|
if dirty:
|
|
@@ -5646,14 +6590,33 @@ def cmd_task_integrate(args: argparse.Namespace) -> None:
|
|
|
5646
6590
|
target = _text(manifest.get("target_branch"))
|
|
5647
6591
|
task_cfg = _load_cfg(worktree)
|
|
5648
6592
|
target_sha = _fetch_target(worktree, remote, target)
|
|
5649
|
-
|
|
5650
|
-
|
|
6593
|
+
_require_dependencies(worktree, manifest, target_sha)
|
|
6594
|
+
_require_approved_review(worktree, task_cfg, manifest)
|
|
6595
|
+
if target_sha == _text(manifest.get("base_sha")):
|
|
6596
|
+
rebase = None
|
|
6597
|
+
else:
|
|
6598
|
+
rebase = run(["git", "rebase", target_sha], cwd=worktree, check=False)
|
|
6599
|
+
if rebase is not None and rebase.returncode != 0:
|
|
5651
6600
|
manifest["state"] = "conflicted"
|
|
6601
|
+
manifest["rebase_target_sha"] = target_sha
|
|
6602
|
+
_invalidate_task_review(manifest, "integration rebase conflicted")
|
|
5652
6603
|
_save_task_manifest(repo, manifest)
|
|
5653
6604
|
raise APError(
|
|
5654
6605
|
f"Task integration rebase conflicted for {task_id}; resolve it only in {worktree}.\n"
|
|
5655
6606
|
f"{rebase.stdout}\n{rebase.stderr}"
|
|
5656
6607
|
)
|
|
6608
|
+
if rebase is not None:
|
|
6609
|
+
manifest["base_sha"] = target_sha
|
|
6610
|
+
manifest["base_ref"] = target_sha
|
|
6611
|
+
manifest["rebase_target_sha"] = ""
|
|
6612
|
+
_invalidate_task_review(manifest, "target changed and task was rebased; review again")
|
|
6613
|
+
manifest["state"] = "active"
|
|
6614
|
+
_save_task_manifest(repo, manifest)
|
|
6615
|
+
_push_current_task(worktree, manifest)
|
|
6616
|
+
raise APError(
|
|
6617
|
+
f"Task {task_id} was rebased onto {target_sha}; the task backup branch was updated. "
|
|
6618
|
+
"Run task-review again before final integration."
|
|
6619
|
+
)
|
|
5657
6620
|
|
|
5658
6621
|
_sync_task_submodule_config(
|
|
5659
6622
|
repo,
|
|
@@ -5664,60 +6627,12 @@ def cmd_task_integrate(args: argparse.Namespace) -> None:
|
|
|
5664
6627
|
)
|
|
5665
6628
|
_save_task_manifest(repo, manifest)
|
|
5666
6629
|
|
|
5667
|
-
before_gate = _task_content_fingerprint(worktree, task_cfg, manifest)
|
|
5668
|
-
try:
|
|
5669
|
-
cmd_light_gate(
|
|
5670
|
-
argparse.Namespace(
|
|
5671
|
-
repo=str(worktree),
|
|
5672
|
-
scope="auto",
|
|
5673
|
-
profile="",
|
|
5674
|
-
mode="",
|
|
5675
|
-
base=target_sha,
|
|
5676
|
-
explain=False,
|
|
5677
|
-
)
|
|
5678
|
-
)
|
|
5679
|
-
except APError:
|
|
5680
|
-
manifest["state"] = "gate-failed"
|
|
5681
|
-
_save_task_manifest(repo, manifest)
|
|
5682
|
-
raise
|
|
5683
|
-
after_gate = _task_content_fingerprint(worktree, task_cfg, manifest)
|
|
5684
|
-
if after_gate != before_gate:
|
|
5685
|
-
manifest["state"] = "gate-mutated"
|
|
5686
|
-
_save_task_manifest(repo, manifest)
|
|
5687
|
-
raise APError(
|
|
5688
|
-
"Integration gate changed task-owned files. Review those changes, run commit-push again, "
|
|
5689
|
-
"then retry integration."
|
|
5690
|
-
)
|
|
5691
|
-
manifest = _require_task_context(worktree, task_cfg, task_id) or manifest
|
|
5692
|
-
|
|
5693
|
-
_append_integration_closure(worktree, task_cfg, manifest, target_sha)
|
|
5694
|
-
_update_active_task_status(worktree, task_cfg, manifest, "Integrated")
|
|
5695
|
-
protected = set(manifest.get("initial_untracked") or [])
|
|
5696
|
-
_cleanup_generated_noise(worktree, protected_paths=protected)
|
|
5697
|
-
integration_fingerprint = _task_content_fingerprint(worktree, task_cfg, manifest)
|
|
5698
6630
|
manifest = _require_task_context(worktree, task_cfg, task_id) or manifest
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
task_tip = ""
|
|
5703
|
-
if integration_paths:
|
|
5704
|
-
staged = _stage_exact_paths(worktree, integration_paths)
|
|
5705
|
-
if staged:
|
|
5706
|
-
unstaged = _unstaged_task_paths(worktree)
|
|
5707
|
-
if unstaged:
|
|
5708
|
-
raise APError(
|
|
5709
|
-
"Task-owned files changed while staging integration evidence:\n- "
|
|
5710
|
-
+ "\n- ".join(unstaged)
|
|
5711
|
-
)
|
|
5712
|
-
manifest = _require_task_context(worktree, task_cfg, task_id) or manifest
|
|
5713
|
-
task_tip = _commit_exact_index(
|
|
5714
|
-
worktree,
|
|
5715
|
-
f"{task_id}: record integration evidence [skip ci]",
|
|
5716
|
-
)
|
|
5717
|
-
|
|
5718
|
-
task_tip = task_tip or _resolve_commit(worktree, "HEAD")
|
|
6631
|
+
_require_current_writer(manifest, args)
|
|
6632
|
+
_require_approved_review(worktree, task_cfg, manifest)
|
|
6633
|
+
task_tip = _resolve_commit(worktree, "HEAD")
|
|
5719
6634
|
if _resolve_commit(worktree, "HEAD") != task_tip:
|
|
5720
|
-
raise APError("HEAD moved
|
|
6635
|
+
raise APError("HEAD moved before the target push; refusing to push.")
|
|
5721
6636
|
if run(
|
|
5722
6637
|
["git", "merge-base", "--is-ancestor", target_sha, task_tip],
|
|
5723
6638
|
cwd=worktree,
|
|
@@ -5740,8 +6655,8 @@ def cmd_task_integrate(args: argparse.Namespace) -> None:
|
|
|
5740
6655
|
manifest["integration_tip"] = task_tip
|
|
5741
6656
|
_save_task_manifest(repo, manifest)
|
|
5742
6657
|
raise APError(
|
|
5743
|
-
f"Target branch moved while integrating {task_id}. Re-run task-integrate to fetch
|
|
5744
|
-
f"
|
|
6658
|
+
f"Target branch moved while integrating {task_id}. Re-run task-integrate to fetch and "
|
|
6659
|
+
f"rebase the new target.\n{push.stdout}\n{push.stderr}"
|
|
5745
6660
|
)
|
|
5746
6661
|
|
|
5747
6662
|
fresh_target = _fetch_target(worktree, remote, target)
|
|
@@ -5952,43 +6867,48 @@ def _commit_exact_index(repo: Path, message: str) -> str:
|
|
|
5952
6867
|
return commit_sha
|
|
5953
6868
|
|
|
5954
6869
|
|
|
5955
|
-
def _push_current_task(repo: Path, manifest:
|
|
6870
|
+
def _push_current_task(repo: Path, manifest: dict, expected_commit: str = "") -> str:
|
|
5956
6871
|
commit_sha = expected_commit or _resolve_commit(repo, "HEAD")
|
|
5957
6872
|
if _resolve_commit(repo, "HEAD") != commit_sha:
|
|
5958
6873
|
raise APError("HEAD moved after the verified commit; refusing to push.")
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
|
|
5973
|
-
"No force push was attempted."
|
|
5974
|
-
)
|
|
5975
|
-
command.append(f"--force-with-lease=refs/heads/{task_branch}:{expected_tip}")
|
|
5976
|
-
command.extend([remote, f"{commit_sha}:refs/heads/{task_branch}"])
|
|
5977
|
-
run(command, cwd=repo)
|
|
5978
|
-
if _resolve_commit(repo, "HEAD") != commit_sha:
|
|
5979
|
-
raise APError("A push hook changed HEAD. The verified task commit was pushed, but local state needs review.")
|
|
5980
|
-
pushed_tip = _remote_branch_tip(repo, remote, task_branch)
|
|
5981
|
-
if pushed_tip != commit_sha:
|
|
6874
|
+
remote = _text(manifest.get("remote")) or "origin"
|
|
6875
|
+
task_branch = _text(manifest.get("task_branch"))
|
|
6876
|
+
remote_tip = _remote_branch_tip(repo, remote, task_branch)
|
|
6877
|
+
command = ["git", "push", "--set-upstream"]
|
|
6878
|
+
# This is an internal backup branch, not the final project push. The
|
|
6879
|
+
# configured pre-push hook runs once later for the target-branch push.
|
|
6880
|
+
command.append("--no-verify")
|
|
6881
|
+
if remote_tip and run(
|
|
6882
|
+
["git", "merge-base", "--is-ancestor", remote_tip, "HEAD"],
|
|
6883
|
+
cwd=repo,
|
|
6884
|
+
check=False,
|
|
6885
|
+
).returncode != 0:
|
|
6886
|
+
expected_tip = _text(manifest.get("remote_task_tip"))
|
|
6887
|
+
if not expected_tip or expected_tip != remote_tip:
|
|
5982
6888
|
raise APError(
|
|
5983
|
-
f"Remote task branch
|
|
6889
|
+
f"Remote task branch moved unexpectedly: {remote}/{task_branch}. "
|
|
6890
|
+
"No force push was attempted."
|
|
5984
6891
|
)
|
|
5985
|
-
|
|
5986
|
-
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
6892
|
+
command.append(f"--force-with-lease=refs/heads/{task_branch}:{expected_tip}")
|
|
6893
|
+
command.extend([remote, f"{commit_sha}:refs/heads/{task_branch}"])
|
|
6894
|
+
run(command, cwd=repo)
|
|
6895
|
+
if _resolve_commit(repo, "HEAD") != commit_sha:
|
|
6896
|
+
raise APError("A push hook changed HEAD. The verified task commit was pushed, but local state needs review.")
|
|
6897
|
+
pushed_tip = _remote_branch_tip(repo, remote, task_branch)
|
|
6898
|
+
if pushed_tip != commit_sha:
|
|
6899
|
+
raise APError(
|
|
6900
|
+
f"Remote task branch verification failed: expected {commit_sha}, got {pushed_tip or '(missing)'}."
|
|
6901
|
+
)
|
|
6902
|
+
manifest["state"] = "pushed"
|
|
6903
|
+
manifest["remote_task_tip"] = commit_sha
|
|
6904
|
+
manifest["last_commit"] = commit_sha
|
|
6905
|
+
manifest["claimed_paths"] = _changed_files(repo, _text(manifest.get("base_sha")))
|
|
6906
|
+
review = manifest.get("review") or {}
|
|
6907
|
+
if _text(review.get("verdict")) == "approved":
|
|
6908
|
+
review["diff_head"] = commit_sha
|
|
6909
|
+
review["diff_fingerprint"] = _task_review_fingerprint(repo, manifest)
|
|
6910
|
+
manifest["review"] = review
|
|
6911
|
+
_save_task_manifest(repo, manifest)
|
|
5992
6912
|
return commit_sha
|
|
5993
6913
|
|
|
5994
6914
|
|
|
@@ -5996,18 +6916,20 @@ def _cmd_commit_push_locked(
|
|
|
5996
6916
|
args: argparse.Namespace,
|
|
5997
6917
|
repo: Path,
|
|
5998
6918
|
cfg: dict,
|
|
5999
|
-
manifest:
|
|
6919
|
+
manifest: dict,
|
|
6000
6920
|
) -> None:
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6921
|
+
control_repo = Path(_text(manifest.get("control_worktree_path"))).resolve()
|
|
6922
|
+
_sync_task_submodule_config(
|
|
6923
|
+
control_repo,
|
|
6924
|
+
repo,
|
|
6925
|
+
manifest,
|
|
6926
|
+
initial=False,
|
|
6927
|
+
check_common=False,
|
|
6928
|
+
)
|
|
6929
|
+
_save_task_manifest(repo, manifest)
|
|
6930
|
+
_require_current_writer(manifest, args)
|
|
6931
|
+
_require_dependencies(repo, manifest, _text(manifest.get("base_sha")))
|
|
6932
|
+
_require_approved_review(repo, cfg, manifest)
|
|
6011
6933
|
cmd_doctor(
|
|
6012
6934
|
argparse.Namespace(
|
|
6013
6935
|
repo=str(repo),
|
|
@@ -6015,7 +6937,7 @@ def _cmd_commit_push_locked(
|
|
|
6015
6937
|
mode=_text(getattr(args, "mode", "")).lower(),
|
|
6016
6938
|
)
|
|
6017
6939
|
)
|
|
6018
|
-
base_ref = _text(manifest.get("base_sha"))
|
|
6940
|
+
base_ref = _text(manifest.get("base_sha"))
|
|
6019
6941
|
plan = _resolve_execution_plan(
|
|
6020
6942
|
cfg,
|
|
6021
6943
|
repo,
|
|
@@ -6028,29 +6950,21 @@ def _cmd_commit_push_locked(
|
|
|
6028
6950
|
args.effective_profile = str(plan["profile"])
|
|
6029
6951
|
if args.result:
|
|
6030
6952
|
_validate_closure_result(mode, str(args.result))
|
|
6031
|
-
target_cfg = (cfg.get("target_env") or {})
|
|
6032
|
-
target_env_required = _verification_required(cfg, "target_env", default=True)
|
|
6033
|
-
jenkins_required = _verification_required(cfg, "jenkins", default=True)
|
|
6034
6953
|
|
|
6035
6954
|
msg = args.msg
|
|
6036
|
-
structure_check_status = "
|
|
6037
|
-
|
|
6038
|
-
if args.require_runtime_health:
|
|
6039
|
-
cmd_wait_health(argparse.Namespace(repo=str(repo), scope="runtime"))
|
|
6955
|
+
structure_check_status = "not part of the fast local gate"
|
|
6040
6956
|
|
|
6041
6957
|
before_gate = _task_content_fingerprint(repo, cfg, manifest)
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
explain=False,
|
|
6051
|
-
)
|
|
6958
|
+
cmd_light_gate(
|
|
6959
|
+
argparse.Namespace(
|
|
6960
|
+
repo=str(repo),
|
|
6961
|
+
scope="changed",
|
|
6962
|
+
profile=plan["profile"],
|
|
6963
|
+
mode="dev",
|
|
6964
|
+
base=base_ref,
|
|
6965
|
+
explain=False,
|
|
6052
6966
|
)
|
|
6053
|
-
|
|
6967
|
+
)
|
|
6054
6968
|
|
|
6055
6969
|
after_gate = _task_content_fingerprint(repo, cfg, manifest)
|
|
6056
6970
|
if after_gate != before_gate:
|
|
@@ -6058,14 +6972,9 @@ def _cmd_commit_push_locked(
|
|
|
6058
6972
|
"The gate changed task-owned files or another writer modified this worktree. "
|
|
6059
6973
|
"Review the changes and rerun commit-push; no files were staged or restored."
|
|
6060
6974
|
)
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
if args.require_jenkins:
|
|
6065
|
-
cmd_verify_jenkins(argparse.Namespace(repo=str(repo)))
|
|
6066
|
-
|
|
6067
|
-
if args.require_matrix and mode != "verify":
|
|
6068
|
-
cmd_check_matrix(argparse.Namespace(repo=str(repo)))
|
|
6975
|
+
manifest = _require_task_context(repo, cfg, args.task_id)
|
|
6976
|
+
_require_current_writer(manifest, args)
|
|
6977
|
+
_require_approved_review(repo, cfg, manifest)
|
|
6069
6978
|
|
|
6070
6979
|
if _task_content_fingerprint(repo, cfg, manifest) != after_gate:
|
|
6071
6980
|
raise APError(
|
|
@@ -6073,30 +6982,28 @@ def _cmd_commit_push_locked(
|
|
|
6073
6982
|
"no files were staged or restored."
|
|
6074
6983
|
)
|
|
6075
6984
|
|
|
6076
|
-
|
|
6077
|
-
|
|
6078
|
-
|
|
6079
|
-
|
|
6080
|
-
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
structure_check=args.structure_check or structure_check_status,
|
|
6092
|
-
)
|
|
6985
|
+
dev_verification = args.verification or [
|
|
6986
|
+
"fast changed-scope gate passed",
|
|
6987
|
+
"project commit/push hooks remain enabled",
|
|
6988
|
+
]
|
|
6989
|
+
_record_commit_push_closure(
|
|
6990
|
+
repo,
|
|
6991
|
+
args,
|
|
6992
|
+
commit="generated by this commit-push run",
|
|
6993
|
+
jenkins="owner-managed after push",
|
|
6994
|
+
target_env="owner-managed acceptance",
|
|
6995
|
+
verification=dev_verification,
|
|
6996
|
+
result=args.result or "DEV-CLOSED",
|
|
6997
|
+
follow_up=args.follow_up or "Complete the push stage with task-integrate; do not wait for Jenkins.",
|
|
6998
|
+
structure_check=args.structure_check or structure_check_status,
|
|
6999
|
+
)
|
|
6093
7000
|
|
|
6094
|
-
protected = set(manifest.get("initial_untracked") or [])
|
|
6095
|
-
|
|
6096
|
-
_cleanup_generated_noise(repo, protected_paths=protected)
|
|
7001
|
+
protected = set(manifest.get("initial_untracked") or [])
|
|
7002
|
+
_cleanup_generated_noise(repo, protected_paths=protected)
|
|
6097
7003
|
pre_stage_fingerprint = _task_content_fingerprint(repo, cfg, manifest)
|
|
6098
|
-
|
|
6099
|
-
|
|
7004
|
+
manifest = _require_task_context(repo, cfg, args.task_id)
|
|
7005
|
+
_require_current_writer(manifest, args)
|
|
7006
|
+
_require_approved_review(repo, cfg, manifest)
|
|
6100
7007
|
if _task_content_fingerprint(repo, cfg, manifest) != pre_stage_fingerprint:
|
|
6101
7008
|
raise APError("Task-owned files changed immediately before staging; refusing to commit.")
|
|
6102
7009
|
task_paths = _task_commit_paths(repo)
|
|
@@ -6108,107 +7015,10 @@ def _cmd_commit_push_locked(
|
|
|
6108
7015
|
raise APError(
|
|
6109
7016
|
"Task-owned files changed while staging; refusing to commit:\n- " + "\n- ".join(unstaged)
|
|
6110
7017
|
)
|
|
6111
|
-
|
|
6112
|
-
manifest = _require_task_context(repo, cfg, args.task_id)
|
|
7018
|
+
manifest = _require_task_context(repo, cfg, args.task_id)
|
|
6113
7019
|
|
|
6114
7020
|
committed_sha = _commit_exact_index(repo, msg)
|
|
6115
7021
|
_push_current_task(repo, manifest, committed_sha)
|
|
6116
|
-
|
|
6117
|
-
if mode == "verify":
|
|
6118
|
-
verification_fingerprint = _task_content_fingerprint(repo, cfg, manifest)
|
|
6119
|
-
if jenkins_required:
|
|
6120
|
-
jenkins_build = cmd_verify_jenkins_build(
|
|
6121
|
-
argparse.Namespace(
|
|
6122
|
-
repo=str(repo),
|
|
6123
|
-
git_ref="HEAD",
|
|
6124
|
-
job_name=args.job_name,
|
|
6125
|
-
job_url=args.job_url,
|
|
6126
|
-
multibranch_root_job=args.multibranch_root_job,
|
|
6127
|
-
branch_name=args.branch_name,
|
|
6128
|
-
build_number=args.build_number,
|
|
6129
|
-
max_builds=args.max_builds,
|
|
6130
|
-
timeout_sec=args.timeout_sec,
|
|
6131
|
-
poll_sec=args.poll_sec,
|
|
6132
|
-
allow_no_deploy=args.allow_no_deploy,
|
|
6133
|
-
)
|
|
6134
|
-
)
|
|
6135
|
-
else:
|
|
6136
|
-
jenkins_build = "skipped by verification.jenkins_required=false"
|
|
6137
|
-
|
|
6138
|
-
if target_env_required:
|
|
6139
|
-
target_summary = cmd_verify_target(
|
|
6140
|
-
argparse.Namespace(
|
|
6141
|
-
repo=str(repo),
|
|
6142
|
-
backend_path=args.backend_path,
|
|
6143
|
-
frontend_path=args.frontend_path,
|
|
6144
|
-
backend_basic_auth=args.backend_basic_auth,
|
|
6145
|
-
frontend_basic_auth=args.frontend_basic_auth,
|
|
6146
|
-
)
|
|
6147
|
-
)
|
|
6148
|
-
else:
|
|
6149
|
-
target_summary = "skipped by verification.target_env_required=false"
|
|
6150
|
-
if args.require_matrix:
|
|
6151
|
-
cmd_check_matrix(argparse.Namespace(repo=str(repo)))
|
|
6152
|
-
verification = args.verification
|
|
6153
|
-
if not verification:
|
|
6154
|
-
verification = []
|
|
6155
|
-
if jenkins_required:
|
|
6156
|
-
verification.append(f"CI/Jenkins build verified: {jenkins_build or 'verified by git-ref HEAD'}")
|
|
6157
|
-
else:
|
|
6158
|
-
verification.append("CI/Jenkins verification skipped by verification.jenkins_required=false")
|
|
6159
|
-
if target_env_required:
|
|
6160
|
-
verification.append(f"Target verification: {target_summary}")
|
|
6161
|
-
else:
|
|
6162
|
-
verification.append("Target verification skipped by verification.target_env_required=false")
|
|
6163
|
-
if _task_content_fingerprint(repo, cfg, manifest) != verification_fingerprint:
|
|
6164
|
-
raise APError(
|
|
6165
|
-
"Verification changed task-owned files. Review them and rerun commit-push before "
|
|
6166
|
-
"recording the verification closure."
|
|
6167
|
-
)
|
|
6168
|
-
if manifest:
|
|
6169
|
-
manifest = _require_task_context(repo, cfg, args.task_id)
|
|
6170
|
-
_record_commit_push_closure(
|
|
6171
|
-
repo,
|
|
6172
|
-
args,
|
|
6173
|
-
commit="HEAD",
|
|
6174
|
-
jenkins=args.jenkins_build or jenkins_build or "verified by git-ref HEAD",
|
|
6175
|
-
target_env=args.target_env
|
|
6176
|
-
or (str(target_cfg.get("name") or "").strip() if target_env_required else "skipped by verification.target_env_required=false"),
|
|
6177
|
-
verification=verification,
|
|
6178
|
-
result=args.result or "PASS",
|
|
6179
|
-
follow_up=args.follow_up or "none",
|
|
6180
|
-
structure_check=args.structure_check or structure_check_status,
|
|
6181
|
-
)
|
|
6182
|
-
if manifest:
|
|
6183
|
-
_cleanup_generated_noise(repo, protected_paths=protected)
|
|
6184
|
-
closure_fingerprint = _task_content_fingerprint(repo, cfg, manifest)
|
|
6185
|
-
if manifest:
|
|
6186
|
-
manifest = _require_task_context(repo, cfg, args.task_id)
|
|
6187
|
-
if _task_content_fingerprint(repo, cfg, manifest) != closure_fingerprint:
|
|
6188
|
-
raise APError("Task-owned files changed immediately before staging verification closure.")
|
|
6189
|
-
closure_paths = _task_commit_paths(repo)
|
|
6190
|
-
closure_staged = _stage_exact_paths(repo, closure_paths)
|
|
6191
|
-
if closure_staged:
|
|
6192
|
-
unstaged = _unstaged_task_paths(repo)
|
|
6193
|
-
if unstaged:
|
|
6194
|
-
raise APError(
|
|
6195
|
-
"Task-owned files changed while staging verification closure:\n- "
|
|
6196
|
-
+ "\n- ".join(unstaged)
|
|
6197
|
-
)
|
|
6198
|
-
closure_sha = _commit_exact_index(repo, f"{args.task_id}: record verification closure [skip ci]")
|
|
6199
|
-
_push_current_task(repo, manifest, closure_sha)
|
|
6200
|
-
elif args.record_closure and mode != "dev":
|
|
6201
|
-
_record_commit_push_closure(
|
|
6202
|
-
repo,
|
|
6203
|
-
args,
|
|
6204
|
-
commit="HEAD",
|
|
6205
|
-
jenkins=args.jenkins_build or "TODO",
|
|
6206
|
-
target_env=args.target_env or str(target_cfg.get("name") or "").strip(),
|
|
6207
|
-
verification=args.verification or [],
|
|
6208
|
-
result=args.result or "PARTIAL",
|
|
6209
|
-
follow_up=args.follow_up or "none",
|
|
6210
|
-
structure_check=args.structure_check or structure_check_status,
|
|
6211
|
-
)
|
|
6212
7022
|
print(f"[commit-push] OK - profile={plan['profile']} mode={mode} scope={plan['selected_scope']}")
|
|
6213
7023
|
|
|
6214
7024
|
|
|
@@ -6216,8 +7026,10 @@ def cmd_commit_push(args: argparse.Namespace) -> None:
|
|
|
6216
7026
|
repo = Path(args.repo).resolve()
|
|
6217
7027
|
ensure_git_repo(repo)
|
|
6218
7028
|
cfg = _load_cfg(repo)
|
|
7029
|
+
_require_workflow_policy_clean(repo, cfg)
|
|
6219
7030
|
manifest = _require_task_context(repo, cfg, args.task_id)
|
|
6220
|
-
|
|
7031
|
+
_require_current_writer(manifest, args)
|
|
7032
|
+
lock_name = f"task-{_validate_task_id(args.task_id)}"
|
|
6221
7033
|
timeout_s = float(_concurrency_cfg(cfg).get("lock_timeout_sec") or 30)
|
|
6222
7034
|
with _repo_lock(repo, lock_name, timeout_s=timeout_s):
|
|
6223
7035
|
_cmd_commit_push_locked(args, repo, cfg, manifest)
|
|
@@ -6272,7 +7084,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
6272
7084
|
s = sp.add_parser("impact")
|
|
6273
7085
|
s.add_argument("--scope", choices=sorted(_GATE_SCOPES), default="")
|
|
6274
7086
|
s.add_argument("--profile", choices=sorted(_WORKFLOW_PROFILES), default="")
|
|
6275
|
-
s.add_argument("--mode", choices=["dev"
|
|
7087
|
+
s.add_argument("--mode", choices=["dev"], default="")
|
|
6276
7088
|
s.add_argument("--base")
|
|
6277
7089
|
s.add_argument("--json", action="store_true")
|
|
6278
7090
|
s.set_defaults(func=cmd_impact)
|
|
@@ -6280,8 +7092,11 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
6280
7092
|
s = sp.add_parser("classify")
|
|
6281
7093
|
s.add_argument("--scope", choices=sorted(_GATE_SCOPES), default="")
|
|
6282
7094
|
s.add_argument("--profile", choices=sorted(_WORKFLOW_PROFILES), default="")
|
|
6283
|
-
s.add_argument("--mode", choices=["dev"
|
|
7095
|
+
s.add_argument("--mode", choices=["dev"], default="")
|
|
6284
7096
|
s.add_argument("--base")
|
|
7097
|
+
s.add_argument("--planned-path", action="append")
|
|
7098
|
+
s.add_argument("--intent")
|
|
7099
|
+
s.add_argument("--intent-file")
|
|
6285
7100
|
s.add_argument("--json", action="store_true")
|
|
6286
7101
|
s.set_defaults(func=cmd_classify)
|
|
6287
7102
|
|
|
@@ -6309,9 +7124,9 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
6309
7124
|
s.set_defaults(func=cmd_docs_ledger_archive)
|
|
6310
7125
|
|
|
6311
7126
|
s = sp.add_parser("light-gate")
|
|
6312
|
-
s.add_argument("--scope", choices=
|
|
7127
|
+
s.add_argument("--scope", choices=["auto", "changed"], default="")
|
|
6313
7128
|
s.add_argument("--profile", choices=sorted(_WORKFLOW_PROFILES), default="")
|
|
6314
|
-
s.add_argument("--mode", choices=["dev"
|
|
7129
|
+
s.add_argument("--mode", choices=["dev"], default="")
|
|
6315
7130
|
s.add_argument("--base")
|
|
6316
7131
|
s.add_argument("--explain", action="store_true")
|
|
6317
7132
|
s.set_defaults(func=cmd_light_gate)
|
|
@@ -6378,6 +7193,9 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
6378
7193
|
s.add_argument("--remote")
|
|
6379
7194
|
s.add_argument("--worktree-root")
|
|
6380
7195
|
s.add_argument("--owner")
|
|
7196
|
+
s.add_argument("--writer")
|
|
7197
|
+
s.add_argument("--owned-path", action="append")
|
|
7198
|
+
s.add_argument("--depends-on", action="append", metavar="TASK_ID=SHA")
|
|
6381
7199
|
s.add_argument("--no-fetch", action="store_true")
|
|
6382
7200
|
s.set_defaults(func=cmd_task_start)
|
|
6383
7201
|
|
|
@@ -6390,10 +7208,30 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
6390
7208
|
s.add_argument("task_id")
|
|
6391
7209
|
s.set_defaults(func=cmd_task_submodule_sync)
|
|
6392
7210
|
|
|
7211
|
+
s = sp.add_parser("task-review")
|
|
7212
|
+
s.add_argument("task_id")
|
|
7213
|
+
s.add_argument("--verdict", choices=["approved", "changes-requested"], required=True)
|
|
7214
|
+
s.add_argument("--diff-fingerprint", required=True)
|
|
7215
|
+
s.add_argument("--reviewer")
|
|
7216
|
+
s.set_defaults(func=cmd_task_review)
|
|
7217
|
+
|
|
7218
|
+
s = sp.add_parser("task-handoff")
|
|
7219
|
+
s.add_argument("task_id")
|
|
7220
|
+
s.add_argument("--from", dest="from_writer", required=True)
|
|
7221
|
+
s.add_argument("--to", dest="to_writer", required=True)
|
|
7222
|
+
s.add_argument("--generation", type=int)
|
|
7223
|
+
s.set_defaults(func=cmd_task_handoff)
|
|
7224
|
+
|
|
7225
|
+
s = sp.add_parser("task-resume")
|
|
7226
|
+
s.add_argument("task_id")
|
|
7227
|
+
s.add_argument("--writer")
|
|
7228
|
+
s.set_defaults(func=cmd_task_resume)
|
|
7229
|
+
|
|
6393
7230
|
s = sp.add_parser("task-integrate")
|
|
6394
7231
|
s.add_argument("task_id")
|
|
6395
7232
|
s.add_argument("--keep-worktree", action="store_true")
|
|
6396
7233
|
s.add_argument("--keep-remote", action="store_true")
|
|
7234
|
+
s.add_argument("--writer")
|
|
6397
7235
|
s.set_defaults(func=cmd_task_integrate)
|
|
6398
7236
|
|
|
6399
7237
|
s = sp.add_parser("task-finish")
|
|
@@ -6409,28 +7247,8 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
6409
7247
|
s.add_argument("task_id")
|
|
6410
7248
|
s.add_argument("--title")
|
|
6411
7249
|
s.add_argument("--msg", required=True)
|
|
6412
|
-
s.add_argument("--mode", choices=["dev"
|
|
7250
|
+
s.add_argument("--mode", choices=["dev"])
|
|
6413
7251
|
s.add_argument("--profile", choices=sorted(_WORKFLOW_PROFILES))
|
|
6414
|
-
s.add_argument("--require-light-gate", action="store_true")
|
|
6415
|
-
s.add_argument("--require-runtime-health", action="store_true")
|
|
6416
|
-
s.add_argument("--require-jenkins", action="store_true")
|
|
6417
|
-
s.add_argument("--require-matrix", action="store_true")
|
|
6418
|
-
s.add_argument("--record-closure", action="store_true")
|
|
6419
|
-
s.add_argument("--job-name")
|
|
6420
|
-
s.add_argument("--job-url")
|
|
6421
|
-
s.add_argument("--multibranch-root-job")
|
|
6422
|
-
s.add_argument("--branch-name")
|
|
6423
|
-
s.add_argument("--build-number", type=int)
|
|
6424
|
-
s.add_argument("--max-builds", type=int, default=20)
|
|
6425
|
-
s.add_argument("--timeout-sec", type=int, default=300)
|
|
6426
|
-
s.add_argument("--poll-sec", type=int, default=5)
|
|
6427
|
-
s.add_argument("--allow-no-deploy", action="store_true")
|
|
6428
|
-
s.add_argument("--backend-path", action="append")
|
|
6429
|
-
s.add_argument("--frontend-path", action="append")
|
|
6430
|
-
s.add_argument("--backend-basic-auth", action="store_true")
|
|
6431
|
-
s.add_argument("--frontend-basic-auth", action="store_true")
|
|
6432
|
-
s.add_argument("--ci-build", "--jenkins-build", dest="jenkins_build", metavar="CI_BUILD")
|
|
6433
|
-
s.add_argument("--target-env")
|
|
6434
7252
|
s.add_argument("--verification", action="append")
|
|
6435
7253
|
s.add_argument("--structure-check")
|
|
6436
7254
|
s.add_argument("--result", choices=["DEV-CLOSED", "PASS", "FAIL", "PARTIAL"])
|
|
@@ -6438,6 +7256,7 @@ def main(argv: Optional[List[str]] = None) -> int:
|
|
|
6438
7256
|
s.add_argument("--initial-commit")
|
|
6439
7257
|
s.add_argument("--ci-failure", "--jenkins-failure", dest="jenkins_failure", metavar="CI_FAILURE")
|
|
6440
7258
|
s.add_argument("--fix-commit")
|
|
7259
|
+
s.add_argument("--writer")
|
|
6441
7260
|
s.set_defaults(func=cmd_commit_push)
|
|
6442
7261
|
|
|
6443
7262
|
try:
|