feat(entity): speculation path and run entities - #444
Draft
behinddwalls wants to merge 1 commit into
Draft
Conversation
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
marked this pull request as ready for review
July 27, 2026 17:36
behinddwalls
force-pushed
the
preetam/speculation-entities
branch
from
July 27, 2026 18:02
4c78ae2 to
e178f70
Compare
behinddwalls
marked this pull request as draft
July 27, 2026 18:05
behinddwalls
marked this pull request as ready for review
July 27, 2026 19:00
behinddwalls
marked this pull request as draft
July 27, 2026 20:45
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Why?
Queue-scoped speculation (#413) needs a shared vocabulary before any of its moving parts can be built: the speculator extension, its generator/allocator collaborators, and the controller that drives them all have to agree on what a speculative path is, how one is identified, and what states it can be in. Landing that vocabulary on its own keeps the contract reviewable in isolation and gives the follow-up branches in the stack a stable base to build against.
What?
Adds the speculation domain model in
submitqueue/entity/speculation.go.The stored model:
SpeculationPath— one guess at how a batch's dependencies resolve: a head batch plus one bet per dependency, in queue order. Every dependency appears exactly once, so a path is self-describing and can be read without consulting an external relaxed set or dependency list.ID()is a hex SHA-256 over the head and its ordered bets, so identical paths share an ID and any difference in head, dependency, or bet yields a different one.DependencyBet/DependencyBetType— how a path treats one dependency:included(bets it lands),excluded(bets it does not), ordropped(ignored by conflict relaxation, so its outcome never invalidates the path).SpeculationPathStatus— the lifecycle of a path's current build attempt:pending,building,passed,failed,cancelling,cancelled.IsTerminal()deliberately excludescancelling, which is a non-terminal intent — a build being cancelled may still reachpassedorfailedfirst.SpeculationPathEntry— the stored record for a chosen path, keyed by the content hash. It carries no build reference and no score: an execution is identified by(ID, Attempt), and a score is only meaningful within a single run.SpeculationPathSet— one head's chosen paths under a single version, holding both live and recently finished entries so a re-run cannot collide with an old build.The run vocabulary, transient and never stored:
PathAction—buildorcancel. There is deliberately no merge or fail action; a batch's verdict is a controller-owned fact, not a proposed one.Speculation— one proposed action on one path.CandidatePath— a path paired with the ranking score assigned within a single run.The three stored types round-trip through
ToBytes/FromBytes(JSON), so they are storage- and queue-ready without pulling in a storage dependency. Enums are string-valued with""sentinels, per the entity convention inCLAUDE.md.No storage and no wiring — these are purely the entities the speculation extension and controller build on in the rest of the stack.
Test Plan
✅
bazel test //submitqueue/entity/...— passes.speculation_test.goadds table tests covering:ID()determinism, and its sensitivity to head, dependency, bet, and bet order.IsTerminal()across every status, including thecancellingexclusion.SpeculationPathEntry.IDderiving fromPath.ID().FromBytes.No behavioral surface yet: nothing constructs or reads these entities on this branch, so there is nothing to exercise beyond the unit tests.
Issues