Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-16707.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- A DCO split cached while no `project.ai_author` was configured is no longer treated as computed with the hive identity, so configuring it later re-reads the commits for in-flight heads ([#16707](https://github.com/hivecommons/hive/issues/16707)).
2 changes: 1 addition & 1 deletion src/pkg/github/automerge/automerge_stage_labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -1190,7 +1190,7 @@ func (c *Engine) ApplyStageLabels(ctx context.Context) (StageLabelResult, error)
soakFirstGreen, _ := c.contributorSoak.FirstGreen(obs.Owner, obs.Repo, obs.Number, obs.HeadSHA)
noteSoak(store, key, obs.Reason, obs.HeadSHA, pass.Route, c.currentContributorLanePolicy().Soak, soakFirstGreen, now)
if dcoRead {
store.NoteDCO(key, obs.HeadSHA, obs.Detail.DCOTotal, obs.Detail.DCOUnsigned, obs.Detail.DCOUnsignedHive, obs.Detail.DCOSquashUnsafeHive)
store.NoteDCO(key, obs.HeadSHA, obs.Detail.DCOTotal, obs.Detail.DCOUnsigned, obs.Detail.DCOUnsignedHive, obs.Detail.DCOSquashUnsafeHive, policy.HiveAuthor != nil)
}
if verdict.Stage != stagelabels.ReturnedToContributor && verdict.Stage != stagelabels.NeedsAuthor {
c.resolveNudge(ctx, prevRec, hadPrev, obs)
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/github/automerge/automerge_stage_labels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2489,7 +2489,7 @@ func TestStageDCORereadsSplitCachedBeforeHiveIdentities(t *testing.T) {
if err != nil || got.unsigned != 1 || got.unsignedHive != 1 || got.unsignedOther != 0 || api.commitReads != 1 {
t.Fatalf("legacy split: %+v, %v, reads=%d; want hive=1 other=0 after one read", got, err, api.commitReads)
}
store.NoteDCO(key, obs.HeadSHA, got.total, got.unsigned, got.unsignedHive, got.squashUnsafeHive)
store.NoteDCO(key, obs.HeadSHA, got.total, got.unsigned, got.unsignedHive, got.squashUnsafeHive, true)
got, err = e.stageDCO(context.Background(), store, key, obs, policy)
if err != nil || got.unsignedHive != 1 || got.unsignedOther != 0 || api.commitReads != 1 {
t.Fatalf("refreshed split: %+v, %v, reads=%d; want the cache served", got, err, api.commitReads)
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/github/automerge/shared_ci_attribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestStageDCONormalizesCachedBotAttributionWithoutChangingSignoffs(t *testin
e, _, store := newStageEngine(t, srv.URL, &contributorLaneClock{at: time.Now()})
key := stageKey("acme", "widget", 42)
store.Observe(key, stagelabels.Fixing, stagelabels.LaneReasonHiveSignoffAttribution)
store.NoteDCO(key, "aaa", 3, 0, 0, 1)
store.NoteDCO(key, "aaa", 3, 0, 0, 1, true)
got, err := e.stageDCO(context.Background(), store, key, stageObservation{
Owner: "acme", Repo: "widget", Number: 42, HeadSHA: "aaa", Author: "dependabot[bot]",
}, StageLabelPolicy{})
Expand Down
24 changes: 20 additions & 4 deletions src/pkg/stagelabels/stagelabels_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -998,18 +998,18 @@ func TestStoreNoteDCOSplitAndAdoptReason(t *testing.T) {
now := time.Date(2026, 10, 16, 12, 0, 0, 0, time.UTC)
s := NewStore("", func() time.Time { return now })
key := Key("acme/widget", 7)
s.NoteDCO(key, "a", 3, 2, 1, 0)
s.NoteDCO(key, "a", 3, 2, 1, 0, true)
s.NoteAdoptReason(key, "dco-rehome")
if _, ok := s.Get(key); ok {
t.Fatal("NoteDCO/NoteAdoptReason created a record")
}
s.Observe(key, ReturnedToContributor, "check-failing:dco")
s.NoteDCO(key, "a", 3, 2, 1, 0)
s.NoteDCO(key, "a", 3, 2, 1, 0, true)
r, _ := s.Get(key)
if t0, u, ok := r.DCOFor("a"); !ok || t0 != 3 || u != 2 || r.DCOUnsignedHive != 1 || r.DCOUnsignedOther != 1 || !r.DCOSplitKnown("a") || r.DCOSplitKnown("b") {
t.Fatalf("cached split: %+v", r)
}
s.NoteDCO(key, "a", 3, 2, 2, 0)
s.NoteDCO(key, "a", 3, 2, 2, 0, true)
if r, _ = s.Get(key); r.DCOUnsignedHive != 2 || r.DCOUnsignedOther != 0 || !r.DCOSplitKnown("a") {
t.Fatalf("hive share not updated: %+v", r)
}
Expand All @@ -1033,12 +1033,28 @@ func TestStoreNoteDCOMarksHiveIdentitySplit(t *testing.T) {
s := NewStore("", nil)
key := Key("acme/widget", 8)
s.items[key] = Record{DCOHead: "a", DCOTotal: 2, DCOUnsigned: 1, DCOUnsignedOther: 1, DCOSquashUnsafeKnown: true}
s.NoteDCO(key, "a", 2, 1, 0, 0)
s.NoteDCO(key, "a", 2, 1, 0, 0, true)
if r, _ := s.Get(key); !r.DCOSplitHiveIdentity || r.DCOUnsignedOther != 1 {
t.Fatalf("legacy record not marked: %+v", r)
}
}

// hivecommons/hive#16707: an App-only split (no hive identity configured)
// must not be marked, so configuring one later triggers the re-read.
func TestStoreNoteDCOAppOnlySplitNotMarked(t *testing.T) {
s := NewStore("", nil)
key := Key("acme/widget", 9)
s.items[key] = Record{DCOHead: "a", DCOTotal: 2, DCOUnsigned: 1, DCOUnsignedOther: 1, DCOSquashUnsafeKnown: true}
s.NoteDCO(key, "a", 2, 1, 1, 0, false)
if r, _ := s.Get(key); r.DCOSplitHiveIdentity || r.DCOUnsignedHive != 1 {
t.Fatalf("app-only split marked or not stored: %+v", r)
}
s.NoteDCO(key, "a", 2, 1, 1, 0, true)
if r, _ := s.Get(key); !r.DCOSplitHiveIdentity {
t.Fatalf("hive-identity split not marked: %+v", r)
}
}

func TestStoreAdoptInPlaceAndYield(t *testing.T) {
now := time.Date(2026, 10, 16, 12, 0, 0, 0, time.UTC)
s := NewStore("", func() time.Time { return now })
Expand Down
12 changes: 8 additions & 4 deletions src/pkg/stagelabels/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2474,8 +2474,10 @@ func (s *Store) ClearHold(key string) { s.NoteHold(key, nil) }

// NoteDCO caches the commit check for head on an existing record:
// unsignedHive is the hive's share of the unsigned commits (App bot or a
// hive identity), the rest is recorded as other.
func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashUnsafeHive int) {
// hive identity), the rest is recorded as other. hiveIdentity says the split
// was computed with a hive identity configured; an App-only split leaves the
// marker unset so configuring one later triggers the one-time re-read.
func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashUnsafeHive int, hiveIdentity bool) {
if head == "" {
return
}
Expand All @@ -2485,12 +2487,14 @@ func (s *Store) NoteDCO(key, head string, total, unsigned, unsignedHive, squashU
s.mu.Lock()
defer s.mu.Unlock()
r, ok := s.items[key]
if !ok || (r.DCOHead == head && r.DCOTotal == total && r.DCOUnsigned == unsigned && r.DCOUnsignedHive == unsignedHive && r.DCOUnsignedOther == other && r.DCOSquashUnsafeHive == squashUnsafeHive && r.DCOSquashUnsafeKnown && r.DCOSplitHiveIdentity) {
if !ok || (r.DCOHead == head && r.DCOTotal == total && r.DCOUnsigned == unsigned && r.DCOUnsignedHive == unsignedHive && r.DCOUnsignedOther == other && r.DCOSquashUnsafeHive == squashUnsafeHive && r.DCOSquashUnsafeKnown && (r.DCOSplitHiveIdentity || !hiveIdentity)) {
return
}
r.DCOHead, r.DCOTotal, r.DCOUnsigned, r.DCOUnsignedHive, r.DCOUnsignedOther, r.DCOSquashUnsafeHive = head, total, unsigned, unsignedHive, other, squashUnsafeHive
r.DCOSquashUnsafeKnown = true
r.DCOSplitHiveIdentity = true
if hiveIdentity {
r.DCOSplitHiveIdentity = true
}
s.items[key] = r
s.dirty = true
}
Expand Down
Loading