Skip to content

Releases

ruleprobe v0.3.0rc1

ruleprobe v0.3.0rc1 Pre-release
Pre-release

Choose a tag to compare

@github-actions github-actions released this 12 Oct 23:00
d3ab542

Added

  • The package metadata links the reference site, https://ruleprobe.jakeselby.com, as its
    Documentation URL (#67). The site is built
    from the README, this changelog and the planning corpus at each release tag.
  • ruleprobe corpus scores the rule binder over a synthetic rules zoo shipped at
    ruleprobe/corpus/rules-zoo.json, and prints its precision and recall per catalog entry under
    the detector table; --json carries them under binding. Any false bind fails the command
    whatever --floor says, and on the shipped zoo recall fails under a recorded floor that rises as
    binding improves (#139).
  • The catalog binds rules about the four shipped detectors it left unbound: never compact the
    context (cache-hygiene/compact), never switch models mid-session
    (cache-hygiene/model-switch), never write a secret into a file (secrets/secret-in-write)
    and filter every find (transcript-hygiene/unfiltered-find). A bound rule is measured by the
    shipped detector, and a rule narrower than what the detector counts, such as "never compact
    more than once", "never switch models mid-task" or "never paste secrets", binds nothing, and ruleprobe detectors now marks all six shipped detectors catalog. The
    rules zoo gains positives and near-misses for each; binding recall on it
    rises to 0.71 with no false bind, and the recorded recall floor with it
    (#143).
  • ruleprobe report with no --rules finds your rule files itself: ~/.claude/CLAUDE.md,
    ~/.codex/AGENTS.md and ~/.gemini/GEMINI.md, and each runtime's project rule files at every
    working directory the transcripts recorded, following Claude Code and Gemini @path imports of
    markdown five hops deep. It names each rule by where its file is, reads a file with the same
    bytes as another once, and says in the coverage block that the rule text is today's. A found
    file binds through the catalog alone, since it may be a clone of somebody else's repository: its
    front matter is ignored, every file and import must resolve inside its project (a global file
    anywhere under the home folder), and a file over 1 MB or past 200 in one rules folder is
    skipped; refused and skipped files are counted, never read or named. --no-config turns it off. A section a word unbound now names its nearest catalog entry beside
    that word (#149).
  • ruleprobe bind binds the rule sections the catalog left unmeasured to detectors you choose.
    bind --plan prints each one in sorted order with its nearest catalog detectors and the reason
    it did not bind, and writes nothing; bind --apply FILE records the choices from the edited
    plan in ~/.config/ruleprobe/bindings.yaml, or with --project in the repository's
    .ruleprobe/bindings.yaml. report shows such a rule as user-bound, counts it under
    coverage.user, marks it stale when its section's text changes, and reads no bindings file
    from a project it found through the transcripts. Catalog binding is unchanged
    (#154).

Changed

  • A tool call counts only when it ran, on all three readers. A call the user refused or
    cancelled, a permission denial, and a call stopped before its tool ran make no event, so
    detectors stop counting them: a cancelled Gemini write_file of a key is no longer a
    secrets/secret-in-write hit. A call that ran and failed still counts, so a test run that
    exits non-zero still follows a change for testing/test-after-change. A call interrupted
    part-way, and any Gemini call whose status is cancelled or error, is left out too
    (#114).
  • The origins section names Model Citizen (formerly agent-harness) and links to the current
    repository while preserving Ruleprobe's extraction history
    (#146).
  • "exempt", "exempted", "exempting", "exempts" and "exemptions" join the exception words, so "Run the tests before
    finishing. Docs-only changes are exempt." leaves its section unmeasured rather than binding it
    (#139).
  • Rule sections bind the catalog one sentence at a time, so a section stating several rules is
    measured by each detector its sentences bind, and the coverage block lists them all on the
    section's line. An exception or permission word anywhere in a section still unbinds every rule
    in it, and a condition or contrast word still unbinds only its own sentence; a sentence no longer
    ends inside parentheses or after e.g., i.e., etc., vs. or cf.; and a negated marker such as "no
    exceptions" or "admit no exception" unbinds nothing where its clause ends. ruleprobe corpus
    scores binding per labelled line, on the line each bind's sentence starts on, and the zoo gains
    six near-misses. On the rules zoo, binding recall rises from 0.44 to 0.66 (27/41) with no false
    bind, and the recorded recall floor rises to 0.65
    (#141).
  • The seven original catalog shapes read more of the ways people phrase them, such as "Before
    you hand back, run the tests", "Prefer uv over pip" and "Keep credentials out of source
    control", and each binds only a sentence it covers whole. Anything more, a scope, an aside or
    a second clause, leaves the rule unmeasured, so "Never force-push on Fridays to main", "Use uv,
    not pip, in production" and "Never commit .env files (in the public repo)" bind nothing. A rule
    narrower than its detector by name no longer binds either: "Never skip pre-commit hooks" and
    "Do not pass --no-verify to git commit" leave out the pushes verification/no-verify
    counts, and "Never commit a .env file" names one kind of secret-shaped file. ruleprobe corpus also scores binding on ruleprobe/corpus/rules-heldout.json, 80 sentences written
    from each detector's claim by an author who never saw the patterns, gated on zero false binds
    and a recall floor of its own. Binding recall, with no false bind anywhere: 0.12 (5/40) on
    that independent set, the honest figure for phrasings the catalog was not written against;
    0.61 on a 65-item set added to the zoo, tuned against; 0.67 on the zoo's older held-out
    labels; 0.69 over the whole zoo, whose floor is now 0.68
    (#151).

Fixed

  • Over one --root, --runtime gemini no longer skips a Gemini session outside any chats
    directory without a word while auto reads it. It still reads only files below a chats
    directory at or under the root, and now notes each such session in errors with error set to
    readers.OUTSIDE_CHATS; the report counts them apart from failures. Over the shipped corpus that
    is gemini-writes.jsonl. --root . from inside a chats directory now reads it. A file that
    cannot be opened under auto now lands in errors instead of vanishing
    (#113).
  • secrets/secret-in-write counts a live credential and stops counting text about secrets: a
    variable's name, a placeholder (changeme, your-token, xxx, ${VAR}, one repeated
    character), a pattern source, redaction code, and a value a test file marks
    fake on its own line. A value in an issuer's shape must sit behind its key or prefix, mix
    letters and digits where it is a prefixed token, and be on a line that is no pattern or
    redaction code, so aws_secret_access_key or client_secret with no literal value is no
    hit, while a prefixed name such as GOOGLE_CLIENT_SECRET=... still is. Anthropic and
    OpenAI project keys and GitHub tokens past ghp_ now count. SECRET_PATTERNS and redact are
    unchanged (#110).
  • A JSON detector or bindings file nested too deeply is a finding naming the file, not a
    RecursionError, and one repeating a key in an object is a finding rather than read with the
    last value (#154).
  • transcript-hygiene/whole-file-cat no longer counts a cat inside a { ...; } group or
    ( ... ) subshell whose output is redirected or piped, such as
    { cat header.txt; echo; } > out.txt, which puts nothing in the transcript;
    transcript-hygiene/unfiltered-find skips a find in one the same way. The shell parse reads
    a redirect after a group as a redirect of every command in it, so the redirect and
    sole_segment keys of a command matcher in your own detectors read groups the same way, and
    are undecided, so no hit, in a group the parse cannot follow, such as one never closed
    (#111).

Install: pip install ruleprobe==0.3.0rc1, or run it with uvx ruleprobe@0.3.0rc1 report.

ruleprobe v0.2.0

Choose a tag to compare

@github-actions github-actions released this 24 Sep 13:31
ca93e24

Breaking

0.2.0 versions the contract and takes its break here, in seven parts: the undecided rule for not
and absent; schema versions, on detector entries (below) and on rows and the report_data result
(under Added); the persisted fold map for renamed detector ids; the declared public API; the
coverage block, which now also appears in report --json as coverage; section rules; and the
report's frequent marker, with its threshold renamed. Each part has its entry below, the row
schema's under Added. From 0.2.0 nothing declared breaks within a minor series, and a later 0.x
minor may break only under a Breaking heading like this one; the README's Versioning section states
the policy.

  • A declarative matcher no longer counts a Bash command the shell parse skipped - empty or missing,
    longer than 16,384 characters, or one that does not tokenize or parse - as a match for not or
    absent (#19). Over such a command every
    command key but regex and unparsed, every git key, every env key and a text read of
    source: heredocs is undecided; not, any and all pass undecided through, and an undecided
    when, an order endpoint or an absent candidate is no hit. A detector file using not or
    absent may count fewer hits; no edit is needed, and a rule that wants those commands asks for
    command: {unparsed: true}. A predicate from compile_matcher may now return a falsy undecided
    value: a Python caller who negates a predicate itself reads it as false and can over-count, and
    should test it with is_undecided or compose through the declarative not, any and all
    instead.
  • A detector file's top-level version, ignored in 0.1, is now read as its entries' schema version,
    and an entry may carry its own schema_version, which wins
    (#32). A schema version this release does not
    know - above 2, 0, negative or not an integer - is a finding, and only the entries that would
    read it are skipped; a top-level schema_version is a finding too, since the file-level key is
    version. A 0.1 detector file whose top-level version is anything but 1 or 2 loses the entries
    without a key of their own until it is corrected.
  • report --rules prints the measured share in the coverage block, as in rules: 2 measured, 1 dark, 1 unmeasured (50% measured), floored so a file with a rule unmeasured never shows 100%
    (#47); and report --json now carries the
    block as a top-level coverage key, where it was printed to stderr only. The key counts rules,
    not sessions.
  • The README declares the public API: every name, call shape and non-name promise a downstream tool
    may pin, each held by a contract test that CI also runs against the built wheel imported as a zip
    (#35). A name outside that list is importable
    but may change in any release.
  • A retired detector id folds onto its current id through one fold map: the renames the package
    ships, with a consumer's own Registry(renamed=) laid over them
    (#34). Chains resolve to their end, and a
    cycle raises ValueError when a Registry is built or a rename would close one. report_data
    and --json carry the effective map as renamed, and corpus labels fold the same way. A test
    fails when a detector id any release shipped is neither registered nor folded.
  • An unbound rule file with headings now splits into one rule per section, with the id
    <path>#<heading-slug> and an ordinal suffix for a repeated slug, so the coverage block counts
    rules, not files (#48). A section holding only
    a heading, a fenced or indented code block, a table, a quote or a comment is not a rule. A file
    with no heading, a file bound in its front matter, and a headed file with no rule section stay one
    rule with their 0.1.0 id. The findings line now reads findings: N (everything else still loaded).
  • The report table marks a detector whose share of measured sessions passes the threshold
    frequent, where 0.1 printed promote?, and the marker advises nothing about the rule
    (#43). The threshold is renamed with it:
    frequent_share= on report and report_data, the --frequent-share option, the
    frequent_share key in report_data and --json, and the RULE_FREQUENT_SHARE constant, where
    0.1 had promote_share, --promote-share and RULE_PROMOTE_SHARE.

Added

  • Rows and the report_data result carry schema_version, which this release writes as 2
    (#33). A row with no version, or a null one,
    reads as 1; a row with a version this release does not know is left out of every count, tallied
    in unknown_schema, and noted by report.
  • is_undecided(value), exported from the package root, tells the undecided result of a
    compile_matcher predicate from a false one
    (#35).
  • Detector takes an optional keyword-only opportunities: a callable over (events, ctx)
    returning (turn, tool_use_id, followed) triples, with followed true, false or None for
    undecided (#41). Declarative order and
    turn-scoped absent detectors set it from the same evaluation as their hits; the positional
    constructor and fn(events, ctx) are unchanged.
  • A row from measure() carries compliance: for each enabled detector that defines
    opportunities, {"opportunities": N, "followed": M, "undecided": U}, with undecided points
    counted apart and never as not followed (#42).
    A raising or malformed opportunities is recorded in rules_errors tagged "hook": "opportunities" and costs only that detector's compliance, not its hit figures.
  • ruleprobe explain reruns the detectors over your transcripts and prints the event behind every
    hit: the session address, turn, tool-use id, detector id and the matched command or input,
    filtered by --session, --detector and --key
    (#51). It changes no report number, sends
    nothing and writes nothing. Every line it prints passes through redact in
    ruleprobe.detectors.common, which hides the shipped secret shapes and a set of common
    credential forms; other credentials can still print, so read the output before sharing it.
  • report and report_data carry compliance beside hits for every detector a row has a tally
    for: opportunities, followed, undecided and compliance_rate, which is followed / opportunities and null below min_opportunities
    (#43). They group under --by repo and
    --by stance as hits do, and the table prints them as four columns only when some row carries
    compliance. --min-opportunities, defaulting to RULE_MIN_OPPORTUNITIES (20), is the fewest
    opportunities a rate is printed for. report_data also counts opportunity_errors,
    malformed_compliance and unreadable_compliance, and report notes each: a detector whose
    opportunities raised, a tally that cannot be read, or a compliance map that names no
    detector. Each costs only compliance figures for those sessions; hits stand.
  • ruleprobe label --session <runtime>:<id> --detector ID --key KEY --corpus DIR --name NAME
    turns a wrong hit into a labelled negative
    (#52). It reruns the detector over that
    session, writes the one event behind the hit, redacted, to DIR/sessions/NAME.events.jsonl,
    and appends a near label to DIR/labels.yaml, creating it when missing, so ruleprobe corpus
    scores the case; the command it prints does that. It is the only command that writes, and only
    under the directory it is given. It refuses a hit on a whole session, a gated detector, a hit
    that redaction would change, an existing file and a corpus that does not load, and on any
    failure it undoes what it wrote. load_corpus reads an .events.jsonl session as written.
  • A shipped catalog of seven common rule shapes binds a rule section no front matter binds, so a
    stranger's own rules are measured without a detector written
    (#49): running the tests after a change,
    skipping hooks, force-pushing the default branch, installing with pip where another manager
    is named, reading a whole file, a non-conventional commit subject, and committing a
    secret-shaped file. A section binds the one entry whose anchored pattern matches its heading or
    a sentence of its text; none or several leave it unmeasured, and a rule that states an
    exception or permission, or a condition in the matching sentence, binds nothing. A file with no
    heading, or no rule section, binds by its whole text. The report notes each bound rule
    catalog-bound, report --json's coverage counts them as catalog, and ruleprobe detectors
    marks the catalog's entries. testing/test-after-change counts followed opportunities as its
    hits, so its compliance columns carry the rate a change was tested.
  • Four declarative matcher keys: git.arg_regex and git.message_regex read one parsed argument
    and the first commit message, and command.program and command.first_operand read a
    segment's program by its basename and its first operand past flags
    (#49).
  • Gemini CLI is the third runtime: --runtime gemini reads its sessions from ~/.gemini/tmp, and
    auto includes them (#55). Its shell tool
    re...
Read more

ruleprobe v0.1.0

Choose a tag to compare

@JakeSelby JakeSelby released this 23 Sep 21:28

Added

  • The measurement engine: run() over a session's events, a Registry of Detector
    objects, and report() over the rows it produces.
  • Readers for Claude Code transcripts and Codex rollouts, behind one event schema and one
    iter_sessions(root, runtime, since).
  • The Bash decomposition every shell detector shares: compounds, pipelines, heredocs,
    substitutions and continuations, parsed once per command.
  • Six generic detectors: whole-file cat, unfiltered find, no-verify, secret in a write,
    compaction, and a model switch mid-session.
  • A ruleprobe report command, grouping by detector, by repository or by stance.
  • An extension point for declarative detectors: register_compiler and from_spec.
  • A declarative detector format, so a rule can be measured without writing Python: one entry
    of id, rule, event, when and an optional gate, compiled by ruleprobe/matchers.py
    into the same Detector a Python detector builds.
  • Matchers for a tool name, an argument, a Bash command through the shared parse, a git
    call, an environment assignment, a text body, an assistant message and a raw event kind,
    composed with any, all and not; and three that read a whole session, order,
    absent and change.
  • ruleprobe/declarative.py: a strict, minimal YAML subset with a line number and a reason
    on every refusal, and the same objects from a .json file. No third-party dependency.
  • Detector files found without a flag: .ruleprobe/detectors.yaml at the root of the
    repository you are in, and ~/.config/ruleprobe/detectors.yaml for the user. --detectors
    names one, --no-config skips discovery.
  • ruleprobe report --rules <dir>: markdown rule files bind to the detectors in their front
    matter, and the report says which rules are measured, which are dark by opt_out, and
    which are unmeasured - the gap an author cannot otherwise see.
  • ruleprobe/detectors/common.yaml: the six shipped detectors written as data, with a test
    asserting they produce identical hits to the Python reference over the corpus and the
    fixture transcripts.
  • A worked example that runs from a clone: docs/rules/ and docs/example-session.jsonl.
  • A labelled corpus, shipped as package data at ruleprobe/corpus/: six synthetic sessions
    in both transcript shapes, every interesting event labelled by hand in labels.yaml with
    the detectors that should fire on it, and a deliberate near-miss beside each - a cat of
    a range, a filtered find, a push after the gate ran, a heredoc with rm -rf in its body
    as text. Every shipped detector carries at least five positives and five negatives.
  • ruleprobe corpus, and ruleprobe.validity() behind it: per-detector precision, recall
    and F1 with their counts, a total, --json, --corpus DIR for a corpus of your own, and
    a non-zero exit under --floor 0.9. The floor is this repository's CI gate, not a runtime
    failure: nothing in ruleprobe report reads it.
  • ruleprobe report --validity: each detector's corpus precision and recall beside its row.
    Off by default, because the two numbers belong to the detector rather than to the run.
  • An optional examples: block on a declarative detector - fire: and skip: lists of
    minimal cases, each bash:, event: or events: - so a detector of your own can be
    scored without a corpus. A detector with neither says no examples rather than a number,
    and the floor steps over it.
  • .github/workflows/ci.yml: the unit tests on 3.9 and the newest 3.x, compileall, and
    ruleprobe corpus --floor 0.9.

Changed

  • A malformed detector entry is a finding with a file, a line and a reason, printed under the
    report; the entry is skipped and every other detector still runs.
  • The README no longer says detector validity is unmeasured; it prints the corpus table
    instead, and a test asserts the README quotes it byte for byte.

Fixed

Every finding of the pre-release review, #2,
each with the reviewer's own input as a regression test in tests/test_findings.py.

  • The shell parse. cat <<\EOF is a heredoc header, so its body is no longer parsed as
    commands and no longer yields a false unfiltered-find hit; a heredoc terminator must be
    the delimiter alone, as bash has it, and only <<- may have it indented; a command that
    does not tokenize is unparsed rather than invisible to every matcher.
  • The denominator. A detector that raises leaves the denominator of that detector only,
    instead of taking the whole row out of every other detector's evidence, and a row is never
    counted twice in the preamble.
  • Errors are counted. iter_sessions(errors=[...]) collects every transcript that
    raised or held no session, and ruleprobe report prints the count. The directory walks
    follow symlinks.
  • Matchers. arg: {equals: ...} no longer raises on a list-valued field; absent over
    a session with no events is not a hit; command: {contains: ...} is a substring;
    a list of command: {regex: ...} patterns is alternatives; order: {within: N} does not
    spend its budget on tool_result events; path_glob is matched as a path, with *
    stopping at a /, ** crossing one, and a relative pattern matching an absolute
    file_path.
  • The parser. An escaped quote inside a double-quoted string no longer truncates it at a
    #; [a: b] is a one-key mapping and not a tuple; yes, no, on, off and a
    leading-zero number are refused with a line and a reason rather than read one way here and
    another by YAML.
  • The readers. A runtime is chosen by parsing the first line, not by searching it for
    "session_meta"; a streamed partial text block is one message that grows, not two; a
    Codex user message is a user_prompt and final is derived there as it is on Claude Code,
    so a detector means the same thing on both.

Changed

  • iter_sessions takes an errors list; measure, run, report, Registry and
    iter_sessions are otherwise unchanged in signature.
  • report_data(rows, ...) is new and is what report() renders and ruleprobe report --json prints, so the table and the JSON cannot disagree about a denominator, a fold or a
    note. --json now prints that object with the rows under rows, and exits non-zero on an
    empty root as the table does.
  • ruleprobe report --stance dimension=variant, repeatable: a gate: block was unreachable
    from the command line, so a gated detector never fired and --by stance could only print
    (no stances). ruleprobe detectors names the stance each gate is waiting for.
  • --since 2024 is refused rather than silently read as 2024 days back.
  • Registry.rename removes the detector it renamed.
  • A user_prompt event carries the prompt's text on both runtimes.
  • README.md and ruleprobe/detectors/common.yaml no longer claim the shipped detector
    file uses every matcher; they name the ten it uses and the four it does not.

Install: pip install ruleprobe==0.1.0, or run it with uvx ruleprobe@0.1.0 report.