Skip to content

explore: self at module top level (import time) #460

Open

Description

@Shinrai

Summary

Exploratory: should self resolve during a module's top-level evaluation (import time), attributed to that module?

Current behavior

Module files are imported outside any instance context, so a top-level self.* access throws RUNTIME_NO_ACTIVE_CONTEXT_SELF (default async runtime). Example: a file added via api.slothlet.api.add(...) whose body calls self.slothlet.permissions.principal.register(...) fails the add with MODULE_IMPORT_FAILED.

Slothlet api files have always been leaves the host calls; all self use lives inside functions, and routines (initialize, etc.) exist for setup work. So this may be a dead end — top-level code with side effects on the composed api risks ordering errors (the tree is mid-build during import), reload double-execution, and lazy-mode materialization surprises.

Why look at it

Import-time registration would let a scoped api.slothlet.api.reload(moduleID) re-register state the module owns (e.g. #459 principals) with the reloaded code automatically, instead of requiring the module's setup routine to run again.

Questions to answer

  • Can import run inside the instance context with the module's identity, in both runtimes and both modes?
  • What is safely reachable through self while the tree is still being built?
  • Does lazy mode (import on first access) make import-time side effects fire at unpredictable times?
  • Is the routines mechanism already the right answer (document it as such and close)?

Activity

  1. added
    type: enhancementAn improvement to existing functionality without adding a new feature
    priority: lowMinor issue or improvement that can be deferred without impact
    area: coreTouches core library / runtime source code
    on Sep 27, 2026
  2. added theissue type on Sep 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreTouches core library / runtime source codepriority: lowMinor issue or improvement that can be deferred without impactstatus: not startedNot implemented yet — no code exists for thistype: enhancementAn improvement to existing functionality without adding a new feature

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions