{"record":{"id":"96ecddbf2acb707a","repo":"Hmbown/CodeWhale","slug":"task-generation-has-no-execution-scope","errorCode":null,"errorMessage":"Task generation has no execution scope","messagePattern":"Task generation has no execution scope","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/task_manager.rs","lineNumber":3178,"sourceCode":"                .with_context(|| format!(\"Failed to parse task file {}\", path.display()))?;\n            if task.schema_version > CURRENT_TASK_SCHEMA_VERSION {\n                bail!(\n                    \"Task schema v{} is newer than supported v{}\",\n                    task.schema_version,\n                    CURRENT_TASK_SCHEMA_VERSION\n                );\n            }\n            ensure_safe_storage_id(\"task id\", &task.id)?;\n            if path.file_stem().and_then(|stem| stem.to_str()) != Some(task.id.as_str()) {\n                bail!(\"Task record identity differs from its path\");\n            }\n            if let Some(scope) = &task.execution_scope {\n                validate_execution_id(scope, 64)?;\n            }\n            if let Some(generation) = &task.execution_generation {\n                validate_execution_id(generation, 32)?;\n                if task.execution_scope.is_none() {\n                    bail!(\"Task generation has no execution scope\");\n                }\n            }\n            tasks.insert(task.id.clone(), task);\n        }\n    }\n\n    let mut queue = if queue_path.exists() {\n        let content = fs::read_to_string(queue_path)\n            .with_context(|| format!(\"Failed to read queue file {}\", queue_path.display()))?;\n        let parsed: QueueFile = serde_json::from_str(&content)\n            .with_context(|| format!(\"Failed to parse queue file {}\", queue_path.display()))?;\n        VecDeque::from(parsed.queue)\n    } else {\n        VecDeque::new()\n    };\n\n    queue.retain(|id| {\n        tasks","sourceCodeStart":3160,"sourceCodeEnd":3196,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/task_manager.rs#L3160-L3196","documentation":"When loading persisted tasks, each task may carry an execution_generation (an opaque execution/run identifier). A generation is only meaningful relative to its execution_scope, so deserialization rejects any task record that has a generation but no scope. This is a persisted-state invariant check in the task manager's load path.","triggerScenarios":"Loading tasks from disk/storage where a task's JSON record contains execution_generation set but execution_scope null/absent — e.g. a hand-edited or older/partially-written task file.","commonSituations":"Upgrading from an older schema where generation existed before scope was introduced; manually editing or merging task state files; a serialization bug writing generation without scope.","solutions":["Open the task state file at the storage location and either remove the execution_generation field or add a matching execution_scope.","If caused by a version migration, restore the task file from before the upgrade or re-create the task.","Check for tools/scripts that write task records partially and fix them to always emit scope together with generation."],"exampleFix":"// before (task state file)\n{\"id\": \"a1b2\", \"execution_generation\": \"gen-7\"}\n// after\n{\"id\": \"a1b2\", \"execution_scope\": \"session-1\", \"execution_generation\": \"gen-7\"}","handlingStrategy":"validation","validationCode":"if (task.execution_generation != null && task.execution_scope == null) { throw new Error(\"task record has generation without scope\"); }","typeGuard":"function hasConsistentExecution(t) { return t.execution_generation == null || t.execution_scope != null; }","tryCatchPattern":null,"preventionTips":["Always write execution_scope and execution_generation together when persisting tasks.","Validate task records on write, not only on load.","Version the task state schema and migrate old records explicitly."],"tags":["deserialization","state-corruption","task-management"],"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"}