Skip to main content

AI mode: --ai

Starter and pro. For “can a model look for what Penthera’s rules miss, without my code leaving my computer and without trusting the model?”
AI mode is opt-in and experimental. A model on your computer reads your code, part by part, and proposes problems that no rule describes. Penthera then checks every proposal with its own rules. A model never decides a finding: what a rule confirms becomes a finding, and the rest is shown as “model-proposed, unverified”, apart from rule findings, and never fails CI.
Whether AI mode finds more than the rules alone is not measured yet. A pre-registered experiment (E9) will measure it, and AI mode stays opt-in until it does.

What you need

Ollama running on this computer, with a code model pulled, for example:
penthera ai models lists your models and says which run on this computer and which run on ollama.com.

What happens, step by step

  1. Consent. Penthera asks before anything is scanned, every run.
  2. Rules. The normal repo scan runs, and records what it read (the coverage ledger in the report).
  3. The model reads. Your code is split into parts of up to 200 lines. Files the rules could not analyse come first, then files that handle outside input. Tests and minified files are left out. Anything the secret scan recognises is masked before a part is sent. The model gets text only: no tools, files, network or shell.
  4. Penthera checks. Each proposal must point at a line of the part the model was shown, or it is dropped. A proposal that a Penthera rule confirms (same kind of issue, same file) marks that rule’s finding “also proposed by AI”. The rest are model-proposed, unverified.
  5. The report has an AI mode section: the model, where it ran, how much it read, and the unverified proposals. They are not counted in the summary and never change the exit code.
Every --ai run shows this, and the default answer is no:
  • Enter, Ctrl-C or anything but y runs the scan with rules only. Saying no is never an error.
  • details explains the route in full, the model’s size and digest, and where consent is logged, then asks again.
  • Nothing is remembered as permission. Each answer is added to a log on this computer only (~/.penthera/consent.jsonl); penthera ai consent shows it.

Cloud models

Ollama can serve models that run on ollama.com through the same local address; their names end in -cloud. Penthera recognises them and never treats one as local. Choosing one shows a second screen, and you type the host to agree:
If Penthera cannot tell whether a model runs locally, it treats it as a cloud model.

CI and other runs that cannot ask

A run without a terminal (CI, piped input, --json) needs consent given in advance, or it stops before scanning with exit code 2:
or, reviewed with the rest of your config, in penthera.policy.json:
The value is a route, not a yes: local never covers a cloud model, which needs ollama-cloud. "allow": [] turns AI mode off for the repository.

In the dashboard

penthera ui: in New scan…, turn on AI mode for a scan of a project folder. The same consent appears as a sheet, with a picture of where your code goes and two equal buttons, “Use <model> on this computer” and “Not now”. See dashboard.md.

Options

When Ollama is not running, has no models, or the model you named is not installed, the rules-only scan runs and the report says why AI mode did not. Ctrl-C during the model’s reading stops it; what it read so far is checked and reported as partial.

Using your own agent instead

You can also run an AI audit in your own coding agent, for example Cloudflare’s security-audit skill, with any model it supports, and give the result to Penthera to check: see penthera verify. Then Penthera runs no model at all; your agent and its provider handled your code, under their terms.

What this does not do

  • It does not make the model a judge. A model’s “critical” stays a claim until a rule confirms it.
  • It does not run your code. (Checking proposals by running the code in a sandbox is planned and will ask separately.)
  • It is not robust against code written to mislead a model. Such code can make the model miss things or invent things; it cannot turn a proposal into a finding, because only rules confirm.
  • It does not call any hosted AI service itself. The only way code leaves your computer in AI mode is a cloud model in your own Ollama, after the second screen.