Skip to content

Parented child Erns are nondeterministic and drop the child's root (Ern + Ern derivation) #12

Description

@rrrodzilla

Problem

When an actor is created with a parent reference, its effective id is computed as child_id = parent_id + id (actor_config.rs:94). With acton-ern 2.0.0, impl Add for Ern keeps only self's root and appends rhs's parts — and an Ern::with_root(..) has empty parts. Two consequences:

  1. The child's root is discarded. A child created as ActorConfig::new(Ern::with_root("worker")?, Some(parent), ..) does not get a parent/worker-style id; the "worker" root vanishes entirely.
  2. The derived id is nondeterministic. The addition re-derives the root through a fresh MagicTypeId, so the same parent_id + recorder_id computed twice yields two different Erns (observed empirically: root brokerpanicsupervisor_kxaemqfcatebgyef gained a second, fresh ULID-style suffix per derivation). Deriving the "same" child id twice never produces equal keys.

Impact

  • Hierarchical identifiers documented as parent/worker do not actually contain the child segment.
  • Anything keyed by a child's Ern (e.g. the broker's subscriber set, which uses Ern-based Eq/Hash on ActorHandle) cannot be re-derived or matched deterministically for parented actors.
  • Because a parented child's id collapses to a re-suffix of the parent's id, a terminating child's RemoveAllSubscriptions { subscriber_id: self.id } could in principle interact with entries related to the parent's id lineage. (The fresh-suffix nondeterminism currently makes exact collisions unlikely, which cuts both ways: no accidental removal, but also no deterministic identity.)

How this surfaced

While writing the broker-purge regression test for #11, a precondition assert_eq! on two identically-derived child ids failed; test had to be restructured to use parentless actors, whose ids are stable. See acton-reactive/tests/panic_termination_tests.rs::test_panicked_actor_is_unsubscribed_from_broker (doc comment records the constraint).

Suggested fix

Decide the intended child-id contract (e.g. parent_id with the child's root appended as a part, deterministically) and either fix the Add usage in ActorConfig::new / acton-ern, or construct the hierarchical id explicitly instead of using +.

Found during remediation of #11 (v8.1.1 + pending fix branches).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions