loopx icon indicating copy to clipboard operation
loopx copied to clipboard

[Bug]: the public boundary scan reports a clean tree when a directory under the scan root cannot be listed

Open JasonBuildAI opened this issue 1 month ago • 1 comments

Preflight

  • [x] I searched existing issues and discussions for this behavior.
  • [x] This report is not an unpatched security vulnerability.
  • [x] The report and attachments contain no credentials or private/internal material.

Issue origin

Observed or reproduced in a real environment

LoopX version or commit

8f19e614ac2143589458a7f3f31e9c75c413efe3 (latest main at report time)

Host or runtime surface

Not host-specific

LoopX area

Control plane (goals, todos, quota, scheduler, registry, runtime)

Problem

loopx check --scan-path <tree> is the public/private boundary gate that CONTRIBUTING and AGENTS.md ask an author to run before publishing docs, examples or fixtures. When the tree contains a directory this process cannot list, the scan silently skips that directory, reports public boundary scan clean: N files, and exits 0 — even when the branch's only private file is inside it.

iter_scan_files walks with a bare os.walk(scan_root). os.walk swallows a listing failure by default (onerror=None), so an entire subtree contributes no file and no signal. #5303 closed the sibling case for a scan root that does not exist (public_boundary_scan_root_missing), and #6476 closed it for the sibling scanner loopx/capabilities/public_safe_outbound with an explicit directory_unreadable reason that keeps ok=false — the boundary owner itself was left with the gap.

Impact: a contributor working in a tree with a locally restricted directory (backup tools, sync agents and security products do set deny ACEs on Windows; chmod/umask or a root-owned directory do the same on POSIX) gets a green boundary report for exactly the content the gate exists to catch, publishes it, and the reviewer's full-tree run on a machine that can read the directory then fails. The failure is silent, so the author has no way to know the report was incomplete. examples/repository-hygiene-smoke.py and loopx canary premerge --from-git-diff call the same function and were equally blind.

Minimal reproduction

Reproduced on native Windows (the condition is the standard "directory cannot be listed"; the advertised loop below uses icacls, the POSIX equivalent is chmod 000 on the directory):

git init -q /tmp/tree && cd /tmp/tree
printf 'public text\n' > README.md
mkdir notes
printf 'internal host 10.0.0.7\n' > notes/private.md   # untracked private material
# Make notes/ unlistable for this user:
#   Windows: icacls notes /deny "%USERNAME%:(RD)"
#   POSIX:   chmod 000 notes

loopx check --scan-path /tmp/tree

Expected behavior

A scan that could not read part of the tree must not report a clean boundary. It should name the directory it could not list and exit non-zero, the way it already does for a missing scan root and the way public_safe_outbound reports directory_unreadable.

Actual behavior

Unreadable directory: the private file becomes invisible and the scan passes.

$ loopx check --scan-path <tree>      # notes/ denied
{"ok":true, ... "checks":["...","public boundary scan clean: 1 files"],
 "public_boundary_scan":{"state":"completed","ok":true,"scanned_files":1,"missing_scan_roots":[]}}
exit 0

Same tree with notes/ listable, for contrast:

{"ok":false, "errors":["notes\\private.md:1: private_ip"]}
exit 1

Sanitized diagnostics

$ python -c "from loopx.contract import scan_public_boundary; ..."
readable: ok=False files=2 hits=['notes\\private.md:1: private_ip'] unreadable=[] missing=[]
directory listing now fails: PermissionError [WinError 5] Access is denied
locked:   ok=True files=1 hits=[] unreadable=[] missing=[]

unreadable_files stays empty too: iter_utf8_file_reads only reports files the scan already enumerated, so a directory-level denial produces no reason code at all.

Additional context

Related merged work in the same family: #5303 (missing scan root fails closed), #6476 (public_safe_outbound fails closed on an unwalkable root/directory with scan_root_missing / directory_unreadable), #6007 (mode-000 read-denial coverage is POSIX-only).

JasonBuildAI avatar Oct 15 '26 05:10 JasonBuildAI

I traced this to iter_scan_files: directory-listing errors never reach scan_public_boundary because os.walk has no error callback. I will collect those traversal failures, include the affected directory and reason in the boundary result, and make loopx check fail without a clean-scan message while still scanning readable siblings. I will add focused regression coverage for unreadable roots/descendants and the CLI exit status, preserving intentional dependency-directory pruning.

Dante-dan avatar Oct 15 '26 11:10 Dante-dan