relink

package
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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 history no change may edit — a managed repository's frozen decision log, which abcd reads and never writes, and the reviews folder, whose gate refuses an in-place edit (RD002): a link there is history as written. A decision record in .abcd/work/decisions/ is relinked like any other record (spc-2610110931381316, decision 13). 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

func Repoint(repoRoot string, moves []Move) ([]Rewrite, error)

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.

Every rewrite is a read-modify-write, and this package takes no lock: it cannot import the stores that own them (they import it). So the CALLER holds the ledger lock, then the intent store's lock, then the spec store's across the call, through intent.WithLedgerThenMintLock — intent's repointUnderLock for the verbs that move an intent or a spec, and capture's repointMovedIssue for an issue transition — or a ledger, intent or spec writer landing on a linking record between the read and the write is erased, and a spec close landing there leaves the spec in both status folders (iss-2609261254247117, iss-2609262143209970, iss-2609262218309668).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL