From 3bc7059fd3d8ef60f749c23ec1bb4b841f3ab136 Mon Sep 17 00:00:00 2001 From: Marius Ciepluch <11855163+norandom@users.noreply.github.com> Date: Mon, 30 Nov 2026 09:52:13 +0100 Subject: [PATCH] spec(dspy-driver): requirements for stage one, each ending in a run Staged on the maintainer's condition of 2026-11-30: measurable, not theoretic. The example book, the wiring of the prover's trace and Joern's results, the delivery check E0 and the baseline E1 are specified. E2 to E6 enter by dated amendment only after the result before them is read. Generated, not approved. Co-Authored-By: Claude Fable 5.2 --- .kiro/breadth.toml | 2 +- .kiro/specs/dspy-driver/requirements.md | 221 ++++++++++++++++++++++-- .kiro/specs/dspy-driver/spec.json | 7 +- 3 files changed, 208 insertions(+), 22 deletions(-) diff --git a/.kiro/breadth.toml b/.kiro/breadth.toml index 63eef21a..9ef7e9a8 100644 --- a/.kiro/breadth.toml +++ b/.kiro/breadth.toml @@ -38,7 +38,7 @@ open_fronts = 0 # filled by the gate script once it exists [spec.dspy-driver] status = "active" # opened 2026-11-30 line = "dspy-driver" -phase = "initialized" +phase = "requirements-generated" owner = ["src/openultrasast/hunt"] closes = "n/a (active)" diff --git a/.kiro/specs/dspy-driver/requirements.md b/.kiro/specs/dspy-driver/requirements.md index 52710dbd..2b390159 100644 --- a/.kiro/specs/dspy-driver/requirements.md +++ b/.kiro/specs/dspy-driver/requirements.md @@ -1,27 +1,212 @@ # Requirements Document -## Project Description (Input) -**Who has the problem.** The maintainer, and after them a developer who pushes AI-written web application -code (Express/TypeScript, FastAPI/Python) and wants to be told about the access-control and path-traversal -bugs in a change before it ships. +## Introduction -**Current situation.** The driver, the model-driven hunter, is a DSPy program (`src/openultrasast/hunt/`). -It was measured in October 2026 on inputs that describe the shape of code and cannot decide unsafety. The -abstract interpretation the project has, the access-control prover's ordered trace and Joern's taint and -dominance results, is not connected to it: no module under `hunt/` imports `cpg`, and the trace is not among -the driver's inputs. The choices of the DSPy strategy (one call or a tool loop, how many samples, which -optimiser, which examples) were never settled by measurement. +The driver is the model-driven hunter, a DSPy program. It should read a pushed change together with what +abstract interpretation establishes about it (the access-control prover's ordered trace, Joern's taint and +dominance results) and name the locations where the change introduces a bug. Today neither result reaches +the driver, and no choice in its strategy has been settled by measurement. -**What should change.** The driver becomes the mapped-out core of the engine: it reads a change together -with what abstract interpretation establishes about it, is sampled several times and scored by agreement, -and is compiled on training repositories only. Every choice in that strategy is made by one experiment on -named examples, and a small example book lets the maintainer read, per example, what the driver was given, -what it answered and why it missed. Admission populations are never read by this work. +The maintainer's condition for this spec, 2026-11-30: "i need this design to be empircally measureable and +not theoretic. with that I want to avoid another endless circle of specs, that essentially cement things we +have to undo". -The map of the driving, the method, the ordered experiments E0 to E6 and the carried work D1 to D10 are in -`brief.md`. +So this document is staged. It specifies in full only the first stage: the example book, the wiring, the +delivery check (E0) and the baseline (E1). Each requirement ends in something that is run and read. The +later strategy questions (E2 to E6 of `brief.md`) are named in Requirement 7 and get their own criteria only +after the result before them has been read. Nothing is designed or built for a stage whose predecessor has +no result. + +The thresholds in Requirements 5 and 6 are proposals. The maintainer confirms or changes them when +approving this document; after that they are fixed before the runs. + +## Boundary Context + +- **In scope**: the example book; the two producers that hand abstract interpretation to the driver; the + record of one example; the rules of an experiment; the delivery check E0; the baseline E1; the rule by + which later stages enter this spec. +- **Out of scope**: new engine queries or facts; the proof arm; the hook's output and its deadline; + benchmark machinery; any admission run; families other than access control and path traversal; + repositories other than AI-written web applications in TypeScript and Python. +- **Adjacent expectations**: `access-control-prover` supplies the trace as it is today. The engine supplies + its existing taint and dominance queries as they are today. `hunter-learning-loop` supplies the runner, + the paired ablation, the proposer and the acceptance rule as built. Where an experiment shows a fact is + missing, the finding goes to `engine-change-scoped-analysis` with the examples that show it; this spec + does not add the fact. `search-with-proof` and `pre-push-safety-net` consume the driver's ordered + suspects later and are not changed here. ## Requirements - +### Requirement 1: The example book +**Objective:** As the maintainer, I want a small set of real changes I can read end to end, so that every +claim about the driver points at examples I can open. + +#### Acceptance Criteria + +1. The example book shall hold ten vulnerable changes, five of access control and five of path traversal, + each with its fixing change, and twenty ordinary changes from the same repositories. +2. The example book shall draw every change from AI-written web application repositories in TypeScript or + Python, with at least three vulnerable changes in each language. +3. The example book shall record for each vulnerable change the repository, the two revisions, the family, + the labelled file and line range, and the source that establishes the vulnerability. +4. When the maintainer names a change as one to include, the example book shall include it or record why it + cannot be used. +5. If a candidate change belongs to a repository of any admission or evaluation population, then the + example book shall refuse it and name the population. +6. When the example book is frozen, the driver work shall record its digest, and every later record shall + carry that digest. +7. If an example is added, removed or relabelled after the freeze, then the driver work shall record a new + digest and shall not compare results across the two digests as one series. + +### Requirement 2: Abstract interpretation reaches the driver + +**Objective:** As the maintainer, I want the driver to receive what the prover and Joern establish about a +change, so that a driver run measures the engine and not the hunter of October. + +#### Acceptance Criteria + +1. When the driver is asked about an access-control example, the driver work shall give it the prover's + ordered trace for the changed location: the entry, the request-derived arguments with their origin, the + protected operation, the guards, and whether a guard dominates the operation. +2. When the driver is asked about a path-traversal example, the driver work shall give it Joern's results + for the changed functions: the path from a request source to a file operation with its steps, the + sanitizers on that path, and the dominance answer. +3. If a producer has no result for a location, then the driver work shall record one cause from a closed + list (no entry recognised; operation not recognised; call unresolved; no source-to-sink path; language + not supported; engine did not start; engine timed out) and shall hand the driver that statement in + place of a result. +4. The driver work shall record, for every producer run, the number of source bytes read, the engine's + exit status and its run time. +5. If a producer read zero source bytes or the engine exited with an error, then the driver work shall mark + the annotation failed, and shall not record it as empty. +6. The driver work shall run Joern in the shipped image for every recorded result. +7. While an experiment is running, the driver work shall give every arm that includes an annotation the + same annotation bytes for the same example. + +### Requirement 3: One page per example + +**Objective:** As the maintainer, I want to see for any example what the driver was given, what it answered +and why it missed, so that a number never stands without its cases. + +#### Acceptance Criteria + +1. When a run finishes an example, the driver work shall write one page for it holding the annotation the + driver received with its byte count, every answer the driver gave, the labelled location, and hit or + miss. +2. When a vulnerable example is missed, the driver work shall record one cause from a closed list: no + annotation; annotation wrong; annotation right and not used; wrong family; wrong location. +3. When an ordinary example draws a suspicion, the driver work shall record the suspicion and what the + annotation said at that location. +4. If a miss cause cannot be set from the records alone, then the driver work shall mark it "to be read" + and the experiment's result shall count it separately until a person has set it. +5. When the maintainer names an example and a run, the driver work shall show that page with one command. +6. When the maintainer names an example and an arm, the driver work shall run that one example again with + one command and state what the run costs before it starts. + +### Requirement 4: The rules of an experiment + +**Objective:** As the maintainer, I want every change to the driver to be one measured comparison, so that +no strategy choice enters the engine on argument alone. + +#### Acceptance Criteria + +1. When an experiment is opened, the driver work shall record before any run: its question, the one thing + that differs between its arms, the examples, the model and its version, the number of samples per + question, the spend ceiling, and the rule that will read its result. +2. The driver work shall run every arm of an experiment over the same examples. +3. If two arms differ in more than the one recorded thing, then the driver work shall refuse the run. +4. When an experiment ends, the driver work shall report per arm the vulnerable examples found out of the + total, the suspicions per ordinary change, and the top-1, top-3 and top-5 hit counts, with the + per-example table beside them. +5. When an experiment runs on the example book alone, the driver work shall report counts and paired + differences, and shall not report a recall rate without its interval. +6. If the spend of an experiment reaches its ceiling, then the driver work shall stop, keep the finished + records, and report what remains undone. +7. If more than one example in ten of an arm ends in an instrument failure, then the driver work shall + report the experiment as not read and shall give no comparison. +8. When an experiment has been read, the driver work shall record its decision in one dated line: what was + chosen, on which examples, and what would reverse it. + +### Requirement 5: The delivery check (E0) + +**Objective:** As the maintainer, I want to know that the producers deliver before any model is called, so +that the first paid run does not measure an empty input. + +#### Acceptance Criteria + +1. When E0 runs, the driver work shall run both producers over every example of the book and shall make no + model call. +2. When E0 ends, the driver work shall report per family and per language the number of vulnerable examples + whose annotation is nonempty and covers the labelled function, and the causes for the rest. +3. When E0 ends, the driver work shall report the number of ordinary examples with a nonempty annotation. +4. If fewer than four of the five vulnerable examples of a family carry an annotation that covers the + labelled function, then the driver work shall report that family as not ready, and E1 shall not run for + it. +5. When a family is not ready, the driver work shall list the examples and causes that keep it so, as the + input for the engine work. +6. The driver work shall record the run time of each producer per example, with the engine's start-up time + apart from the query time. + +### Requirement 6: The baseline (E1) + +**Objective:** As the maintainer, I want to know whether abstract interpretation helps the driver find the +bugs of the book, so that the central bet of the engine has a result. + +#### Acceptance Criteria + +1. When E1 runs, the driver work shall run three arms over the example book with the driver as it is built + today: no annotation; the prover's trace; Joern's results. +2. The driver work shall report a family only under the arms whose annotation covers it, and under the + arm without annotation. +3. The driver work shall ask each question three times in every arm and shall count an example as found + when at least two of the three answers name the labelled location within ten lines. +4. When E1 ends, the driver work shall state for each family whether the annotated arm found at least two + more of the five vulnerable examples than the arm without annotation, with no more suspicions per + ordinary change. +5. If no family meets that mark, then the driver work shall stop the strategy experiments and report the + miss causes of Requirement 3 as the result, and the next step shall be the maintainer's decision. +6. When a family meets the mark, the driver work shall name the annotated arm as the starting point of the + next experiment for that family. +7. The driver work shall keep the spend of E1 within the maintainer's ceiling of 10 USD. +8. When E1 ends, the driver work shall publish its record under `benchmarks/measurements/` with the example + book's digest, the counts, the per-example pages and the proof that every input was read. + +### Requirement 7: Later stages enter one at a time + +**Objective:** As the maintainer, I want the spec to grow only from results, so that it cements nothing that +a later measurement would have to undo. + +#### Acceptance Criteria + +1. The driver work shall hold these questions as later stages, each without criteria until it is opened: + whether the tool loop earns its cost (E2); whether agreement across samples separates true suspects from + false ones (E3); how the question is cut (E4); whether compilation on training repositories carries to + held-out repositories (E5); whether the annotation is given up front or on demand (E6). +2. When a stage is opened, the driver work shall add its criteria to this document as a dated amendment + that cites the result it rests on. +3. If the experiment before a stage has no read result, then the driver work shall not open the stage and + shall not build for it. +4. The design of this spec shall cover the open stage and the stages already read, and nothing beyond. +5. When a later result contradicts a recorded decision, the driver work shall reverse the decision in a + dated line and shall keep the earlier line as history. +6. The driver work shall reuse the runner, the paired comparison, the proposer and the acceptance rule that + exist, and shall add a new shared contract or abstraction only when two read experiments have needed it. +7. Where a stage compiles the driver, the driver work shall compile on training repositories only, shall + accept a program only when it passes the reversed-surface probe, and shall tune nothing on an admission + label. + +### Requirement 8: Populations and honesty + +**Objective:** As the maintainer, I want the driver work unable to touch what later qualifies a release, so +that a good result here can still be tested fairly. + +#### Acceptance Criteria + +1. The driver work shall read no case, label or result of an admission or evaluation population. +2. If a run names a repository of such a population, then the driver work shall refuse the run before any + model call. +3. The driver work shall treat the example book as development data and shall quote no figure from it as a + detection rate of the tool. +4. The driver work shall record every model call with its model, version, sampling settings and cost. +5. While no paid run is in progress, the driver work shall run with both API keys unset. diff --git a/.kiro/specs/dspy-driver/spec.json b/.kiro/specs/dspy-driver/spec.json index 73668689..bb3f783d 100644 --- a/.kiro/specs/dspy-driver/spec.json +++ b/.kiro/specs/dspy-driver/spec.json @@ -3,10 +3,10 @@ "created_at": "2026-11-30T00:00:00+01:00", "updated_at": "2026-11-30T00:00:00+01:00", "language": "en", - "phase": "initialized", + "phase": "requirements-generated", "approvals": { "requirements": { - "generated": false, + "generated": true, "approved": false }, "design": { @@ -23,5 +23,6 @@ "builds_on": [ "hunter-learning-loop", "access-control-prover" - ] + ], + "staging_note": "Requirements cover stage one only (example book, wiring, E0, E1). Later stages E2 to E6 enter by dated amendment after the result before them is read (Requirement 7)." }