Repository navigation
Description
Related: #460, File provider API: traversal and discovery — the same surface, approached from
traversal and matching. This is the predicate half, and the two want reading together.
Design deferred, ruled 2026-09-24. This records the gap and the conversation that found it. The
API wants thoughtful design and now is not the time; nothing here is settled.
The gap
The file provider has predicates — file.exists, file.is_dir, file.is_file — and they already
compose as first-class values: test_choose_predicates.star uses them as plan.choose conditions
beside lambda bodies. There is no predicate for links. Nothing answers "is this a symbolic
link" or "is this link broken", so a traversal cannot select on it.
file.walk_tree(root, fn, include_gitignored) folds a tree through a Reducer:
Reducer func(initial any, entry Resource, relativePath string, stack *op.RecoveryStack) (any, error)
Everything needed to sweep dead links is there except the question.
Why this is worth a provider action rather than a script
noblefactor-ops/Home/common.Windows/.local/bin/Remove-BrokenLinks.ps1 is 247 lines — about 108
of code — to do what find -xtype l -delete does on Unix. The script says so itself and refuses to
run on Unix. The length is not gold-plating; PowerShell makes it necessary:
- Windows overloads reparse points. A OneDrive Files On-Demand placeholder, a deduplication stub
and a StoreAPPEXECLINKalias are all reparse points that are not links. The script carries a
hand-maintained allowlist of three tags, with a paragraph explaining that it must be an
allowlist because a denylist would start deleting each new tag Microsoft ships. - .NET leaves
LinkTypeandTargetempty forIO_REPARSE_TAG_LX_SYMLINK. That is
noblefactor-ops#241: 56 dead links survived on a machine for nine months because a blank
LinkTyperead as "not a link". Recovering the tag needsfsutil, and recovering a WSL target
needs parsingfsutil's hex dump by fixed column offsets — seven characters of padding, then
exactly 49 characters of hex field.
Go removes most of that. os/types_windows.go switches on the reparse tag and ends:
default:
m |= ModeIrregularfs.ModeSymlink is the allowlist, maintained by the Go team and failing closed on any tag it
does not know. And os.Stat follows a link, so a missing target is exactly os.IsNotExist — no
resolving relative targets against the link's parent, no fsutil, no subprocess.
Measured on DANOBLE-WD11-3, 2026-09-24, over ~/.local, ~/.config, ~/.claude: a 70-line Go probe
reported 87 symlinks, 1 broken, 0 irregular — the same 87 the PowerShell script sees, and it found
a live broken link, ~/.config/git/config.os.
The shape proposed, for the design to accept or reject
Layer 1 — predicates, extending the family that exists:
file.is_link(...) # a symlink, by fs.ModeSymlink
file.is_broken_link(...) # a symlink whose target does not resolvecomposed in the reducer's lambda:
broken = file.walk_tree(
root = "~/.local",
fn = lambda acc, res, path, stack:
(acc or []) + [res] if file.is_broken_link(res) else (acc or []),
)Removal then reuses file.remove, which already removes a symbolic link as itself — its doc is
explicit that it never follows — with archival undo, on_missing and pruning. No new mutation path.
Layer 2 — reducer combinators, the part that most needs design:
file.collecting(fn)
file.filtering(pred, reducer)
file.counting(pred)Every collector reducer in the fixtures hand-writes the same if initial == None accumulator
boilerplate, which is what a combinator would absorb.
Open questions
- Do predicates take
resourceorpath? The existing family takespath=; a reducer is
handed aresource. Splitting the family is a cost; overloading both is friendlier and less
crisp. - Is
is_linkworth having separately fromis_broken_link? "Is this a link at all" is the
question the PowerShell allowlist exists to answer, and Go answers it for free. - Layer 2 at all? It reads better and hides two things that matter: a reducer returns an
error to abort the traversal, and its fourth parameter is the recovery stack where compensation
is recorded. A combinator that drops either makes the composable path the one that cannot
compensate.walk_treeestablished the fold; a second way to write a reducer is a cost. - Is the WSL case in scope? A
IO_REPARSE_TAG_LX_SYMLINKlink isModeIrregularto Go, so a
ModeSymlinkpredicate will not see it — the 56 from noblefactor-ops#241 would be invisible.
Go does not expose the tag:Sys()returns*syscall.Win32FileAttributeData, no tag field.
Reading it meansgolang.org/x/sys/windowsandDeviceIoControl(FSCTL_GET_REPARSE_POINT)—
auint32from a struct rather than scraped text, but new Windows-specific code. - Does this retire
Remove-BrokenLinks.ps1? If it does, that is a noblefactor-ops change and
a deployment, not part of this issue.
Related
noblefactor-ops#241 (the 56 dead links, and the ruling "a blank link is broken") ·
noblefactor-ops#213 (where Remove-BrokenLinks.ps1 was committed) ·
noblefactor-ops#243 (a blank LinkType is not evidence that something is not a link) ·
pkg/gitignore (the precedent for replacing a fragile shell answer with Go, from
star-file-tree-walking.md, now docs/architecture/9.3-file-tree-walking.md)
Activity
David-Noble-at-work commentedon Nov 9, 2026
star github triage sweep added this issue to Triage: devlore, for the rule it breaks:
no-evidence: no Evidence of completion section