Lightweight coding agent that runs in your terminal
Rust
Add a cacheable Bazel app-server schema bundle (#42174)
Charlie Marshb21f2e30815a
diff --git a/bazel/rules/BUILD.bazel b/bazel/rules/BUILD.bazelindex 218872c73c..ab6d1f9763 100644--- a/bazel/rules/BUILD.bazel+++ b/bazel/rules/BUILD.bazel@@ -2,4 +2,5 @@ package(default_visibility = ["//visibility:public"])exports_files(["e2e_benchmark.bzl",+ "schema_bundle.bzl",])diff --git a/bazel/rules/schema_bundle.bzl b/bazel/rules/schema_bundle.bzlnew file mode 100644index 0000000000..5f8e2eae01--- /dev/null+++ b/bazel/rules/schema_bundle.bzl@@ -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.",+)diff --git a/bazel/schema/BUILD.bazel b/bazel/schema/BUILD.bazelnew file mode 100644index 0000000000..401d30b00f--- /dev/null+++ b/bazel/schema/BUILD.bazel@@ -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"],+)diff --git a/codex-rs/app-server-protocol/BUILD.bazel b/codex-rs/app-server-protocol/BUILD.bazelindex eb6e1d280a..4ecf754479 100644--- a/codex-rs/app-server-protocol/BUILD.bazel+++ b/codex-rs/app-server-protocol/BUILD.bazel@@ -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__"],+)