Skip to content

fix: a gate that cannot see all of its input stops with exit 2 (PL-1822) - #125

Merged
jmf-pobox merged 31 commits into
mainfrom
fix/pl-1822-incomplete-scan
Dec 1, 2026
Merged

jmf-pobox merged 31 commits into
mainfrom
fix/pl-1822-incomplete-scan

Conversation

@jmf-pobox

@jmf-pobox jmf-pobox commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

What changed

Fixes PL-1822. A gate that cannot see all of its input now stops with exit 2 and names the cause, instead of passing over the part it read (IncompleteScanError).

The full list is the PL-1822 entry in CHANGELOG.md and "Incomplete Scans" in docs/REFERENCE.md.

Parsing. A module anywhere in the scan that does not parse stops every ratchet action with exit 2, touched or not, and nothing is written. This covers --check, --update, --reconcile, --rebaseline, --relax, --rebaseline-files and oo --audit-completeness.

Unreadable input. Each of these exits 2, in every gate:

  • an unlistable subdirectory;
  • an unlistable directory under a configured root glob;
  • an unreadable or non-UTF-8 module;
  • a source whose parent cannot be searched (on Python 3.14 this read as "Not found").

git.

  • Only git's "not a git repository" means no repository. Any other refusal exits 2 (for example "dubious ownership"), and so does any git failure other than a missing ref.
  • Every git call runs in the C locale, so a translated git reads the same.

Smaller changes.

  • coupling . names the package from the absolute path.
  • A single-file source that does not parse exits 2, as a directory does.
  • design without --base-ref stays advisory on a syntax error. A read or decode failure still exits 2.

Baseline and audit formats are unchanged. PR #124's partial-source refusal still applies. A reset over a module that does not parse now stops earlier, with exit 2 (incomplete scan), rather than exit 1; nothing is written in either case.

How it was proven

Tests under tests/incomplete_scan/, each failing before its fix. They cover:

  • unparseable modules, unreadable files, unreadable directories and root globs;
  • git failures, including a real German-locale git;
  • a single file;
  • a source under an unsearchable parent;
  • --audit-completeness.

Local review ran two rounds (code-reviewer, silent-failure-hunter, qodo). It found two High wrong-passes (the root glob and --audit-completeness), which are fixed. Every other finding is fixed, each with a test that fails first.

Ratchet rows that rose were blessed with audited reasons (--source PL-1822):

  • errors.py gained one public name;
  • sources.py and layers/scan.py import the new error;
  • oogate.py LCOM rose to 0.077 after deleting _unscorable.

Demo

demo confirmed: 0122767

Built a git repo with pkg/a.py and pkg/sub/s.py baselined, then broke it in two ways. Same script, main (c72f4cd) against this branch (0122767), both installed:

# 1. pkg/c.py added with a syntax error, outside the diff
main:   $ oo-ratchet oo pkg --check --base-ref HEAD
        No Python files touched -- trivial pass
        [exit 0]
branch: $ oo-ratchet oo pkg --check --base-ref HEAD
        oo-ratchet oo: error: incomplete scan: pkg/c.py could not be parsed
        [exit 2]

# 2. pkg/sub made unlistable (chmod 0)
main:   $ oo-ratchet coupling pkg --check --base-ref HEAD
        No scored Python files touched
        [exit 0]
branch: $ oo-ratchet coupling pkg --check --base-ref HEAD
        oo-ratchet coupling: error: incomplete scan: cannot read pkg/sub: Permission denied
        [exit 2]

# 3. refusal input
branch: $ oo-ratchet oo pkg --check --bogus
        oo-ratchet oo: error: unrecognized arguments: --bogus
        [exit 2]

…-1822)

`oo-ratchet coupling SRC --threshold` exited 0 when a module did not parse:
it printed an empty row for the file and a PASS table over the modules that
did parse. The `oo` view exited 1 with the same empty row and no cause.

Both views now exit 2 when any module failed to parse, and the table views
end with one line per such module naming the cause:

    ERROR: pkg/bad.py could not be parsed: invalid syntax (bad.py, line 1)

The JSON views keep the {"file", "error"} row and exit 2. `--check` and
`--update` are unchanged: they already fail on a touched unparseable module.

Failing on the unfixed code (tests/incomplete_scan/test_unparseable_module.py,
first draft of the same cases):

    FAILED ...test_threshold_view_exits_2_naming_the_file[coupling]
        pkg/bad.py   (empty row)        assert 0 == 2
    FAILED ...test_threshold_view_exits_2_naming_the_file[oo]
        pkg/bad.py   (empty row)        assert 1 == 2
    FAILED ...test_json_view_exits_2    assert 0 == 2

Passing after the fix:

    uv run pytest tests/incomplete_scan/test_unparseable_module.py -m ""
    .......                                                  [100%]

Two characterizations pinned the old exit 1 for an oo view over a broken
module (tests/oo/test_oo_scoring_domain.py, tests/test_qodo_fixes.py); they
now pin exit 2 and the ERROR line.
…L-1822)

`Sources.files` enumerated modules with `Path.rglob`, which skips a directory
it cannot read without a word. A package with an unreadable subdirectory was
scored without it, so oo, coupling, suppressions, design and layers could all
pass without measuring that code.

The enumeration now walks the tree with `Path.walk(on_error=...)`, and a
listing error raises the new `IncompleteScanError` (core/domain/errors.py).
It is neither an `OSError` nor a `StateError`, so no gate's "unreadable file"
handler can turn it into an error row or a plain FAIL. The dispatcher
(`__main__.Dispatcher._call`) catches it for every gate and exits 2:

    oo-ratchet coupling: error: incomplete scan: cannot read pkg/locked: Permission denied

Failing on the unfixed code (pkg/locked at mode 000, first draft):

    FAILED ...test_gate_exits_2_naming_the_directory[coupling]  assert 0 == 2
    FAILED ...test_gate_exits_2_naming_the_directory[oo]        assert 0 == 2
    FAILED ...test_gate_exits_2_naming_the_directory[suppressions]
        "total": 0, "by_file": {}                              assert 0 == 2
    FAILED ...test_gate_exits_2_naming_the_directory[design]
        "files_scanned": 1                                     assert 0 == 2

Passing after the fix:

    uv run pytest tests/incomplete_scan/test_unreadable_directory.py -m ""
    ........                                                 [100%]

(coupling --threshold/--json, oo --threshold/--check, suppressions, design,
layers, and an --namespace scan.)
…sitory" (PL-1822)

`GitRepo` found its root with `git rev-parse --show-toplevel` through `_run`,
which dropped git's stderr and returned None for every nonzero exit. A
checkout git refuses to open ("detected dubious ownership", an unsupported
`core.repositoryformatversion`) therefore looked like a directory outside any
repository, and the gates fell back to the cwd for config and cap keys.

`GitRepo._toplevel` now reads git's answer (in the C locale): only "not a git
repository (or any ...)" is absence, a state the gates handle. Any other
refusal, and a git that times out, raises `IncompleteScanError`, which the
dispatcher turns into exit 2 with git's own message:

    oo-ratchet coupling: error: incomplete scan: git refused the repository at
    /.../repo: fatal: detected dubious ownership in repository at '/.../repo' ...

A missing git binary is still "git unavailable", as before.

Failing on the unfixed code (first draft of the same cases):

    FAILED ...test_dubious_ownership_exits_2_with_gits_message  assert 0 == 2
    FAILED ...test_unsupported_repository_format_exits_2        assert 0 == 2

Passing after the fix:

    uv run pytest tests/incomplete_scan/test_git_refusal.py -m ""
    .....                                                    [100%]

(dubious ownership through coupling --threshold, oo --check and suppressions
--check via git's GIT_TEST_ASSUME_DIFFERENT_OWNER; repository format 99; and a
directory outside any repository still scans with exit 0.)
…L-1822)

`SourceSelection.name`, the package spelling coupling import resolution used,
was `self.anchor.name`. For `oo-ratchet coupling .` run inside the package
that is `Path(".").name == ""`, so no absolute import (`from pkg.b import x`)
resolved: a real import cycle reported 0 and efferent coupling dropped to 0,
while the same package scanned from its parent reported the cycle.

The count was right for the edges it saw; the package name was wrong. The
fix removes `name` and uses `package_name`, which already derived the name
from the normalized absolute anchor (unresolved, so a symlinked package keeps
the name it was given). `ModuleSource` loses its `name` member; coupling's
TreeScan and design's ShadowScan read `package_name`.

Failing on the unfixed code (first draft):

    FAILED ...test_cycle_count_does_not_depend_on_cwd
        {'efferent_coupling': 0.0} != {'efferent_coupling': 1.0}
        {'circular_imports': 0.0} != {'circular_imports': 1.0}

Passing after the fix:

    uv run pytest tests/incomplete_scan/test_scan_from_inside.py -m ""
    ....                                                     [100%]

(JSON equal from both cwds; `coupling .`, `../pkg` and `./` from inside all
FAIL circular_imports 1.00.)
…eline (PL-1822)

REFERENCE.md gains an Incomplete Scans section. CHANGELOG names the adopters vox, quarry, lux, z-spec and punt-kit. oo-baseline/audit come from make update-oo with --base-ref 7b04026 --require-base (no regression). The coupling baseline is not in this commit: update-coupling refused three rows (see the unit report).
…ord exit 2 (PL-1822)

The Path.walk enumeration dropped a directory named *.py, which rglob yielded; the scorers then failed on reading it. tests/suppression/test_suppression_ratchet.py TestSuppressionFailClosed failed on the walk (DID NOT RAISE OSError; main() == 0 instead of 1) and passes again. The core_real coupling and oo view transcripts recorded exit 0/1 for a --json view over an unparseable module; they now record exit 2 (one code field each).
…(PL-1822)

One new error type for an incomplete scan: defined in core/domain/errors.py (public_names 2 -> 3), raised by sources.py (efferent_coupling 0 -> 1), caught by the dispatcher in __main__.py (efferent_coupling 4 -> 5). Blessed with --rebaseline-files and a recorded reason; oo/scoring.py and source_set.py LCOM improved.

check-coupling against 7b04026: three rows RELAXED, four IMPROVED, 'PASS: no regressions'.
…ery ratchet action with exit 2 (PL-1822)

Review round 1, items 1, 2 and 4.

1. `--check` kept only parse errors in touched files (core/application/
   check.py), so an unparseable module outside the diff passed: "No Python
   files touched -- trivial pass". `--update` refused only the touched one and
   wrote the rest. `Measurement.complete()` now raises `IncompleteScanError`
   when any module in the scan did not parse; Check (before it resolves a base,
   so a first adoption is stopped too), Update, Reconcile and the waive actions
   call it before any verdict or write. The parse-error / parse-refused
   verdict paths that no operation can produce any more are deleted from
   update.py, oocli, couplingview, gatecli and outcomelog.
2. An unreadable touched module exited 1 with "touched file(s) failed to
   parse". Reading moved to one place, `Sources.text` (through
   `SourceSelection.text`), which raises `cannot read <file>: <reason>`
   (permissions, not UTF-8, a directory named like a module); a syntax error
   is still an error row, a different message.
4. coupling/trees.py read a package `__init__.py` and treated an OSError as
   "absent" for package metrics; it now reads through `Sources.text`.
design/output.py adds `IncompleteScanError` to the errors it reports as exit 2.

Failing on the unfixed code (tests/incomplete_scan/test_ratchet_scan.py):

    test_check_exits_2_on_an_untouched_unparseable_module[oo]
        No Python files touched -- trivial pass          assert 0 == 2
    test_check_exits_2_on_an_untouched_unparseable_module[coupling]
        No scored Python files touched                   assert 0 == 2
    test_check_exits_2_on_a_touched_unparseable_module[oo|coupling]
        FAIL: touched file(s) failed to parse: pkg/a.py  assert 1 == 2
    test_update_exits_2_on_an_unparseable_module_and_writes_nothing[oo]
        Baseline updated ... files improved: 0           assert 0 == 2
    test_check_exits_2_on_an_unreadable_touched_module[oo|coupling]
        FAIL: touched file(s) failed to parse: pkg/a.py  assert 1 == 2
    test_coupling_exits_2_on_an_unreadable_package_init
        exit 2 via an error row, no "cannot read pkg/sub/__init__.py"

Passing after the fix:

    uv run pytest tests/incomplete_scan -m ""
    ........................................                 [100%]

22 existing tests and recorded transcripts pinned "row kept, exit 1" for an
unparseable or undecodable module; they now pin IncompleteScanError and that
nothing was written (four coupling transcripts re-recorded, diff checked:
only code, the message line, and no first-adoption write; two unused OO golden
entries dropped; the design encoding scenario now reads "cannot read ...: not
UTF-8"). test_update_backfill's "failure" scenario uses a metric regression
instead of a syntax error, since a syntax error no longer reaches the writer.
…ing ref is unresolved (PL-1822)

Review round 1, items 3, 5 and 6.

3. `GitRepo.resolve` read every nonzero git exit, and a missing git binary, as
   "unresolved"; without --require-base and with no baseline that passed as a
   first adoption (bases.py). It now asks git whether the ref names anything
   (`rev-parse --verify --quiet`, exit 1 with no message = absent), then peels
   it. A named ref that points at a missing object, a merge base git cannot
   compute, and a git that cannot start raise IncompleteScanError with git's
   message. A literal object id the repository lacks (a shallow clone, a typo)
   and a ref that does not exist stay unresolved, as do origin/main and HEAD
   sharing no history. `_run` callers keep their None-on-failure contract; a
   timeout reads as a failed call.
5. `_toplevel` ran git with cwd = the source; for a single-file source that
   raised "[Errno 20] Not a directory". It now runs in the file's directory;
   a source not on disk is outside any repository, as before.
6. Every git call from GitRepo runs with LC_ALL=C and LANGUAGE=C (one `_call`),
   so "not a git repository" and the ref answers read the same in any locale.

Failing on the unfixed code (tests/incomplete_scan/test_git_failures.py):

    test_a_merge_base_git_cannot_compute_exits_2[oo|coupling]
        No base and no in-tree baseline -- first-adoption bootstrap pass
                                                         assert 0 == 2
    test_a_base_ref_naming_a_missing_commit_exits_2     assert 0 == 2
    test_a_missing_git_binary_exits_2
        git did not run ...; treating it as unavailable ... bootstrap pass
                                                         assert 0 == 2
    test_a_single_file_source_finds_its_repository
        oo-ratchet goal: [Errno 20] Not a directory: PosixPath('pkg/a.py')

Passing after the fix:

    uv run pytest tests/incomplete_scan -m ""
    ........................................                 [100%]

test_git_is_read_in_the_c_locale (de_DE locale, outside a repository: exit 0,
every git call carries LC_ALL=C) passes on this host's git either way; it
guards the override. tests/design/test_design_snapshot.py's fake
subprocess.run now accepts and passes through `env`.
…o and coupling baselines (PL-1822)

REFERENCE.md: every ratchet action stops on a module that does not parse anywhere in the scan; an unreadable module has its own message; the --update and files_regressed rows no longer describe kept parse-error rows. docs/ratchet.tex: OUTCOME gains incompleteScan (exit 2); new Scan, CompleteScan and IncompleteScan schemas; OoCheck, CplCheck and NeverLoosenUpdate include CompleteScan in place of brokenTouched/parseErrTouched. fuzz -t type-checks it with no errors. CHANGELOG names the round-1 behavior changes for vox, quarry, lux, z-spec and punt-kit. oo baseline/audit from make update-oo, coupling baseline/audit from make update-coupling plus the leader's bless of scores.py efferent_coupling 0 -> 1, all with --base-ref 7b04026 --require-base; check-oo and check-coupling both PASS.
… (PL-1822)

Path.glob skipped a directory it could not list, so roots = ["parts/*/ns"]
with parts/b at mode 000 dropped parts/b/ns from the scan and oo/coupling
--check passed a regressed module there. Root patterns now expand segment by
segment with os.scandir and raise IncompleteScanError on any listing error.

Before:
  FAILED test_glob_root_over_unlistable_directory_exits_2[oo]
    AssertionError: No Python files touched -- trivial pass; assert 0 == 2
  FAILED test_glob_root_over_unlistable_directory_exits_2[coupling]
    AssertionError: No scored Python files touched; assert 0 == 2
After:
  tests/incomplete_scan/test_unreadable_directory.py: 10 passed
… (PL-1822)

The audit compared only the parse-clean files with the baseline, so an
unbaselined module that did not parse was invisible and the audit printed
PASS. It now reads the measurement through Measurement.complete(), as every
other oo action does.

Before:
  FAILED test_audit_completeness_exits_2_on_an_unbaselined_unparseable_module
    AssertionError: PASS: baseline complete for 2 scored files; assert 0 == 2
After:
  tests/incomplete_scan/test_unparseable_module.py: 8 passed
…dule (PL-1822)

test_missing_file_flagged_hidden_and_broken_excluded pinned the bug the
previous commit fixed: it expected --audit-completeness to report on the
parse-clean files and leave sub/broken.py out. Split it: hidden files are
still excluded, and an unparseable module now raises IncompleteScanError.

Before (after the fix, old test):
  FAILED TestCompleteness::test_missing_file_flagged_hidden_and_broken_excluded
    IncompleteScanError: sub/broken.py could not be parsed
After:
  tests/oo/test_oo_ratchet.py -k Completeness: 3 passed
suppressions read modules with tokenize.open and caught OSError and
UnicodeDecodeError into a plain FAIL (exit 1). ModuleIndex caught read and
decode errors into its skipped list, so layers exited 1 (FAIL: cannot read
or parse) and design exited 0 listing the module as skipped.

Reads now go through Sources.text, which raises IncompleteScanError, and
nothing downgrades it: suppressions falls back to Sources.text when its
cookie-aware read fails, SourceSelection.read_source uses Sources.text, and
ModuleIndex catches only SyntaxError and ValueError. layers exits 2 on a
skipped (unparseable) module too; design keeps it advisory in skipped.
REFERENCE, DESIGN and the CHANGELOG PL-1822 entry describe the new exits.

Before (tests/incomplete_scan/test_unreadable_file.py):
  11 failed, 1 passed, e.g.
  layers:       FAIL: cannot read or parse: pkg/locked.py; assert 1 == 2
  design:       ... skipped (unparseable): pkg/locked.py; assert 0 == 2
  suppressions: FAIL: [Errno 13] Permission denied: 'pkg/locked.py'; assert 1 == 2
  suppressions: FAIL: 'utf-8' codec can't decode byte 0xe9 ...; assert 1 == 2
  layers bad.py: FAIL: cannot read or parse: pkg/bad.py; assert 1 == 2
After:
  tests/incomplete_scan: 55 passed
Three suppressions tests and one layers test pinned the old exit 1 and were
moved to IncompleteScanError.
GitRepo.show and exists_at ran git in the user's locale, but _absent reads
git's English "does not exist in". Under a translated git a missing
baseline or path raised GitError instead of reading as absent. Both now go
through _call, which sets LC_ALL=C and LANGUAGE=C; a missing git binary now
stops the scan (exit 2) as it does for every other git call.

Before:
  FAILED test_a_translated_git_still_reads_a_missing_path_as_absent
    GitError: git show HEAD:missing.json errored: Schwerwiegend: Pfad
    'missing.json' existiert nicht in 'HEAD'
After:
  tests/incomplete_scan: 56 passed
…-1822)

make update-oo with --base-ref d4bda73 --require-base: pass, 0 regressed.
make update-coupling refused src/oo_ratchet/layers/scan.py (efferent_coupling
regressed: it now imports core.domain.errors for IncompleteScanError); its
coupling baseline is unchanged and the refusal is in the audit log.
…chive locale exit 2 (PL-1822)

Q1: oo on a single file that does not parse returned 'FAIL: cannot score'
(exit 1) before the incomplete-scan handling ran. OoGate._unscorable is
deleted: the view now exits 2 with 'ERROR: <file> could not be parsed:
<cause>' and the actions stop with 'incomplete scan: <file> could not be
parsed', as for a directory.

R3b: on Python 3.14 Path.exists is False on EACCES, so a source under a
mode-600 directory printed 'Not found' (exit 1). The source guards in oo,
coupling, suppressions, layers and goal (cli, summary, next, propose) now ask
Sources.present, which uses Presence and turns 'cannot tell' into
IncompleteScanError. GitRepo._toplevel uses Presence too, so it no longer
reads 'cannot tell' as 'not in a repository'.

L1 scope: archive_paths now runs git with the same C-locale environment as
_call, show and exists_at (GitRepo._c_locale). New tests cover a translated
git end to end: a first-adoption --check, a spy over every git call a --check
makes (including git show), and archive_paths.

H2: the --audit-completeness test moves to test_ratchet_scan.py, and the
CHANGELOG and REFERENCE action lists name --audit-completeness. REFERENCE's
Incomplete Scans section names design's advisory exception.

Two older tests pinned 'FAIL: cannot score' exit 1 and now expect exit 2 /
IncompleteScanError; the stale golden row test_target_missing_and_unscorable#1
is removed.

Before (src changes reverted, new tests kept):
  FAILED test_single_file_view_exits_2_naming_the_file[argv0,argv1]
    AssertionError: FAIL: cannot score pkg/bad.py; assert 1 == 2
  FAILED test_single_file_check_exits_2_naming_the_file
    AssertionError: FAIL: cannot score pkg/bad.py; assert 1 == 2
  FAILED test_source_under_an_unlistable_parent_exits_2[oo,coupling,layers]
    AssertionError: Not found: outer/pkg; assert 1 == 2
  FAILED test_source_under_an_unlistable_parent_exits_2[suppressions]
    AssertionError: not found: outer/pkg; assert 1 == 2
  FAILED test_source_under_an_unlistable_parent_exits_2[goal]
    oo-ratchet goal: Not found: outer/pkg
  FAILED test_repository_lookup_under_an_unlistable_parent_raises
    DID NOT RAISE PresenceError
  FAILED test_archive_paths_runs_git_in_the_c_locale (env not C)
Before L1 (gitrepo.py at 6711f86):
  FAILED test_a_first_adoption_check_passes_under_a_translated_git
    FAIL: git show ...:.punt-labs/oo-ratchet/oo-baseline.json errored:
    Schwerwiegend: Pfad ... existiert nicht in ...; assert 1 == 0
  FAILED test_a_check_reads_every_git_answer_in_the_c_locale (same)
After:
  tests/core_real/test_oo_gate.py tests/test_qodo_fixes.py
  tests/incomplete_scan: 143 passed
… (PL-1822)

The coupling update refused the previous commit's new imports: goal flows
imported source_set at runtime, gitrepo imported presence, and a second
SourceSelection method broke the class's method cap.

- SourceSelection gets one method, exists(); gate_options and oogate build a
  SourceSelection, the goal flows call it on theirs (no new imports).
- GitRepo._mode stats the start path itself and raises IncompleteScanError on
  'cannot tell' (exit 2, not a PresenceError FAIL); _toplevel stays under the
  complexity target.

make update-oo: pass, 0 regressed. make update-coupling refused
src/oo_ratchet/core/adapters/oogate.py max_lcom/avg_lcom (0.038 -> 0.077)
after deleting _unscorable; left unblessed.

tests/test_class_debt_sources.py failed with 25 > 24 methods before this
change and passes after; tests/incomplete_scan, tests/core_real, tests/oo,
tests/goal, tests/test_qodo_fixes.py all pass.
… (PL-1822)

check-design --enforce found three added size-cap findings (classes over 25
methods): Sources, SourceSelection and GitRepo.

- The root-glob expansion moves to a private _RootPattern class in sources.py.
  Its ** walk no longer asks Path.is_dir, which is False on 3.14 when stat
  fails.
- SourceSelection.exists is gone. The source guard is GateOptions.present
  (Sources.present), and the Requested protocol carries it for OoGate.
- GitRepo's C-locale env and stat helper become module functions.
- goal propose now checks its source first, as goal show does. Its flows
  printed 'Not found' for a source under an unsearchable parent; the
  test_source_under_an_unlistable_parent_exits_2[argv5] case failed with
  'oo-ratchet goal: Not found: outer/pkg' without the guard and passes with it.

check-design --base-ref d4bda73 --enforce: neutral, 0 tier0/tier1 added.
make update-oo: pass. Full make test on this tree: 3489 passed, 4 skipped.
A reset or reconcile over a module that does not parse, or a directory it
cannot list, now stops with IncompleteScanError (exit 2) before PR 124's
coverage check; the five rebaseline-scope tests that expected exit 1 now
expect that, and still assert nothing is written.
@qodo-code-review

qodo-code-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

fix: a gate that cannot see all of its input stops with exit 2 (PL-1822)

🐞 Bug fix 🧪 Tests 📝 Documentation 🕐 40+ Minutes

Grey Divider

AI Description

• Every ratchet action exits 2 when any module in the scan fails to parse, touched or not.
• Unlistable directories, unreadable or non-UTF-8 modules, and unsearchable sources now exit 2 with
 the cause.
• Only git's "not a git repository" counts as no repo; other git failures exit 2, run in the C
 locale.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 2 capabilities

  • 2 affected capabilities span independent functional scopes: ratchet analysis CLI integration, ratchet quality-gate integration.
  • Check, update, reconcile, relax, and rebaseline operate on the same measured source tree and baseline state; the complete-scan invariant reaches each operation through Measurement and shared dispatch behavior.
  • These commands expose source-analysis outcomes through the same source-selection and dispatcher integration.
  • Their reporting surfaces are related outcomes of one bounded scan-reporting integration, not separate technical-layer capabilities.
Sources

src/oo_ratchet/main.py[74-80]

        try:
            return gate(self._args[1:], *extra)
        except IncompleteScanError as exc:
            # The gate did not see all of its input: never a pass, never a
            # plain FAIL that reads as a measured regression.
            sys.stderr.write(f"oo-ratchet {name}: error: incomplete scan: {exc}\n")
            return 2
Behavioral complexity 🟡 Medium 🧩 Multiple interactions

  • Before, source discovery and read failures could be skipped, scored as ordinary errors, or treated as absent, and suppression decoding retried through a generic UTF-8 path.
  • After, discovery, reads, parsing, Git inspection, and ratchet writes use a fail-closed incomplete-scan protocol, while suppression distinguishes default UTF-8 fallback from a conflicting declared encoding.
  • New correctness conditions are that every selected module is enumerated and readable, only a genuinely missing path or ref is treated as absent, declared encodings are honored without unauthorized reinterpretation, all operation entry points reject incomplete measurements, and CLI callers preserve the distinction between an incomplete scan and a measured regression.
  • Existing AST scoring, mapping, and Git helpers are reused; their reuse is not itself complexity.
  • The coordinated invariant is that no ratchet state mutation occurs after an incomplete scan.
  • Tests cover parse, unreadable, directory, encoding, missing-Git, locale, and Git-refusal transitions, but external CLI consumers remain unverified.
Sources

src/oo_ratchet/main.py[74-80]

        try:
            return gate(self._args[1:], *extra)
        except IncompleteScanError as exc:
            # The gate did not see all of its input: never a pass, never a
            # plain FAIL that reads as a measured regression.
            sys.stderr.write(f"oo-ratchet {name}: error: incomplete scan: {exc}\n")
            return 2
Potential damage 🟡 Medium 🩹 Incorrect results

  • If the fail-closed invariant regresses, incomplete source or Git input could be treated as a valid measurement, producing a false pass, misleading regression, or unsafe baseline decision.
  • The follow-up narrows one compatibility ambiguity by rejecting a file that violates its declared encoding instead of reinterpreting it as UTF-8.
  • A false decision can be rerun after repairing the scan input.
  • If incorrect baseline or audit rows were written, stored state requires manual restoration or correct backfill; no automatic repair worker is shown.
Sources

src/oo_ratchet/main.py[74-80]

        try:
            return gate(self._args[1:], *extra)
        except IncompleteScanError as exc:
            # The gate did not see all of its input: never a pass, never a
            # plain FAIL that reads as a measured regression.
            sys.stderr.write(f"oo-ratchet {name}: error: incomplete scan: {exc}\n")
            return 2
Assessed commit 0122767
Diagram

graph TD
  A["Gate run"] --> B["Sources scan"] --> C["Module parse and read"] --> E["IncompleteScanError"] --> D["Dispatcher"] --> X["Exit 2 with cause"]
  A --> G["GitRepo"] --> E
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Per-gate error handling with exit codes
  • ➕ Each gate decides its own message and exit code
  • ➕ No cross-cutting exception type
  • ➖ Seven gates would each need the same catch-and-exit logic
  • ➖ Easy to miss one gate, which is the bug this PR fixes
2. Wrap Path.glob or glob.glob and catch OSError
  • ➕ Less code than a custom glob walker
  • ➖ Both skip unlistable directories silently, so errors never surface
  • ➖ Cannot distinguish a missing directory from an unreadable one

Recommendation: The PR's central choice is sound: one IncompleteScanError, caught once in the Dispatcher, so no gate can turn an unreadable input into a plain FAIL or a silent pass. Per-gate return codes would repeat the same mistakes across seven gates. The custom _RootPattern glob is justified because Path.glob and glob.glob skip unlistable directories silently. The main open question is whether the _run timeout path should also raise, so a timed-out git call is not read as absence.

Files changed (69) +1849 / -486

Enhancement (4) +38 / -0
errors.pyAdd IncompleteScanError, the signal for a scan that cannot read all input +9/-0

Add IncompleteScanError, the signal for a scan that cannot read all input

• Adds IncompleteScanError as a plain Exception, deliberately not an OSError or StateError, so gate handlers cannot turn it into a scored row or a FAIL.

src/oo_ratchet/core/domain/errors.py

scores.pyAdd scores support for complete-scan measurement +13/-0

Add scores support for complete-scan measurement

• Adds 13 lines in the scoring domain; the complete() measurement path that every action now calls. Not individually reviewed here.

src/oo_ratchet/core/domain/scores.py

report.pyAdd render_errors for per-module parse-failure lines +8/-0

Add render_errors for per-module parse-failure lines

• Adds 8 lines that render one 'ERROR: <file> could not be parsed: <cause>' line per failed module for table views.

src/oo_ratchet/coupling/report.py

scoring.pyOo scorer exposes complete-scan support +8/-0

Oo scorer exposes complete-scan support

• Adds 8 lines to the oo scorer so the gate can check for a complete scan. Not individually reviewed here.

src/oo_ratchet/oo/scoring.py

Bug fix (17) +392 / -159
__main__.pyDispatcher maps IncompleteScanError to exit 2 with an incomplete-scan message +8/-1

Dispatcher maps IncompleteScanError to exit 2 with an incomplete-scan message

• Dispatcher._call catches IncompleteScanError once, writes the cause to stderr with the gate name, and returns 2 for every gate.

src/oo_ratchet/main.py

gitrepo.pyFail closed on git errors; run every git call in the C locale +137/-44

Fail closed on git errors; run every git call in the C locale

• _toplevel reads only 'not a git repository' as absence. resolve, _commit and _named raise on git failures other than a missing ref. _call sets LC_ALL=C and raises if git cannot run. _mode treats a permission error as 'cannot tell', not absent.

src/oo_ratchet/core/adapters/gitrepo.py

sources.pyEnumerate and read sources so unreadable input raises instead of being skipped +134/-8

Enumerate and read sources so unreadable input raises instead of being skipped

• Replaces rglob and Path.glob with a walk that raises on an unlistable directory. Adds a text() reader for UTF-8 and read errors, and present() for a 3.14 stat failure. Configured root globs use the new _RootPattern expander.

src/oo_ratchet/sources.py

source_set.pyRoute source reads through Sources; derive package name from absolute anchor +16/-8

Route source reads through Sources; derive package name from absolute anchor

• read_source and the new text() delegate to Sources, so every read raises IncompleteScanError. package_dirs-style naming now uses package_name from the normalized absolute path, which fixes 'coupling .' inside a package. The name property is removed.

src/oo_ratchet/source_set.py

gate_options.pyAdd present property that uses Sources.present +5/-0

Add present property that uses Sources.present

• GateOptions.present returns Sources.present(anchor), so an unsearchable source raises instead of reading as 'Not found'.

src/oo_ratchet/gate_options.py

oogate.pyStop the oo gate on parse errors; audit-completeness measures the full scan +17/-20

Stop the oo gate on parse errors; audit-completeness measures the full scan

• The single-file unscorable check and the _unscorable helper are removed. _view exits 2 when any module has a parse error. _completeness reads measure().complete(), so an unparsed module stops the audit instead of passing.

src/oo_ratchet/core/adapters/oogate.py

oorequest.pyAdd present property to the oo request +5/-0

Add present property to the oo request

• Adds a five-line present property on the oo request, used by OoGate.run in place of the old Path.exists check.

src/oo_ratchet/core/adapters/oorequest.py

check.pyCheck measures the full scan first; parse-error verdict removed +6/-4

Check measures the full scan first; parse-error verdict removed

• Check calls measure().complete() before any verdict, so an unparseable module anywhere in the scan stops --check. The parse-error failure path for touched files is removed.

src/oo_ratchet/core/application/check.py

update.pyUpdate refuses an incomplete scan before writing; parse_errors removed from plans +20/-32

Update refuses an incomplete scan before writing; parse_errors removed from plans

• Update uses measure().complete(), so no plan exists for a broken scan and nothing is written. UnparsedPlan, parse_errors, and the parse-refused path are removed from the reconciliation and tally.

src/oo_ratchet/core/application/update.py

waive.pyWaive and rebaseline use the complete scan +3/-3

Waive and rebaseline use the complete scan

• Three lines changed in the waiver operations so rebaseline and relax stop on an incomplete scan.

src/oo_ratchet/core/application/waive.py

trees.pyCoupling tree scan reads through source.text and fails on unreadable modules +10/-17

Coupling tree scan reads through source.text and fails on unreadable modules

• Read failures now raise IncompleteScanError through source.text. Only SyntaxError is skipped as an error row. The package __init__ read and _safe_score use the same path.

src/oo_ratchet/coupling/trees.py

cli.pyCoupling view exits 2 on parse errors and prints the error lines +5/-3

Coupling view exits 2 on parse errors and prints the error lines

• _view returns 2 when any module has a parse error, and appends per-module ERROR lines. The existence check uses options.present.

src/oo_ratchet/coupling/cli.py

proposerun.pyGoal proposal run stops on an incomplete scan +7/-0

Goal proposal run stops on an incomplete scan

• Seven lines added so the goal proposal run surfaces IncompleteScanError instead of proposing on a partial scan.

src/oo_ratchet/goal/proposerun.py

scan.pyLayers scan raises IncompleteScanError for an unparseable module +3/-2

Layers scan raises IncompleteScanError for an unparseable module

• Replaces LayersScanError('cannot read or parse') with IncompleteScanError naming the module, so layers exits 2 instead of 1.

src/oo_ratchet/layers/scan.py

tree.pyOo tree reads through source.text and package_name +6/-8

Oo tree reads through source.text and package_name

• Replaces raw file reads with source.text, so unreadable modules raise IncompleteScanError. Uses package_name for module keys.

src/oo_ratchet/oo/tree.py

cli.pySuppression CLI uses the present check and updated naming +5/-5

Suppression CLI uses the present check and updated naming

• Five lines changed so suppression gates use the complete-scan and present checks.

src/oo_ratchet/suppression/cli.py

gateinput.pySuppression gate input reads through the complete-scan path +5/-4

Suppression gate input reads through the complete-scan path

• Five lines added and four changed so suppression input is read through the source reader that raises on failure.

src/oo_ratchet/suppression/gateinput.py

Refactor (13) +15 / -48
couplingview.pyRemove parse-refused reporting from the coupling view +2/-17

Remove parse-refused reporting from the coupling view

• Drops the parse-refused kind from REPORTED and the _parse_or and parse-refused refusal rendering. Parse failures no longer reach the view as verdict failures.

src/oo_ratchet/core/adapters/couplingview.py

oocli.pyDrop parse-refused and parse-error branches from the oo CLI renderer +1/-11

Drop parse-refused and parse-error branches from the oo CLI renderer

• Removes the parse-refused refusal and parse-error FAIL messages, since a parse failure now stops the gate before a verdict.

src/oo_ratchet/core/adapters/oocli.py

gatecli.pyRemove two lines of gate CLI handling +0/-2

Remove two lines of gate CLI handling

• Removes two lines from the shared gate CLI adapter; the removed lines are not individually described in the PR.

src/oo_ratchet/core/adapters/gatecli.py

outcomelog.pyRemove one line from the outcome log adapter +0/-1

Remove one line from the outcome log adapter

• Removes one line; the change is not individually described in the PR.

src/oo_ratchet/core/adapters/outcomelog.py

reconcile.pyUpdate reconcile call for the new plan shape +1/-1

Update reconcile call for the new plan shape

• A one-line change in the reconcile operation to match the removed parse_errors field.

src/oo_ratchet/core/application/reconcile.py

modules.pyUse package_name in the module index +2/-2

Use package_name in the module index

• Two lines swap the removed name property for package_name.

src/oo_ratchet/core/domain/modules.py

modulesource.pyTrim ModuleSource protocol to package_name; read_source docs say IncompleteScanError +2/-7

Trim ModuleSource protocol to package_name; read_source docs say IncompleteScanError

• Removes the name property from the ModuleSource protocol and documents that read_source raises IncompleteScanError rather than OSError.

src/oo_ratchet/core/domain/modulesource.py

output.pyAdjust design output for the source name change +2/-2

Adjust design output for the source name change

• Two lines updated to use the new package naming in design output.

src/oo_ratchet/design/output.py

shadow_scan.pyUse source.package_name in shadow scan +1/-1

Use source.package_name in shadow scan

• One line switches from source.name to source.package_name for module keys.

src/oo_ratchet/design/shadow_scan.py

cli.pyGoal CLI uses the updated source naming +1/-1

Goal CLI uses the updated source naming

• One line changed to match the source-name API update.

src/oo_ratchet/goal/cli.py

summaryrun.pyGoal summary run uses updated source naming +1/-1

Goal summary run uses updated source naming

• One line changed to match the source-name API update.

src/oo_ratchet/goal/summaryrun.py

cli.pyLayers CLI uses updated source naming +1/-1

Layers CLI uses updated source naming

• One line changed to match the source-name API update.

src/oo_ratchet/layers/cli.py

suggest.pyLayers suggest uses updated source naming +1/-1

Layers suggest uses updated source naming

• One line changed to match the source-name API update.

src/oo_ratchet/layers/suggest.py

Tests (27) +1102 / -172
__init__.pyPackage marker for the incomplete-scan test suite +0/-0

Package marker for the incomplete-scan test suite

• Empty package file so the new incomplete_scan tests can be collected.

tests/incomplete_scan/init.py

scan_cli.pyShared CLI helper for incomplete-scan tests +37/-0

Shared CLI helper for incomplete-scan tests

• Adds a 37-line helper that runs the gate CLI in a subprocess and returns exit code and output for the scan tests.

tests/incomplete_scan/scan_cli.py

test_unparseable_module.pyTests that an unparseable module stops every gate with exit 2 +81/-0

Tests that an unparseable module stops every gate with exit 2

• Covers threshold and JSON views for coupling and oo, and every ratchet action over a broken module, touched or not.

tests/incomplete_scan/test_unparseable_module.py

test_unreadable_file.pyTests for unreadable and non-UTF-8 modules +103/-0

Tests for unreadable and non-UTF-8 modules

• Covers a module that cannot be read or decoded, exiting 2 with the cause in every gate.

tests/incomplete_scan/test_unreadable_file.py

test_unreadable_directory.pyTests for unlistable subdirectories and root globs +135/-0

Tests for unlistable subdirectories and root globs

• Covers an unlistable subdirectory and an unlistable directory under a configured root glob, both exiting 2.

tests/incomplete_scan/test_unreadable_directory.py

test_git_refusal.pyTests that only 'not a git repository' reads as no repo +65/-0

Tests that only 'not a git repository' reads as no repo

• Covers git refusals such as dubious ownership and an unsupported repository format, which now exit 2.

tests/incomplete_scan/test_git_refusal.py

test_git_failures.pyTests for git failures, including a German-locale git +229/-0

Tests for git failures, including a German-locale git

• Covers git failures other than a missing ref and a translated git, with a first-adoption check under a German locale.

tests/incomplete_scan/test_git_failures.py

test_ratchet_scan.pyTests that ratchet actions stop on an incomplete scan +219/-0

Tests that ratchet actions stop on an incomplete scan

• Covers --check, --update, --reconcile, --rebaseline, --relax, and --rebaseline-files over incomplete input.

tests/incomplete_scan/test_ratchet_scan.py

test_scan_from_inside.pyTests scans run from inside the package +52/-0

Tests scans run from inside the package

• Covers scans started from inside the package, including coupling . naming the package correctly.

tests/incomplete_scan/test_scan_from_inside.py

test_check.pyUpdate check tests for the complete-scan requirement +13/-2

Update check tests for the complete-scan requirement

• Thirteen lines added and two changed for the new exit behavior on parse failures.

tests/core/test_check.py

test_writes.pyUpdate write tests for the complete-scan requirement +4/-3

Update write tests for the complete-scan requirement

• Four lines added and three changed so write tests expect the new exit-2 behavior.

tests/core/test_writes.py

coupling_play.pyCoupling play script adds a case +6/-0

Coupling play script adds a case

• Six lines added to the coupling play harness for the new incomplete-scan case.

tests/core_real/coupling_play.py

design_golden.jsonUpdate design golden output +1/-1

Update design golden output

• One line changed in the design golden file for the new package naming.

tests/core_real/design_golden.json

golden_coupling_gate.jsonUpdate coupling gate golden output +18/-33

Update coupling gate golden output

• Eighteen lines added and 33 removed to match the new coupling output and error lines.

tests/core_real/golden_coupling_gate.json

oo_gate_golden.jsonTrim oo gate golden output +1/-25

Trim oo gate golden output

• Removes 25 lines of golden output for the dropped parse-refused and unscorable paths.

tests/core_real/oo_gate_golden.json

test_oo_gate.pyUpdate oo gate real-repo tests for exit 2 +14/-16

Update oo gate real-repo tests for exit 2

• Fourteen lines added and 16 changed to match the new exit-2 and naming behavior.

tests/core_real/test_oo_gate.py

test_coupling_ratchet.pyUpdate coupling ratchet tests for exit 2 on parse errors +16/-17

Update coupling ratchet tests for exit 2 on parse errors

• Sixteen lines added and 17 changed for the new coupling exit behavior.

tests/coupling/test_coupling_ratchet.py

test_design_snapshot.pyDesign snapshot test covers the advisory syntax-error path +7/-1

Design snapshot test covers the advisory syntax-error path

• Seven lines added to confirm design without --base-ref stays advisory on a syntax error.

tests/design/test_design_snapshot.py

gate_runs.pyGate run helper updated for exit 2 +7/-1

Gate run helper updated for exit 2

• Seven lines added to the shared gate-run helper to cover the new exit code.

tests/gate_runs.py

test_layers_scan.pyLayers scan test expects IncompleteScanError +4/-1

Layers scan test expects IncompleteScanError

• Four lines added and one changed to assert the new layers exception.

tests/layers/test_layers_scan.py

test_oo_ratchet.pyOo ratchet tests move from exit 1 to exit 2 for parse errors +41/-35

Oo ratchet tests move from exit 1 to exit 2 for parse errors

• Forty-one lines added and 35 removed. Characterization tests that pinned exit 1 for an oo view over a broken module are updated.

tests/oo/test_oo_ratchet.py

test_oo_scorer.pyOo scorer tests updated for the new scoring path +7/-5

Oo scorer tests updated for the new scoring path

• Seven lines added and five changed for the scorer's new behavior.

tests/oo/test_oo_scorer.py

test_oo_scoring_domain.pyDomain characterization test pins exit 2 for broken modules +2/-1

Domain characterization test pins exit 2 for broken modules

• Two lines added and one changed; the oo view over a broken module now expects exit 2.

tests/oo/test_oo_scoring_domain.py

test_suppression_ratchet.pySuppression ratchet tests updated for exit 2 +10/-8

Suppression ratchet tests updated for exit 2

• Ten lines added and eight changed for the suppression gate's new exit behavior.

tests/suppression/test_suppression_ratchet.py

test_qodo_fixes.pyQodo review fixes covered by updated tests +15/-7

Qodo review fixes covered by updated tests

• Fifteen lines added and seven changed for the qodo-review follow-ups, including the root-glob and audit-completeness fixes.

tests/test_qodo_fixes.py

test_rebaseline_scope.pyRebaseline scope tests updated for the complete-scan rule +8/-15

Rebaseline scope tests updated for the complete-scan rule

• Eight lines added and 15 removed; reset over a module that does not parse now expects exit 2 with nothing written.

tests/test_rebaseline_scope.py

test_update_backfill.pyUpdate backfill test updated for the complete-scan rule +7/-1

Update backfill test updated for the complete-scan rule

• Seven lines added and one changed for the new update behavior on incomplete scans.

tests/test_update_backfill.py

Documentation (4) +207 / -42
CHANGELOG.mdChangelog entry for PL-1822 incomplete-scan exits +60/-2

Changelog entry for PL-1822 incomplete-scan exits

• Adds a PL-1822 bullet listing each gate behavior that changes to exit 2, and rewrites the earlier partial-source reset entry to say exit 2.

CHANGELOG.md

REFERENCE.mdDocument the Incomplete Scans section and exit codes +64/-8

Document the Incomplete Scans section and exit codes

• Adds an 'Incomplete Scans' section describing exit 2 for every incomplete-input case, and updates the exit-code table.

docs/REFERENCE.md

DESIGN.mdDesign note on fail-closed incomplete scans +7/-1

Design note on fail-closed incomplete scans

• Seven lines added and one changed to describe the fail-closed design for incomplete scans.

docs/DESIGN.md

ratchet.texUpdate the LaTeX ratchet spec for exit 2 on incomplete scans +76/-31

Update the LaTeX ratchet spec for exit 2 on incomplete scans

• Adjusts the formal ratchet description so a parse failure stops the run rather than producing a refusal verdict.

docs/ratchet.tex

Other (4) +95 / -65
oo-baseline.jsonRe-bless oo baseline rows with audited reasons +50/-50

Re-bless oo baseline rows with audited reasons

• 50 rows changed, including the oogate LCOM rise to 0.077 after _unscorable was removed. Each change carries the audited PL-1822 reason.

.punt-labs/oo-ratchet/oo-baseline.json

oo-audit.jsonlAppend audit records for the PL-1822 re-bless +12/-0

Append audit records for the PL-1822 re-bless

• Twelve audit lines record the PL-1822 reasons for the blessed rows.

.punt-labs/oo-ratchet/oo-audit.jsonl

coupling-baseline.jsonRe-bless coupling baseline rows with audited reasons +15/-15

Re-bless coupling baseline rows with audited reasons

• 15 rows changed for rows that rose under the PL-1822 change.

.punt-labs/oo-ratchet/coupling-baseline.json

coupling-audit.jsonlAppend audit records for the coupling re-bless +18/-0

Append audit records for the coupling re-bless

• Eighteen audit lines record the PL-1822 reasons for the coupling rows.

.punt-labs/oo-ratchet/coupling-audit.jsonl

@qodo-code-review

qodo-code-review Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Windows scans can omit source roots ✓ Resolved High Strong Bug

Resolving commit: e6d48fa

Description
_RootPattern._step uses fnmatch.fnmatchcase for wildcard segments, replacing Path.glob's
platform-dependent matching with case-sensitive matching on every platform. On Windows, a configured
pattern such as parts/*/App* can therefore omit a directory named app, leaving its modules
outside the gate's scan when another root still matches.


View medium (2)
Remediation recommended
2. Invalid source can enter suppression counts ✓ Resolved Medium Strong Bug

Resolving commit: e6d48fa

Description
Scanner._read now catches UnicodeDecodeError from a declared source encoding and retries the
file as UTF-8. A UTF-8-decodable file with # coding: ascii and a non-ASCII character is accepted
and counted despite contradicting its coding cookie, so a suppression check can produce a verdict
from source that failed its declared decoding.

3. Single-file scans still exit as plain failures ✓ Resolved Medium Moderate Bug
Description
OoGate._dispatch returns FAIL: cannot score before the new _view exit-2 handling or
Measurement.complete() can run. When the source is a single Python file with a syntax error, both
a table view and a ratchet action exit 1 without the parse-error diagnostic.

Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #124
✅ Compliance rules (platform): 6 rules
✅ Cross-repo context — repo relationships
  Explored: repo: punt-labs/vox (sha: a38512d4) — View relationship
  Explored: repo: punt-labs/z-spec (sha: 8415d18f) — View relationship
  Explored: repo: punt-labs/punt-kit (sha: 4a775aed) — View relationship
  Explored: repo: punt-labs/lux (sha: 883cf508) — View relationship
✅ REVIEW.md
Review mode: Auto: ⚖️ Balanced: Cross-cutting scanner changes alter fail-closed behavior across multiple gates.

Grey Divider

Previous reviews

Review updated until commit 0122767 ⚖️ Balanced

Results up to commit dc5fc4f ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required
1. Windows scans can omit source roots ✓ Resolved High Strong Bug

Resolving commit: e6d48fa

Description
_RootPattern._step uses fnmatch.fnmatchcase for wildcard segments, replacing Path.glob's
platform-dependent matching with case-sensitive matching on every platform. On Windows, a configured
pattern such as parts/*/App* can therefore omit a directory named app, leaving its modules
outside the gate's scan when another root still matches.


View medium (2)
Remediation recommended
2. Invalid source can enter suppression counts ✓ Resolved Medium Strong Bug

Resolving commit: e6d48fa

Description
Scanner._read now catches UnicodeDecodeError from a declared source encoding and retries the
file as UTF-8. A UTF-8-decodable file with # coding: ascii and a non-ASCII character is accepted
and counted despite contradicting its coding cookie, so a suppression check can produce a verdict
from source that failed its declared decoding.

3. Single-file scans still exit as plain failures ✓ Resolved Medium Moderate Bug
Description
OoGate._dispatch returns FAIL: cannot score before the new _view exit-2 handling or
Measurement.complete() can run. When the source is a single Python file with a syntax error, both
a table view and a ratchet action exit 1 without the parse-error diagnostic.

Grey Divider

Comment thread src/oo_ratchet/sources.py Resolved
Comment thread src/oo_ratchet/suppression/gateinput.py Resolved
@qodo-code-review

Copy link
Copy Markdown
Contributor

Qodo Fixer

✅ Committed (2) · ☑ Fixed (2)

Grey Divider

Commits pushed directly to this PR — no separate fix PR opened.

Process — 2 fixed
  • ☑ Fixed: Windows scans can omit source roots
  • ☑ Fixed: Invalid source can enter suppression counts

…b Actions (PL-1822)

CI failed 13 incomplete_scan tests: their --update seeding refused under
GITHUB_ACTIONS ('refusing to write baseline under GITHUB_ACTIONS without
--allow-ci-write'), and the dubious-ownership test passed as a first adoption
because actions/checkout trusts every directory in the runner's global git
config. An autouse fixture unsets GITHUB_ACTIONS for these tests, and the
ownership test points git at an empty global config.

Proof: tests/incomplete_scan passes with GITHUB_ACTIONS=true and a global
config of safe.directory='*'.
…ixer's two commits (PL-1822)

The Qodo Fixer's e6d48fa reported every decode failure as 'not valid under its
declared encoding', including a module with no cookie (UTF-8 by default), so
test_non_utf8_module_exits_2_naming_it[suppressions] failed: 'cannot read
pkg/latin.py: not UTF-8' was no longer printed. A UTF-8 decode failure now
falls back to SourceSelection.text, which names it; only another declared
encoding gets the cookie message.

New tests:
- test_glob_root_matches_with_the_platforms_case_rule: with a case-folding
  normcase, parts/*/App* matches parts/x/app. Before 7a29076 (fnmatchcase):
  'assert [] == [.../parts/x/app]'. After: passes.
- test_suppressions_refuses_a_module_its_coding_cookie_rejects: an ascii
  cookie over UTF-8 text exits 2.
@jmf-pobox

Copy link
Copy Markdown
Contributor Author

verified: 0122767
demo confirmed: 0122767

  • CI is green on 0122767 for Python 3.13 and 3.14, plus check: the full suite and every ratchet gate.
  • The incomplete-scan tests also pass locally with GITHUB_ACTIONS=true and a global git config of safe.directory='*', as on the runner.
  • Demo, run on 0122767 installed into its own venv:
    • A module that does not parse, outside the diff: oo --check exits 2 ("incomplete scan: pkg/c.py could not be parsed"). Main passes it, exit 0.
    • A subdirectory that cannot be listed: coupling --check exits 2 ("cannot read pkg/sub: Permission denied"). Main passes it, exit 0.
    • A bad flag exits 2.
  • Qodo's two findings (wildcard root casing; the coding cookie) are fixed, each with a test that fails first. Both threads are resolved.

@jmf-pobox
jmf-pobox merged commit 90d9d11 into main Dec 1, 2026
3 checks passed
@jmf-pobox
jmf-pobox deleted the fix/pl-1822-incomplete-scan branch December 1, 2026 23:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant