Artifact 88ba346907e0b67cdef87bae8fddbe0b30cbc70d3ab924432b827c224c6d23ee:
- File
repo_submanifest.go
— part of check-in
[14f17e675e]
at
2026-10-18 16:44:14
on branch feat/submanifest-reader
— feat(manifest): write tree check-ins behind enable-submanifests
Checkin now honours draft-fossil-submanifests-00 §8.1: with enable-submanifests on and a pinned submanifest-k it stores the canonical tree first, marks each sub-manifest unsent, records the seen-submanifest indicator that arms the §7.2 gate, and writes a manifest of S cards with no F card and never a B card. The setting is off by default, so every commit is byte-identical to before. A stored k outside 1..12 falls back to a flat manifest and logs it (§6.3); unchanged sub-manifests are shared by content addressing.
EnableSubmanifests is §8.1's local request: a valid pin wins and a different explicit k is refused as a re-tune; with no valid pin an explicit k is pinned, or §6.3's selection runs over the current check-in; a request that cannot be met changes neither setting. RetuneSubmanifests is the manual §6.4 re-tune. After a tree commit the §6.4 gate re-pins k while submanifest-auto-retune is on, and only advises otherwise.
A sync run reports avoid-submanifests in SyncResult, and CheckinOpts.AvoidSubmanifests keeps a commit made in that sync flat (§7.2). The settings' names and parsers move to internal/manifest, which sync now uses. Repo.EnableSubmanifests and Repo.RetuneSubmanifests expose the two requests, the first returning the operator warning. A test shows fossil 2.28 never receives a tree this writer made. (user: [email protected], size: 1628) [annotate] [blame] [check-ins using]
package libfossil import ( "fmt" fsltype "github.com/danmestas/go-libfossil/internal/fsltype" "github.com/danmestas/go-libfossil/internal/manifest" ) // EnableSubmanifests turns on tree manifest emission // (draft-fossil-submanifests-00 §8.1): from the next commit, check-ins carry // their file sets as sub-manifest trees. A pinned partition parameter is kept, // and an explicit k (1 to 12) that differs from it is refused, since // changing it is a re-tune. With no pin, k is pinned as given, or, when k is // 0, selected over the file set of current, the check-in the next commit // descends from (0 for none); a set no k partitions is refused. A refused // request changes nothing. It returns the pinned k and the warning the // operator must be shown: trees cannot be retired, and peers older than // Fossil 2.29 are refused them. func (r *Repo) EnableSubmanifests(current int64, k int) (pinned int, warning string, err error) { pinned, err = manifest.EnableSubmanifests(r.inner, fsltype.FslID(current), k) if err != nil { return 0, "", fmt.Errorf("libfossil: enable sub-manifests: %w", err) } return pinned, manifest.SubmanifestEnableWarning, nil } // RetuneSubmanifests pins a new partition parameter k, 1 to 12, for the // commits that follow (draft-fossil-submanifests-00 §6.4). Existing // check-ins are unchanged; the next tree shares only the sub-manifests whose // bytes are the same under both values. func (r *Repo) RetuneSubmanifests(k int) error { if err := manifest.RetuneSubmanifests(r.inner, k); err != nil { return fmt.Errorf("libfossil: re-tune sub-manifests: %w", err) } return nil }