Merge route continuity B1: a continuity abort cleans its own projection

A continuity abort demotes the shared key to Expected-only with its own
exact activation, and never withdraws the Expected. a148802 is reverted.
Pre-B1 terminal continuity aborts keep their phase under a
LegacySkippedBeforeB1 marker that only the lift can construct. Boot
reconciliation is the single owner of legacy residue and demotes only by
exact identity. Supervision records a failed pre-restart demotion and
defers instead of minting a continuity. Scheduler faults are isolated per
transaction and backed off, reported once and kept in the record. Queued
commands freeze every tick, so one wedged target cannot starve the
others. An unreadable history fails closed for freezing. boot is a
separate, tested step.

Soul made four passes. The first found boot-wedging on legacy records.
The second traced it to Self's ruling to reopen terminal records, which
was replaced with one owner for the cleanup. Pass three found
cross-target starvation, and pass four found fault re-arming. 241 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-29 10:37:54 +02:00
commit a61540b93f
8 changed files with 2839 additions and 362 deletions

View file

@ -312,14 +312,21 @@ observation own current workload health. Historical receipts do not expire
merely because their provider remains admitted longer than the observation
window.
An Expected digest stays stable across continuity restarts, so the current
activation at that projection key can be newer than the activation cached in an
older admitted-generation receipt. During post-fencing rollback, Idunn first
stops the candidate and withdraws the lease. It then verifies any current
projected activation against Idunn's own trust anchor and the exact Expected
record, refuses if a projected write lease remains, and demotes the projection
to Expected-only. The admitted receipt does not overwrite a newer signed
activation, and no operator edits the CultCache projection by hand.
A failed continuity restart leaves its own candidate activation projected under
the shared Expected key. Its abort demotes that key to Expected-only with the
exact activation the transaction issued. Rollback after fencing demotes the
admitted generation's exact activation. No path adopts an activation the
transaction did not issue.
A projection can still hold an activation the abort never resolved: a failure
between preparing a candidate and publishing its observation, an abort written
by an earlier Idunn, or an operator edit. Continuity therefore restarts a
generation only from an Expected-only projection: when its own demotion is
refused it mints no restart, records the deferral in the generation's
continuity backoff, and tries again after it. At boot, Idunn demotes an
activation still projected for a failed continuity in history, by that
transaction's exact activation, and only reports one no failed transaction
issued.
Idunn starts and recovers from its own durable admitted state. Odin is the first
managed semantic daemon, never an Idunn bootstrap dependency. Odin's initial

File diff suppressed because it is too large Load diff

View file

@ -4420,36 +4420,20 @@ impl CultCacheTopologyDriver {
provider_anchor: &ServiceIdentityTrustAnchor,
activation: &IdunnRuntimeActivationRecord,
lease: Option<&IdunnProcessWriteLeaseRecord>,
) -> Result<String> {
self.demote_projection(expected, provider_anchor, Some(activation), lease)
}
fn demote_projection(
&self,
expected: &IdunnExpectedIncarnationRecord,
provider_anchor: &ServiceIdentityTrustAnchor,
activation: Option<&IdunnRuntimeActivationRecord>,
lease: Option<&IdunnProcessWriteLeaseRecord>,
) -> Result<String> {
expected.validate()?;
if let Some(activation) = activation {
activation.validate()?;
ensure!(
activation.expected_projection_sha256 == expected.canonical_sha256()?,
"admitted activation does not bind the admitted Expected projection"
);
}
activation.validate()?;
ensure!(
activation.expected_projection_sha256 == expected.canonical_sha256()?,
"admitted activation does not bind the admitted Expected projection"
);
if let Some(lease) = lease {
validate_topology_lease(
expected,
activation.context("demotion lease has no exact activation")?,
lease,
)?;
validate_topology_lease(expected, activation, lease)?;
}
let anchor = runtime_presence_trust_anchor(expected, provider_anchor)?;
let key = incarnation_key(expected)?;
self.mutate(|entries| {
let projected = ProjectedIncarnation::read(entries, expected, activation, lease)?;
let projected = ProjectedIncarnation::read(entries, expected, Some(activation), lease)?;
let current_anchor = projection_entry(
entries,
GameCultServiceTrustAnchorRecord::TYPE,
@ -4490,55 +4474,6 @@ impl CultCacheTopologyDriver {
expected.canonical_sha256()
}
/// Demote the current projected activation after the owning transaction
/// has fenced the target. A continuity restart can replace the activation
/// under the same Expected key while the admitted-generation receipt still
/// carries the prior runtime instance. In that one post-fence recovery
/// path, trust the current projection only after verifying Idunn's
/// signature and exact Expected binding, and refuse while any projected
/// write lease remains.
pub fn demote_current_activation_to_expected_only(
&self,
expected: &IdunnExpectedIncarnationRecord,
provider_anchor: &ServiceIdentityTrustAnchor,
idunn_anchor: &ServiceIdentityTrustAnchor,
) -> Result<String> {
expected.validate()?;
let entries = self.snapshot()?;
let key = incarnation_key(expected)?;
let projected_activation = projection_entry(
&entries,
IdunnRuntimeActivationRecord::TYPE,
&key,
)?
.map(|envelope| -> Result<IdunnRuntimeActivationRecord> {
ensure!(
envelope.schema_id.as_deref() == Some(IDUNN_RUNTIME_ACTIVATION_SCHEMA),
"projected activation schema is substituted"
);
let activation = IdunnRuntimeActivationRecord::decode_canonical(&envelope.payload)?;
activation.verify_for_expected(expected, idunn_anchor)?;
Ok(activation)
})
.transpose()?;
ensure!(
projection_entry(
&entries,
IdunnProcessWriteLeaseRecord::TYPE,
&key,
)?
.is_none(),
"cannot demote an incarnation while its projected write lease remains"
);
self.demote_projection(
expected,
provider_anchor,
projected_activation.as_ref(),
None,
)
}
/// Whether the projection currently names an activation for this
/// incarnation. Continuity asks so it can tell a projection that still
/// describes a dead incarnation from one already demoted to Expected-only.
@ -4553,6 +4488,22 @@ impl CultCacheTopologyDriver {
)
}
/// The activation the projection currently names under this incarnation's
/// key, if any. Read-only: it never judges whether the activation is the
/// right one, so a caller can tell an exact issuer from a substitute
/// before it demotes anything.
pub fn projected_activation(
&self,
expected: &IdunnExpectedIncarnationRecord,
) -> Result<Option<IdunnRuntimeActivationRecord>> {
let key = incarnation_key(expected)?;
let entries = self.snapshot()?;
projection_entry(&entries, IdunnRuntimeActivationRecord::TYPE, &key)?
.map(|envelope| IdunnRuntimeActivationRecord::decode_canonical(&envelope.payload))
.transpose()
.map_err(Into::into)
}
/// Every incarnation currently projected for one target, by its Expected.
pub fn projected_incarnations(
&self,
@ -8468,7 +8419,7 @@ mod tests {
IDUNN_PROCESS_WRITE_LEASE_SCHEMA, IdunnServiceIdentity,
OdinRuntimeTopologyCorrelationPurpose, OdinTopologyAuthenticationContext,
OdinTopologyIdentity, authenticate_odin_runtime_topology_correlation,
enroll_service_identity_at, open_service_identity_at, verify_runtime_authority,
enroll_service_identity_at, verify_runtime_authority,
};
fn digest(byte: char) -> String {
@ -10918,12 +10869,7 @@ mod tests {
);
assert!(!driver.projected_activation_is_present(&incumbent)?);
let idempotent_bytes = fs::read(&driver.projection_store)?;
driver.demote_to_expected_only(
&incumbent,
&provider_anchor,
&activation,
Some(&lease),
)?;
driver.demote_to_expected_only(&incumbent, &provider_anchor, &activation, Some(&lease))?;
assert_eq!(fs::read(&driver.projection_store)?, idempotent_bytes);
// A record under the incumbent's key that is not the incumbent's is a
@ -10987,104 +10933,6 @@ mod tests {
Ok(())
}
#[test]
fn fenced_demotion_uses_the_current_verified_activation() -> Result<()> {
let temp = tempfile::tempdir()?;
let (expected, admitted_activation, warming, provider_anchor) =
authenticated_warming(temp.path())?;
let idunn = open_service_identity_at::<IdunnServiceIdentity>(&temp.path().join("idunn.cc"))?;
let replacement = IdunnRuntimeActivationLaunch::issue(
&expected,
digest('a'),
300,
&idunn,
)?
.activation()
.clone();
assert_ne!(admitted_activation, replacement);
let driver = topology_driver(temp.path(), "fenced-demotion");
driver.publish_expected(&expected, &provider_anchor)?;
project_activation(&driver, &expected, &admitted_activation)?;
let key = incarnation_key(&expected)?;
upsert_record(
&driver.projection_store,
activation_envelope(&key, &replacement)?,
)?;
assert_eq!(
driver.demote_current_activation_to_expected_only(
&expected,
&provider_anchor,
&idunn.trust_anchor()?,
)?,
expected.canonical_sha256()?
);
assert!(!driver.projected_activation_is_present(&expected)?);
let after = SingleFileMessagePackBackingStore::new(&driver.projection_store)
.pull_all_read_only_snapshot()?;
assert!(after.iter().any(|entry| {
entry.key == key && entry.r#type == IdunnExpectedIncarnationRecord::TYPE
}));
assert!(after.iter().all(|entry| {
!(entry.key == key
&& (entry.r#type == IdunnRuntimeActivationRecord::TYPE
|| entry.r#type == IdunnProcessWriteLeaseRecord::TYPE))
}));
// Expected-only demotion is idempotent when the activation is already
// absent.
let settled = fs::read(&driver.projection_store)?;
driver.demote_current_activation_to_expected_only(
&expected,
&provider_anchor,
&idunn.trust_anchor()?,
)?;
assert_eq!(fs::read(&driver.projection_store)?, settled);
// A record with an invalid Idunn signature is not adopted as current
// authority, even after fencing.
let mut forged = replacement;
forged.runtime_instance_id = digest('b');
upsert_record(
&driver.projection_store,
activation_envelope(&key, &forged)?,
)?;
let before_forgery_attempt = fs::read(&driver.projection_store)?;
assert!(driver
.demote_current_activation_to_expected_only(
&expected,
&provider_anchor,
&idunn.trust_anchor()?,
)
.is_err());
assert_eq!(fs::read(&driver.projection_store)?, before_forgery_attempt);
// A remaining lease means the target has not reached the demotion
// boundary. The operation leaves every byte untouched.
let incumbent_lease = lease(&expected, &admitted_activation, &warming);
upsert_record(
&driver.projection_store,
CultCacheEnvelope {
key: key.clone(),
r#type: IdunnProcessWriteLeaseRecord::TYPE.into(),
payload: incumbent_lease.canonical_bytes()?,
stored_at: "2026-09-03T00:00:00Z".into(),
schema_id: Some(IDUNN_PROCESS_WRITE_LEASE_SCHEMA.into()),
},
)?;
let before_leased_attempt = fs::read(&driver.projection_store)?;
assert!(driver
.demote_current_activation_to_expected_only(
&expected,
&provider_anchor,
&idunn.trust_anchor()?,
)
.is_err());
assert_eq!(fs::read(&driver.projection_store)?, before_leased_attempt);
Ok(())
}
/// A replaced incarnation nothing owns is withdrawn whole; the one still
/// admitted, and the target's anchor, are untouched.
#[test]

View file

@ -22,3 +22,23 @@ the plan is the `deployment_plan` test recipe. No byte comes from a live store.
`control_plane.rs` decodes these through `LegacyDeploymentTransaction` and
`LegacyAdmittedGeneration`. The fixtures die with those structs.
## Pre-B1 continuity aborts
The `transaction-*-abort*` files and `provider-anchor` were printed by a second
throwaway test over `9001b58`. It built a continuity transaction that issued an
activation (the recipe and binding of the `deployment_plan` tests, a provider
identity enrolled fresh, the trust-anchor path in the binding fixed at
`/tmp/idunn-b1-legacy/provider-anchor.cc`) and gave it the aborts the base code
writes: the pre-fence abort literal of `begin_pre_fencing_abort`, and the base
`post_fencing_abort_intent`. In each, the transaction issued an activation and
its abort records `topology_reconciliation = Skipped`, because the base rule
owed a continuity no projection cleanup. The workload and Odin evidence are
borrowed from `transaction-fencing`.
| File | What it is |
|---|---|
| `transaction-pre-fence-abort` | Warming continuity, pre-fencing abort in flight |
| `transaction-pre-fence-abort-terminal` | the same abort finished: Complete, `FailedBeforeFencing` |
| `transaction-post-fence-abort` | Fencing continuity, post-fencing abort in flight |
| `provider-anchor` | one line: the provider trust-anchor file bytes, hex. A test writes it to the fixed path so the Engine can read the plan's anchor |

View file

@ -0,0 +1 @@
93b263756c7463616368652e73746f72652e76319197d93167616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e7631d93167616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e7631d93467616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e76312e7631d93167616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e7631d9967b22736368656d614e616d65223a2267616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e7631222c22736368656d6156657273696f6e223a2267616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e76312e7631222c226d656d62657273223a5b5d7d91d93167616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e7631909194d92867616d6563756c742d70726f76696465722d6865616c74682d6964656e746974792d7075626c6963d93167616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e7631d923323032362d30392d32395430333a34353a31352e3031353232313330302b30303a3030c5014596d93167616d6563756c742e70726f76696465725f6865616c74685f6964656e746974792e74727573745f616e63686f722e7631d94031626661653932326138626630313132373562353536623236393135303363386366643538313234383931373134323365373736663133386463313235376337dc00205858cca9ccbb7dccb9cc8d01cccfccfccc9153ccdbcce23c224bcca757617dcce5cc8a163a6516cc9dccee2c2acce9d92d6f735f696e7374616c6c6174696f6e5f66696c655f626f756e645f636c6f6e6561626c655f626173656c696e65d923323032362d30392d32395430333a34353a31352e3031353232313330302b30303a3030d9477368613235362d63663933623766656534396235313133343736366538613937623432303065653636396338353164386464336634353366623537666664326233366630653430

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long