agent-sdlc 0.5.0__tar.gz → 0.5.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {agent_sdlc-0.5.0/agent_sdlc.egg-info → agent_sdlc-0.5.2}/PKG-INFO +4 -3
  2. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/README.md +3 -2
  3. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2/agent_sdlc.egg-info}/PKG-INFO +4 -3
  4. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/__init__.py +1 -1
  5. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/adversary.py +32 -8
  6. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/host_exec.py +63 -6
  7. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/LICENSE +0 -0
  8. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/NOTICE.md +0 -0
  9. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/agent_sdlc.egg-info/SOURCES.txt +0 -0
  10. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/agent_sdlc.egg-info/dependency_links.txt +0 -0
  11. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/agent_sdlc.egg-info/entry_points.txt +0 -0
  12. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/agent_sdlc.egg-info/requires.txt +0 -0
  13. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/agent_sdlc.egg-info/top_level.txt +0 -0
  14. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/cli.py +0 -0
  15. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/commit_msg.py +0 -0
  16. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/coverage_map.py +0 -0
  17. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/diff_discipline.py +0 -0
  18. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/model_vv.py +0 -0
  19. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/mutants.py +0 -0
  20. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/no_comments.py +0 -0
  21. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/no_leaks.py +0 -0
  22. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/no_new_docs.py +0 -0
  23. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/repo.py +0 -0
  24. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/rules.py +0 -0
  25. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/runner.py +0 -0
  26. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/token.py +0 -0
  27. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/vocabulary.py +0 -0
  28. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/vocabulary_check.py +0 -0
  29. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/vocabulary_core.toml +0 -0
  30. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/vocabulary_molds.py +0 -0
  31. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/vocabulary_path.py +0 -0
  32. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/vocabulary_wordnet.py +0 -0
  33. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/mutation_gate/waivers.py +0 -0
  34. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/pyproject.toml +0 -0
  35. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/rules/code-clarity.md +0 -0
  36. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/rules/diff-discipline.md +0 -0
  37. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/rules/model-vv.md +0 -0
  38. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/rules/naming.md +0 -0
  39. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/rules/testing.md +0 -0
  40. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/rules/tickets.md +0 -0
  41. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/rules/voice.md +0 -0
  42. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/setup.cfg +0 -0
  43. {agent_sdlc-0.5.0 → agent_sdlc-0.5.2}/tests/test_say_narrate_bin.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-sdlc
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: Diff-scoped mutation gate for pre-commit and agent Stop hooks
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/PavelGuzenfeld/agent-sdlc
@@ -73,7 +73,8 @@ memory.
73
73
  | implement | smallest change [diff-discipline]
74
74
  | | no comments, canonical names
75
75
  +--------------------------+ [code-clarity] [naming]
76
- | every Bash call: git-guardrail x reset --hard, add -A, force-push
76
+ | every Bash call: git-guardrail x reset --hard, add -A, force-push, checkout in the primary worktree
77
+ | host-exec host python3/pytest/make run in test_image
77
78
  v
78
79
  +--------------------------+
79
80
  | git commit |
@@ -193,7 +194,7 @@ them. Setup order, the CI job and the `docs/` allowlist:
193
194
  | `rules/` | How to work; synced into a repo with `mutation-gate rules sync` |
194
195
  | `commands/` | Slash commands: `/kata`, `/done`, `/grill`, `/rectify` … |
195
196
  | `skills/` | On-demand playbooks: `/diagnose`, `/sol-budget`, `/verify-generated-diff` … |
196
- | `bin/` | Hooks and helpers: `git-guardrail.sh`, the `/say` stack |
197
+ | `bin/` | Hooks and helpers: `session-preflight.sh`, `git-guardrail.sh`, the `/say` stack. `mutation_gate/host_exec.py` is the host-exec hook |
197
198
  | `mutation_gate/` | The gate and the `mutation-gate` CLI |
198
199
 
199
200
  CI runs `scripts/no-leaks.sh` on every PR. It flags emails, RFC1918
@@ -58,7 +58,8 @@ memory.
58
58
  | implement | smallest change [diff-discipline]
59
59
  | | no comments, canonical names
60
60
  +--------------------------+ [code-clarity] [naming]
61
- | every Bash call: git-guardrail x reset --hard, add -A, force-push
61
+ | every Bash call: git-guardrail x reset --hard, add -A, force-push, checkout in the primary worktree
62
+ | host-exec host python3/pytest/make run in test_image
62
63
  v
63
64
  +--------------------------+
64
65
  | git commit |
@@ -178,7 +179,7 @@ them. Setup order, the CI job and the `docs/` allowlist:
178
179
  | `rules/` | How to work; synced into a repo with `mutation-gate rules sync` |
179
180
  | `commands/` | Slash commands: `/kata`, `/done`, `/grill`, `/rectify` … |
180
181
  | `skills/` | On-demand playbooks: `/diagnose`, `/sol-budget`, `/verify-generated-diff` … |
181
- | `bin/` | Hooks and helpers: `git-guardrail.sh`, the `/say` stack |
182
+ | `bin/` | Hooks and helpers: `session-preflight.sh`, `git-guardrail.sh`, the `/say` stack. `mutation_gate/host_exec.py` is the host-exec hook |
182
183
  | `mutation_gate/` | The gate and the `mutation-gate` CLI |
183
184
 
184
185
  CI runs `scripts/no-leaks.sh` on every PR. It flags emails, RFC1918
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: agent-sdlc
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: Diff-scoped mutation gate for pre-commit and agent Stop hooks
5
5
  License-Expression: MIT
6
6
  Project-URL: Homepage, https://github.com/PavelGuzenfeld/agent-sdlc
@@ -73,7 +73,8 @@ memory.
73
73
  | implement | smallest change [diff-discipline]
74
74
  | | no comments, canonical names
75
75
  +--------------------------+ [code-clarity] [naming]
76
- | every Bash call: git-guardrail x reset --hard, add -A, force-push
76
+ | every Bash call: git-guardrail x reset --hard, add -A, force-push, checkout in the primary worktree
77
+ | host-exec host python3/pytest/make run in test_image
77
78
  v
78
79
  +--------------------------+
79
80
  | git commit |
@@ -193,7 +194,7 @@ them. Setup order, the CI job and the `docs/` allowlist:
193
194
  | `rules/` | How to work; synced into a repo with `mutation-gate rules sync` |
194
195
  | `commands/` | Slash commands: `/kata`, `/done`, `/grill`, `/rectify` … |
195
196
  | `skills/` | On-demand playbooks: `/diagnose`, `/sol-budget`, `/verify-generated-diff` … |
196
- | `bin/` | Hooks and helpers: `git-guardrail.sh`, the `/say` stack |
197
+ | `bin/` | Hooks and helpers: `session-preflight.sh`, `git-guardrail.sh`, the `/say` stack. `mutation_gate/host_exec.py` is the host-exec hook |
197
198
  | `mutation_gate/` | The gate and the `mutation-gate` CLI |
198
199
 
199
200
  CI runs `scripts/no-leaks.sh` on every PR. It flags emails, RFC1918
@@ -1,3 +1,3 @@
1
1
  """Diff-scoped mutation gate. Spec: PavelGuzenfeld/dotfiles#9."""
2
2
 
3
- __version__ = "0.5.0"
3
+ __version__ = "0.5.2"
@@ -7,7 +7,9 @@ cannot be anchored by what the code happens to do. It reports; it never blocks.
7
7
 
8
8
  from __future__ import annotations
9
9
 
10
+ import contextlib
10
11
  import json
12
+ import os
11
13
  import re
12
14
  import shutil
13
15
  import subprocess
@@ -127,14 +129,36 @@ def run_isolated(name: str, prompt: str, work: Path, extra: tuple[str, ...] = ()
127
129
  cannot wait on a terminal. Returns findings or the one-line reason it did not run."""
128
130
  if not shutil.which("claude"):
129
131
  return f"{name} skipped: `claude` not on PATH"
130
- proc = subprocess.run(
131
- [
132
- "claude", "-p", prompt, "--restricted", "--disable-slash-commands",
133
- "--no-session-persistence", *extra,
134
- ],
135
- cwd=work, stdin=subprocess.DEVNULL, capture_output=True, text=True,
136
- check=False, timeout=600,
137
- )
132
+ try:
133
+ proc = subprocess.run(
134
+ [
135
+ "claude", "-p", prompt, "--restricted", "--disable-slash-commands",
136
+ "--no-session-persistence", *extra,
137
+ ],
138
+ cwd=work, stdin=subprocess.DEVNULL, capture_output=True, text=True,
139
+ check=False, timeout=600,
140
+ )
141
+ finally:
142
+ _remove_empty_projects_folder(work)
138
143
  if proc.returncode != 0:
139
144
  return f"{name} failed to run: {proc.stderr.strip()[:200]}"
140
145
  return proc.stdout.strip()
146
+
147
+
148
+ def _remove_empty_projects_folder(work: Path) -> None:
149
+ """Deletes the `claude` projects folder for `work` only when it holds no
150
+ files or symlinks. rmdir alone, never rmtree: a folder with anything in it
151
+ belongs to the user."""
152
+ folder = _claude_projects_dir() / re.sub(r"[^A-Za-z0-9]", "-", str(work.resolve()))
153
+ tree = []
154
+ for dirpath, dirnames, filenames in os.walk(folder):
155
+ if filenames or any(Path(dirpath, d).is_symlink() for d in dirnames):
156
+ return
157
+ tree.append(dirpath)
158
+ for dirpath in reversed(tree):
159
+ with contextlib.suppress(OSError):
160
+ os.rmdir(dirpath)
161
+
162
+
163
+ def _claude_projects_dir() -> Path:
164
+ return Path(os.environ.get("CLAUDE_CONFIG_DIR") or Path.home() / ".claude") / "projects"
@@ -18,6 +18,7 @@ CONTAINER_MARKER = Path("/.dockerenv")
18
18
  HOST_COMMANDS = frozenset({"python3", "pytest", "make", "cmake", "colcon"})
19
19
  USER_FLAG = "--user $(id -u):$(id -g)"
20
20
  SEPARATORS = ";&|"
21
+ LIST_SEPARATORS = ("&&", "||", ";", "\n")
21
22
  PWD_PREFIX = re.compile(r"^(\$\{PWD\}|\$PWD|\$\(pwd\)|`pwd`)")
22
23
  USER_FLAGS = frozenset({"-u", "--user"})
23
24
  VOLUME_FLAGS = frozenset({"-v", "--volume"})
@@ -125,6 +126,58 @@ def is_host_command(tokens: list[str]) -> bool:
125
126
  return tokens[0] in HOST_COMMANDS or tokens[:2] == ["pip", "install"]
126
127
 
127
128
 
129
+ def split_list(command: str) -> list[str]:
130
+ pieces: list[str] = []
131
+ start = depth = index = 0
132
+ quote = ""
133
+ while index < len(command):
134
+ char = command[index]
135
+ if quote:
136
+ index += char == "\\" and quote == '"'
137
+ quote = "" if char == quote else quote
138
+ elif char == "\\":
139
+ index += 1
140
+ elif char in "'\"":
141
+ quote = char
142
+ elif char in "()":
143
+ depth = max(depth + (1 if char == "(" else -1), 0)
144
+ elif depth == 0:
145
+ separator = next((s for s in LIST_SEPARATORS if command.startswith(s, index)), None)
146
+ if separator:
147
+ pieces += [command[start:index], separator]
148
+ index += len(separator)
149
+ start = index
150
+ continue
151
+ index += 1
152
+ return pieces + [command[start:]]
153
+
154
+
155
+ def in_image(command: str, image: str) -> str:
156
+ return (f'docker run --rm {USER_FLAG} -e HOME=/tmp -v "$PWD:/w" -w /w '
157
+ f"{shlex.quote(image)} sh -c {shlex.quote(command)}")
158
+
159
+
160
+ def rewrite_host_elements(command: str, image: str) -> str:
161
+ pieces = split_list(command)
162
+ for index in range(0, len(pieces), 2):
163
+ padded = pieces[index]
164
+ element = padded.strip()
165
+ parts = segments(element)
166
+ if parts and parts[0][0] != "docker" and any(is_host_command(part) for part in parts):
167
+ pieces[index] = padded.replace(element, in_image(element, image), 1)
168
+ return "".join(pieces)
169
+
170
+
171
+ def host_command_piped_from_docker(command: str) -> str | None:
172
+ for element in split_list(command)[::2]:
173
+ parts = segments(element)
174
+ if parts and parts[0][0] == "docker":
175
+ host = next((part[0] for part in parts[1:] if is_host_command(part)), None)
176
+ if host:
177
+ return host
178
+ return None
179
+
180
+
128
181
  def decide(command: str, cwd: Path, is_in_container: bool) -> Denial | Rewrite | Notice | None:
129
182
  toplevel = git_lines(cwd, "rev-parse", "--show-toplevel")
130
183
  if toplevel is None or not (Path(toplevel[0]) / CONFIG_NAME).exists():
@@ -152,18 +205,22 @@ def decide(command: str, cwd: Path, is_in_container: bool) -> Denial | Rewrite |
152
205
  f"which leaves root-owned files. Run instead:\n {with_user(command)}"
153
206
  )
154
207
  host = next((part[0] for part in parts if is_host_command(part)), None)
155
- if (host is None or is_in_container or not config.is_test_image_used
156
- or any(part[0] == "docker" for part in parts)):
208
+ if host is None or is_in_container or not config.is_test_image_used:
157
209
  return None
158
210
  if not config.test_image:
159
211
  return Denial(
160
212
  f"`{host}` would run on the host. Set test_image = \"<image>\" in "
161
213
  f"{CONFIG_NAME} to run it in that image, or is_test_image_used = false to keep it on the host."
162
214
  )
163
- return Rewrite(
164
- f'docker run --rm {USER_FLAG} -e HOME=/tmp -v "$PWD:/w" -w /w '
165
- f"{shlex.quote(config.test_image)} sh -c {shlex.quote(command)}"
166
- )
215
+ piped = host_command_piped_from_docker(command)
216
+ if piped:
217
+ return Denial(
218
+ f"`{piped}` is piped from a docker command and would run on the host. Split the "
219
+ f"line so `{piped}` is its own command and runs in {config.test_image}."
220
+ )
221
+ if any(part[0] == "docker" for part in parts):
222
+ return Rewrite(rewrite_host_elements(command, config.test_image))
223
+ return Rewrite(in_image(command, config.test_image))
167
224
 
168
225
 
169
226
  def main() -> int:
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes