8000 NixEvaluatorSettings is not accepted where its docstring says it is · Issue #56 · nixidae/nixidae · GitHub
[go: up one dir, main page]

Skip to content

NixEvaluatorSettings is not accepted where its docstring says it is #56

Closed

Description

@Lillecarl

Passing a NixEvaluatorSettings as eval_settings raises, although the class
documents itself as accepted there.

Evidence

NixEvaluatorSettings says (nanopynix/src/nanopynix/settings.py:584-594):

A narrow parameter typed :class:NixEvalSettings accepts one of these,
because it really is one.

Measured on this tree, Nix 2.34, inproc engine:

session.eval(store, eval_settings=NixEvaluatorSettings(max_call_depth=50, warn_dirty=False))
RuntimeError: unknown eval setting: warn-dirty

session.eval(store, eval_settings=NixEvalSettings(max_call_depth=50))
OK

Cause

Both engines render the object with to_worker_settings() and send the whole
result as the eval settings map (inproc/_impl.py:969,
rpc/client/_session.py:955). A NixEvaluatorSettings inherits
NixFetchSettings too, so the map carries fetch keys, and Nix does not know
them as eval settings.

The same applies to configure() on both engines, and to the fetch_settings
parameter in the other direction.

Scope

Split the object by scope where it is rendered, rather than trusting the
declared parameter type. NixConfigModel.for_scope is the tool: render
NixEvalSettings.for_scope(spec) into the eval map and
NixFetchSettings.for_scope(spec) into the fetch map, so a caller may pass
either scope or both in one object.

The alternative is to delete the paragraph and reject a NixEvaluatorSettings
at the parameter, but the class exists precisely to be the one object an
evaluator is configured with.

Files

nanopynix/src/nanopynix/inproc/_impl.py, rpc/client/_session.py.

Tests

session.eval(store, eval_settings=NixEvaluatorSettings(<one eval field>, <one fetch field>)) opens on both engines, and both settings take effect.
configure() with the same object applies both.

Note

Found while working on #35. It is not caused by that change and is not fixed by
it -- the merge there preserves the object type, so the rendering stays as it
is today.

Activity

  1. Lillecarl commented on Aug 1, 2026

    @Lillecarl
    ContributorAuthor

    Two findings from the implementation, both widening this slightly beyond the
    eval and fetch doors the issue names.

    The same defect exists at two more doors

    Every narrow settings parameter renders the whole object into one scope's map,
    so the defect is not specific to eval_settings/fetch_settings:

    door site (inproc / rpc)
    eval_settings _impl.py:1065, 1110 / _session.py:964, 1033
    fetch_settings _impl.py:1067, 1111 / _session.py:971, 1034
    flake_settings _impl.py:1243, 1268 / _session.py:1144, 1239
    set_settings _impl.py:617 / session.py:361

    NixSettings is a subclass of each narrow scope class, so each parameter
    accepts one. The fix covers all four, because one shared helper is less code
    than four separate corrections.

    A field that no door on the call owns

    Narrowing alone would drop such a field in silence, which is what
    SettingNotLiveError and #37 exist to prevent. There is now a
    SettingOutOfScopeError, a sibling of SettingNotLiveError under
    ObjectMisuseError: that one means the wrong moment, this one means the
    wrong door.

    It also replaces a misleading message. Measured before the change:

    session.eval(store, eval_settings=NixSettings(max_jobs=3))
    RuntimeError: unknown eval setting: experimental-features
    

    Nix named experimental-features, which the caller never set, because
    NixSettings gives that field a default. The check reads model_fields_set,
    so a default alone never trips it, and it runs before the merge with the
    session defaults -- fill_unset_fields uses model_copy(update=...), and that
    marks a filled default as set.

    set_settings narrows the rendered map, not the model

    NixConfigModel.for_scope re-validates, and that promotes a default to an
    explicitly-set field. Measured:

    NixSettings(max_jobs=3).to_worker_settings(explicit_only=True)
      -> {'max-jobs': '3'}
    NixGlobalSettings.for_scope(that).to_worker_settings(explicit_only=True)
      -> {'experimental-features': '...', 'max-jobs': '3'}
    

    set_settings renders with explicit_only=True precisely so that writing one
    field does not reset the feature list. Narrowing that door by model would undo
    it, so that door filters the rendered mapping instead.

    Side effect: set_settings(NixSettings(max_jobs=3)) now works, where it used
    to fail with unknown setting: pure-eval.

    Verification

    All twelve new test cases fail with the fix removed, and none of them passes.
    The four root causes are exactly the defect in its four shapes:

    6x  RuntimeError: unknown eval setting: allow-dirty      # fetch half at the eval door
    2x  RuntimeError: unknown fetch setting: pure-eval       # eval half at the fetch door
    2x  Failed: DID NOT RAISE SettingOutOfScopeError         # the refusal
    2x  RuntimeError: unknown setting: pure-eval             # the global door
    
  2. added
    source: nanopynix
    on Oct 19, 2026
  3. added theissue type 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

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      0