Commit Graph
16 Commits
Author SHA1 Message Date
Marius Ciepluch e2163a4fea feat(scan): an unwritable tree keeps a scan's learnings under the runs directory (item 5b)
The decision of the maintainer on the ninth session's menu, answer 9 (.kiro/handover.md,
untracked, 1340-1343 as it stood on 2026-11-27; the option as offered, 1451-1452):

> 9. The ledger in the image. Answer: "Decide the key now": a digest of the tree's files
> (the `fingerprint` of the `provenance` stage is no digest), one ledger per digest under
> the runs directory; a design note is shown to the maintainer before any code.

The design note (/tmp/opencode/s10_c10_design_note.md, 299 lines) was reviewed in five
rounds before it was shown, and shown to the maintainer whole on 2026-11-27 with its three
questions. The maintainer's answers came on 2026-11-28, through the question tool, each the
recommended option as offered: "Stand as written (Recommended)" on the note's rule of reading
and writing (its section 3.3), "With the runs, by last use (Recommended)" on how long a ledger
stays (section 3.5), and "Build it now (Recommended)". The dated note on task 3.1 of
.kiro/specs/contributor-scan/tasks.md (lines 459-502) carries the rule as approved.

The fault: the image mounts the target read-only, so the ledger a scan writes into the tree
(<target>/.openultrasast/calibration/false_positive_learnings.json) cannot be written there,
the scan records ledger_not_written, and the next scan in the image starts without the
learnings of the one before.

What changed
- src/openultrasast/tree_digest.py: tree_digest(target, runs_directory) (line 48), a sha256
  over one entry per file in path order (the length of the path, a colon, the path, a tab,
  the sha256 of the bytes), after a version line. Left out: links, the directories a scan
  ignores (IGNORED_DIRS, so that the tree's ledger does not change its own key) and the runs
  directory, whichever way it is reached (by device and inode). A file that cannot be read
  and a directory that cannot be listed are named "unreadable"; a directory that can be
  listed but not searched raises, as the scan's own reading of the tree does.
- src/openultrasast/digest_ledger.py: the ledger of a digest, calibration/<digest>.json under
  the runs directory, in the JSON of the tree's ledger. read_digest_ledger (line 47) reads it
  and marks it as used; settle_digest_ledger (line 65) applies the rule.
  The tree took the write: the ledger is removed. The tree refused: the ledger is written
  with its own entries and this scan's new ones, never one whose finding id the tree's
  ledger has, only when that differs from its content, and removed when that would leave it
  empty. No write: a ledger whose every entry the tree's ledger also has is removed. One that
  could not be read (a file that is not a ledger, whatever its top level or its depth) is
  taken for empty and goes, unless the tree refused and this scan wrote it. It is written
  through a temporary file of the writer's own and a rename (line 112).
- src/openultrasast/cli.py: the stage tree_digest, before any stage reads the tree
  (cli.py:603-605); _read_ledgers (cli.py:1085-1099), the tree's ledger and then the
  digest's, the tree's entry winning by finding id; _persist_calibration_feedback
  (cli.py:1101-1136), which writes the tree's ledger when its content would differ from what
  it held, also when only the digest's entries are new to it; the manifest's ledger block
  (cli.py:731-735); a notice when the digest's ledger could not be written or removed
  (cli.py:755).
- src/openultrasast/run.py: prune_expired_ledgers (run.py:112), called by prune_scan_runs
  (run.py:71-99). Under calibration/ of the same two locations as the runs, a ledger, or the
  temporary file it was written through, last used OPENULTRASAST_RUNS_RETENTION_DAYS days
  ago is removed; 0 keeps all. Files called something else, links and directories stay. A
  removal that fails is said once and costs the scan nothing.
- src/openultrasast/reports.py: write_manifest takes ledger (reports.py:212, 254-255). The
  ledger_not_written sentence names the digest's ledger when it holds the learnings
  (reports.py:461-467, chosen at 479-483).
- README.md, docs/examples.md, docs/architecture.md and
  .agents/skills/openultrasast-scan/SKILL.md say where the learnings of a read-only tree go,
  and what removes them.

Two departures from recorded decisions, both put to the maintainer in the note and accepted
with it:
- The tree's ledger is written when a scan learns nothing new, because the digest's entries
  are new to it. The decision of 2026-11-24 says it "is written only when a scan learns
  something" (spec.json:68).
- A ledger of a digest is removed when it expires, and its time is changed when a scan reads
  it. The decision of 2026-11-24 says "the scan's own run and anything not named like a run
  are never touched" (spec.json:73), and dates a run by its id, where a ledger is dated by
  its use.

Measured
- The built function gives the note's prototype's digest for the four-file subject
  (915506a8...) and for libpng's copy (1dcd664f...): s10_c10_port.out.
- In the image, on the final code. A probe image of openultrasast:dev (3f959b31f2f2) with
  the tree's package copied over it, built at 09:06:36Z and holding the tree's 297 .py files
  (s10_c10_image_probe/03_probe_sources.out, s10_c10_sources_still_equal4.out). Standard
  mode, no key, network none. The four C files of contrib/examples of libpng and their
  README, copied fresh and mounted read-only at /target; a scratch runs directory mounted at
  /reports with the wrapper's OPENULTRASAST_RUNS_DIR=/reports (s10_c10_image_probe.sh,
  stamps 09:06:36Z to 09:09:14Z, 2026-11-28).
  - The first scan learns four entries and keeps them in /reports/calibration/<digest>.json:
    calibrations_applied=0, project_score 26, the manifest's ledger {digest_ledger: written,
    learnings_read: {digest: 0, tree: 0}} (10_, 11_). The report names the file.
  - The second scan of the same bytes reads them: calibrations_applied=2 on two files,
    project_score 59, penalty_total 32.0, learnings_read 4 from the digest's ledger,
    digest_ledger "left as it was" (20_, 21_). The file's time is that of the second scan's
    read, 09:07:19Z (22_).
  - The digest the scan took in the image equals the one taken on the host for the same
    files (s10_c10_image_digest_host4.out). The target is unchanged
    (s10_c10_image_target_same4.out).
  - Three earlier runs of this probe and of the native run below, each on the code as it
    stood before a later correction of the same rule (the value for a ledger that could not
    be read; a ledger whose top level is not an object; one nested too deep), gave the same
    numbers. Their stamps: 08:12:50Z to 08:17:31Z, 08:23:38Z to 08:27:42Z and 08:50:15Z to
    08:54:17Z. They are kept as s10_c10_image_probe_run1, _run2, s10_c10_native_run1,
    _run2 and _run3; of the third image run s10_c10_image_probe_run3.out and the host,
    target and sources checks numbered 3 remain, since s10_c10_image_probe_run3 is empty.
    Its files were read by the reviewer in round two.
- The shipped image, the control, on the same files: calibrations_applied=0 and
  project_score 26 on both scans, no ledger block and no ledger (30_ to 42_).
- Natively, on a fresh copy of the same five files, the network off (s10_c10_native.sh,
  09:09:14Z to 09:10:38Z): the first scan writes the tree's ledger (calibrations_applied=0,
  project_score 26, digest_ledger none), the second reads it (calibrations_applied=2,
  project_score 59, learnings_read 4 from the tree's ledger), and no ledger of a digest is
  made (s10_c10_native/10_ to 22_).
- The probe left no container (2 before, 2 after: 00_, 91_) and its image is removed (90_,
  92_).

Tests
- tests/test_tree_digest.py (7) and tests/test_digest_ledger.py (11, one over nine contents
  a file may hold); seven tests in tests/test_scan_output_location.py, six through the scan
  (three over two cases) and one on _read_ledgers; six in tests/test_run_pruning.py; one
  sentence in tests/test_reports.py. The scan test of a refused write selects its run by
  name now, since the runs directory holds calibration/ as well.
- RED on an archive of e231b78 with the final test files: the two unit files do not import
  (s10_c10_red14.out); the scan, pruning and report files give 15 failed, 101 passed
  (s10_c10_red13.out; the tree's tree_digest.py and digest_ledger.py were copied into that
  archive, since the test file imports both, and cli.py, run.py and reports.py were HEAD's).
  On the tree before each fix: the test of a ledger that is not a JSON object failed
  (s10_c10_red8.out), and so did the content nested too deep and its scan test
  (s10_c10_red12.out).
- GREEN on the final tree: 134 passed over the five files (s10_c10_green9.out); 873 passed
  over the 60 files of the scan path (s10_c10_wide4_full.out; the list is
  s10_c10_testfiles.txt); the docs and skills tests, with the strict site build, 11 passed
  (s10_c10_docs_tests4.out; no page changed after it).
- Gates on the final tree: ten zeros (s10_c10e_exits.txt), the three gate outputs equal to
  the baseline.

- Review: three rounds against e231b78, by one reviewer subagent, read-only; no
  docker and no wrapper run, the probes read from their files. Round one blocked
  on one finding and measured it end to end on a scratch tree: a ledger of a
  digest whose top level is not a JSON object raised AttributeError in the tree's
  loader and stopped the scan (exit 1), against the note's "a cache must not stop
  a scan". Round two approved with remarks, which the code and the tests took:
  RecursionError joined the tuple (digest_ledger.py:57), with a ninth content in
  the unit test and a scan test of a ledger that is not a ledger, red before the
  fix (s10_c10_red12.out). Round three approved the code, the tests and the dated
  note, and blocked on one sentence of this message, which named
  s10_c10_image_probe_run3 as kept: that directory is empty. On the final tree the
  reviewer measured the scan past a digest's ledger nested 5000 deep (exit 0,
  "unreadable", the file removed) and passed 30000 contents through
  read_digest_ledger, with none let through; it re-ran the five files (134
  passed), the docs and skills files with two scan files outside the sixty (20
  passed), ruff, mypy (297 files) and the comparison of the three gate outputs
  with the baseline, the gates themselves not run; it recomputed the three
  digests, matched the tree's 297 .py files to the fourth probe image's list, and
  read the fourth image and native runs. The third image run's files were read in
  round two, before they were lost. The sentence was reworded as the reviewer
  wrote it.

By reading, not measured
- A pre-push run does not go through _run_scan, and src/openultrasast/push names no ledger:
  nothing changes there.
- ousast benchmark and the MCP server call _run_scan and get the rule as a scan does.
- mark_all of the hunt tooling lists the children of a runs root it is given; it has no
  caller under src.

Found and not fixed, for the maintainer
- The note says the digest stage's seconds are in the manifest. No stage's are: a stage's
  time is in trace/events.jsonl (stage_start and stage_end), and so is this one's. The pages
  and the dated note do not repeat the sentence.
- The report's sentence (reports.py:461-467) says this scan's learnings are kept in the
  ledger of the digest whenever that file holds some of them (cli.py:1131-1133). A new
  learning whose finding id the tree's ledger already holds is left out by the rule; the
  tree's version stands, and the new evidence text is in the run directory alone. The
  sentence is the note's as approved.
- The tree's own ledger stops the scan when its top level is not a JSON object, or when it
  is nested too deep (calibration.py:157-159, read at cli.py:610 outside any stage). That
  is older than this commit; the ledger of a digest does not.
- read_digest_ledger raises when calibration/ cannot be searched, as the tree's ledger does
  when .openultrasast/calibration cannot (digest_ledger.py:53).
- By reading: a tree whose runs directory is the target itself gets another digest at every
  scan, since its run directory is made inside the target before the stage. Such a tree can
  be written, so its own ledger takes the learnings and no ledger of a digest is made.
- docs/architecture.md draws no provenance stage, which cli.py runs between
  entry_point_mapping and rank.
- The wrapper builds its image only when the image is missing: until a rebuild, a scan
  through it runs the shipped code, which has none of this.
- The notice of a removed ledger names the runs directory as the scan sees it (/reports in
  the image), not the host's path.

Not checked
- the whole test suite; Windows; ops/shell/ousast.ps1 (not read for this commit); two scans
  of one tree at once; the wrapper and the compose route (the probe used docker run with the
  wrapper's mount and override); a removal that fails on a real cache; Docker Desktop, where
  a directory mounted twice may not keep one inode.
2026-11-28 10:21:05 +01:00
Marius Ciepluch 312c09bdbf fix(scan): a scan in the image prunes the wrapper's runs directory too (item 5b)
The maintainer's answer 7 of 2026-11-27 (the ninth session's menu). The label is in
.kiro/specs/contributor-scan/spec.json (80abac5). The record, .kiro/handover.md:1335-1337
(not tracked), in full:

    7. The wrapper's runs are never pruned by a scan in the image. Answer: "Image scan
    prunes too": a scan in the image prunes its runs directory when the wrapper's
    override is set; a change in the scan path, a test first. Not chosen: "Document:
    never pruned" (the session's recommendation); "Queue in step 8"; "Leave it".

The option as offered (handover.md:1435-1436): "the scan path prunes its runs
directory when the wrapper's override is set; a code change, a test first."

A second decision, taken on this change. The reviewer found that the wrapper passes no
OPENULTRASAST_RUNS_RETENTION_DAYS into the image, so with this change alone a scan
through the wrapper would remove runs older than 30 days from
~/.cache/openultrasast/runs, native runs included, even for a user who keeps every run
natively with 0. Asked, the maintainer chose "Pass it through (Recommended)": the
wrappers pass OPENULTRASAST_RUNS_RETENTION_DAYS into the container, one more -e in
ops/shell/ousast.sh and ops/shell/ousast.ps1, a test first. That is the next commit.
This one is the scan path alone, as answer 7 says. The wrapper builds its image only
when it is missing (ops/shell/ousast.sh:64-67), so until the image is rebuilt the
wrapper's scans run the code shipped in it and remove nothing (measured below).

The fault. The shell wrapper mounts ~/.cache/openultrasast/runs at /reports and passes
-e OPENULTRASAST_RUNS_DIR=/reports (d1f61fb). prune_scan_runs returned nothing whenever
OPENULTRASAST_RUNS_DIR was set, so a scan in the image never removed an expired run:
the wrapper's runs were removed only by a later native scan on the default location.

What changed.
- src/openultrasast/config.py: WRAPPER_RUNS_MOUNT = "/reports" and
  runs_dir_is_the_wrappers(), true when OPENULTRASAST_RUNS_DIR is that path.
- src/openultrasast/run.py: prune_scan_runs prunes config.runs_dir when the override
  is unset (as before) or is the wrapper's. Any other override still removes nothing.
- README.md, docs/examples.md and .agents/skills/openultrasast-scan/SKILL.md said that
  nothing is removed from a location chosen with OPENULTRASAST_RUNS_DIR; each says now
  that the shell wrapper is the one exception. The decision says "a change in the scan
  path"; these three sentences state the rule the change alters, and would be false
  without them.
- tests/test_run_pruning.py: its module docstring, and three tests (below).

The session's readings of the decision, to be confirmed by the maintainer.
1. "The wrapper's override" is recognised by its value. Both wrappers pass exactly
   /reports (ops/shell/ousast.sh:91, ops/shell/ousast.ps1:50), and nothing in the
   container's environment tells the wrapper's run from a compose run started by hand.
   Two consequences, by reading: a native scan with OPENULTRASAST_RUNS_DIR=/reports is
   pruned as well; and a compose run started by hand with the same -e and the default
   ./reports mounted prunes run-shaped directories older than 30 days under the
   checkout's reports/ (docker-compose.yml:33-34).
2. The compose file's own value, /reports/runs (docker-compose.yml:47), is a chosen
   location and is not pruned: there ./reports on the host is mounted, which may hold
   more than runs.

This amends the run retention decided on 2026-11-24 (spec.json, approval_history entry
six: "after each scan, with no OPENULTRASAST_RUNS_DIR set, runs in the default location
older than 30 days are removed"): the wrapper's mount is pruned as well.

Measured, in an image. The script is /tmp/opencode/s10_c7_probe.sh and its files are
under /tmp/opencode/s10_c7_probe/, one per measurement; the files of the four scans
and of the listings after them start with the command they ran. The four scans' stamps
run from 17:57:27Z to 17:57:32Z; the listings carry none. The probe image is
openultrasast:dev (3f959b31f2f2, uid 1000) with the working tree's package copied
over it: 295 files, equal to the tree by
sha256 (03_probe_sources.out is a bare list of digests; the comparison is
/tmp/opencode/s10_c7_sources_cmp.out, which starts with its command). Every runs
directory is a scratch directory mounted at /reports; the real ~/.cache/openultrasast/
runs was not mounted. Network off, no key. The subject is a fresh copy of the four C
files and their README (04_subject.out). Each scratch runs directory held a run of 40
days ago, a run of 5 days ago and a directory called notes.
- With the wrapper's override, on the probe image (10_wrapper_override.out): exit 0,
  file_targets=4, findings=4, and the line
  "notice: removed 1 run older than 30 days from /reports". The expired run is gone;
  the run of 5 days ago, the new run and notes remain (11_wrapper_override_after.out).
- With the compose file's /reports/runs (20_compose_override.out,
  21_compose_override_after.out): no notice, all three entries remain.
- With the wrapper's override on the shipped image (30_shipped_image.out,
  31_shipped_image_after.out): no notice, all three remain: the fault as shipped.
- With the wrapper's override and OPENULTRASAST_RUNS_RETENTION_DAYS=0 passed into the
  container (40_retention_zero.out, 41_retention_zero_after.out): no notice, all three
  remain.
- The probe image is removed (90_remove_probe.out); no container remains
  (91_containers_after.out).
The wrapper itself was not run.

Tests (tests/test_run_pruning.py).
- test_a_scan_through_the_wrapper_removes_the_expired_runs_from_the_mounted_runs_directory
  calls prune_scan_runs, as cli.py:720 does, with OPENULTRASAST_RUNS_DIR=/reports and
  a runs directory that stands in for /reports, which only root can make on the host.
  It expects one notice, and the run of 5 days ago and the current run to remain.
- test_a_scan_that_compose_runs_without_the_wrapper_removes_nothing: /reports/runs
  removes nothing and says nothing.
- test_the_wrapper_passes_the_override_that_a_scan_prunes: the shell wrapper's command
  holds "-e OPENULTRASAST_RUNS_DIR=" + WRAPPER_RUNS_MOUNT, so its word and the scan's
  mount point cannot drift apart. Nothing reads the PowerShell wrapper's.
RED. An archive of HEAD (src, tests, pyproject.toml) with the first test as written,
the package imported from the archive (s10_c7_red_where.out): 1 failed, 1 passed; the
passed one was a throwaway test that printed where the package came from and was
removed after. The failure is at
"assert () == ('removed 1 run older than 30 days from .../reports',)"
(s10_c7_red.out). The command, run from the archive's directory, where the throwaway
test was tests/test_zz_where.py:
env -u OPENROUTER_API_KEY -u DEEPSEEK_API_KEY PYTHONPATH=/tmp/opencode/s10_c7_head/src
/home/mc/Source/OpenUltraSAST/.venv/bin/python -m pytest -q -p no:cacheprovider
tests/test_run_pruning.py tests/test_zz_where.py -k "where or through_the_wrapper"
GREEN: 250 passed on the final tree (s10_c7_green4.out; the command is not
in the file) over
tests/test_run_pruning.py tests/test_scan_output_location.py tests/test_config.py
tests/test_run.py tests/test_mcp.py tests/test_agent_skills.py
tests/test_shell_wrapper.py tests/test_task_images.py tests/test_benchmark.py
tests/test_benchmark_artifact_contract.py tests/test_model_scope.py
tests/test_pair_harvest.py.
Mutants, to show the two guards bite: the tree's sources with one line changed and the
final test file (the copies are /tmp/opencode/s10_c7_mutA, mutB, mutC).
- the predicate "_runs_dir_override().startswith(WRAPPER_RUNS_MOUNT)" fails the
  compose test alone (s10_c7_mutA2.out: 1 failed, 36 passed);
- WRAPPER_RUNS_MOUNT = "/reports2" fails the wrapper test and the first test
  (s10_c7_mutB2.out: 2 failed, 35 passed);
- HEAD's condition, "if runs_dir_is_overridden():", fails the first test alone, at the
  assertion above (s10_c7_mutC2.out: 1 failed, 36 passed).

Checks on the final tree. mkdocs build --strict exits 0 (s10_c7_mkdocs2.out; its
examples page is byte-identical to the first build's); ruff format, ruff check, mypy,
compileall and the three gates pass, and the gates print what they printed before the
change (s10_c7d_exits.txt). Three files date from before the test module's docstring
was edited, on documentation unchanged since: the first build's examples page holds
each of the three added phrases once and the old wording zero times
(s10_c7_site_sentence.out), and tests/test_docs_site.py with
tests/test_removed_plane_references.py gave 8 passed (s10_c7_docs_tests.out). An
earlier gates run found an unused name in the first test (s10_c7_ruff_check.out); it
is removed.

- Review: two rounds by a reviewer subagent, reading and re-running, no docker. Round one
  found the code right for answer 7 (RED reproduced on an archive of HEAD, 250 passed over
  the 12 files, the three mutants failing as stated) and conditioned the commit on a
  decision: the wrapper passed no retention variable into the image, so this change alone
  broke "0 keeps every run" on the wrapper path. Asked, the maintainer chose "Pass it
  through (Recommended)"; the wrapper's commit follows at once, before other work and any
  push. Round two found the delta to be the test module's docstring; re-ran the 12 files
  (250 passed), the docs tests, ruff, mypy, mkdocs and the three mutants; checked the
  round-two evidence against the test file's last change and every sentence of this
  message, and had two false sentences corrected: the spec.json path and the RED command.

By reading, not measured.
- cli.py:720 passes the config whose runs_dir is /reports in the image (config.py,
  _runs_dir), so the scan in the image prunes that directory.
- ops/shell/ousast.ps1:50 passes the same override; PowerShell is not installed here.
- A failed removal still costs the scan nothing: prune_scan_runs catches OSError and
  RecursionError, and tests/test_run_pruning.py has two scans whose removal fails.
- `ousast benchmark` in the image goes through the same line (cli.py:1123, then
  cli.py:720) and prunes once per benchmark scan. That is answer 7's rule.

Found and not fixed, for the maintainer.
- The notice names the path the scan sees, /reports, not the host's
  ~/.cache/openultrasast/runs.

Not checked: the whole test suite; the wrapper and a compose run (the image was run
with docker run on scratch mounts); a removal that fails inside the container; Windows
and ops/shell/ousast.ps1; a native scan with OPENULTRASAST_RUNS_DIR=/reports.
2026-11-27 19:36:15 +01:00
Marius Ciepluch 09a9fcea96 docs(contributor-scan): the user docs name the skipped runs directory and its notice (3.1, follow-up)
By the maintainer's decision of 2026-11-25, as the handover records it: "One
sentence in README.md and docs/examples.md, in its own docs commit: a scan does
not read the files under its runs directory when it lies inside the scanned
path. A notice chosen above would be documented in the same place."

The sentence, the same in both files: "A scan does not read the files under its
runs directory when that directory lies inside the scanned path; when this
leaves source files out of the scan, `ousast` prints one `notice:` line naming
the directory and how many." It closes the run-location paragraph of README.md
and sits in the first paragraph of docs/examples.md, before the benchmark
sentence.

"when this leaves source files out of the scan" is the exact promise of
`52c9afb`: the notice counts what the skip took out of the scan, so a source
file that the target's root `.gitignore` or an ignored directory already keeps
out brings none. "`ousast` prints" matches the retention sentence two lines up;
`ousast scan` and `ousast benchmark` print the line, and the
`openultrasast.scan` and `openultrasast.benchmark` tools return the same text
among their notices instead (the independent reviewer's probes). The first
clause keeps the maintainer's words: nothing under the runs directory becomes a
file target, while the other readers of a scanned tree stay as they are by the
decision "No, leave them"; a route manifest under the runs directory is still
read.

No code changes. The two documentation test files pass (8 passed). An
independent reviewer approved the change in two rounds; its first round found
that the first wording, "when source files are left out there", promised a
notice for files the scan was not going to read anyway, which this wording
closes.
2026-11-25 17:44:42 +01:00
Marius Ciepluch 9e4983f465 feat(contributor-scan): benchmark runs go beside the scan runs (3.1, follow-up)
`ousast benchmark` and its MCP twin wrote a run to
`<target>/.openultrasast/benchmarks/<id>/`, into the scanned tree, and no user
document said so. By the maintainer decision of 2026-11-24 a benchmark run now
goes to `<runs_dir>/<benchmark-run-id>/`, beside the scan runs, where run
retention removes it like a scan run.

`create_benchmark_run` in src/openultrasast/benchmark.py takes the runs
directory instead of the target. The two `_benchmark` functions, in cli.py and
in mcp.py, load the configuration the way `_run_scan` does and pass
`config.runs_dir`, so a benchmark run follows `OPENULTRASAST_RUNS_DIR` like the
scan it runs.

Both create the run once the scan has returned. Created first, as it was, the
run was under the scan's own retention while the scan ran, and a scan that
outlasted the retention window took it for an old one: the scoreboard could not
be written and the scan outcome was never printed. A failed scan now also
leaves no empty run behind.

README.md and docs/examples.md name where a benchmark run goes.

Tests: the three location assertions failed before the change and pass after
it. A new test pins that retention removes a benchmark run like a scan run, and
another that a benchmark keeps its run when its scan outlasts the retention
window. The nine test files around the change pass (120 passed); ruff, mypy,
the three gates and compileall pass. A run of the real CLI printed `run_dir=`
and `benchmark_run_dir=` as siblings under the runs directory and left only the
calibration ledger in the scanned tree. An independent reviewer approved the
change in two rounds; its first round found the retention window, which this
cut closes.
2026-11-25 10:40:01 +01:00
Marius Ciepluch 17d46c0f93 feat(contributor-scan): remove scan runs older than 30 days from the default cache (3.1, run retention)
By maintainer decision. Since 6edae3a a native scan leaves a run directory
under ~/.cache/openultrasast/runs/ and nothing removed them. After a scan's
manifest is written, with no OPENULTRASAST_RUNS_DIR set, the runs in that
default location that are older than 30 days are now removed. The age comes
from the UTC timestamp in the run id, never from file times, so a copied or
touched directory is not misjudged, and a run exactly 30 days old is kept.

Never touched: the scan's own run; anything not named exactly like a run
(only direct children of the runs root whose name is a run id); symlinks,
which are neither followed nor removed; and any location chosen with
OPENULTRASAST_RUNS_DIR, even when it resolves to the default.

OPENULTRASAST_RUNS_RETENTION_DAYS sets the number of days and 0 keeps every
run. A failed prune never fails the scan: it is one notice on the command
line, and the MCP scan and benchmark results now carry a notices key. A
retention longer than the calendar and a directory tree too deep to remove
are both turned into that same behaviour.

Known limits, on record: a removal that fails part-way leaves the run half
deleted and it is retried on every later scan; the prune stops at the first
failure; a clock set far ahead removes earlier runs; a filesystem mounted at
or under an expired run is emptied before the removal fails.

Tests: tests/test_run_pruning.py drives the function and the real command
line (34 tests); tests/test_mcp.py pins the notices. The reviewer attacked
the deletion path with about sixty hostile inputs and twenty-three mutations;
all are killed or kept safe.
2026-11-24 17:51:37 +01:00
Marius Ciepluch 6edae3a585 feat(contributor-scan): a scan writes its run to the user cache, and the ledger only when it learns (3.1, part A)
Where a scan writes. A native scan now creates its run under the user cache,
~/.cache/openultrasast/runs/<scan-id>/ by default ($XDG_CACHE_HOME when it is
set and absolute), prints run_dir=<path> once, and no longer writes anything
under the analysed tree. OPENULTRASAST_RUNS_DIR still wins: an absolute value
is used as given, a relative one resolves against the working directory.
Pre-push storage is unchanged.

The calibration ledger, by maintainer decision: .openultrasast/calibration/
stays the store, and a scan writes the false-positive ledger into the tree
only when its content would change. On a read-only tree the scan records
ledger_not_written, with a sentence in the report, and completes; before, a
read-only target with one rejected finding crashed before report.md existed.

benchmarks/repos/measure.py follows the printed run directory. It read the
run from under the scanned copy, which would have recorded every repository
as failed, and it also read a stale run left in a copy.

Tests: tests/test_scan_output_location.py drives the real CLI and compares
the whole tree before and after; tests/test_repo_measure.py pins the
measurement script; an autouse fixture keeps every test's scan runs out of
the developer's cache; fourteen test files follow the run to its new place.
README, docs/examples.md and the scan skill name the ledger as the one write
a scan makes. _run_scan is touched by one line and stays over the complexity
cap.

Task 3.1 stays open for part B, the readable summary.
2026-11-24 15:33:35 +01:00
Marius CiepluchandClaude Fable 5.1 94e96c6885 chore(p0): remove the improve lever and the plane improvement loop
Off every active line (PATHFINDER-2026-10-13/03-unified-proposal.md, cuts).
Deleted: src/openultrasast/improve/ (1,175 lines), the ousast improve
subcommand, plane/tasks/loop.py and loop.yaml with the --loop generation,
the memory-snapshot step in memory.seed, pairs.build_pair_signals, and the
four improve tests plus the loop cases in other tests. Docs no longer
describe the lever. Net: 3,073 lines deleted, 83 added. Targeted tests:
154 passed; 3,436 tests collect.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
2026-10-13 10:34:57 +02:00
Marius CiepluchandClaude Opus 5.5 552671ca6a docs: plain-language pass -- README, index, where we stand, scanning, examples, threat model
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
2026-10-02 21:01:10 +02:00
Marius CiepluchandClaude Fable 5.1 5aac7eac36 docs: audit against v2.0.0; deployment guide (local ax and a separate Kubernetes cluster)
Every README and docs page checked against ousast --help, the code and the committed records. New docs/deployment.md (in the nav): what runs where today, this host's setup (up.sh, doctor, smoke Run, footprint), step-by-step guidance for a separate Kubernetes cluster with implemented vs planned stated per item (no cluster deployment has been made; kube context and doctor's registry check are hard-coded in doctor.py, egress.py, router.py), and what the plane/ manifests need changed. Decision-engine pages state slice 2 (six families, pooled and within-pair AUC, BLOCK offered nowhere, canary below 0.9 for three families, positives-only inflation) and that the engine is not adopted; exp-002 registered, not run, no result quoted. Fixed: model/judge.py reference (now model/pipeline.py), missing-key behaviour, .env reference (OPENROUTER_EMBEDDING_MODEL, store variables), docs extra, plane memory-normalise and ousast index listed, ax README's cluster table made precise. RELEASE_NOTES gets an Unreleased entry.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
2026-10-02 16:03:46 +02:00
Marius CiepluchandClaude Opus 5.5 95a252b89b docs: MkDocs site with flow diagrams; RustFS permissions
Material for MkDocs site (mkdocs.yml, optional extra `docs`) with Mermaid via
the superfences custom fence. New pages: overview, scanning (modes, quick
rules, Joern engine, priors, pre-push delta), the plane on ax (one task as a
sequence, golden snapshot, Run DAGs), memory (row kinds, write/read paths,
FileStore vs S3, verify at startup), memory and detection, and RustFS setup
(admin steps, complete agent policy, .env, refusal messages, Select limit).
The ops READMEs are included at build time; evaluation gains the population
lifecycle and the fold layout. tests/test_docs_site.py runs the strict build
when mkdocs is importable and checks Mermaid blocks and the RustFS page.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
2026-10-02 08:17:40 +02:00
Marius CiepluchandClaude Opus 5.5 32a2cb8bcf docs: describe the system as of 2026-10-02 (ax plane, AI decision engine, PHP, v3)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
2026-10-02 07:08:44 +02:00
Marius CiepluchandClaude Opus 5.5 f4bd984fda docs(harnessx-removal): the plane replaces HarnessX in README, docs and specs (task 8)
README: "Configuring the HarnessX agentic plane" becomes "The agentic
plane (ax)" (ousast plane run|status|doctor|remember, per-task Model,
budget and egress, pointer to ops/ax/README.md, one tagged retirement
line); "The HarnessX self-improving cycle" becomes "The self-improving
cycle", and its MetaAgent paragraph is replaced by the memory proposer
(`ousast improve --memory`, provenance, train-on-test guard). The fusion
panel_model/decider_model lines and the [harnessx] spend caps are gone.
The README reference test now passes without its strict xfail.

docs/examples.md section 6 runs the plane; docs/threat-model.md describes
the per-task EgressPolicy, the usd/calls budgets and the start-request
credential path. RELEASE_NOTES.md gets an Unreleased entry: HarnessX
removed, the retired keys and their errors, the silent loss of the
second hunter for users who set [models] hunter, and the plane as the
agentic path.

Dated retirement notes (2026-09-30) head the requirements, design and
brief of harnessx-self-improving-rulesets, learning-harness,
three-stage-scan and openrouter-sast-harness, and follow the spec table
in steering/overview.md; history is unchanged. All tasks are checked, so
spec.json moves to implementation-complete.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01EmM1j46qgKMh3zqD1QMwEo
2026-09-30 12:45:29 +02:00
Marius CiepluchandClaude Fable 5.1 b3b47ad757 feat(corpus-seeded-mechanisms): the mechanisms lever runs from ousast improve
Review rounds 3-5 remediations (Req 5, 7).

- ousast improve resolves candidates from the target's calibration dir,
  then the working directory's (where `mechanisms export` writes), and
  admits into <target>/.openultrasast/calibration/mechanisms.jsonl,
  where a scan of that target reads; --mechanism-candidates,
  --mechanism-store, --no-mechanisms; --dry-run redirects the store to
  scratch; accepted rounds print admit/retract <id>.
- run_improvement threads the store paths; RoundOutcome carries the
  mechanism edits; reverted mechanism keys are blocked outright; a
  no-gain admission is rejected as mechanism_no_gain; a retraction may
  name an admitted record that left the candidate set.
- leave-one-out forwards variant-search degradations and pins the
  containment and label rules; mechanisms export defaults to the
  candidates file so it never re-admits a tombstone.
- design §Lever rewritten to the implemented gate; README and docs show
  export -> improve -> scan.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
2026-09-05 15:35:08 +02:00
Marius CiepluchandClaude Fable 5.1 3c36f13e03 feat(pair-corpus-honesty): LLM-generated Real-Vuln repos and unlicensed agent fixes as pointer pairs
Task 8.4 (Req 10.6, 5.1).

- harvest.merge_recipes appends recipes by name and never rewrites
  existing rows.
- vibe-py/build_recipes.py --pointers: the 40 LLM-generated repositories
  without a license become vendored = false rows (80 pairs, agent,
  seeded) appended to recipes.toml; unlicensed human repos stay skipped.
- agent-vfc/build_recipes.py --from ... --pointers [--cache]: unlicensed
  agent-authored fixes become title-tier pointer rows whose function
  label is derived from the cached excerpt (30 added from a fresh
  662-candidate search); TOML booleans rendered correctly.
- catalogs regenerated: vibe-py 115 rows (35 vendored + 80 pointer),
  agent-vfc 59 (29 + 30); no excerpt is vendored for any pointer row.
- `pairs --slice vibe-py --pointers` scores both provenances (human 35,
  agent 80); the default run skips 80 pairs with pointer_pair_skipped;
  suite and gates unchanged. README/docs name the nightly command.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01T7XD7x5KonMdmGRkp63EQG
2026-09-05 10:45:43 +02:00
Marius Ciepluch 1ae41eea19 feat(propose-adjudicate-prove): overlay adjudicates inventory before prove
Regex inventory stays the proposer. MAP attaches promote/demote/unadjudicated/coverage
from intra-file taint (tree-sitter when a grammar parses, Python ast as last resort).
Deep sandboxes promotions only, ordered by the existing heuristic ranker plus optional
OpenRouter mechanism recall. The SAST pair slice scores overlay outcomes; the stage-1
detection gate and local pair gate stay inventory-only.
2026-09-04 13:57:33 +02:00
Marius CiepluchandClaude Opus 4.8 b5e40318db feat(hardening): Phase 15 — redaction, retry/backoff, budgets, threat-model docs
Release-readiness hardening.

- redaction.py (zero-dep): redact_secrets masks provider API keys, AWS/GitHub/Slack/
  Google tokens, bearer tokens, URL-embedded credentials, PEM private keys, and
  sensitive key=value assignments. Wired into the trace writer and the markdown report
  (on by default), so scan artifacts never leak a credential quoted from source.
- provider/openrouter.py: call_with_retry — exponential backoff on transient failures
  (HTTP 429/5xx, connection errors, timeouts); non-transient errors fail fast. Both the
  chat and embedding clients use it (max_attempts/retry_base_delay configurable).
- config [hardening]: redact_secrets (default true) + max_findings (bounded-CI output
  cap, 0 = unlimited; truncation is severity-ordered and disclosed as a `budget`
  degradation). Agentic spend stays bounded by [harnessx] max_cost_usd/token_threshold.
- docs/threat-model.md (trust boundaries, controls, sandbox limits) + docs/examples.md
  (six end-to-end walkthroughs); README "Security & hardening" section links both.
- CI lint/typecheck/test/detection-gate/dagger gates already existed.

tests/test_redaction.py, test_provider_retry.py, test_hardening_pipeline.py + config
tests. 206 passed, 4 skipped; ruff + mypy clean; detection gate PASS.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-06-22 20:02:34 +02:00