Skip to content

Commit f93744d

Browse files
committed
🛡️ chore(process): enforce plan scope permission lock
Require active execution plans to record allowed paths and explicit permission checkboxes, and enforce this mechanically via arch-test to prevent unscoped edits.
1 parent 7b5c725 commit f93744d

File tree

5 files changed

+78
-4
lines changed

5 files changed

+78
-4
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
from __future__ import annotations
2+
3+
from pathlib import Path
4+
5+
6+
ROOT = Path(__file__).resolve().parent.parent
7+
ACTIVE_PLANS_DIR = ROOT / "docs" / "exec-plans" / "active"
8+
9+
REQUIRED_SNIPPETS = (
10+
"## Files/Directories To Change",
11+
"## Edit Permission",
12+
"- [x] Allowed paths confirmed by user.",
13+
"- [x] No edits outside listed paths.",
14+
)
15+
16+
17+
def should_check(path: Path) -> bool:
18+
return path.suffix == ".md" and path.name != "README.md"
19+
20+
21+
def main() -> int:
22+
missing = []
23+
for plan in sorted(ACTIVE_PLANS_DIR.glob("*.md")):
24+
if not should_check(plan):
25+
continue
26+
text = plan.read_text(encoding="utf-8")
27+
not_found = [snippet for snippet in REQUIRED_SNIPPETS if snippet not in text]
28+
if not_found:
29+
missing.append((plan, not_found))
30+
31+
if missing:
32+
print("Execution plan scope-lock check failed:")
33+
for plan, snippets in missing:
34+
rel = plan.relative_to(ROOT)
35+
print(f"- {rel} is missing required items:")
36+
for snippet in snippets:
37+
print(f" - {snippet}")
38+
print(
39+
"Fix: update active plan with explicit allowed paths and checked permission items."
40+
)
41+
return 1
42+
43+
print("Execution plan scope-lock checks passed.")
44+
return 0
45+
46+
47+
if __name__ == "__main__":
48+
raise SystemExit(main())

docs/exec-plans/active/2026-03-01-wallet-crypto-v2-migration.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,15 @@ Operational rollout without feature flags:
3838
- `adr/` (new ADR)
3939
- `docs/runbooks/` (migration/rollback runbook)
4040

41+
## Edit Permission
42+
43+
- [x] Allowed paths confirmed by user.
44+
- [x] No edits outside listed paths.
45+
46+
Permission evidence:
47+
48+
> "Ок, давай сделаем тогда план в файлике дотошный..." and explicit follow-ups to proceed with implementation.
49+
4150
## Change Plan
4251

4352
1. [x] Add new DB field and model mapping (no legacy removal).

docs/exec-plans/template.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,20 @@
44

55
Why this task exists and links to issue/ADR.
66

7+
## Files/Directories To Change
8+
9+
- `<path-or-dir-1>`
10+
- `<path-or-dir-2>`
11+
12+
## Edit Permission
13+
14+
- [ ] Allowed paths confirmed by user.
15+
- [ ] No edits outside listed paths.
16+
17+
Permission evidence (copy user wording or exact confirmation):
18+
19+
> <user confirmation>
20+
721
## Change Plan
822

923
1. [ ] Step one with concrete file targets.

docs/runbooks/task-intake-and-execution.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,19 @@ Ensure every non-trivial task starts in AI-first workflow mode.
1414
just start-task <task-id> title="<short title>"
1515
```
1616

17-
4. Fill checkboxes in the created plan under `docs/exec-plans/active/`.
18-
5. Implement with minimal diff.
19-
6. Run validation commands:
17+
4. Record allowed paths and permission evidence in the plan (`Files/Directories To
18+
Change` and `Edit Permission` sections).
19+
5. Mark permission checkboxes as done before first edit.
20+
6. Implement with minimal diff.
21+
7. Run validation commands:
2022

2123
```bash
2224
just arch-test
2325
just lint
2426
just test-fast
2527
```
2628

27-
7. Move completed plan:
29+
8. Move completed plan:
2830

2931
```bash
3032
just finish-task <plan-file>

justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ test-external:
6262
arch-test:
6363
uv run python .linters/check_import_boundaries.py
6464
uv run python .linters/check_docs_contract.py
65+
uv run python .linters/check_exec_plan_scope_lock.py
6566

6667
secret-scan:
6768
docker run --rm -v "$PWD:/repo" -w /repo zricethezav/gitleaks:v8.24.2 detect --source=. --no-git --redact --config=.gitleaks.toml

0 commit comments

Comments
 (0)