From 54d63c34ce18b506ff954e26591bad1823f8578c Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 1 Dec 2026 14:14:19 +0000 Subject: [PATCH 1/2] feat(repos): repo scan counts an ignored claim apart from unresolved (#1489) An `[[ignore]]` entry in `.dokimi/scan.toml` turns a matching claim into `unresolved_ignored`, but every count put it back under `unresolved`, so a repository that declared all its external names showed the same `unresolved N` as one that declared none. `counts`, `by_file`, `by_kind`, `by_source` and `summary.claims` now carry `ignored`, the number of `unresolved` claims that are `unresolved_ignored`. `unresolved` keeps counting them, so `ok + unresolved + fail == total` still holds. The key is absent when no claim is ignored, so reports and output of a repository with no ignores are unchanged. The console line reads `unresolved 2 (1 ignored)` and `report summary` shows `claims.ignored 1`. `repo_readiness.v1` widens in place with an optional `ignored`. Signed-off-by: Anton Volkov --- ...20261201_150000_repo-scan-ignored-count.md | 8 ++ dokimi/docs/repo-evaluation-contract.md | 6 +- dokimi/dokimi/commands/repo_scan.py | 3 +- dokimi/dokimi/repos/l0/__init__.py | 2 + dokimi/dokimi/schemas/repo_readiness.v1.json | 3 +- dokimi/tests/test_repo_scan_ignored_count.py | 78 +++++++++++++++++++ 6 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 dokimi/changelog.d/20261201_150000_repo-scan-ignored-count.md create mode 100644 dokimi/tests/test_repo_scan_ignored_count.py diff --git a/dokimi/changelog.d/20261201_150000_repo-scan-ignored-count.md b/dokimi/changelog.d/20261201_150000_repo-scan-ignored-count.md new file mode 100644 index 0000000000..40a7f09108 --- /dev/null +++ b/dokimi/changelog.d/20261201_150000_repo-scan-ignored-count.md @@ -0,0 +1,8 @@ + + +### Added + +- **`repo scan` counts an ignored claim apart** (#1489) — `counts`, `by_file`, `by_kind`, `by_source` and `summary.claims` gain `ignored`: how many of the `unresolved` claims are `unresolved_ignored` (a `.dokimi/scan.toml` `[[ignore]]` entry matched). `unresolved` still counts them, so `ok + unresolved + fail == total` holds. The key is absent when no claim is ignored. The console line reads `unresolved 2 (1 ignored)` and `report summary` shows `claims.ignored 1`, so `unresolved` minus `ignored` is what is still open. diff --git a/dokimi/docs/repo-evaluation-contract.md b/dokimi/docs/repo-evaluation-contract.md index 10c85fd8c9..2b0890d20c 100644 --- a/dokimi/docs/repo-evaluation-contract.md +++ b/dokimi/docs/repo-evaluation-contract.md @@ -2303,7 +2303,11 @@ the repository cannot fix: - `.dokimi/scan.toml` in the tree is the repository's own setting. `identifiers = "fail"` restores failing on a missing identifier. Each `[[ignore]]` entry (`pattern`, an fnmatch on the claim text; optional `kind`; a required `reason`) turns a matching claim that is not `ok` into - `unresolved_ignored`. The report's `scan_config` block lists each entry with its hit count, and a + `unresolved_ignored`. That claim stays in the `unresolved` class; `counts`, `by_file`, `by_kind`, + `by_source` and `summary.claims` of the `--json` document add `ignored`, how many of the `unresolved` + claims are `unresolved_ignored` (absent when none is), the console line reads + `unresolved 2 (1 ignored)` and `report summary` shows `claims.ignored 1`, so `unresolved` minus + `ignored` is what is still open. The report's `scan_config` block lists each entry with its hit count, and a file with any error (bad TOML, an unknown key, also inside an `[[ignore]]`, an `[[ignore]]` without a `reason`, a non-list `ignore`) is a warning that discards every setting in it and keeps the defaults, and makes the scan `incomplete`, so `--fail-on fail` exits 1 until the file is fixed. An ignore applies to the claims of diff --git a/dokimi/dokimi/commands/repo_scan.py b/dokimi/dokimi/commands/repo_scan.py index b69dea5151..bda915b4d3 100644 --- a/dokimi/dokimi/commands/repo_scan.py +++ b/dokimi/dokimi/commands/repo_scan.py @@ -219,7 +219,8 @@ def _print_scan_text(manifest, payload: dict, out: str | None) -> None: detected = " (detected)" if payload["adapters_detected"] else "" print(f"{manifest.id}: {len(payload['files'])} guidance files in {payload['repo']['tree']}; " f"adapters: {', '.join(payload['adapters']) or 'none'}{detected}") - print(f" claims: {c['total']} (ok {c['ok']}, unresolved {c['unresolved']}, fail {c['fail']})") + ignored = f" ({c['ignored']} ignored)" if c.get("ignored") else "" + print(f" claims: {c['total']} (ok {c['ok']}, unresolved {c['unresolved']}{ignored}, fail {c['fail']})") for warning in payload["warnings"]: print(f" warning: {warning}") if payload["incomplete"]: diff --git a/dokimi/dokimi/repos/l0/__init__.py b/dokimi/dokimi/repos/l0/__init__.py index 1bd21739b9..d287e8008a 100644 --- a/dokimi/dokimi/repos/l0/__init__.py +++ b/dokimi/dokimi/repos/l0/__init__.py @@ -170,6 +170,8 @@ def _counts(claims: list[dict[str, Any]]) -> dict[str, int]: for c in claims: counts[status_class(c["status"])] += 1 counts["total"] = len(claims) + if ignored := sum(c["status"] == "unresolved_ignored" for c in claims): + counts["ignored"] = ignored # a subset of unresolved; absent when no claim is ignored return counts diff --git a/dokimi/dokimi/schemas/repo_readiness.v1.json b/dokimi/dokimi/schemas/repo_readiness.v1.json index 887a7774fd..d0f1cd8798 100644 --- a/dokimi/dokimi/schemas/repo_readiness.v1.json +++ b/dokimi/dokimi/schemas/repo_readiness.v1.json @@ -15,7 +15,8 @@ "ok": {"type": "integer", "minimum": 0}, "unresolved": {"type": "integer", "minimum": 0}, "fail": {"type": "integer", "minimum": 0}, - "total": {"type": "integer", "minimum": 0} + "total": {"type": "integer", "minimum": 0}, + "ignored": {"type": "integer", "minimum": 1, "description": "How many of the `unresolved` claims are `unresolved_ignored` (a `.dokimi/scan.toml` [[ignore]] entry matched). Absent when none is; `unresolved` still counts them."} } } }, diff --git a/dokimi/tests/test_repo_scan_ignored_count.py b/dokimi/tests/test_repo_scan_ignored_count.py new file mode 100644 index 0000000000..0fd3544577 --- /dev/null +++ b/dokimi/tests/test_repo_scan_ignored_count.py @@ -0,0 +1,78 @@ +# Copyright (C) 2026 Intel Corporation +# SPDX-License-Identifier: Apache-2.0 + +"""#1489: an ignored claim is counted apart (`ignored`, a subset of `unresolved`) in every scan count. + +The counts come from ``dokimi.repos.l0``, the console line from ``dokimi.commands.repo_scan`` and the +``--json`` summary from ``dokimi.commands.repo``; ``dokimi.report.summary`` renders the cell. +""" + +from __future__ import annotations + +import json +from pathlib import Path + +from dokimi.artifacts import schema_errors +from dokimi.cli import build_parser +from dokimi.report.summary import render, summarize + +MANIFEST = """schema: repo_manifest.v1 +id: ignored-repro +source: {url: https://github.com/example/ignored-repro} +guidance: + globs: ["**/AGENTS.md"] +""" +NOTES = "### Notes\n\n- `sibling_pkg` is a sibling package.\n- `old_helper` parses the config.\n" +IGNORE = '[[ignore]]\npattern = "sibling_*"\nkind = "identifier"\nreason = "sibling packages in other repositories"\n' + + +def _repo(root: Path, scan_toml: str | None) -> Path: + files = {".github/dokimi/repo.yaml": MANIFEST, "AGENTS.md": NOTES} + if scan_toml is not None: + files[".dokimi/scan.toml"] = scan_toml + for rel, text in files.items(): + (root / rel).parent.mkdir(parents=True, exist_ok=True) + (root / rel).write_text(text, encoding="utf-8") + return root + + +def _scan(root: Path, capsys, *flags: str) -> str: + args = build_parser().parse_args(["repo", "scan", str(root), "--manifest", str(root / ".github/dokimi/repo.yaml"), + *flags]) + args.func(args) + return capsys.readouterr().out + + +def test_an_ignored_claim_is_counted_apart_in_every_block_and_in_the_json_summary(tmp_path, capsys): + root = _repo(tmp_path, IGNORE) + doc = json.loads(_scan(root, capsys, "--json")) + data = doc["data"] + assert [c["status"] for c in data["claims"] if c["claim"] == "sibling_pkg"] == ["unresolved_ignored"] + assert data["counts"]["unresolved"] == 2 and data["counts"]["ignored"] == 1 + assert data["counts"]["ok"] + data["counts"]["unresolved"] + data["counts"]["fail"] == data["counts"]["total"] + assert data["by_file"]["AGENTS.md"]["ignored"] == 1 + assert data["by_kind"]["identifier"]["ignored"] == 1 + assert data["by_source"]["framework"]["ignored"] == 1 + assert doc["summary"]["claims"]["ignored"] == 1 and doc["summary"]["claims"]["unresolved"] == 2 + assert schema_errors("repo_readiness.v1", data) == [] + + +def test_a_repository_with_no_ignore_entry_has_no_ignored_key(tmp_path, capsys): + root = _repo(tmp_path, None) + doc = json.loads(_scan(root, capsys, "--json")) + assert doc["data"]["counts"]["unresolved"] == 2 + assert "ignored" not in doc["data"]["counts"] and "ignored" not in doc["summary"]["claims"] + assert "claims: 2 (ok 0, unresolved 2, fail 0)" in _scan(root, capsys) + + +def test_the_console_line_shows_the_ignored_count_inside_unresolved(tmp_path, capsys): + out = _scan(_repo(tmp_path, IGNORE), capsys) + assert "claims: 2 (ok 0, unresolved 2 (1 ignored), fail 0)" in out + + +def test_report_summary_shows_the_ignored_cell_after_unresolved(tmp_path, capsys): + root = _repo(tmp_path / "repo", IGNORE) + scan = tmp_path / "scan.json" + scan.write_text(_scan(root, capsys, "--json"), encoding="utf-8") + md = render(summarize([str(scan)]), "markdown") + assert "claims.unresolved 2" in md and "claims.ignored 1" in md From 97bdde6838aa10cdc2b97636484cd1c8bceea20c Mon Sep 17 00:00:00 2001 From: Anton Volkov Date: Tue, 1 Dec 2026 16:26:45 +0000 Subject: [PATCH 2/2] fix(repos): repo_readiness.v1 keeps accepting counts.ignored of 0 The new `ignored` property had a minimum of 1, which rejected a v1 document that carries `counts.ignored: 0`; the counts object allowed extra keys before, so such a document was valid on main. The minimum is now 0 (the writer still omits the key when no claim is ignored), and a test validates a document with `ignored: 0`. Settles the blocking schema point of the review of #1497. Signed-off-by: Anton Volkov --- dokimi/dokimi/schemas/repo_readiness.v1.json | 2 +- dokimi/tests/test_repo_scan_ignored_count.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dokimi/dokimi/schemas/repo_readiness.v1.json b/dokimi/dokimi/schemas/repo_readiness.v1.json index d0f1cd8798..b0e438032d 100644 --- a/dokimi/dokimi/schemas/repo_readiness.v1.json +++ b/dokimi/dokimi/schemas/repo_readiness.v1.json @@ -16,7 +16,7 @@ "unresolved": {"type": "integer", "minimum": 0}, "fail": {"type": "integer", "minimum": 0}, "total": {"type": "integer", "minimum": 0}, - "ignored": {"type": "integer", "minimum": 1, "description": "How many of the `unresolved` claims are `unresolved_ignored` (a `.dokimi/scan.toml` [[ignore]] entry matched). Absent when none is; `unresolved` still counts them."} + "ignored": {"type": "integer", "minimum": 0, "description": "How many of the `unresolved` claims are `unresolved_ignored` (a `.dokimi/scan.toml` [[ignore]] entry matched). The writer omits it when none is; `unresolved` still counts them."} } } }, diff --git a/dokimi/tests/test_repo_scan_ignored_count.py b/dokimi/tests/test_repo_scan_ignored_count.py index 0fd3544577..45667cb84c 100644 --- a/dokimi/tests/test_repo_scan_ignored_count.py +++ b/dokimi/tests/test_repo_scan_ignored_count.py @@ -65,6 +65,12 @@ def test_a_repository_with_no_ignore_entry_has_no_ignored_key(tmp_path, capsys): assert "claims: 2 (ok 0, unresolved 2, fail 0)" in _scan(root, capsys) +def test_a_v1_document_with_ignored_zero_still_validates(tmp_path, capsys): + data = json.loads(_scan(_repo(tmp_path, None), capsys, "--json"))["data"] + data["counts"]["ignored"] = 0 + assert schema_errors("repo_readiness.v1", data) == [] + + def test_the_console_line_shows_the_ignored_count_inside_unresolved(tmp_path, capsys): out = _scan(_repo(tmp_path, IGNORE), capsys) assert "claims: 2 (ok 0, unresolved 2 (1 ignored), fail 0)" in out