Artifact 7cf919c774cb6d84c55b6e4805416e791f82ab41df0707255b7dd5e542dfe041:
- File
internal/manifest/dephantomize.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: 3510) [annotate] [blame] [check-ins using]
package manifest import ( "fmt" "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" ) // AfterDephantomize crosslinks a formerly-phantom blob and any dependents. // Matches Fossil's after_dephantomize (content.c:389-456). func AfterDephantomize(r *repo.Repo, rid libfossil.FslID) { if r == nil { panic("manifest.AfterDephantomize: r must not be nil") } if rid <= 0 { return } afterDephantomize(r, rid, true) } func afterDephantomize(r *repo.Repo, rid libfossil.FslID, linkFlag bool) { // Work stack replaces recursion. Bounded by total blob count in repo. type workItem struct { rid libfossil.FslID linkFlag bool } stack := []workItem{{rid: rid, linkFlag: linkFlag}} const maxIterations = 1_000_000 // Guard against pathological delta chains. iterations := 0 for len(stack) > 0 { iterations++ if iterations > maxIterations { return // Safety bound exceeded. } // Pop from stack. item := stack[len(stack)-1] stack = stack[:len(stack)-1] current := item.rid if current <= 0 { continue } if item.linkFlag { _ = crosslinkSingle(r, current) } // Process orphaned delta manifests whose baseline is this rid. orphanRows, err := r.DB().Query("SELECT rid FROM orphan WHERE baseline=?", current) if err == nil { var orphans []libfossil.FslID for orphanRows.Next() { var orid int64 if orphanRows.Scan(&orid) == nil { orphans = append(orphans, libfossil.FslID(orid)) } } orphanRows.Close() for _, orid := range orphans { _ = crosslinkSingle(r, orid) } if len(orphans) > 0 { if _, err := r.DB().Exec("DELETE FROM orphan WHERE baseline=?", current); err != nil { continue } } } // Find delta children not yet crosslinked. childRows, err := r.DB().Query( `SELECT rid FROM delta WHERE srcid=? AND NOT EXISTS (SELECT 1 FROM mlink WHERE mid=delta.rid)`, current) if err != nil { continue } var children []libfossil.FslID for childRows.Next() { var crid int64 if childRows.Scan(&crid) == nil { children = append(children, libfossil.FslID(crid)) } } childRows.Close() // Push all children onto work stack (reverse order for LIFO processing). for i := len(children) - 1; i >= 0; i-- { stack = append(stack, workItem{rid: children[i], linkFlag: true}) } } } // crosslinkSingle crosslinks a single blob by rid. func crosslinkSingle(r *repo.Repo, rid libfossil.FslID) error { if r == nil { panic("crosslinkSingle: r must not be nil") } if rid <= 0 { panic("crosslinkSingle: rid must be positive") } data, err := content.Expand(r.DB(), rid) if err != nil { return fmt.Errorf("crosslinkSingle expand rid=%d: %w", rid, err) } d, err := deck.Parse(data) if err != nil { return fmt.Errorf("crosslinkSingle parse rid=%d: %w", rid, err) } switch d.Type { case deck.Checkin: return crosslinkCheckin(r, rid, d) case deck.Wiki: _, err = crosslinkWiki(r, rid, d) return err case deck.Ticket: _, err = crosslinkTicket(r, rid, d) return err case deck.Event: _, err = crosslinkEvent(r, rid, d) return err case deck.Attachment: return crosslinkAttachment(r, rid, d) case deck.Cluster: return CrosslinkCluster(r.DB(), rid, d) case deck.ForumPost: return crosslinkForum(r, rid, d) case deck.Control: return crosslinkControl(r, rid, d) } return nil }