Skip to Content
ConceptsLLM boundary

LLM boundary

The LLM has two jobs: extract structured indicators from unstructured text, and write the human explanation of a finding. The LLM never decides a finding. Only deterministic matching runs in the detection path.

What the LLM does

The LLM client has two prompts:

PromptInputOutput
extractCleaned article text (truncated to 8,000 tokens) plus the watchlistA JSON array of Intel records. An empty array is a valid answer.
triageOne Finding plus its Intel recordThree sentences: what happened, why it matters here, what to do.

Both prompts use structured output with a JSON schema. The client rejects any response that fails schema validation and logs the failure. Temperature is zero.

The extract prompt converts news articles into Intel records with indicators. The output is an array of Intel, each with kind, severity, title, summary, and indicators.

The triage prompt writes the explanation text shown in the Findings window. It explains what the incident is, why it affects this machine, and what to do.

What the LLM never does

Four rules limit the LLM:

  1. No tools. The LLM cannot read files, run commands, or make requests.
  2. Data wrapping. Article text is wrapped as data. The system prompt states that the text can contain instructions and that the only valid output is the schema.
  3. Indicators are strings. An indicator from the LLM is a pattern. The matcher applies it. Nothing from the LLM is run as a command.
  4. No inventory by default. Local inventory never goes to the LLM unless send_inventory = "matched-only". Then the client sends only the purl of the matched item.

The LLM is not in the detection path. The matcher applies indicators deterministically. A poisoned article cannot produce a finding unless the matcher sees a real match in the inventory.

Schema-constrained output

Both prompts use JSON schema with strict: true. The schema defines every field and its type. The model must produce valid JSON that matches the schema, or the call fails.

Extract schema (simplified):

{ "type": "array", "items": { "type": "object", "properties": { "kind": { "enum": ["malicious-package", "vulnerability", "exploited-vulnerability", "news-advisory"] }, "severity": { "enum": ["low", "medium", "high", "critical"] }, "title": { "type": "string" }, "summary": { "type": "string" }, "indicators": { "type": "array", "items": { ... } }, "remediation": { "type": "array", "items": { "type": "string" } }, "aliases": { "type": "array", "items": { "type": "string" } } }, "required": ["kind", "severity", "title", "summary", "indicators"] } }

The indicators array has typed objects, one per indicator type. Each type has required fields. An indicator with missing fields fails schema validation.

Triage schema:

{ "type": "object", "properties": { "explanation": { "type": "string" } }, "required": ["explanation"] }

The explanation is three sentences, written for a developer. It does not repeat the finding ID or tier, which the UI already shows.

Send inventory: never

The default is send_inventory = "never". The LLM sees article text and the watchlist only. It does not see the local inventory.

The only exception is send_inventory = "matched-only". In that mode, the triage prompt receives the purl of the matched item. This lets the LLM say “your installation of litellm at version 1.107.0” instead of “this package.”

The full inventory never leaves the machine by default. OSV bulk downloads are local. The matcher runs locally. The findings are local.

API key in Keychain

The API key lives in the macOS Keychain. The configuration file never holds a key.

Default Keychain item:

  • Service: buckler.llm
  • Account: api-key
  • Value: the Anthropic API key

The LLM client reads the key at runtime. The key is never written to disk outside the Keychain.

To set the key:

buckler llm key set

This prompts for the key and writes it to the Keychain.

Token ledger

The LLM client records token usage in the llm_ledger table. Each row has:

  • Date
  • Prompt (extract or triage)
  • Input tokens
  • Output tokens
  • Cost (estimated)

A daily token budget (default 200,000) stops extraction when reached. Triage keeps a separate reserve (20,000 tokens), so alerts still get explanations even when the budget is exhausted.

The Findings window shows the current day’s usage.

Provider options

The LLM client supports three provider modes:

ProviderConfiguration
anthropicAnthropic Messages API. Uses api_key_keychain. Default model: claude-sonnet-5-5.
openaiAny OpenAI-compatible endpoint. Covers Ollama, LM Studio, and other local servers. Uses base_url and api_key_keychain.
claude-cliThe claude CLI with -p (persistent mode). No API key required. Runs claude -p <prompt> and reads stdout.
noneDisables the LLM. RSS providers fail. Triage uses template text.

Example for Ollama:

[llm] provider = "openai" model = "llama3" base_url = "http://localhost:11434/v1" api_key_keychain = "" send_inventory = "never"

Example for claude-cli:

[llm] provider = "claude-cli" model = "" send_inventory = "never"

The claude-cli mode requires the claude binary in PATH. Buckler runs it as a subprocess and parses JSON from stdout.

Why the model never decides a finding

The LLM extracts indicators. The matcher applies them. Only the matcher writes findings.

A poisoned article can produce garbage indicators. The matcher will apply them, but they will not match anything in the inventory unless a real package or file matches.

An attacker cannot produce a finding by injecting instructions into an article. The schema constraint blocks it, and the matcher checks the inventory.

This design keeps the LLM out of the trust boundary. The deterministic matcher is the detection engine.

Last updated on