feat: local drafter (pi against a self-run model server)

drafter: local runs the pi coding agent against the model resident on an
OpenAI-compatible server at the new local_url input, keyed by the
LOCAL_MODEL_API_KEY secret. It asks the server which model is loaded and
names exactly that one, so it never evicts the resident model. An
unreachable server or no loaded model posts the stage 1 flags with a note
and exits 0; a drafter that ran and failed still exits 1.

pi runs in the existing sandbox with read, ls, edit and write, every
project-local pi file and AGENTS.md ignored, stdin from /dev/null, the task
passed as an @file, and an allowlisted environment. As root with
DOCS_REVIEW_DRAFTER_USER set, it runs as that unprivileged user, which
owns only the sandbox and pi's temporary home.

Both drafters now hash the checkout's .git/config and .git/hooks before
drafting and stop with no further git command if either changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jaredandClaude Opus 5.5 committed 2026-11-12 16:28:21 -05:00
1 parent 9dea56ce98
commit 28b993cb23
14 files changed
+1042 -30

No files matched your search

+23
View File
@@ -41,6 +41,7 @@ class ParseInputsTest(unittest.TestCase):
{
"INPUT_DOCS": "a.md",
"INPUT_DRAFTER": "Local",
"INPUT_LOCAL_URL": " http://model-host:8888/v1/ ",
"INPUT_TRACKING_ISSUE": " 42 ",
"INPUT_DOC_GUIDE": "docs/guide.md",
"INPUT_MODEL": "m",
@@ -51,6 +52,7 @@ class ParseInputsTest(unittest.TestCase):
}
)
self.assertEqual(i.drafter, "local")
self.assertEqual(i.local_url, "http://model-host:8888/v1")
self.assertEqual(i.tracking_issue, 42)
self.assertEqual(i.doc_guide, "docs/guide.md")
self.assertEqual((i.model, i.workstream), ("m", "model"))
@@ -90,6 +92,27 @@ class ParseInputsTest(unittest.TestCase):
with self.assertRaisesRegex(ValueError, "tracking_issue"):
parse_inputs({"INPUT_DOCS": "a.md", "INPUT_TRACKING_ISSUE": "abc"})
def test_local_url_required_for_local(self):
for url in (None, "", " "):
with self.assertRaisesRegex(ValueError, "local_url"):
parse_inputs({"INPUT_DOCS": "a.md", "INPUT_DRAFTER": "local",
"INPUT_LOCAL_URL": url})
def test_local_url_must_be_http(self):
for url in ("ftp://h/v1", "file:///etc/passwd", "model-host:8888/v1", "http://",
"http:///v1"):
with self.assertRaisesRegex(ValueError, "local_url"):
parse_inputs({"INPUT_DOCS": "a.md", "INPUT_DRAFTER": "local",
"INPUT_LOCAL_URL": url})
i = parse_inputs({"INPUT_DOCS": "a.md", "INPUT_DRAFTER": "local",
"INPUT_LOCAL_URL": "https://h/v1"})
self.assertEqual(i.local_url, "https://h/v1")
def test_local_url_ignored_for_other_drafters(self):
i = parse_inputs({"INPUT_DOCS": "a.md", "INPUT_DRAFTER": "claude",
"INPUT_LOCAL_URL": "ftp://x"})
self.assertIsNone(i.local_url)
class PatternTest(unittest.TestCase):
def test_expand_sorted_deduplicated_posix(self):