Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<!--
Copyright (C) 2026 Intel Corporation
SPDX-License-Identifier: Apache-2.0
-->

### 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.
6 changes: 5 additions & 1 deletion dokimi/docs/repo-evaluation-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion dokimi/dokimi/commands/repo_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]:
Expand Down
2 changes: 2 additions & 0 deletions dokimi/dokimi/repos/l0/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
3 changes: 2 additions & 1 deletion dokimi/dokimi/schemas/repo_readiness.v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": 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."}
}
}
},
Expand Down
84 changes: 84 additions & 0 deletions dokimi/tests/test_repo_scan_ignored_count.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# 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_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


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
Loading