Repository source certificate staging
repo-source-certificates stage --config <protected-binding-file> obtains fresh
leaves for Context Engine and Knowledge and publishes one private complete
certificate generation. This is an uninstalled local oneshot. It is not
scheduled, connected to deployment, or authorized for operational invocation by
this change. Its result is staged material, never evidence of adoption or source
release. It cannot edit source flags, either HOST_DIR selector, E2 intent, or a
running service.
The later S1 selector/adopter consumes the two returned directory references via
REPO_SOURCE_CE_HOST_DIR and REPO_SOURCE_KNOWLEDGE_HOST_DIR. That composition
must bind actual E2 intent/CAS/clean-handoff and the supported config writer and
reconciler, verify both service identities and old-connection drain, and preserve
operator veto/no automatic rearm. Staging does not implement those interfaces.
Reviewed source and operating boundary
The fixed adapter/profiles follow qualification source
d315d6867ff7982de322d7346f2a98fe799cb680,
scripts/step-qualification/{compatibility.py,profiles.py,ce.tpl,knowledge.tpl}:
Step CLI 0.31.0, CA 0.30.2, explicit offline-token key path, and /1.0/sign.
The retained attempt 14 qualification is reused; these tests do not repeat it.
Before this change becomes review-ready, bind the actual merged #4375 source
and show equivalence to those qualified files. An unmerged source is not a
landed dependency.
The founder's settled Step selection and beta two-stage cutoff are recorded in #4222's decision relay. The implementation reset permits bounded OFF engineering. Neither authorizes provisioning. Real execution still requires named primary/backup and alert owner, host/private custody and backup records, accepted qualified binary delivery, exact protected paths and permissions, explicit approved lifetime, and provisioning/issuance authority. A configuration reference is an audit binding, not proof of that external gate. No test value, fixture lifetime, fixture port, or fixture key is an operational default. No CA initialization, installation, root/intermediate/enrollment key creation, timer, service operation, or activation follows from this runbook.
Configuration contract
Supply one absolute, clean, regular JSON file owned by the invoking user, with no group/other permissions. Unknown fields, duplicate names, trailing JSON, missing fields and files over 16 KiB are refused. Errors do not echo inputs. All fields below are required; there are no environment, home-directory, tenant vault or running-container defaults.
| Field | Required binding |
|---|---|
policy | Exactly step-0.31.0-ca-0.30.2-repository-source-v1. |
qualified_source | Exactly d315d6867ff7982de322d7346f2a98fe799cb680; retained qualification source, subject to the merged dependency above. |
qualification_reference | Nonsecret record for accepted qualification and exact binary delivery. |
operation_reference | Nonsecret approved provisioning/issuance record for this invocation. |
lifetime_approval_reference | Nonsecret review/approval for the explicit lifetime substitution. |
cli_path, cli_sha256 | Absolute protected executable path and lowercase SHA256 of its bytes. The command verifies it before launching any child. No arbitrary flags or shell command fields exist. |
root_path, root_sha256 | Dedicated root certificate file and lowercase SHA256 of its DER certificate. |
intermediate_path, intermediate_sha256 | Dedicated intermediate file and lowercase SHA256 of its DER certificate; signature must chain to that root. |
endpoint | Explicit https://127.0.0.1:<port> authority, no userinfo/path/query/fragment. The approved provisioning binding chooses the port. |
staging_parent | Existing absolute clean directory, owned by the invoking principal, mode 0700. |
runtime_uid | Explicit numeric UID equal to the invoking UID. No chown or guessed service UID. |
directory_mode, file_mode | Exactly 0700 and 0600. A deployment requiring another owner or group policy needs separate review. |
lifetime | Positive Go duration in whole seconds, explicitly approved and shorter than remaining root/intermediate validity. The returned leaf must have exactly that duration. |
ce | Object with issuer: "core4222-ce", explicit kid and protected key_path. |
knowledge | Object with issuer: "core4222-knowledge", distinct explicit kid and protected key_path. |
References and kids are bounded nonsecret identifiers using letters, numbers,
._:/#@+-, up to 192 characters. Do not place credentials in references or file
names. Enrollment files contain the already provisioned private P-256 JWK with
exact kty, crv, x, y, d, kid, use: "sig", alg: "ES256"; the
binding verifies kid and public/private correspondence. It never generates
these keys. Root/intermediate files contain exactly one PEM certificate each.
Every path component must be nonsymlink. Files must be regular, not writable by group/other; secrets and the binding file must be private and owned by the invoking user. Root-owned public input/executable files are permitted. Ancestor directories must belong to the invoking user or root. Writable ancestor directories are refused unless sticky-bit protected. These checks are input hygiene under the existing host principal boundary, not a new protection against that same user or host root. The installed qualified executable and its protected directories must not be mutable by an untrusted principal.
The fixed token-only-absent.json below the staging parent must not exist,
including as a broken symlink. It is passed only to Step's explicit-key offline
token command. No live CA configuration/database is read. The CLI receives only
fixed arguments and file references; tokens/CSRs travel in memory to HTTPS.
Its environment contains only PATH and task-owned HOME/STEPPATH/TMPDIR. The HTTP
client trusts only the configured root, checks the server's loopback IP, requires
TLS 1.3, ignores proxy environment variables, and refuses redirects.
The two profiles are fixed: CE subject/DNS context-engine, URI
spiffe://upsquad.internal/platform/context-engine-source, serverAuth only;
Knowledge subject upsquad-knowledge-mcp, no DNS, URI
spiffe://upsquad.internal/platform/upsquad-knowledge-mcp, clientAuth only.
Both require fresh distinct P-256 keys, exact subject/SAN sets, digitalSignature
only, non-CA, and no extra/unknown EKU or hidden SAN type. Existing
RepositorySourceTLS performs real key/chain/validity/role checks. The stager
also checks the exact dedicated intermediate/root and chain lifetime and
retains the complete returned chain. It does not change application acceptance.
Publication and outcomes
The command takes a nonblocking .stage.lock advisory lock under the owned
parent. Busy is failure. The reusable private lock file remains after exit; it
is not an intent record. All participating staging invocations use this lock.
A fresh private temporary sibling holds context-engine/ and knowledge/,
each with ca.crt, tls.crt, and tls.key. File/directory syncs precede Linux
renameat2(RENAME_NOREPLACE) publication as gen-<random identifier>; the parent
is synced before success. Unsupported no-overwrite publication fails closed.
Existing gen- generations are inspected only for public-key reuse (at most
1024 parent entries); unsafe/malformed generations refuse staging. Existing
active or foreign content is never overwritten or selected.
Private permissions do not make a generation immutable against its own user. Immutability here means the command never updates an existing generation. Retire old generations only through the later explicitly authorized lifecycle, not by this command. Cleanup removes only this invocation's unpublished temporary resources and does not claim secure erasure.
One generation makes at most one issuance attempt per role. There is no retry, replay journal, renewal/rekey command, controller or queue. The work budget is 80 seconds inside a 90-second overall allocation with 10 seconds reserved for owned termination/cleanup; each CLI/HTTP operation is capped at 30 seconds and clipped by the work context. Child cancellation kills its owned process group; pipe drain is bounded at two seconds. Ordinary local filesystem operations must complete; these are implementation bounds, not measured operating fit or proof of the separate 300-second source-cutoff contract.
CLI stdout is capped at 32 KiB, stderr at 16 KiB; issuer bodies and material at 256 KiB. Overflow fails. Only status 201 is eligible for certificate validation. Timeout, connection loss, malformed response or cleanup failure is failure, never proof that unseen issuance did not occur. No automatic retry follows.
Exit 0 emits bounded JSON with outcome: "staged", generation ID, both directory
references, public certificate fingerprints/expiries, policy and qualification/
lifetime references, and cleanup status. Exit 1 reports fixed sanitized errors;
usage errors return 2. A parent sync failure after rename reports
publication_unknown, with the generation identifier and no usable directory
result. The complete unselected generation may remain for explicit operator
inspection; the command neither deletes it nor claims publication success.
Cleanup failure is reported separately and preserves the original error.
Results are not authoritative E2 intent or adoption evidence.
Focused verification
The two packages use Go-generated ephemeral fixtures, a fixed fake executable,
and local httptest HTTPS. No real Step, CA setup, host issuer keys, Docker,
network acquisition, database, provider/model call or production state is used.
From the assigned checkout, using the already installed Go 1.26.9 binary:
git diff --check
GOPROXY=off GOTOOLCHAIN=local GOMAXPROCS=2 GOFLAGS=-p=2 timeout --signal=TERM --kill-after=10s 300s go test -race -count=1 -timeout=240s ./internal/reposourcepki ./cmd/repo-source-certificates
Missing toolchain/cache prerequisites are setup failures, not permission to install or download. Staging tests do not complete installation, scheduling, selection/adoption, composed source-release proof, live cutoff, G3/G4 or activation, and this deliverable does not close parent #4222.