phalanx, n. a disciplined infantry formation in which each soldier's shield protects the one to their left. The formation is the defense; no soldier stands alone.
Phalanx is a reference implementation of an autonomous code-modernization studio: a multi-agent system that takes a refactor request as input and produces a reviewed, tested, security-scanned pull request as output. It happens under a deterministic guardrail layer that keeps autonomous code generation safe enough for production use.
It exists to make three architectural claims visible, runnable, and testable.
Autonomous agents can produce predictable, structurally-sound code if the orchestration layer enforces typed contracts at every agent boundary and the guardrail layer is non-LLM. Phalanx demonstrates this with a LangGraph state machine, Pydantic-validated agent I/O, and a replayable structured-event audit log.
Enterprises will not deploy autonomous coding agents until they can prove the agent cannot exfiltrate data, execute arbitrary code, or be hijacked by a prompt-injected docstring in the codebase it is modernizing. Phalanx embeds a runtime guardrail layer. This includes: input filter, tool allowlist gateway, egress firewall, SAST output validator. It is between the agent loop and any side-effectful operation. The guardrails run in the orchestrator, not in agent context, so a prompt cannot disable them.
The entire flow from a refactor request to a merge-ready PR runs in a single container in minutes, including test generation and security review. The surrounding system is disciplined enough to ship that code without a human gating every step.
Everything runs in Docker. The host needs only Docker Desktop.
cp .env.example .env # then set ANTHROPIC_API_KEY
docker compose run --rm phalanx-run \
run --target /app/target --out /app/outPhalanx will:
- Read
target/REQUEST.md(a refactor request expressed as a GitHub issue) - Plan, implement, test, and review the change against
target/app.py - On a PASS verdict, emit
out/pr_payload.json: a title/body/diff bundle ready to feed togh pr create - On a FAIL verdict, emit
out/verdict.jsonwith the failing acceptance criteria and exit non-zero - Either way, emit
out/audit.jsonl— one structured event per agent decision, replay-able
The bundled target is a small Flask service with three planted issues: a deprecated @before_first_request decorator, a SQL-injection vulnerability, and a docstring containing a prompt-injection attempt. The injection is there to demonstrate that the input filter neutralizes it without halting the run.
To verify the Docker harness without making model calls on a fresh checkout or for a fork without an API key:
docker compose up phalanx-run # default command is --scaffolddocs/ARCHITECTURE.md: agent state machine and contract schemasdocs/GUARDRAILS.md: runtime security layer specification and threat modeldocs/ROADMAP.md: PR-by-PR build trace, what is done and what is planned
This is an actively-developed reference implementation. The initial scaffold establishes the project shape, the Docker harness, and the target codebase. Agents and guardrails land in successive PRs. Each PR is a single reviewable unit with its own contract tests. CI builds the image and runs the smoke suite on every PR. Dependabot watches pip, Docker, and GitHub Actions for drift.
See open PRs, the PR-history changelog, and the roadmap for the build trace.
MIT. See LICENSE.