Skip to content

feat(cli): add nano package test with a strict fixture runner (#84) - #90

Merged
AetherAI3 merged 3 commits into
mainfrom
claude/nano84-package-cases
Nov 7, 2026
Merged

AetherAI3 merged 3 commits into
mainfrom
claude/nano84-package-cases

Conversation

@AetherAI3

Copy link
Copy Markdown
Owner

Second slice of #84, stacked on #89: nano package test --manifest … --lock … --cases PATH. A strict, versioned local fixture runner over the existing v1 VM. Cases assert proposed intents (or a VM runtime rejection); nothing is ever executed.

What changed

  • nano/cli/package_cases.py (new, pure library, no I/O): load_cases validates nanoPackageCasesVersion 1.0.0. The rules:

    • duplicate keys, NaN/Infinity and unknown or missing keys are rejected at every level;
    • cases must be a non-empty list of at most 256, with unique non-empty names;
    • timestamps: 1..4096 strictly increasing ints;
    • signals: numbers or booleans only, ints within ±2**53, equal lengths;
    • expect has exactly one of proposedIntents or runtimeError;
    • there is no skip/only/provider/handler/executed field.

    Every violation is a FIXTURE_ERROR with a JSON pointer.

  • admit_module refuses (UNSUPPORTED_HANDLER) anything not tier nano, any effect outside {intent.emit, log.append}, and any ai.infer / ai.signature / llmre.escalate / route node. The op list is derived from the IR OPS table, so a future reasoning op is refused by default. All of this happens before any case runs.

  • run_cases calls run_module(module, frame, provider=None), reports every case, and catches only RuntimeError_.

  • CLI wiring in nano/cli/package.py: the fixture is read once with a 1 MiB ceiling. Output is a canonical NanoPackageTestReport 1.0.0 (actionsExecuted: 0), or text PASS/FAIL lines (ASCII-escaped) plus n/m passed. Exit codes: 0 only if at least one case ran and all passed; 1 for a fixture, handler, package or case failure; 3 for an unreadable fixture.

  • Example README documents cases.json; RFC 0066 now says check/build/test are implemented and init/fmt remain deferred.

Evidence (base cb6ea884d63dcaa8cc0e7c0b952bb88784e8219f, stacked on c8c49e5, head f8446421cbbfb400fb74aa82467d0705bf173846)

  • RED: the library tests fail at collection (ModuleNotFoundError); the CLI tests were 18 failed / 1 passed (the passing one is the trivial usage exit-2 case).

  • Focused + compatibility suite (PR1's set plus test_package_cases and test_package_test_cli):

    Python Passed Failed Skipped
    3.13.5 448 1 1
    3.12.10 448 1 1
  • Full suite, base vs head (3.13):

    • base: 2349 passed / 3 failed / 18 skipped
    • head: 2556 passed / 3 failed / 18 skipped
    • The failure sets are identical: test_metadata_depth_is_positioned and two qsearch ibm_kingston/ibm_marrakesh backend tests that fail at base in this environment.
    • +207 passed is exactly the new tests (52 + 129 + 26).
  • Frozen dev set examples/agent-package/cases.json (sha256 3c97ba80…2abd at freeze): 5/5 pass, byte-identical across repeated runs. Every case ran with provider=None (asserted). JSON output is one canonical LF document from a fresh interpreter.

  • Negative controls:

    • Library: 30+ malformed fixtures, including empty, wrong version, skip/provider/executed keys, duplicate names and over-size files.
    • Handlers: infer/escalate/route/signature, refused with a run_module call count of 0. Effect and tier refusal is checked separately.
    • Mismatches: wrong or extra intent, expected error but got intents, expected intents but got an error, substring mismatch. Mixed pass/fail runs report every case.
    • CLI: stale pin (PACKAGE_ERROR, nothing run), missing or directory fixture (exit 3), missing --cases (exit 2), package dir unchanged after runs.
    • A mutation check (disabling admission and the duplicate-key check) fails 16 tests.
  • Held-out (not tuned against): clean installed wheel outside the repository.

    • Setup: wheel sha256 f3481127…07d6 from this head, installed with --no-deps --no-index into a fresh Python 3.10.0 venv with no qiskit or numpy importable. The example was copied to an unrelated temp directory.
    • check --json: packageHash b5f5a854…a099, moduleHash 78031edf…200e.
    • build: sha256 3a1bae4e…1070, byte-identical to the in-repo build.
    • test: 5/5, exit 0.
    • The pinned sources still match the lock. The copied cases.json checks out as CRLF under core.autocrlf; fixtures are not byte-pinned, so that is expected.

Review: the independent review found 2 confirmed HIGH issues, both fixed in f844642 with RED (6 failed) then GREEN tests.

  • Ints over 2**53 overflowed float() in the VM and produced a traceback; they are now a FIXTURE_ERROR before execution.
  • Non-ASCII or lone-surrogate case names crashed text output; text output is now ASCII-escaped.
  • Huge timestamps were probed separately: they stay exact ints, with no crash.

Iterations on this slice (none against the held-out set):

  1. Library iteration 1: 6 failed (observed was frozen into tuples; two pointer expectations were inconsistent).
  2. Library iteration 2: GREEN.
  3. CLI wiring: GREEN.
  4. Review fixes, prompted by new findings rather than the dev set.

No assertion was weakened and no negative control was removed.

Limitations: same pre-existing items as #89. CI is billing-locked and starts zero jobs. Merge waiver given explicitly by the repo owner in-session for these PRs: "yes merge on local evidence, waiver for these PRs". init/fmt remain deferred.

Closes #84. Refs #67

🤖 Generated with Claude Code

AetherAI3 and others added 3 commits November 7, 2026 17:49
Pure library behind `nano package test --cases PATH`, per the frozen
contract in docs/package-cli.md. No argparse, no I/O beyond the bytes
it is handed; CLI dispatch is left to the concurrent package CLI lane.

- load_cases: 1 MiB ceiling, strict UTF-8, duplicate-key and
  NaN/Infinity/overflow rejection located by JSON pointer, exact key
  sets at every level, version 1.0.0, 1..256 uniquely named cases,
  1..4096 strictly increasing integer timestamps (bool excluded),
  number/boolean signal series, exactly one expectation
  (proposedIntents shaped as Intent.to_dict(), or a non-empty
  runtimeError substring). Returns frozen CaseSet/Case values.
- admit_module: refuses tier != nano, effects outside
  {intent.emit, log.append}, and any ai.infer / ai.signature /
  llmre.escalate / route node, derived from the IR OPS table.
- run_cases: admits before any case runs, then calls
  run_module(module, frame, provider=None) per case; only the VM's
  RuntimeError_ becomes an observed runtimeError, everything else
  propagates. Every case is reported; ACTIONS_EXECUTED is 0.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Adds the test action: build through the public package API, read the
--cases file once (1 MiB ceiling), validate it and admit the module before
any case runs, then report every case. JSON mode emits one canonical
NanoPackageTestReport with actionsExecuted 0; text mode prints PASS/FAIL
lines and a summary. Exit 0 only when at least one case ran and all passed;
fixture, handler and package rejections exit 1; an unreadable fixture exits 3.

Refs #84, #67

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review findings on the test command:
- integer signal values beyond +/-2**53 reached the VM's float() and
  escaped as OverflowError; they are now FIXTURE_ERROR at their pointer
  before any case runs (2**53 itself is accepted);
- text mode printed case names and reasons through the console encoding,
  so non-ASCII or lone-surrogate names crashed with UnicodeEncodeError;
  text lines are now ASCII-escaped single lines. JSON mode was already safe.

Refs #84

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@AetherAI3
AetherAI3 changed the base branch from claude/nano84-package-cli to main November 7, 2026 23:43
@AetherAI3
AetherAI3 merged commit 27e8a5f into main Nov 7, 2026
0 of 2 checks passed
@AetherAI3
AetherAI3 deleted the claude/nano84-package-cases branch November 8, 2026 19:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[P1][hillclimb] Add explicit hermetic package check, build and fixture-test CLI

1 participant