Repository navigation
feat(cli): add nano package test with a strict fixture runner (#84) - #90
Merged
Merged
Conversation
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]>
This was referenced Nov 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_casesvalidatesnanoPackageCasesVersion1.0.0. The rules:casesmust be a non-empty list of at most 256, with unique non-empty names;expecthas exactly one ofproposedIntentsorruntimeError;Every violation is a
FIXTURE_ERRORwith a JSON pointer.admit_modulerefuses (UNSUPPORTED_HANDLER) anything not tiernano, any effect outside{intent.emit, log.append}, and anyai.infer/ai.signature/llmre.escalate/routenode. The op list is derived from the IROPStable, so a future reasoning op is refused by default. All of this happens before any case runs.run_casescallsrun_module(module, frame, provider=None), reports every case, and catches onlyRuntimeError_.CLI wiring in
nano/cli/package.py: the fixture is read once with a 1 MiB ceiling. Output is a canonicalNanoPackageTestReport1.0.0 (actionsExecuted: 0), or textPASS/FAILlines (ASCII-escaped) plusn/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 onc8c49e5, headf8446421cbbfb400fb74aa82467d0705bf173846)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):
Full suite, base vs head (3.13):
test_metadata_depth_is_positionedand two qsearchibm_kingston/ibm_marrakeshbackend tests that fail at base in this environment.Frozen dev set
examples/agent-package/cases.json(sha2563c97ba80…2abdat freeze): 5/5 pass, byte-identical across repeated runs. Every case ran withprovider=None(asserted). JSON output is one canonical LF document from a fresh interpreter.Negative controls:
run_modulecall count of 0. Effect and tier refusal is checked separately.--cases(exit 2), package dir unchanged after runs.Held-out (not tuned against): clean installed wheel outside the repository.
f3481127…07d6from this head, installed with--no-deps --no-indexinto a fresh Python 3.10.0 venv with no qiskit or numpy importable. The example was copied to an unrelated temp directory.check --json: packageHashb5f5a854…a099, moduleHash78031edf…200e.build: sha2563a1bae4e…1070, byte-identical to the in-repo build.test: 5/5, exit 0.cases.jsonchecks out as CRLF undercore.autocrlf; fixtures are not byte-pinned, so that is expected.Review: the independent review found 2 confirmed HIGH issues, both fixed in
f844642with RED (6 failed) then GREEN tests.float()in the VM and produced a traceback; they are now aFIXTURE_ERRORbefore execution.Iterations on this slice (none against the held-out set):
observedwas frozen into tuples; two pointer expectations were inconsistent).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/fmtremain deferred.Closes #84. Refs #67
🤖 Generated with Claude Code