Add a cacheable Bazel app-server schema bundle (#42174)

## What changed

- Add a `schema_bundle` rule that generates stable and experimental app-server
  schema directories as declared Bazel actions.
- Include the pinned `zstd` executable in the bundle so consumers can normalize
  generated JSON without a separate `bazel run` invocation.
- Expose the app-server protocol test binary as the schema generator and add the
  manual `//bazel/schema:public-schema-bundle` target.

GitOrigin-RevId: 0a7ce47258d297dbf20db78626f2843145ee1b49
This commit is contained in:
Charlie Marsh
2026-09-02 02:00:18 +00:00
committed by copyberry
parent 671d5d1b35
commit b21f2e3081
4 changed files with 56 additions and 0 deletions
+1
View File
@@ -2,4 +2,5 @@ package(default_visibility = ["//visibility:public"])
exports_files([
"e2e_benchmark.bzl",
"schema_bundle.bzl",
])
+39
View File
@@ -0,0 +1,39 @@
"""Cache schema generation from the filtered public Rust test executable."""
def _schema_bundle_impl(ctx):
outputs = []
for mode in ["stable", "experimental"]:
schema = ctx.actions.declare_directory(ctx.label.name + "." + mode)
ctx.actions.run(
executable = ctx.executable.generator,
tools = [ctx.attr.generator[DefaultInfo].files_to_run],
arguments = [
"--exact",
"--ignored",
"schema_fixtures_tests::write_schema_fixtures_from_env",
],
env = {
"CODEX_APP_SERVER_SCHEMA_ROOT": schema.path,
"CODEX_APP_SERVER_SCHEMA_EXPERIMENTAL": "1" if mode == "experimental" else "0",
"RUST_MIN_STACK": "8388608",
},
outputs = [schema],
mnemonic = "PublicSchema",
progress_message = "Generating %s public app-server schemas" % mode,
)
outputs.append(schema)
# Expose the pinned compressor alongside the cached directories so callers
# can normalize the JSON without a separate `bazel run` invocation.
zstd = ctx.actions.declare_file(ctx.label.name + ".zstd")
ctx.actions.symlink(output = zstd, target_file = ctx.executable.zstd, is_executable = True)
return [DefaultInfo(files = depset(outputs + [zstd]))]
schema_bundle = rule(
implementation = _schema_bundle_impl,
attrs = {
"generator": attr.label(mandatory = True, executable = True, cfg = "exec"),
"zstd": attr.label(default = "@zstd//:zstd_cli", executable = True, cfg = "exec"),
},
doc = "Generates both schema modes as cacheable actions with explicit tool dependencies.",
)
+8
View File
@@ -0,0 +1,8 @@
load("//bazel/rules:schema_bundle.bzl", "schema_bundle")
schema_bundle(
name = "public-schema-bundle",
testonly = True,
generator = "//codex-rs/app-server-protocol:schema-generator",
tags = ["manual"],
)
+8
View File
@@ -9,3 +9,11 @@ codex_rust_crate(
allow_empty = True,
),
)
alias(
name = "schema-generator",
testonly = True,
actual = ":app-server-protocol-unit-tests-bin",
tags = ["manual"],
visibility = ["//bazel/schema:__pkg__"],
)