Skip to content

Decision model questions to Nova rules - #37

Merged
fr0gger merged 19 commits into
Nova-Hunting:mainfrom
marcopedrinazzi:jev-marco
Nov 29, 2026
Merged

fr0gger merged 19 commits into
Nova-Hunting:mainfrom
marcopedrinazzi:jev-marco

Conversation

@marcopedrinazzi

@marcopedrinazzi marcopedrinazzi commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Adds noul, choice, and score declarations under llm:, alongside existing quoted LLM checks. Quoted checks use the configured LLM provider; typed questions use a decision model through OpenRouter Decisions or Ollama.

Changes

  • Use noul for yes/no judgments, choice for categories, and score for ordered levels. Declaration settings turn answers into predicates referenced as llm.$name in conditions.
  • Add decision-model configuration, explicit activation, and optional caller-supplied context through the CLI and Python APIs.
  • Preserve typed answers, probabilities, confidence, and evaluation diagnostics. Required unresolved checks raise NovaEvaluationError; SDK results cannot report them as clean or allowed.
  • Preserve early blocking: a definite keyword or semantic BLOCK skips remaining model calls.
  • Fix @nova.protect() to scan default argument values and bound-method arguments, apply rules added after decoration, and respect skip_decision.
  • Update documentation and remove tests and packaging requirements for absent decision examples.

Existing quoted LLM syntax remains supported, including its parenthesized model temperature.

Updated setup.py and requirements.txt to require sentence-transformers~=5.6.0, the fixed version listed in the advisory (https://osv.dev/vulnerability/PYSEC-2026-4164)

fr0gger and others added 18 commits September 21, 2026 19:48
Commit 8a4881d deleted examples/decision/ while README.md and three guides
still link to eight of its files. Restore Marco's 825bee6 versions,
converted from the removed decision: section to llm: (decision.$x ->
llm.$x; LayeredPromptRisk merges its typed and quoted checks into one
llm: block). Harness scripts treat an incomplete scan as undecided.

Restore the examples test, packaging entries and artifact checks, and
add guards that every example rule parses and every documented
examples/decision path exists. The config-loading test now clears
OPENROUTER_API_KEY so a developer's real key can never be read or echoed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Decision is disabled by default, so before this change one typed rule
in a rules directory made Nova.scan() and NovaScanner.scan() raise
whenever its answer was needed, breaking scans for unrelated rules.

- A required check that was not run (Decision disabled, skip_decision,
  skip_llm, no LLM/semantic evaluator) now leaves the rule incomplete
  instead of raising: ScanResult.incomplete_rules and
  scan_with_details()["incomplete_rules"] list "llm.$name: reason", and
  evaluation_complete/allowed/clean stay False. Runtime failures of
  checks that ran still raise NovaEvaluationError with partial results.
  This matches the SDK's existing rule that a missing LLM key must not
  block keyword-only use.
- The SDK logs one nova.decision warning when typed rules load while
  Decision is disabled; the CLI adds a --decision hint and
  incomplete_rules to JSON, and still exits 1.
- Policy and global callbacks run only after the result is final, never
  for a scan that raises.
- protect(): a param_name the function lacks raises NovaConfigError at
  decoration time; **kwargs functions are scanned (and redacted) through
  that keyword; incomplete scans raise with the specific unresolved
  checks as causes.
- SDK loader: if strict boundary detection fails, split at rule
  declarations so a malformed rule no longer hides its valid siblings
  under ignore_invalid_rules; stray non-comment text is still reported.
- Docs and CHANGELOG describe the contract and list breaking changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The wheel smoke script still asserted the previous contract, where a
disabled required check raised NovaEvaluationError. Assert the scoped
behaviour instead: the scan returns with the rule in incomplete_rules and
allowed/clean/evaluation_complete False.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fr0gger

fr0gger commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Thanks @marcopedrinazzi, this is a great contribution.

Before merging, I tested the new parser on 281 real .nov files from our rule packs and pushed 3 commits to your branch. CI is green. Here's what changed and why.

1. Parser: no changes needed
270 of 281 files parse exactly as they do on main. Five files that start with a comment header now load in the SDK. Before, they failed. The only regression was one of my own rules with an unclosed quote. Rejecting that is correct. Nice work.

2. Narrower fail-closed (the one design change)
Decision models are off by default. So a single typed rule in a rules folder made Nova.scan() / NovaScanner.scan() raise every time its answer was needed, which broke scanning for every other rule. The new split:

  • A check that ran and failed (provider error, bad answer, low confidence, invalid state) still raises NovaEvaluationError with the partial result, exactly as you designed it.
  • A check that never ran (decision disabled, skip_decision, skip_llm, no evaluator configured) no longer raises. The rule appears in a new ScanResult.incomplete_rules / scan_with_details()["incomplete_rules"], for example {"Risk": ["llm.$scope: disabled"]}. evaluation_complete, allowed and clean stay False.
  • protect() still refuses to run the function in both cases, so gating actions stays fail-closed.
  • The SDK logs one nova.decision warning when typed rules load with decision models disabled. The CLI adds a --decision hint and still exits 1.

This follows the existing SDK rule that a missing LLM key must not block keyword-only use. If you see a case where it's too lenient, let's discuss.

3. Smaller fixes

  • Policy and global on_block/on_flag callbacks no longer fire for a scan that then raises.
  • protect(): a param_name the function doesn't have now raises NovaConfigError when you decorate it, instead of a missing_scan_text error on every call. Functions that only take **kwargs are supported, including redaction. The error lists the exact unresolved checks.
  • SDK loader: a malformed rule in a multi-rule file no longer hides the valid rules next to it when ignore_invalid_rules=True.

4. Restored examples/decision/
Commit 8a4881d deleted the examples, but the README and three guides still link to 8 of those files. I restored your 825bee6 versions, converted to the llm: syntax. New tests check that every example parses and every documented example path exists.

5. Docs

  • CHANGELOG has a new Breaking section covering the removed sections and Laya, the protect() argument binding, and the stricter parser.
  • docs/decision.md, the SDK README and ARCHITECTURE describe the new failure behaviour.
  • scripts/smoke_wheel.py now expects the new behaviour.

Tests: 351 passed (was 318). The build, artifact verification and wheel smoke test all pass locally and in CI.

Commits: ce1a4cc (examples), da638f8 (fixes), c43b2d4 (smoke test). Let me know if anything looks off. Otherwise I'm happy to merge.

@marcopedrinazzi

Copy link
Copy Markdown
Contributor Author

Below my latest fixes:

Correct the CLI exit status with --single

When the first rule is keyword-only and a later rule uses typed llm: checks, --single evaluates only the first rule. The CLI still selects Decision output based on the whole file. The keyword-only result omitted evaluation_complete, so the CLI reported INCOMPLETE and exited 1 even after a successful match.

NovaScanner.scan_with_details() now returns evaluation_complete=True and an empty incomplete_rules map for scans without typed Decision rules. The completed --single scan exits 0. Scans with unresolved required Decision checks still exit 1.

Handle incomplete scans in SDK examples and debug output

When a required Decision check is disabled or skipped, Nova.scan() can return evaluation_complete=False alongside blocked=False. The OpenAI example previously checked only blocked before forwarding a prompt.

The example now checks evaluation_complete before sending the prompt and raises NovaEvaluationError with the unresolved checks. The SDK README and docstrings show the same check. Both debug printers report “Evaluation incomplete” while preserving confirmed match details.

Respect the protect() severity threshold before skipping model checks

A low-severity keyword match with a BLOCK policy action could stop the scan before a higher-severity rule ran. With protect(action="block", severity="high"), the decorator could then execute the function because the only reported match was below its threshold. In the reproduction, switching the keyword rule’s action to FLAG let the scan continue. The pending rule matched at high, and the decorator blocked the call.

The SDK now checks the decorator’s severity threshold before stopping early. A BLOCK match below the threshold allows pending Decision and legacy LLM checks to proceed. If a required Decision check remains unresolved, protect() raises NovaEvaluationError before executing the function. A confirmed policy block that meets the threshold still skips the remaining model calls

@fr0gger
fr0gger merged commit c377d8d into Nova-Hunting:main Nov 29, 2026
10 checks passed
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.

2 participants