affaan-m/ECC · error · anyhow::Error
an active harness configuration already exists
Error message
an active harness configuration already exists
What it means
activate_initial_harness is one-shot: it requires that no row exists in active_harness_config for slot 'default'. A second initial activation is refused — subsequent harness changes must go through the promotion path, not re-initialization.
Source
Thrown at ecc2/src/session/store.rs:5416
pub fn activate_initial_harness(&self, candidate_id: &str, evidence_ref: &str) -> Result<()> {
if candidate_id.len() != 64 || evidence_ref.trim().is_empty() || evidence_ref.len() > 4096 {
anyhow::bail!(
"valid candidate id and bounded activation evidence reference are required"
);
}
let tx = self.conn.unchecked_transaction()?;
let stored_candidate_id = Self::resolve_harness_candidate_id(&tx, candidate_id)?;
if tx
.query_row(
"SELECT candidate_id FROM active_harness_config WHERE slot = 'default'",
[],
|row| row.get::<_, String>(0),
)
.optional()?
.is_some()
{
anyhow::bail!("an active harness configuration already exists");
}
let now = chrono::Utc::now().to_rfc3339();
tx.execute("INSERT INTO active_harness_config (slot, candidate_id, updated_at) VALUES ('default', ?1, ?2)", rusqlite::params![stored_candidate_id, now])?;
tx.execute("INSERT INTO harness_eval_audit (event_type, candidate_id, evidence_ref, legacy_unverifiable, created_at) VALUES ('initial_activation', ?1, ?2, 0, ?3)", rusqlite::params![stored_candidate_id, evidence_ref, now])?;
tx.commit()?;
Ok(())
}
#[cfg(test)]
pub fn active_harness_id(&self) -> Result<Option<String>> {
let stored = self
.conn
.query_row(
"SELECT candidate_id FROM active_harness_config WHERE slot = 'default'",
[],
|row| row.get(0),
)
.optional()?;View on GitHub (pinned to 01e15490f0)
Solutions
- Use promote_harness (the compare-and-swap path) for any change after the first activation.
- If you genuinely need to re-initialize, drop the active_harness_config 'default' row first as an explicit, audited reset.
- Guard activation behind an 'is this the first activation?' check that queries active_harness_config.
Defensive patterns
Strategy: validation
Validate before calling
fn has_active_harness(conn: &rusqlite::Connection) -> Result<bool> {
let row: Option<String> = conn.query_row(
"SELECT candidate_id FROM active_harness_config WHERE slot = 'default'",
[], |r| r.get(0)).optional()?;
Ok(row.is_some())
}
if has_active_harness(&conn)? {
// do not call activate_initial_harness; use promote_harness instead
return Err(anyhow::anyhow!("harness already active; use promote path"));
} Type guard
fn initial_activation_allowed(conn: &rusqlite::Connection) -> bool {
!has_active_harness(conn).unwrap_or(true)
} Try / catch
match store.activate_initial_harness(&candidate_id, &evidence_ref) {
Ok(()) => { /* first activation done */ }
Err(e) if e.to_string().contains("active harness configuration already exists") => {
// switch to the promotion flow instead of re-initializing
}
Err(e) => return Err(e),
} Prevention
- Treat activate_initial_harness as bootstrap-only; gate it behind a setup phase that runs once.
- In tests, reset active_harness_config between cases so activation is reproducible.
- Make deployment scripts idempotent by checking for an active config before calling activate.
When it happens
Trigger: Calling activate_initial_harness when SELECT candidate_id FROM active_harness_config WHERE slot='default' already returns a row.
Common situations: Re-running setup/bootstrap on an already-initialized store; calling activate twice in a test without resetting the DB; a deployment script that re-runs initialization idempotently.
Related errors
- harness health evidence is inconsistent with audit outcome
- candidate alias collision with physical candidate id
- candidate alias collision with different immutable target
- legacy candidate id collision with different immutable conte
- candidate id collision with different immutable content
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/dc76d9cc2e3d86fc.
Report an issue: GitHub.