Skip to content

task layer: a task cannot learn its own id (no task_self) — blocks message-link supervision #526

Description

@InauguralPhysicist

Surfaced by

Building lib/supervise.eigs (#409). Filed per the forcing-function model — surfacing the gap rather than working around it.

The gap

A cooperative task (#408) has no way to obtain its own task id. task_spawn returns the child's id to the parent, but a task cannot discover its own — there is no task_self. So a worker cannot hand its supervisor a return address, which is exactly what the BEAM-style link pattern needs (a worker delivers its exit/throw as a message to the supervisor's mailbox).

lib/supervise.eigs works today without it: cooperative tasks share the module-global heap on one thread, so the supervisor reads workers' progress and completion out of shared state rather than via messages. But the message-link variant the #409 issue sketches ("task exit/throw delivered as an ordinary message") is not expressible — a worker has no id to send to until something tells it, and nothing can tell it its supervisor's id without the supervisor knowing its own id to pass down.

Proposal

  • task_self of null → the current task's id (the same integer space task_spawn returns; the main task gets a stable id too). Pure and deterministic under the seeded scheduler — it reads the current task id, not a nondeterminism source, so no tape participation is needed. The extend-vm checklist applies (new builtin registration, docs, the discoverability gate, SPEC "Cooperative tasks").

Payoff

Unblocks message-link supervision (lib/supervise.eigs could offer a link-based mode alongside the shared-state one), and the general "reply to whoever spawned/messaged me" pattern that mailboxes otherwise can't express.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions