Hmbown/CodeWhale · error

continual harness state

Error message

continual harness state {} has {} entries; maximum is {MAX_ENTRIES}

What it means

load_state capacity guard: a harness state file on disk holds more than MAX_ENTRIES refinement entries; loading is refused to keep the journal bounded, and the error names the file and its actual entry count. The overfull state file is the input at fault.

Solutions

  1. Prune or archive entries in the state file so it is within MAX_ENTRIES
  2. Call remove to delete individual entries (after temporarily lowering the entry count in the file)
  3. Reset the state file and rebuild the harness

Example fix

// before
// state file with 250 entries when MAX_ENTRIES is 100
// after
jq '.entries = (.entries[:100])' state.json > state.json.tmp && mv state.json.tmp state.json
Defensive patterns

Strategy: validation

Validate before calling

let count = state.entries.len();
if count > MAX_ENTRIES { prune_or_archive(&mut state); }

Prevention

When it happens

Trigger: Calling overview, refine, or remove when state.entries.len() > MAX_ENTRIES in the parsed state file.

Common situations: Very long-lived harness sessions accumulating hundreds of entries, a script that appends entries directly to the JSON, or a hand-edited state file.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22). Data as JSON: /api/errors/202f8418a44c8553. Report an issue: GitHub.

Appendix: source

Thrown at crates/tui/src/continual_harness.rs:267

            return Err(error)
                .with_context(|| format!("read continual harness state {}", path.display()));
        }
    };
    let mut state: HarnessState = serde_json::from_str(&raw)
        .with_context(|| format!("parse continual harness state {}", path.display()))?;
    if state.schema_version == 0 {
        state.schema_version = SCHEMA_VERSION;
    }
    if state.schema_version > SCHEMA_VERSION {
        bail!(
            "continual harness state {} uses newer schema {}; this Codewhale supports schema {}",
            path.display(),
            state.schema_version,
            SCHEMA_VERSION
        );
    }
    if state.entries.len() > MAX_ENTRIES {
        bail!(
            "continual harness state {} has {} entries; maximum is {MAX_ENTRIES}",
            path.display(),
            state.entries.len()
        );
    }
    Ok(state)
}

fn save_state(path: &Path, state: &HarnessState) -> Result<()> {
    let parent = path
        .parent()
        .ok_or_else(|| anyhow!("continual harness state has no parent: {}", path.display()))?;
    fs::create_dir_all(parent)
        .with_context(|| format!("create continual harness directory {}", parent.display()))?;
    let payload = serde_json::to_vec_pretty(state)?;
    let tmp = path.with_extension(format!("{}.tmp", Uuid::new_v4().simple()));
    fs::write(&tmp, payload)
        .with_context(|| format!("write continual harness temporary state {}", tmp.display()))?;

View on GitHub (pinned to 73e0f67d83)