I9: register, watch and the seed read no branch's protection
The forge's branch protection is no longer a condition of the mesh: register and watch refuse only a reserved branch name, and the seed leaves out no module for its default branch's protection and reads none. The module compiles again only once C0 to C3's removals are all followed (H-A-66's callers, I7's manifest events, the gate's pin events, the entry's pull); its unit suite runs green from that commit on. Builds: design 47 H §763 (G §5), §764 (the branch protection) Claude-Session: https://claude.ai/code/session_01JG73KHUnBze48rdua8u2sy
This commit is contained in:
@@ -224,26 +224,15 @@ func reviewRequired(s meshcatalog.StepStatuses) bool {
|
||||
return s.Review == meshcatalog.StepStatusesApprovalRequired
|
||||
}
|
||||
|
||||
// protect refuses a watched branch that is named as the catalog's keys are (reason `reserved branch name`, §704) or that
|
||||
// the forge does not protect (reason `unprotected branch`, §5), naming it; both empty when every branch is accepted.
|
||||
func (r *Registry) protect(repository string, branches []string) (reason, words string, err error) {
|
||||
// reserved refuses a watched branch that is named as the catalog's keys are (reason `reserved branch name`, §704), naming
|
||||
// it; both empty when every branch is accepted. No branch's protection is read (design 47 H §763 corrects G §5).
|
||||
func reserved(branches []string) (reason, words string) {
|
||||
for _, b := range branches {
|
||||
if w := forbiddenBranch(b); w != "" {
|
||||
return meshcatalog.RegistrationAskedRefusedReservedBranchName, w, nil
|
||||
}
|
||||
a, err := r.Branch(repository, b)
|
||||
if err != nil {
|
||||
return "", "", fmt.Errorf("the seat git does not answer for %s %s: %w", repository, b, err)
|
||||
}
|
||||
if a.Error != "" {
|
||||
return "", "", fmt.Errorf("the seat git cannot read %s %s: %s", repository, b, a.Error)
|
||||
}
|
||||
if !a.Protected {
|
||||
return meshcatalog.RegistrationAskedRefusedUnprotectedBranch,
|
||||
fmt.Sprintf("the branch %s of %s is not protected: no rule refuses a direct push and admits only merges", b, repository), nil
|
||||
return meshcatalog.RegistrationAskedRefusedReservedBranchName, w
|
||||
}
|
||||
}
|
||||
return "", "", nil
|
||||
return "", ""
|
||||
}
|
||||
|
||||
// stepLines names each step status a policy moves, one line each.
|
||||
@@ -491,11 +480,7 @@ func (r *Registry) Propose(ctx context.Context, verb, caller string, change json
|
||||
branches = []string{branch}
|
||||
}
|
||||
if len(branches) > 0 {
|
||||
reason, words, err := r.protect(next.Origin, branches)
|
||||
if err != nil {
|
||||
return meshcatalog.RegistrationAsked{}, err
|
||||
}
|
||||
if reason != "" {
|
||||
if reason, words := reserved(branches); reason != "" {
|
||||
return refused(module, reason, words), nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ type regRig struct {
|
||||
history []meshcatalog.Registration
|
||||
events []meshcatalog.RegistrationChangedEvent
|
||||
now time.Time
|
||||
unprotect map[string]bool
|
||||
whereErr error
|
||||
chosen map[string]string // ask id -> option the router's record holds
|
||||
missing map[string]bool
|
||||
@@ -31,7 +30,7 @@ type regRig struct {
|
||||
}
|
||||
|
||||
func newRegRig() *regRig {
|
||||
g := ®Rig{asks: map[string]oc.Ask{}, now: time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC), unprotect: map[string]bool{}, chosen: map[string]string{}, missing: map[string]bool{}}
|
||||
g := ®Rig{asks: map[string]oc.Ask{}, now: time.Date(2026, 11, 11, 12, 0, 0, 0, time.UTC), chosen: map[string]string{}, missing: map[string]bool{}}
|
||||
g.r = &Registry{Module: testSelf, Registrations: MemoryStore(), Proposals: MemoryStore(),
|
||||
History: func(_ context.Context, r meshcatalog.Registration) error {
|
||||
g.history = append(g.history, r)
|
||||
@@ -45,7 +44,7 @@ func newRegRig() *regRig {
|
||||
if branch == "" {
|
||||
branch = "main"
|
||||
}
|
||||
return gitseat.BranchAnswer{Branch: branch, Repository: repo, Protected: !g.unprotect[branch]}, nil
|
||||
return gitseat.BranchAnswer{Branch: branch, Repository: repo}, nil
|
||||
},
|
||||
Placement: func(module string) ([]mma.ModulePlacement, error) { return g.placed[module], nil },
|
||||
Ask: func(a oc.Ask) error { g.asks[a.ID] = a; return nil },
|
||||
@@ -96,14 +95,12 @@ func pol(module string, s meshcatalog.StepStatuses) json.RawMessage {
|
||||
func TestRegistrationsAreWrittenOnTheirWarrantOnly(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
g := newRegRig()
|
||||
// Refusals raise no ask: a code review that is required (§3), a branch named candidate or entry (§343), an unprotected branch (§5).
|
||||
g.unprotect["beta"] = true
|
||||
// Refusals raise no ask: a code review that is required (§3), a branch named candidate or entry (§343).
|
||||
for _, c := range []struct {
|
||||
name, why string
|
||||
change json.RawMessage
|
||||
}{
|
||||
{"review", meshcatalog.RegistrationAskedRefusedReviewRequired, reg("a", meshcatalog.StepStatuses{Review: "required"}, "main")},
|
||||
{"unprotected", meshcatalog.RegistrationAskedRefusedUnprotectedBranch, reg("a", meshcatalog.StepStatuses{}, "beta")},
|
||||
{"candidate", meshcatalog.RegistrationAskedRefusedReservedBranchName, reg("a", meshcatalog.StepStatuses{}, "candidate")},
|
||||
{"entry", meshcatalog.RegistrationAskedRefusedReservedBranchName, reg("a", meshcatalog.StepStatuses{}, "entry")},
|
||||
} {
|
||||
@@ -171,13 +168,11 @@ func TestRegistrationsAreWrittenOnTheirWarrantOnly(t *testing.T) {
|
||||
if now, _, _ := g.r.Registration(ctx, "a"); now.Version != 2 || now.Policy.Steps.Unit != "optional" {
|
||||
t.Fatalf("the second change: %+v", now)
|
||||
}
|
||||
// watch adds a branch only when protected; unwatch removes it; each on its warrant.
|
||||
// watch adds a branch, its protection never read (I9/AC1, design 47 H §763 corrects G §5); unwatch removes it; each on its warrant.
|
||||
w, _ := g.r.Propose(ctx, "watch", "s@n", mustJSON(meshcatalog.WatchInput{Module: "a", Branch: "beta"}))
|
||||
if w.Refused != meshcatalog.RegistrationAskedRefusedUnprotectedBranch {
|
||||
t.Fatalf("watch of an unprotected branch: %+v", w)
|
||||
if w.Refused != "" || w.Ask == "" {
|
||||
t.Fatalf("watch of a branch: %+v; want an ask, no refusal", w)
|
||||
}
|
||||
delete(g.unprotect, "beta")
|
||||
w, _ = g.r.Propose(ctx, "watch", "s@n", mustJSON(meshcatalog.WatchInput{Module: "a", Branch: "beta"}))
|
||||
g.decide(t, w.Ask, "approve")
|
||||
// A branch a placement names is not unwatched: refused as placed, naming the placement, and no ask is raised (§704, A-62).
|
||||
g.placed = map[string][]mma.ModulePlacement{"a": {{Branch: "beta", Nodes: []string{"n1", "n2"}}}}
|
||||
@@ -239,7 +234,6 @@ func TestProposalsSurviveARestartAndAreDropped(t *testing.T) {
|
||||
func TestSeedWritesTheModuleGraphWithNoAskAndWaitsForEveryBuildSeat(t *testing.T) {
|
||||
ctx := context.Background()
|
||||
g := newRegRig()
|
||||
g.unprotect["main"] = false
|
||||
mods := []SeedModule{{Module: "a", Origin: "novox/a", Path: "module.json", Artifacts: []SeedArtifact{{Name: "program", Seat: "node-build-go", Answered: false}}}}
|
||||
if _, err := g.r.ProposeSeed(ctx, mods, false, "indexer"); err == nil || !strings.Contains(err.Error(), "node-build-go") {
|
||||
t.Fatalf("an unanswered build seat did not hold the seed: %v", err)
|
||||
@@ -260,12 +254,19 @@ func TestSeedWritesTheModuleGraphWithNoAskAndWaitsForEveryBuildSeat(t *testing.T
|
||||
if _, err := g.r.ProposeSeed(ctx, mods, true, "s@n"); err == nil {
|
||||
t.Fatal("the seed wrote over registrations the indexer holds")
|
||||
}
|
||||
// An unprotected default branch is left out and named.
|
||||
// The seed leaves out no module for its branch's protection, and reads none (I9/AC2, design 47 H §764).
|
||||
g2 := newRegRig()
|
||||
g2.unprotect["main"] = true
|
||||
reads := 0
|
||||
branch := g2.r.Branch
|
||||
g2.r.Branch = func(repo, b string) (gitseat.BranchAnswer, error) {
|
||||
if b != "" {
|
||||
reads++
|
||||
}
|
||||
return branch(repo, b)
|
||||
}
|
||||
seed, err := g2.r.ComposeSeed(mods)
|
||||
if err != nil || len(seed.Registrations) != 0 || len(seed.Left) != 1 || !strings.Contains(seed.Left[0], "not protected") {
|
||||
t.Fatalf("seed with an unprotected default branch: %+v, %v", seed, err)
|
||||
if err != nil || len(seed.Registrations) != 1 || len(seed.Left) != 0 || reads != 0 {
|
||||
t.Fatalf("seed: %+v, %v, %d reads of a named branch; want one registration, none left out, no protection read", seed, err, reads)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ type SeedArtifact struct {
|
||||
}
|
||||
|
||||
// SeedProposal is the first registrations composed from what the indexer took in (§8): the registrations proposed, the
|
||||
// modules left out because their default branch is not protected, and the build seats still unanswered.
|
||||
// modules left out, and the build seats still unanswered.
|
||||
type SeedProposal struct {
|
||||
Registrations []meshcatalog.Registration
|
||||
Left []string
|
||||
@@ -44,9 +44,8 @@ type SeedProposal struct {
|
||||
// ComposeSeed proposes one registration for every module its trunk revision holds (§8): the origin and path of each, its
|
||||
// watched branch the repository's default branch read through the seat git, and the statuses the check judged until then:
|
||||
// lint, unit tests, integration tests and composition required, code review optional, approval bypass; each step an
|
||||
// artifact's build seat answers steps with none is bypass, so no module is held by a required step it has nothing for. A
|
||||
// module whose default branch the forge does not protect is left out and named. A build seat that has not answered holds
|
||||
// the seed.
|
||||
// artifact's build seat answers steps with none is bypass, so no module is held by a required step it has nothing for. No
|
||||
// branch's protection is read (design 47 H §764). A build seat that has not answered holds the seed.
|
||||
func (r *Registry) ComposeSeed(modules []SeedModule) (SeedProposal, error) {
|
||||
var out SeedProposal
|
||||
slices.SortFunc(modules, func(a, b SeedModule) int { return strings.Compare(a.Module, b.Module) })
|
||||
@@ -74,10 +73,6 @@ func (r *Registry) ComposeSeed(modules []SeedModule) (SeedProposal, error) {
|
||||
if b.Error != "" || b.Branch == "" {
|
||||
return out, fmt.Errorf("the default branch of %s is not read: %s", m.Origin, b.Error)
|
||||
}
|
||||
if p, err := r.Branch(m.Origin, b.Branch); err != nil || !p.Protected || p.Error != "" {
|
||||
out.Left = append(out.Left, fmt.Sprintf("%s (the branch %s of %s is not protected)", m.Module, b.Branch, m.Origin))
|
||||
continue
|
||||
}
|
||||
reg := meshcatalog.Registration{Module: m.Module, Origin: m.Origin, Path: m.Path, Branches: []string{b.Branch},
|
||||
Policy: meshcatalog.Policy{Steps: meshcatalog.StepStatuses{Lint: "required", Unit: "required", Integration: "required",
|
||||
Composition: "required", Review: "optional", Approval: "bypass"}}}
|
||||
|
||||
Reference in New Issue
Block a user