Read a root file a document under docs/ links, which neither reading reached - #169
Merged
iderex merged 1 commit intoAug 22, 2026
Merged
Conversation
…reached A document under docs/ writes a link to a file at the root as ../NAME, and that target fell between the two readings the paths leg joins. PathsNamedInProse requires a leading segment naming a directory of this tree and two full stops are not one; LinkTargetsWithoutADirectory skips any target carrying a slash. So a document under docs/ could link a root file that is not in the tree and nothing said so, which is the case #162 raised and #165 closed one directory up. The failure this prevents is the passing run. Three links on the default branch are in that shape today and all three resolve, so nothing is broken until the day one of them is not, and that day has already happened once: LICENSE left the default branch for a day and docs/operator-guide.md would have pointed at nothing while the leg stayed green. Neither existing reading grows. Both are exact about a population and say so in their own comments, so this adds a third, LinkTargetsAboveTheirDocument, which returns a link target that steps out of the document's own directory and leaves the caller to place it. pathsNamedIn joins it to the document's directory rather than to the root, and drops a target that climbs past the root, because whether a file outside the checkout exists is not a question any reading of this tree answers. Closes #168 Signed-off-by: Nils Lehnen <30603423+iderex@users.noreply.github.com>
iderex
deleted the
invariants/a-document-under-docs-linking-a-root-file
branch
August 22, 2026 07:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #168
What this changes
A document under
docs/writes a link to a file at the repository root as../NAME, and that target was read by neither of the two readings the paths legjoins.
PathsNamedInProserequires a leading segment naming a directory of thistree and
..is not one;LinkTargetsWithoutADirectoryskips any targetcarrying a slash. The two sat either side of the shape.
Neither of them grows. Both are exact about a population and argue for that
exactness in their own comments, so this adds a third reading,
LinkTargetsAboveTheirDocument, which returns a link target stepping out of thedocument's own directory and leaves the caller to place it.
pathsNamedInjoins it to the document's own directory rather than to the root,which is what the issue requires of whichever reading was chosen, and it drops a
target that climbs past the root of the checkout.
Two fixtures hold both directions, in the register the two neighbouring cases
already use: a document under
docs/linking a root file that is not there, andits near neighbour linking one that is.
What failure it prevents
The passing run. Three links on the default branch are in this shape and all
three resolve, so nothing is broken today. The day one of them is not has
already happened once:
LICENSEleft the default branch for a day under #155and
docs/operator-guide.mdwould have pointed at nothing while the leg stayedgreen.
What was run
At
2eb07c1, onwindows/amd64.The near-miss the issue names, in both spellings. Before this change the
../spelling passed and only the bare spelling reddened. Both redden now:
The guard deleted, which is what says it bites for the reason it names. With the
third reading's loop taken out of
pathsNamedInand nothing else changed, onecase reddens and no other:
The three links the issue lists are subjects the leg examines rather than text it
walks past. Moving
LICENSEout of the tree and running the leg reaches both ofthe
docs/ones, alongside the two root documents the second reading alreadyhad:
and the third one the same way:
Both files were put back before the commit, which
git statusreported cleanafterwards.
The gate
CONTRIBUTING.mdnames, in the order it names it:gofmt -lprinted nothing, which is its passing result. The suite:and the runner over this tree:
That run is on one platform. What the other two suite platforms do with this
change is not measured here and is the workflow's answer rather than mine.
What this does not do
Nobody but me has read this change. The evidence above is in place of a second
reader rather than alongside one, and it is a weaker thing.
It does not widen
PathsNamedInProseto read..in a sentence. That pattern isnarrow on purpose and the reason is written where it is narrow, so
../LICENSEtyped into a sentence is still a word here and only a link is resolved.
It says nothing about a target that climbs past the root of the checkout. Such a
target is returned by the reading and dropped by the caller, deliberately and
with the reason at the drop: whether a file outside the checkout exists is not a
question any reading of this tree answers, which is the same reason a target
carrying a scheme is left alone. So a document linking
../../somewhereisneither resolved nor refused, and a run that is green says nothing about it.
The fixture proves the property and never which line inside the leg produced it,
which is the bound the harness states about itself. The arms a tree cannot reach
are covered by the direct table in
internal/check/paths_test.goinstead: afragment on the end, a repeated target, ordering, a scheme, a backslash, and the
two shapes that belong to the other two readings.