refact(comments): state the mechanism, not the incident

Every comment that invoked a 'law' (50 word-boundary sites across 28
tracked files) now states what is going on and why, in terms that
transfer to any project: gate twins drift until one side greenlights
what the other refuses; a tag re-points while a digest pins; a
restrictive engine behavior belongs to the runtime that imposed it and
must be re-tested, not inherited; a speculative head is tensors in the
file, not a flag; snapshot links dangle where the container resolves
them; exit 0 is a clean stop to systemd, so a self-exiting daemon on
on-failure goes dark reporting success. Event narratives and dates are
gone from these comments; the mechanics carry the argument.

Behavior-identical: bash -n, py_compile, yaml parse, full bats suite
408/408 green. One symbol rename rides along (stack script local
scale_law -> scale_contract, with its log text).
This commit is contained in:
Frank committed 2026-10-14 13:36:40 -07:00
1 parent 65bd5ccea7
commit d4ce76b68b
28 files changed
+195 -164

No files matched your search

+14 -12
View File
@@ -1,10 +1,11 @@
#!/usr/bin/env bash
# llm-gates.sh — the artifact gates every LLM endpoint runs before it starts.
#
# Why this file exists: the fleet law from the 2026-10-01 crash-loop is that
# a serve script and the deployer must refuse the SAME missing/truncated
# artifact, the SAME way. When the two gates were hand-written twins they
# drifted mid-cutover — green deploy, red unit, every time the payload moved.
# Why this file exists: every LLM endpoint gates its payload twice — the
# serve script at start, the deployer before dispatch. Two hand-written
# copies of the same checks drift apart in wording and strictness, and the
# drift surfaces as deploy-time disagreement: one side passes, the other
# refuses, and the failure lands in production instead of in the gate.
# Both sides source this library, so the refusal is one text and one rule.
#
# Contract (public interface):
@@ -27,9 +28,10 @@
# disagree. The deployer's old "halogen vision tower" and the serve script's
# "vision-tower" were one gate in two vocabularies that no grep could join.
# The size law is equality, not a floor, for `require_bytes`: a hub fetch
# that truncates is the fleet's standing hazard (curl exits 0 on 401/403 and
# writes the error body as the artifact), and the declared byte count is a
# Size checks use equality, not a floor, for `require_bytes`: a fetch that
# truncates looks like a success (an HTTP error exit is often swallowed, and
# the error body is written in the artifact's place), so "exists and is big
# enough" is not proof of the right artifact. The declared byte count is a
# contract in both directions — a bigger file is a DIFFERENT artifact.
# GATE_PREFIX names the endpoint in every refusal (e.g. frank-dragoon). The
@@ -38,7 +40,7 @@
# shellcheck disable=SC2034
: "${GATE_PREFIX:=gate}"
# Two bash laws make the `return 1` at every call site load-bearing:
# Two bash behaviors make the `return 1` at every call site load-bearing:
# * a function whose body ends inside an `if` returns the CONDITION's
# status (true = 0), so a gate that ends on its own refusal prints the
# refusal and reports SUCCESS;
@@ -100,10 +102,10 @@ require_min_mib() {
}
# require_dir_files — DIR must be a directory and every named member a
# regular file (the flat-tokenizer law: snapshot symlinks dangle in the
# container mount even when the directory itself is real. A symlinked
# DIRECTORY is refused too: a HF cache snapshot can link the directory
# itself, and a link dangles inside the container mount.
# regular file, never a symlink: snapshot layouts link files into place, and
# a link dangles inside the container mount even when the directory itself
# is real. A symlinked DIRECTORY is refused too — the same layout can link
# the directory itself, and the link dangles identically.
require_dir_files() {
local dir="$1" label="$2" hint="$3"
shift 3