Artifact 7c38f714a03a500089d9a4778bf3b32500b4504cea48563733c19a6f4211a88c:
- File
internal/verify/rebuild_tags.go
— part of check-in
[6273a0750d]
at
2026-07-22 23:03:24
on branch trunk
— fix: correct go.mod module path to go-libfossil (#76) (#117)
* fix: correct go.mod module path to go-libfossil (#76)
The module directive still declared github.com/danmestas/libfossil after the repository was renamed to go-libfossil. pkg.go.dev/godoc scraping matches the declared module path against its hosting path, so the stale path broke SDK doc generation.
Rename the module path across all four in-repo modules (root, the two db/driver submodules, observer/otel, and docs/site) and every internal import, plus the release workflow, the doc-generation script, and the docs.
No tag has been published under the go-libfossil path yet, so the cross-module requires cannot resolve from the proxy. Add replace directives pointing the in-repo requires at their local directories so GOWORK=off builds and the CI matrix resolve without a published version. These replaces are ignored by downstream consumers and can be dropped once new-path tags are cut.
* Guard releases against replace directives; regenerate SDK docs
The go-libfossil rename bridges the in-repo modules with `replace` directives. Go refuses a main module that carries them, so a tag cut while they are present breaks `go install .../cmd/libfossil@<tag>` and every `@version` fetch of the driver submodules. Add a Release workflow step that fails the job before anything is published if any tracked go.mod still contains a replace directive, so the bridge is a CI-enforced TODO rather than a silent landmine. The step comment records what unblocks a release: re-tag the submodules with the corrected module paths, bump the root requires, then drop the replace blocks.
Regenerate the SDK reference docs. The previous pass only substituted URLs over the pre-existing generated files, leaving stale signatures (Repo.Timeline was still documented as taking LogOpts rather than TimelineOpts). Note that gomarkdoc must be run outside a git worktree — inside one it silently strips every source link.
Also reword the README rename note, which read as though the import path had not changed, and re-sort the ncruces require block. (user: [email protected], size: 4107) [annotate] [blame] [check-ins using]
package verify import ( "fmt" "github.com/danmestas/go-libfossil/db" "github.com/danmestas/go-libfossil/internal/blob" "github.com/danmestas/go-libfossil/internal/content" "github.com/danmestas/go-libfossil/internal/deck" libfossil "github.com/danmestas/go-libfossil/internal/fsltype" "github.com/danmestas/go-libfossil/internal/repo" "github.com/danmestas/go-libfossil/internal/tag" ) // rebuildTags reconstructs tagxref rows from inline T-cards in checkin // manifests and from control artifacts. It runs inside the single rebuild // transaction, so it uses tag.ApplyTagWithTx to avoid nested transactions. // // Precondition: rebuildManifests has already populated event/plink/mlink/filename. // The plink graph must exist before tag propagation can walk descendants. func rebuildTags(_ *repo.Repo, tx *db.Tx, report *Report) error { if tx == nil { panic("rebuildTags: nil *db.Tx") } if report == nil { panic("rebuildTags: nil *Report") } entries, err := collectBlobEntries(tx) if err != nil { return err } // Pass 1: process checkin manifests (inline T-cards where UUID == "*"). for _, e := range entries { data, err := content.Expand(tx, e.rid) if err != nil { continue // already counted in BlobsSkipped by rebuildManifests } d, err := deck.Parse(data) if err != nil { continue } if d.Type != deck.Checkin { continue } if err := rebuildInlineTags(tx, e.rid, d); err != nil { return fmt.Errorf("rebuildTags inline rid=%d: %w", e.rid, err) } } // Pass 2: process control artifacts (T-cards with explicit target UUID). for _, e := range entries { data, err := content.Expand(tx, e.rid) if err != nil { continue // already counted in BlobsSkipped by rebuildManifests } d, err := deck.Parse(data) if err != nil { continue } if d.Type != deck.Control { continue } if err := rebuildControlTags(tx, e.rid, d); err != nil { return fmt.Errorf("rebuildTags control rid=%d: %w", e.rid, err) } } return nil } // rebuildInlineTags processes inline T-cards (UUID == "*") from a checkin manifest. func rebuildInlineTags(tx *db.Tx, rid libfossil.FslID, d *deck.Deck) error { if tx == nil { panic("rebuildInlineTags: nil *db.Tx") } if d == nil { panic("rebuildInlineTags: nil *deck.Deck") } mtime := libfossil.TimeToJulian(d.D) for _, tc := range d.T { if tc.UUID != "*" { continue } tagType, ok := mapDeckTagType(tc.Type) if !ok { continue } if err := tag.ApplyTagWithTx(tx, tag.ApplyOpts{ TargetRID: rid, SrcRID: rid, // inline: checkin is its own source TagName: tc.Name, TagType: tagType, Value: tc.Value, MTime: mtime, }); err != nil { return fmt.Errorf("inline tag %q: %w", tc.Name, err) } } return nil } // rebuildControlTags processes T-cards from a control artifact. func rebuildControlTags(tx *db.Tx, srcRID libfossil.FslID, d *deck.Deck) error { if tx == nil { panic("rebuildControlTags: nil *db.Tx") } if d == nil { panic("rebuildControlTags: nil *deck.Deck") } mtime := libfossil.TimeToJulian(d.D) for _, tc := range d.T { if tc.UUID == "*" { continue // self-referencing — handled by rebuildInlineTags } targetRID, ok := blob.Exists(tx, tc.UUID) if !ok { continue // target not found — phantom or not yet received } tagType, ok := mapDeckTagType(tc.Type) if !ok { continue } if err := tag.ApplyTagWithTx(tx, tag.ApplyOpts{ TargetRID: targetRID, SrcRID: srcRID, TagName: tc.Name, TagType: tagType, Value: tc.Value, MTime: mtime, }); err != nil { return fmt.Errorf("control tag %q on rid=%d: %w", tc.Name, targetRID, err) } } return nil } // mapDeckTagType converts a deck.TagType to a tag package constant. // Returns (tagType, true) on success, (0, false) for unrecognized types. func mapDeckTagType(dt deck.TagType) (int, bool) { switch dt { case deck.TagPropagating: return tag.TagPropagating, true case deck.TagSingleton: return tag.TagSingleton, true case deck.TagCancel: return tag.TagCancel, true default: return 0, false } }