Skip to content

feat(project): deprecate WHALE.md; add .codewhale/constitution.json authority layer (v0.8.53)#2688

Merged
Hmbown merged 2 commits into
codex/v0.8.53from
codex/v0.8.53-deprecate-whale-md
Jun 3, 2026
Merged

feat(project): deprecate WHALE.md; add .codewhale/constitution.json authority layer (v0.8.53)#2688
Hmbown merged 2 commits into
codex/v0.8.53from
codex/v0.8.53-deprecate-whale-md

Conversation

@Hmbown
Copy link
Copy Markdown
Owner

@Hmbown Hmbown commented Jun 3, 2026

Part of the v0.8.53 cutover. Splits repo-level guidance into two clear artifacts and deprecates the confusing WHALE.md concept (it overlapped with AGENTS.md and 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.mddeprecated, legacy fallback only.

WHALE.md migration (compat-preserving)

  • AGENTS.md now ranks above WHALE.md in both project and global discovery — with both present, AGENTS.md wins (rationale: stop the overlap).
  • WHALE.md is still read as a legacy fallback, but now emits a deprecation warning and is never created or recommended (/init no longer suggests it).
  • Eventual removal from default discovery is left for a future release (point 7 of the migration plan) — not done here.

constitution.json

  • New RepoConstitution (serde; all fields optional; unknown fields ignored; schema_version checked with a best-effort warning on mismatch). 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/* + !**/.codewhale/constitution.json). init.rs writes the same pattern for new repos. This repo's own .codewhale/constitution.json added as dogfood.
  • find_git_root made pub(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 --bins3946 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)

  • Removing the silent auto-generation of .codewhale/instructions.md (an agent suggested /init should be the only thing that writes instruction files) — deliberately not changed here to keep the PR focused; tracked as a follow-up.
  • Aligns with the design in PR docs: v0.8.53 tool-surface-diet design + north-star direction (#2681, #2680) #2686 (docs/VISION_NORTH_STAR.md command-surface taxonomy: /memory small, /context dashboard, /rules, .codewhale/constitution.json authority).

🤖 Generated with Claude Code

…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.
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmbown has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +262 to +263
if path.is_file() {
match fs::read_to_string(&path) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.
Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmbown has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@Hmbown Hmbown merged commit fc8ad7b into codex/v0.8.53 Jun 3, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant