affaan-m/ECC · error

an active harness configuration already exists

Error message

an active harness configuration already exists

What it means

activate_initial_harness only allows the first activation of a harness configuration. If a row already exists in active_harness_config for slot 'default', the initial activation is refused; subsequent changes must go through the evaluate/promote (compare-and-swap) path rather than the initial-activation path.

Solutions

  1. If the goal is to change the active harness, use evaluate_promote_and_health_check (promotion with evidence) instead of activate_initial_harness.
  2. Verify current state by querying active_harness_config WHERE slot = 'default' before attempting initial activation.
  3. If the existing active configuration is invalid and you truly need to re-initialize, clear the active_harness_config row (and audit accordingly) in a deliberate migration, then call activate_initial_harness.
  4. Use a fresh store/database if you intended a brand-new harness lifecycle rather than continuing an existing one.

Example fix

// before: re-initializing an already-activated store
store.activate_initial_harness(&candidate_id, &evidence)?; // already active

// after: guard first, promote instead
if store.active_harness_id()?.is_none() {
    store.activate_initial_harness(&candidate_id, &evidence)?;
} else {
    // change via promotion flow
    store.evaluate_promote_and_health_check(...)?;
}
Defensive patterns

Strategy: validation

Validate before calling

// Only call activate_initial_harness when nothing is active yet
if store.active_harness_id()?.is_some() {
    // switch via promotion flow instead
    return Err(anyhow!("harness already active; use promotion flow"));
}
store.activate_initial_harness(&candidate_id, &evidence_ref)?;

Prevention

When it happens

Trigger: Calling activate_initial_harness when the active_harness_config table already contains a row for slot 'default', i.e. a harness was previously activated in this store/database.

Common situations: Re-running an initialization script against a database that was already initialized; pointing a new tool run at a shared/migrated SQLite file with existing harness state; trying to reset the active configuration via the initial-activation API instead of the promotion flow.

Understand the failure class

Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/dc76d9cc2e3d86fc. Report an issue: GitHub.

Appendix: 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 8321021c54)