The open work of hunter-learning-loop (4.1, 6 and the group 7 of the same day) moves to dspy-driver as D1 to D10. The brief maps the driving in seven stages and orders the experiments E0 to E6. The abstract interpretation is wired in before anything is measured: the prover's trace and Joern's results are not inputs of the driver today. HarnessX is gone from the tree, and the four plane modules the ledger suspected are still imported. Co-Authored-By: Claude Fable 5.2 <[email protected]>
12 KiB
Brief: the DSPy driver
Opened 2026-11-30 on the maintainer's words: "I would like to approach this empircally as a focus, and measure the driver by example. I would like to focus on a dspy strategy and map out this driving soldily because it is the core of the engine. can we move this into an extra spec?"
This spec is line 1 of the roadmap of 2026-11-30 (.kiro/steering/roadmap.md, top section). It takes the
open work of hunter-learning-loop (tasks 4.1, 6 and the group 7 added that day) and owns the driver from
here. hunter-learning-loop keeps what it delivered: the feature table, the paired ablation, the proposer
and the acceptance rule. This spec builds on that code and does not rebuild it.
Problem
- Who has it. The maintainer, and after them a developer who pushes AI-written web application code.
- Today. The driver is the model-driven hunter, a DSPy program (
src/openultrasast/hunt/program.py). It was measured in October with inputs that describe the shape of the code around a change, and those inputs could not decide whether a change is unsafe. The project then built a deterministic prover and kept Joern, and never connected either to the driver. Read on 2026-11-30: no module underhunt/,learn/or the hunter tools importscpg, and the prover's trace is not among the driver's inputs. So the core of the engine, a model that drives the search with what abstract interpretation establishes, does not exist as a running thing. Nobody has decided, on evidence, how the DSPy program should be built either: one call or a tool loop, how many samples, which optimiser, on what examples. - What should change. The driver is mapped out as a DSPy strategy, wired to the abstract interpretation, and every choice in that strategy is made by an experiment on named examples. The maintainer can open any example and see what the driver was given, what it answered, and why it missed.
What exists (read in the code on 2026-11-30, not run)
| Part | Where | State |
|---|---|---|
| Program | hunt/program.py: HuntProgram, a dspy.Module; a dspy.ReAct loop when tools are bound, else dspy.Predict |
built |
| Signature | signature_for(mask): nine text inputs, one output findings: list[Finding] (path, line, family, confidence, rationale, cited lines) |
built |
| Inputs | change summary, hunks, enclosing function, callers, entry points, roles, def-use, a function-local obligations check, the family list | built; shape features |
| Tools | read_file, grep_repo, find_refs, clamped to the repository |
built |
| Model | build_lm: DeepSeek through dspy.LM, disk cache, fixed temperature |
built |
| Runner | hunt/runner.py: one record per change, input digest, spend ledger, InstrumentFailure |
built |
| Metric | hunt/metric.py: search_outcome (a finding within 10 lines of the labelled location) and search_metric |
built |
| Ablation | hunt/ablation.py: paired arms over the same changes, repository-clustered bootstrap |
built |
| Proposer | hunt/propose.py: GEPA, MIPROv2 or BootstrapFewShot, one change per round, on compile folds |
built |
| Acceptance | hunt/accept.py: compile and held-out folds both non-negative, one strictly positive |
built |
| Probe | core/probes.py: reversed-surface probes against shortcuts |
built |
| Prover trace | hunt/prover.py over semantic/ (tree-sitter, control-flow graph, dominance, abstract domain, path composition); access control |
built; not an input of the driver |
| Joern | cpg/, used by model/taint.py, model/dominance.py and push/ |
built; not reachable from the driver |
| Sampling | one answer per question | missing: no repeated sampling, no agreement score |
| Examples | pool manifests and a feature table | missing: no small set a person can read end to end |
The driving, mapped
One pushed change goes through these stages. Each stage names the choice that is open and the experiment that settles it.
- The question. One change, and per changed function one question: does this change introduce a weakness of family F that an attacker can reach? Open: one question per change or one per changed function and family (E4).
- What abstract interpretation says. Two producers, each proving it read nonzero input.
- The prover's ordered trace: the entry, the request-derived arguments with their provenance, the protected operation, the guards and whether one dominates. Family: access control.
- Joern's results for the changed functions: the taint path from a request source to a sink with its steps, the sanitizers on it, the dominance answer. Family first: path traversal.
- A location with no result says why (no entry recognised, operation not recognised, unresolved call, engine did not start). An empty annotation and a failed one are different records. Open: whether the results are handed over up front, or the driver asks for them through a tool (E6).
- The signature. Inputs: the change, the abstract interpretation for it, the family definition. Output: suspects, each with a location, a family, the step of the trace it rests on, and a rationale. Open: one signature for all families or one per family; one step or two (locate, then judge) (E4).
- The module.
dspy.Predict,dspy.ChainOfThoughtor thedspy.ReActtool loop. Open: whether the tool loop still earns its cost once the trace is in the input (E2). - The probabilistic loop. The question is asked k times. A suspect's score is the share of samples that name it. The score orders suspects; it establishes nothing. Open: k, the temperature, and whether agreement separates true suspects from false ones at all (E3).
- Compilation. Instructions and demonstrations chosen by a DSPy optimiser on compile folds of training repositories, accepted by the existing rule, and passed through the reversed-surface probe. Open: instructions only (GEPA with the metric's feedback) against demonstrations (bootstrap), and whether either beats the uncompiled program on held-out folds (E5).
- The output. Ordered suspects go to the proof arm as starting intents (
search-with-proof7.1) and to the hook as advisory lines (pre-push-safety-net18.1). The driver's opinion never becomes evidence: a finding needs the trace's own rule or a demonstration.
Method: measure by example
- The example book. A small set of real changes that a person can read end to end, in the chosen
scope: access control and path traversal, in AI-written web applications (Express/TypeScript,
FastAPI/Python). To start: ten vulnerable changes, five per family, each with its fixed side, and
twenty ordinary changes from the same repositories. Each is a
dspy.Examplewith the labelled location and family. The book is development data: it is open, it is looked at, and nothing in it is ever an admission case. - One page per example. What the producers gave the driver (with byte counts), the k answers, the agreement score, hit or miss, and for a miss one cause from a closed list: no annotation; annotation wrong; annotation right and ignored; wrong family; wrong location; ordinary change flagged.
- One experiment at a time. An experiment names its lever, changes one thing, runs the same examples
on both arms, and reports the paired difference with the per-example table beside it. Its manifest is
fixed before it runs. This is rule 12 of
detection-quality.md. - Three sets, never mixed. The example book (read freely), the training set with its compile and held-out folds (teaches and selects), and the admission populations (untouched, read once).
- Two numbers and the table. Search recall on vulnerable changes and suspicions per ordinary push, with counts and intervals, and top-K recall per push (K = 1, 3, 5). At book size the intervals are wide: the book shows mechanisms and causes, the training set gives the numbers.
Experiments, in order
| Id | Question | Arms | Needs |
|---|---|---|---|
| E0 | Do the producers deliver? | share of examples with a nonempty annotation, per family and producer | D1, D2, D3; no model call |
| E1 | Does abstract interpretation help the driver? | no annotation; prover trace; Joern results | E0 |
| E2 | Does the tool loop earn its cost? | Predict; ChainOfThought; ReAct | E1 |
| E3 | Does agreement mean anything? | k = 1, 3, 5; score against hit or miss | E1 |
| E4 | How should the question be cut? | one signature; one per family; locate then judge | E2 |
| E5 | Does compilation generalise? | uncompiled; GEPA instructions; bootstrap demonstrations; on held-out folds | D6, E4 |
| E6 | Up front or on demand? | annotation in the input; annotation behind a tool | E2 |
E0 costs nothing and comes first. E1 is the baseline of the roadmap's step N1 and has the maintainer's ceiling of 10 USD. Every later experiment needs its own ceiling.
Carried work
Input for the requirements and task phases. The ids are this brief's.
| Id | Work | From |
|---|---|---|
| D1 | The example book: the thirty changes, their labels, the page format, the closed list of miss causes | new |
| D2 | The prover's trace as an annotation of HuntProgram |
hunter-learning-loop 7.1a; reachability-flow-model 4.1 |
| D3 | Joern's results as an annotation: one run per revision, cached, in the shipped image, engine exit code on record | hunter-learning-loop 7.1b |
| D4 | The baseline in three arms (E1) | hunter-learning-loop 7.2 |
| D5 | Repeated sampling, the agreement score, top-K recall per push | hunter-learning-loop 7.3; learned-decision-engine 17.1, 17.2 |
| D6 | The training set apart from every admission population, with vibe-code pairs, one as a whole repository | hunter-learning-loop 4.1; contributor-scan 5.2 |
| D7 | Compilation on training repositories, the acceptance rule, the reversed-surface probe | hunter-learning-loop 7.4; learned-decision-engine 16 |
| D8 | The driver gives an opinion on intent and raises no evidence | hunter-learning-loop 7.5; authorization-obligations 3.3 |
| D9 | The handoff of the top suspects to the proof arm | hunter-learning-loop 7.6 |
| D10 | One read of an accepted program on a held-out pilot, at most once per program | hunter-learning-loop 6 |
Scope
- In. The driver's inputs, signature, module, sampling, compilation and output; the two producers; the example book; the experiments above.
- Out. New engine queries or facts (they go to
engine-change-scoped-analysis, and only when an experiment names the missing fact). The proof arm. The hook's output and its deadline. Benchmark machinery. Families other than the two chosen, until E1 has been read.
Constraints
- Admission and evaluation populations never train and are never read during this work.
- Software shape features alone decide nothing; a compiled program passes the reversed-surface probe.
- A zero proves its instrument: every producer and every run records the bytes it read and the exit codes.
- Joern runs in the shipped image, once per revision, offline for these runs. Its start-up time is recorded and does not gate an experiment.
- Paid runs have a ceiling set by the maintainer before they start. Both API keys are unset for anything that is not a paid run.
- Standard metrics, plain English, ASCII in written files.
Open questions for the requirements phase
- Which thirty changes go into the example book, and from which repositories. The maintainer may want to name some: the bugs they want to avoid.
- Whether the driver stays on DeepSeek for every experiment, or a second model is an arm.
- Whether the driver's records adopt the core's model contract (
hunt/model_contract.py) from the start. - What "found" means for path traversal: the sink line, the unsanitised step, or either.