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
30 changes: 15 additions & 15 deletions bazel/include/go.MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -24,42 +24,42 @@ single_version_override(
bazel_dep(name = "aspect_gazelle", version = "0.0.0")
archive_override(
module_name = "aspect_gazelle",
integrity = "sha256-XZUwwAH0/gyoW90PDDiZUxZaSuQcBQuvEe7PBaL0Eoc=",
strip_prefix = "aspect-gazelle-9c84884007d508c04a4b327cbf9c586a0c9d966c",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/9c84884007d508c04a4b327cbf9c586a0c9d966c.tar.gz"],
integrity = "sha256-Vi6jAIMt/3AxZsdLl0cTv9sNyYMK+iBK6b0lzDUJhdY=",
strip_prefix = "aspect-gazelle-75d3c1f7ae519e5a0a82e2b57a51280d029ac843",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/75d3c1f7ae519e5a0a82e2b57a51280d029ac843.tar.gz"],
)

bazel_dep(name = "aspect_gazelle_js", version = "0.0.0")
archive_override(
module_name = "aspect_gazelle_js",
integrity = "sha256-XZUwwAH0/gyoW90PDDiZUxZaSuQcBQuvEe7PBaL0Eoc=",
strip_prefix = "aspect-gazelle-9c84884007d508c04a4b327cbf9c586a0c9d966c/language/js",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/9c84884007d508c04a4b327cbf9c586a0c9d966c.tar.gz"],
integrity = "sha256-Vi6jAIMt/3AxZsdLl0cTv9sNyYMK+iBK6b0lzDUJhdY=",
strip_prefix = "aspect-gazelle-75d3c1f7ae519e5a0a82e2b57a51280d029ac843/language/js",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/75d3c1f7ae519e5a0a82e2b57a51280d029ac843.tar.gz"],
)

bazel_dep(name = "aspect_gazelle_orion", version = "0.0.0")
archive_override(
module_name = "aspect_gazelle_orion",
integrity = "sha256-XZUwwAH0/gyoW90PDDiZUxZaSuQcBQuvEe7PBaL0Eoc=",
strip_prefix = "aspect-gazelle-9c84884007d508c04a4b327cbf9c586a0c9d966c/language/orion",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/9c84884007d508c04a4b327cbf9c586a0c9d966c.tar.gz"],
integrity = "sha256-Vi6jAIMt/3AxZsdLl0cTv9sNyYMK+iBK6b0lzDUJhdY=",
strip_prefix = "aspect-gazelle-75d3c1f7ae519e5a0a82e2b57a51280d029ac843/language/orion",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/75d3c1f7ae519e5a0a82e2b57a51280d029ac843.tar.gz"],
)

bazel_dep(name = "aspect_gazelle_runner", version = "0.0.0")
archive_override(
module_name = "aspect_gazelle_runner",
integrity = "sha256-XZUwwAH0/gyoW90PDDiZUxZaSuQcBQuvEe7PBaL0Eoc=",
strip_prefix = "aspect-gazelle-9c84884007d508c04a4b327cbf9c586a0c9d966c/runner",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/9c84884007d508c04a4b327cbf9c586a0c9d966c.tar.gz"],
integrity = "sha256-Vi6jAIMt/3AxZsdLl0cTv9sNyYMK+iBK6b0lzDUJhdY=",
strip_prefix = "aspect-gazelle-75d3c1f7ae519e5a0a82e2b57a51280d029ac843/runner",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/75d3c1f7ae519e5a0a82e2b57a51280d029ac843.tar.gz"],
)

# Not direclty used but must be declared+overriden until aspect_gazelle_runner points to one published to BCR.
bazel_dep(name = "aspect_gazelle_kotlin", version = "0.0.0")
archive_override(
module_name = "aspect_gazelle_kotlin",
integrity = "sha256-XZUwwAH0/gyoW90PDDiZUxZaSuQcBQuvEe7PBaL0Eoc=",
strip_prefix = "aspect-gazelle-9c84884007d508c04a4b327cbf9c586a0c9d966c/language/kotlin",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/9c84884007d508c04a4b327cbf9c586a0c9d966c.tar.gz"],
integrity = "sha256-Vi6jAIMt/3AxZsdLl0cTv9sNyYMK+iBK6b0lzDUJhdY=",
strip_prefix = "aspect-gazelle-75d3c1f7ae519e5a0a82e2b57a51280d029ac843/language/kotlin",
urls = ["https://github.com/aspect-build/aspect-gazelle/archive/75d3c1f7ae519e5a0a82e2b57a51280d029ac843.tar.gz"],
)

# Go modules
Expand Down
10 changes: 8 additions & 2 deletions cmd/aspect/configure/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,14 @@ func runConfigureWatch(ctx context.Context, v *runner.GazelleRunner, mode string
return fmt.Errorf("failed to enter build state: %w", err)
}

if err := abazel.Cycle(ctx, ibp.WatchScope_Sources, changesetToCycle(cs)); err != nil {
return fmt.Errorf("failed to send cycle to incremental protocol: %w", err)
if cs.IsFreshInstance {
if err := abazel.CycleReset(ctx); err != nil {
return fmt.Errorf("failed to send cycle reset to incremental protocol: %w", err)
}
} else {
if err := abazel.Cycle(ctx, ibp.WatchScope_Sources, changesetToCycle(cs)); err != nil {
return fmt.Errorf("failed to send cycle to incremental protocol: %w", err)
}
}

// Leave the build state and fast forward the subscription clock.
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ go 1.26.1

require (
github.com/alphadose/haxmap v1.4.1
github.com/aspect-build/aspect-gazelle/common v0.0.0-20260504072208-9c84884007d5
github.com/aspect-build/aspect-gazelle/language/orion v0.0.0-20260504072208-9c84884007d5
github.com/aspect-build/aspect-gazelle/runner v0.0.0-20260504072208-9c84884007d5
github.com/aspect-build/aspect-gazelle/common v0.0.0-20260508230703-75d3c1f7ae51
github.com/aspect-build/aspect-gazelle/language/orion v0.0.0-20260508230703-75d3c1f7ae51
github.com/aspect-build/aspect-gazelle/runner v0.0.0-20260508230703-75d3c1f7ae51
github.com/bazelbuild/bazel-gazelle v0.50.0
github.com/bazelbuild/bazelisk v1.27.0 // NOTE: keep vendored code in sync
github.com/bazelbuild/buildtools v0.0.0-20260319080235-05d2ebe49b0f
Expand Down Expand Up @@ -62,8 +62,8 @@ require (
github.com/alecthomas/chroma/v2 v2.23.1 // indirect
github.com/alecthomas/participle/v2 v2.1.4 // indirect
github.com/apparentlymart/go-textseg/v15 v15.0.0 // indirect
github.com/aspect-build/aspect-gazelle/language/js v0.0.0-20260504072208-9c84884007d5 // indirect
github.com/aspect-build/aspect-gazelle/language/kotlin v0.0.0-20260504072208-9c84884007d5 // indirect
github.com/aspect-build/aspect-gazelle/language/js v0.0.0-20260508230703-75d3c1f7ae51 // indirect
github.com/aspect-build/aspect-gazelle/language/kotlin v0.0.0-20260508230703-75d3c1f7ae51 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/aymerick/douceur v0.2.0 // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@ github.com/apparentlymart/go-textseg/v15 v15.0.0 h1:uYvfpb3DyLSCGWnctWKGj857c6ew
github.com/apparentlymart/go-textseg/v15 v15.0.0/go.mod h1:K8XmNZdhEBkdlyDdvbmmsvpAG721bKi0joRfFdHIWJ4=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aspect-build/aspect-gazelle/common v0.0.0-20260504072208-9c84884007d5 h1:njHRmzoTLbaMhuMP46B2hZxGGWypwdnKp/1B76tVBks=
github.com/aspect-build/aspect-gazelle/common v0.0.0-20260504072208-9c84884007d5/go.mod h1:YYCHODCLeqDOEgXNvFKhKRwwprkXiaiCLceotY/ohHE=
github.com/aspect-build/aspect-gazelle/language/js v0.0.0-20260504072208-9c84884007d5 h1:kbwv97gOLoPN3nbYlkp/gHplKttrHBABtERTR3ya4nw=
github.com/aspect-build/aspect-gazelle/language/js v0.0.0-20260504072208-9c84884007d5/go.mod h1:mfeY2D7N0R0Od12id9hDnjPrR0Z2RXZN0JwTo7wNp/I=
github.com/aspect-build/aspect-gazelle/language/kotlin v0.0.0-20260504072208-9c84884007d5 h1:1v5EsA5OdV5eSrkObKCXtsbrQfJzpfObkHm4NgE3U5M=
github.com/aspect-build/aspect-gazelle/language/kotlin v0.0.0-20260504072208-9c84884007d5/go.mod h1:6YdjU23ZHWJEki9K3X+7agym4rf6BQ6Kes4a5MzfcgM=
github.com/aspect-build/aspect-gazelle/language/orion v0.0.0-20260504072208-9c84884007d5 h1:o00OB32hiquD2DfBjKGt21SmkL+gVxCpWllHF+g1XQk=
github.com/aspect-build/aspect-gazelle/language/orion v0.0.0-20260504072208-9c84884007d5/go.mod h1:2BMCnAh1+8C/LlOFsO/hR32xZtBLey3QDQ9a6DP5D7c=
github.com/aspect-build/aspect-gazelle/runner v0.0.0-20260504072208-9c84884007d5 h1:lbxAF24IfmqKvIOt6BPVFvc52EdTQ7T4MCe5bsG4paQ=
github.com/aspect-build/aspect-gazelle/runner v0.0.0-20260504072208-9c84884007d5/go.mod h1:s+yb0ysyhmYsEX02/Ao+ENhaDXEkzCfOg9iENGMWFfY=
github.com/aspect-build/aspect-gazelle/common v0.0.0-20260508230703-75d3c1f7ae51 h1:M5Ha1P7eYomjRxFDtxCF+La0M358JhHkHCSrVUvgs48=
github.com/aspect-build/aspect-gazelle/common v0.0.0-20260508230703-75d3c1f7ae51/go.mod h1:YYCHODCLeqDOEgXNvFKhKRwwprkXiaiCLceotY/ohHE=
github.com/aspect-build/aspect-gazelle/language/js v0.0.0-20260508230703-75d3c1f7ae51 h1:sv4tWtKyHoIPD2su7jwFO2RoTdPQlMn/UHzrmkH/vWo=
github.com/aspect-build/aspect-gazelle/language/js v0.0.0-20260508230703-75d3c1f7ae51/go.mod h1:mfeY2D7N0R0Od12id9hDnjPrR0Z2RXZN0JwTo7wNp/I=
github.com/aspect-build/aspect-gazelle/language/kotlin v0.0.0-20260508230703-75d3c1f7ae51 h1:gI5z4krmNi+Qp6YEZvIccD4fG9FJGxGBFJN1U6k7ACQ=
github.com/aspect-build/aspect-gazelle/language/kotlin v0.0.0-20260508230703-75d3c1f7ae51/go.mod h1:6YdjU23ZHWJEki9K3X+7agym4rf6BQ6Kes4a5MzfcgM=
github.com/aspect-build/aspect-gazelle/language/orion v0.0.0-20260508230703-75d3c1f7ae51 h1:QzCyALq8ESD8ifCAvXzZxXv6nmQn9zyXkyivEaua+PQ=
github.com/aspect-build/aspect-gazelle/language/orion v0.0.0-20260508230703-75d3c1f7ae51/go.mod h1:2BMCnAh1+8C/LlOFsO/hR32xZtBLey3QDQ9a6DP5D7c=
github.com/aspect-build/aspect-gazelle/runner v0.0.0-20260508230703-75d3c1f7ae51 h1:QpRpwJw3YtgcmH/i0WY3jC0YlV3UPrXctoEK81Ydu8E=
github.com/aspect-build/aspect-gazelle/runner v0.0.0-20260508230703-75d3c1f7ae51/go.mod h1:s+yb0ysyhmYsEX02/Ao+ENhaDXEkzCfOg9iENGMWFfY=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/aymanbagabas/go-osc52/v2 v2.0.1 h1:HwpRHbFMcZLEVr42D4p7XBqjyuxQH5SMiErDT4WkJ2k=
Expand Down
6 changes: 6 additions & 0 deletions pkg/aspect/run/ibazel.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (ib *IBazelProtocol) Cycle(ctx context.Context, scope ibp.WatchScope, chang

return res
}
func (ib *IBazelProtocol) CycleReset(ctx context.Context) error {
return ib.Cycle(ctx, ibp.WatchScope_Runfiles, nil)
}
func (ib *IBazelProtocol) Close() error {
return nil
}
Expand Down Expand Up @@ -174,6 +177,9 @@ func (rb *RestartBazelProtocol) Cycle(ctx context.Context, scope ibp.WatchScope,

return nil
}
func (rb *RestartBazelProtocol) CycleReset(ctx context.Context) error {
return rb.Cycle(ctx, ibp.WatchScope_Runfiles, nil)
}
func (rb *RestartBazelProtocol) Close() error {
return nil
}
Expand Down
28 changes: 19 additions & 9 deletions pkg/aspect/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ func (runner *Run) runWatch(ctx context.Context, bazelCmd []string, bzlCommandSt
var (
cycleScope ibp.WatchScope
cycleChanges ibp.SourceInfoMap
cycleIsReset bool
)

if incBuildErr != nil {
Expand All @@ -525,19 +526,15 @@ func (runner *Run) runWatch(ctx context.Context, bazelCmd []string, bzlCommandSt
} else {
// Drain accumulated changes every cycle to keep the
// detector's internal map bounded; the result may be
// ignored (fresh-instance, source mode) when constructing
// ignored (source mode + fresh-instance) when constructing
// the IBP message.
changes := changedetect.cycleChanges()

switch {
case cs.IsFreshInstance:
// IBP peer gets a reset (nil sources) instead of `changes`.
if watchRunfilesChanges {
cycleScope = ibp.WatchScope_Runfiles
} else if watchSourceChanges {
cycleScope = ibp.WatchScope_Sources
}
case watchRunfilesChanges && len(changes) > 0:
// Runfiles deltas are reconciled from the runfiles manifest and
// execlog, so they're trustworthy even after a watchman fresh-instance
// where cs.Paths is empty.
logger.Infof("Cycle changes: %v", changes)

// For now just rerun the target, beware that RunCommand does not yield until
Expand All @@ -547,6 +544,11 @@ func (runner *Run) runWatch(ctx context.Context, bazelCmd []string, bzlCommandSt
cycleScope = ibp.WatchScope_Runfiles
cycleChanges = changes
// TODO: if we want to support ibazel livereload then we need to report changes.
case watchSourceChanges && cs.IsFreshInstance:
// Source-mode cycles are keyed by cs.Paths, which is unreliable on a
// fresh-instance and has no manifest-based reconciliation; signal a
// full peer reset.
cycleIsReset = true
case watchSourceChanges:
logger.Infof("Cycle source changes: %v", cs.Paths)

Expand All @@ -562,7 +564,15 @@ func (runner *Run) runWatch(ctx context.Context, bazelCmd []string, bzlCommandSt
}
}

if cycleScope != "" {
if cycleIsReset {
ctctx, cycleTrace := runner.tracer.Start(tctx, "Run.Cycle")
defer cycleTrace.End()

if err := incrementalProtocol.CycleReset(ctctx); err != nil {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve fallback for pre-v2 watch clients

When the target connects with an older IBP client that negotiates v1 but watches sources, a watchman fresh-instance now sets cycleIsReset and reaches CycleReset; the upgraded server rejects that call for negotiated versions below v2 (CYCLE_RESET requires protocol >= v2), so the watch loop returns an error instead of notifying the target as it did before with a CYCLE/nil-sources message. This only shows up for source-watching targets built against the older protocol after a fresh-instance/recrawl, but it breaks backwards-compatible watch sessions.

Useful? React with 👍 / 👎.

cycleTrace.SetStatus(codes.Error, err.Error())
return fmt.Errorf("failed to report cycle reset: %w", err)
}
} else if cycleScope != "" {
ctctx, cycleTrace := runner.tracer.Start(tctx, "Run.Cycle")
defer cycleTrace.End()

Expand Down
Loading