{"record":{"id":"202f8418a44c8553","repo":"Hmbown/CodeWhale","slug":"continual-harness-state-has-entries-maximum","errorCode":null,"errorMessage":"continual harness state {} has {} entries; maximum is {MAX_ENTRIES}","messagePattern":"continual harness state (.+?) has (.+?) entries; maximum is (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/continual_harness.rs","lineNumber":267,"sourceCode":"            return Err(error)\n                .with_context(|| format!(\"read continual harness state {}\", path.display()));\n        }\n    };\n    let mut state: HarnessState = serde_json::from_str(&raw)\n        .with_context(|| format!(\"parse continual harness state {}\", path.display()))?;\n    if state.schema_version == 0 {\n        state.schema_version = SCHEMA_VERSION;\n    }\n    if state.schema_version > SCHEMA_VERSION {\n        bail!(\n            \"continual harness state {} uses newer schema {}; this Codewhale supports schema {}\",\n            path.display(),\n            state.schema_version,\n            SCHEMA_VERSION\n        );\n    }\n    if state.entries.len() > MAX_ENTRIES {\n        bail!(\n            \"continual harness state {} has {} entries; maximum is {MAX_ENTRIES}\",\n            path.display(),\n            state.entries.len()\n        );\n    }\n    Ok(state)\n}\n\nfn save_state(path: &Path, state: &HarnessState) -> Result<()> {\n    let parent = path\n        .parent()\n        .ok_or_else(|| anyhow!(\"continual harness state has no parent: {}\", path.display()))?;\n    fs::create_dir_all(parent)\n        .with_context(|| format!(\"create continual harness directory {}\", parent.display()))?;\n    let payload = serde_json::to_vec_pretty(state)?;\n    let tmp = path.with_extension(format!(\"{}.tmp\", Uuid::new_v4().simple()));\n    fs::write(&tmp, payload)\n        .with_context(|| format!(\"write continual harness temporary state {}\", tmp.display()))?;","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/continual_harness.rs#L249-L285","documentation":"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.","triggerScenarios":"Calling overview, refine, or remove when state.entries.len() > MAX_ENTRIES in the parsed state file.","commonSituations":"Very long-lived harness sessions accumulating hundreds of entries, a script that appends entries directly to the JSON, or a hand-edited state file.","solutions":["Prune or archive entries in the state file so it is within MAX_ENTRIES","Call remove to delete individual entries (after temporarily lowering the entry count in the file)","Reset the state file and rebuild the harness"],"exampleFix":"// before\n// state file with 250 entries when MAX_ENTRIES is 100\n// after\njq '.entries = (.entries[:100])' state.json > state.json.tmp && mv state.json.tmp state.json","handlingStrategy":"validation","validationCode":"let count = state.entries.len();\nif count > MAX_ENTRIES { prune_or_archive(&mut state); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Periodically prune old harness entries via remove","Never hand-append entries to the state JSON","Monitor entry count as your harness runs"],"tags":["state-file","limit-exceeded","validation"],"backgroundTag":"value-out-of-range","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}