Skip to content

core(actor): rebuild from kameo reference — Actor trait, lifecycle hooks, run-loop #116

Description

@joeldsouzax

Part of the core-rebuild epic — follows the shared rigor contract there.

Component

src/actor.rs, src/actor/spawn.rs, src/actor/kind.rs (~1,983 LOC). The Actor trait, lifecycle hooks (on_start/on_panic/on_stop), spawn, and the receive loop.

Learning & discussion

The loop is identity-agnostic — it survives the identity-first inversion unchanged in spirit (it just runs whatever bears the identity). A panic in a handle is actor-internal: caught and routed to on_panic; it is NOT observable via should_panic (see core-wiring latent-defects note) — probe via an on_panic observer.

Existing crates

tokio task/JoinHandle, tokio-util CancellationToken for cooperative abort (#55), futures.

Research — best algorithm/approach

Actor run-loop patterns; panic isolation (catch_unwind / task boundary); guaranteed ordering of lifecycle hooks; cooperative cancellation vs abort.

Testing — hard as fuck

Lifecycle (start → panic → restart → stop ordering; panic in on_start), sequence, defensive boundary. DST over scheduling + abort races. loom where atomics touch the run-state. Mutation: cargo-mutants, zero survivors.

Absorbs

#55 (tokio-util CancellationToken for task abort).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions