Issue 2026-07-11
v0.8.67
CodeWhale
any model, open models first
The thesis

Three layers of law三层法

As a project ages, instructions pile up and conflict: the original spec, a refactor that contradicts it, stale memory, a previous agent's handoff, your current request, fresh test output that doesn't match what the handoff claimed. A flat system prompt makes the model resolve that by guess. CodeWhale uses a nested constitution so there is a defined rank instead of vibes — the order is enforced in the harness, with tests asserting it can't drift, and it stays intact when you swap models.

New in v0.8.67Constitution-first setup — first launch walks language, model, posture, and your constitution; /setup any time. The model can draft it. You ratify it.
The rank, most-static first
01

Bundled Constitution

compiled into every binary

The base law. Its priority article fixes the authority order for any conflict, so a stale handoff can never outrank a fresh test result by accident.

02

/constitution — your standing law

$CODEWHALE_HOME/constitution.json

Structured data, not a raw prompt editor: guided setup renders it into a model-facing prose block. Drafted with your model's help, ratified by you, and carried across every project.

03

Your repo's law

.codewhale/constitution.json

Protected invariants, branch policy, verification requirements, escalation conditions — loaded as a repo-local authority block above project instructions, memory, and handoffs.

Below the three layers rank project instructions (AGENTS.md), then memory and handoffs. Your current request and live tool evidence still control the active turn — the model may be given many layers, but it may never report a fact the tools did not return.

The honest boundary

Approval, sandbox, network, and trust controls are enforced in code — constitution text never overrides them.

Observable in the reasoning

The rank is not a claim on a landing page. These are faithful excerpts from a real session — the model cites the articles as it decides.

codewhale — thinking
reasoning trace
When the prior session's summary didn't match the real repo state…
 Let me be careful and truthful here. Per Article II (truth) and V (verification), I need to report what's actually in the tree — not what the previous agent claimed.
Article II · TruthArticle V · Verification
Reported the uncommitted work the summary left out, instead of repeating the claim.
codewhale — thinking
reasoning trace
When a “pause” signal conflicted with the user's explicit request to keep going…
 The user's current request outranks the runtime statute — so I keep executing the task, not stopping on a technicality.
Article III · User agencyArticle VII · Hierarchy
Finished the work the user actually asked for.
codewhale — thinking
reasoning trace
When trimming the README, tempted to drop the contributor wall…
 Deleting community credit would break the project's own ethos. Relocate it instead — zero names lost.
Community ethos
Moved 200 lines of credits to docs/CONTRIBUTORS.md and linked from the README.