Revision: 1 Last modified: 2026-12-04T19:00:00Z
labelctl.sh is the bash entry point to the constitution label-sync system (§11.4.182 labels plus
real-time sync).
It exists because the real implementation is Go (labelctl and label-busd), and a consumer project
should not need a manual build step after a constitution pull. So this wrapper does three things:
- builds the Go binaries when they are missing or stale;
- otherwise skips straight through;
execs the requested binary, becoming that process.
"Stale" is not a guess: it is bincache.sh's ls_bin_stale, which keys on a digest of this module's Go
sources recorded in the cache's .source-digest stamp. A different source tree, or uncommitted/newer
sources, triggers a rebuild. Every consuming project therefore behaves identically after a pull without
anyone remembering to rebuild.
bash.- A Go toolchain only when a build is needed; a prebuilt binary is used when the toolchain is absent.
bincache.shbeside it (sourced; a missingbincache.shexits2).- The Go sources for
labelctl/label-busd.
Environment variables (names only):
| Variable | Meaning |
|---|---|
LABEL_SYNC_DIR |
State dir. Default $HOME/.local/state/constitution-label-sync. |
LABEL_SYNC_BIN |
Binary cache dir. Default is per checkout: ${XDG_CACHE_HOME:-$HOME/.cache}/constitution-label-sync/bin-<hash of this module's path> (see bincache.sh). |
LABEL_SYNC_LABELER |
Canonical labeler. Default: sibling ../multitrack/track_branch_label.sh. |
# any labelctl argument is passed straight through
bash scripts/label-sync/labelctl.sh list --text
# run the daemon
bash scripts/label-sync/labelctl.sh busd
# build only, then print the bin directory
bash scripts/label-sync/labelctl.sh --build
# print the bin directory without building
bash scripts/label-sync/labelctl.sh --bin-dir| Code | Meaning |
|---|---|
0 |
OK — the exec'd binary succeeded, or --build / --bin-dir completed. |
1 |
A finding or invalid input, from the binary. |
2 |
Cannot determine: no Go toolchain and no prebuilt binary, the build failed, or a usage error. 2 is never a pass. |
2 is the code that matters operationally. A label-sync that cannot run is not a label-sync that works,
so the wrapper refuses rather than silently continuing unlabelled.
- No Go toolchain and no prebuilt binary.
2. Cannot determine the label state; must not be read as success. - A failed build.
2, with the build output surfaced. - Binaries present and not stale. No build; straight to
exec. This is the common steady-state path, so it stays cheap. - A different source tree. The per-checkout cache key means checkout A cannot run checkout B's binary
— the defect (
review-2finding 13) that a single shared cache caused. - Uncommitted or newer Go sources. Detected by the source digest → rebuild.
bincache.shmissing.2immediately, naming the missing file.LABEL_SYNC_LABELERpointing at a missing labeler. Surfaced by the binary, which owns that resolution.
- Sources
bincache.sh(exit 2if absent). - Handles the two no-exec flags:
--bin-dirprints the cache directory and exits0;--buildbuilds and prints it. - Otherwise resolves the cache directory and asks
ls_bin_stalewhetherlabelctl/label-busdneed rebuilding; if both are fresh, skips the build. - Builds when needed, recording the
.source-digeststamp so the next run can tell. execs the requested binary with the caller's arguments, so the exit status is the binary's own.
Sources scripts/label-sync/bincache.sh.
Called by scripts/label-sync/hooks/label-sync-lib.sh (via ls_ctl) and
scripts/label-sync/mcp/label-mcp.sh.
Related: scripts/label-sync/install_label_sync.sh (wires the hooks that call this),
scripts/multitrack/track_branch_label.sh (the default canonical labeler).
Cross-reference: docs/label-sync/CONTRACT.md.
See also docs/scripts/bincache.md, docs/scripts/label-sync-lib.md and docs/scripts/label-mcp.md.
2026-12-04 — bash -n scripts/label-sync/labelctl.sh → exit 0. bash scripts/label-sync/labelctl.sh --bin-dir prints the per-checkout binary cache directory and exits 0
without building anything.