{"record":{"id":"8bcf9e745682d718","repo":"Hmbown/CodeWhale","slug":"unsupported-legacy-spillover-ownership-schema","errorCode":null,"errorMessage":"unsupported legacy spillover ownership schema","messagePattern":"unsupported legacy spillover ownership schema","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/tools/truncate.rs","lineNumber":174,"sourceCode":"}\n\npub(crate) fn read_legacy_spillover_ownership(\n    payload_path: &Path,\n) -> io::Result<LegacySpilloverOwnership> {\n    let sidecar = legacy_spillover_ownership_path(payload_path);\n    if std::fs::symlink_metadata(&sidecar)?\n        .file_type()\n        .is_symlink()\n    {\n        return Err(io::Error::new(\n            io::ErrorKind::PermissionDenied,\n            \"legacy spillover ownership sidecar must not be a symlink\",\n        ));\n    }\n    let ownership = serde_json::from_slice::<LegacySpilloverOwnership>(&std::fs::read(sidecar)?)\n        .map_err(|error| io::Error::new(io::ErrorKind::InvalidData, error))?;\n    if ownership.schema_version != LEGACY_SPILLOVER_OWNER_SCHEMA_VERSION {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            \"unsupported legacy spillover ownership schema\",\n        ));\n    }\n    Ok(ownership)\n}\n\n/// Resolve the spillover-file path for a SHA256 content hash. Separate\n/// namespace (`sha_<hex>.txt`) from the tool-call-id files so legacy\n/// SHA-addressed evidence can be recognized without colliding with\n/// tool-call references. Retrieval still requires matching ownership\n/// metadata. `sha` must be the raw 64-char lowercase hex digest —\n/// case-insensitive matching is done by the caller.\n#[must_use]\npub fn sha_spillover_path(sha: &str) -> Option<PathBuf> {\n    let sha = sha.trim().to_ascii_lowercase();\n    if !is_valid_sha256(&sha) {\n        return None;","sourceCodeStart":156,"sourceCodeEnd":192,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/tools/truncate.rs#L156-L192","documentation":"The legacy spillover ownership sidecar parsed successfully, but its schema_version field does not match LEGACY_SPILLOVER_OWNER_SCHEMA_VERSION. The library refuses to interpret an ownership sidecar written by an unknown schema version rather than guess at its layout.","triggerScenarios":"Reading a sidecar whose JSON schema_version differs from the compile-time LEGACY_SPILLOVER_OWNER_SCHEMA_VERSION constant — typically a file written by a newer or older build.","commonSituations":"Downgrading the binary after a schema bump; multiple Codewhale versions sharing the same home directory; a stale sidecar left over from a migration that was never completed.","solutions":["Check the sidecar's schema_version value and compare it against the expected constant in truncate.rs","Upgrade or downgrade Codewhale to the version matching the sidecar's schema","Delete the stale sidecar and let the current version recreate it via its migration path","Manually migrate the sidecar's schema_version if you know the format is otherwise compatible"],"exampleFix":"// before: hard failure on version mismatch\nlet ownership = read_legacy_spillover_ownership(&sidecar)?;\n// after: treat unsupported schema as absent and re-migrate\nlet ownership = read_legacy_spillover_ownership(&sidecar)\n    .or_else(|e| {\n        if e.kind() == io::ErrorKind::InvalidData {\n            recreate_sidecar(&sidecar)\n        } else {\n            Err(e)\n        }\n    })?;","handlingStrategy":"validation","validationCode":"let v: serde_json::Value = serde_json::from_reader(std::fs::File::open(&sidecar)?)?;\nif v.get(\"schema_version\") != Some(&serde_json::json!(LEGACY_SPILLOVER_OWNER_SCHEMA_VERSION)) {\n    // migrate or recreate the sidecar before calling the reader\n}","typeGuard":"fn sidecar_matches_schema(v: &serde_json::Value) -> bool {\n    v.get(\"schema_version\").and_then(|s| s.as_u64()) == Some(LEGACY_SPILLOVER_OWNER_SCHEMA_VERSION)\n}","tryCatchPattern":null,"preventionTips":["Keep a single constant for the schema version and use it on both write and read","Bump the version only with an accompanying migration","Log the found vs expected version when mismatching","Avoid sharing one home directory across different binary versions"],"tags":["io","schema","version-mismatch","migration"],"backgroundTag":"schema-validation-failed","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"}