8000 API: the public surface disagrees with itself · Issue #44 · nixidae/nixidae · GitHub
[go: up one dir, main page]

Skip to content

API: the public surface disagrees with itself #44

Closed

Description

@Lillecarl

Names that work are in no __all__, the two __all__ lists disagree in both
directions, and one exception class sits outside the taxonomy.

Evidence

  • 20 names are importable from nanopynix and absent from its __all__.
    Among them: EvalError, EvalSessionClosedError, ForeignValueError,
    InfiniteRecursionError, MissingArgumentError, LogCapture,
    LogCollector, LogEvent, Derivation, BuildResult, EvalState,
    DEFAULT_EXPERIMENTAL_FEATURES.
  • 3 exception classes defined in exceptions.py are absent from its
    __all__: ListIndexError, MissingAttributeError, SettingNotLiveError.
    The first two are in nanopynix.__all__, so the two lists disagree in both
    directions.
  • WorkerDiedError (rpc/client/_pool.py:94) is a bare RuntimeError. It is
    not a NixError, not an ObjectMisuseError, and not in
    nanopynix.__all__. A caller who writes except nanopynix.NixError around
    an rpc call is not protected against the failure mode that the engine exists
    to produce.
  • Session.subscribe(self, callback: Any) -> Any
    (rpc/client/session.py:345) is untyped, and the inproc engine's own
    subscribe returns BusSubscription (inproc/_impl.py:547). The two
    engines disagree on the return type of a method that the parity ledger
    treats as shared.
  • Nix = Session (rpc/client/session.py:467), labelled "Backward-compatible
    alias", is exported and used by one test. ROADMAP.md says backwards
    compatibility is not a priority.
  • inproc.Store.call(method, *args, **kwargs) -> Any (inproc/_impl.py:908)
    is an untyped escape hatch with one caller, a test.

EvalError is the base of half the exception tree, and
except nanopynix.EvalError is what a caller reaches for first. It is
importable, it works, and it appears in no __all__ and in no generated
document. A name in that state is neither supported nor removable.

Scope

  • Adopt one rule: __all__ is the public surface, and every entry has a
    documented home.
    Add the names that belong. Make the rest private by a
    rename or by removal.
  • Add an EngineError(RuntimeError) base to nanopynix.exceptions, and put
    WorkerDiedError(EngineError) under it. Export both from nanopynix. Keep
    nanopynix.rpc.WorkerDiedError as an alias. State in the class docstring
    that the inproc engine cannot raise it, and why.
  • Make exceptions.__all__ complete.
  • Type Session.subscribe as WorkerClient.subscribe already is.
  • Delete Nix, and update the one test.
  • Delete inproc.Store.call and its test, or document it as unsupported. It
    duplicates a surface that AGENTS.md says was already retired on
    CoreStore.

Acceptance criteria

A new tests/nanopynix/test_public_surface.py asserts, and passes:

  • every name in nanopynix.__all__ resolves;
  • every public name importable from nanopynix is in __all__;
  • every exception class in nanopynix.exceptions is in its __all__;
  • every name in __all__ appears in docs/nanopynix/api/.

That test is a few lines and it prevents 8BD0 this class of drift entirely.

Compatibility

One deliberate break: deleting Nix = Session. Everything else adds a name or
adds a type.

Findings F6 and F9 of CODE_IMPROVEMENT_PLAN.md.

Activity

  1. Lillecarl commented on Jul 30, 2026

    @Lillecarl
    ContributorAuthor

    One more, found while building #57's allowlist from the class objects.

    WrongNixTypeError is exported and raised by nothing.
    nanopynix.__all__ and exceptions.__all__ both hold it, and no module in
    nanopynix/src raises it. Measured with
    rg -n "raise WrongNixTypeError" nanopynix/src/ -- no hits. The only mentions
    are two docstrings in rpc/client/_session.py that describe it as something a
    previous design raised.

    It also has the only constructor in the hierarchy that a message alone cannot
    rebuild -- __init__(self, *, expected, actual), keyword-only. That made it
    the single exclusion from #57's wire allowlist
    (exceptions._NOT_ON_THE_WIRE), which is a real cost paid for a class nobody
    raises.

    So it is the mirror image of the EvalError case above: that one works and is
    undeclared, this one is declared and is unreachable. Whichever way #44 settles
    the two __all__ lists, this class needs a separate decision -- delete it, or
    raise it where the code currently raises a bare TypeError for the same
    situation.

    Co-Authored-By: Claude Opus 5 noreply@anthropic.com

  2. Lillecarl commented on Aug 1, 2026

    @Lillecarl
    ContributorAuthor

    Measured against the current tree. Every claim still holds, and two of the
    counts have grown.

    Re-measured

    claim issue says measured now
    names importable and absent from nanopynix.__all__ 20 30, of which 11 are submodules and the annotations artifact, so 19 real names
    exception classes absent from exceptions.__all__ 3 5
    WorkerDiedError is a bare RuntimeError yes yes, MRO is RuntimeError, Exception, BaseException
    Session.subscribe untyped yes yes
    Nix = Session used by one test yes one test file, with 18 call sites
    inproc.Store.call has one caller yes one caller, and a parity-ledger row

    The nineteen:

    BuildResult  DEFAULT_EXPERIMENTAL_FEATURES  Derivation  DerivationOutput
    DerivationOutputs  EvalError  EvalSessionClosedError  EvalState  FlakeRef
    ForeignValueError  InfiniteRecursionError  Input  LockedFlake  LockedInput
    LogCapture  LogCollector  LogEvent  MissingArgumentError  MissingInfo
    

    Nothing in __all__ fails to resolve, so that half is purely additive.

    The drift is current, not historical

    Two of the five missing exception classes were added this week:
    EvaluatorAbandonedError by #66, and SettingOutOfScopeError by #56. The rate
    is about one name per feature.

    SettingOutOfScopeError was caught immediately by the wire allowlist in
    test_exceptions_classify.py, in the same commit that added it, because that
    list is restated as a literal. The same class of name went into
    exceptions.__all__ unnoticed. One had a guard and the other did not.

    Two notes for the implementation

    Session.subscribe is a one-line change. It forwards to
    WorkerClient.subscribe, which is already typed
    Callable[..., None] -> BusSubscription at rpc/client/_pool.py:443. Copying
    that signature closes the parity gap with inproc exactly.

    Deleting Store.call removes a parity-ledger row at
    tests/nanopynix/test_engine_parity.py:195, where it is recorded as an
    accepted inproc-only asymmetry. That touches #65.

    Acceptance criterion 4 does not belong here

    The fourth criterion says every name in __all__ appears in
    docs/nanopynix/api/, and calls the whole test "a few lines". Three of the
    four are. The fourth is not:

    • As written it is the wrong check. The docs are Sphinx automodule :members:, so a name is documented without appearing as text. A substring
      test reports 78 missing; resolving the directives gives 46, and most of
      the 78 are false.
    • It is a documentation project. 22 of the 46 come from
      nanopynix_bindings.* and have no page at all.

    Moved out, so this issue stays landable:

    Three questions this issue owns

    #71 found public names whose status is a decision, not a documentation gap:

    • set_manager_title is public and lives in nanopynix._process_title, a
      private module.
    • strip_ansi is re-exported from a third-party package of the same name. Does
      __all__ promise a function this project does not own?
    • init_libexpr, process_connection and register_store_implementation are
      lifecycle and extension points that Session already calls. Docs: the nanopynix_bindings surface has no reference page #72 is blocked
      on whether each gets a page or leaves __all__.

    Related

    #70 turns the conventions that are prose only into tests, and adds
    tests/meta/. This issue keeps criteria 1 to 3; #70 does not touch __all__.

  3. Lillecarl commented on Aug 1, 2026

    @Lillecarl
    ContributorAuthor

    Measurement from #70, recorded here because it is evidence for this issue and out of scope there.

    tests/ imports six names from the nanopynix top level that are absent from
    nanopynix.__all__:

    Derivation
    EvalSessionClosedError
    ForeignValueError
    LogCollector
    LogEvent
    MissingInfo
    

    Each is reachable as from nanopynix import <name> and each is missing from
    the export list, so this is a gap in __all__ rather than a gap in the module.

    The consumer side is already clean, and #70 now guards it:
    tests/meta/test_consumer_surface.py::test_every_public_name_a_consumer_imports_is_exported
    asserts that every name pynix, ekn, nanopynix-helpers and docs import
    from the top level is exported. That test is green today. Extending the same
    check to tests/ would fail on exactly the six names above, so it is one way
    to close this part of the issue and keep it closed.

    #70 also leaves a ledger for this issue to empty:
    CONSUMER_PRIVATE_IMPORTS holds nanopynix._typechecking.BEARTYPING and
    nanopynix._typechecking.no_runtime_type_check. Promoting them here deletes
    both entries, and the ledger test fails until they are deleted, so the two
    cannot drift apart.

  4. Lillecarl commented on Aug 2, 2026

    @Lillecarl
    ContributorAuthor

    Corrections and decisions, before the commit

    The counts moved. The issue said 20 names absent from nanopynix.__all__
    and 3 exception classes absent from exceptions.__all__. Measured on this
    tree: 19 real names plus annotations, and 5 exception classes
    (EvaluatorAbandonedError, ListIndexError, MissingAttributeError,
    SettingNotLiveError, SettingOutOfScopeError). annotations is the binding
    that from __future__ import annotations leaves behind. It is a
    __future__._Feature, not an export, and the test excludes it by name with
    that reason next to the filter.

    The test lives in tests/meta/, not tests/nanopynix/. tests/AGENTS.md
    now states the rule: a meta test reads the repository, it does not run it.
    This one walks module objects and touches no store.

    Criterion 4 belongs to #71. "Every name in __all__ appears in
    docs/nanopynix/api/" is exactly #71's subject, and #71 already records why a
    text search reports the wrong number: the docs use Sphinx autodoc, so the
    check must resolve the directives. Doing it twice would give two answers.
    The other three criteria are in tests/meta/test_public_surface.py.

    Two extras the work turned up.

    1. Session.subscribe was typed as part of a larger defect, not on its own.
      The two engines delivered different types through it: inproc emitted
      models.LogEvent, rpc emitted the bare proto that class subclasses. Every
      subscriber began by converting, and ekn reached into nanopynix_proto
      for a class to narrow against, because nanopynix exports the subclass and
      not the base. CallbackBus.emit normalises now, so the type the signature
      states is the type a subscriber gets.

    2. log_stream had drifted into two different methods with one name. rpc
      bounded its buffer, discarded the oldest event and stopped on the teardown
      marker; inproc used math.inf, reported nothing and never stopped at all,
      because it never sent the marker. Both are now
      nanopynix.logging.bus_log_stream. rpc also sent its marker after the
      teardown rather than inside the finally, so a teardown that raised left
      every iterator waiting for an event that would not arrive.

  5. Lillecarl commented on Aug 2, 2026

    @Lillecarl
    ContributorAuthor

    039d772 lands everything in Scope and three of the four acceptance
    criteria. Refs, not Closes, because criterion 4 is not met here.

    Done:

    • nanopynix.__all__ gained 19 names; nanopynix.exceptions.__all__ gained 7.
    • EngineError(RuntimeError) added, WorkerDiedError(EngineError) moved into
      nanopynix.exceptions, both exported. nanopynix.rpc.WorkerDiedError still
      resolves and is the same class. The docstring states that inproc cannot
      raise it, and why that is correct rather than a gap.
    • Session.subscribe typed on both engines, and the reason it was untyped
      fixed underneath it.
    • Nix = Session deleted; the one test rewritten.
    • inproc.Store.call deleted, with its test and its Store.call:inproc-only
      line in the engine parity ledger.
    • tests/meta/test_public_surface.py, six checks, each proven red before
      green.

    What is left: criterion 4 only, and #71 owns it. "Every name in __all__
    appears in docs/nanopynix/api/" is #71's whole subject, and #71 already
    records the part that makes it non-trivial: the docs use Sphinx autodoc, so
    the check must resolve the directives rather than search for text. Writing it
    twice would produce two answers to one question. Close this issue when #71
    lands, or now if you would rather #71 carry the criterion outright.

    Gates: check-lint, check-lint-strict, check-format and check-types all
    build. Full suite 1907 passed, 0 failed, 3 skipped.

  6. Lillecarl commented on Aug 2, 2026

    @Lillecarl
    ContributorAuthor

    Status, and what is left. Measured on develop at 253b0fc.

    Done, with a gate behind each one

    • EngineError(RuntimeError) and WorkerDiedError(EngineError) live in
      nanopynix.exceptions, both exported. nanopynix.rpc.WorkerDiedError
      still resolves.
    • exceptions.__all__ is complete, and
      tests/meta/test_public_surface.py keeps it so. That test caught this
      exact omission once while it was being written.
    • Session.subscribe returns BusSubscription on both engines. The
      engines disagreed because CallbackBus.emit passed the model on one and
      the bare proto on the other; the fix is at that one choke point.
    • Nix = Session is deleted.
    • inproc.Store.call is deleted.

    Criterion 4 is now measured, and it is a ledger rather than a pass

    #71 landed the check. It resolves the autodoc directives rather than
    searching the Markdown, and 22 of the 44 undocumented names only needed a
    directive, which they now have. 32 remain, and 23 of those are the
    compiled bindings that #72 owns.

    That leaves 9 names, and each is a question this issue owns

    Each one is a public name that cannot get a page until somebody decides
    whether it should be public, because writing the page settles it by
    accident. The reasons are recorded in UNDOCUMENTED in
    tests/meta/test_docs_coverage.py.

    name home the question
    strip_ansi the third-party package of the same name does __all__ promise a function this project does not own?
    set_manager_title nanopynix._process_title a public name with a private home
    DISPATCHABLE_METHODS a tuple, no __module__ is it API, or an internal table?
    rpc the submodule its contents are documented; the module object is not something autodoc renders
    init_libstore the nanopynix package itself no automodule reaches it
    LogLevel nanopynix_proto normalize_log_level and LogLevelInput are the documented way in
    ResultType nanopynix_proto the enum inside the documented BuildResult
    ValueHandle nanopynix_proto an rpc wire type: one engine's transport detail
    GcRoot nanopynix_proto a store internal a caller does not construct

    The other seven proto-derived models -- BuildResult, DerivationOutput,
    DerivationOutputs, FlakeRef, Input, LockedFlake, LockedInput --
    raised no question and joined models.md, beside Derivation and
    PathInfo which were already there.

    One correction to this issue's evidence

    Session.subscribe(self, callback: Any) -> Any ... The two engines
    disagree on the return type of a method that the parity ledger treats as
    shared.

    The parity ledger could not have caught it, and still could not.
    _compare_member in tests/nanopynix/test_engine_parity.py compares
    parameter names and async-ness, and not return annotations. The same blind
    spot hid a second case: to_python returned JsonValue on rpc and Any
    on inproc while both engines satisfied AsyncValue. That one is fixed, and
    the blind spot is now written down in that file's docstring. A gate over
    return types needs to resolve Self and ValueT against each engine's own
    class first -- 17 of the 18 members whose return annotations differ are
    correct specialisations, so a naive check would report 17 false differences.

  7. Lillecarl commented on Aug 2, 2026

    @Lillecarl
    ContributorAuthor

    #72 is done, and it did not need a decision from here

    #72 was marked "blocked by #44, for the names where the answer is removal
    rather than a page". It removed no name, so the block did not bind. Each of
    the 23 compiled-binding names was already in nanopynix.__all__, and writing a
    page for a name that __all__ already lists adds no promise.

    That leaves this issue with exactly 9 names to rule on. They are the whole
    of what is left in the UNDOCUMENTED ledger in
    tests/meta/test_docs_coverage.py, which is down from 32 entries to 9:

    name the question
    DISPATCHABLE_METHODS A tuple with no __module__. No page owns it.
    GcRoot A proto message a caller receives from a store, but does not construct.
    LogLevel The raw proto enum. normalize_log_level and LogLevelInput are the documented way in.
    ResultType The enum inside BuildResult, already reachable through that documented class.
    ValueHandle An integer handle for a worker-side value. One engine's transport detail.
    init_libstore Defined on the package itself rather than in a module, so no automodule reaches it.
    rpc The submodule, exported as a name. Its contents are documented; the module object is not a thing autodoc renders.
    set_manager_title A public name whose home, nanopynix._process_title, is private.
    strip_ansi Re-exported from the third-party package of the same name. Documenting it promises a function this project does not own.

    Each one is either "document it, and the page says where" or "take it out of
    __all__". The ledger entry carries the reason, and the gate asserts both
    directions, so an answer either way shortens the list.

  8. Lillecarl commented on Aug 2, 2026

    @Lillecarl
    ContributorAuthor

    e029277 rules on the last nine names and empties the UNDOCUMENTED ledger, so all four acceptance criteria are now met.

    The nine

    Seven get a page, because each is already in a public signature and the only
    open question was where the page goes:

    name page why it is public
    LogLevel session.md what get_verbosity and set_verbosity return, on both engines and on AsyncVerbosityController
    GcRoot models.md the element type of AsyncStore.find_roots
    ResultType models.md what BuildResult.result_type returns
    init_libstore process.md (new) pynix/config.py calls it three times
    set_manager_title process.md (new) pynix/__init__.py imports it from the top level
    DISPATCHABLE_METHODS stores.md the StoreImpl extension contract, which store_impl.py already cross-referenced with :data:
    rpc worker.md inproc already had an automodule directive and rpc did not

    process.md is new because init_libstore and set_manager_title share a
    scope no existing page has: they act on the operating-system process, and a
    host calls each once before it opens anything. Neither belongs to an engine.

    DISPATCHABLE_METHODS needed one code change to be worth a page. The comment
    above it becomes a docstring, so autodoc renders the reason the list is derived
    from PyStoreImpl rather than restated.

    Two leave __all__:

    • ValueHandle appears in no client-side signature. Measured: rpc/worker/
      and the proto use it, and a caller of Session receives a ValueProxy. It
      stays in nanopynix.models, beside CallArg, DeepValue, RemoteCallArg
      and ScalarValue -- the other wire types that also stop one import deeper.
    • strip_ansi is the third-party function of the same name. The package
      imported it and never called it, so __all__ promised a function this
      project does not own.

    One correction to the evidence

    The issue says strip_ansi has no consumer. Two test modules reached for it
    through nanopynix, and pyright found the second one after the first was
    fixed -- a multi-line from nanopynix import (...) that a single-line grep
    does not match. Both now import it directly, as four other test modules
    already did.

    session.md also loses a stale sentence: it said Nix is a
    backward-compatible alias for Session, and 039d772 deleted Nix.

    Gates

    ruff check, ruff check --config ruff-strict.toml, ruff format --check and
    pyright all clean. nanopynix-docs builds with -W, and the seven names
    render on the pages above. Full suite 2044 passed, 0 failed, 4 skipped, which
    is the pre-change baseline.

    Co-Authored-By: Claude Opus 5 noreply@anthropic.com

  9. added
    source: nanopynix
    on Oct 19, 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

    source: nanopynix

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0