Tools
Tools tree
This tree contains developer tools and reusable Bazel rule modules. All tracked
content follows the repository’s public-source policy. Standalone rules_*
modules retain their own Bzlmod names and public build APIs, with documentation
on the main repository site. They do not own separate landing sites.
Requirements
- Bazel targets MUST use repository-internal visibility except for standalone
Bazel rule modules and toolchain types whose owner explicitly exposes a public
build API.
- Tool artifacts MUST NOT be published as first-party product artifacts.
- Standalone Bazel rule modules MAY publish their reusable build APIs through
their explicit module release workflow.
- Production build targets MAY load Starlark rules and use execution tools and
toolchains, including the public build APIs of standalone Bazel rule modules.
Other tool targets MUST NOT be ordinary source, library, or runtime dependencies
of production build targets.
- Tool targets intended for repository-wide use MUST use
visibility = ["//:__subpackages__"]. - Tool targets MAY be used in tests and explicit source-generation/update
targets.
Build rules may run tools from this tree in the execution configuration to
generate source artifacts owned by their consuming component. Generated code
may be compiled by that component’s normal language rules; the tool itself
does not become a runtime dependency.
An explicit source-update target is a developer workflow. It may use
write_source_file to update a checked-in artifact. Consumers of that
checked-in artifact read it directly rather than running its update target.
Transitive dependency enforcement
//tools:transitive_consumers records the packages permitted to consume this
tree. Gazelle selects package groups using the path mappings in
transitive_visibility/transitive_visibility.toml.
The listed project exceptions preserve documentation, tests, source updates,
and explicit developer/release commands. An exception permits the entire
consumer package, including other targets sharing it; it does not prove that
every target in that package follows the production rule above. New exceptions
require review of the consuming workflow. Standalone modules are separate
repositories and retain their public build APIs.
Public toolchain-type packages and shared build settings explicitly select
//tools:build_api_consumers. This preserves external toolchain registration
and repository build configuration without granting other tool packages the
same exception.
The intended artifact boundary excludes execution-tool and Starlark-load
edges. Bazel 9.3.1’s native transitive check cannot express that distinction
for every attribute; see the generator’s enforcement limitations.
Use --notool_deps for queries of ordinary target dependencies. A package
exception also permits ordinary dependencies from that package, so it is not
equivalent to an exemption for execution tools alone.
1 - Agents
Repository-wide reusable agent skills
Repository agent skills
This project owns the reusable cross-repository agent skills. Maintained
improvement work lives in this project’s OpenSpec workspace. It
does not centralize component facts or runtime state: each fact remains
canonical at its natural owner.
The main site publishes this project’s repository documentation at
/docs/tools/agents/ through //tools:docs.
Start here
| Document | Purpose |
|---|
| OpenSpec changes | Maintained work, acceptance, and preserved goal history |
AGENTS.md at the root of your checkout | Repository-wide operating policy for the revision you are working on |
Dated audits remain in
migrated history.
Ownership boundaries
openspec/ owns agent-system requirements, changes, and evidence;
the migration map locates historical records.- Other components own their specifications and changes under their own
openspec/ directory. infra/src/openspec/ describes repository evolution. skills/ owns reusable cross-product, repository-wide agent procedures and
their development-time evaluations. A product-specific procedure belongs
with its product; a procedure that no narrower project genuinely owns lives
here rather than in a contrived local home.- Product-specific skills remain with their project at
projects/<project>/skills/<name>. Do not split one skill across owners.
Skill packaging and discovery
Every canonical skill is packaged as a skill_library in its owning
directory.
The discovery declaration in .agents/BUILD.bazel lists the inputs to
//.agents:write_skills. Entries under symlinks point directly to the
owning directories. Entries under archives are unpacked into
.agents/skills/. To change a packaged skill, edit the source of its declared
target or update its upstream pin, then regenerate discovery. The generated
exact-state test checks both forms. Bazel ignores the discovery directory
and builds the canonical targets.
Skill evaluation data is not part of the runtime skill_library unless a
skill explicitly declares otherwise. Every new or updated skill includes an
offline Promptfoo configuration-validation target. That target checks the eval
harness, not answer correctness. Live behavioral evaluations are manual,
networked tests and must not be included in ordinary wildcard test runs; they
may be omitted when representative coverage requires tool calls or external
state that cannot be provided safely and reproducibly, with the gap documented
beside the eval configuration.
External references
2 - Android
Android
packages.txt owns the SDK and NDK package selection used by :install and
:installer_tar. The latter packages the installer and the pinned Linux x86-64
command-line tools for Ansible deployment without bootstrapping Bazel on the
remote host. It requires a host Java runtime; downloading SDK packages happens
only when the installed command runs, never in a Bazel build action.
Release manifest versions
Stamped APKs use STABLE_VERSION for Android’s version name. Build
production APKs on the weekly release branch. Their codes order releases
by ISO week and patch. Development builds use code 1.
AL’s nightly channel appends .nightly to the manifest package so the APK
can install alongside the weekly release. Nightly codes use the UTC date
from STABLE_NIGHTLY_DATE as a YYYYMMDD integer.
The app-owned launcher.svg files are rasterized by Bazel at the Android
xxxhdpi size. F-Droid extracts the launcher image from the resulting APK.
APK signing identities
Each app’s sign_apk target uses Android SDK signing code with its own
Vault Transit key and original public certificate. Android uses the
certificate to authenticate upgrades. The F-Droid repository key signs
the index separately.
An authorized Vault operator imports the existing RSA-4096 private keys
using the same wrapped import procedure as the repository key.
For each AppRole, import its original apk_signing key into
transit/default/keys/<approle>. Put its unchanged PEM certificate in
the role’s apk_signing_certificate KV entry with field certificate.
- Android Launcher uses
src_projects_android_launcher. - ActivityWatch Ingester uses
src_projects_activitywatch_ingester_android.
Compare each certificate fingerprint with the deployed APK before importing.
After provisioning both keys and certificates, apply the app policies through
//infra/vault/tf:tf. The signing roles can read their certificates and ask
Transit for signatures. The original private-key entries are restricted to
operators.
3 - Ansible
Bazel rules for ansible
al_ansible_package from //tools/ansible/rules:al_ansible_package.bzl
declares mapped sources, their runtime package, an <name>_bin executable and
AL command wrappers. For example:
al_ansible_package(
name = "ansible",
srcs = ["inventory.yaml"] + glob(["group_vars/**/*.yaml", "playbook_*.yaml"]),
configs = ["//infra/example:al"],
plugin_labels = {"ansible": "", "vault_env": "default_default"},
)
The default command uses --inventory inventory.yaml playbook_deploy.yaml.
Pass an args dictionary to declare custom command suffixes and arguments;
the macro supplies the executable. Sources retain package-relative paths.
renames changes individual destinations, while packaged_srcs supplies the
complete ordered list of mapped source groups (including :srcs_files).
srcs_name and files_name override those source target names, and
binary_visibility grants access to the packaged executable independently.
The binary includes the shared infrastructure Ansible configuration and
repository collection. Run bazel test //path/to/package:<name>.syntax to
check the default playbook or append .syntax to a named command to check its
playbook. Each test uses the command’s arguments and packaged extra-vars files
without loading deployment plugins.
ansible_lint runs ansible-lint from Bazel-managed Python
dependencies. A Go test runner exposes the CLI binaries under their
hyphenated names, configures writable Ansible paths, and invokes the
linter against workspace-relative sources.
Python dependencies are declared in pyproject.toml and locked in uv.lock.
Update the lock with //tools/ansible:uv_lock.update and review its
diff. Build //tools/ansible:uv_lock to generate it without source writes.
These use the shared uv locking workflow, whose sandboxed resolution action
requires network access to PyPI.
The current lock uses ansible-core 2.22 for Python 3.15 targets. Its matching
Ansible community bundle is 15.0.0rc1, selected because the stable community
bundle still requires an older core. The compatibility change
records that release-candidate constraint and deployment validation.
bazel run //tools/ansible:molecule -- --version runs the locked Molecule
CLI using the same Python dependency set as Ansible. The disposable QEMU
guest runner and collection scenarios are tracked in the
Molecule runner change.
3.1.1 - al_ansible_binaries
al_ansible_binaries
load("@com_alwaldend_src//tools/ansible/rules:al_ansible_binaries.bzl", "al_ansible_binaries")
al_ansible_binaries(name, args, visibility, **kwargs)
Generate a binary for earch ansible command
PARAMETERS
| Name | Description | Default Value |
|---|
| name | name prefix | none |
| args | specific kwargs | {} |
| visibility | visibility | None |
| kwargs | common arguments | none |
3.1.2 - al_ansible_binary
al_ansible_binary
load("@com_alwaldend_src//tools/ansible/rules:al_ansible_binary.bzl", "al_ansible_binary")
al_ansible_binary(name, data, ansible, arguments, process_name)
Run an ansible command
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| data | Data | List of labels | optional | [] |
| ansible | Ansible executable | Dictionary: String -> Label | optional | {"ansible": "@com_alwaldend_src//tools/ansible", "ansible_config": "@com_alwaldend_src//tools/ansible:ansible_config", "ansible_console": "@com_alwaldend_src//tools/ansible:ansible_console", "ansible_doc": "@com_alwaldend_src//tools/ansible:ansible_doc", "ansible_galaxy": "@com_alwaldend_src//tools/ansible:ansible_galaxy", "ansible_inventory": "@com_alwaldend_src//tools/ansible:ansible_inventory", "ansible_playbook": "@com_alwaldend_src//tools/ansible:ansible_playbook", "ansible_pull": "@com_alwaldend_src//tools/ansible:ansible_pull", "ansible_test": "@com_alwaldend_src//tools/ansible:ansible_test", "ansible_vault": "@com_alwaldend_src//tools/ansible:ansible_vault"} |
| arguments | Ansible arguments | List of strings | optional | [] |
| process_name | Process name | String | required | |
3.1.3 - al_ansible_extension
al_ansible_extension
al_ansible_extension = use_extension("@com_alwaldend_src//tools/ansible/rules:al_ansible_extension.bzl", "al_ansible_extension")
al_ansible_extension.lock(name, lock)
Ansible extensions
TAG CLASSES
lock
Attributes
| Name | Description | Type | Mandatory | Default |
|---|
| name | Name prefix | Name | required | |
| lock | Ansible lock path | Label | required | |
3.1.4 - al_ansible_package
Repository Ansible packages with mapped runtime files and AL commands.
al_ansible_package
load("@com_alwaldend_src//tools/ansible/rules:al_ansible_package.bzl", "al_ansible_package")
al_ansible_package(name, srcs, configs, plugin_labels, args, packaged_srcs, renames, srcs_name,
files_name, binary_visibility, extra_vars_files, **kwargs)
Package sources and expose Ansible playbook commands and syntax tests.
PARAMETERS
| Name | Description | Default Value |
|---|
| name | Command prefix; the packaged executable is <name>_bin. | none |
| srcs | Files to map relative to the caller’s package. | none |
| configs | AL configuration dependencies for command wrappers. | [] |
| plugin_labels | AL plugin selectors for command wrappers. | {} |
| args | Command suffix to Ansible argument list, without the executable. Defaults to the inventory.yaml/playbook_deploy.yaml invocation. | None |
| packaged_srcs | Mapped source groups; defaults to the files_name target. | None |
| renames | Destination overrides for srcs. | {} |
| srcs_name | Combined runtime source target name. | "srcs" |
| files_name | Mapped source target name. | "srcs_files" |
| binary_visibility | Optional visibility for the packaged executable. | None |
| extra_vars_files | Packaged Ansible variables files passed in order to each playbook. | [] |
| kwargs | Common target attributes for the package and commands. | none |
3.1.5 - al_ansible_role
al_ansible_role
load("@com_alwaldend_src//tools/ansible/rules:al_ansible_role.bzl", "al_ansible_role")
al_ansible_role(name, srcs, visibility, renames, deps, **kwargs)
Create targets for an ansible role
PARAMETERS
| Name | Description | Default Value |
|---|
| name | name prefix | none |
| srcs | role sources | none |
| visibility | resulting archive visibility | none |
| renames | - | {} |
| deps | - | [] |
| kwargs | kwargs for pkg_files | none |
3.1.6 - al_ansible_scripts
4 - Artifact mirror
Stage pinned Helm charts and OCI images and publish them to Forgejo
//tools/artifact_mirror reads a JSON inventory of Helm chart archives and
OCI images. It verifies staged digests before publishing and verifies the
destination after copying. OCI copies preserve multi-platform indexes.


bazel run //tools/artifact_mirror -- pull --inventory /absolute/path/artifacts.json
bazel run //tools/artifact_mirror -- push --inventory /absolute/path/artifacts.json --owner ORGANIZATION
Direct invocations use helm and oras from PATH. Override either with
--helm or --oras. The default staging directory is out/artifact-mirror.
Push uses FORGEJO_HOST and FORGEJO_API_TOKEN from its caller.
The third-party mirror targets
supply the pinned executables, package inventory, and Forgejo login.
5 - AWS CLI
Repository command for Amazon Web Services
Run the pinned AWS CLI
from the repository root.
bazel run //tools/aws -- --version
6 - Bazel configs
Bazel config targets
Harbor
Targets that pull from the private Harbor registry are disabled by default so
repository-wide builds work while Harbor is unavailable. Enable them with
--config=harbor when the registry is reachable.
7 - Bazel session cleanup
The repository’s .codex/config.toml queues asynchronous Bazel expunge when a
Codex session ends. Review and trust the hook with /hooks in Codex; project
hooks do not run until trusted. A completed assistant turn does not trigger
cleanup.
If /hooks is empty in a linked Git worktree, check the primary checkout’s
.codex/config.toml. In Codex CLI 0.153.4, observed on 2026-09-06, config/read
returned the primary checkout’s configuration even though its project-layer
metadata named the linked worktree. That primary configuration had no hooks,
so hooks/list returned an empty list. The exact worktree TOML listed both
hooks in an isolated normal checkout; separate user-config probes also accepted
both TOML and JSON. Changing formats is therefore not an established fix.
Merge the hook configuration and update the primary checkout, then start a new
CLI session and check /hooks to trust it. Recheck configuration resolution
after upgrading Codex; this is an observed version-specific behavior, not a
guarantee for every release.
The shell hook launches a transient user systemd service, which runs
bazel --noblock_for_lock clean --expunge_async in each built,
tracked Bazel workspace in the linked Git worktree. It skips the primary
checkout, submodules, workspaces without a bazel-out symlink, and busy Bazel
instances. Source files, Git worktrees, and shared disk caches are preserved.
Nested workspaces are discovered from tracked MODULE.bazel, WORKSPACE, and
WORKSPACE.bazel files. Custom convenience-symlink prefixes are not supported.
This Linux hook requires Bash, Git, Bazelisk’s bazel on PATH, and a running
user systemd manager. The service inherits PATH, not the session’s full
environment. KillMode=process allows Bazel’s asynchronous deletion child to
finish after the service exits. Failures appear in the user journal; failure
to enqueue is reported by Codex as a hook failure. There is no automatic retry
or orphan-cache sweep. Concurrent sessions sharing a worktree may lose warm
build state when one ends; the Bazel lock protects running builds, not idle
sessions. Resuming a cleaned session rebuilds its outputs normally.
The hook uses shell because it must run from a fresh checkout without first
building a helper. The startup lock flag lets it skip a busy Bazel server.
Tests replace Git, systemd, and Bazel with fixtures and never clean real caches.
Codex’s SessionEnd hook is synchronous even with async: true and permits
at most three seconds. Systemd owns the longer-running cleanup; the hook does
not wait for it. See the Codex hook documentation.
8 - Bazel shell worker
Bazel worker that runs shell commands
8.1.1 - al_genrule
al_genrule
load("@com_alwaldend_src//tools/shell_worker/rules:al_genrule.bzl", "al_genrule")
al_genrule(test, executable, **kwargs)
Generate al_genrule target
PARAMETERS
| Name | Description | Default Value |
|---|
| test | If set, use al_genrule_test | False |
| executable | if set, use al_genrule_executable | False |
| kwargs | kwargs for the rule | none |
8.1.2 - al_genrule_rule
al_genrule_executable
load("@com_alwaldend_src//tools/shell_worker/rules:al_genrule_rule.bzl", "al_genrule_executable")
al_genrule_executable(name, srcs, data, outs, cmd, set_flags, shell, tools, worker)
Build executable using shell worker
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| srcs | Sources, will not be added to runfiles | List of labels | optional | [] |
| data | Data, will be added to runfiles | List of labels | optional | [] |
| outs | Outputs | List of labels; nonconfigurable | required | |
| cmd | Script to execute | String | required | |
| set_flags | set flags | List of strings | optional | ["-eux"] |
| shell | shell to use | String | optional | "/bin/sh" |
| tools | Tools, will be added to runfiles | List of labels | optional | [] |
| worker | Worker binary | Label | optional | "@com_alwaldend_src//tools/shell_worker" |
al_genrule_regular
load("@com_alwaldend_src//tools/shell_worker/rules:al_genrule_rule.bzl", "al_genrule_regular")
al_genrule_regular(name, srcs, data, outs, cmd, set_flags, shell, tools, worker)
Build shell worker rule
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| srcs | Sources, will not be added to runfiles | List of labels | optional | [] |
| data | Data, will be added to runfiles | List of labels | optional | [] |
| outs | Outputs | List of labels; nonconfigurable | required | |
| cmd | Script to execute | String | required | |
| set_flags | set flags | List of strings | optional | ["-eux"] |
| shell | shell to use | String | optional | "/bin/sh" |
| tools | Tools, will be added to runfiles | List of labels | optional | [] |
| worker | Worker binary | Label | optional | "@com_alwaldend_src//tools/shell_worker" |
al_genrule_test
load("@com_alwaldend_src//tools/shell_worker/rules:al_genrule_rule.bzl", "al_genrule_test")
al_genrule_test(name, srcs, data, outs, cmd, set_flags, shell, tools, worker)
Test using shell worker
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| srcs | Sources, will not be added to runfiles | List of labels | optional | [] |
| data | Data, will be added to runfiles | List of labels | optional | [] |
| outs | Outputs | List of labels; nonconfigurable | required | |
| cmd | Script to execute | String | required | |
| set_flags | set flags | List of strings | optional | ["-eux"] |
| shell | shell to use | String | optional | "/bin/sh" |
| tools | Tools, will be added to runfiles | List of labels | optional | [] |
| worker | Worker binary | Label | optional | "@com_alwaldend_src//tools/shell_worker" |
9 - Bazelrc
Bazelrc files
Usage
bazel run //tools/bazelrc:preset.update
Account-specific output defaults belong in ~/.bazelrc; see the
repository setup guide.
Repository configuration must not propagate ambient TEMP, TMP, or TMPDIR
values into repository rules, actions, host actions, or tests. Those execution
contexts use Bazel-managed temporary storage; host tools own any explicit
task/run scratch they require.
Go build actions (Go* and RunNogo) remove an inherited no-sandbox
execution requirement through the shared --modify_execution_info setting.
This keeps compilation in Bazel-managed sandboxes even when its owning test
needs local workspace access. TestRunner retains its existing requirements,
so the test can still inspect workspace files. The shared root and nested
workspace configuration both apply this setting.
Agent tests use Bazel’s normal result cache. Tests that inspect undeclared
workspace files must use the external tag to bypass local test-result reuse;
no-cache alone does not disable that cache.
Agent commands use Bazel’s default lockfile update mode. Review and commit
generated lockfile changes with dependency changes. CI retains strict lockfile
checking; use --lockfile_mode=error for an explicit reproducibility check.
The shared CI profile works in root and nested workspaces. The root-only
//tools/bazel_configs:ci_flag belongs in root.bazelrc; nested workspaces
import the common CI flags without resolving that root package.
The project configuration owns CI log presentation and the top-level remote
download setting. The preset generator omits overlapping defaults.
In the root workspace, lint actions fail on violations. Their failure setting
is identical across normal and lint configurations to preserve the analysis
cache when switching modes. --config=lint enables the linter aspects and
requests only lint reports and skill validation, not ordinary target outputs.
Repository caching and protobuf
Bazel 9 enables the local repository contents cache by default under
{--repository_cache}/contents. It reuses eligible fetched repositories across
workspaces; the shared configuration preserves this default location.
The shared startup configuration also enables
--experimental_remote_repo_contents_cache. It uses configured remote or disk
cache backends for reproducible repository rules. It does not provision a cache
service or configure an endpoint. Existing cache upload policy still applies.
Because the option is a startup flag, changing it restarts the Bazel server.
The root workspace enables
--@protobuf//bazel/toolchains:prefer_prebuilt_protoc to use the pinned protobuf
module’s prebuilt compiler where supported, with source compilation as the
fallback. The setting is root-only because standalone nested modules can use
different protobuf versions. User overrides remain last.
Links
The generated preset omits the optional Cloudflare module mirror because it
slow-stalls on the CI network. Bazel uses the source URLs and mirrors declared
by each registry entry. Configure this omission in BUILD.bazel, then regenerate
preset.bazelrc; a later empty flag does not clear an accumulated mirror.
11 - Buildifier
Buildifier
Links
12 - Bzl
Bazel rules related to Bazel itself
First-party ruleset archives
Develop rulesets from the monorepo root using their package paths, for example
bazel test //tools/rules_docs/.... Each project declares its standalone name
in its own release.MODULE.bazel.
To package the source archives, run:
bazel run //tools/bzl/cmd/release_archives -- --output-directory "$PWD/out/releases"
The command packages the committed source at HEAD, translates package labels
for standalone consumers, removes the enclosing monorepo visibility directive
from OpenSpec packages, and installs each release.MODULE.bazel as
MODULE.bazel inside its archive. Use those
manifests and archive checksums to prepare registry entries. DNSControl,
ISO, and systemd provide their own release_archive build targets.
12.1.1 - al_alias_map
al_alias_map
load("@com_alwaldend_src//tools/bzl/rules:al_alias_map.bzl", "al_alias_map")
al_alias_map(aliases, visibility)
Generate aliases from an alias map
PARAMETERS
| Name | Description | Default Value |
|---|
| aliases | alias map, keys are names, values are alias arguments | none |
| visibility | default visibility | ["//:__subpackages__"] |
12.1.2 - al_bzl_generate_repository
al_bzl_generate_repository
load("@com_alwaldend_src//tools/bzl/rules:al_bzl_generate_repository.bzl", "al_bzl_generate_repository")
al_bzl_generate_repository(name, files)
Generate a repository
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this repository. | Name | required | |
| files | Files to generate, keys are paths, values are file contents | Dictionary: String -> String | optional | {} |
12.1.3 - al_bzl_library_map
al_bzl_library_map
load("@com_alwaldend_src//tools/bzl/rules:al_bzl_library_map.bzl", "al_bzl_library_map")
al_bzl_library_map(name, visibility, libs, deps, **kwargs)
Create bzl_library targets from a map
PARAMETERS
| Name | Description | Default Value |
|---|
| name | combined bzl_library target name | none |
| visibility | - | None |
| libs | bzl_library names | {} |
| deps | other al_bzl_library_map targets | [] |
| kwargs | bzl_library kwargs | none |
12.1.4 - al_bzl_target_doc
al_bzl_target_doc
load("@com_alwaldend_src//tools/bzl/rules:al_bzl_target_doc.bzl", "al_bzl_target_doc")
al_bzl_target_doc(name, visibility, subpackages)
Document bazel targets
PARAMETERS
| Name | Description | Default Value |
|---|
| name | target name | none |
| visibility | - | none |
| subpackages | list of subpackages | [] |
12.1.5 - al_genquery_write_to_source_file
al_genquery_write_to_source_file
load("@com_alwaldend_src//tools/bzl/rules:al_genquery_write_to_source_file.bzl", "al_genquery_write_to_source_file")
al_genquery_write_to_source_file(name, expression, scope, var_name, out_file)
Write genquery result to a bzl file
Example:
al_genquery_write_to_source_file(
name = "al_bzl_libs",
expression = """
filter(
"^//",
attr(
"srcs",
".{3,}",
kind(
"bzl_library",
deps("//bzl")
)
)
)
""",
out_file = "al_bzl_libs.bzl",
scope = ["//bzl"],
var_name = "AL_BZL_LIBS",
)
PARAMETERS
| Name | Description | Default Value |
|---|
| name | name prefix | none |
| expression | genquery expression | none |
| scope | genquery scope | none |
| var_name | variable name in the generated .bzl file | none |
| out_file | output bzl file | none |
13 - Bzlenv
Setup bazel environment
Rules to create a bazel environment which functions similar to venv
Features
- Adds bazel-built tools to
${PATH} - Exposes each executable under its configured
tools dictionary key,
independently of the underlying binary’s filename, and retains its runfiles - Exports .env
Usage
Create env and activate:
. "$(bazel run //tools/bzlenv)"
Activate existing env:
Deactivate env:
13.1.1 - al_bzlenv_binary
al_bzlenv_binary
load("@com_alwaldend_src//tools/bzlenv/rules:al_bzlenv_binary.bzl", "al_bzlenv_binary")
al_bzlenv_binary(name, activate, tools)
Dev shell binary
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| activate | Activation script | Label | optional | "@com_alwaldend_src//tools/bzlenv/internal/scripts:activate" |
| tools | Tools, keys are tool names, values are tool labels | Dictionary: String -> Label | optional | {} |
14 - Cc
Cc
//:refresh_compile_commands uses the pinned Hedron extractor. Its archive is
declared through use_repo_rule and fetched when the extractor’s package is
loaded, rather than during module resolution. LLVM toolchain registration
remains automatic.
Links
15 - Cloc
Cloc
Links
The pinned upstream binary is owned by
third_party/com_github_aldanial_cloc.
16 - Cmctl
Cert Manager cmctl
Links
17 - Code screenshot
Capture a UTF-8 code file as a PNG using the alwaldend.com shared light/dark palette and typography. Source is inserted as literal text, never interpreted as HTML or executed. The command runs the pinned headless browser with page JavaScript disabled and network requests blocked.
bazel run //tools/code_screenshot -- \
--input tools/code_screenshot/cmd/code_screenshot/main.mjs \
--output out/code_screenshot/example.png --theme dark
Paths are relative to the workspace when run through Bazel. Parent output directories are created. --theme accepts light (default) or dark; --width sets the canvas width (default 960); --scale sets pixel density (default 2, maximum 4). Line numbers identify original source lines. Long lines wrap within the canvas; continuation rows retain their original line number. Whitespace and tabs are preserved; known filename extensions receive monochrome syntax highlighting: muted comments and emphasized keywords. --language NAME overrides detection; unknown extensions stay plain. Multiline tokens retain their styling across numbered, wrapped lines. Images exceeding 30,000 pixels on either side or 100 million pixels are rejected. Reduce scale or use a smaller file in that case.
The command compiles the existing site application stylesheet and embeds pinned Liberation Mono. It adds no runtime network dependency and does not change the site theme. Chrome’s process sandbox remains enabled. Run as a non-root user on a host that supports Chromium sandboxing; startup fails if the sandbox cannot initialize. Capture only files you intend to read.
Run bazel test //tools/code_screenshot/test:capture_test for repeatable command-level checks. Bazel test outputs retain light and dark PNGs plus a JSON report.
18 - ComfyUI
Pinned local CPU image generation through Bazel
This package owns local ComfyUI launch and repeatable CPU image-generation
benchmarks. Upstream source and model weights retain their upstream ownership
under third_party. Python packages are locked locally; no host Python packages
or global configuration are installed.
Commands
The official comfy-cli is separately
packaged at version 1.25.0; it does not download the local CPU models:
bazel run //tools/comfyui:cli -- --help
Its independent hash-bearing lock lives in cli/. The repository entry
point opts out of telemetry and selects out/comfyui/cli for settings/cache
before importing the upstream command. COMFY_REPOSITORY_PROFILE selects another
task-owned profile. No host Python installation or shared CLI settings change.
The rental’s authenticated target
adds its Vault login and verified HTTPS connection. The temporary Go bridge
binds loopback, checks Linux TCP socket ownership, rejects browser origins,
refuses upstream redirects and closes when the command exits. It removes the
injected login and Vault/Vast credentials from the CLI child environment. It
forces local routing and disables detached watchers. Each authenticated command
uses a temporary profile and queries server history for later job commands;
use prompt IDs for status/download instead of cached state-file paths.
Endpoint discovery reads the final nonempty line, up to 64 KiB, after initialization logs.
The render command accepts up to 64 MiB of JSON per CLI stage. Downloaded image
files are written directly by the CLI and do not count toward that limit. Same-user processes share the
operator account’s credential boundary. The authenticated bridge requires Linux
procfs; the raw packaged CLI retains upstream platform support.
Use the authenticated target’s render command to supply workflow inputs,
upload optional reference images, and download the generated files in one
invocation. See the rental command guide.
The local tag search
is available as //tools/comfyui:tags.
bazel test //tools/comfyui/cmd/remote:remote_test exercises the real packaged CLI
against an isolated HTTPS API, including a workflow/WebSocket run, job status,
download, credential rejection and TLS hostname rejection. Its sanitized result
artifact describes transport acceptance; it does not test a GPU model.
bazel run //tools/comfyui:benchmark
bazel run //tools/comfyui -- --directory out/comfyui/session
The benchmark generates one seeded 512 by 512 SD-Turbo image with one sampling
step and twelve CPU threads. Each invocation creates a separate run directory
beneath out/comfyui/runs containing the PNG, workflow, history, server log,
and timing report. Startup time is separate from generation time; the first
generation includes checkpoint loading. --steps, --threads, --seed,
--prompt, and --timeout select benchmark inputs.
The interactive command serves the local frontend at http://127.0.0.1:8188.
It uses the same CPU-only environment and checkpoint. The thin cmd/serve launcher prepares state and executes upstream ComfyUI
directly. cmd/benchmark owns readiness checks, workflow submission, output
verification, and timing; it starts that same launcher. Interrupting either
command stops its owned server. Inputs, outputs, user data, and temporary
files stay in the selected writable directory, separate from Bazel runfiles.
The launcher serves the bundled frontend from its physical package directory.
This keeps aiohttp’s static-file symlink protections intact while allowing
JavaScript, styles, and fonts to load from Bazel-managed package inputs.
BUILD.bazel supplies --threads 12 to the public server and benchmark targets.
Append -- --threads N to override it. Both Python entry points keep the flag
optional without a default; omitting it leaves inherited or library-default
thread settings unchanged. The flag sets OpenMP, MKL, and OpenBLAS parallelism.
For interactive SD-Turbo generation, select sd_turbo.safetensors, 512 by 512,
Euler sampling with the normal scheduler, one to four steps, and CFG 1.0.
Custom nodes and partner API nodes are disabled. Hugging Face and Transformers
are configured for offline operation. bazel run is not an OS sandbox: this
configuration does not enforce a process-wide network or filesystem boundary.
Linux system libraries remain a platform prerequisite for upstream native wheels.
Dependencies
ComfyUI v0.43.0 and SD-Turbo are declared under third_party. This package uses
Bazel Python 3.13.13 and a native uv.lock rather than the shared Python dependency
set. CPU wheel availability determines the runtime selection. Updating the lock
requires network access only in the upstream sandboxed resolution action:
bazel run --action_env=HTTPS_PROXY --action_env=HTTP_PROXY --action_env=NO_PROXY //tools/comfyui:uv_lock.update
The proxy flags forward the controller’s existing configuration; omit them when
direct registry access is available. The initial build downloads several GB,
including the 5.2 GB complete model checkpoint. Subsequent inference uses the
declared local inputs without package installation or model downloads.
Model-bearing targets are tagged manual to keep multi-GB downloads out of
ordinary wildcard builds. The explicitly named commands above still build and run them.
Z-Image-Turbo CPU trial
bazel run //tools/comfyui:z_image_turbo_benchmark -- --timeout 2400
# Interactive UI at http://127.0.0.1:8188; Ctrl+C stops the server.
bazel run //tools/comfyui:z_image_turbo
The benchmark defaults to 512-square images, eight res_multistep/simple steps,
CFG 1, and twelve CPU threads. --size 1024 selects the upstream workflow’s
normal resolution. --steps, --seed, and --prompt select trial inputs.
Reports include every model file’s SHA-256. Generation time includes initial
model loading but excludes Bazel downloads and server startup.
The three model files are pinned under
third_party/co_huggingface_comfy_org_z_image_turbo: 12.3 GB diffusion weights,
8.0 GB Qwen3-4B text encoder, and 0.34 GB VAE. Bazel downloads and verifies
them; the launcher stages only declared runfiles. No additional Python
packages or custom nodes are needed. All model-bearing commands are manual.
Z-Image’s default targets require an effective cgroup v2 RAM ceiling of at most
44 GiB and zero cgroup swap before starting inference. The commands above use
a transient user systemd scope; they do not install or modify host services.
The scope can terminate a run that exceeds its limit. A Linux host with a
working user systemd manager and memory controller is required. The public
targets declare MemoryHigh=40G, MemoryMax=44G, and MemorySwapMax=0 through the
generic systemd rule, keeping Bazel’s persistent
server outside the scope. The server stores state in
out/comfyui/z-image-session; pass -- --directory <path> to override it.
The benchmark starts its private server inside the same scope. The command remains in
the foreground and holds that workspace’s Bazel run lock until stopped.
SD-Turbo retains its smaller existing runtime contract.
19 - Consul
Consul
Links
The pinned upstream binary is owned by
third_party/com_hashicorp_consul.
19.1 - Gen gossip key
Generate a gossip key and write it to a kv secret
20 - Drawio
Bazel rules for drawio
Links
Reproducible SVGs
drawio_svg in defs.bzl renders named pages from a .drawio file with the
pinned Drawio web exporter and the existing pinned Chrome-for-Testing browser.
The extraction action unpacks the web application from the Drawio AppImage;
rendering uses a small Puppeteer bridge for its export messages. Neither action
uses a host display server or accesses the network. JavaScript keeps this
adapter close to Drawio’s browser API and the existing Puppeteer dependency.
Use the rule from an explicit source-update target with write_source_files,
when a consumer requires checked-in SVGs. Normal documentation consumes the
maintained SVGs, not the rendering tool. The generated freshness tests catch stale output.
Exports use a light theme with an opaque white canvas, keeping labels and
connectors readable in both light and dark documentation themes and standalone
image viewers. The renderer adds this canvas on every export.
The adapter supplies the shadow-padding return value expected by the pinned
export API, preserving shadow filters and finite dimensions. It rejects
non-finite or empty SVG viewboxes rather than accepting malformed output.
Chrome’s process sandbox and the Bazel action sandbox remain enabled.
Run as a non-root user on a host that supports Chromium sandboxing; startup
fails if the sandbox cannot initialize. Requests outside local files and
embedded data are rejected. The renderer is intended for checked-in, reviewed
diagram sources and propagates export failures.
The repeat-render test checks byte equality, including stable SVG identifiers.
Rendering uses only the declared Liberation Fonts 2.1.5
through an isolated Fontconfig configuration. Helvetica/Arial map to Liberation
Sans, Times to Liberation Serif, and Courier to Liberation Mono. The fonts are
licensed under the SIL Open Font License 1.1; their archive retains LICENSE.
21 - F-Droid
Pinned fdroidserver environment for local F-Droid build testing
Pinned fdroidserver environment for local F-Droid builds. The wrapper
provisions an isolated Python virtualenv and delegates to fdroid. Use
//tools/gradle:gradle-wrapper for the Android app’s Gradle build; this tool
also prepares repository metadata and signs repository indexes.
The Bazel repository macro lives in defs.bzl. The Go wrapper in
cmd/fdroid_wrapper prepares unsigned indexes. The JVM signer in
internal/index_signer assembles signed JARs and delegates private key
operations to Vault Transit.
See the repository signing command
for F-Droid release preparation.
Usage
bazel run //tools/fdroid:fdroid_wrapper -- readmeta
Run from an F-Droid data directory inside the worktree containing config.yml and metadata/.
Caches go under the workspace’s ignored out/ tree.
22 - File installer
CLI tool to install files
Directory and archive installation
//tools/file_installer accepts install --target DIRECTORY SOURCE.... A
directory source creates symlinks to its files. Reinstalling an identical
link succeeds, while a conflicting destination reports an error. Traversal
skips a destination nested inside the source and accepts up to 128 directory
levels. A tar source requires an existing destination directory. Each regular
archive entry is staged beside its destination and replaced after the write
completes. Replacing a regular file retains its permissions. New files use the
archive mode subject to the process umask. An interrupted installation can be
retried.
Standalone executable installation
//tools/file_installer/cmd/install_binary copies a regular executable to a
private temporary sibling, sets mode 0755, and atomically replaces the installed
command. It accepts --source, --name, and optional --directory (default
~/.local/bin). It does not install runfiles or follow an automatic cache
refresh protocol. Missing or invalid sources leave an existing installation
unchanged. Tool-specific install targets supply their source and command name.
//tools/al:install use this
installer. Host installation requires explicit authority; validation uses an
isolated directory. Existing directory/archive installation remains separate.
23 - fj
Forgejo CLI
fj is the repository-pinned Forgejo CLI. The
delivery procedure
owns PR operations, remote selection, authentication options and capability
limits. PRs stay on the selected repository remote’s forge.
On dev1, the managed installation provides
~/.local/bin/fj. With an OAuth client configured for the instance, start its
native browser login when authorized:
fj --host https://forgejo.alwaldend.com auth login
For the configured instance, bazel run //tools/fj -- ... is the existing
Vault-authenticated wrapper. To inspect the pinned CLI’s help without invoking
that authentication flow, run:
bazel run //third_party/org_codeberg_forgejo_contrib_forgejo_cli_bin -- --help
Links
26 - Flux operator
Flux operator
Links
28 - Gazelle
Repository BUILD file generation
//tools/gazelle:gazelle runs the repository’s Gazelle language plugins.
Repository-wide directives remain in root BUILD.bazel, where Gazelle discovers
them for all packages. Root //:gazelle and //:gazelle_bin remain compatibility
entry points.
//tools/gazelle:workspace_test checks BUILD file freshness across the
root workspace in diff mode. Normal CI’s root test wildcard includes it.
Packages with hand-maintained targets use scoped Gazelle directives to
preserve explicit runtime, platform, or generated-source wiring.
The transitive-visibility extension is registered last so it also covers
packages created by other languages. Each tree selects a package group with
tools/transitive_visibility/transitive_visibility.toml. To regenerate
only these package declarations, run:
bazel run //:gazelle -- -lang=enforce_transitive_visibility
The plugin documentation
describes inheritance and standalone use. Nested modules are separate Gazelle
workspaces; root path mappings do not cross those boundaries.
//tools/gazelle:gazelle_python_manifest.update refreshes root
gazelle_python.yaml; //tools/gazelle:gazelle_python_manifest.test validates
its integrity against tools/py/uv.lock. The manifest stays at the
repository root for default ancestor discovery. It can live elsewhere if the
root BUILD file sets gazelle:python_manifest_file_name to its relative path.
29 - Git filter repo
Git filter repo
30 - Gitea
Gitea
Links
The pinned upstream binary is owned by
third_party/com_gitea_gitea.
31.1.1 - al_go_repository
al_go_repository
al_go_repository = use_extension("@com_alwaldend_src//tools/go/rules:al_go_repository.bzl", "al_go_repository")
al_go_repository.go_repository(name, importpath, sum, version)
Extension wrapper around go_repository (useless because you can just call use_repo_rule)
TAG CLASSES
go_repository
Attributes
| Name | Description | Type | Mandatory | Default |
|---|
| name | Name | Name | required | |
| importpath | importpath | String | required | |
| sum | checksum | String | optional | "" |
| version | - | String | required | |
32 - go_mod
Keep go.mod files on one Go version
go_mod
go_mod keeps every tracked go.mod file on the Go version configured in
tools/go_mod/cmd/go_mod/BUILD.bazel. It discovers files with Git, so ignored
scratch files are excluded. The updater stages each changed module beside its
destination, preserves its permissions, and replaces it after a successful
write. Rerunning resumes with the remaining mismatches. The parser accepts
up to 16 MiB per module and Git’s module path list may contain up to 4 MiB.
Update all module files:
bazel run //tools/go_mod/cmd/go_mod:update
Check without writing:
bazel test //tools/go_mod/cmd/go_mod:test
The check target is part of //:repo_quality_test.
33 - Gradle wrapper
//tools/gradle:gradle-wrapper runs the pinned Gradle distribution from
third_party/net_gradle_gradle with the Java runtime selected by the existing
rules_java toolchain. It does not download anything at run time.
The launcher derives runfile paths from those declared targets and includes
the existing rules_shell runtime; it does not hardcode external repository
names.
bazel run //tools/gradle:gradle-wrapper -- --version
Gradle caches remain under ignored out/gradle/. Set GRADLE_CACHE_ROOT to
redirect them for a task.
34 - Graphviz DOT rules
Bazel rules for exporting DOT and rendering themed SVG diagrams
dot_svg renders a DOT file on Linux using Bazel’s pinned Graphviz build.
The SVG embeds the common diagram font and has light and dark palettes.
Pass a checked-in .dot file as src, or generate one with dot_export
from a command that writes DOT to standard output.
load("//tools/dot:defs.bzl", "dot_export", "dot_svg")
dot_export(
name = "state_machine_dot",
arguments = ["state-machine", "graph"],
command = ":mlflow-vastai",
out = "state-machine.dot",
)
dot_svg(
name = "state_machine_svg",
src = ":state_machine_dot",
out = "state-machine.svg",
target_compatible_with = ["@platforms//os:linux"],
)
The MLflow Vast.ai CLI uses these rules to build its command graph.
35.1.1 - al_gzip_extension
al_gzip_extension
al_gzip_extension = use_extension("@com_alwaldend_src//tools/gzip/rules:al_gzip_extension.bzl", "al_gzip_extension")
al_gzip_extension.download(name, integrity, url)
Extension for gzip repos
TAG CLASSES
download
Attributes
| Name | Description | Type | Mandatory | Default |
|---|
| name | Name | Name | required | |
| integrity | Integrity | String | optional | "" |
| url | Url | String | required | |
35.1.2 - al_gzip_repo
al_gzip_repo
load("@com_alwaldend_src//tools/gzip/rules:al_gzip_repo.bzl", "al_gzip_repo")
al_gzip_repo(name, integrity, url)
Gzip repo
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this repository. | Name | required | |
| integrity | Integrity | String | optional | "" |
| url | Url | String | required | |
36 - Harbor
Harbor CLI
Links
37 - Helm
Bazel rules for helm
Links
37.1.1 - al_helm_binary
al_helm_binary
load("@com_alwaldend_src//tools/helm/rules:al_helm_binary.bzl", "al_helm_binary")
al_helm_binary(name, data, arguments, cd)
Helm binary
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| data | Helm chart | List of labels | optional | [] |
| arguments | Helm arguments | List of strings | optional | [] |
| cd | Cd to a directory before running bazel | String | optional | "." |
37.1.2 - al_helm_chart
al_helm_chart
load("@com_alwaldend_src//tools/helm/rules:al_helm_chart.bzl", "al_helm_chart")
al_helm_chart(name, deps, package, source)
Helm chart
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| deps | Helm chart deps | List of labels | optional | [] |
| package | Helm chart package | Label | optional | None |
| source | Helm chart source | Label | optional | None |
37.1.3 - al_helm_chart_info
AlHelmChartInfo
load("@com_alwaldend_src//tools/helm/rules:al_helm_chart_info.bzl", "AlHelmChartInfo")
AlHelmChartInfo(source, package, deps, files_info)
Information about a helm chart
FIELDS
| Name | Description |
|---|
| source | Chart sources (PackageFilegroupInfo, optional) |
| package | Chart package (tgz file) |
| deps | Chart deps (depset of AlHelmChartInfo) |
| files_info | Chart file structure (PackageFilesInfo) |
37.1.4 - al_helm_chart_lock
al_helm_chart_lock
load("@com_alwaldend_src//tools/helm/rules:al_helm_chart_lock.bzl", "al_helm_chart_lock")
al_helm_chart_lock(name, lock, lock_out)
Generate targets for a chart lock
PARAMETERS
| Name | Description | Default Value |
|---|
| name | name | none |
| lock | lock label | none |
| lock_out | parsed lock filename | none |
37.1.5 - al_helm_cmds
37.1.6 - al_helm_deps
al_helm_deps
al_helm_deps = use_extension("@com_alwaldend_src//tools/helm/rules:al_helm_deps.bzl", "al_helm_deps")
al_helm_deps.from_locks(name, integrity, locks)
Extension to download helm dependencies
TAG CLASSES
from_locks
Attributes
37.1.7 - al_helm_deps_repo
al_helm_deps_repo
load("@com_alwaldend_src//tools/helm/rules:al_helm_deps_repo.bzl", "al_helm_deps_repo")
al_helm_deps_repo(name, integrity, locks)
Helm deps repo
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this repository. | Name | required | |
| integrity | Intergrity for locks, keys are packages, values are integrity | Dictionary: String -> String | optional | {} |
| locks | Lock labels to parse | List of labels | optional | [] |
37.1.8 - al_helm_toolchain
al_helm_toolchain
load("@com_alwaldend_src//tools/helm/rules:al_helm_toolchain.bzl", "al_helm_toolchain")
al_helm_toolchain(name, helm)
Helm toolchain
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| helm | Helm binary | Label | required | |
38 - Hermes install
Run the Hermes Agent install script
Links
Usage
Run the pinned Hermes Agent install script:
bazel run //tools/hermes_install
39 - Hooks
Git hooks
The hook installer resolves the repository’s effective hooks directory through
Git. This supports linked worktrees and repositories that configure
core.hooksPath.
The installed pre-commit hook requires the Bazelisk-managed bazel on PATH.
Install or update the checked-in hooks:
bazel run //:write_git_hooks
Verify that every hook is current and executable without changing it:
bazel run //:write_git_hooks -- test
40 - Http server
Bazel rules for running http.server
40.1.1 - al_http_server_binary
al_http_server_binary
load("@com_alwaldend_src//tools/http_server/rules:al_http_server_binary.bzl", "al_http_server_binary")
al_http_server_binary(name, srcs, arguments)
Run a http server
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| srcs | Files to symlink | List of labels | optional | [] |
| arguments | Arguments | List of strings | optional | [] |
41 - Install file
Bazel rules to install files
41.1.1 - al_install_file
al_install_file
load("@com_alwaldend_src//tools/install_file/rules:al_install_file.bzl", "al_install_file")
al_install_file(name, args, install_file_label, visibility, **py_binary_kwargs)
Create py_binary target to install file
PARAMETERS
| Name | Description | Default Value |
|---|
| name | target name | none |
| args | install-file args | [] |
| install_file_label | - | "//tools/install_file/cmd/install_file:install_file_lib" |
| visibility | - | ["//:__subpackages__"] |
| py_binary_kwargs | - | none |
43 - Java tools
Repository-pinned JDK and Java command-line tools
Use //tools/java:runtime for the pinned JDK and //tools/java:keytool for
certificate and keystore operations. The keytool target carries the JDK files
it needs at runtime.
bazel run //tools/java:keytool -- -help
44 - Js
Js
Repository JavaScript tooling dependencies belong to the pnpm workspace in
tools/. Its package.json and pnpm-lock.yaml own their requested and resolved
versions. //tools:node_modules owns the Bazel package store and links; loading
the repository root package does not load the npm extension’s generated rules.
Run pnpm with //tools/pnpm, passing --dir with the absolute path to tools/
for dependency updates. Keep lifecycle scripts disabled (--ignore-scripts)
when updating the lockfile.
A security override selects patched KaTeX where Mermaid’s upstream range
retains a vulnerable release. PostCSS is pinned explicitly to supply a secure
version to its CLI and plugins’ peers. Mermaid and Three.js are exact pins;
the Dagre spacing patch is maintained with each Mermaid upgrade.
TypeScript
Use ts_project from @aspect_rules_ts//ts:defs.bzl to type-check and compile
TypeScript. It integrates with the existing js_binary, js_test, and npm
providers. tools/package.json owns the compiler pin; the TypeScript module
extension reads it with version_from and uses upstream integrity-checked
compiler archives. The Node runtime and rules_js retain their existing pins.
Keep compiler options with the consuming project. Set strict: true and
noEmitOnError: true, choose transpiler = "tsc", and set
supports_workers = 0 for the native compiler. Node programs use NodeNext
module resolution and explicit Node declarations; browser programs declare
their DOM libraries. Add the required npm type targets to deps.
Use .ts source and a project-owned package.json with "type": "module"
for ES modules. Include that manifest in srcs for compiler resolution and
in data for runtime packaging. When multiple Bazel packages share it, expose
one copy_to_bin target from the manifest’s owning package and consume that
target in both attributes. Compilation emits .js, and
declaration = True additionally emits .d.ts for dependent projects.
Consumers depend on the ts_project target and execute its generated JavaScript
through js_binary or package it for the browser. Generated JavaScript remains
a build output. The native compiler provides tsc; it does not provide the
former JavaScript tsserver entry point.
The Node,
browser, and
shared model fixtures demonstrate the direct
rule configuration and declaration dependencies. Run their full acceptance with:
bazel test //tools/js/test/typescript:typescript_test
The test runs emitted modules in pinned Node and Chrome, exercises a Three.js
vector calculation, checks a real compiler type error, and retains
node-result.json, browser.png, type-error.log, and
verification.json with output hashes in its test output directory.
45 - Jsonnet
Sandboxed generation of declared JSON outputs
This package exposes the approved Jsonnet compiler and formatter from the
pinned upstream toolchain.
It owns build execution, not application configuration or generated artifacts.
Use jsonnet_to_json from defs.bzl with an entrypoint, all imported files in deps,
and explicit package-relative outs. The entrypoint returns an object keyed by
those output paths. Bazel executes the compiler without network access and puts
native JSON in the consumer’s output tree. The compiler is an execution tool;
it is not installed on hosts or included in application/runtime dependencies.
bazel run //tools/jsonnet -- --version
bazel run //tools/jsonnet:format -- --version
The compiler’s multi-output mode and directory creation preserve model-grouped
filenames. Every import must be a declared input, including configuration JSON.
No source or generated output is downloaded at execution time.
48.1.1 - al_lua_library
al_lua_library
load("@com_alwaldend_src//tools/lua/rules:al_lua_library.bzl", "al_lua_library")
al_lua_library(name, srcs, check, stylua_config_label, stylua_label, pkg_kwargs, visibility)
Generate targets for a lua library
PARAMETERS
| Name | Description | Default Value |
|---|
| name | library name | none |
| srcs | library sources | none |
| check | if set, only these files will be checked | [] |
| stylua_config_label | - | "//tools/stylua:stylua_config" |
| stylua_label | - | "//tools/stylua" |
| pkg_kwargs | - | {} |
| visibility | visibility | ["//:__subpackages__"] |
49 - Make install
Rules to create tar archives that can be installed with make
49.1.1 - al_make_install
al_make_install
load("@com_alwaldend_src//tools/make_install/rules:al_make_install.bzl", "al_make_install")
al_make_install(name, srcs)
Create the make install executable and a filegroup
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| srcs | Make install filegroups | List of labels | optional | [] |
49.1.2 - al_make_install_binary
al_make_install_binary
load("@com_alwaldend_src//tools/make_install/rules:al_make_install_binary.bzl", "al_make_install_binary")
al_make_install_binary(name, src, arguments)
Create a binary target for a make install
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| src | Make install target | Label | required | |
| arguments | Arugments for the executable | List of strings | optional | [] |
49.1.3 - al_make_install_filegroup
al_make_install_filegroup
load("@com_alwaldend_src//tools/make_install/rules:al_make_install_filegroup.bzl", "al_make_install_filegroup")
al_make_install_filegroup(name, deps, srcs, diff_args, install_args, install_dir, pkg_prefix)
Create a make install filegroup
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| deps | Deps | List of labels | optional | [] |
| srcs | Sources to install | List of labels | optional | [] |
| diff_args | Diff args | List of strings | optional | [] |
| install_args | Install args | List of strings | optional | ["--compare", "-D"] |
| install_dir | Install directory | String | optional | "${HOME}" |
| pkg_prefix | Ignore that prefix for srcs | String | required | |
49.1.4 - al_make_install_filegroup_info
AlMakeInstallFilegroupInfo
load("@com_alwaldend_src//tools/make_install/rules:al_make_install_filegroup_info.bzl", "AlMakeInstallFilegroupInfo")
AlMakeInstallFilegroupInfo(srcs, deps, install_dir, origin, install_args, diff_args, pkg_prefix)
Describe install info for a single filegrop
FIELDS
| Name | Description |
|---|
| srcs | depset of PackageFilegroupInfo |
| deps | depset of AlMakeInstallFilegroupInfo |
| install_dir | Install directory |
| origin | Rule label |
| install_args | Args for the install command |
| diff_args | Args for the diff command |
| pkg_prefix | Ignore that prefix for srcs |
50 - Maven Install Gradle Converter
Converts rules_jvm_external maven_install.json locks to Gradle build inputs
Converts rules_jvm_external maven_install.json lock files into Gradle
version catalogs and dependency verification metadata so Bazel-built Android
apps can maintain the parallel Gradle build required for F-Droid.
Usage
Use the al_gradle_lock Starlark macro from
defs.bzl in your app’s gradle/BUILD.bazel:
load("//tools/maven_install_gradle_converter:defs.bzl", "al_gradle_lock")
al_gradle_lock(
name = "update",
lock_file = "//projects/<app>:maven_lock.json",
tool = "//tools/maven_install_gradle_converter/cmd/gradle_lock_gen",
)
Run bazel run :update_toml_write to regenerate the checked-in version
catalog. The corresponding *_write_test target fails when it goes stale.
Gradle owns verification-metadata.xml because it must record the plugin
classpath in addition to the Bazel lock. Regenerate it with:
projects/<app>/../../tools/gradle/gradle-wrapper --project-cache-dir out/gradle-wrapper/project-cache --write-verification-metadata sha256
51.1.1 - al_md_data
al_md_data
load("@com_alwaldend_src//tools/md/rules:al_md_data.bzl", "al_md_data")
al_md_data(name, srcs, deps, **kwargs)
Markdown data backed by a filegroup
Targets:
PARAMETERS
| Name | Description | Default Value |
|---|
| name | filegroup name | none |
| srcs | markdown files | none |
| deps | deps | [] |
| kwargs | filegroup kwargs | none |
52 - Mermaid
Bazel-managed Mermaid diagram renderer
This package exposes the Mermaid CLI as a repository-wide Bazel tool. Bazel
provisions the pinned Node toolchain, JavaScript dependency graph, Mermaid CLI,
and Chrome-for-Testing browser used by Puppeteer. Rendering runs as a Bazel
target or action; it does not use a host browser, download one during an npm
lifecycle hook, or fetch scripts or fonts from a CDN.
Native site diagrams embed a FontTools subset of their pinned font. The first
render supplies actual Unicode text, including decoded entities and generated
labels; delivered variants are rendered again through Mermaid’s CSS input.
Glyph outlines and metrics are retained, and each SVG remains self-contained.
The pinned Python dependency belongs to tools/py; historical themed output
retains its existing embedding behavior.
Mermaid CLI 12 uses customFontCSS to load and embed custom fonts. Native
rules require label_font_license alongside label_font; both must describe
the same face. The renderer supplies a local stylesheet, subset font, and
license to the CLI, which writes the SVG without geometry post-processing.
theme.json owns the diagram appearance. It applies a
documentation palette, typography, layout, and the handDrawn look to every
diagram, so rendered work shares one visual contract instead of Mermaid’s
built-in default. Shapes stay semantic: () and other inherently rounded
shapes render rounded, while [] boxes render as sketched rectangles. Nothing
forces every node into a rounded outline.
The mermaid_svg rule and the mmdc target both apply the theme by default.
A diagram can override any part of it with its own Mermaid directive, which
Mermaid merges over the file config:
%%{init: {"look": "classic"}}%%
flowchart LR
a[Square] --> b(Rounded)
Node label paragraphs have 2px of horizontal padding. The pinned handwriting
font can paint beyond a string’s measured advance: openai.com measures 78px
but its final glyph reaches 79px. Mermaid clips HTML labels to their measured
foreignObject, so the padding reserves room for that overhang before layout.
Label foreignObject elements also use overflow: visible: if an SVG viewer
falls back to a wider font, its glyphs can extend into the node’s existing
padding instead of being cut off at the narrower measured frame. A fallback
Arial render reproduces right-edge clipping on the hostname without this rule.
The rule selects .label > * because Mermaid lowercases element selectors;
foreignobject would not match the case-sensitive SVG foreignObject name.
themeCSS boxes every edge label and every cluster title, so an annotation
reads as a caption instead of sitting on the edge line. The rule styles the
<p> inside a real label and leaves .labelBkg transparent; styling
.labelBkg directly would draw a stray box wherever an edge carries no text.
Mermaid emits an empty label plate for unlabelled edges under the dagre
renderer but omits it under ELK, so the rule is what the test asserts rather
than any particular empty element.
Each boxed label carries a 3px margin. Under the dagre renderer Mermaid sizes
a label’s <p> to the text only, so the frame clips the outer half of the 1px
border and a label appears to have a missing right edge; the margin keeps the
border inside the clip rect. Under ELK the frame already includes the margin,
so the value there is breathing room rather than a correctness fix.
The cluster title plate pins font-size: 13px. ELK sizes a container from the
width of its own title plate, so a child container whose title is wider than
its parent’s escapes the parent on both sides. Nesting a hostname title inside
a short parent title is the case that exposes this: at the inherited 16px
the child measured 333px against a 302px parent and escaped 20px per side,
while 13px fits it with 7px of clearance per side. The plate is a container
label, not body text, so the smaller size also keeps it visually subordinate.
flowchart.defaultRenderer selects dagre-wrapper, Mermaid’s Dagre renderer.
Diagrams use left-to-right flow by default. Dagre’s nodeSpacing and
rankSpacing control spacing between nodes and ranks, while the title styling
below keeps nested containers readable.
flowchart.subGraphTitleMargin.top is negative on purpose. Under dagre a
nested cluster keeps a fixed 20px inset from its parent that does not grow with
nodeSpacing, rankSpacing, padding, or this margin, so the parent title
would be overlapped by the container nested inside it, and the negative margin
is the only thing that lifts it clear. ELK does not need the lift, but both
renderers share this one config, so the value stays and keeps the title on the
cluster border. Remove it only after re-checking a diagram with nested
subgraphs.
The cluster title additionally forces line-height: 1, which keeps the plate
short enough to sit on the border consistently instead of spilling past it.
handDrawnSeed is fixed, so the sketch jitter is stable rather than different
on every render. Pass theme on the rule or a later -c argument to the CLI
to replace the whole config for one diagram; because a second -c file
replaces rather than merges, override only the specific keys you need with a
directive.
Paint order
Mermaid emits a container title in <g class="cluster-label"> inside
<g class="clusters">, and emits that group before the edges, the edge labels,
and the nodes. SVG paints in document order and offers no other layer control:
z-index needs a CSS-positioned box and does not reorder SVG elements, and
paint-order only orders fill, stroke, and markers within a single element.
An edge that crosses a container border therefore paints over the title plate
and appears to run through the title text. Mermaid exposes no z-order, layer,
or paint-order configuration key, so this is fixed by rewriting the SVG rather
than by a theme setting.
The current theme already does everything CSS can do here, so the remaining
crossing is the one case CSS cannot reach. The title plate is the topmost paint
at its own plate coordinates, and on the host_bot diagram one edge crosses the
External services plate and two cross the LLM BM plate. A rasterised check
draws a white plate and then a red line over it and reads the pixel at the
crossing: reordering the document turns that pixel white, while z-index,
z-index with position:relative or position:absolute, isolation:isolate,
paint-order, transform:translateZ(0), will-change:transform, a
filter:drop-shadow stacking context, and opacity:0.999 all leave it red.
Only document order moves an SVG group above a later sibling, which is why the
lift is a rewrite and not a rule.
cmd/render/paint_order.mjs moves every title group to the end of the outer
root group after Mermaid writes the file. Dagre places nested containers in
translated groups; the lift composes their ancestor transforms onto each title
so its position stays unchanged. Empty, self-closing paint layers do not affect
the group scan. A browser test checks both title coordinates and visible
stacking. Both entry points apply the lift, so a diagram rendered through
mermaid_svg and the same diagram rendered through mmdc paint identically.
mmdc rewrites the file named by -o or --output; an SVG printed to stdout
is not rewritten.
Diagram direction
Write flowchart LR for left-to-right flow. Direction belongs to the diagram
source; the shared theme selects Dagre but does not override an explicit
diagram direction. Use another direction when the diagram or the user requires
it.
Subgraphs can declare direction TB, but Mermaid ignores that direction when
their internal nodes connect outside the group. Both Dagre and ELK exhibit
this limitation on the T3 Code graph, so verify the rendered arrangement rather
than assuming a direction declaration took effect.
Actors
An actor is an ordinary rounded node marked with the actor class. The theme
owns the figure: a .actor div rule paints a hand-drawn stick figure as a
background-image and reserves room with padding-left. A diagram therefore
carries only its label text:
remote("Actor")
classDef actor font-style:normal;
class remote,intranet actor
The classDef is required even though the theme supplies the appearance.
Mermaid emits a node’s class attribute only when a classDef declares it, so a
bare class statement leaves the node unstyled and the figure does not paint.
Keeping the figure in the theme rather than in the diagram means the ~1.2 KB of
base64 SVG is written once, every actor node shares it, and the diagram source
states topology only. Sizing is fixed by the theme, so all actors match: the
figure plus the renderer’s padding lands an actor node at the same height as a
single-line service node.
The rule rides in every rendered document, including diagrams with no actor
node, where it adds about 1.3 KB to the inline stylesheet. That is the cost of
owning appearance centrally; it is acceptable because the rule is inert without
an actor node and every diagram already carries a much larger stylesheet. The wobble is baked into the path coordinates with a
fixed seed rather than applied through an SVG filter, so the shared figure
carries no <defs> id that would collide when the background repeats.
Branching edges
Use a visible junction node when several outgoing edges share one label:
codex ---|"Inference"| inference@{ shape: junction }
inference --> openai
inference --> openrouter
The incoming segment carries the shared label without an arrowhead, and the
outgoing segments point to their respective targets. The junction is a real
flowchart node and affects layout, so inspect the rendered spacing. This is
the form used by the maintained T3 Code diagram. The separate
architecture-beta diagram type has its own junction declaration syntax.
Layout width
Dagre uses nodeSpacing between nodes in a rank and rankSpacing between
ranks. For an LR diagram, rank spacing contributes to width and node spacing
contributes to height. These settings do not impose a maximum canvas width;
labels, topology, and nested groups also affect the result. Check the rendered
diagram at its intended display size before adjusting spacing or direction.
Plain renders
mermaid_svg(..., plain = True) and MERMAID_PLAIN=1 render with Mermaid’s own
defaults instead of the repository appearance: no theme, no paint-order
post-processing, and no pinned fonts. The output is deliberately neither themed
nor hermetic, and exists to compare a diagram against the upstream appearance.
A plain action declares neither the theme nor the fonts as inputs, so it cannot
depend on them by accident; //infra/dev:rendered_plain is a
worked example. Plain output is not published and not committed.
upstream-theme.json is the themed counterpart to that
opt-out. It selects Mermaid’s built-in default theme and pins the label family
to a font the renderer already carries, so the result is hermetic like any other
render and shows the upstream appearance rather than a host-dependent one. Use
it when a consumer has to show the contrast between Mermaid’s own look and the
repository theme, as the blog post on this work does:
mermaid_svg(
name = "example_default",
src = "example.mmd",
out = "rendered/example-default.svg",
theme = "//tools/mermaid:upstream-theme.json",
)
This is a comparison input, not a second appearance the repository maintains. It
exists so a before-and-after pair renders from one source through the same
pipeline; a diagram’s own look still comes from theme.json.
Native site diagrams
Use mermaid_diagram from
projects/alwaldend.com/pkg/mermaid/defs.bzl
for maintained non-blog diagrams. Its aggregate target builds .svg,
.dark.svg, .webp, and .dark.webp from one source and output stem.
The _svg target builds both SVGs. The _webp and _dark_webp targets
build one raster each. Set webp_scale and webp_aspect_ratio to configure
both rasters together.
The macro defaults to the native //internal/assets:mermaid_theme target.
The theme bundles generated configuration and light/dark palette JSON with
the pinned font and its license. Its preset draws rounded caption
plates using Mermaid’s themeCSS and flowchart settings. The site’s compact
preset uses basis curves and flowchart.edgeSpacing; the
pinned dependency patch
passes the latter through to Dagre before layout, including nested subgraphs.
Native rules accept a bundled theme target. MermaidThemeInfo and
mermaid_theme in theme.bzl define its configuration, palette, font, and
license files. A standalone JSON configuration can instead supply separate
palette JSON, label_font, and label_font_license inputs. A palette maps
light and dark to concrete Mermaid theme-variable colors; the renderer
reads it directly and exposes matching --mermaid-* properties on the diagram
root for input themeCSS. mermaid_svg requires dark_out, while
mermaid_webp selects one color_scheme. Font embedding uses the CLI’s CSS
input. Returned SVG bytes are written directly without geometry or color
post-processing. The historical non-native JSON theme API remains available.
Both SVGs are packaged beside each other. The site selects the .dark.svg
sibling using its existing theme attribute and always prints the light image.
A diagram used by documentation and a historical blog post can expose both
render targets from one authoritative .mmd source. Blog consumers keep their
original mermaid_svg target and its existing appearance.
Raster renders
mermaid_webp renders the same diagram source to a WebP image for a consumer
that has to upload the file to a service. Some upload endpoints accept only a
fixed set of raster media types and reject image/svg+xml, so such a consumer
cannot use the SVG rule at all.
load("//tools/mermaid:defs.bzl", "mermaid_webp")
mermaid_webp(
name = "rendered",
src = "architecture.mmd",
out = "rendered/architecture.webp",
)
The rule projects the mermaid_svg document to a raster. By default it renders
the historical themed SVG first — same shared theme, same pinned browser and
fonts, same paint-order pass — then has the pinned browser encode that document
to WebP. Set native = True and pass the same bundled theme as a native SVG target to encode that target’s appearance.
Set color_scheme = "dark" for its dark appearance; the default remains
"light". Native rendering reads the selected palette data, embeds
the selected font through Mermaid’s CSS input, and sends the returned SVG straight to the
existing encoder without SVG post-processing. A native theme supplies the
palette. Select the dark mode in a native render to produce a fixed dark
appearance for page embeds, social cards, and service uploads.
Encoding stays inside the hermetic graph and adds no image-conversion
dependency. The raster is authored at the diagram’s
natural size and scaled by the rule’s scale (default 1). Set scale = 2
when a consumer needs higher pixel density for text or re-encoding. A raster render
always uses the maintained appearance; it has no plain opt-out, because a
plain raster could not show the contrast a comparison needs any more reliably
than the SVG rule’s.
WebP canvases default to aspect_ratio = [5, 2]. The
encoder reduces the two positive integer terms and adds the selected theme’s
background around the scaled diagram. It uses the smallest whole-pixel canvas
with that exact ratio that contains the original image, centers the diagram,
and never crops or stretches it. SVG output is unaffected. Set aspect_ratio = []
for the natural raster canvas, or select another positive integer pair. The CLI
uses the same default; --aspect-ratio natural selects natural output, and two
repeated numeric --aspect-ratio flags select another ratio.
scale must be a positive integer, and the
final image must fit WebP’s 16383-pixel limit in each dimension.
Consumers that must keep the image as a checked-in asset obtain it from the
rule’s output rather than by hand, so the asset can be regenerated and compared
against a fresh render. The .mmd source stays authoritative. Blog posts keep
the raster render beside index.md by copying it through write_source_files,
as the diagram skill describes.
Tests
test/renderer/renderer_test.go renders fixture diagrams through the
mermaid_svg rule and asserts the contract of the theme: the documentation
palette and hand-drawn node class survive, the built-in lavender colors do not,
labels are measured through the pinned fonts, and the label plates keep their
border slack. It also asserts that every container title is written after the
nodes, which is the paint order cmd/render/paint_order.mjs produces and the
property that keeps an edge from drawing over a title. The same package renders
a WebP fixture and asserts the raster reproduces the SVG canvas at the rule’s
scale, so a raster that stopped following the maintained document fails there.
test/renderer/native_raster_test.mjs compares light and dark native WebPs with
their separately built SVGs, checks each selected site palette, visible label
pixels, and the embedded site font, and verifies unchanged scaled canvas
geometry. The test saves each reference and actual image and a JSON measurement
report in its undeclared outputs for repeatable inspection.
test/renderer/aspect_ratio_test.mjs checks horizontal and vertical padding,
minimal exact-ratio dimensions, unchanged content scale, and theme backgrounds
against independently rendered SVG references. It also exercises invalid size
and ratio inputs, and saves reference rasters and measurement reports.
cmd/mmdc/mmdc_test.go
drives the interactive CLI and re-renders under a Fontconfig pointed at a
monospace-only pool; a byte-identical result shows the CLI resolved text
through the pinned fonts.
Hermetic rendering
Mermaid measures label text through Fontconfig, so a renderer that follows the
host would produce different canvas geometry on every machine. Both entry
points instead expose only the repository’s pinned fonts to Chrome:
cmd/render/fontconfig.mjs writes a Fontconfig file whose sole <dir> values
are the directory holding the pinned handwriting face and the directory holding
the pinned Liberation set, and whose aliases map the families the theme requests
onto them. The same file is applied by the build action and by an interactive
mmdc run, so both resolve identical text metrics.
The generated Fontconfig must use absolute paths. Chrome is a separate process
from the launcher, and a relative <dir> resolves against whatever working
directory it inherits rather than the action’s execroot. Passing a caller’s own
-p/--puppeteerConfigFile hands full control of the browser launch, and
including the font aliases in it, to that caller.
Pinned fonts fix the metrics a render measures with, but not the metrics a
consumer displays those glyphs with. A documentation page embeds an SVG through
<img>, and an SVG loaded that way is an isolated document: it cannot see the
page’s webfonts, loads no network font, and falls back to whatever the viewer’s
system provides. A host font is wider than the pinned handwriting face, so
github.com overflowed the label box Mermaid sized with the pinned font and
appeared clipped, even though the file was correct. cmd/render/embed_font.mjs
therefore inlines the pinned face as a @font-face data URI in every themed
document, so the glyphs travel with the SVG and the label metrics match
everywhere, including in a viewer that can load no webfont at all. The rule
adds about 50 KB to a rendered diagram; that is the cost of an image that is
correct wherever it is displayed. Its family name is read from the font’s own
name table rather than hard-coded, so a font swap cannot silently desync it
from the theme.
The JavaScript launcher runs from Bazel’s output tree. Pass absolute paths when
rendering source-tree files directly:
repo_root="$PWD"
bazel run //tools/mermaid:mmdc -- \
-i "${repo_root}/path/to/diagram.mmd" \
-o "${repo_root}/path/to/diagram.svg"
Declare a maintained diagram as a mermaid_svg action and feed the output to
its consumer, which uses declared Bazel paths and needs no absolute-path
handling. The diagram skill defines direct
documentation consumption and checked-in publication assets for blog posts.
The .mmd remains the authoritative diagram source in both cases.
The pinned upstream binary is owned by
third_party/com_google_chrome_headless_shell.
52.1 - OpenSpec
52.1.1 - Specifications
52.1.1.1 - Mermaid rendering
52.1.1.1.1 - mermaid-rendering Specification
Purpose
Provide hermetic SVG and raster diagram outputs that share their selected
theme, font, and canvas geometry, with reproducible publication assets.
Requirements
Requirement: Raster diagram renders
The tool SHALL expose a rule that renders a Mermaid source to a raster image in
a media type a service upload endpoint can accept, beginning with WebP. The
raster render SHALL reuse the selected SVG render contract rather than defining a
second appearance: the same theme, the same pinned browser and fonts, and
the same post-processing policy as the SVG rule. Native rendering SHALL use
the consumer’s palette and font and encode the selected light or dark SVG without post-processing;
the default SHALL retain the historical theme and paint-order pass.
Encoding MUST go through the pinned
browser, so the rule introduces no image-conversion dependency. The render SHALL
be a projection of the SVG render — the same maintained document, encoded to a
raster — rather than a second layout. The render SHALL be hermetic — no host
browser, host font, or network fetch — and deterministic for a given source,
theme, and configuration.
Scenario: Render a diagram to a raster image
- WHEN a diagram source is rendered through the raster rule
- THEN it produces an image in a service-acceptable media type
- AND the render uses the shared theme, the pinned browser, and the pinned
fonts rather than host or network inputs
- WHEN the same diagram source is rendered to SVG and to the raster format
- THEN both renders apply the same selected theme and post-processing policy
- AND neither render introduces an appearance of its own
- AND the raster content reproduces the SVG render’s geometry at the rule’s scale, with selected canvas padding
Scenario: Render a native site diagram
- WHEN the raster rule selects native mode with a palette and label font
- THEN it encodes the selected native SVG with the same palette and font
- AND it performs no historical SVG post-processing
- AND native mode and a palette must be selected together
Scenario: Reproduce the natural canvas
- WHEN a consumer explicitly selects natural raster proportions
- AND the diagram’s natural canvas differs from the browser’s default replaced-element size
- THEN the raster is captured at the SVG’s own
viewBox geometry rather than
the default size - AND its canvas equals the SVG render’s geometry at the rule’s scale
- WHEN the raster rule’s inputs are inspected
- THEN it uses the pinned browser to encode the raster format
- AND it declares no image-conversion tool or library
Scenario: Select a native raster color scheme
- WHEN a native raster selects
color_scheme as light or dark - THEN it uses the corresponding consumer palette media values
- AND an omitted color scheme retains the light default
- AND both schemes preserve SVG geometry and label visibility
- AND unsupported schemes and dark selection without native mode are rejected
Requirement: Raster renders belong to their source
A raster render SHALL be reproducible from the diagram source, with the source
remaining authoritative. A consumer that must keep the image as a checked-in
asset SHALL obtain it from the rule’s output rather than by hand, so the asset
can be regenerated and compared against a fresh render.
Scenario: Keep a checked-in raster asset current
- WHEN a consumer checks in a diagram’s raster render
- THEN the asset is the rule’s output for that source
- AND the asset can be compared against a fresh render of the same source
Scenario: Update the source
- WHEN a diagram source changes
- THEN its raster render changes when regenerated from the new source
- AND the source remains the artifact an author edits
Requirement: Default raster canvas ratio
WebP rendering SHALL default to a 5:2 width-to-height canvas through the Bazel
rule, CLI, and encoder. Padding SHALL center the scaled diagram on the smallest
exact-ratio canvas that contains it without cropping or stretching its content.
Explicit positive-integer ratios SHALL remain supported. An explicit natural
canvas selection SHALL omit ratio padding. SVG geometry SHALL remain unchanged.
Scenario: Omit the raster ratio
- WHEN a raster consumer omits its aspect ratio
- THEN the WebP canvas has exact 5:2 proportions
- AND content scale, labels, and theme colors are preserved
Scenario: Select natural geometry
- WHEN a rule or encoder selects an empty ratio list, or the CLI selects
natural - THEN the raster canvas follows the scaled natural SVG dimensions
Scenario: Override the ratio
- WHEN a consumer selects another positive-integer width and height ratio
- THEN the renderer pads to that exact ratio instead of 5:2
Requirement: Natural-size raster default
WebP rendering SHALL default to scale 1, using the ceiling of each natural SVG canvas dimension before optional aspect-ratio padding. Explicit positive integer scales SHALL remain supported and multiply those dimensions before padding.
Scenario: Omit raster scale
- WHEN a WebP render omits its scale
- THEN the diagram is rasterized at its natural size
- AND optional aspect-ratio padding retains the existing centering and exact-ratio behavior
Scenario: Request a higher raster scale
- WHEN a WebP render explicitly selects scale 2 or 3
- THEN the diagram’s pixel dimensions are multiplied by that scale
- AND its selected appearance and aspect-ratio padding are preserved
53 - Molecule QEMU tests
Ansible-native lifecycle for disposable Fedora smoke guests
//tools/molecule:smoke_test boots the pinned Fedora 44 cloud image in a
local QEMU guest. The test uses //tools/ansible:molecule and native
create, prepare, converge, idempotence, verify, and destroy
actions. It verifies SSH connectivity, the Fedora version, and a file
written by Ansible.


Diagram source
The smoke target requires Linux x86-64 with QEMU and OpenSSH. Bazel builds
the read-only cloud-init seed ISO from fixed metadata and the Molecule CA
public snapshot using the shared
ISO image rule. The ISO build is
offline. At test time, the AL wrapper uses the Molecule test AppRole
to generate a fresh keypair and obtain a signed fedora certificate from
Vault. The wrapper deletes its key material when the invocation ends.
bazel build //tools/molecule:seed_iso
bazel test --test_env=HOME //tools/molecule:smoke_test //tools/molecule:failure_test \
//tools/molecule:cancellation_test
The test launcher uses HOME to find the Vault token helper. Molecule and
Ansible run with a separate test home and the temporary SSH credential.
The additional modes exercise an assertion failure and interruption during
verification. Molecule runs its teardown after the assertion fails. An
interrupt can exit before teardown, so the cancellation test invokes the
same molecule destroy action with a bounded timeout. Use Bazel’s local
test sandbox for process isolation when aborting the whole Bazel invocation.
The test allocates an SSH port bound to loopback and uses
temporary keys, an isolated inventory, and a fresh overlay. The Molecule
phase log is available in the Bazel test outputs.
57 - Nogo
Golang static analyser
The analyzer configuration preserves generated upstream code. nilness ignores
only OpenAPI Generator 7.26.0’s redundant named-result nil check in the X SDK’s
and shared Vast.ai SDK’s generated client.go; handwritten source and
other analyzers remain enabled.
Links
58 - Nping
Nping - Network packet generation tool & ping utility
Links
60 - OpenAPI Generator
Pinned OpenAPI Generator CLI and offline Bazel source generation
The wrapper runs the unmodified upstream CLI with Bazel’s pinned Java runtime.
The JAR and integrity pin belong to
third_party/org_openapitools_openapi_generator.
bazel run //tools/openapi_generator -- version
bazel run //tools/openapi_generator -- help generate
openapi_generate in defs.bzl declares the schema and configuration as inputs
and returns one directory artifact. Generation runs offline in the normal Bazel
sandbox. Its output stays in Bazel’s output tree. Consumers can filter the tree
to the source language they need and compile it using their normal language
rules, as the X SDK does for Go. Remote schema
references must be vendored before sandboxed generation.
Generation diagnostics are retained in a declared .log artifact rather than
printing a message for every generated file. Request --output_groups=logs
on the generation target to materialize the complete upstream log, for example:
bazel build --output_groups=logs //internal/x_sdk:generated_client
61 - Opencode
Opencode - The open source AI coding agent
Links
62 - OpenSpec
Pinned OpenSpec CLI and repository specification validation
This package runs the upstream OpenSpec CLI with
Bazel’s pinned Node toolchain. tools/rules_openspec/package.json pins
@fission-ai/openspec to 1.11.0; tools/rules_openspec/pnpm-lock.yaml records the package
integrities and transitive dependency versions. Package lifecycle scripts are
disabled. No global npm installation is needed.
Each component owns an OpenSpec workspace at <owner>/openspec/. The
repository’s evolution belongs to infra/src/openspec/,
which is the default for the runnable target. Run commands from the enclosing
repository root; OPENSPEC_PROJECT selects a different owner directory:
bazel run //tools/openspec -- --version
bazel run //tools/openspec -- list --specs --json
bazel run //tools/openspec -- status --change <change-name> --json
bazel run //tools/openspec -- validate --all --strict --no-interactive
OPENSPEC_PROJECT=tools/agents bazel run //tools/openspec -- list --specs --json
OPENSPEC_PROJECT=infra/vault bazel run //tools/openspec -- list --specs --json
OPENSPEC_PROJECT is a repository launcher setting, not an upstream CLI flag.
It is relative to the enclosing repository root, and OpenSpec reads and writes
that owner’s source artifacts directly. Standalone nested projects use the
same root invocation, for example OPENSPEC_PROJECT=tools/rules_skills.
Run the workspace’s sandboxed validation suite from the repository root.
bazel test //infra/src/openspec:validate_test
bazel test //tools/agents/openspec:validate_test
The suite runs the CLI in strict mode against declared workspace runfiles.
The current check validates specifications and active changes. The archive
check verifies that archived task lists are complete. Requirement scenarios
still need evidence from their owning implementation.
Gazelle generates the source target and validation suite from the workspace’s
openspec/config.yaml. See the OpenSpec Gazelle extension.
The launcher disables telemetry and update checks. Tests isolate the CLI’s
XDG config and data paths in Bazel’s test temporary directory. Commands that
create, edit, or archive changes modify source artifacts as documented by the
upstream CLI.
Update the version in tools/rules_openspec/package.json, then use the owning pnpm workflow
described in tools/js to regenerate its lock with lifecycle
scripts disabled. Re-run the version command and the workspace validation suite after
upgrading.
62.1 - OpenSpec
62.1.1 - project-rules-openspec Specification
Purpose
Define reusable Bazel validation and execution behavior for owner-local OpenSpec workspaces.
Requirements
OpenSpec validation
The system SHALL validate one owner-local OpenSpec workspace in a sandbox using the pinned OpenSpec CLI.
Scenario: current validation
- WHEN a caller runs the validation target
- THEN OpenSpec validates current specifications and active changes with strict mode
Scenario: archived validation
- WHEN a caller requests archived validation
- THEN OpenSpec validates completed archived changes with strict mode
63 - OpenSpec Gazelle
Gazelle extension for owner-local OpenSpec workspaces
The OpenSpec extension generates openspec_workspace(name = "source") and
openspec_validate_test(name = "validate_test") in directories named
openspec that contain config.yaml. The workspace’s source glob stops at
Bazel package boundaries. The generator preserves existing attributes and
leaves packages with conflicting target names alone.
The repository’s Gazelle binary includes the extension. A custom binary can
include the public language library in //tools/rules_openspec_gazelle/gazelle,
or use the plugin-only :gazelle_openspec binary. The extension loads
@rules_openspec//rules:defs.bzl using the consumer’s Bzlmod repository mapping.
The root invocation supplies the equivalent in-tree label.
64 - Ops
Ops CLI binary
Links
65.1.1 - al_apply_patches
al_apply_patches
load("@com_alwaldend_src//tools/patch/rules:al_apply_patches.bzl", "al_apply_patches")
al_apply_patches(name, src, patches, visibility, **kwargs)
Create a genrule applying patches
PARAMETERS
| Name | Description | Default Value |
|---|
| name | genrule name | none |
| src | source archive label | none |
| patches | patches label | none |
| visibility | visibility | ["//:__subpackages__"] |
| kwargs | other genrule kwargs | none |
66.1.1 - al_genrule_src
al_genrule_src
load("@com_alwaldend_src//tools/pkg/rules:al_genrule_src.bzl", "al_genrule_src")
al_genrule_src(name, srcs, visibility)
Create a filegroup and a genrule generating a tar archive
PARAMETERS
| Name | Description | Default Value |
|---|
| name | genrule name | none |
| srcs | source labels | [] |
| visibility | - | ["//:__subpackages"] |
66.1.2 - al_pkg_basic_naming
al_pkg_basic_naming
load("@com_alwaldend_src//tools/pkg/rules:al_pkg_basic_naming.bzl", "al_pkg_basic_naming")
al_pkg_basic_naming(name, deps)
Variables for @rules_pkg
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| deps | Deps to merge | List of labels | optional | [] |
66.1.3 - al_pkg_extract_dir
al_pkg_extract_dir
load("@com_alwaldend_src//tools/pkg/rules:al_pkg_extract_dir.bzl", "al_pkg_extract_dir")
al_pkg_extract_dir(name, src, out, arguments)
Extract an archive into a TreeArtifact
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| src | Archive to unpack | Label | required | |
| out | Output directory name | String | optional | "" |
| arguments | Additional arguments | List of strings | optional | [] |
66.1.4 - al_pkg_tar_combined
al_pkg_tar_combined
load("@com_alwaldend_src//tools/pkg/rules:al_pkg_tar_combined.bzl", "al_pkg_tar_combined")
al_pkg_tar_combined(name, srcs, strip_components, **kwargs)
Create a genrule combining several tars into one
PARAMETERS
| Name | Description | Default Value |
|---|
| name | genrule name | none |
| srcs | dicts tar archives ({“label”: “tar label”, “dir”: “target dir”}) | [] |
| strip_components | value of –stip-components | 2 |
| kwargs | other genrule kwargs | none |
66.1.5 - al_unpack_archives
al_unpack_archives
load("@com_alwaldend_src//tools/pkg/rules:al_unpack_archives.bzl", "al_unpack_archives")
al_unpack_archives(name, srcs, out)
Unpack several archives using tar into a directory
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| srcs | - | List of labels | required | |
| out | - | String | optional | "" |
70 - Prettier
Prettier
Links
71 - Print deps
Aspect to print deps
71.1.1 - al_print_deps
al_print_deps
load("@com_alwaldend_src//tools/print_deps/rules:al_print_deps.bzl", "al_print_deps")
al_print_deps()
ASPECT ATTRIBUTES
ATTRIBUTES
72.1.1 - al_proto_docs
al_proto_docs
load("@com_alwaldend_src//tools/proto/rules:al_proto_docs.bzl", "al_proto_docs")
al_proto_docs(name, src, prefix, visibility, renames)
Generate protobuf documentation
PARAMETERS
| Name | Description | Default Value |
|---|
| name | name | none |
| src | protobuf source file | none |
| prefix | - | None |
| visibility | visibility | None |
| renames | - | None |
73 - Py
Python rules
This package owns the repository Python dependency manifest pyproject.toml
and native uv.lock. Update it with //tools/py:uv_lock.update; root
//:uv_lock.update is an alias. Bazel’s pip.parse reads uv.lock directly,
and Gazelle uses that same lock to validate its import manifest. There are no
requirements-file exports or separately maintained pip locks.
BUILD files load lock directly from @rules_python//python/uv:lock.bzl with
out = "uv.lock", which selects native uv lock. Build uv_lock to regenerate
the lock without modifying source. Run uv_lock.update to replace the checked-in
file, then review package versions, hashes and platform/Python markers. Extras
are declared in pyproject.toml and retained in the native lock.
The same workflow owns component-local manifests and locks in //tools/ansible,
//tools/ykman, //projects/autoscroll and //projects/infinitime. Update each
through its own uv_lock.update target. Lock generation needs PyPI access, so
only the upstream resolution action carries requires-network; it remains
sandboxed. All locking targets are manual. Normal consumers use checked-in
locks without running resolution, and there is no custom lock freshness test.
include.MODULE.bazel pins uv and Python 3.14.4, the newest stable runtime in
rules_python 2.4.2’s bundled version catalog. This updates Bazel-managed Python
without changing the host interpreter or adding a custom runtime archive.
The root pyproject.toml contains only shared tool settings. Ruff and other
Python tools discover it from source packages, and the repository checker
targets use //tools/py:pyproject to select those settings explicitly. The
manifest in this package contains only project metadata and dependencies.
The repo-python skill owns the repository Python
implementation and review procedure, including mandatory type hints. Its
discovery link is generated by //.agents:write_skills.
73.1.1 - al_genrule_with_wheels
al_genrule_with_wheels
load("@com_alwaldend_src//tools/py/rules:al_genrule_with_wheels.bzl", "al_genrule_with_wheels")
al_genrule_with_wheels(name, wheels, srcs, cmd, **kwargs)
Regular genrule with wheels added to ${PYTHONPATH}
PARAMETERS
| Name | Description | Default Value |
|---|
| name | genrule name | none |
| wheels | list of wheel labels | none |
| srcs | srcs for the genrule | [] |
| cmd | genrule cmd | [] |
| kwargs | other genrule kwargs | none |
73.1.2 - al_py_binary_shell
al_py_binary_shell
load("@com_alwaldend_src//tools/py/rules:al_py_binary_shell.bzl", "al_py_binary_shell")
al_py_binary_shell(name, deps, srcs, shell_type, shell_label, **kwargs)
Create a py_binary target that allows you to run commands in proper python environment
PARAMETERS
| Name | Description | Default Value |
|---|
| name | target name | none |
| deps | py_binary deps | [] |
| srcs | py_binary srcs | [] |
| shell_type | ${BAZEL_PYTHON_SHELL_TYPE} | "python" |
| shell_label | - | "//tools/py/cmd/bazel_python_shell:bazel_python_shell_lib" |
| kwargs | other py_binary kwargs | none |
73.1.3 - al_py_checker
al_py_checker
load("@com_alwaldend_src//tools/py/rules:al_py_checker.bzl", "al_py_checker")
al_py_checker(name, tool, args_bin, args_test, test_size, disable_fix, **kwargs)
Create -fix and -test targets for a python checker
PARAMETERS
| Name | Description | Default Value |
|---|
| name | Name prefix | None |
| tool | Tool label | None |
| args_bin | Args for the binary target | None |
| args_test | Args for the test | None |
| test_size | - | "small" |
| disable_fix | If set, do not create fix target | False |
| kwargs | Kwargs for both targets | none |
73.1.4 - al_py_checkers
al_py_checkers
load("@com_alwaldend_src//tools/py/rules:al_py_checkers.bzl", "al_py_checkers")
al_py_checkers(name, srcs, isort_label, black_label, mypy_label, flake8_label, pyproject_label)
Generate -fix and -test targets for python checkers
PARAMETERS
| Name | Description | Default Value |
|---|
| name | - | none |
| srcs | list of source file labels | none |
| isort_label | - | "//tools/isort" |
| black_label | - | "//tools/black" |
| mypy_label | - | "//tools/mypy" |
| flake8_label | - | "//tools/flake8" |
| pyproject_label | - | "//tools/py:pyproject" |
74 - Qt
Qt rules
Links
Hermetic Qt
The module configuration downloads SHA-256-pinned Qt 6.8.3 distributions via
rules_qt and registers its build tools. Bazel builds do not require Qt under
/opt or another host installation.
75 - Readme tree
Tool to parse README.md files
Example
bazel run tools/readme_tree -- parse -g -C "${PWD}" .
76 - Replace section
Replace sections of files
77 - Repo map
Extension to download several versions of a repository depending on a platform
77.1.1 - al_repo_map
al_repo_map
al_repo_map = use_extension("@com_alwaldend_src//tools/repo_map/rules:al_repo_map.bzl", "al_repo_map")
al_repo_map.download(name, build_file_content, build_file_native_binary, download_type, executable,
repos, strip_prefix)
Extension to create several repos from a map
TAG CLASSES
download
Attributes
| Name | Description | Type | Mandatory | Default |
|---|
| name | Name | Name | required | |
| build_file_content | Build file content | String | optional | "" |
| build_file_native_binary | Args for a native binary build file | Dictionary: String -> String | optional | {} |
| download_type | Download type | String | optional | "http_archive" |
| executable | Field executable for http_file | Boolean | optional | False |
| repos | Map of repos | Dictionary: String -> List of strings | required | |
| strip_prefix | Strip prefix | String | optional | "" |
78 - Repository AL configuration
Shared configuration for repository command wrappers
The reusable executable, APIs, rules, and lifecycle skills belong to
AL. This package keeps the monorepo integration:
typed configuration targets, the explicit //tools/al:install entry point, and
native command tests that use AL’s built-in injector.
//tools/al:config composes the shared authentication, Vault connection, and
plugin targets declared in this package. Components compose it with their own
small authentication and plugin-call targets. Component auth extends
//tools/al:auth; aggregate list ordering does not select overrides. Short declarations stay inline. Extract
local defs.bzl only for significant reuse or readability gains from complex
inputs; common graphs use reusable target macros directly. Injector calls use
al_inject with named res_<type> maps. Plugin executables and certificate
files are declared with Bazel labels, and their runtime dependencies propagate
through AlConfigInfo targets. AL loads generated JSON; no Lua configuration
sources or Lua imports are used.
The //tools/al:tf.* targets select Terraform commands declared here
with the public rules_terraform command maps and the generic AL wrapper. These
bindings use the shared config and explicitly select the repository root as
their Terraform working directory.
Load al_terraform_binary_map, al_terraform_target_binary_map, and
al_terraform_test_map from //tools/al:al_terraform.bzl for repository
Terraform commands. Pass configs and plugin_labels directly; this integration
selects the AL wrapper once. Provider pins and operation behavior remain owned
by standalone rules_terraform. Plain offline tests can use its maps directly.
Use al_terraform_package from the same file for a Terraform root’s command
and test maps:
al_terraform_package(
name = "tf",
configs = ["//infra/example:al"],
data = glob(["*.tf"]),
plugin_labels = {"tf": "main"},
providers = ["@terraform_provider_hashicorp_vault//:provider"],
)
It shares configuration inputs and providers between operations and checks,
preserving names such as tf.plan and tf_tests.fmt_test. Checks run directly
without AL by default; tests_use_al = True retains AL-wrapped checks and
inherits configs, independently of operation plugin selectors. test_kwargs
overrides check inputs, arguments, providers or selectors, including data that
omits an operational backend. command_kwargs overrides only operations.
tests_name retains custom test prefixes, and tests = False declares only
operations. Keep scoped operation maps and other specialized targets explicit.
Backend calls reuse vault_tf_backend(name = ..., path = ..., labels = ...) from
//tools/vault/tf_backend:defs.bzl. The shared configuration registers the
backend executable once and supplies its runtime files to component commands.
AL owns the built-in graph engine and generic resource lifetimes. The shared
configuration registers @rules_al//plugins/vault:config, whose executable
advertises Vault resource types in its startup response. Wrappers inherit provider runfiles
through config targets. Builtin-only command fixtures need no plugin binary;
cleanup receipts cover success, startup failure and cancellation.
//tools/al:vault_dev_server_test retains the isolated pinned Vault dev-server
fixture. AL’s process fixtures exercise a non-Vault provider and Vault loopback
requests, proving that resource dispatch belongs to the advertised provider.
The AL lifecycle page owns one Mermaid
diagram with Build and Run subgraphs. :run_lifecycle_svg renders its source in the
repository’s site theme and packages light/dark assets for that page. This
integration keeps site tooling outside the standalone AL module.
:run_lifecycle_dark_webp provides a dark WebP for visual inspection.
79 - Repository CI
Shared entry point for repository builds and tests
The Forgejo workflow runs on pushes to
master and can be called by other trusted workflows in this repository:
jobs:
ci:
uses: ./.forgejo/workflows/ci.yaml
It checks out the event revision with complete Git history and tags
for release metadata and secret scanning, including Git LFS assets, and uses
the local action:
- name: Build and test the repository
uses: ./tools/ci/action
with:
stable-checkout: "true"
The action uses bazel run --script_path to build
//tools/ci with the CI profile and produce a launcher. Node.js runs that
launcher in a separate stage, streams output, and propagates failure. By default
it builds in GITHUB_WORKSPACE. With stable-checkout: "true", it verifies the
job checkout is at the event commit, fetches it locally into
~/.cache/repository-ci/<owner>/<repository>, checks out that commit using the
job’s existing LFS objects, and removes untracked and ignored files there
before launching Bazel. Use this option only on the dedicated runner with one
job slot. The stable path keeps Bazel’s on-disk outputs and caches reusable
across jobs.
The command runs bazel build --config=ci //...,
bazel test --config=ci //..., and
bazel build --config=ci --config=lint //... from the repository root. The root wildcard
covers first-party rulesets under their package paths. Bazel applies its
normal exclusions for manual and incompatible targets.
All phases are attempted even after a failure. The test phase includes
Buildifier and the workspace-wide Gazelle drift test. The lint phase applies
the Buildifier, Ruff, and ShellCheck aspects to declared targets. The command
streams diagnostics and exits nonzero if any phase fails. Forgejo jobs
shut down the Bazel server after the phases to release runner memory.
In Forgejo, each phase has a collapsible section. The
job summary above the log shows whether each phase passed and how long it ran.
Expand Build repository CI command and then Bazel launcher diagnostics
to see the Bazel output for the launcher build.
The stable checkout has its own Prepare repository checkout group.
The CI profile omits Bazel configuration traces, progress updates, and
successful target listings. Routine output and warnings are available under
Bazel diagnostics inside each phase. Errors and test results are visible
when the phase is expanded. Each failed test’s output has its own expandable
section in the test phase.
The same command streams plain-text diagnostics when run locally.
The runner needs the repository-managed Node.js, bazel, and Android
SDK/NDK prerequisites. The runner deployment
installs these before CI starts. Agent invocations use
bazel run --config=ci //tools/ci.
The pinned Bazel releases its invocation before executing the command, allowing
the build and test to reuse the root workspace’s normal output base. The Linux
acceptance fixture runs the compiled CI command against a private Bazel process
fixture. It verifies root-only execution, phase and shutdown failures, missing
Bazel, and reporting. Bazel test outputs include its ci-execution.json receipt.
The workflow’s checkout action comes from the organization-owned
Forgejo mirror,
at the existing v4.4.0 commit. Its immutable pin selects the action implementation;
github.sha separately selects the source revision being built.
80 - Repository quality
Whole-index formatting, linting and validation coordinator
This package uses upstream aspect_rules_lint formatting and linting rules to
discover Git-tracked files and inspect declared source targets with established
tools acquired by Bazel. It does not implement a formatter or linter and does
not download tools at runtime. Thin workspace adapters extend the upstream
language list with the official Go SDK for module and workspace manifests,
StyLua and Selene for Lua, and the existing Prettier XML plugin for Qt .ui
and .qrc files.
Format all safe, hand-maintained files:
Run the non-mutating repository check:
bazel test //:repo_quality_test
The suite also parses root BUILD.bazel and rejects load() statements to keep
unrelated tool dependencies out of root package loading. Run this check alone
with bazel test //tools/repo_quality/test/root_build:root_build_test.
Run semantic source linters over declared targets:
bazel build --config=lint //...
The CSS formatter bucket includes CSS, Less and SCSS. The JavaScript bucket
includes JavaScript, JSON, JSON-with-comments, JSON5, TypeScript, TSX and Vue.
Go source uses gofumpt; go.mod and go.work use the official Go SDK.
Lua checks cover every tracked file not excluded by Git attributes, using
StyLua for canonical formatting and Selene for correctness diagnostics.
Explicit templates (.j2, .tmpl, .tpl, and the Hugo layout tree), generic
application configuration, and non-Terraform HCL are deliberately excluded
from general formatting. Ordinary Markdown, YAML, HTML and other files remain
covered even when their contents include template expressions. Generated,
vendored, lock, binary, diagram and exact-content files likewise retain their
owning regeneration, validation or integrity workflow.
The integration test intentionally uses the upstream rule’s no_sandbox mode
so it can inspect files that are tracked by Git but not declared in BUILD
files. This is a local-checkout guarantee, like the root Buildifier test; tool
acquisition remains hermetic and pinned through Bazel.
The quality suite also runs pinned ast-grep against every tracked first-party
Python file not marked linguist-vendored or linguist-vendored=true, rejecting symbol imports in
favor of module imports and qualified member access. Formatting exclusions do
not exempt first-party Python from this check. Explicit public re-exports
listed in __all__ may use direct symbol imports in __init__.py; wildcard
imports remain forbidden.
Its syntax fixtures distinguish real imports from
comments and strings. Module from-imports are verified against source paths
and pinned Python module specifications without executing imported packages.
Like formatting, this complete-checkout check is local
and uncached; downloaded external repositories are outside its coverage.
Project inventory
bazel run //tools/repo_quality:inventory_update derives the project index from
project README metadata, validates each project’s lifecycle declaration against
projects/statuses.yaml, generates the lifecycle definitions and index status
column, and synchronizes existing landing-page status fields. Project READMEs
own the declarations. Landing-page membership remains owned by
projects/projects.bzl, independently of the documentation index.
The inventory freshness test checks these projections against the actual checkout.
Its isolated command fixture checks regeneration and preserves the results in
test outputs.
81 - Resolved toolchain
Helper rule to create a resolved toolchain
Links
81.1.1 - al_resolved_toolchain
al_resolved_toolchain
load("@com_alwaldend_src//tools/resolved_toolchain/rules:al_resolved_toolchain.bzl", "al_resolved_toolchain")
al_resolved_toolchain(toolchain_label, **kwargs)
Create a resolved toolchain
PARAMETERS
| Name | Description | Default Value |
|---|
| toolchain_label | - | none |
| kwargs | rule kwargs | none |
RETURNS
Resolved toolchain rule
82.1.1 - al_rfc_extension
al_rfc_extension
al_rfc_extension = use_extension("@com_alwaldend_src//tools/rfc/rules:al_rfc_extension.bzl", "al_rfc_extension")
al_rfc_extension.download(name, integrity, rfcs)
Rfc extension
TAG CLASSES
download
Attributes
82.1.2 - al_rfc_repo
al_rfc_repo
load("@com_alwaldend_src//tools/rfc/rules:al_rfc_repo.bzl", "al_rfc_repo")
al_rfc_repo(name, integrity, rfcs, url)
Rfc repository
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this repository. | Name | required | |
| integrity | Rfc integrity | Dictionary: String -> String | optional | {} |
| rfcs | Rfcs | List of strings | optional | [] |
| url | Url format | String | optional | "https://www.rfc-editor.org/rfc/{postfix}" |
83 - Root Bazel module
Generate the root module’s owning include list
MODULE.bazel is generated directly from include.MODULE.bazel files:
bazel run //tools/bazel_module:update
Dependency declarations and pins stay in their owning include files. The small
root module(...) header lives in the Go generator. Discovery uses the existing
@rules_al//:git host Git wrapper to include tracked and untracked files while
respecting Git ignore rules. Deleted files, symlinks, .bazelignore
directories, and standalone workspaces beneath
MODULE.bazel, WORKSPACE, or WORKSPACE.bazel boundaries are excluded.
Includes are ordered by owning directory, with third_party, tools, then
projects before other trees. This keeps the existing precedence between those
trees, including toolchain registrations. A parent directory precedes its
children. Keep any order-sensitive declarations together in one owning include.
//tools/bazel_module/cmd/update:freshness_test checks the current checkout and
is included in //:repo_quality_test. It intentionally disables sandboxing and
result caching to detect new or removed files outside declared Bazel inputs.
The generator’s unit tests remain sandboxed and cacheable.
Before deleting or moving an existing include, retain a launcher so regeneration
does not need to load the old module after its include disappears:
mkdir -p out/bazel_module
bazel run --script_path=out/bazel_module/update //tools/bazel_module:update
# Delete or move the include, then regenerate:
out/bazel_module/update
84 - Rules binary toolchain
Bazel toolchains for packaged executable binaries
rules_binary_toolchain creates Bazel toolchains and runnable targets for
packaged executable binaries. Archive entries can include runtime files,
which the generated binary targets expose through Bazel runfiles.
Lock structures reject unknown fields. Archive execution constraints belong under
toolchain.exec_compatible_with; the obsolete rules field is rejected. Update
producers and locks together when the schema changes. Downloader and execution
keyword dictionaries retain the corresponding Bazel repository API contract.
84.1 - Bzl
Bazel code
Archive binaries
Each archive binaries entry requires a name and path. It can also set
runtime_files to a list of Bazel glob patterns relative to the unpacked
archive. The generated <name>_native_binary exposes matching files as
runfiles; <name>_filegroup exposes the binary and those same files.
Omit runtime_files when the binary needs no extra runtime files.
84.2 - Examples
Examples of using these rules
84.3 - OpenSpec
84.3.1 - Specifications
84.3.1.1 - Project dns
84.3.1.1.1 - project-dns Specification
Purpose
Record the retirement of rules_binary_toolchain landing infrastructure while preserving
its reusable Bazel module.
Requirements
Requirement: Keep landing infrastructure retired
The module SHALL follow the tools boundary and SHALL
have no dedicated landing DNS declarations, Terraform root, or operational
source exports.
Scenario: Inspect the module after landing retirement
- WHEN the module is consumed from
tools/rules_binary_toolchain - THEN its reusable Bazel rules remain available without landing infrastructure.
84.3.1.2 - Project rules binary toolchain
84.3.1.2.1 - Rules binary toolchain
Purpose
Provide Bazel toolchains and runnable targets for packaged executable binaries,
including their runtime files. This source baseline was observed on 2026-09-08
at revision 550d7e79b1f5fdbc2b6017b75178471d6914082f.
Sources: project description,
lock parsing,
module extension,
archive repositories,
and runnable wrapper.
Requirements
The module extension SHALL resolve a requested toolchain by name and version
from its JSON lock and create repositories for the matching archives.
- WHEN the requested toolchain is absent or has no archive matching its locked version
- THEN extension evaluation fails with a diagnostic instead of selecting another version.
Requirement: Verify downloaded archive integrity
Archive repository download and download-and-extract actions SHALL compare the
reported integrity against the action’s declared integrity and fail on mismatch.
Scenario: Downloaded content differs from its lock entry
- WHEN a download reports an integrity value different from the lock action
- THEN repository creation fails with the expected and observed integrity values.
Requirement: Preserve runtime files in generated binary targets
Generated native binary and filegroup targets SHALL include the files selected
by each binary’s runtime_files glob patterns, in addition to the executable.
Runnable toolchain wrappers SHALL merge the selected toolchain’s runfiles and
declared data runfiles.
Scenario: A packaged executable needs an adjacent runtime asset
- WHEN an archive declares a runtime asset through
runtime_files - THEN the native binary carries that asset in its data, the filegroup exposes it, and a wrapper carries the toolchain runfiles into execution.
Requirement: Forward wrapper arguments and environment
The runnable wrapper SHALL expand declared location and make-variable arguments,
append invocation arguments, and expose the declared env through
RunEnvironmentInfo.
Scenario: A caller supplies additional command arguments
- WHEN a generated wrapper is invoked with arguments after its configured arguments
- THEN the selected toolchain binary receives both argument sets in that order.
85 - Rules Dnscontrol
Bazel-aware DNSControl configuration packaging
rules_dnscontrol packages a DNSControl JavaScript entrypoint together with
its record configuration files and emits a generated requires.json manifest
of relative paths matching the Bazel runfiles tree. Record symlinks retain a
.json suffix so DNSControl parses them as JSON. Load the manifest with
require() and load each listed path with another require() call;
DNSControl’s JavaScript loader does not implement CommonJS module.exports.
Development and releases
Run bazel test //tools/rules_dnscontrol/... from the monorepo root. Build
//tools/rules_dnscontrol:release_archive for the standalone archive.
Use release.MODULE.bazel as the basis for the published registry entry.
Registry consumers load @rules_dnscontrol//rules:dnscontrol.bzl.
86 - Rules docs
Bazel documentation packaging rules
rules_docs packages Markdown documentation under a common archive prefix.
Documentation rule
Add the module dependency:
bazel_dep(name = "rules_docs", version = "<VERSION>")
Then declare the package documentation. srcs defaults to
glob(["*.md"]); visibility is optional.
load("@rules_docs//docs:defs.bzl", "docs_filegroup")
docs_filegroup(
name = "docs",
deps = ["child"],
)
Relative dependency names without a colon are normalized to the child
package’s docs target. prefix defaults to the current package beneath
content/docs/.
Files are packaged at their basename by default. When a package’s sources span
subdirectories that hold identically named files, set preserve_paths = True
so each source keeps its package-relative path and the destinations stay
distinct.
Gazelle extension
Generation support is packaged separately so consumers of the documentation
rule do not inherit Gazelle and Go dependencies. Add it as a development-only
module dependency:
bazel_dep(
name = "rules_docs_gazelle",
version = "<VERSION>",
dev_dependency = True,
)
Add the public language target to the repository’s custom Gazelle binary:
load("@gazelle//:def.bzl", "gazelle_binary")
gazelle_binary(
name = "gazelle_binary",
languages = [
"@rules_docs_gazelle//gazelle",
],
)
The extension only operates in directories where both a BUILD file and a
README.md already exist. Newly generated rules use glob(["*.md"]) and are
visible only to their nearest ancestor Bazel package. Existing srcs, deps,
visibility, and prefix attributes are preserved.
The public @rules_docs_gazelle//gazelle:gazelle_docs binary contains only
this extension and can update a nested workspace without initializing
unrelated language plugins from its parent repository.
87 - Rules docs Gazelle
Gazelle extension for Bazel documentation packaging rules
rules_docs_gazelle adds a docs_filegroup to existing Bazel packages that
contain a README.md. The generated rule loads its macro from rules_docs.
Add rules_docs as a normal dependency and this generator as a development
dependency:
bazel_dep(name = "rules_docs", version = "<VERSION>")
bazel_dep(
name = "rules_docs_gazelle",
version = "<VERSION>",
dev_dependency = True,
)
Add the public language target to the repository’s custom Gazelle binary:
load("@gazelle//:def.bzl", "gazelle_binary")
gazelle_binary(
name = "gazelle_binary",
languages = [
"@rules_docs_gazelle//gazelle",
],
)
The extension only operates in directories where both a BUILD file and a
README.md already exist. Newly generated rules use glob(["*.md"]) and are
visible only to their nearest ancestor Bazel package. Existing srcs, deps,
visibility, and prefix attributes are preserved.
The public @rules_docs_gazelle//gazelle:gazelle_docs binary contains only
this extension and can update a nested workspace without initializing
unrelated language plugins from its parent repository.
88 - Rules Hugo
Bazel rules for Hugo sites
rules_hugo builds Hugo sites with a registered Hugo toolchain. It keeps the
site archive in the target configuration and the Hugo binary in the execution
configuration so site sources are not rebuilt for the execution platform.
al_hugo_site wraps a site source archive and its PostCSS tooling.
PostCSS and entries in tools use the execution configuration; site source
archives remain in the target configuration. Queries with --notool_deps
exclude these tools from the site’s input graph.
al_hugo_run_binary builds the site with the registered Hugo toolchain and
al_hugo_binary exposes a runnable Hugo command for a site. The optional
al_hugo_worker rule runs the build through a persistent worker.
Module setup
bazel_dep(name = "rules_hugo", version = "<VERSION>")
The Hugo toolchain is generated by the al_hugo_extension module
extension, not declared in @rules_hugo//pkg/bzl. Declare the extension
in the root module, request the toolchain archives for the Hugo version,
and register the generated toolchain repository:
al_hugo_extension = use_extension(
"@rules_hugo//pkg/bzl:al_hugo_extension.bzl",
"al_hugo_extension",
)
al_hugo_extension.toolchains(
name = "my_hugo_toolchain",
version = "0.165.0",
)
use_repo(
al_hugo_extension,
"my_hugo_toolchain_os_linux_cpu_x86_64",
)
register_toolchains("@my_hugo_toolchain_os_linux_cpu_x86_64")
The generated repository name is "<name>_<os>_<cpu>" for each platform
in the requested version’s archive set. See
projects/alwaldend.com/include.MODULE.bazel for a complete example that
also wires the Hugo lock file and remote themes.
88.1 - OpenSpec
88.1.1 - Specifications
88.1.1.1 - Project dns
88.1.1.1.1 - project-dns Specification
Purpose
Record the retirement of rules_hugo landing infrastructure while preserving
its reusable Bazel module.
Requirements
Requirement: Keep landing infrastructure retired
The module SHALL follow the tools boundary and SHALL
have no dedicated landing DNS declarations, Terraform root, or operational
source exports.
Scenario: Inspect the module after landing retirement
- WHEN the module is consumed from
tools/rules_hugo - THEN its reusable Bazel rules remain available without landing infrastructure.
88.1.1.2 - Project rules hugo
88.1.1.2.1 - Rules Hugo
Purpose
Build and run Hugo sites with registered Bazel toolchains, site source archives,
and declared PostCSS tooling. This source baseline was observed on 2026-09-08
at revision 550d7e79b1f5fdbc2b6017b75178471d6914082f.
Sources: project description,
site provider rule,
build rule,
toolchain extension,
and worker rule.
Requirements
al_hugo_site SHALL retain the .tar site archive in the target configuration
and resolve its executable PostCSS dependency in the execution configuration.
Build rules SHALL obtain Hugo from the registered Hugo toolchain.
- WHEN Bazel analyzes a Hugo site build for distinct target and execution platforms
- THEN the site archive remains a target input and Hugo and PostCSS are selected as execution tools.
Requirement: Build into a declared destination directory
al_hugo_run_binary SHALL unpack the site archive, make its PostCSS executable
available to Hugo, and invoke Hugo with --destination pointing to the declared
output directory.
Scenario: A site build specifies an output directory
- WHEN a caller supplies
out_dir and additional Hugo arguments - THEN the action appends the declared destination to those arguments and exposes the output directory through
DefaultInfo.
The Hugo module extension SHALL create toolchain repositories from the archive
set associated with the requested version, carrying each archive’s declared
integrity and execution-platform constraints.
Scenario: A supported version has a Linux x86-64 archive
- WHEN a toolchain tag requests that version under a repository name prefix
- THEN the extension creates the corresponding
<name>_os_linux_cpu_x86_64 repository with a Hugo toolchain constrained to that platform.
Requirement: Support an explicit persistent-worker build path
al_hugo_worker SHALL serialize site inputs, arguments, tools, environment, and
output location into a flag file and invoke its worker with Bazel’s protobuf
worker protocol requirements.
Scenario: A caller chooses the worker rule
- WHEN a site is built with
al_hugo_worker - THEN Bazel receives a worker-capable
HugoSite action whose declared output directory is <target>.dest.
89 - Rules Promptfoo
A pinned Bazel runner for Promptfoo skill evaluations
rules_promptfoo runs repository skills through a pinned Promptfoo CLI. It
keeps dependency resolution reproducible in Bazel while deliberately running
model calls only at test runtime.
Setup
Add the module and its skill-provider dependency:
bazel_dep(name = "rules_promptfoo", version = "<VERSION>")
bazel_dep(name = "rules_skills", version = "<VERSION>")
The development checkout uses sibling local_path_override declarations.
Published releases must replace those local overrides with registry versions.
Evaluate a skill
load("@rules_promptfoo//promptfoo:defs.bzl", "promptfoo_test")
promptfoo_test(
name = "quality_assessment_eval",
config = "promptfooconfig.yaml",
skills = ["//tools/agents/skills/quality-assessment:skill"],
env_inherit = [
"CODEX_HOME",
"CODEX_PATH_OVERRIDE",
],
reuse_codex_login = True,
)
The runner physically copies each selected SkillInfo.files_by_path bundle
to an isolated Bazel test-temporary
workspace/.agents/skills/<name>/ tree. Point the Codex SDK provider at the
exported workspace and, when using a compatible host Codex executable, at the
exported executable path:
prompts:
- "{{ question }}"
providers:
- id: openai:codex-sdk
config:
codex_path_override: "{{ env.CODEX_PATH_OVERRIDE }}"
working_dir: "{{ env.PROMPTFOO_SKILL_WORKSPACE }}"
cli_env:
CODEX_HOME: "{{ env.PROMPTFOO_SUBJECT_CODEX_HOME }}"
tests:
- vars:
question: Is it accurate to say one passing test proves correctness?
assert:
- type: skill-used
value: quality-assessment
Live eval targets are tagged manual, requires-network, no-cache,
no-remote, and local. They also pass --no-cache, --no-write, and
--no-share to Promptfoo; local prevents sandboxed or remote execution when
the caller opts into host Codex credentials. The runner exports a separate
empty PROMPTFOO_JUDGE_WORKSPACE so a model judge need not discover the skill
it grades. Explicit results are preserved as the Bazel undeclared output
results.json; Promptfoo configuration, cache, isolated workspaces, and
subprocess temporary files stay in a mode-0700 directory below Bazel’s
absolute TEST_TMPDIR and are removed on exit. Bazel owns and cleans that
private parent directory as a second cleanup boundary. Callers that must
redirect test scratch can use Bazel’s --test_tmpdir option.
The runner deliberately uses Bazel-managed temporary storage instead of a
source-checkout out/ directory. Putting a no-skill control below the source
tree would expose the checkout’s .agents directory through an ancestor and
invalidate the isolation that the control is meant to measure. This is the
repository policy’s operating-system-temporary exception for a tool that
cannot safely use task-local source storage; the runner still removes its
randomized child directory on normal exit and handled signals. The runner
rejects a TEST_TMPDIR below any ancestor containing .agents, so do not
redirect --test_tmpdir into a source checkout or another agent tree.
results.json contains the evaluated prompts and model outputs. CI may collect
undeclared outputs when a manual eval is explicitly run, so treat the artifact
as potentially sensitive even though the target is no-cache and no-remote.
Run a live target explicitly and pass the absolute path to an existing Codex
login and a compatible host Codex executable through the test environment,
never credential contents through env or a checked-in config. Set the
provider’s codex_path_override from CODEX_PATH_OVERRIDE:
bazel test //path/to:quality_assessment_eval \
--test_env=CODEX_HOME=/absolute/path/to/.codex \
--test_env=CODEX_PATH_OVERRIDE=/absolute/path/to/codex \
--test_output=errors
If that Codex installation reaches OpenAI through host proxy variables, pass
only the needed names as well (for example, --test_env=HTTPS_PROXY and
--test_env=NO_PROXY) and declare the same names in the rule’s env_inherit.
Do not put proxy values in checked-in files.
With reuse_codex_login = True, the runner links only the writable
CODEX_HOME/auth.json into distinct, otherwise empty subject and judge Codex
homes inside its mode-0700 state directory. Provider configs can select them
through PROMPTFOO_SUBJECT_CODEX_HOME and PROMPTFOO_JUDGE_CODEX_HOME. The
runner holds an exclusive advisory lock on the stable login directory for the
complete test, serializing repository eval targets that use the same login.
With a compatible Codex executable, an automatic refresh writes through either
link to the persistent host file, while the host’s config.toml, skills,
plugins, memories, and MCP configuration remain unstaged and cannot contaminate
the subject, no-skill control, or judge. This reuses the caller’s existing
login state; it does not mint or export a token. An API-key-backed target may
instead inherit OPENAI_API_KEY without enabling login reuse.
For this purpose, compatible means that file-backed auth updates open and
truncate $CODEX_HOME/auth.json, preserving the symlink. The bundled Codex
0.144.0 implementation and the tested host Codex 0.150.1 do this. Do not
override the executable with an implementation that atomically replaces the
isolated auth.json path: that would replace the symlink, split subject and
judge state, and fail to persist a rotated refresh token. See the corresponding
OpenAI Codex file-storage implementations for
0.144.0
and
0.150.1.
Login reuse also forces Promptfoo’s CLI, assertion-worker, and prompt-suggestion
concurrency to one, overriding higher configuration values so subject and judge
Codex processes cannot race the same single-use refresh token within one test.
Do not run another Codex process against the same auth.json concurrently;
unrelated processes do not honor the runner’s advisory lock. ChatGPT-managed
auth can rotate its refresh token, so the refreshed file must remain persistent
and have a single serialized user. The local-login mode is unsuitable for
shared or untrusted CI; use an API key or supported workload identity there.
In this public repository it is strictly a manual, trusted-developer workflow;
never seed or persist ChatGPT-managed auth in repository CI or artifacts.
See OpenAI’s
managed-auth guidance for the
refresh and serialization requirements.
Run credentialed live targets only from a reviewed, trusted revision. The
isolated working directory and read-only provider setting reduce accidental
writes, but Codex still has whatever host read access its enforced sandbox
policy permits and can send prompt context to the configured service.
Files in data are placed in the test runfiles. args are passed literally;
they do not expand Bazel location expressions. Prefer keeping checked-in
Promptfoo prompt and dataset files beside the config and list them in data
so Promptfoo’s own config-relative path resolution remains portable.
The env and env_inherit attributes cannot override Bazel’s test temporary
directories or the runner-owned TMPDIR, TMP, and TEMP values.
Validate without a model call
load(
"@rules_promptfoo//promptfoo:defs.bzl",
"promptfoo_validate_test",
)
promptfoo_validate_test(
name = "promptfoo_config_test",
config = "promptfooconfig.yaml",
)
Validation is an ordinary offline Bazel test and does not receive the live
eval tags. It rejects env_inherit so validation cannot accidentally receive
host credentials.
Dependency boundary
The module pins Promptfoo and the Codex SDK with a dedicated pnpm lock. npm
lifecycle hooks, automatic peer installation, and optional dependencies are disabled. The Codex executable
and Promptfoo’s libSQL binding are promoted to explicit Linux x86-64
dependencies. AJV is also promoted because ajv-formats declares its runtime
peer as optional, which would otherwise be removed by no_optional. The
bundled real CLI target is intentionally compatible only with glibc-based
Linux x86-64. Bazel enforces the OS and CPU constraints, but this repository
does not currently expose a libc constraint. Other Promptfoo providers that
rely on omitted optional packages or install scripts must be reviewed and
promoted explicitly before use.
The pinned Promptfoo distribution is patched so
PROMPTFOO_DISABLE_TELEMETRY=1 also suppresses its best-effort request to
r.promptfoo.app. The upstream 0.125.1 telemetry implementation otherwise
records a “telemetry disabled” event through that separate endpoint. The same
patch makes Promptfoo’s otherwise hard-coded prompt-suggestion concurrency
honor the runner’s serialization setting.
Security overrides select patched MSAL, basic-ftp, glob, and minimatch versions
where transitive ranges retain vulnerable releases. OpenTelemetry API stays at 1.9.0 to satisfy
the tracing SDK’s <1.10.0 peer contract. Optional provider peers are installed
only when explicitly declared by this runner.
90 - Rules Promptfoo Gazelle
Gazelle extension for offline Promptfoo validation tests
rules_promptfoo_gazelle generates required, offline
promptfoo_validate_test targets for Promptfoo configurations below an
evals/ directory. It never creates an evals subpackage and never generates
live promptfoo_test targets.
Add rules_promptfoo as a normal dependency and this generator as a
development dependency:
bazel_dep(name = "rules_promptfoo", version = "<VERSION>")
bazel_dep(
name = "rules_promptfoo_gazelle",
version = "<VERSION>",
dev_dependency = True,
)
For one-pass skill package creation, also add rules_skills as a normal
dependency and rules_skill_gazelle as a development dependency:
bazel_dep(name = "rules_skills", version = "<VERSION>")
bazel_dep(
name = "rules_skill_gazelle",
version = "<VERSION>",
dev_dependency = True,
)
Add both public language targets to the repository’s custom Gazelle binary:
load("@gazelle//:def.bzl", "gazelle_binary")
gazelle_binary(
name = "gazelle_binary",
languages = [
"@rules_promptfoo_gazelle//gazelle",
"@rules_skill_gazelle//gazelle",
],
)
With both extensions installed, a fresh directory containing SKILL.md and a
conventional Promptfoo configuration receives both skill_library and
promptfoo_validate_test targets in one Gazelle run; it does not need an
existing BUILD file.
The extension recognizes these conventional configuration paths:
evals/promptfooconfig.yaml
evals/promptfooconfig.<variant>.yaml
evals/promptfooconfig.yml
evals/promptfooconfig.<variant>.json
The default file produces eval_config_test; a variant produces
eval_<sanitized_variant>_config_test. Variants are lowercased, and runs of
characters other than ASCII letters and digits become underscores. Colliding
sanitized names receive a stable path-derived __<8 lowercase hex digits>
suffix. The double underscore cannot be produced by the sanitizer, so a
variant cannot claim a collision target’s namespace.
When a non-root containing package has a SKILL.md, each ordinary validation
target stages that package’s conventional :skill target. Repository-root
skills are unsupported by rules_skills, so a root-package SKILL.md does not
infer that label. The exact no_skill variant omits skills so it remains a
control. A generic Promptfoo package without SKILL.md receives no inferred
skill label. Every non-configuration regular file under evals/, including
README.md and test cases, is added to data in sorted order. Directories
containing BUILD, BUILD.bazel, or an additional filename configured as
valid in Gazelle are package boundaries and are not traversed.
A scan accepts up to 65,536 directory entries and 64 levels below evals/.
Generation accepts up to 1,048,576 config and data labels across a package’s
validation rules. If a limit is exceeded, Gazelle reports the package and
leaves its existing rules in place without emitting partial results.
The extension reconciles config, data, and skills when a discovered
configuration matches a conventionally named validation target. Adding or
editing eval files therefore updates those attributes on the next run.
Removing or renaming a configuration does not delete the old target: a name
shape is not reliable proof that Gazelle created a rule, so stale targets must
be removed explicitly. Gazelle’s # keep semantics remain available at the
rule, attribute, and individual list-item levels for intentional overrides.
Other attributes, including args, env, tags, and visibility, remain
manual and are preserved while the generated target exists. Existing manual
or live promptfoo_test rules are also left intact.
The extension does not follow a symlink used as the package’s evals
directory, because it could escape the repository. Such a symlink, or another
unexpected filesystem scan error including an error while checking a candidate
package boundary, is a non-destructive no-op rather than a signal to remove
targets. Before scanning, it also resolves the repository root and package
directory and refuses a package whose resolved path escapes the workspace,
including a package reached through Gazelle’s symlink-following support. The
extension manages the shared load for both Promptfoo rule symbols and uses
Bzlmod’s apparent repository name.
The public @rules_promptfoo_gazelle//gazelle:gazelle_promptfoo binary
contains only this extension and can update a nested workspace without
initializing unrelated language plugins from its parent repository.
91 - Rules skill
Bazel rules and validation for Codex skills
rules_skills packages all files belonging to a Codex skill and validates its
instructions and optional OpenAI metadata with a hermetic Bazel aspect.
Getting started
Add the module and register the validation aspect:
bazel_dep(name = "rules_skills", version = "<VERSION>")
build --aspects @rules_skills//skill:defs.bzl%skill_validation_aspect
build --output_groups=+skill_validation
Declare one library in the skill’s named, non-root package:
load("@rules_skills//skill:defs.bzl", "skill_library")
skill_library(
name = "skill",
srcs = glob(
["**"],
exclude = [
"BUILD.bazel",
"BUILD",
"evals/**",
],
),
)
The package’s final path segment is the skill name, so a skill_library
cannot be declared in a repository root package. Move a root-level skill into
a named subpackage before declaring it.
Building the library materializes the skill_validation output group. The
aspect checks SKILL.md, verifies that the frontmatter name matches its
package directory, and validates agents/openai.yaml when it is present. Each of these two documents may be up
to 4 MiB. The validator rejects larger documents before parsing their contents.
Consuming a skill
Rules that install or evaluate skills can require the public SkillInfo
provider:
load("@rules_skills//skill:defs.bzl", "SkillInfo")
attrs = {
"skill": attr.label(providers = [SkillInfo]),
}
SkillInfo exposes these fields:
name is the logical skill name derived from the final segment of root.
The validation aspect verifies that the SKILL.md frontmatter uses the same
name.root is the owning Bazel package path within the skill’s repository, such
as tools/agents/skills/quality-assessment. It has no repository,
execution-path, or runfiles prefix. It is always non-empty because
repository root packages are unsupported.files_by_path maps slash-separated paths relative to root to Bazel
File values. It includes SKILL.md, preserves nested paths such as
agents/openai.yaml, and has the same shape for source and generated files.files remains the depset of all skill files. skill is the distinguished
SKILL.md file, and openai_yaml is the optional distinguished
agents/openai.yaml file.
Consumers should use files_by_path when staging a bundle instead of parsing
File.path or File.short_path. Every source must belong to the skill’s Bazel
package, and duplicate logical paths are rejected during analysis.
Packaging skills from an external archive
Use skill_archives when skills are maintained upstream and consumed as a
pinned archive. The external repository’s BUILD file derives one target per
skill directory from a wildcard, so a new upstream skill needs no edit here:
load("@rules_skills//skill:defs.bzl", "skill_archives")
skill_archives(
name = "skills",
roots = [
manifest.rsplit("/", 1)[0]
for manifest in glob(["skills/*/SKILL.md"])
],
)
skill_archives is a macro over the skill_archive rule. Each generated
target’s name is its skill directory’s final segment, root is the skill
directory inside the package, and its packaged logical paths are relative to
root. Analysis fails when a root has no SKILL.md. Declare one
skill_archive directly when a single skill needs a hand-written target.
Writing the source-tree discovery directory
Use skills_write to reconcile .agents/skills from declared skills. Each
symlinks label is installed as a direct relative symlink to its canonical
root; each archives label is copied in as regular files, which is how archive
skills are materialized into the consuming repository:
load("@rules_skills//skill:defs.bzl", "skills_write")
skills_write(
name = "write_skills",
archives = ["@org_fissionai_openspec//:openspec-propose"],
discovery_dir = ".agents/skills",
symlinks = ["//tools/agents/skills/quality-assessment:skill"],
workspace_marker = "//:AGENTS.md",
)
workspace_marker is a source file in the consuming repository used to
resolve the workspace root from test runfiles. Reconcile and verify:
bazel run //.agents:write_skills
bazel test //.agents:write_skills_test
The generated check requires exactly the declared names: missing, extra, or
stale entries fail, and a written entry must match its declared source
byte-for-byte. The updater holds a sibling <discovery_dir>.lock directory
while it changes entries; a process killed without running its exit trap can
leave that lock behind. After confirming no updater is active, remove the empty
lock directory and rerun the updater.
Both rules require POSIX symlinks and Bash and are limited to Linux and macOS
checkouts; native Windows checkouts are not supported.
92 - Rules skill Gazelle
Gazelle extension for Bazel skill libraries
rules_skill_gazelle adds a skill_library(name = "skill") to each named
subpackage that contains a SKILL.md. The generated rule loads its macro from
the apparent rules_skills repository, so Bzlmod repository mappings are
respected.
Add rules_skills as a normal dependency and this generator as a development
dependency:
bazel_dep(name = "rules_skills", version = "<VERSION>")
bazel_dep(
name = "rules_skill_gazelle",
version = "<VERSION>",
dev_dependency = True,
)
Add the public language target to the repository’s custom Gazelle binary:
load("@gazelle//:def.bzl", "gazelle_binary")
gazelle_binary(
name = "gazelle_binary",
languages = [
"@rules_skill_gazelle//gazelle",
],
)
The generated source bundle is:
load("@rules_skills//skill:defs.bzl", "skill_library")
skill_library(
name = "skill",
srcs = glob(
["**"],
exclude = [
"BUILD.bazel",
"BUILD",
"evals/**",
],
),
)
The generator always excludes BUILD.bazel and BUILD, plus every custom
BUILD filename configured in Gazelle. Duplicate configured names are removed.
SKILL.md is sufficient for Gazelle to create a new BUILD file below the
repository root. A root-level SKILL.md is ignored because rules_skills
requires a named package from which it can derive the skill name. Existing
attributes on a manually maintained skill_library(name = "skill") are
preserved, and a missing SKILL.md does not delete a manual rule.
The public @rules_skill_gazelle//gazelle:gazelle_skills binary contains only
this extension and can update a nested workspace without initializing
unrelated language plugins from its parent repository.
93 - Rules systemd
Executable Bazel targets with user systemd resource limits
rules_systemd is a standalone Linux Bazel module. Add a bazel_dep on
rules_systemd and load its public systemd/defs.bzl API. The module uses
its own dependency manifest and lockfile; the parent checkout supplies a local
module override for development.
The systemd_run rule exposes a normal executable Bazel target with its
resource policy declared in BUILD.bazel. It runs the application through the
host’s systemd-run --user --scope, preserving literal arguments, environment,
working directory, standard streams, signals, and exit status. It does not
install services or change persistent host configuration.
load("@rules_systemd//systemd:defs.bzl", "systemd_run")
systemd_run(
name = "server",
binary = ":server_bin",
arguments = ["--input", "$(rlocationpath :input.txt)"],
data = ["input.txt"],
properties = {
"MemoryHigh": "96M",
"MemoryMax": "128M",
"MemorySwapMax": "0",
},
)
Run it with bazel run //path/to:server. Arguments after --
are appended to arguments. Configure the application’s default arguments
on the wrapper; defaults from the raw binary’s Bazel args attribute are
not inherited. arguments supports location/runfiles expressions referring
to binary and data. The rule merges their runfiles and preserves the
binary’s RunEnvironmentInfo.
The rule uses the existing hermetic copy action to package the Go launcher
and an adjacent generated JSON configuration of up to 16 MiB. The launcher resolves the
application through Bazel runfiles. Both output files are required when
packaging the executable. No shell launch script or per-target Go build is
needed. All systemd execution occurs at runtime, outside build actions.
The host systemd must support --expand-environment=no; the launcher uses
it to preserve dollar expressions literally in child arguments.
Properties use systemd’s native names and values; at least one is required.
Unsupported properties, unavailable controllers, or an unavailable user
systemd manager fail without an unbounded fallback. The command runs in
the foreground and Ctrl+C stops it. Ordinary Bazel run-lock behavior remains;
Bazel’s persistent server stays outside the new scope.
The CLI remains available for direct commands:
bazel run @rules_systemd//:systemd_run -- \
--property=MemoryMax=128M --property=MemorySwapMax=0 -- /usr/bin/true
ComfyUI declares its existing
model limits through this rule. The small //tools/rules_systemd/test:probe
fixture writes JSON evidence of real kernel limits, argument forwarding,
environment, and runfiles when supplied -- --report <absolute-output-path>.
Development
Run bazel test //tools/rules_systemd/... from the monorepo root. The
build_test target checks the public rule against the runfiles fixture. Runtime verification requires a Linux user systemd manager
and delegated memory controllers; invoke //tools/rules_systemd/test:probe with an absolute
--report path to record actual kernel limits.
Build //tools/rules_systemd:release_archive for the standalone module. Use
release.MODULE.bazel as the basis for the published registry entry. Registry
consumers load @rules_systemd//systemd:defs.bzl.
94 - Rules template
Bazel rules and a Go command for rendering template files
rules_template provides Bazel rules and a Go command for rendering template
files. A registered toolchain supplies the templating executable to build
actions. The to_html_table helper accepts up to 128 levels of nested values
and reports a rendering error when an input exceeds that depth. One invocation
accepts up to 64 MiB of template and data files combined, with up to 1,048,576
data lines. Rendering stops before buffered output exceeds 64 MiB. A size or
depth failure leaves the destination untouched.
Getting started
MODULE.bazel:
bazel_dep(name = "rules_template", version = "<VERSION>")
register_toolchains("@rules_template//rules:all")
BUILD.bazel:
94.2 - OpenSpec
94.2.1 - Specifications
94.2.1.1 - Project dns
94.2.1.1.1 - project-dns Specification
Purpose
Record the retirement of rules_template landing infrastructure while preserving
its reusable Bazel module.
Requirements
Requirement: Keep landing infrastructure retired
The module SHALL follow the tools boundary and SHALL
have no dedicated landing DNS declarations, Terraform root, or operational
source exports.
Scenario: Inspect the module after landing retirement
- WHEN the module is consumed from
tools/rules_template - THEN its reusable Bazel rules remain available without landing infrastructure.
94.2.1.2 - Project rules template
94.2.1.2.1 - Rules template
Purpose
Render Go text templates from declared data files through a command and a Bazel
toolchain rule. This source baseline was observed on 2026-09-08 at revision
550d7e79b1f5fdbc2b6017b75178471d6914082f. The command operates on one template
and output per invocation; the rule’s list attributes do not establish a
multi-template rendering guarantee.
Sources: project description,
command flags,
templater,
template functions,
and Bazel action.
Requirements
Requirement: Load supported data formats into template context
The template command SHALL load data files in argument order into DataFiles,
decode .toml, .json, .ndjson, and .yaml data, and expose .txt files as
lines without structured decoding. --extension SHALL override extension
selection for the supplied data files.
Scenario: A caller renders a template using newline-delimited JSON
- WHEN a declared
.ndjson input contains valid JSON on each data line - THEN its template context contains a parsed sequence in
Data and the input lines in Lines.
The command SHALL return errors for unsupported data extensions, failed reads,
invalid structured data, invalid template syntax, template execution failures,
and failed output writes.
Scenario: A data file uses an unsupported extension
- WHEN a data path has an unrecognized extension and no supported override
- THEN rendering fails with an unsupported-extension diagnostic identifying the data path.
Requirement: Expose the registered template function set
Template execution SHALL use the project’s function map, including JSON
serialization, HTML escaping, path basename and dirname helpers, and first and
last element helpers.
Scenario: A template serializes structured data
- WHEN a valid template invokes
to_json on JSON-serializable context data - THEN the function returns the JSON representation for inclusion in the output.
template_run_binary SHALL invoke the registered templater with its template
subcommand, declare source and data files as inputs, declare output files, and
forward additional rule arguments.
Scenario: A target declares one template and one output
- WHEN Bazel executes the target with its registered template toolchain
- THEN the action passes the template, ordered data flags, and output path to the templater and exposes the declared output to downstream targets.
95 - Rules Terraform
Bazel rules and pinned provider installation for Terraform
This standalone module owns reusable Terraform rules. Terraform and provider
archives are declared Bazel inputs. Provider downloads belong to the Bzlmod
extension; Terraform uses a filesystem mirror containing only the providers
selected by its target.
The extension resolves one version per provider source. Consumers select a
provider by Bazel label. Explicit version override policy can be added at this
resolution boundary later; conflicting versions currently fail resolution.
Repository authentication and backend injection are supplied by the caller.
The module does not depend on the enclosing monorepo’s AL or Vault packages.
Declare providers
Use terraform_providers from @rules_terraform//:extensions.bzl. Each
archive tag requires a unique repository name, canonical lowercase
source (hostname/namespace/type), exact version, Terraform platform
(os_arch), immutable HTTPS urls, and SHA256 SRI integrity. Verify the
integrity against the publisher’s release checksums before declaring it.
Import each generated repository with use_repo. Its public :provider
target exposes TerraformProviderInfo. Different platforms can share one
provider version; duplicate archives or conflicting versions fail before
repositories are registered. Provider downloads use Bazel’s verified downloader
and repository cache, without executing host tools or querying a registry.
This repository’s concrete declarations live in the
Terraform dependency package.
The module is currently developed with a local Bzlmod override; no registry
release is implied.
load("@rules_terraform//terraform:defs.bzl", "terraform_binary", "terraform_test")
terraform_binary(
name = "tf_plan",
srcs = glob(["*.tf"]),
data = ["//modules/example:source"],
providers = ["@my_provider_linux_amd64//:provider"],
arguments = ["plan"],
)
terraform_test(
name = "tf_fmt_test",
srcs = glob(["*.tf"]),
arguments = ["--direct", "fmt", "-check", "-recursive"],
)
arguments are fixed runner/Terraform arguments; command-line arguments are
appended. srcs and data declare configuration, local child modules, and files
read by the configuration. chdir defaults to the target’s package. The
rules package ZIPs at
HOST/NAMESPACE/TYPE/terraform-provider-TYPE_VERSION_OS_ARCH.zip beneath a
target-specific runfiles mirror, following Terraform’s
filesystem mirror contract.
Command maps and wrappers
The same terraform/defs.bzl exports terraform_binary_map,
terraform_target_binary_map, and terraform_test_map. They preserve explicit
operation names such as tf.plan, tf.apply, and tf_tests.fmt_test.
The test map includes format checking by default. Set validate = True to
add tf_tests.validate_test with a backend-free configuration and declared
providers. For al_terraform_package, pass the option and those inputs through
test_kwargs.
Targeted maps produce plan/show/apply commands; their apply command requires
one saved plan. No unnamed apply alias is generated.
Maps run the Terraform rules directly by default. Callers can supply a
wrapper macro and its wrapper_kwargs to compose authentication or other
command setup without adding that framework to rules_terraform. The wrapper
receives the final target name, the inner executable in args, its runfiles
in data, and common target attributes. wrapper_kwargs cannot replace those
arguments or duplicate common attributes. Wrapped tests require a test wrapper.
Repository consumers load al_terraform_binary_map,
al_terraform_target_binary_map, or al_terraform_test_map from
//tools/al:al_terraform.bzl and pass configs and run_args directly.
That repository integration selects the wrapper once; configuration targets
provide plugin runfiles transitively. Provider-free tests can use the Terraform
test maps directly. Repository root command bindings
live with the shared AL configuration.
The default Terraform executable is the pinned toolchain in
terraform/binary_toolchain.json, acquired through rules_binary_toolchain.
The initial supported executable platform is Linux amd64. The optional
terraform executable attribute permits a caller-supplied Bazel tool.
@rules_terraform//terraform:cli exposes the pinned CLI for formatting and
other consumers that do not initialize providers.
Initialization and generated locks remain in runtime workspaces. No source
.terraform.lock.hcl is required. The launcher contract
describes working directories, direct commands, saved plans, and manifest-only
execution. Provider and backend operations can still use the network when
the operator invokes them; provider acquisition itself has no runtime registry
fallback. Configuration modules must be declared local inputs.
95.1 - OpenSpec
95.1.1 - Specifications
95.1.1.1 - Terraform execution
95.1.1.1.1 - terraform-execution Specification
Purpose
Provide reusable Bazel rules that acquire pinned Terraform providers and run
Terraform with declared configuration, executable, and provider inputs.
Requirements
Requirement: Verified provider acquisition
The provider module extension SHALL download immutable HTTPS archives with
mandatory SHA256 integrity through Bazel repository fetching. It SHALL select
one version for each canonical provider source across the extension graph.
Scenario: Conflicting provider versions
- WHEN declarations select different versions of the same provider source
- THEN extension resolution fails before provider repositories are created.
Scenario: Verified archive
- WHEN a provider archive is fetched
- THEN Bazel verifies the declared integrity and exposes its canonical source,
version, platform, and packed filesystem-mirror path.
Requirement: Declared provider execution
Terraform rules SHALL place selected provider archives in runfiles using the
packed filesystem-mirror layout. The runner SHALL configure only that mirror
for provider installation and SHALL preserve the declared Terraform executable.
Scenario: Offline initialization
- WHEN all required providers are declared by a target
- THEN initialization and provider schema validation succeed without registry
access or a host provider cache.
Scenario: Missing provider
- WHEN configuration requires a provider absent from the target’s mirror
- THEN initialization fails without falling back to a registry download.
Requirement: Reusable execution and repository integration
The reusable module SHALL own Terraform execution and named command maps while
remaining independent of parent repository labels. Maps SHALL support optional
caller-supplied command wrappers. Repository consumers SHALL select generic AL
wrappers explicitly to preserve configuration, plugin lifecycle, backend
injection, named operations, and the saved-plan apply guard. Shared provider
pins SHALL be owned by third_party/terraform.
Scenario: Saved-plan apply
- WHEN a targeted apply wrapper receives a missing plan or extra arguments
- THEN the runner rejects it before Terraform initialization.
Scenario: Repository migration
- WHEN repository Terraform commands and tests are analyzed
- THEN they load maps from rules_terraform, select shared provider labels,
and require neither tools/terraform nor a checked-in .terraform.lock.hcl file.
Scenario: Optional wrapper
- WHEN a command map supplies a wrapper
- THEN the wrapper receives the declared Terraform invocation and runfiles
without requiring a framework dependency in the reusable module.
Scenario: Direct tests
- WHEN a test map needs no external command setup
- THEN it runs the Terraform test rule without an AL dependency.
95.2 - Terraform launcher
Execute Terraform with providers declared by Bazel
This implementation launcher reads the generated target sidecar and resolves
Terraform, configuration inputs, and provider archives through Bazel runfiles.
Both the generated sidecar and the provider selection JSON collected from
Terraform may be up to 64 MiB each.
Consumer targets use the public Terraform rules instead of invoking this binary
directly.
The launcher selects the target’s working directory inside the runfiles tree.
Source files can remain symlinks, so formatting retains its existing source
behavior. Initialization writes lockfiles and Terraform metadata in that runfiles
directory. Saved plans and local state retain their normal paths relative to
the working directory; the launcher never removes them.
Each invocation uses a private CLI configuration containing only the declared
filesystem provider mirror. It overrides user CLI configuration, removes inherited
provider-cache settings, disables checkpoint checks, and rejects injected CLI
arguments, provider reattachment, and provider-download commands. Missing provider
versions and platforms fail without a registry installation fallback. Temporary
CLI configuration and any materialized provider mirror are removed on exit.
Before commands that can load providers, the launcher reads Terraform’s lock
selections through version -json and checks every selected installed package
against its declared archive. Source addresses, versions, file paths, and file
contents must match; undeclared selections and extra, missing, modified, or linked
package files fail before the requested command starts. The check honors
TF_DATA_DIR, including paths relative to Terraform’s working directory. It also
runs after explicit initialization. This adds local archive decompression and
hashing work; it does not initialize the backend or contact a registry. The
working directory must not be modified concurrently during execution.
Initialization runs before the requested command unless --direct precedes it.
Its standard output goes to standard error, preserving structured command output.
AL_TF_BACKEND_CONFIG* environment values remain literal initialization
arguments; other provider and backend environment, including TF_HTTP_*, is
preserved. Terraform process exit codes are returned unchanged.
SIGINT and SIGTERM interrupt the active Terraform child and wait for it to exit.
The launcher allows ten seconds for graceful shutdown, then forces the child to
exit. Callers that start the launcher with their own cancellation deadline must
allow a longer interval so that Terraform finishes before recovery begins.
Configuration supports declared local modules. Provider installation is isolated;
the launcher does not inspect module source expressions or sandbox Terraform’s
service connections.
--require-saved-plan accepts only apply <saved-plan-file>. The file must exist
and be regular; relative paths resolve against the selected working directory.
Argument and environment validation happens before initialization.
Manifest-only tests materialize declared configuration inputs beneath
TEST_TMPDIR, retaining their workspace until Bazel removes that test directory.
Outside tests, a directory runfiles tree is required to preserve persistent
working-directory semantics. An explicit --chdir before the Terraform command
selects a caller-owned directory when that behavior is intended.
Invocation scratch uses TEST_TMPDIR, then an explicitly configured TMPDIR,
then BUILD_WORKSPACE_DIRECTORY/out/rules_terraform/runtime. It never falls back
to the system temporary directory.
96 - rules_iso
ISO image download and flash rules
Module extension that downloads ISO images with http_file and adds a
runnable iso_flash target next to each image.
In the repository workspace, load iso_image from
//tools/rules_iso/rules:iso_image.bzl to build a deterministic ISO. Set
out, volume_id, and files, a dictionary mapping input file labels to
root filenames. Rock Ridge and Joliet readers see the supplied filenames.
Develop and test the rules from the monorepo root:
bazel test //tools/rules_iso/...
bazel build //tools/rules_iso:release_archive
The release archive is bazel-bin/tools/rules_iso/rules_iso.tar.gz. It contains
the rules under pkg/bzl, their module declaration, and the repository license.
For a registered release, use release.MODULE.bazel as
the basis for the version’s registry MODULE.bazel and set its release
version. The registry’s source.json identifies the archive URL and integrity
hash. The archive uses the module root directly and needs no strip prefix.
Registry consumers load the extension from
@rules_iso//pkg/bzl:iso_extension.bzl.
97 - Run tool
Run tool rules
97.1.1 - al_run_tool
al_run_tool
load("@com_alwaldend_src//tools/run_tool/rules:al_run_tool.bzl", "al_run_tool")
al_run_tool(name, tool, executable, test, **kwargs)
Generate either native_test, native_binary, or run_binary target
PARAMETERS
| Name | Description | Default Value |
|---|
| name | Target name (required) | none |
| tool | Tool label to run (required) | none |
| executable | If True, generate native_binary | False |
| test | If True, generate native_test | False |
| kwargs | kwargs for rules | none |
98 - Selene
Hermetic Selene Lua linter
Selene provides correctness-oriented linting for the repository’s
hand-maintained Lua files. The repository standard-library description permits
the intentional al configuration DSL and Neovim’s vim global while keeping
Selene’s ordinary Lua diagnostics enabled.
Links
The pinned upstream binary is owned by
third_party/com_github_kampfkarren_selene.
99.1.1 - al_sh_library
al_sh_library
load("@com_alwaldend_src//tools/sh/rules:al_sh_library.bzl", "al_sh_library")
al_sh_library(name, shfmt_src, editorconfig_src, shellcheck_src, run_args_src, visibility,
test_data, **sh_kwargs)
Create targets for a shell library
Targets:
- ${name}.shfmt_fix: executable to run shfmt
- ${name}.shfmt_test: test whether the script is formatted
- ${name}.shellcheck_test: shellcheck test
PARAMETERS
| Name | Description | Default Value |
|---|
| name | target name | none |
| shfmt_src | - | "//tools/shfmt" |
| editorconfig_src | - | "//tools/shfmt:editorconfig" |
| shellcheck_src | - | "//third_party/com_github_koalaman_shellcheck:shellcheck" |
| run_args_src | - | "//tools/sh/internal/scripts:run_args_lib" |
| visibility | - | ["//:__subpackages__"] |
| test_data | - | [] |
| sh_kwargs | kwargs for sh targets | none |
99.1.2 - al_write_script
al_write_script
load("@com_alwaldend_src//tools/sh/rules:al_write_script.bzl", "al_write_script")
al_write_script(name, out, content, make_vars, set_flags, shebang)
Write a script and make it executable
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| out | Output file | Label; nonconfigurable | required | |
| content | Script content | String | required | |
| make_vars | Additional make vars | Dictionary: String -> String | optional | {} |
| set_flags | Flags to pass to set | List of strings | optional | ["-eu"] |
| shebang | Sheband to use | String | optional | "#!/usr/bin/env sh" |
100 - Shfmt
Shfmt
Links
The pinned upstream binary is owned by
third_party/com_github_mvdan_sh.
102 - SSH
Host SSH client wrapped by AL
ssh_binary runs the host’s ssh from PATH through al_binary_run.
AL configurations and plugins can inject SSH keys before the command runs.
load("//tools/ssh:defs.bzl", "ssh_binary")
ssh_binary(
name = "ssh",
configs = [":config"],
args = ["example.invalid"],
)
The macro accepts al_binary_run attributes, including configs, run_args,
data, env, and visibility. Declare injection plugins in data and select
their calls through run_args. The consuming AL configuration owns Vault
references and key injection. No authentication is selected by default.
Run bazel run //tools/ssh -- -V to check the host client. Arguments supplied
at invocation are appended after the target’s fixed SSH arguments. The host
must provide OpenSSH; it is not downloaded or built by Bazel.
//tools/ssh:forward provides the AL ssh_forward resource. Add the
provider to the command’s AL configuration. Declare a resource with the SSH
server host and port, SSH user, remote TCP target, and trusted
host_ca public key. Give it one dependency that returns the
private_key and public_key_signed paths, such as vault_ssh.
Each client key or certificate file may contain up to 1 MiB.
Use the resource’s .Last.Data.address in a dependent environment
variable. The provider verifies the SSH host and remote service before
returning an ephemeral loopback address. The forward closes when the
command exits.
103 - Stylua
Stylua wrapper
Links
The pinned upstream binary is owned by
third_party/com_github_johnnymorganz_stylua.
104.1.1 - al_toml_data
al_toml_data
load("@com_alwaldend_src//tools/toml/rules:al_toml_data.bzl", "al_toml_data")
al_toml_data(name, deps, srcs, tomlv)
ATTRIBUTES
| Name | Description | Type | Mandatory | Default |
|---|
| name | A unique name for this target. | Name | required | |
| deps | Toml data targets | List of labels | optional | [] |
| srcs | Toml files | List of labels | optional | [] |
| tomlv | Tomlv target to use for validation | Label | optional | "@com_alwaldend_src//tools/tomlv" |
104.1.2 - al_toml_info
AlTomlInfo
load("@com_alwaldend_src//tools/toml/rules:al_toml_info.bzl", "AlTomlInfo")
AlTomlInfo(srcs, deps)
Provide toml data info
FIELDS
| Name | Description |
|---|
| srcs | Toml files |
| deps | Toml data targets |
104.1.3 - al_toml_validate
al_toml_validate
load("@com_alwaldend_src//tools/toml/rules:al_toml_validate.bzl", "al_toml_validate")
al_toml_validate()
Aspect adding linters for toml files
ASPECT ATTRIBUTES
ATTRIBUTES
106 - Traefik
Traefik
Links
107 - Transitive sources
Provider and a rule to extract transitive sources
107.1.1 - al_transitive_sources
AlTransitiveSources
load("@com_alwaldend_src//tools/transitive_sources/rules:al_transitive_sources.bzl", "AlTransitiveSources")
AlTransitiveSources(transitive_sources)
Provide transitive sources
FIELDS
| Name | Description |
|---|
| transitive_sources | - |
al_transitive_sources
load("@com_alwaldend_src//tools/transitive_sources/rules:al_transitive_sources.bzl", "al_transitive_sources")
al_transitive_sources(srcs, deps)
Obtain the source files for a target and its transitive dependencies.
PARAMETERS
| Name | Description | Default Value |
|---|
| srcs | a list of source files | none |
| deps | a list of targets that are direct dependencies | none |
RETURNS
a collection of the transitive sources
108 - Transitive visibility policy
transitive_visibility.toml selects the package groups used by the repository’s
Gazelle transitive-visibility extension. The groups themselves remain in their
owning trees’ BUILD files.
The [paths] table maps workspace-relative directories to absolute group labels.
Use "." for the workspace root. A mapping includes descendants; the most
specific directory match wins. Paths are literal directories, not globs.
The tools:build_api_consumers entries preserve existing build-tool and
toolchain exceptions. Website, developer, and test exceptions remain expressed
by the package groups.
Run bazel run //:gazelle -- -lang=enforce_transitive_visibility
after changing this file. Gazelle validates all mappings before updating BUILD
files and places managed package() declarations in existing files after loads
and before rules.
Do not add gazelle:transitive_visibility comments; the extension rejects them.
See the plugin documentation
for standalone usage and the Bazel 9.3.1 indirect-enforcement limitation.
Gazelle 0.54.0 appends package() after generated rules when it creates a new
BUILD file. A subsequent run moves it after the loads; further runs are stable.
The repository uses unmodified upstream Gazelle and does not patch this behavior.
Artifact dependency tests
artifact_boundary_test in defs.bzl checks ordinary dependencies separately
from native package exceptions. It rejects paths into tools, infra and
users through direct or indirect dependencies, using Bazel genquery with
--noimplicit_deps --notool_deps --nonodep_deps. Execution tools, toolchains,
visibility metadata and Starlark loads are excluded. Select branches remain
unconfigured, so this is a conservative source graph rather than a configured
runtime or action-graph guarantee.
The current audited runtime roots are AL, the dependency analyzer, the X profile
cleaner, and the Article uploader’s converter and draft commands. Their owning
command BUILD files declare the tests; normal repository tests run them.
Documentation aggregates and authenticated operator wrappers have different
allowed inputs and are deliberately outside this check’s coverage. The fixture
suite preserves query outputs proving indirect artifact inclusion and execution
tool exclusion.
109 - Trufflehog
Trufflehog
The normal //tools/trufflehog:repo_test scans the history reachable from the
checked-out HEAD and skips unrelated local refs. Run the manual
//tools/trufflehog:repo_all_refs_test target explicitly when an audit must
include every local Git ref, such as T3 checkpoint refs from other worktrees.
The normal //tools/trufflehog:repo_checkout_test scans the tracked checkout
with TruffleHog’s filesystem source, including materialized Git LFS payloads.
It requires tracked files to match HEAD. Git metadata and untracked files
stay outside the scan. Historical LFS payloads are outside checkout coverage.
The tests use the external tag so Bazel reruns them when undeclared Git
history or refs change instead of reusing a previous test result.
The rules project supplies the
scan-only wrapper. The tests disable credential verification and update checks.
They use the rules module’s default scanner without specifying a binary label.
allowlist.json suppresses only an exact detector, path, full commit ID, and
line tuple with a recorded reason. Files with approved historical findings remain
in the scan. There are no value hashes or regex exclusions.
For a reviewed synthetic credential in current source, prefer a
trufflehog:ignore comment on the same physical line, followed by a short reason.
The pinned scanner honors these comments before emitting results. They do not
affect earlier Git revisions: retain exact commit-and-line entries for historical
findings whose source lacks the comment. Do not add a current-commit entry for a
fixture already covered by its inline comment.
Inline-ignored results are absent from the wrapper’s events and counts. To inspect
them explicitly, run the pinned CLI with --no-ignore-tag, --no-verification,
and --no-update, selecting the required source scope and retaining output locally.
Output preserves original findings as JSON events with a suppressed flag and
ends with total, suppressed, and unmatched counts. A successful repository test
means zero unmatched findings; approved findings are still counted and retained.
Policy errors, incomplete results, and scanner errors fail the test even when
every decoded finding is approved. Add entries only after reviewing the exact
source location and recording the reason.
Use the repository secret-scan skill
for scan execution, original local finding retention, and triage.
Links
The pinned upstream binary and toolchain are owned by
rules_trufflehog. This package’s CLI
label forwards to that same binary; the former root third-party package has been removed.
111.1.1 - al_combine_files
al_combine_files
load("@com_alwaldend_src//tools/txt/rules:al_combine_files.bzl", "al_combine_files")
al_combine_files(name, srcs, **kwargs)
Create a genrule combining several files into one
PARAMETERS
| Name | Description | Default Value |
|---|
| name | genrule target | none |
| srcs | list of labels to combine | none |
| kwargs | other genrule kwargs | none |
111.1.2 - al_txt_data
al_txt_data
load("@com_alwaldend_src//tools/txt/rules:al_txt_data.bzl", "al_txt_data")
al_txt_data(name, srcs, **kwargs)
Text data
PARAMETERS
| Name | Description | Default Value |
|---|
| name | target name | none |
| srcs | sources | none |
| kwargs | filegroup kwargs | none |
112 - Vast.ai CLI
Vast.ai command-line client
Runs the unmodified upstream vastai CLI with exact versions and hashes recorded
in uv.lock. The manifest in pyproject.toml leaves
the Vast.ai version unconstrained so lock updates can select newer releases. The existing
Python dependency workflow defines the update mechanism: bazel run //tools/vastai:uv_lock.update.
The component-local environment requires Python 3.11 or later and overrides
upstream’s vulnerable Pillow and cryptography pins with secure release minimums.
The lock isolates these dependencies from the shared Python environment.
bazel run //tools/vastai -- --help
bazel run //tools/vastai -- search offers --help
This target does not install software on the host or supply credentials.
Commands that contact Vast.ai require network access; resource operations can
incur charges. Configure authentication through upstream’s supported credential
mechanism before making authenticated requests. Keep API keys out of source,
command arguments, and captured output.
Links
113 - Vault
Vault
Links
The root //:vault and //:vault.* labels delegate to wrappers in
//tools/vault/cmd/workspace, using //tools/al:config. //tools/vault:vault
is the standalone CLI; the wrappers add the existing AL environment injection.
The pinned upstream binary is owned by
third_party/com_hashicorp_vault.
cmd/ssh_key creates or reuses an Ed25519 SSH pair
directly in Vault KV v2. Callers select its mount and path and own deployment;
the tool preserves the cached identity and refuses implicit rotation.
113.1 - Backup
Run backup for Vault
113.2 - Forgejo login
Get a short-lived Forgejo token using OIDC
Plugin data supplies the default Forgejo URL, OIDC source, Vault connection,
and Vault authentication. One selected plugin_call may override nonempty
configuration fields, for example vault_auth = "forgejo_registration",
while inheriting the remaining defaults. Calls without overrides preserve
the defaults. Multiple calls with overrides and malformed configuration are
rejected before authentication; configuration values are omitted from errors.
The plugin registers token removal before issuance, using a unique token name.
Startup failure and normal shutdown attempt removal through the authenticated
Forgejo browser session, including when creation did not return a usable token.
Cleanup parses the complete applications settings page and verifies token absence
after deletion. It then logs out the invocation’s browser session and verifies
that the retained original cookie no longer accesses authenticated settings.
Cleanup failures are reported.
The parser follows the Forgejo 15.0.3 applications template: all tokens appear on
one page, each in a flex-item row with a title and a matching delete button.
It requires the applications page marker and new-token link before accepting an
empty list. Login pages, invalid token IDs, duplicates, and responses larger than
4 MiB fail closed. A changed upstream template may require a parser update.
Network requests have a ten-second timeout and honor cancellation. Forced process
termination or an unavailable Forgejo server can prevent cleanup; Forgejo tokens
do not acquire an expiry merely because this plugin created them.
113.2.1 - api
Proto docs for api.proto
Java
load("@rules_java//java:defs.bzl", "java_library")
java_library(
name = "name",
deps = [
"@com_alwaldend_src//tools/vault/forgejo_login:api_java_library",
],
)
Golang
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "name",
deps = [
"@com_alwaldend_src//tools/vault/forgejo_login:forgejo_login",
],
)
Proto
syntax = "proto3";
package com.alwaldend.src.tools.vault.forgejo_login.forgejo_login_proto;
option go_package = "git.alwaldend.com/alwaldend/src/tools/vault/forgejo_login/forgejo_login_proto";
message Config {
string forgejo_url = 1;
string forgejo_oauth_name = 2;
string vault_conn = 3;
string vault_auth = 4;
}
113.3 - Gen client cert
Generate a client certificate
113.4 - Gen root token
Generate a root token for Vault
113.5 - Harbor login
Create a harbor session using OIDC
The plugin destroys its Harbor session on normal shutdown and checks that the
original session ID is rejected by the current-user API. Cleanup uses Harbor’s
/c/oidc/logout endpoint (available in newer Harbor releases) and does not follow
the optional identity-provider logout redirect. Unsupported endpoints, network
failures, or sessions that remain valid are reported as cleanup errors. Session
expiry remains server-controlled; forced termination cannot guarantee logout.
The session destruction behavior is defined by Harbor’s
OIDC controller.
Vault tokens created by the invocation are revoked after session cleanup.
113.5.1 - api
Proto docs for api.proto
Java
load("@rules_java//java:defs.bzl", "java_library")
java_library(
name = "name",
deps = [
"@com_alwaldend_src//tools/vault/harbor_login:api_java_library",
],
)
Golang
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "name",
deps = [
"@com_alwaldend_src//tools/vault/harbor_login:harbor_login",
],
)
Proto
syntax = "proto3";
package com.alwaldend.src.tools.vault.harbor_login.harbor_login_proto;
option go_package = "git.alwaldend.com/alwaldend/src/tools/vault/harbor_login/harbor_login_proto";
message Config {
string harbor_url = 1;
string vault_conn = 2;
string vault_auth = 3;
}
113.6 - PVE login
Get a login ticket using OIDC
The plugin requests an API token with a one-hour expiry and deletes that token
on shutdown using the retained login ticket and CSRF token. The token name is
registered for cleanup before creation, so cleanup is attempted even when a
creation response is lost or malformed. Failures to delete are reported; expiry
is the fallback when shutdown cannot complete. Pre-existing credentials are not
revoked. Vault tokens created by the invocation are revoked after token cleanup.
Token deletion uses the Proxmox
user token API.
113.6.1 - api
Proto docs for api.proto
Java
load("@rules_java//java:defs.bzl", "java_library")
java_library(
name = "name",
deps = [
"@com_alwaldend_src//tools/vault/pve_login:api_java_library",
],
)
Golang
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "name",
deps = [
"@com_alwaldend_src//tools/vault/pve_login:pve_login",
],
)
Proto
syntax = "proto3";
package com.alwaldend.src.tools.vault.pve_login.pve_login_proto;
option go_package = "git.alwaldend.com/alwaldend/src/tools/vault/pve_login/pve_login_proto";
message Config {
string pve_base_url = 1;
string pve_redirect_url = 2;
string pve_realm = 3;
string vault_conn = 4;
string vault_auth = 5;
}
113.7 - Tf backend
Http terraform backend backed by Vault
The plugin tracks each running backend for shutdown, including backends created
before a later call fails. Shutdown drains HTTP requests before revoking the
backend’s invocation-owned Vault credentials. If the shutdown deadline expires,
connections are forcibly closed and the timeout is reported. Normal HTTP server
closure is not an error. Vault requests use their incoming request context. The HTTP listener accepts
state and lock payloads of up to 32 MiB and returns HTTP 413 for larger bodies.
The limit matches the default Vault TCP listener request limit.
A new Vault record is initialized with a create-only write.
Use vault_tf_backend(path = ..., labels = ...) from :defs.bzl to construct
an al_config plugin-call dictionary. The helper owns the plugin binding and
the default secrets mount; callers own their backend path and selection labels.
Optional vault_auth, vault_conn, and mount select other named inputs.
The shared //tools/al:config registers the executable and propagates runfiles.
113.7.1 - api
Proto docs for api.proto
Java
load("@rules_java//java:defs.bzl", "java_library")
java_library(
name = "name",
deps = [
"@com_alwaldend_src//tools/vault/tf_backend:api_java_library",
],
)
Golang
load("@rules_go//go:def.bzl", "go_library")
go_library(
name = "name",
deps = [
"@com_alwaldend_src//tools/vault/tf_backend:tf_backend",
],
)
Proto
syntax = "proto3";
package com.alwaldend.src.tools.vault.tf_backend.tf_backend_proto;
option go_package = "git.alwaldend.com/alwaldend/src/tools/vault/tf_backend/tf_backend_proto";
message Config {
string vault_conn = 1;
string vault_auth = 2;
string vault_secret = 3;
string vault_secret_mount = 4;
}
113.8 - Unseal
Unseal the vault
113.9 - Vault certificate login
Go command for Vault login with a PKCS#11 hardware certificate
The Go command authenticates once using the selected hardware certificate, then
atomically replaces ~/.vault-token with mode 0600. Authentication or response
validation failures preserve the previous token. Tokens and server response
bodies are never printed. Curl’s normal TLS diagnostics and provider PIN prompts
remain visible on stderr; verbose HTTP logging is not enabled.
Usage
bazel run //tools/vault/login -- <role-name>
The existing AL wrapper injects VAULT_ADDR and VAULT_CACERT without requiring
an existing Vault token. The address must use HTTPS. The role name is the name
configured in Vault’s certificate authentication method.
Automatic discovery ignores trust modules and examines public certificates on
hardware tokens. It excludes CA certificates, expired or not-yet-valid
certificates, and certificates unsuitable for TLS client authentication. It
prefers certificates whose common name or DNS identity matches the role name
(exactly or as the first DNS label), choosing the newest valid matching
certificate. A sole usable hardware certificate can also be selected when the
role has a different name. Selection does not depend on token enumeration order.
The private key is selected by the certificate’s object ID; a certificate’s
label is not reused as a private-key label.
To override automatic selection, provide the certificate’s PKCS#11 URI:
bazel run //tools/vault/login -- <role-name> \
--certificate-uri 'pkcs11:token=example;id=%01;type=cert'
Provider mode (--certificate-type PROV) is the default and supports OpenSSL 4.
Use --certificate-type ENG only for an older engine-based installation. Both
certificate and private-key loading use the selected mode. PIN handling belongs
to the native PKCS#11 provider and its controlling terminal; do not put a PIN in
the certificate URI. No global OpenSSL configuration is changed.
The Go binary invokes the existing host p11tool for automatic discovery and
curl for PKCS#11 TLS signing. It does not invoke a shell, jq, grep, awk, or tail.
Curl configuration files are disabled for this request; certificate settings,
HTTPS, JSON encoding, bounded response size, and the request timeout are explicit.
Login does not follow redirects or retry. Raw trailing curl arguments have been
replaced by typed options. --timeout defaults to one minute; --token-file
selects a different destination. Existing symbolic-link destinations are rejected.
Offline validation
bazel test //tools/vault/login:login_test
bazel build //tools/vault/login
The command test uses native-tool fixtures written in Go and synthetic tokens.
It verifies provider/engine selection, hardware and role selection, certificate
validity and usage filtering, response rejection, timeout,
secret-free diagnostics, token preservation, and private atomic replacement.
Its undeclared test outputs contain login-results.json. These checks do not
prove a live hardware login; that requires the real certificate and Vault role.
114 - Vial
Bazel rules for Vial
Links
114.1.1 - al_vial_configs
al_vial_configs
load("@com_alwaldend_src//tools/vial/rules:al_vial_configs.bzl", "al_vial_configs")
al_vial_configs(name, srcs, visibility, **kwargs)
Generate vial config targets
PARAMETERS
| Name | Description | Default Value |
|---|
| name | generated docs archive name | none |
| srcs | vial config | none |
| visibility | visibility | None |
| kwargs | kwargs for template_files | none |
115 - Workspace status
Workspace status script
Links
116 - X API schema fetch tool
Authenticated upstream schema download for dependency maintenance
This first-party developer tool implements the X API schema download command.
Its maintained entry point belongs to the dependency package:
bazel run //third_party/com_x_api_openapi:fetch_schema
That target injects the Article uploader’s existing OAuth 1.0a credentials.
The command downloads into ignored out/x_sdk/openapi.json by default and
accepts --out to select another destination. It validates a bounded response
and atomically replaces the download only after success. It does not publish
the snapshot or alter dependency pins. The dependency’s
update procedure owns those steps.
The command and its local HTTP E2E fixtures live in cmd/fetch_schema.
The runtime SDK consumes the pinned mirror and
does not own this maintenance command.
117 - X CLI
Pinned upstream xurl command-line client for the X API
This target runs the unmodified upstream xurl CLI. The release archive and
integrity pin belong to
third_party/com_github_xdevplatform_xurl.
The current toolchain supports Linux x86-64.
bazel run //tools/xurl -- version
bazel run //tools/xurl -- --help
xurl uses its native ~/.xurl/auth.yml credential store. Startup can create or
migrate this store and import ~/.twurlrc, even for help and version commands.
There is no upstream configuration-path override. Automated use must isolate
these paths; do not place credentials in command arguments or enable verbose
logging, which prints the Authorization header.
Select --auth oauth1 and --app <name> explicitly when comparing the Article
uploader with the CLI. Otherwise xurl prefers stored OAuth 2.0 credentials.
--data accepts literal JSON, not curl-style @file input. The CLI follows
redirects and uses Go’s default transport; a single invocation does not provide
the uploader’s stricter redirect and request-replay safeguards.
This generic tool supplies neither repository credentials nor a Markdown
converter. The Article uploader
owns those operations and its Vault injection flow. Creating a draft is a
separate, quota-consuming operation from inspecting this CLI.
Links
118 - Ykman
Ykman (Yubikey Manager)
Links
Python dependencies use the shared uv locking workflow.
Dependencies are declared in pyproject.toml and locked in uv.lock.
Run //tools/ykman:uv_lock.update to update the native lock and review its
diff. Build //tools/ykman:uv_lock to generate it without source writes.
The sandboxed resolution action requires network access to PyPI.