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
14 changes: 14 additions & 0 deletions submitqueue/extension/conflict/tango/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = [
"mock_store.go",
"store.go",
"target_label.go",
"target_signature.go",
],
importpath = "github.com/uber/submitqueue/submitqueue/extension/conflict/tango",
visibility = ["//visibility:public"],
deps = ["@org_uber_go_mock//gomock:go_default_library"],
)
205 changes: 205 additions & 0 deletions submitqueue/extension/conflict/tango/mock_store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 60 additions & 0 deletions submitqueue/extension/conflict/tango/store.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package tango

//go:generate mockgen -source=store.go -destination=mock_store.go -package=tango

import "context"

// SignatureReader reads the target signature of a batch. It is the read-only
// view of SignatureStore for consumers that must not write.
type SignatureReader interface {
// Get returns the signature of batchID in the bound queue. The bool is
// false when no signature has been created for the batch.
Get(ctx context.Context, batchID string) (TargetSignature, bool, error)
}

// SignatureStore persists target signatures. A signature is immutable: it is
// created once under (Queue, BatchID) and never updated. Reads and writes are
// per-batch point operations, so any backend can implement it.
type SignatureStore interface {
SignatureReader

// Create persists signature in one write. Returns an already-exists error
// if the bound queue already holds a signature for signature.BatchID, so the
// first signature written stays and the caller can read it back with Get.
Create(ctx context.Context, signature TargetSignature) error
}

// DictionaryReader reads the label recorded for a target ID. It is the
// read-only view of DictionaryStore.
type DictionaryReader interface {
// Get returns the label recorded for id in the bound queue. The bool is
// false when none has been recorded.
Get(ctx context.Context, id uint64) (TargetLabel, bool, error)
}

// DictionaryStore persists the target dictionary: one TargetLabel for each
// 64-bit target ID. A record is immutable: it is created once under
// (Queue, ID) and never updated. Two labels can share an ID, so the first label
// recorded stays and the caller can read it back with Get to detect a collision.
type DictionaryStore interface {
DictionaryReader

// Create persists label in one write. Returns an already-exists error if
// the bound queue holds a label for label.ID, whether or not it is the same
// label, so repeating a write is harmless.
Create(ctx context.Context, label TargetLabel) error
}
33 changes: 33 additions & 0 deletions submitqueue/extension/conflict/tango/target_label.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package tango

// TargetLabel is one build target label and the 64-bit ID it hashes to. The
// whole record is immutable: (Queue, ID) is its identity and there is no update
// path. Two labels can share an ID on a hash collision; the first one recorded
// stays.
type TargetLabel struct {
// Queue is the queue the label was seen in. Unique together with ID.
Queue string

// ID is the 64-bit hash of Label.
ID uint64

// Label is the target label exactly as the build graph reported it.
Label string

// CreatedAt is the Unix milliseconds timestamp when the record was created.
CreatedAt int64
Comment thread
manjari25 marked this conversation as resolved.
}
45 changes: 45 additions & 0 deletions submitqueue/extension/conflict/tango/target_signature.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Copyright (c) 2026 Uber Technologies, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package tango

// TargetSignature is the set of build targets a batch changes, as 64-bit IDs.
// The whole record is immutable: (Queue, BatchID) is its identity and there is
// no update path.
type TargetSignature struct {
// Queue is the queue the batch belongs to. Unique together with BatchID.
Queue string

// BatchID is the canonical decimal batch identifier, unique within Queue.
BatchID string

// BaseRevision is the commit SHA the changed targets were computed against.
BaseRevision string

// Targets is sorted ascending by ID, with no duplicate IDs.
Targets []SignatureTarget

// CreatedAt is the Unix milliseconds timestamp when the record was created.
CreatedAt int64
Comment thread
manjari25 marked this conversation as resolved.
}

// SignatureTarget is one changed build target in a TargetSignature.
type SignatureTarget struct {
// ID is the 64-bit hash of the target's label.
ID uint64

// Distance is the distance from the nearest directly changed source in the
// reverse dependency graph; 0 means directly changed.
Distance int32
}
Loading