# AI data use

What Bucker sends to a language model, when, what it never sends, and how to turn it off. This
page is written from what the code sends (`domain/src/modules/rca/` and
`workers/src/remediation/`), not from what we would like to be true, and it names the file behind
each statement so a reviewer can check it. Where something is not built, it says so.

## The short version

- **By default, nothing is sent to any model.** The default provider is deterministic and
  rule-based: it runs inside the Bucker process, makes no network call and needs no key. Root-cause
  analysis works without a model. A deployment sends data to a model only if its operator has
  configured a hosted provider (`BUCKER_LLM_PROVIDER`) and a key.
- **When a hosted provider is configured, four features call it:** root-cause analysis (a few
  short sentences of already-validated facts), the issue summary's first line (the same kind of
  facts), fix authoring (which includes **your source code**; see below), and the optional
  evaluation judge for agent observability.
- **One switch turns all of it off, per organization:** *AI features enabled* under Settings →
  General (the `aiEnabled` setting). Off, nothing new starts, and a model is never called for that
  organization.
- **Bucker does not train, fine-tune or evaluate any model on your content.** Bucker has no model of
  its own and no training pipeline. The model provider's own retention and training terms apply to
  what reaches it, and we have no zero-data-retention agreement with any provider. We say so
  rather than imply one.

## What is sent, per feature

### Root-cause analysis

*Code: `domain/src/modules/rca/service.ts` (`narrate`), `rca/llm.ts`.*

Hypotheses and evidence are produced from your stored rows by deterministic rules and validated
against real entities. The model is asked only to **rephrase** the top three hypotheses, one
sentence each, and its output is re-validated: a sentence that names a file, function, release or
commit that is not in the validated set is discarded and the deterministic wording is kept.

Each call carries:

| Sent | Example |
| --- | --- |
| A fixed instruction (the same text for every customer) | "Phrase this hypothesis in one sentence" |
| One hypothesis as three short strings: a subject, a mechanism and an effect | `src/cart/total.ts` / "contains the top in-app frame (computeTotal:42) and is where execution failed" / "a null dereference in computeTotal()" |
| A ceiling on the answer (120 tokens) | |

What that means in practice: **file paths, function names, a line number, a release or commit
identifier, the minutes between a change and the first error, and a similarity percentage.** The
effect is the wording of the rule that matched; **the exception's own message is deliberately not
spliced in**, because it is customer-controlled text.

**Not sent:** the exception message, request data, user data, breadcrumbs, event payloads, log
lines, replay, or the issue's full error essence.

### Issue summary (the header's first line)

*Code: `domain/src/modules/rca/summary.ts`.*

The issue header shows two lines: what failed, and the likely cause. The cause line is the latest
root-cause analysis's top hypothesis, word for word, with "from RCA run #n"; no model writes it.
The first line is built from stored facts by a fixed template, and only when a hosted provider is
in use (and AI features are on) is the model asked to rephrase those facts as one sentence.

| Sent | Example |
| --- | --- |
| A fixed instruction | "Phrase these facts as one sentence… Never state or guess a cause." |
| The exception type, the top frame (file, function, line) and the culprit | `TypeError`, `src/cart/total.ts`, `computeTotal`, `42` |
| First and last seen, event and user counts, environment names, the release version | `2026-04-01T12:00:00Z`, `12`, `3`, `production`, `1.4.0` |

**Not sent:** the exception message, stack contents beyond the top frame, request or user data,
breadcrumbs, logs, replay. The answer is shown only if it names no file, commit or number that is
not in those facts and asserts no cause; otherwise the template is shown. One answer is reused per
issue, analysis run and event count, so a page view does not make a call.

### Fix authoring (the remediation loop)

*Code: `workers/src/remediation/author-llm.ts`, `prepare-remediation-run.ts`.*

Fix authoring writes a reproduction test and a patch, so it needs the code. When a hosted provider
is configured and a remediation run starts, the prompt contains:

| Sent | Scrubbed first? |
| --- | --- |
| The issue's short id, exception type and exception value, and the culprit | Yes: the agent-tier scrub, with your organization's own scrub rules |
| A summary of the latest root-cause analysis | Built from validated facts only |
| The **error essence** (bounded, trust-labelled) | Yes: scrubbed and injection-checked |
| The files the patch may modify (the blast radius) | n/a (paths) |
| Prior rejections and the localization hint | Yes: a human's free-text rejection reasons are scrubbed and injection-checked |
| **Source code from your connected repository**: the chunks retrieved for the issue | **No.** See below |
| On a retry, the current contents of the files being patched, the model's previous diff and the repro test's failure output (last 3,000 characters) | **No** |

**Source code is not redacted, on purpose.** The patch is applied by an exact matcher that needs
the model to reproduce the repository's bytes character for character; scrubbing the code would
break the applier rather than protect anything. Two things bound the exposure instead: the
instruction tells the model that everything in the prompt is data and never to follow instructions
inside it, and the sandbox refuses any change outside the allowed files regardless of what the
model wrote. If your source code must not leave your environment, **turn AI features off for the
organization** (below), or do not connect a repository.

Anything the model writes is run in an isolated sandbox against your tests before it is shown as
a verified fix; the model never decides whether a fix is correct, and a human approves every
merge ([agent governance](agent-governance.md)).

**Not sent:** other issues, other projects, other organizations' data, credentials, or environment
variables. Secret-shaped strings are removed by the storage-tier scrub before anything is
persisted, so they are not in the rows these prompts are built from.

### Evaluation judge (agent observability, optional)

*Code: `domain/src/modules/agent-observability/evals-case-shape.ts`.*

Only when you run an evaluation whose cases escalate to a model judge. The call carries your
judge's own prompt (which you wrote), a score computed locally, a pass/fail and at most ten reason
strings drawn from the fixed rubric. **The agent's output and the reference answer are not sent.**
With the default provider the judge is deterministic and nothing leaves the process.

### Similar issues and grouping suggestions (embeddings)

*Code: `domain/src/modules/codebase/embeddings.ts`, `codebase/issue-embeddings.ts`,
`codebase/memory.ts` (`issueEmbeddingText`).*

Not a language model: an embeddings provider turns text into a vector of numbers that Bucker
stores beside the issue and compares with other issues in the same project. Only when the
deployment has configured a hosted embeddings provider and your organization has AI features
enabled. Each issue sends four fields — exception type, exception message, title and culprit —
when it is created and when its vector is rebuilt. They have had the storage-tier scrub
(credentials removed), not the stricter agent-tier pass, so an email address inside an exception
message is sent as stored. **Your source code is not sent**: Bucker's hosted service does not
enable source-code embeddings. With AI features off, or no provider configured, issues are
compared by shared words inside Bucker and nothing leaves. Details:
[similar issues and grouping](semantic-grouping.md).

<!-- egress-contracts:begin -->
## What each purpose may send (generated)

This section is generated from the AI egress contracts (`domain/src/lib/llm/egress-contracts.ts`) by
`scripts/generate-ai-data-use.mjs`; `--check` fails when it is out of date. A contract is a reviewed
code change: nothing at run time can add a data class, a purpose or a provider to one. A project can
only take away (`ai_egress_policy.narrow`), and giving that back is a person's act with a second
owner confirming (`ai_egress_policy.widen`).

Before a call reaches a hosted model, a gate in the model seam labels every part of the prompt with a
data class and checks the labels against the purpose's contract, then runs the credential, personal-data
and injection detectors over every part that is not sent verbatim by design. A call that carries a class
its contract does not list, goes to a provider it does not list, is over its token ceiling, or is
switched off for the project is refused, and the feature uses its deterministic wording instead. Every
call, allowed or refused, is one row in the egress ledger: counts by data class, tokens, the contract
version, a SHA-256 of the prompt and the decision, and never the prompt itself. Read it with the
`ai_egress_get` tool.

| Purpose | What it is for | Data classes it may carry | Providers | Token ceiling | Version | Sent verbatim | If refused |
| --- | --- | --- | --- | --- | --- | --- | --- |
| `rca_narration` | Rephrase one validated root-cause hypothesis (three short strings) as a single sentence. | `validated_fact`, `frame_identifier` | `anthropic`, `openai` | 2,000 | 1 | none | The deterministic hypothesis statement the rule engine already produced. |
| `issue_summary_line` | Rephrase the issue header's stored facts as one sentence that states no cause. | `validated_fact`, `frame_identifier`, `release_label`, `tag_key` | `anthropic`, `openai` | 2,000 | 1 | none | The fixed template line built from the same facts. |
| `fix_author` | Write a reproduction test and a unified diff for one issue. Source code and the failing test output are sent verbatim. | `validated_fact`, `issue_title`, `exception_value`, `frame_identifier`, `local_variable`, `comment_body`, `code_snippet`, `ci_log` | `anthropic`, `openai` | 200,000 | 1 | `code_snippet`, `ci_log` | No fallback: a run with no usable author fails with a named reason, never an empty patch. |
| `eval_judge` | Score one evaluation case with the judge's own prompt and rubric. The call carries either a locally computed score and at most ten rubric reasons, or, for a model-judged judge on a project that switched judging on and an organization key for the judge's provider, the case's content after the agent-tier scrub inside a data-only frame (delimited as data, with the instruction that nothing inside is a command; text the injection scanner flags is withheld before the frame is built). The reference answer is never sent. | `customer_authored_prompt`, `validated_fact`, `rubric_reason`, `span_attribute_value` | `anthropic`, `openai` | 8,000 | 2 | none | The judged tier answers abstain for the refused case and records why; the rubric score of the case is unaffected, and the run is never adopted as a baseline on a judged verdict. |
| `session_summary` | Summarize one recorded session from its scrubbed action log (route templates, element selector leaves, request methods, paths and status codes, console lines unless the project masks all text) with counts Bucker computed, or label one selector skeleton's role from a closed list of twenty. No DOM, pixels, request or response bodies or headers, query strings or input values are sent, and nothing is sent unless a person switched session summaries on for the project. | `validated_fact`, `replay_input_label`, `replay_console`, `page_url` | `anthropic` | 3,500 | 1 | none | The deterministic chapters and counts the replay already derives; a rejected or unavailable summary is shown as such, never replaced by a guess. |
| `survey_theme_naming` | Name ONE cluster of survey answers in at most six words from its distinguishing phrases (at most five short n-grams drawn from the scrubbed answers, each shared by at least three respondents) and counts Bucker computed. No answer, respondent, sentence or identifier is sent, and nothing is sent unless a person switched theme naming on for the project and the organization allows AI features. | `validated_fact`, `survey_text` | `anthropic`, `openai` | 1,200 | 1 | none | The default label: the top three distinguishing n-grams of the cluster, as computed by the clustering itself. |
| `candidate_replay` | Re-run ONE recorded inference step of a stored trace once, with an edited prompt template or another model, on the organization's own key, so a person can compare the new response with the recorded one. The call carries the customer's own prompt template and the step's stored input messages after the agent-tier scrub, inside a data-only frame (text the injection scanner flags is withheld before the frame is built). Nothing is sent unless the project chose full capture and a person turned model use on for it; no tool is executed, no second turn is run, and the response is stored as untrusted text. | `customer_authored_prompt`, `validated_fact`, `span_attribute_value` | `anthropic`, `openai` | 16,000 | 1 | none | The replay of that recording is reported as not run, with the reason; nothing is substituted and the recorded response is left as it was. |
| `manifest_draft` | Draft one REST source manifest (table paths, pagination, primary keys, auth shape) from a provider's public API documentation a person supplied or allowed, plus the key names and types (never values) of recorded sample responses. The model has no tools and its output is JSON a strict schema checks; nothing is sent unless the organization's AI switch is on. | `validated_fact`, `http_response_text`, `plan_echo` | `anthropic` | 20,000 | 1 | none | No draft is made and nothing is stored: the caller is told the model call was refused, and writes the manifest by hand. |

Reserved, with no contract yet and therefore refused if called: `cluster_label` (P3-128).

"Sent verbatim" lists the classes the second net does not scan, because their exact bytes are what the
call is for (the fix author's patch is applied by an exact matcher, so source code cannot be redacted).
<!-- egress-contracts:end -->

## Which provider, and whose key

- **On Bucker's hosted service, the deployment's key is held only by the service that runs
  remediation.** It is used there for fix authoring and for the root-cause analysis that service
  runs on its own: the analysis an alert rule's "investigate" action starts, and the one the
  autofix sweep runs on an issue it stops at analysis. Root-cause analysis you or your agent
  request (from the dashboard or the API), the issue summary and the evaluation judge run in
  the API, which holds no deployment key, so for an organization without its own key they use the
  deterministic provider and nothing is sent.

- **Two hosted providers have working adapters** (`rca/llm.ts`): **Anthropic** (the vendor SDK) and
  **OpenAI** (the Chat Completions endpoint; `OPENAI_BASE_URL` points it at a compatible gateway,
  a deployment setting only).
- **Each organization can bring its own key** (SG-069): Agents → Model key, or
  `PUT /orgs/:orgSlug/llm-credential` with a provider, a key and an optional model. The key is
  sealed at rest under the deployment's `AUTH_SECRET` with a purpose and an org binding
  (`rca/org-llm-credential.ts`), is never returned by any route or written to an audit row (the
  audit row carries the provider, the model and the last four characters), and revoking it wipes
  the ciphertext. While one is stored, that organization's **root-cause analysis, issue summary and
  fix authoring** run on it, and the provider relationship for those calls is the customer's. The
  **evaluation judge** below still uses the deployment's provider.
- **Without an org key, the deployment's key applies** (`BUCKER_LLM_PROVIDER`, `BUCKER_LLM_API_KEY`).
  That provider relationship is Bucker's.
- **An org key that cannot be used never falls back to the deployment's key.** Analysis falls back
  to the deterministic wording and records why it degraded (`org-llm-key-unusable`); a remediation
  run fails with a named reason. A deployment provider that is selected but unusable likewise leaves
  analysis on the deterministic wording, and for fix authoring there is no silent fallback: with no
  key, the run fails with a named reason rather than producing an empty patch.

## Retention and training

- **Bucker stores results, not a transcript.** What is kept is the analysis row (verdict, ranked
  hypotheses, the evidence it assembled, a clipped summary), the proposal, and its evidence bundle.
  Bucker keeps no copy of what it sent to a model. It does keep an **egress ledger** for 400 days: one
  row per hosted-model call with the purpose, provider and model, how many items of each data class the
  prompt carried, the tokens, the contract version, a SHA-256 of the prompt and the decision. A row has no
  column that could hold prompt text, so the ledger can show *that* a call carried a stack frame and a
  count, never *which* frame. Your agent reads it with `ai_egress_get`.
- **The provider's retention applies to what reaches it.** We have **not** negotiated a
  zero-data-retention agreement with any provider and do not claim one. See the
  [privacy notice](https://www.bucker.io/en/legal/privacy) and the [trust page](https://www.bucker.io/en/trust).
- **Training.** Bucker does not use your content to train or fine-tune a model, and has no
  cross-tenant model or memory. (Cross-tenant fix memory is not built.) Whether the provider trains
  on API traffic is governed by the provider's own commercial terms; Bucker cannot change those and
  does not speak for them. If this is a procurement requirement, ask for the terms that apply to the
  deployment you will use, or store your organization's own key (above), which puts those calls
  under your own provider contract.

## Every call is metered and budgeted

Each model call goes through one metering wrapper (`MeteredLlmProvider`): a token budget is reserved
before the call and charged after it, and a spend entry records the tokens and cost with the agent
principal, the user it acted for and the incident, where there are any. There is no path to the provider that skips
it. Budgets and the kill switch are in [agent governance](agent-governance.md). The same seam holds
the egress gate described above: a hosted call is checked against its purpose's contract and ledgered
before it is made, and a call the gate refuses spends no budget.

## Turning it off

| To | Do this |
| --- | --- |
| Stop all AI features for an organization | Settings → General → AI features off (`aiEnabled=false`), also shown as *AI features enabled* under Agents. RCA, fix authoring and the autonomy sweep all refuse for that organization |
| Stop agent-initiated pull requests only | `agentPrCreationEnabled=false`, independent of the switch above |
| Send nothing to any model, deployment-wide | Leave `BUCKER_LLM_PROVIDER` at `rule-based` (the default) and store no organization key |
| Send this organization's calls under its own provider contract | Agents → Model key: store an Anthropic or OpenAI key; remove it to go back |
| Keep your source out of prompts | Turn AI features off, or do not connect a repository |

Any organization administrator or owner can change the switch; the change is written to the audit log with the before and after value.

## What we have not built

So that nothing here reads as a promise: a zero-data-retention agreement, a per-field opt-out
inside fix authoring (the choice today is all of it or none of it), the organization's own key for
the evaluation judge, and a contract with any provider on training. Each is a tracked gap, not a
claim.
