From f98b3988a3da70dc876367970e024f1f65667ac0 Mon Sep 17 00:00:00 2001 From: manjari Date: Tue, 24 Feb 2026 00:27:01 +0000 Subject: [PATCH 1/4] feat(entities) Adds build entity and sql schema --- entity/build.go | 36 ++++++++++++++++++++++++ extension/storage/mysql/schema/build.sql | 8 ++++++ 2 files changed, 44 insertions(+) create mode 100644 entity/build.go create mode 100644 extension/storage/mysql/schema/build.sql diff --git a/entity/build.go b/entity/build.go new file mode 100644 index 00000000..19736432 --- /dev/null +++ b/entity/build.go @@ -0,0 +1,36 @@ +package entity + +// BuildStatus defines the possible states of a build. +type BuildStatus string + +const ( + // BuildStateUnknown is the unreachable state. It is set by default when the structure is initialized. It should never be seen in the system. + BuildStateUnknown BuildStatus = "" + // TODO: Add comprehensive list of known build states. +) + +// SpeculationPathInfo represents the base and head commits of a speculation path used in a build. +type SpeculationPathInfo struct { + // Base represents the base state of this speculation path. + Base string + // Head represents the head commit of this speculation path. + Head string +} + +// Build represents a build scheduled for a batch along a specific speculation path. +// All fields except the Status are immutable after creation. +type Build struct { + // ID represents the build ID. It is the responsibility of the caller to ensure + // this is unique. + ID string + // BatchID is the batch for which this build is scheduled. + BatchID string + // SpeculationPath is the speculation path that represents this build. For + // a given batch this path is crafted from the graph that is generated from the + // dependencies of this batch. + SpeculationPath SpeculationPathInfo + // Score represents the build prediction score for this speculation path. + Score float32 + // Status represents the state of the build lifecycle this build is in. + Status BuildStatus +} diff --git a/extension/storage/mysql/schema/build.sql b/extension/storage/mysql/schema/build.sql new file mode 100644 index 00000000..93bc5744 --- /dev/null +++ b/extension/storage/mysql/schema/build.sql @@ -0,0 +1,8 @@ +CREATE TABLE IF NOT EXISTS build ( + id VARCHAR(255) NOT NULL, + batch_id VARCHAR(255) NOT NULL, + speculation_path JSON NOT NULL, + score FLOAT NOT NULL, + status VARCHAR(64) NOT NULL, + PRIMARY KEY (id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; From 6c33a38ad5791e041bbfe9846787261323f96682 Mon Sep 17 00:00:00 2001 From: manjari Date: Tue, 24 Feb 2026 01:25:26 +0000 Subject: [PATCH 2/4] update base type to be list of strings --- entity/build.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/entity/build.go b/entity/build.go index 19736432..806481e6 100644 --- a/entity/build.go +++ b/entity/build.go @@ -11,8 +11,8 @@ const ( // SpeculationPathInfo represents the base and head commits of a speculation path used in a build. type SpeculationPathInfo struct { - // Base represents the base state of this speculation path. - Base string + // Base is a list of batchIDs(in order) that form the base of this speculation path. + Base []string // Head represents the head commit of this speculation path. Head string } From a59f0b9ffdef23f4b7d2c430d0131267ff48df68 Mon Sep 17 00:00:00 2001 From: manjari Date: Tue, 24 Feb 2026 02:49:16 +0000 Subject: [PATCH 3/4] gazelle --- entity/BUILD.bazel | 1 + 1 file changed, 1 insertion(+) diff --git a/entity/BUILD.bazel b/entity/BUILD.bazel index 616ea5c2..0a562dbb 100644 --- a/entity/BUILD.bazel +++ b/entity/BUILD.bazel @@ -5,6 +5,7 @@ go_library( srcs = [ "batch.go", "batch_dependent.go", + "build.go", "change_provider.go", "request.go", ], From 27f6ad08d2d21f228dcb45cfd442f0e4152aabb1 Mon Sep 17 00:00:00 2001 From: manjari Date: Tue, 24 Feb 2026 20:04:31 +0000 Subject: [PATCH 4/4] address comments --- entity/build.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/entity/build.go b/entity/build.go index 806481e6..26d23754 100644 --- a/entity/build.go +++ b/entity/build.go @@ -13,15 +13,13 @@ const ( type SpeculationPathInfo struct { // Base is a list of batchIDs(in order) that form the base of this speculation path. Base []string - // Head represents the head commit of this speculation path. - Head string } // Build represents a build scheduled for a batch along a specific speculation path. // All fields except the Status are immutable after creation. type Build struct { - // ID represents the build ID. It is the responsibility of the caller to ensure - // this is unique. + // ID represents the build ID. It is the responsibility of a build management system to ensure + // that this is unique. ID string // BatchID is the batch for which this build is scheduled. BatchID string