feat(project): deprecate WHALE.md; add .codewhale/constitution.json authority layer (v0.8.53)#2688
Conversation
…uthority layer Splits repo-level guidance into two clear artifacts and deprecates the confusing WHALE.md concept (overlapped with AGENTS.md): - AGENTS.md is the canonical cross-agent project-instructions file. - .codewhale/constitution.json is the CodeWhale-specific repo authority / prioritization policy (when local sources conflict, which to trust first; what to verify before claiming done). Rendered into the system prompt as a higher-authority <codewhale_repo_constitution> block; takes precedence over a legacy WHALE.md. WHALE.md migration (compat-preserving): - AGENTS.md now ranks above WHALE.md in both project and global discovery; with both present, AGENTS.md wins. - WHALE.md is still read as a legacy fallback, but now emits a deprecation warning and is never created or recommended (init.rs no longer suggests it). - Discovery/docs updated; the global CodeWhale Constitution in prompts/base.md is unaffected (different thing). constitution.json: - New RepoConstitution (serde, all fields optional, unknown fields ignored, schema_version checked). Discovered at .codewhale/constitution.json in the workspace or any parent up to the git root. Malformed JSON warns, never panics. - Loaded after the auto-generate fallback so it can't be clobbered. .gitignore: ignore .codewhale/ contents at any depth EXCEPT the committed constitution.json (a directory exclude can't be negated, so **/.codewhale/* + negation). init.rs writes the same pattern for new repos. Dogfood: this repo's .codewhale/constitution.json added. find_git_root made pub(crate) and reused (no duplicate loader). Tests: AGENTS-over-WHALE precedence, WHALE legacy-read-with-warning, constitution render + system-block surfacing, malformed-constitution warning, gitignore-keeps-constitution. cargo test -p codewhale-tui --bins → 3946 passed; clippy clean. Targets codex/v0.8.53.
There was a problem hiding this comment.
Hmbown has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
There was a problem hiding this comment.
Code Review
This pull request introduces a new CodeWhale-specific repo authority and prioritization policy loaded from .codewhale/constitution.json, which is rendered as a higher-authority block in the system prompt. It also deprecates the legacy WHALE.md in favor of AGENTS.md for cross-agent project instructions. The .gitignore handling is updated to ignore other .codewhale/ runtime state while keeping constitution.json committable. Feedback suggests adding a file size limit check when reading .codewhale/constitution.json to prevent potential out-of-memory issues or high latency.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if path.is_file() { | ||
| match fs::read_to_string(&path) { |
There was a problem hiding this comment.
To prevent potential Out Of Memory (OOM) crashes or high latency when loading extremely large or malformed files, it is recommended to enforce a size limit check on the .codewhale/constitution.json file before reading it entirely into memory, similar to how other context files are loaded via load_context_file.
if path.is_file() {
if let Ok(metadata) = fs::metadata(&path) {
if metadata.len() > MAX_CONTEXT_SIZE as u64 {
warnings.push(format!(
"Constitution file {} is too large ({} bytes, max {})",
path.display(),
metadata.len(),
MAX_CONTEXT_SIZE
));
return (None, warnings);
}
}
match fs::read_to_string(&path) {…scalation) Per the layered-authority clarification (base myth → global Constitution → repo constitution = local law → task packet → runtime policy), extend .codewhale/constitution.json beyond authority+verification with optional: - protected_invariants — repo invariants the agent must not break - branch_policy — branch/release policy in effect - escalate_when — conditions to stop and escalate to the user All optional; rendered as concise model-facing prose. The global Brother Whale identity anchor and Constitution in prompts/base.md are unchanged (verified untouched on this branch). Dogfood constitution.json filled with CodeWhale's real invariants (prefix-cache byte-stability, transcript replay, stable Rust, cli/tui parity), branch policy (codex/v0.8.53), and escalation rules. Docs note the layered hierarchy. cargo test -p codewhale-tui --bins → 3946 passed; clippy clean.
There was a problem hiding this comment.
Hmbown has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Part of the v0.8.53 cutover. Splits repo-level guidance into two clear artifacts and deprecates the confusing
WHALE.mdconcept (it overlapped withAGENTS.mdand sounded like CodeWhale-native authority — which now has a real home).The model
AGENTS.md— canonical cross-agent project instructions (prose, for humans and any agent)..codewhale/constitution.json— CodeWhale-specific repo authority / prioritization policy (JSON): when local sources conflict, which to trust first, and what to verify before claiming done..codewhale/lives inside the repo like.github/. Rendered into the system prompt as a higher-authority<codewhale_repo_constitution>block.prompts/base.md— the global CodeWhale Constitution. Unaffected (different thing).WHALE.md— deprecated, legacy fallback only.WHALE.md migration (compat-preserving)
AGENTS.mdnow ranks aboveWHALE.mdin both project and global discovery — with both present,AGENTS.mdwins (rationale: stop the overlap).WHALE.mdis still read as a legacy fallback, but now emits a deprecation warning and is never created or recommended (/initno longer suggests it).constitution.json
RepoConstitution(serde; all fields optional; unknown fields ignored;schema_versionchecked with a best-effort warning on mismatch). Discovered at.codewhale/constitution.jsonin the workspace or any parent up to the git root. Malformed JSON warns, never panics. Loaded after the auto-generate fallback so it can't be clobbered..gitignore: ignore.codewhale/contents at any depth except the committedconstitution.json(a directory exclude can't be negated, so**/.codewhale/*+!**/.codewhale/constitution.json).init.rswrites the same pattern for new repos. This repo's own.codewhale/constitution.jsonadded as dogfood.find_git_rootmadepub(crate)and reused — no duplicate loader.Files
crates/tui/src/project_context.rs,project_doc.rs,commands/init.rs,docs/CONFIGURATION.md,.gitignore,.codewhale/constitution.json.Verification
cargo test -p codewhale-tui --bins→ 3946 passed, 0 failed. New tests: AGENTS-over-WHALE precedence, WHALE legacy-read-with-deprecation-warning, constitution render + system-block surfacing, malformed-constitution warns-not-crashes, gitignore-keeps-constitution.cargo clippy -p codewhale-tui --bins→ clean.Notes / not in this PR (tracked as follow-ups)
.codewhale/instructions.md(an agent suggested/initshould be the only thing that writes instruction files) — deliberately not changed here to keep the PR focused; tracked as a follow-up.docs/VISION_NORTH_STAR.mdcommand-surface taxonomy:/memorysmall,/contextdashboard,/rules,.codewhale/constitution.jsonauthority).🤖 Generated with Claude Code