Repository navigation
feat(repo scan): a gate any repository can adopt (#851) - #898
Conversation
- A bare identifier the tree lacks is unresolved_identifier, not fail; a file stem (bench_fftnd for bench_fftnd.py) is ok_stem. - .dokimi/scan.toml: repo-owned [[ignore]] entries with reasons, and identifiers = "fail" to opt back in; scan_config in the report. - --baseline FILE: --fail-on-fail counts only fail claims the earlier report does not also fail; baseline block gives known/new/fixed. - report summary --format sarif (SARIF 2.1.0 with file and line). - Fixes: Doxygen /// is not a Bazel label; pipe-to-shell skips python -c, -m and node -e; "Use to" is a when cue; catalog formats counts skills a marketplace.json declares; memory lint refuses a repository root. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
OpenCodeReview: Commit 31d2953 was not reviewed. This PR has reached its review limit (6 reviews). CI at `31d2953`: 11 still running, 2 passing, 1 skipped
1 more not listed. To review this commit: re-request review from exai-bot in the Reviewers list. <details><summary>Last review (7f838e1): 7 medium, 1 low</summary> Open threads from the bot: 0 </details> |
There was a problem hiding this comment.
🟡 Changes recommended
Critical regressions allow piped shell execution to evade detection and same-path report output to overwrite the baseline before comparison, hiding new failures and incorrectly returning success.
7 open issues
Apply baseline before writing the report · New Preserve shell option detection when excluding command-selection flags · New Validate baseline claim records before applying them · New Include verdict-only failures in SARIF results · New Validate ignore collection types before iteration · New Fall back to defaults when configuration validation fails · New Handle malformed marketplace plugin collections gracefully · New
What changed in this PR
7 new findings. This PR makes dokimi’s model-free repository scan easier to adopt as a CI gate, using repository-owned settings and baselines to distinguish new drift from existing noise.
Changes:
- Adds baseline-aware gating, ignore rules, and configurable handling of missing identifiers.
- Adds SARIF output and updates report schemas, CLI documentation, and regression tests.
- Refines command and guidance checks, plugin skill counting, and memory-directory validation.
| File | Description |
|---|---|
dokimi/tests/test_scan_gate.py |
Tests gating, SARIF, and related fixes. |
dokimi/tests/test_repo_l0.py |
Updates missing-identifier expectations. |
dokimi/dokimi/skills/formats.py |
Counts plugin- and marketplace-declared skills. |
dokimi/dokimi/schemas/repo_readiness.v1.json |
Allows configuration and baseline metadata. |
dokimi/dokimi/repos/l0/config.py |
Implements scan settings and baseline matching. |
dokimi/dokimi/repos/l0/adapters.py |
Excludes Doxygen markers from Bazel labels. |
dokimi/dokimi/repos/l0/__init__.py |
Applies repository settings during scans. |
dokimi/dokimi/report/summary.py |
Adds SARIF rendering. |
dokimi/dokimi/memory/store.py |
Rejects repository roots as memory directories. |
dokimi/dokimi/external/when_cues.py |
Recognizes “Use to” descriptions. |
dokimi/dokimi/external/command_checks.py |
Refines pipe-to-interpreter detection. |
dokimi/dokimi/commands/report.py |
Exposes the SARIF format option. |
dokimi/dokimi/commands/repo.py |
Adds baseline-aware scan gating. |
dokimi/dokimi/commands/repo_scan.py |
Loads baselines and reports known failures. |
dokimi/docs/repo-evaluation-contract.md |
Documents scan settings and baseline behavior. |
dokimi/docs/reference/cli-interface.json |
Records the new CLI options. |
dokimi/changelog.d/20261116_220000_vchamarthi_scan-gate.md |
Records features, fixes, and changed defaults. |
Review effort: Balanced
| except OSError as exc: | ||
| print(f"✗ cannot write {args.out}: {exc}", file=sys.stderr) | ||
| sys.exit(EXIT_USAGE) | ||
| baseline_from(args, payload) |
There was a problem hiding this comment.
Already holds on the head: a34ffca: baseline_from runs before --out is written (commands/repo.py:168), so the saved report holds the baseline block and --out may be the baseline file. Pinned by tests/test_scan_gate.py::test_the_baseline_is_applied_before_out_overwrites_it.
| r"(?:(?:ba|z|da|k)?sh|fish|python(?:3(?:\.\d+)?)?|node|perl|ruby)\b" | ||
| # `python -c PROGRAM`, `python -m json.tool`, `node -e`, `perl -e`: the program is on the command line and the | ||
| # download is only its input (JSON to parse), so nothing downloaded is run. | ||
| r"(?![ \t]+-[cme](?![\w-]))" |
There was a problem hiding this comment.
Already holds on the head: a34ffca: the -e/-m exemption is per interpreter and a shell is not exempt; curl … | sh -e and | bash -e fire. Pinned by tests/test_scan_gate.py::test_pipe_to_shell_skips_an_interpreter_that_runs_its_own_program.
| from dokimi.repos.l0.config import apply_baseline | ||
|
|
||
| if not getattr(args, "baseline", None): | ||
| return | ||
| try: | ||
| doc = json.loads(Path(args.baseline).read_text(encoding="utf-8")) | ||
| except (OSError, ValueError) as exc: | ||
| raise InputError(f"--baseline {args.baseline}: {exc}") from None | ||
| doc = doc.get("data", doc) if isinstance(doc, dict) and doc.get("schema_version") == "cli_output.v1" else doc | ||
| if not isinstance(doc, dict) or not isinstance(doc.get("claims"), list): | ||
| raise InputError(f"--baseline {args.baseline}: not a repo_readiness.v1 report (no claims list)") | ||
| apply_baseline(payload, doc, args.baseline) |
There was a problem hiding this comment.
Already holds on the head: a34ffca: baseline_from refuses a claims entry that is not an object with an input error (commands/repo_scan.py), so {"claims": [null]} exits 2 instead of crashing. Pinned by tests/test_scan_gate.py::test_a_baseline_claim_that_is_not_an_object_is_an_input_error.
| for c in summary["checks"]: | ||
| if c["state"] in ("failed", "invalid", "not_run", "infra_error"): | ||
| result(f"dokimi/{c['kind'] or 'input'}/{c['state']}", "error", | ||
| f"{c['kind'] or c['source']}: {c['state']}: {c['reason'] or ''}".rstrip(": "), None, None) | ||
| for s in summary["subjects"]: | ||
| for f in s["findings"]: | ||
| result(f"dokimi/{f['check']}/{f.get('code')}", _SARIF_LEVEL.get(str(f.get("level")), "note"), | ||
| f"{s['subject']}: {f.get('message')}", f.get("file"), f.get("line")) |
There was a problem hiding this comment.
Already holds on the head: a34ffca: a check in fail or a stopped state and a subject with a bad verdict and no findings are SARIF results, as in render_annotations(). Pinned by tests/test_scan_gate.py::test_sarif_keeps_a_failed_verdict_with_no_findings.
| errors.append(f"{source}: identifiers must be one of {', '.join(IDENTIFIER_POLICIES)}, not {identifiers!r}") | ||
| identifiers = "unresolved" | ||
| ignores: list[Ignore] = [] | ||
| for i, entry in enumerate(data.get("ignore") or [], 1): |
There was a problem hiding this comment.
Already holds on the head: a34ffca: a non-list ignore is a config error and keeps the defaults (config.py parse_config). Pinned by tests/test_scan_gate.py::test_a_scalar_ignore_is_a_config_error_not_a_crash.
| unknown = sorted(set(data) - {"identifiers", "ignore"}) | ||
| if unknown: | ||
| errors.append(f"{source}: unknown key(s) {', '.join(unknown)}") | ||
| return ScanConfig(identifiers, tuple(ignores), source, tuple(errors)) |
There was a problem hiding this comment.
Already holds on the head: a34ffca: any config error returns the defaults with no ignores (parse_config: if errors: return ScanConfig(source=source, errors=...)). Pinned by tests/test_scan_gate.py::test_a_config_with_any_error_keeps_every_default.
| bundle = path.parent if fmt == FORMAT_GEMINI_EXTENSION else path.parent.parent | ||
| pkg.details["skills"] = len(list((bundle / "skills").glob("*/SKILL.md"))) | ||
| if fmt == FORMAT_CLAUDE_PLUGIN and not pkg.details["skills"]: | ||
| pkg.details["skills"] = _declared_skills(bundle, data, path.parent / "marketplace.json") |
There was a problem hiding this comment.
Already holds on the head: a34ffca: a plugins that is not a list is recorded as a problem, not raised. Pinned by tests/test_scan_gate.py::test_a_marketplace_whose_plugins_is_not_a_list_is_a_problem.
Fixes review findings on the scan gate: - scan.toml: any error discards every setting; a non-list `ignore` is an error, not a TypeError; an unreadable or dangling link is a warning. - [[ignore]] now applies to merged `--static` claims; a `baselined` mark from a static checker is dropped, so only --baseline marks a claim known. - --baseline is applied before --out is written; a non-object claim entry is an input error (exit 2). - pipe-to-shell exempts only the inline-program flag of its own interpreter: `sh -e` fires, `python3.11 -m` does not. - SARIF: file URIs are percent-encoded with `/` separators; failed, stopped and bad-verdict checks and findingless subjects are results. - catalog formats: Claude plugin skills are the union of `skills/` and declared directories; a marketplace source counts its `skills/`; a non-list `plugins` is a problem, not a crash. Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
CLI interface change detectedThis PR changes dokimi's user-facing CLI surface (commands and/or options): ~ `dokimi repo scan` parameters changed:
+ added option `--baseline`
~ `dokimi report summary` parameters changed:
~ changed option `--format`: choices: ["'annotations'", "'json'", "'markdown'"] -> ["'annotations'", "'json'", "'markdown'", "'sarif'"]Updated on every push; the |
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #898 +/- ##
==========================================
- Coverage 95.92% 95.91% -0.01%
==========================================
Files 450 451 +1
Lines 59527 59770 +243
Branches 10265 10316 +51
==========================================
+ Hits 57101 57330 +229
- Misses 1507 1512 +5
- Partials 919 928 +9
🚀 New features to boost your workflow:
|
|
🟢 Ready for re-review · 1 commit on Next: a re-review of the new head. PR description updated
Threads and comments
Verified on the new head: ✅ 16/16 tests fail before the fix, pass after · ✅ full suite with main merged in: 23123 passed · ✅ second reader: nothing raised What each test shows
|
- pipe-to-shell: an inline python -c, node -e, perl -e or ruby -e program that execs or evals still fires; ruby -E is not an inline program. - sarif: a drive-qualified Windows path is a file:/// URI; a pathless finding, failed check or bare verdict is located at its input file. - scan.toml: a non-string ignore kind is a config error, not a match-any rule; a symlink loop is a warning, not exit 5. - catalog formats: a skill reached by a symlink and a declared path counts once; an unreadable or non-object marketplace.json is a problem. Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
|
🟢 Ready for re-review · 1 commit on Next: a re-review of the new head. Changes
PR description updated
Threads and comments
Verified on the new head: ✅ 7/7 tests fail before the fix, pass after · ✅ full suite with main merged in: 23352 passed · ✅ second reader: nothing raised · What each test shows
|
pipe-to-shell: the exec/eval guard now reads the quoted inline program of python -c, node -e, perl -e and ruby -e, across its lines, and not the rest of the line: a string literal "eval" or a later `exec` no longer fires, and `exec(...)` on a second line of the program does. report summary --format sarif: a finding with no file is placed at its input report without the finding's line. Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
|
🟢 Ready for re-review · 1 commit on Next: a re-review of the new head. Threads and comments
Verified on the new head: ✅ 2/2 tests fail before the fix, pass after · ✅ full suite with main merged in: 23609 passed · ✅ second reader: nothing raised What each test shows
|
|
|
||
| # A word that runs what it reads (exec, eval, a shell, a child process); a word that ends a string | ||
| # literal ("eval") is data. | ||
| _EXEC = r"(?<!\w)(?:exec|eval|system|popen|spawn|subprocess|child_process|__import__|Function)(?!\w*['\"])" |
There was a problem hiding this comment.
Must-fix — Impact: benign data processors still receive pipe-to-shell warnings and can incorrectly fail catalog check --strict when unrestricted Bash is granted. Trigger: curl https://x/data.json | python -c 'print("eval result")' (likewise Node -e 'console.log("exec result")'). Evidence: the trailing lookahead ignores a marker only when its remaining word characters immediately precede a quote. Here eval is followed by a space, so it is treated as execution despite being entirely inside a string literal. The claimed string-literal fix therefore remains incomplete across the shared Python/Node/Perl/Ruby guard. Inspect string-literal boundaries rather than the character following a marker, and add longer-literal regressions, including a public gate assertion. Workaround: avoid execution-marker words in these literals. Severity justification: medium, a supported benign command produces a bounded but materially incorrect finding and strict-gate failure.
There was a problem hiding this comment.
Not a defect: curl https://x/data.json | python -c 'print("eval result")' is flagged because a marker word followed by a space cannot be told from code without parsing the inner program's literals; kept the warning over exempting it (chose flagging over guessing, so a real exec is never missed). python -c "from dokimi.external.command_checks import PIPE_TO_SHELL as P; print(bool(P.search('curl https://x/d.json | python -c \'print(\"eval result\")\'')))" gives True.
An inline program after python -c / node -e in a double-quoted string ended at the first escaped quote, so exec(...) after it was never inspected and pipe-to-shell was lost. Read the escapes, and require the program to end before a glued quoted segment. Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
|
🟢 Ready for re-review · 1 commit on Next: a re-review of the new head. Changes
Threads and comments
Verified on the new head: ✅ 1/1 tests fail before the fix, pass after · ✅ full suite with main merged in: 23730 passed · ✅ second reader: nothing raised What each test shows
|
vlad-perevezentsev
left a comment
There was a problem hiding this comment.
Review at fa4049e. The gate is the right shape: the baseline is applied before --out is written, a config with any error keeps the defaults, and ignores cover --static claims. Two things still let it pass when it should not: the pipe-to-shell exemption misses several commands that run the download, and a broken scan.toml silently drops identifiers = "fail". Smaller gaps are in the line comments.
Agreed with @exai-bot: the escaped unquoted program at command_checks.py:50; the unchecked [[ignore]] keys at config.py:81; the stem of a multi-dot name at config.py:146 (doc files are a second case, in that thread); the RuntimeError from a symlink loop at formats.py:201; the input path in the SARIF ruleId at summary.py:309. On flagging print("eval result") I agree with the author: a warning there is safer than a guess.
What I ran, at fa4049e:
make ci-local --offline: 23,110 tests passed, 72 skipped; the one FAIL row,schema_compat, is aboutdocling_sources,suite_manifestandquestionsschemas that this PR does not touch (drift between the PR base andmain).PIPE_TO_SHELLon 9 commands, against this branch and the base regex: the 6 commands in the line comment are flagged on the base and not here;exec(sys.stdin.read())andos.execvpstill fire,-m json.tooldoes not.repo scan --jsonon scratch trees: a repeated known path with--baseline, a misspelledkind,identifiers = "fail"with a typo key, doc and multi-dot stems; andreport summary --format annotationson a baselined scan.
Checked, no issues
- Baseline input: an envelope or a bare report is read, a
claimsentry that is not an object is exit 2, and abaselinedkey from--staticis dropped. - Earlier threads: the Copilot threads that are still open are fixed on this head, as the author replied; each has a test.
- Schema and docs:
repo_readiness.v1is only widened (scan_config,baseline); the contract and the changelog say the identifier default changed, sofailcounts of new scans are lower than those of old ones.
- pipe-to-shell: read every character of an unquoted inline program for exec markers; treat $(, backticks, runpy, *_eval and qx as running the input; exempt only `python -m json.tool` - scan.toml: an unknown key inside [[ignore]] is a config error; any config error makes the scan incomplete so --fail-on-fail exits 1 - identifiers: stems come from non-doc files, minus the last extension only - baseline: a key counts once per claim the baseline holds - report summary: SARIF ruleId names the check, not the input file; annotations print a baselined claim as ::notice - catalog formats: an unresolvable skills path is a package problem - "use it to" / "use this to" are not a when-cue - changelog fragment gets its SPDX header Signed-off-by: vchamarthi <venkata.sai.gireesh.chamarthi@intel.com>
|
🟢 Ready for re-review · 1 commit on Next: @vlad-perevezentsev: re-review the new head. Changes
PR description updated
Threads and comments
Verified on the new head: ✅ 9/9 tests fail before the fix, pass after · ✅ full suite with main merged in: 24015 passed · ✅ second reader: nothing raised What each test shows
|
napetrov
left a comment
There was a problem hiding this comment.
Change class: CONTRACT (head 7f838e1)
- Contract: changed. errors dokimi/dokimi/commands/repo_scan.py:174; errors dokimi/dokimi/commands/repo_scan.py:175
- Responsibility: none
- Dependency: none
- Review depth: check the changed surface: callers, docs, tests pin new behaviour
- Coverage gaps: none
One blocking finding. I checked identifier handling, repository configuration, baseline multiplicity and SARIF rendering. The author’s 12-repository rescan figures were not independently repeated.
Focused tests on 7f838e186: 19 passed, 63 deselected in 1.50s. CI on head 7f838e1: 0 failing Actions jobs; merge base 1846bb5 is behind base tip 36075a0.
Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
… file stem A claim such as WrongNamespace::DemoWidget was marked ok_stem when a DemoWidget.py existed, so identifiers = "fail" no longer failed it. The stem lookup now uses the whole claim text. Test added. Signed-off-by: vchamarthi <123653452+vchamarthi@users.noreply.github.com>
|
Ready for re-review, @napetrov: 2 commits on Changes:
Threads and comments:
Not the PR's:
Checked on the new head:
What each test shows
|


Closes #851.
repo scan --fail-on-failcould not gate a product repository: on 12 Intel repositories, 18 of the 19 scan failures in product repos were dokimi misreading the docs, not wrong docs. Fixing each misread in dokimi does not scale to the next 100 repositories, so this moves the noise decision to the repository and gates on drift instead of on the starting state.What this changes
mkl_random,PyArray_Resize) isunresolved_identifier, notfail: it may be an external API, a sibling package or a builtin. A name that is a tracked file's stem (bench_fftndforbench_fftnd.py) isok_stem. Paths, links and scripts still fail..dokimi/scan.toml[[ignore]]entries (pattern, optionalkind, requiredreason), andidentifiers = "fail"to opt back in. The report'sscan_configblock lists each entry with its hit count; a file with any error keeps every default, adds a warning and makes the scan incomplete.--baseline FILErepo scan --out, or the--jsonenvelope).--fail-on-failthen counts onlyfailclaims the baseline does not hold; claims match on file, kind and text, not line. Thebaselineblock givesknown,new,fixed.report summary --format sarif: SARIF 2.1.0 with file and line, for GitHub code scanning, Azure DevOps, GitLab and Jenkins. A check that failed or did not run is anerrorresult.Smaller fixes found in the same assessment:
///is not read as a Bazel label.pipe-to-shellskipscurl … | python -c,python -m json.toolandnode -ewhen the inline program does not exec, eval or substitute a command (the downloaded bytes are data), but notsh -eorruby -E.catalog formatscounts skills a plugin'sskillskey or a siblingmarketplace.jsondeclares.memory lintrefuses a repository root instead of linting README and AGENTS.md as memory entries.Behaviour change
A missing bare identifier no longer fails by default. Two expectations in
test_repo_l0.py(GhostWidget,OnlyInDocs) move tounresolved_identifier. A repository that wants the old behaviour setsidentifiers = "fail". Listed under "Changed" in the changelog.Evidence
Rescan of the same 12 clones (shallow, no
.git):actions/cache, named in prose and used by no workflow: an ignore entry)scripts/publish.shTests
tests/test_scan_gate.py: 20 tests covering each part above.make ci-local --offline) on the Linux image: 23,119 passed; 1 failure,test_repo_compare_interval.py::test_the_row_p_places_zero_where_large_deltas_round_p_at_zero_apart, fails onmaintoo (fix(eval): the interval of a Monte Carlo row of widely spread deltas counts its resamples on exact sums #893).@dataclass(frozen=True)flipped toFalse, which no test can observe.Not exercised:
--changed-fromand git-history checks, since the clones had no history.