~/how-the-ai-works
Patterns find strings. A model decides what they mean.
Leaksweep is AI-native in a narrow, checkable way. Here is the full pipeline, including the parts where we do not trust the model.
the pipeline
Three stages, one of them deterministic.
01 · detect candidates
deterministic · in code
29 regex detectors ordered from most specific to most generic, with span claiming so one string is never reported twice. Entropy gates on generic hits. References to environment variables are dropped. The output is a list of candidates, each already masked and fingerprinted.
02 · reason about real risk
language model
Is this a live credential or a fixture? How far does it reach? Is its pair present? The model reads masked context and answers with a verdict, a severity, a confidence, and one sentence of reasoning per candidate.
03 · draft the remediation
language model · schema-bound
Ordered steps for this provider and this stack: where to rotate, how to read the value from env in your framework, the history purge for that path, which audit log to read. Validated against a zod schema before it ships.
the boundary
What the model sees, and what it never sees.
sent to the model
{
"id": "f1",
"detector": "stripe_live_key",
"masked_value": "sk_l••••••••••••YhJ9",
"length": 32,
"entropy_bits_per_char": 4.94,
"file": ".env",
"line": 5,
"hints": [],
"context": "4 \n5> STRIPE_SECRET_KEY=sk_l••••••••••••YhJ9\n6 ..."
}never sent
- ×The full secret. It is masked before the prompt is built, and there is no code path that adds it back.
- ×The rest of your file. Context is five redacted lines around the hit.
- ×Other long high-entropy tokens on those lines. A second scrub masks anything the detectors did not claim.
- ×Your identity. Prompts carry no account, email, or repo owner fields.
guardrails
Where we do not trust the model.
the score is computed
Risk score comes from a fixed formula over severities and verdicts. The model never picks the number.
certain means certain
A private key block, a GitHub token, a live Stripe key, a database URL with a password: the model alone cannot mark these as noise. It needs a pattern-engine hint to agree.
noise stays visible
A dismissed finding is rendered with its reason. You can disagree with the model because you can see what it decided.
schema or nothing
Output is parsed with zod. A malformed answer for a chunk falls back to the rules floor for that chunk.
impact, not technique
The prompt asks what access a third party would gain. It forbids step-by-step abuse instructions, and Leaksweep never validates a credential.
house style filter
Model text passes a small post-filter so reports read the same regardless of which provider answered.
routing
Model-agnostic, stated plainly.
Leaksweep does not depend on one vendor. A thin layer, about 150 lines, takes a system prompt and a JSON payload and returns parsed JSON. It picks the configured provider, walks a fallback chain of model IDs when one is unavailable, and times out instead of hanging. Candidates are judged in small parallel chunks, which keeps a typical sweep near five seconds and means one failed call only affects three findings.
Providers are called under API terms that exclude training on the traffic. If no model is reachable at all, the rules floor takes over: a playbook per credential family with correct verdict logic, impact, and remediation. The summary tile tells you which engine answered.
engine readout
router online chain 3 models deep chunk size 3 candidates timeout 28s per call floor rules, 19 families
Why this cannot be done with patterns alone: read the post.
$ leaksweep init
Sweep your code before someone else does.
Three sweeps a month on the free tier. No card. Secrets masked from the first byte.