reqmd Package: repin

Package: repin

approved 39Leaf

39 requirements · 9 items

X Reqmd.source File
X Reqmd.source Line
X Reqmd.symbol Kind

This file is auto-generated by reqmd-code. Do not edit by hand.

IMP-repin-Result-e706624 Result

#

missing coverage

Result is the value Build returns: a sorted list of deltas plus aper-file summary derived from the same list. The caller passesDeltas to Apply or to one of the Format* functions.

The JSON field names form the stable contract for thereqmd repin --json interface.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
31
X Reqmd.symbol Kind
type
Status
approved

IMP-repin-ApplyReport-fe50f25 ApplyReport

#

missing coverage

ApplyReport describes the outcome of a repin apply step. Appliedis the number of ref replacements actually written to disk (adelta whose SourceRef wasn't found in any attr block is a no-opand not counted). Skipped holds the predated deltas, which repinnever auto-fixes. Files is the number of distinct spec filesactually rewritten.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
45
X Reqmd.symbol Kind
type
Status
approved

IMP-repin-Build-e76efe3 Build

#

missing coverage

Build parses the spec tree at root and returns the list ofversion-pin changes that repin would propose (or apply, whenfollowed by Apply). When promoteUnpinned is true, refs withouta pin against a versioned upstream are also proposed for pinning— converting "no claim" into "claimed at current version".

The returned Result is sorted (delegated to graph.RepinDeltas).

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
58
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-Apply-5d0fd9b Apply

#

missing coverage

Apply rewrites each file containing at least one outdated orunpinned delta. Predated deltas are reported back in the Skippedslice and never applied — they are data-integrity errors thatrequire manual review.

The rewrite is scoped to ```attr blocks: each block's contentsare scanned for the SourceRef substring, which is replaced withthe new ref form (REFnewPin, or REFnewPin if the ref waspreviously unpinned). All other bytes of the file are preservedverbatim.

Files are read and rewritten relative to root through an os.Root, so adelta path can never escape the requirements tree. If a write fails thefunction returns the error; the apply report lists every delta that wassuccessfully applied.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
101
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-applyToFile-396fcb0 applyToFile

#

missing coverage

applyToFile rewrites the attr-block portions of src so that eachdelta's SourceRef is replaced with the new ref form. A delta isconsidered a no-op if its SourceRef isn't found in any attr block(or every match is at a non-boundary position); in that case thefile is returned unchanged.

Returns the (possibly rewritten) bytes and the total number ofref replacements actually made across all attr blocks.

Matching is whole-ref: SourceRef "UP-001" only matches when theref is at a list-element boundary (followed by ,, ], orwhitespace) AND is not the prefix of a longer ref (not followedby ~ for the unpinned-promote case). This prevents a naivesubstring match from corrupting an already-pinned ref likeUP-001~3 when the same ref is being promoted from unpinned.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
173
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-refPair-3f3a0d2 refPair

#

missing coverage

refPair is a pre-computed (oldRef, newRef) pair ready for bytematching. oldRef and newRef are []byte (not strings) to avoidrepeated []byte() conversions inside the hot scan loop.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
203
X Reqmd.symbol Kind
type
Status
approved

IMP-repin-buildPairs-b1a95f0 buildPairs

#

missing coverage

buildPairs projects a slice of RepinDelta into refPairs, droppingany delta whose old ref already equals the new ref (no-op).

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
209
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-applyPairsToBlock-d1dd176 applyPairsToBlock

#

missing coverage

applyPairsToBlock scans block and emits a new []byte with everymatching ref replaced. For each position it finds the earliestnext match across all pairs, copies the unmatched run verbatim,then emits the replacement. Returns the new bytes and the numberof replacements made. When no pair matches, returns blockunchanged (zero allocation) and a count of 0.

Cost note: this is N sub-scans into one output buffer, where N islen(pairs) — not a true single pass. For the typical repinworkload (a handful of deltas, small attr blocks) this is fine;an Aho-Corasick automaton would be the single-pass alternative butis overkill here.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
234
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-isRefBoundary-7978e98 isRefBoundary

#

missing coverage

isRefBoundary reports whether the match at [start, end) inside bufis a whole ref (not a substring of a longer token). Both edges arechecked:The byte before the match must be a list-element starter ([, ,, whitespace, or start-of-block) so we don't match "UP-001" inside "XUP-001".The byte after the match must be a list-element terminator ( , \t, \n, \r, ,, ], or end-of-block) so we don't match "UP-001" inside "UP-001X".The byte after must NOT be ~ — that would mean we matched the prefix of a longer ref (e.g. "UP-001" inside "UP-001~3"), which must never be rewritten.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
291
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-newRefFrom-b432132 newRefFrom

#

missing coverage

newRefFrom computes the new source-form ref string for a delta.The transform is:"doc-id/ID1" + newPin=3 → "doc-id/ID3""ID1" + newPin=3 → "ID3""doc-id/ID" + newPin=3 → "doc-id/ID3" (unpinned promote)"ID" + newPin=3 → "ID3" (unpinned promote)

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
323
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-attrRange-a27fc5f attrRange

#

missing coverage

attrRange is an inclusive [start, end) byte range covering theinner YAML of an attr block (NOT including the ``` fences).

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
330
X Reqmd.symbol Kind
type
Status
approved

IMP-repin-locateAttrBlocks-482068e locateAttrBlocks

#

missing coverage

locateAttrBlocks scans src for attr\n ... \n fences andreturns the inner-YAML byte ranges. Blank lines between theopening fence and the first YAML line are skipped over by theparser; the same applies here: we treat the byte immediatelyafter the opening fence's newline as the range start.

The match is anchored to the literal string "```attr" followedby an optional space/info segment. This matches the parser'sattrFenceInfo = "attr" convention exactly.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
341
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-bytesSliceReplace-0712eaa bytesSliceReplace

#

missing coverage

bytesSliceReplace returns a new []byte with src[start:end]replaced by replacement. Single allocation via nested appends.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
381
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-stripPinForDisplay-6fee437 stripPinForDisplay

#

missing coverage

stripPinForDisplay removes a trailing ~N from a ref so the dry-rundiff reads naturally. Delegates to model.StripPin.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
387
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-FormatText-ef8de19 FormatText

#

missing coverage

FormatText renders the Result as the human-readable change listshown by reqmd repin in dry-run mode. The format is:spec/path/to/file.md REQ-ID REF → REF~newPin ... N outdated + M unpinned + P predated refs across K files.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
398
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-FormatTextApplied-c2e84fe FormatTextApplied

#

missing coverage

FormatTextApplied renders an ApplyReport as a one-line summary.Used after a successful --yes run.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin.go
X Reqmd.source Line
419
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-writeFile-e36944a writeFile

#

missing coverage


Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
21
X Reqmd.symbol Kind
function
Status
approved

Helpers

writeFile creates a temp dir, writes content, and returns the dir path(caller is responsible for cleanup via t.TempDir()).

IMP-repin-minimalSchema-67f296b minimalSchema

#

missing coverage

minimalSchema is a permissive JSON Schema for attr blocks. Testsonly need the schema to exist (parser requires it); they don'tvalidate the attrs strictly.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
35
X Reqmd.symbol Kind
const
Status
approved

IMP-repin-makeTree-1cd1113 makeTree

#

missing coverage

makeTree creates a two-doc spec tree with one upstream (versionedat upVersion) and one downstream that traces to it with thesupplied pin (or no pin when pin is ""). The downstream's traceline is rendered exactly as supplied so we can assert byte-leveledits in Apply.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
43
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestBuild_Outdated-1e31778 TestBuild_Outdated

#

missing coverage


Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
60
X Reqmd.symbol Kind
function
Status
approved

Build

IMP-repin-TestBuild_PromoteUnpinned-9dcb605 TestBuild_PromoteUnpinned

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
75
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestBuild_NoPromoteUnpinned-0171e10 TestBuild_NoPromoteUnpinned

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
89
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestBuild_CurrentIsNoOp-e4931f1 TestBuild_CurrentIsNoOp

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
100
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestApply_RewritesAttrBlockOnly-7f89609 TestApply_RewritesAttrBlockOnly

#

missing coverage


Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
115
X Reqmd.symbol Kind
function
Status
approved

Apply: file rewrite semantics

IMP-repin-TestApply_PromoteAddsPin-026610f TestApply_PromoteAddsPin

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
152
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestApply_PreservesProseWithTilde-cc05272 TestApply_PreservesProseWithTilde

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
170
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestApply_Idempotent-be9805f TestApply_Idempotent

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
212
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestApply_UnpinnedPromoteDoesNotCorruptPinnedSiblings-c1fd101 TestApply_UnpinnedPromoteDoesNotCorruptPinnedSiblings

#

missing coverage

TestApply_UnpinnedPromoteDoesNotCorruptPinnedSiblings guardsagainst a real bug discovered in the smoke test: a naive substringmatch for SourceRef="UP-001" would rewrite the prefix of analready-pinned ref "UP-0013" to "UP-0013~3". The apply pathmust use whole-ref matching so an unpinned ref never corrupts apinned sibling.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
237
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestApply_SkipsPredated-6633c33 TestApply_SkipsPredated

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
295
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestApply_MultipleDeltasSameFile-33d073f TestApply_MultipleDeltasSameFile

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
321
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestNewRefFrom-124c532 TestNewRefFrom

#

missing coverage


Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
371
X Reqmd.symbol Kind
function
Status
approved

newRefFrom

IMP-repin-TestLocateAttrBlocks-c978a8e TestLocateAttrBlocks

#

missing coverage


Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
396
X Reqmd.symbol Kind
function
Status
approved

locateAttrBlocks

IMP-repin-TestLocateAttrBlocks_NoBlocks-ce0a15e TestLocateAttrBlocks_NoBlocks

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
425
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestLocateAttrBlocks_IgnoresFencedButNotAttr-4a508d6 TestLocateAttrBlocks_IgnoresFencedButNotAttr

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
432
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestFormatText_Empty-aedec57 TestFormatText_Empty

#

missing coverage


Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
445
X Reqmd.symbol Kind
function
Status
approved

FormatText

IMP-repin-TestFormatText_Outdated-6b59b62 TestFormatText_Outdated

#

missing coverage

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
452
X Reqmd.symbol Kind
function
Status
approved

IMP-repin-TestResultJSON_Roundtrip-82619ce TestResultJSON_Roundtrip

#

missing coverage


Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
471
X Reqmd.symbol Kind
function
Status
approved

JSON output

IMP-repin-TestBuild_SortedByFile-d604ba6 TestBuild_SortedByFile

#

missing coverage


Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
507
X Reqmd.symbol Kind
function
Status
approved

Sort order — repin reuses graph's sort; this is a regression testto ensure Build preserves it.

IMP-repin-TestApply_PreservesFileMode-ff4fcfc TestApply_PreservesFileMode

#

missing coverage

TestApply_PreservesFileMode verifies that rewriting a spec file keeps itsexisting permissions instead of forcing a default mode.

Details
X Reqmd.imported
true
X Reqmd.source File
internal/repin/repin_test.go
X Reqmd.source Line
534
X Reqmd.symbol Kind
function
Status
approved