Skip to content

fix: hold nested self writes to the module ownership rule (#625) - #628

Merged
Shinrai merged 130 commits into
nextfrom
fix/nested-self-assign-ownership
Oct 27, 2026
Merged

Shinrai merged 130 commits into
nextfrom
fix/nested-self-assign-ownership

Conversation

@cldmv-bot

@cldmv-bot cldmv-bot Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🚀 What's Changed

💥 Breaking Changes

No breaking changes

✨ Features

🐛 Bug Fixes

📦 Dependencies

No dependency updates

🔧 Other Changes

👥 Contributors

@cldmv-bot cldmv-bot Bot added ! fix → next v4 flow: fix contributor PR targeting the next integration branch area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure type: documentation Relates to docs, README updates, guides, or inline code comments labels Oct 18, 2026
@cldmv-bot cldmv-bot Bot changed the title chore(types): regenerate declarations fix: hold nested self writes to the module ownership rule (#625) Oct 18, 2026
@cldmv-bot

cldmv-bot Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Auto-normalized PR title: rewrote PR title to match the highest-priority commit type (fix).

  • Before: chore(types): regenerate declarations
  • After: fix: hold nested self writes to the module ownership rule (#625)

If this isn't what you want, edit the title — the normalizer won't re-fire as long as the title stays conventional.

)

A top-level `self.X = …` is refused outside the writing module's mount
point, but a write below it (`self.X.Y = …`) reaches the wrapper at
`self.X` and landed unchecked: a module could replace another module's
member or plant new code under its mount point.

The ownership check now lives in ApiManager#assertOwnedWrite and runs
for the top-level write and for assignment, defineProperty and delete
on any wrapper node, against the member's full api path. Host code,
base-module code, modules sharing a mount point, symbol keys and the
framework's own build keep their existing freedom. A module's own
api.add / remove / reload runs as a framework mutation for that module,
so the framework's writes on its behalf are not taken for the module's.
…red nested nodes under the ownership rule (#625)

A module's own code running while an api.add or remove it started is still
in flight, a second call of the same leaf, and another module writing while
the host runs an api.add are all checked. Setting the prototype of, sealing,
or freezing another module's node is refused with no change made, and a
write through a nested node a module captured, made later with no active
context, is refused as the top-level one is. The framework's own add,
reload, remove, and routine stack installs a module starts below another
module's mount point keep working.
…ites (#625)

The exemption for a module's api.add / remove / reload was a per-leaf count
held until the operation settled, and the build marker exempted every module
for as long as any build ran. Both let module code through: the caller's own
code after a non-awaited add, a second call of the same leaf, and any other
module writing while the host built.

The framework now marks each write it makes for the node it writes, for that
write's synchronous extent only, in both runtimes. Mounting, removal, rebuild,
array integrity sync, and routine stack installs go through it; nothing a
module runs meanwhile can see it.

Setting a node's prototype and making it non-extensible are held to the same
rule as writing its members, checked before anything changes, so a refused
freeze or seal leaves the node as it was.
…dule is executing (#625)

A write through self with no module executing throws
RUNTIME_NO_ACTIVE_CONTEXT_SELF, but a node a module read through self and
wrote into later, outside any call, reached the node with no caller, which
is the host's standing, so it landed.

A node read through self is now a view of it: reads, calls, and enumeration
behave as on the node, and nodes read through it come back as views. A
write, definition, deletion, prototype change, or seal through it is refused
while no module is executing, and otherwise reaches the node, whose own
ownership rule decides. Storing a view stores the node, and the host's api
nodes are untouched. One view per node keeps repeated reads identical.
…ost run/scope writes, unattributable live writes (#625)
…wnership, view descriptors and returns, refuse unattributable live writes (#625)

- One view per (node, reader). With no module executing and outside a host-opened run()/scope(), a write
  through the view goes through only under a path the reading module owns (host reader owns all,
  unattributable reader owns none). A module's own node stays writable from a callback it hands out.
- The view gains getOwnPropertyDescriptor/ownKeys traps, views what a call returns (also once a plain
  promise settles), and passes itself as the receiver, so the raw node no longer leaks through
  descriptors or `this`.
- A host run()/scope() callback writing through self below the top level is the host's, as at the top.
- runtime_assertOwnedWrite refuses with LOOSE_SET_UNATTRIBUTED when the live runtime cannot attribute
  the code, instead of falling back to the store's last-entered caller.
- ApiManager.ownsPath: the non-throwing ownership check assertOwnedWrite now uses.
… receivers held to the caller, removed and restarted readers own nothing (#625)
…ws and live-identity receivers for the caller, keep views across restart, and give a module no longer mounted no ownership (#625)
…caller passed them, and what it keeps or returns stays held to the caller (#625)
… was read from, pass arguments and steered receivers as given, and document the reload ownership window (#625)
…ycle impl and diag hand it views, never another module's node (#625)
…s hooks, lifecycle subscribers and diag calls its own views instead of the api's nodes (#625)
…nd a frozen unloaded node, behave as in eager mode (#625)
…s to in lazy mode, and close an unloaded node with the prototype it reports (#625)
Brings in #656 (#655) and #666 (#661). Two adjustments where the merged code meets:

- runtime_isConstructor asks through a proxy whose construct trap answers, so a class (whose prototype is fixed)
  is a constructor again and nothing of the function is read; #625's own copy of the function is dropped.
- A self view over a module's captured view stands over that view's shadow and forwards every trap to it, so the
  engine's invariant checks never ask the captured view for a fixed member its reader may not read.
…625)

A member a node holds fixed (an element of a frozen array, a member of a
frozen node) is handed out exactly as the node holds it, so the view a
module read it through never saw a later change made through it. A view of
such a member now holds a change made with no standing of its own to the
module that read it, as the module's view of any other member does.

- Captured views refuse such a change outside what their reader owns.
- With permissions or capture off, a module's view of a node works through
  a view that only applies that rule; storing it stores the node itself.
- A closed node lists its keys for a reader denied one of its members.
- The framework's own integrity step on a frozen array is exempt while the
  node is built, so module code can mount a module that exports one.
…625)

A view of a member a node holds fixed reaches module code with no view of
`self` over it. It now hands out every node it reads as a view of the same
kind, and what a call through it returns as the caller's view, as a call
through `self` does, so the ownership rule follows the value down.
…ons are on (#625)

Ownership is still recorded for every path, but a module is refused a write
because of it only while the permission system is on. With no permissions
configured, a module writes anywhere, as before.

Tests that pinned a refusal with permissions off now either run with
permissions on (where the refusal is the point) or assert that the write lands.
… keep a module's view holding across a toggle, and keep the permission namespace and reserved names (#625)

A member a module places through the api a framework payload hands it is
recorded as that module's whether or not permissions are on, so enabling the
system later holds it to the module's ownership. A module's view of a node is
built the same way whether permissions are on or off, and asks at each change
whether ownership applies, so a view read while the system was off holds once
it is enabled.

With permissions off, module code still never changes the permission system's
own namespace, so it cannot drop rules the host registers before enabling the
system, and slothlet, shutdown and destroy are refused when defined or deleted
through self, as when assigned. Freezing a view of a lazy node not loaded yet
now fixes the view's own inspect hook instead of failing.
…e an isolated scope, and refuse unattributed changes through a module's api with permissions off (#625)

Inside a full-isolation scope, module code now reads the framework namespace
through the same view as outside it, over the scope's own copy, so a function
kept from it still runs as the module and the permission namespace stays out
of reach. Assigning slothlet, shutdown or destroy through a scope's self is
refused as outside one. With permissions off, a change the live runtime cannot
attribute, made through the api a module is handed, is refused as it is
through self, rather than recorded as the host's.
…it is reached, and keep an isolated scope's writes and views to the scope (#625)

The permission system's namespace and every member of it are now known by
identity, through the framework's own route proxies too, so module code cannot
change it after storing it under another member of the namespace and reaching
it there. Inside an isolated scope, a member's descriptor hands out the scope's
own copy, so a write through it stays in the scope, and the scope's views of
self refuse to be closed rather than breaking.
…here it is held, whatever reached it (#625)

A change to the permission system's namespace is now refused on the route
proxies the framework serves it through, so module code reaching the raw
namespace as `this` of a function or getter it placed on self.slothlet is
refused like any other. A member that merely holds a reference to the
namespace is no longer kept from being replaced or deleted. The docs note the
limits of a full-isolation scope (#674).
…amework namespace the module's view as this (#625)

A function called through a module's view of the framework namespace now gets
the receiver it was called on, the view, and a getter read through it runs
with the view as this. Kept and used later, outside any call, it still acts as
the module, so it cannot change the permission namespace or turn the system
off. The permission namespace is recognised as the framework's own member, not
by route, so a module's own symbol-keyed object may hold a member named
permissions.
… as that module, and call hook handlers with no receiver (#625)

A function or accessor module code places on the framework namespace now runs
as that module whoever calls it, the host included, with the module's view of
what it is called on as this, so it is never handed the host's namespace.
Module code no longer changes the prototype of the framework's own objects.
Hook handlers are called as plain functions, so a handler is never handed its
own registration. The permission namespace is again recognised by identity
only, and symbol-keyed changes are judged by the member they are made on.
…eeping the framework namespace from module code unless disabled (#625)

The permission system now has three modes, set with `permissions.mode`:
"on" applies every rule; "off", the default with no permissions config (and
what `enabled: false` and `control.disable()` mean), evaluates no rule and
refuses no write on ownership, but still keeps module code from changing the
framework's own namespace, root functions, and keys on api nodes; "disabled"
checks nothing. `control.mode` reports the mode. Calls behave in "off" as they
did with the system off before.

With the namespace kept from module code in "off", the identity tracking and
wrapping of what a module placed on it are no longer needed, and are removed.
@cldmv-bot cldmv-bot Bot added the type: feature Implements new functionality — a PR or issue that adds a feature label Oct 26, 2026
… path, keep the host's mode across a reload, and keep framework keys from a kept view while off (#625)

Whether a write is the framework's own is now decided from the path's first and
last segments, so a write in "off" costs no more than with the system disabled
and nothing is cached per path. A mode the host switched to with
control.enable() / control.disable() holds across reload(). A framework key on a
node changed through a module's view kept and used later is refused while the
system is off, as through a direct write. The permission docs describe what
"off" and "disabled" still evaluate.
@Shinrai
Shinrai merged commit a735230 into next Oct 27, 2026
28 checks passed
@cldmv-bot
cldmv-bot Bot deleted the fix/nested-self-assign-ownership branch October 27, 2026 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Touches core library / runtime source code area: tests Touches test files, fixtures, or test infrastructure ! fix → next v4 flow: fix contributor PR targeting the next integration branch type: documentation Relates to docs, README updates, guides, or inline code comments type: feature Implements new functionality — a PR or issue that adds a feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant