{"record":{"id":"0b4fbeafb3ec8a8d","repo":"affaan-m/ECC","slug":"baseline-is-not-the-active-harness-configuration","errorCode":null,"errorMessage":"baseline is not the active harness configuration","messagePattern":"baseline is not the active harness configuration","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ecc2/src/session/store.rs","lineNumber":5490,"sourceCode":"            anyhow::bail!(\"valid candidate ids, recorded-v1 evaluator, and bounded evidence reference are required\");\n        }\n        health_evidence.verify()?;\n        if health_evidence.candidate_id != candidate_id || health_evidence.evaluator != evaluator {\n            anyhow::bail!(\"health evidence does not match candidate and evaluator\");\n        }\n        let comparison = policy.compare(samples)?;\n        let tx = self.conn.unchecked_transaction()?;\n        let stored_candidate_id = Self::resolve_harness_candidate_id(&tx, candidate_id)?;\n        let stored_baseline_id = Self::resolve_harness_candidate_id(&tx, baseline_id)?;\n        let active: String = tx\n            .query_row(\n                \"SELECT candidate_id FROM active_harness_config WHERE slot = 'default'\",\n                [],\n                |row| row.get(0),\n            )\n            .context(\"no active baseline configuration\")?;\n        if active != stored_baseline_id {\n            anyhow::bail!(\"baseline is not the active harness configuration\");\n        }\n        let now = chrono::Utc::now().to_rfc3339();\n        if !comparison.passed {\n            tx.execute(\"INSERT INTO harness_evaluations (candidate_id, baseline_id, evaluator, samples_json, policy_json, comparison_json, evidence_ref, legacy_unverifiable, created_at) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, 0, ?8)\", rusqlite::params![stored_candidate_id, stored_baseline_id, evaluator, serde_json::to_string(samples)?, serde_json::to_string(&policy)?, serde_json::to_string(&comparison)?, evidence_ref, now])?;\n            let evaluation_id = tx.last_insert_rowid();\n            tx.execute(\"INSERT INTO harness_eval_audit (event_type, candidate_id, prior_candidate_id, evaluation_id, evidence_ref, legacy_unverifiable, created_at) VALUES ('promotion_rejected', ?1, ?2, ?3, ?4, 0, ?5)\", rusqlite::params![stored_candidate_id, stored_baseline_id, evaluation_id, evidence_ref, now])?;\n            tx.commit()?;\n            return Ok(HarnessPromotionOutcome {\n                evaluation_id: Some(evaluation_id),\n                promoted: false,\n                rolled_back: false,\n                failures: comparison.failures,\n            });\n        }\n        let changed = tx.execute(\"UPDATE active_harness_config SET candidate_id = ?1, updated_at = ?2 WHERE slot = 'default' AND candidate_id = ?3\", rusqlite::params![stored_candidate_id, now, stored_baseline_id])?;\n        if changed != 1 {\n            anyhow::bail!(\"atomic promotion compare-and-swap failed\");\n        }","sourceCodeStart":5472,"sourceCodeEnd":5508,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/ecc2/src/session/store.rs#L5472-L5508","documentation":"Promotion is only evaluated against the configuration that is currently active in slot 'default'. The store reads the active candidate_id and requires it to equal the stored baseline_id from the call; if the active configuration has moved on (someone else promoted, or the wrong baseline was named), the evaluation is refused so a stale baseline is never silently replaced.","triggerScenarios":"Calling evaluate_promote_and_health_check with baseline_id that differs from the candidate currently recorded in active_harness_config (slot 'default'), typically after another promotion already changed the active configuration.","commonSituations":"Concurrent promotions where another process promoted a candidate between your snapshot and your call; passing the candidate you think is deployed rather than reading the actual active id; running a scripted promotion twice — the second run's baseline is now outdated.","solutions":["Read the current active id (active_harness_config, slot 'default') immediately before the call and use it as baseline_id.","Retry the evaluation with the actual current active configuration as the baseline (the compare-and-swap design assumes you re-base on current state).","Serialize promotions through a single coordinator/lock if multiple processes promote concurrently.","Audit harness_eval_audit for recent promotion events to understand who changed the active configuration before your call."],"exampleFix":"// before: hardcoded stale baseline\nstore.evaluate_promote_and_health_check(&cand, &old_baseline, ...)?;\n\n// after: re-base on the live active id\nlet current = store.active_harness_id()?.ok_or_else(|| anyhow!(\"no active baseline\"))?;\nstore.evaluate_promote_and_health_check(&cand, &current, ...)?;","handlingStrategy":"retry","validationCode":"// Re-base on the live active configuration immediately before promoting\nlet current_baseline = store.active_harness_id()?\n    .ok_or_else(|| anyhow!(\"no active baseline configuration\"))?;\n// pass current_baseline as baseline_id, not a cached/stale id","typeGuard":null,"tryCatchPattern":"match store.evaluate_promote_and_health_check(&cand, &baseline, ...) {\n    Err(e) if e.to_string().contains(\"baseline is not the active harness configuration\") => {\n        let current = store.active_harness_id()?.unwrap();\n        store.evaluate_promote_and_health_check(&cand, &current, ...)?\n    }\n    other => other?,\n}","preventionTips":["Read the active id at promotion time instead of caching it from earlier in the run","Serialize promotions through one job/lock to avoid racing operators or CI pipelines","Review harness_eval_audit when this error occurs to see who changed the active slot"],"tags":["concurrency","state-machine","database","rust"],"backgroundTag":"invalid-state-transition","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}