fix: local drafter review round 1

- Refuse to run pi as root when DOCS_REVIEW_DRAFTER_USER is unset.
- Keep a record of the run: parse partial output on timeout, add the first
  redacted stderr line to failures, and report summed output and peak
  input tokens with turns in the log and step summary.
- Delete top-level .pi* entries from the sandbox before drafting and
  refuse a draft that recreates one.
- Probe: an HTTP error, redirect or non-JSON answer is a hard failure;
  only connection failures and an empty model list are soft. Refuse model
  ids starting with "-" and pass --model=<id>.
- README: mid-run model swap note, hard-failure cases, rewrap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-12 16:42:10 -05:00
1 parent 28b993cb23
commit 7095db060e
9 files changed
+330 -86

No files matched your search

+27
View File
@@ -66,6 +66,33 @@ def remove_symlinks(root: Path) -> tuple[str, ...]:
return tuple(sorted(removed))
PI_CONFIG_PREFIX = ".pi"
def is_pi_config(rel: str) -> bool:
"""True for a path under a top-level entry named .pi*: pi's project settings,
extensions and model config, or a config file beside them."""
return Path(rel).parts[0].startswith(PI_CONFIG_PREFIX) if rel else False
def pi_config_entries(root: Path) -> tuple[str, ...]:
"""Top-level names under root that start with .pi."""
return tuple(sorted(n for n in os.listdir(root) if n.startswith(PI_CONFIG_PREFIX)))
def remove_pi_config(root: Path) -> tuple[str, ...]:
"""Delete every top-level .pi* entry, so a pull request's pi settings or model
config cannot load whatever flags pi is given. Returns the removed names."""
removed = pi_config_entries(root)
for name in removed:
path = root / name
if path.is_dir() and not path.is_symlink():
shutil.rmtree(path)
else:
path.unlink()
return removed
class CopyRefused(RuntimeError):
"""A change cannot be copied back safely; the message names the path."""