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 with a defined rank. The harness enforces the order, tests assert it can't drift, and it stays intact when you swap models.

Since v0.9.0

Constitution-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

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 is instructed never to report a fact the tools did not return.

  1. 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.

  2. /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.

  3. 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.

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.

Reasoning traceWhen the prior session's summary didn't match the repo…
Per Article II (truth) and V (verification), I 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.

Reasoning traceWhen a “pause” signal conflicted with the user's request to continue…
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.

Reasoning traceWhen 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.