Skip to content

feat(entity): speculation path and run entities - #444

Open
behinddwalls wants to merge 1 commit into
mainfrom
preetam/speculation-entities
Open

feat(entity): speculation path and run entities#444
behinddwalls wants to merge 1 commit into
mainfrom
preetam/speculation-entities

Conversation

@behinddwalls

@behinddwalls behinddwalls commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

Summary

Why?

Queue-scoped speculation (#413) needs a shared vocabulary before the extension, generator, allocator, and controller can be built against it. Landing it on its own keeps it reviewable and gives the rest of the stack a fixed base.

What?

Adds the speculation domain model in submitqueue/entity/speculation.go.

Stored:

  • SpeculationPath — a head batch plus one bet per dependency, in queue order. ID() hashes the head and its ordered bets, so identical paths share an ID.
  • DependencyBet / DependencyBetTypeincluded, excluded, or dropped (ignored by conflict relaxation).
  • SpeculationPathStatuspending, building, passed, failed, cancelling, cancelled. IsTerminal() excludes cancelling: a build being cancelled may still reach passed or failed.
  • SpeculationPathEntry — keyed by the content hash. No build reference, no score: an execution is (ID, Attempt), and a score only means something within one run.
  • SpeculationPathSet — one head's paths under a single version, live and recently finished.

Transient, never stored: PathAction (build or cancel only — a verdict is a controller fact, not a proposal), Speculation, CandidatePath.

The three stored types round-trip through ToBytes/FromBytes. Enums are string-valued with "" sentinels. No storage and no wiring.

Test Plan

bazel test //submitqueue/entity/...

Table tests cover ID() determinism and its sensitivity to head, dependency, bet, and bet order; IsTerminal() across every status; and JSON round-trips plus invalid and empty input for each FromBytes.

Stack

  1. @ feat(entity): speculation path and run entities #444
  2. feat(speculation): speculator extension contract #445
  3. feat(speculation): generator contract and bestfirst impl #446
  4. feat(speculation): allocator contract and sticky impl #450

Add the speculation domain model in submitqueue/entity/speculation.go: SpeculationPath (keyed by a content hash), DependencyBet/DependencyBetType, SpeculationPathStatus, SpeculationPathEntry, and SpeculationPathSet, plus the run vocabulary PathAction/Speculation/CandidatePath. Enums are iota-based and every type round-trips through ToBytes/FromBytes; covered by table tests.

No storage and no wiring — these are the entities the speculation extension and controller build on.
@behinddwalls
behinddwalls marked this pull request as ready for review July 27, 2026 17:36
@behinddwalls
behinddwalls requested review from a team and sbalabanov as code owners July 27, 2026 17:36
@behinddwalls
behinddwalls force-pushed the preetam/speculation-entities branch from 4c78ae2 to e178f70 Compare July 27, 2026 18:02
@behinddwalls
behinddwalls marked this pull request as draft July 27, 2026 18:05
@behinddwalls
behinddwalls marked this pull request as ready for review July 27, 2026 19:00
@behinddwalls
behinddwalls marked this pull request as draft July 27, 2026 20:45
@behinddwalls
behinddwalls marked this pull request as ready for review July 27, 2026 23:17
@behinddwalls
behinddwalls force-pushed the preetam/speculation-entities branch from e178f70 to f905059 Compare July 27, 2026 23:18
// full meaning can be read without consulting any external relaxed set or
// dependency list.
type SpeculationPath struct {
// Head is the batch being built along this path.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wording should say "batch id" ? May be even field name.

// and its bets in order. Two paths with the same head and the same ordered
// bets share an ID; any difference in head, dependency, or bet yields a
// different ID.
func (p SpeculationPath) ID() string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be GetID() to indicate that the operation is always computational and there is no cache?

// is meaningful only within a single speculation run).
type SpeculationPathEntry struct {
// ID is the primary key: the hash of the path's content (head plus its
// bets). It equals Path.ID().

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a reason to duplicate from path.ID?

UpdatedAtMs int64
}

// ToBytes serializes the SpeculationPathEntry to JSON bytes for queue message payload.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it ever transmitted over queue? what serialization is for? May be add it when needed?

// dependency list.
type SpeculationPathSet struct {
// BatchID is the primary key: the head batch these paths speculate on.
BatchID string

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to name is consistently with SpeculationPath - "Head" ? or at least the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants