You signed in with another tab or window. Reload to refre
8000
sh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Docs: write down the ownership rules and the layering rules #53
The rules below are what the code mostly follows. Where the code does not
follow them, the difference is work rather than taste. Nothing states them
today.
The rules for a native resource
A CoreValue, a CoreEvalState and a CoreLockedFlake are confined to
one evaluator thread. Every call reaches them through the NixThreadExecutor of that evaluator.
A CoreStore is thread-safe, and the store pool may share it.
Every native resource has exactly one owner, and the owner is the object
that created it.
Dependencies point from the right to the left only. _core never imports an
engine. An engine never imports the other engine.
One exception is permanent, and it must stay documented at the import site: rpc/client/_pool.py imports rpc/worker/_worker.worker_service_factory,
because the forkserver pickles it by module path.
Scope
Put the rules for a native resource in the module docstring of _core/_objects.py. Put both sets in docs/nanopynix/architecture-principles.md.
with Dependencies point right to left only, the two named rules
(_core never imports an engine, An engine never imports the other
engine), and the permanent worker_service_factory` exception.
The five rules for a native resource are under ## Native resource ownership.
The module docstring of _core/_objects.py -- three rules short
nanopynix/src/nanopynix/_core/_objects.py has an 18-line docstring. It
carries rule 1 and rule 2:
The public inproc API may share a CoreStore across Store-pool
threads, but each CoreEvalState and its values remain confined to one
evaluator thread.
The rest of the docstring explains why the class is named Core and not Local, which is worth keeping and is not one of these rules.
Rules 3, 4 and 5 are not there:
Every native resource has exactly one owner, and the owner is the object
that created it. (The docstring says the objects "own L1 bindings", which
is not the same statement.)
Dropping the Python handle releases the native resource, on both engines,
with no action by the caller.
A finalizer never calls Nix. A finalizer queues, and the next operation on
the owning thread drains the queue.
What is left
Add rules 3, 4 and 5 to the docstring of _core/_objects.py. Nothing else in
this issue needs work.
#40, which rule 4 refers to, is closed, so the behaviour that rule 4 states
exists and is only undocumented at that site.
Activity
Lillecarl commentedon Aug 7, 2026
Half of this issue is already done
Checked on 2026-08-07 against the tree.
docs/nanopynix/architecture-principles.md-- completeThe file carries both sets of rules that this issue asks for. The layering
rule is there, in the shape this issue gives it:
with
Dependencies point right to left only, the two named rules(
_corenever imports an engine,An engine never imports the otherengine
), and the permanentworker_service_factory` exception.The five rules for a native resource are under
## Native resource ownership.The module docstring of
_core/_objects.py-- three rules shortnanopynix/src/nanopynix/_core/_objects.pyhas an 18-line docstring. Itcarries rule 1 and rule 2:
The rest of the docstring explains why the class is named
Coreand notLocal, which is worth keeping and is not one of these rules.Rules 3, 4 and 5 are not there:
that created it. (The docstring says the objects "own L1 bindings", which
is not the same statement.)
with no action by the caller.
the owning thread drains the queue.
What is left
Add rules 3, 4 and 5 to the docstring of
_core/_objects.py. Nothing else inthis issue needs work.
#40, which rule 4 refers to, is closed, so the behaviour that rule 4 states
exists and is only undocumented at that site.