Repository source deployment preparation (#4185)
G2b supplies OFF configuration and executable prerequisite proofs. It does not release repository source. Ordinary builds keep the production disclosure gate closed; G3a owns runtime/session/remember enforcement, G3b the protected result path, G3c release wiring, and G4 deployed acceptance. No flag, live environment, cluster or infrastructure was changed by this implementation.
Configuration and rollout order
Both operator Compose stacks include internal Knowledge on 9101 with the native
/app -healthcheck, explicit restart policy and the existing embedding pin. Its
only bridge is repository-source-internal (internal: true), shared with CE,
PgBouncer, Redis, Ollama and the storage emulator. PostgreSQL is an ordering
prerequisite; its traffic passes through PgBouncer. Neither 9101 nor source9444
is published to the host. Source transport uses dedicated read-only directory
mounts; it does not read the ordinary service certificate paths.
Dev requires a verified immutable UPSQUAD_KNOWLEDGE_IMAGE_TAG. Tenant inherits
the existing immutable UPSQUAD_IMAGE_TAG, with an explicit Knowledge override
allowed. The first compatible image must contain the native health probe.
Publish the reviewed image, have the authorized operator verify/set the dev pin,
then deploy/reconcile changed Compose. Missing the new dev pin rejects the
entire Compose config and reconciliation, even with source OFF. It does not
merely leave Knowledge unavailable. No future tag or latest fallback is
invented. See the recorded rollout disposition.
The reconciler now propagates failed service enumeration before snapshot, pull or up, and uses health-check exit status while retaining the failure reason. Mocked full-script proofs exercise absent/configured pins, Knowledge image inventory, unhealthy refusal, snapshot inclusion and a Knowledge-only configuration change with unchanged image identity. These are not live reconciliation or image-publication receipts.
The production tenant profile still needs the separate ordinary TLS disposition
in #4187. CE and
orchestrator have bidirectional ordinary gRPC clients; Memory calls orchestrator
governance. Source CA files and edge TLS do not define that trust policy.
Synthetic tenant tests explicitly supply disposable ordinary material. With it
absent, actual CE refuses startup before listeners/readiness, but existing
synchronous pool.Close in the TLS error branch can stall before logging/exit.
The proof captures absent listeners and an owned diagnostic stack/termination;
it does not report a natural immediate exit. G2b changes no ordinary issuance,
rotation, lifetime or startup-cleanup policy.
Staged audiences and switches
MCP_GATEWAY_PUBLIC_BASE_URL is the shared mint base. Knowledge accepts
{base}/mcp/upsquad-knowledge; Memory accepts {base}/mcp/upsquad-memory.
CE, orchestrator and all configured MCP audiences must agree on the base.
Trailing slashes are normalized at boot; token audience comparison stays exact.
Public issuer/base URLs remain distinct from the configured internal JWKS
network address. mnet's WikiJS audience stays distinct and unchanged.
| Source flag | Session enforcement | G2b boot behavior |
|---|---|---|
| false | false | Legacy-compatible boot, no source material/listener/tool advertisement |
| false | true | Exact audience validation, source absent; G3a implements runtime/marker behavior |
| true | false | Startup refusal before serving |
| true | true | Strict source TLS/audience prerequisites; production release still refuses |
Both switches default false and reject explicitly empty/malformed values in CE, Knowledge and Memory; other legacy boolean parsing is unchanged. Arming either switch is outside this runbook's implementation authority. Later arming requires G3 completion, credential refresh and the ten-minute gateway token drain. Source OFF must not disable G3a marker restrictions. G2b boot checks alone do not implement those restrictions.
Source identity provisioning and rotation prerequisite
G2b does not provision real issuer material. Before any later authorized source activation, DevOps must record the concrete environment-specific issuer/root fingerprints, owner-readable file provenance, leaf lifetime and rotation window privately in the existing Vault/SecretManager operational record. Public receipts identify the exact CE/Knowledge URI SANs, validity/EKU and hostname checks without printing certificates, keys or credentials. Missing issuer provenance is an operational prerequisite, not permission to create a new CA.
The approved source procedure uses bounded trust overlap: distribute a bundle containing old and new environment roots, roll the clients and server with the new leaves, verify both exact service identities and hostname/expiry checks, then remove the old root and roll again. Constructors load files at startup; a mounted file replacement alone does not prove adoption. Keep source disabled through an incomplete/failed rotation and preserve the closed release boundary; never use insecure TLS, ambient OS roots, development fallback or the unrelated ordinary service CA. The private record sets the concrete lifetime/window; this code change does not invent or activate one.
Kubernetes is render-only
Source9444 has paired explicit namespace/pod peers between Knowledge and CE. The dedicated optional Secret mounts permit OFF startup without material; ON fails if required material is absent or invalid. ExternalSecret templates name explicit operator replacement keys in the existing store. Never substitute ordinary service or cross-environment CA material.
CE labels use includeSelectors: false to avoid injecting labels into other
pods' NetworkPolicy peer selectors. Explicit Deployment, Service, policy and PDB
selectors retain every label from the pre-change render, including each overlay's
environment label. No immutable-selector transition or recreate is proposed.
The proof archives and renders the actual Git merge base for every profile, then
independently compares existing selectors and rejects a dropped-label mutant.
CI checks out full history and binds the base to the PR base SHA or merge-group
base SHA and the actual event head; missing history, unsupported events and a
HEAD-versus-HEAD baseline fail. Local proofs use merge-base HEAD origin/main.
Receipts retain the base SHA, archive hash, exact commands and raw render hashes.
This change performs no apply. Knowledge retains its existing node-originated
kubelet TCP9101 ingress allowance; no CNI host-traffic exemption is assumed.
Knowledge mnet HTTPS is restricted to existing Google API VIP
199.36.153.4/30. Vertex hostname, provider, model and dimensions are unchanged.
The render verifier evaluates the union of all Egress policies selecting the
Knowledge pods; a second broad policy is a failure. DNS, metadata, Cloud SQL,
Redis, internal JWKS and private source reachability remain explicit. See
tenant install prerequisites
for private DNS/PGA/route/WorkloadIdentity verification. Static rendering does
not verify any live route, DNS result or provider call.
Evidence and reproduction
Use an already installed Go1.26 compiler and put its explicit directory on PATH;
GOTOOLCHAIN=local must not silently select an older system compiler. Installed
Docker/Compose, Kustomize, PyYAML, golang-migrate, pgvector:pg16 and
the committed redis:7.2-bookworm@sha256:eff04a11793238f661f4c974efcb33b715adb8c5c7e9272430d99851375d68d0 are prerequisites. Scripts refuse missing tools/images and
never pull or install. Dependencies and service images are not deployment
prerequisites proven by a synthetic render tag.
The exact wrapper modes are:
unset GH_TOKEN GITHUB_TOKEN GH_DEBUG
export GOPROXY=off GOTOOLCHAIN=local GOMAXPROCS=2 GOFLAGS=-p=2
bash scripts/verify-repo-source-deployment.sh --mode render --output /tmp/g2b-render
bash scripts/verify-repo-source-deployment.sh --mode isolated-fakes --output /tmp/g2b-isolated
bash scripts/verify-repo-source-deployment.sh --mode acquisition-memory --output /tmp/g2b-memory
Use new output directories. The process modes create an isolated internal network, exact-ID scratch containers, genuine application-role databases and disposable credentials. They run full migrations and full DOWN/zero tables, compare database rosters, remove all owned containers/anonymous volumes/network and source/ordinary key material, and preserve cleanup receipts. No durable source history is deleted to make downgrade pass; only exact owned workload databases are disposed.
CE memory proof builds the actual command graph with reposource_memoryproof,
substitutes owned dependency leaves and drives real acquisition, parser,
decoder, arena/cache, quota and final closed Release in that same process. It
also executes the real GenerationRuntime, tokenizer, accounting and publication
against owned SCM/model-gateway fixtures. Four caller lifetimes overlap, but
56MiB of a64MiB arena admits only one; the other three honestly refuse. No arena
budget or release gate is widened. Cancellation covers transport, parser,
decode and release. Five-minute cache expiry uses real elapsed time.
Knowledge memory proof runs its actual command/client/exchange/decoder graph
against a synthetic responder. This is whole-process synthetic decode RSS,
not a successful production source hop or G3 acceptance. Ordinary binaries
exclude the engineering entrypoints and cannot select them with environment
variables; an actual mTLS/JWKS/session-authorized ordinary source request still
returns source_service_unavailable with zero acquisition operations.
The proof-tag-only collector reads its own /proc/self and cgroup v2 files,
so it also works across the existing CI runner/DinD PID boundary. Docker's
inspect PID is recorded separately from the container PID and cross-checked
with container identity, network address, executable and start time. No host
PID namespace, privileges or runner changes are used. Kernel HWM/memory.peak
cover startup from exec and are never reset; periodic collection begins when
the engineering control endpoint is available, before readiness/workloads.
The single-process sample population excludes the native healthcheck child;
isolated-fakes executes that real child separately at the same enforced cap
and verifies no OOM or restart. Collection overhead is included.
Every 50 ms sample records PID/start ticks, complete process population, RSS/HWM and cgroup current/peak/swap separately. Process and host swap evidence are separate; changed host swap counters invalidate the latter. Measured limits use an explicit committed headroom formula and must pass the same scenarios under enforced memory/no-swap caps with no OOM or restart. Calibration receipts are diagnostic; they are not substituted for the capped final mode. The committed sizing report preserves failed local host-swap receipts and the 400 MiB CE / 96 MiB Knowledge provisional limits. Both-profile capped CI proof must pass before accepting those values.
The full gate records actual producer/checker exits before the final checker:
bash scripts/verify-repo-source-g2b.sh /tmp/repository-source-g2
python3 scripts/check-repo-source-g2-envelope.py /tmp/repository-source-g2
The required DB lane runs this on PR heads and merge groups, reusing its existing Go/migrate/Pgvector setup, the repository's Kustomize 5.4.3 setup and committed Redis image digest. PyYAML presence is checked. These normal CI acquisition steps were explicitly disposed by the coordinator; the proof wrappers remain no-install/no-pull. The existing CI host's documented no-swap posture is a candidate environment, not a substitute for actual counters.
Final G2 acceptance also requires the two explicit G2b Go parents, all five G2a parents/55 children, preserved G1 evidence, all three mode rosters and semantic mutants. The independent checker rejects omitted children, modes, processes, samples, scenarios and unexecuted producers. CI must execute the actual producers on both the PR head and merge group; skipped checks do not establish acceptance.
Rollback boundary
The owned OFF restart/fresh-refusal test is a prerequisite rehearsal, preserving grants, markers and spent state. Later deployed acceptance starts at the authorized environment edit and includes workflow, queue, checkout sync, reconcile, restart/drain and fresh refusal within300s. Tenant uses its supported Compose path. Kubernetes remains render-only; no300s cluster rollback lever is claimed. Do not downgrade shared schema or disable session enforcement to turn source OFF.
The existing Wave 2 smoke, daily Wave 2 and golden-flow CI lanes supply an explicit main-${{ github.sha }} test-render-only Knowledge pin because Compose interpolates the entire file. Their selected service/dependency closures exclude Knowledge, so those lanes neither pull nor boot it and do not establish its deployment readiness. The required G2 process lane supplies the separate actual-binary proof. The operational dev-deploy path receives no synthetic fallback.
Uninstalled OFF-only certificate staging
The certificate staging command produces a complete private generation for the existing two HOST_DIR selectors. A staged generation is not adopted: this command never changes either selector, source intent/flags, or running services. Real invocation requires the runbook's operator/custody/provisioning bindings; selection, E2 composition, actual peer adoption and connection drain remain separate gates.
Protected initial OFF preparation (#4718)
The installed command accepts exactly repo-source-control bootstrap-off in
addition to the existing read-only status. It requires the protected fixed
install.json and writers.json, the allowed actual operator EUID, current
host/boot binding and all three pre-provisioned empty beta-dev leaves. It does
not provision directories or policies. It creates exclusive stable locks, two
generation-bound READY/bootstrap records, then durable disabled intent. Initial
publication never replaces an existing destination, including an identical one.
Success is exactly off-prepared followed by a newline, empty stderr, and a
zero exit within the original invocation deadline. A complete line without a
timely zero exit is not success. Receipts bind the committed control instance,
epoch and both generations without claiming live peer identities. Receipt or
output failure leaves committed state intact. After the first exclusive creation,
any failure retains the exact created prefix; retry refuses occupied leaves and
never repairs, erases or resumes an attempt. A failure before the first creation
leaves the installation unchanged. Operator intervention is a separate capability.
This prepares only the filesystem control store. It neither reads nor writes canonical configuration, which may still be true, and grants no service start or runtime continuation authority. Installed status still requires its unchanged full qualification of actual live peers and refuses a peerless bootstrap. False-only configuration publication, disable/recovery, activation, adoption, restart/drain, renewal and deployment remain outside this capability.
The single invocation clock includes authorization, loading, lock acquisition, publication guards, receipts and output, retaining the 300-second ceiling and 30-second reserve. Deadline checks cannot interrupt a blocked filesystem syscall; source fixtures do not establish a strict wall-time termination guarantee. Actual cross-UID ownership/readability, physical cross-device behavior, host equivalence, protected provisioning, binary/issuer/custody records, installation and runtime cutoff proof remain separately admitted operational holds under #4222/#4715. Same-UID synthetic metadata proof is not privileged production ownership proof.
Directory creation uses bounded temporary staging names in the pinned operator
intent root, because mkdir does not return an inode descriptor. Each directory,
including a nested generation directory, is first pinned there, assigned metadata
through that held descriptor, and moved without replacement to its final role
location. Both parents are synced after each move. Failed staging names remain
part of the retained prefix; successful preparation leaves no staging names.
This mechanism additionally requires distinct production operator and runtime UIDs, and the same device for all three leaves, checked before any creation. The operator-owned intent root must remain unwritable by services. Cross-device layouts refuse; there is no copy fallback or permission repair. The private synthetic-root test route permits same-UID fixtures solely to verify algorithm and metadata handling. It does not qualify real service/operator isolation.
Cooperative ordinary configuration writers (#4721)
The signing-key writer and Model Gateway configuration lever share the existing
stable beta-dev intent.lock for their final local read, revalidation, rebuild
and publication. This capability does not publish the protected source overlay,
change source selectors/enablement, or implement installed disable/recovery or
service adoption. Installed context-engine and upsquad-knowledge-mcp lever
requests refuse until their separate adoption path is available.
The fixed writer and installation policies, intent directory/lock and protected
three-key overlay are mandatory when any fixed installation marker exists.
operator.json and the installed project directory also trigger installed
classification; when present, their identities and custody are qualified. An
incomplete or ambiguous installation refuses. Absence is accepted only beneath
qualified no-follow ancestors; a dangling ancestor alias is not absence. Only ENOENT for every marker and a
bounded source-free ordinary input permits canonical beta unmanaged behavior.
Explicit unrelated source-free tenant targets retain legacy behavior. A beta
alias, mixed beta project/environment or source-bearing alternate target refuses.
One owner process retains the original policy, ancestor, target and key references. The signing writer snapshots key content and custody before OpenSSL generation, which runs outside the lock using a private staged-file descriptor. Supported legacy key-directory aliases retain every traversed link and original real-parent identity, custody and resolution through completion; a redirected alias refuses even if the originally resolved key is unchanged. At the lock, both writers reread the current ordinary environment: selected-input conflicts refuse, while unrelated supported-writer edits survive. A supported predecessor may replace the environment inode even with identical bytes. This one boundary establishes a separate publication snapshot under the lock, with original parent/custody and selected occurrence/absence checks. The original authority, key and ancestor pins never refresh. Any subsequent environment rebind before publication refuses; byte changes do not authenticate a writer. The ordinary environment keeps its own owner/group/mode, separately from the protected overlay's policy metadata. Nonselected bytes, order, line endings and an unterminated last line are retained. No helper repairs ordinary ownership; the signing writer alone retains its existing authorized root handover branch.
The lock is never created or replaced here and is never held over generation, log capture, Docker, network or readiness operations. Acquisition is bounded by two seconds and, for MG, the original whole-operation deadline. These checks do not interrupt a stalled filesystem syscall. Cooperative trusted host/writer custody is an operating assumption: read/compare plus atomic rename under flock is not kernel compare-and-swap against hostile same-UID or noncooperating writes.
Signing prepares and fsyncs both stages before publishing the key. A proved
pre-environment-publication failure permits only a verified, fsynced key restore
or removal of the writer's own newly created key. A committed or unknown
environment rename never permits key-only rollback. Exit 3 retains the actual
visible pair and recovery dependencies; an operator must diagnose and perform
separately authorized locked recovery. Do not replay the writer or use unguarded
mv recipes as recovery. SIGKILL or power loss between the two renames can still
leave an incomplete pair. Local publication is not running-service adoption,
source OFF evidence, restart authority or production-key provisioning.