Skip to main content

Repository source control: source lifecycle and read-only qualification (#4261)

The original control-only proof remains CONTROL_ONLY_PASS; FULL_E2_PENDING. Subsequent source integration connects the ordinary CE and Knowledge constructors, owned source/status lifetimes and fixed read-only installation loading. This does not establish an installed or deployed operating contract. The administrative CLI now exposes only exact status against a separately provisioned protected OFF installation. All installed mutations still refuse before loading. No command-line switch supplies paths, identities, arbitrary commands, deadlines or enablement.

The issue body and first-stage addendum are the contract, SHA256 f1d2100b7f08a3fc7c8213135ff7599a79b5d0c6d0a29d5b1f7a20203f41733a. Base at pickup: b75d6cc49ef920eff6154259ca880f90232d881c.

Durable safety state​

One exact-schema intent names both expected service generations, the qualified binary policy, boot and control instance, host binding and unsigned epoch. Missing, malformed, foreign, ambiguous or regressed state refuses source startup. OFF startup remains inert and does not consume READY. A service consumes READY/CLEAN into fsynced RUNNING before the source-open callback. RUNNING survives a crash as a restart veto. FAULT is latched before disk locking; restored ON does not clear it.

Records are bounded to 4096 bytes. The parser rejects duplicate, missing, unknown, null or trailing fields and noncanonical identifiers. Integers never pass through float conversion. Trusted directory descriptors use no-follow traversal and strict ownership/mode checks with separately bound operator/CE/Knowledge owner UIDs; regular files permit protected group read but no group write or world access, must have one link and remain on-device. Stable lock inodes live outside generation directories. Writes use an owned temp, file fsync, atomic same-directory rename and directory fsync. A failure after rename is unknown durability, never a successful acknowledgement.

Lock order is intent then context-engine then Knowledge. A service takes shared intent and exclusive own-service locks for startup/CLEAN. Fault takes only its own service lock after locally denying. Draining occurs before final CAS locks. CLEAN requires the unchanged ON snapshot and a fault-free, completed owned-source drain; terminal owners cannot restart. Recovery requires durable OFF, two quiescence attestations and an exact both-service snapshot rechecked under ordered locks. It creates new READY generations and publishes a new still-OFF epoch. No recovery clears a fault in place. Two generations per service is a hard inventory bound; this preparation does not delete old authority records to regain capacity.

Status and operator boundary​

The read-only Unix status protocol is version 2. Version 1 requests and responses fail closed; durable intent/state record schemas are unchanged. It uses a random 32-byte nonce, exact bounded response schema and a maximum two-second deadline. The verifier requires socket-directory ownership, SO_PEERCRED PID/UID and an explicit process-image mapping. Tests bind owned processes and the test executable. This does not qualify deployed container namespace/image mapping. Both fresh service statuses must match the OFF epoch, control/boot, generations and owners with zero active calls/release permits, retired transport and completed cleanup. A connection error is incomplete evidence.

The injected control-only fixture entry supports disable, status, bootstrap-off, recover-off. These mutating operations are not installed CLI commands; main dispatches only exact status. Disable publishes incremented OFF before the false-only adapter. That writer changes only REPO_MAP_SOURCE_TOOLS_ENABLED in its fixed owned .env target and preserves unrelated bytes. The production deadline is 300 seconds with the final 30 seconds reserved for failure/receipt handling. Tests inject short deadlines through dependencies, never CLI switches. Only complete fixture verification emits source cutoff complete; deployment reconciliation pending; this is a tested protocol string, not a deployed cutoff claim. Reconciliation is a distinct later stage and cannot clear durable OFF. Receipts are bounded metadata, never authority.

Fixed service installation loading​

Both actual service roots call LoadInstalledControl with their normal parsed nonsecret source settings. The loader reads only the fixed root-owned policy /etc/upsquad/repository-source-control/beta-dev/install.json, bounded to 4096 bytes, through non-symlink, root-owned parents without group/world write. Missing or mismatched policy refuses source and does not bootstrap/recover/rearm authority. The policy contains environment, expected host/boot/control identity, qualified policy digest, intent UID, and each role's UID/executable digest plus explicit enabled_config_digest and disabled_config_digest. Both semantic config digests include the actual enable boolean; only the matching parsed-state slot is used. An ordinary ON-to-OFF restart can retain truthful status without weakening ON.

Observations independently use actual EUID, PID/start ticks, current boot UUID and SHA256 of /proc/self/exe. Host binding is SHA256 of the canonical lowercase 32-hex ID in protected /etc/machine-id; installation must mount the same actual host ID into both service namespaces. No host-ID file was provisioned or inspected by the source tests. This observation is not host/container namespace or image qualification. The process correlation UUID is derived from actual boot, service, PID namespace, namespace PID and process start ticks. It supplies correlation only.

The canonical config digest covers service, parsed source enable/address/server name/CA/certificate/key paths, session enforcement, denial policy, vault-enabled boolean, authority issuer/JWKS URL, signing-key file/ID and inline-key-presence boolean, plus the fixed intent/own/peer/status paths. It excludes key/passphrase contents and the whole environment. The exact ordered encoding is the struct in installationConfigDigest; independently qualified policy production must use that encoding and the effective normal parsed values, not a caller-supplied digest.

Fixed application mounts are /run/upsquad/repository-source-control for intent, /var/lib/upsquad/repository-source-safety for own state, and /run/upsquad/repository-source-peer for peer state. Status is separately owned at /run/upsquad/repository-source-status/status.sock, with actual service UID, 0700 parent/0600 socket. Before bind, its pinned device/inode must differ from all three pinned authority directories; borrowed authority descriptors remain owned by the store. Source-only cutoff retains the bounded responder; whole process close joins it and the observer before store close. This adds no mount or host permission automatically. The status-only reader qualifies peer PID/start/namespace/image and mounted directory identities as described below; actual deployed mappings remain unproved.

Control records are created as the executing EUID. A configured expected owner is not an ownership-changing operation; incompatible creation refuses before file creation. Mixed-UID operator bootstrap/recovery remains unsupported without a separately authorized operating/source contract. No host permissions or ownership changes are supplied by this source integration.

Reproducible control-only proof​

Use an explicit sibling task scratch directory and an already-installed compatible Go toolchain on PATH. The checkout must contain a valid HEAD commit and a local refs/remotes/origin/main commit for a verified merge-base; missing provenance fails setup and still records cleanup. The wrapper never substitutes HEAD as the comparison base or creates refs. No downloads, installation, SQL, Redis, Docker, provider, Step, production credentials or integration tags are used.

unset GH_TOKEN GITHUB_TOKEN GH_DEBUG
SCRATCH=/opt/upsquad-worktrees/upsquad-core/backend-sme-4261-scratch
bash scripts/verify-repo-source-control.sh "$SCRATCH/control-only" control-only
python3 scripts/check-repo-source-control-proof.py --root "$SCRATCH/control-only" --mode control-only

The wrapper owns one 600-second deadline with a 60-second cleanup reserve. It runs the exact two race-enabled Go commands serially (240/180-second caps), the checker unit module, exact-resource cleanup and the independent consumer. Setup, compilation, failure and cleanup consume the same clock. A failed invocation is retained and never reset or silently retried. The independent contract fixes three package-qualified parents and 22 nonparallel direct children; missing, skipped, duplicated, unexpected, unexecuted or misbound evidence fails.

The artifact directory may have an ordinary long checkout-derived path. Unix socket fixtures instead live for one invocation in an exclusive mode-0700 short /tmp/rsc-* directory. This is an owned runtime exception, not an artifact or shared discovery location. The wrapper creates one mode-0600 regular ledger in the artifact root and children open that exact inode append-only and no-follow; there is no hardlink, copy, inherited ledger, or create fallback. The manifest binds the acquired fixture-root device/inode and the consumer requires every registered directory/socket to be contained there. Cleanup refuses foreign, noncanonical, linked, or replaced paths and treats unreadable/reused process identity as unknown. It removes only the registered root whose identity it acquired.

The source manifest hashes actual tracked and untracked source contents and modes, records dirty state, repository/base/head, run/invocation IDs, anchors, command exits and artifact digests. Dirty development proof is not PR-head acceptance. Owned resource registration happens before fixture use; child processes wait for a parent registration handshake. Cleanup observations retain primary and cleanup failures separately. A killed/partial wrapper has no acceptance result.

Still pending​

Full composed acceptance for integrated G3a/G3c/S1 source, real CE/Knowledge binaries, production positive source release, SQL retention/marker/spend correctness, gRPC transport completion, source-only stop preserving ordinary services, operator surface probes, actual clean handoff, rollback qualification, namespace mapping, host permissions, capacity, installed PKI and deployed 300-second rehearsal remain unproved. Full-composition parents, six process modes and 16 semantic mutants are not run or replaced here. No workflows/runner topology changes, activation, provisioning, live .env access, or whole-E2 acceptance follows from this stage.

Actual TLS material-use observations​

The ordinary CE listener and Knowledge client hash the public leaf DER from the exact validated TLS config supplied to gRPC. No second file read or expected S1 fingerprint supplies the observation. The existing TLS chain, URI, EKU, expiry, hostname and key-correspondence checks remain authoritative and unchanged. OFF startup creates no loaded or use evidence.

Status v2 contains one loaded leaf and two fixed latest RPC records, Exchange and source. A delegating credentials wrapper supplies the actual connection's local leaf and a runtime-wide monotonically increasing connection sequence; credential clones and additional ClientConn objects share that allocator. Each exact RPC's verified TLS peer supplies its remote leaf. One internally generated operation UUID links a Knowledge operation's Exchange and subsequent source method; its fixed metadata key is correlation only. Missing, duplicate or malformed UUIDs produce no correlatable record and do not change RPC permissions.

Server completion requires the post-handler invocation check and gRPC stats.End with no error, while the runtime generation and cutoff still permit publication. Knowledge requires the actual generated call return and invocation check. Normal gRPC context cancellation at End is not independently a failed call. Exchange completion proves no source release. Failed authorization, cancellation, unavailable acquisition and provider errors never become completed source records. Pairing both roles is needed; server completion alone does not prove client delivery.

Records expose only public leaf digests, operation/method/outcome, local connection sequence, intent epoch, marker generation, observation sequence and bounded age. Outer status binds process/control identity. State is constant-size and updated in memory; nonce handling performs no certificate or filesystem IO. The existing 4096-byte frame cap, strict missing/unknown/duplicate/null rejection and two-second exchange deadline remain. Runtime Status/HandleControlStatus/ReadControlStatus and the administrative CLI's existing reader now use v2; fixture responders were migrated together. Version 1 has no fallback for material adoption.

The 60000ms diagnostic age cap is not adoption freshness. An adoption verifier must require active material, age at most 5000ms, the exact intended operation and method on both qualified peers, matching observed/current generation and epoch, and sequences newer than its baseline. It must compare CE local = selected CE = Knowledge remote and Knowledge local = selected Knowledge = CE remote. Exchange and source stages are separate. An overwritten slot, stale record or unmatched operation is unproven. File selection cannot rewrite an old connection's observed leaf, and connection sequences cannot prove old-channel retirement. Historical records remain after cutoff with active=false; real old/fresh channel attempts and lifecycle cleanup remain required.

No installed adoption consumer or supported workflow operation-correlation binding is supplied by this phase. Tests prove real mutual TLS and Exchange with explicit synthetic validator/session-authority leaves and a real local signer; nil acquisition is tested only as failed source. Successful real source acquisition and SQL retention, installed two-role adoption, full E2/full14/full17 remain unexecuted. The held operator ownership path and deployed policy/mount/peer qualification gaps are unchanged.

Direct Knowledge operational-probe response correlation​

The existing Knowledge source route emits X-Upsquad-Source-Operation only for its actual Client receipt after DTO validation, the unchanged 16384-byte DTO bound, full JSON-RPC serialization and the final invocation check. The UUID is generated internally once for the actual Exchange/source pair; inbound values are ignored. The three methods retain their existing DTO, MCP content and structuredContent bytes. Clients without the receipt capability still produce ordinary results without correlation evidence. No latest-status fallback exists.

This header is correlation, not authority or delivery proof. A failed or short body write cannot retract transmitted headers. The separately qualified direct probe must receive the entire valid matching success response, then match its single canonical UUID and method against both independently qualified status-v2 records within 5000ms, with post-baseline sequence, current process/control instance, epoch/generation and reciprocal selected leaves. Partial bodies, stripped headers, concurrent overwritten observations and old-channel leaves are UNPROVEN; HTTP200/header alone never establishes adoption. The invocation remains owned until the HTTP write returns; writes run without authority locks.

The installed operational probe consumer, identity/custody and selected-material qualification remain unbound. No enable/adoption command or unused verifier was added. Unit TLS/HTTP tests use explicitly synthetic issuer/result leaves; real SQL release, deployed adoption and separate actual-agent/full14/full17 acceptance remain unexecuted. Agent-runtime receipt propagation is not required for this approved direct operational probe route.

Startup policy lifetime guard​

The fixed production loader retains the exact protected install.json descriptor used for parsing, including device/inode, owner/group/mode/link count, size, mtime/ctime and content digest. Protection is revalidated on the stable read's metadata, not merely an earlier path-open check. The private guard is installed before status/admission. The generic synthetic constructor does not establish this production provenance.

The existing single filesystem observation path checks the fixed protected path and retained object together with control state, for both active source and inert OFF status. Freshness starts before sample IO, so a delayed completion cannot refresh old evidence. Status/nonce handlers remain memory-only with the existing five-second bound and schema2. An observed mismatch/read failure irreversibly invalidates qualification, admission and final release/status; restoring bytes does not rearm or clear existing fault/denial state. Source-to-status observer handoff joins the old worker before starting the next one.

Whole-process close joins source work, the status acceptor and observation before closing the retained policy descriptor/store. Failed joins retain ownership for a later bounded close; they do not close a descriptor beneath a reader. Startup failures that still own work return the owned handle with the error.

This establishes bounded observed policy lifetime, not detection of every transient change wholly between samples. The status-only reader below supplies the independently protected unchanged-policy barrier strictly greater than five seconds and challenge/recheck under its original deadline. Mutating installed operator composition remains unimplemented. This source change grants no OS permissions or exact enabled-slot inference. The changed binary requires independent qualification. SQL/fullE2/full14/full17 and deployed acceptance remain unexecuted.

M3 extraction boundary (#4699)​

M3 reconstructs the bounded lifecycle/material-status-v2 cut at a2e4f977 and selected later correctness hunks against landed M2 09e4f1b8. It preserves current authentication provenance, session/member checks, SQL marker release, extraction/Remember fences, ordinary worker behavior and retained history. Gateway discovery applies session and governance filtering before a fresh authenticated, five-second/64-KiB Knowledge observation. Only the three authenticated protected-source tools bypass generic response replay; ordinary Knowledge and third-party same-name tools retain deduplication.

The selected engineering adapter retains its existing build tag and only its owned lifecycle/target compatibility. No installed operator, custody writer, adoption/renewal/activation workflow, operational probe or full-E2 orchestration is included. Historical donor results do not qualify this extracted candidate. Its scoped runtime/SQL tests require separately admitted finite windows; compilation alone is not proof of source release, full E2 or operating acceptance.

Installed OFF-status reader (#4716)​

Exact repo-source-control status starts one 300-second clock before its protected loader, reserving the final 30 seconds for failure/receipt handling. It requires root EUID and the fixed root-owned installation policy, root-owned intent and the existing common service custody UID. It reads pre-existing host authority at /var/lib/upsquad/repository-source-control/beta-dev and /var/lib/upsquad/repository-source-faults/beta-dev/{context-engine,knowledge}. It never creates, repairs, locks for writing, changes permissions or reclaims a generation. It does not read credentials or deployment environment files, launch processes, call services, or probe source/issuer endpoints.

The reader retains the policy descriptor and requires an unchanged protected policy/authority interval strictly greater than five seconds. It compares raw record digests, inode/metadata identity, canonical directory identity and the complete bounded generation roster before, during and after this interval and both challenges. This is bounded observed stability; a transient change entirely between observations is not claimed detectable.

Only the fixed local sockets at /run/upsquad/repository-source-status/{context-engine,knowledge}/status.sock are connected. A preliminary connection discovers kernel SO_PEERCRED; a fresh v2 nonce challenge independently repeats the exact PID/start, UID, boot, user/PID/mount namespace, process root and executable digest/inode checks. The actual peer's /proc/<pid>/root must expose the same pinned policy and authority inodes at the fixed service mount paths, plus its independently protected status directory and host binding. User-namespace remapping refuses. Final rechecks include the first peer after the second challenge; two service correlation UUIDs from a single actual PID are insufficient.

Only matching OFF authority and both quiescent status-v2 records emit off-evidence. Existing READY, RUNNING and FAULT bytes remain untouched where VerifyControlQuiescence permits observation. This output is evidence of the observation, never a cutoff acknowledgement, activation, fault repair or operating authority. Every mutating verb and every invalid argument list refuses before loader invocation.

Tests use owned synthetic filesystem trees and two actual child processes with Unix sockets. An unexported test seam substitutes peer pathnames only; production has fixed / and root ownership, with no CLI, environment, policy or exported mapping override. Synthetic success does not attest real mounts, mixed-UID access, installed binaries, PKI or deployment. Installation/invocation authorization, mutating operator composition, adoption, automatic fault-free ON renewal, activation and deployed 300-second cutoff/full-E2 acceptance remain held under #4261/#3678/#4219.

The CLI checks the original deadline after output and does not report a successful exit after a failed or late write. The context bounds validation and socket challenges; it cannot interrupt an arbitrary permanently blocked output writer. The invoking OS/caller must bound that output sink. Already transmitted output bytes cannot be retracted when a write subsequently fails or completes late.

Validation, loader and challenge failures emit no off-evidence. During the output phase, any partial or late bytes are invalid evidence: consumers require the full expected record and exit status 0 within the original clock. Output is never a durable receipt or cutoff acknowledgement.