{"record":{"id":"44f161071ad75089","repo":"xai-org/grok-build","slug":"leader-does-not-advertise-capabilities-legacy-ver","errorCode":null,"errorMessage":"Leader does not advertise capabilities (legacy version)","messagePattern":"Leader does not advertise capabilities \\(legacy version\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-pager-bin/src/main.rs","lineNumber":445,"sourceCode":"        \"wsUrlSuffix\": d.ws_url_suffix,\n    })\n}\nfn leader_info_json(\n    d: &LeaderDescriptor,\n    reg: &LeaderRegistration,\n    info: Option<&xai_grok_shell::leader::ControlPayload>,\n) -> Result<serde_json::Value> {\n    let mut val = leader_descriptor_json(d);\n    val[\"clientId\"] = serde_json::json!(reg.client_id);\n    if let Some(info) = info {\n        val[\"info\"] = serde_json::to_value(info)?;\n    }\n    Ok(val)\n}\nfn ensure_control_caps(reg: &LeaderRegistration) -> Result<&LeaderCapabilities> {\n    reg.leader_capabilities\n        .as_ref()\n        .ok_or_else(|| anyhow::anyhow!(\"Leader does not advertise capabilities (legacy version)\"))\n}\n/// Env override for the `grok workspace` gate: any truthy value enables the\n/// command locally, a falsy one disables it — bypassing the remote settings flag.\nconst WORKSPACE_COMMAND_ENV: &str = \"GROK_WORKSPACE_COMMAND\";\n/// Resolution of the `grok workspace` gate. `Unknown` is kept separate from\n/// `Disabled` so we don't tell the user the flag is off when the settings were\n/// simply never read (both fail closed, but `Unknown` earns an honest message).\n#[derive(Debug, PartialEq, Eq)]\nenum WorkspaceGate {\n    Enabled,\n    Disabled,\n    Unknown,\n}\n/// The `GROK_WORKSPACE_COMMAND` override, if set (`Some(true)`/`Some(false)`);\n/// `None` defers to the remote settings flag.\nfn workspace_command_env_override() -> Option<bool> {\n    std::env::var(WORKSPACE_COMMAND_ENV)\n        .ok()","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-pager-bin/src/main.rs#L427-L463","documentation":"ensure_control_caps requires the leader registration to include leader_capabilities; a leader from a legacy (older) build omits that field, so the capability negotiation cannot proceed and this error is raised. It is a forward-compatibility guard, not a runtime fault.","triggerScenarios":"Calling ensure_control_caps (via run_leader_mgmt or ensure_workspace_caps) on a LeaderRegistration whose leader_capabilities field is None — i.e. the running leader predates the capabilities-advertisement protocol.","commonSituations":"Mixed-version setup: an old grok binary still running as leader while the pager/CLI was updated; leader started before a version upgrade and never restarted.","solutions":["Restart the leader with an up-to-date grok build that advertises leader_capabilities","Kill stale leader processes from older versions and start a fresh session","Align versions of the pager CLI and the leader so both speak the capabilities protocol"],"exampleFix":"// before\n$ grok workspace status   # old leader binary from v1.2 still running\n// after\n$ pkill -f old-grok-leader && grok workspace start   # fresh, current-version leader","handlingStrategy":"type-guard","validationCode":"fn leader_supports_caps(reg: &LeaderRegistration) -> bool {\n    reg.leader_capabilities.is_some()\n}\nif !leader_supports_caps(reg) {\n    eprintln!(\"leader is a legacy build; restart with a current grok version\");\n}","typeGuard":"fn has_capabilities(reg: &LeaderRegistration) -> bool {\n    reg.leader_capabilities.is_some()\n}","tryCatchPattern":"match ensure_control_caps(reg) {\n    Ok(caps) => { /* proceed with caps */ }\n    Err(e) if e.to_string().contains(\"legacy version\") => {\n        eprintln!(\"leader too old: {e}. Restart the leader with an updated grok binary.\");\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep leader and CLI binaries on the same version","Restart long-running leader processes after upgrades","Check registration.leader_capabilities before invoking capability-dependent commands","Pin versions in shared/CI environments to avoid mixed-version fleets"],"tags":["version-mismatch","capabilities","leader","compatibility"],"backgroundTag":"leader-capability-negotiation-failed","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}