Documentation
¶
Overview ¶
Package relink is the one link-repoint primitive: after a verb MOVES a record between status folders, it rewrites every relative markdown link in the working tree that named the record's old path so that it names the new one, and reports each rewrite.
A record's status is its folder (open/ → closed/, planned/ → shipped/, open/ → resolved/), so every lifecycle transition is a rename, and a rename strands every relative link that named the file where it was. The verb that moves the record is the one place that knows both paths, so it is the place the links are repointed — in the same operation, not by a hand survey the next gate run discovers was incomplete (iss-2608311127491949, iss-2609091732329046). Three classes of link are repointed by the one rule:
- a link FROM any other file TO a moved record, from any folder — a spec already closed that names ../open/<the closing spec>, an ADR or a plan naming an intent's planned/ path, a draft naming both;
- a link FROM a moved record to a file that did not move, which was written from the old folder and resolves against the new one differently — a closing spec's bare link to a sibling still in open/;
- a link from a moved record to another record moved in the same operation.
The second and third classes read the moved record's links from the folder it left, which is sound only when the caller moved it in this operation (Move.MovedNow). A move an earlier operation made — a verb's re-run — still repoints the first class, but the moved record's own links are read where it is, because it may have been edited there since.
A link is rewritten only when it resolved before the move, so a link that never pointed anywhere stays exactly as written: repairing that is not the move's business, and a rewrite would disguise it. Links inside fenced code and HTML comments are rewritten too — a destination that resolved to the moved record is a reference to it wherever it is written, and record-lint's links_resolve judges a commented link as much as a live one.
The walk covers the whole working tree's markdown — the durable record, the shared working tier and the user-facing docs alike — because a link to a record is broken wherever it is written. It never enters .git, the local tier (.abcd/.work.local, which is per-checkout scratch), a node_modules directory, or a nested checkout (any directory holding its own .git), whose files belong to another working tree. Nor does it write into the two append-only logs the repository's gates refuse an in-place edit of — the decision log (DA002) and the reviews folder (RD002): a link there is history as written, and rewriting it would trade a dead link no lint root reads for a refused change. It reads and writes through an os.Root, follows no symlink, and skips any file past a byte cap.
The package is transport-free: it writes no output, and reports what it did as data for the front door to render.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Move ¶
type Move struct {
From string `json:"from"`
To string `json:"to"`
// MovedNow says the caller made this rename in the same operation, so the
// moved file's own relative links were written from From's folder and are
// re-relativised against To's. A move an earlier operation made (a verb's
// re-run finding the record already moved) leaves it false: the file may
// have been edited in its new folder since, so its own links are read from
// where it is, and only other files' links to From are repointed. The zero
// value is the conservative reading.
MovedNow bool `json:"moved_now,omitempty"`
}
Move is one record rename, as repo-relative slash paths.
type Rewrite ¶
type Rewrite struct {
// File is the repo-relative slash path of the file holding the link, at
// its location after the move.
File string `json:"file"`
// Line is the 1-based line the link is on.
Line int `json:"line"`
// From is the destination as it was written, and To as it now reads; both
// carry any #anchor or ?query the link had.
From string `json:"from"`
To string `json:"to"`
}
Rewrite is one link destination this package changed.
func Repoint ¶
Repoint rewrites every relative markdown link under repoRoot that the given moves left pointing at an old path, and returns the rewrites in file then line order. It runs AFTER the moves: a move whose destination is absent, or whose source is still present, did not happen as described and is ignored, which is also what makes a second call over the same moves a no-op — a verb may re-run it on a retry without double-rewriting anything. A moved file's own links are re-relativised only for a move marked MovedNow; see Move.
A move naming a path that is not a clean repo-relative slash path is refused before anything is read. An error part-way through the walk returns the rewrites already written alongside it, so a caller can report both.