Skip to main content

Module gate

Module gate 

Source
Expand description

G6 in the Instance (process v1 §5): the locked-path check on submit and before verify, and the gate’s own rerun of the declared command at the judged commit. Both run here, in the Instance’s process, never through an agent’s shell.

What the agent’s repository cannot change. Every git call runs with an empty environment, no global or system config, no replace objects, no attributes file, and hooks, fsmonitor, external diff and textconv off. The judged commit and spec_commit are fetched into a private bare repository in the gate’s own directory (over git’s transport, so every object is hashed again on the way in; no refs/replace, no alternates, no filters, no config of the agent’s repository). The commit-to-commit check and the rerun tree come only from that copy; the tree is written blob by blob, with no checkout, so no smudge filter or attribute applies.

The locked-path check judges the commit and the handed-in worktree: the commit against spec_commit in the private copy (what the rerun runs), and the worktree with git diff <spec_commit> and git ls-files --others --exclude-standard (§5). Every path under a locked path (under_locked, the matcher Cloud’s contract tests use) is kept, each once with its strongest kind; any type change of a locked path (file ↔ symlink ↔ directory) is type_changed, and a path that was a symlink at spec_commit and now resolves outside the repository is outside_repo. A locked path that itself lies outside the repository is refused.

The rerun (run) runs its tree outside $HOME (cargo reads every parent’s .cargo/config.toml; a run under one is refused), with an empty environment plus a fixed allowlist (a fixed PATH, the gate’s own CARGO_HOME, CARGO_TARGET_DIR and TMPDIR under the Instance’s data dir), and the locked paths laid over from spec_commit (files the judged commit added under a locked path are not in the tree), read-only during the run and compared with spec_commit after every command (a build script that rewrote a locked test fails locked_paths_changed). A judged commit that changes, against spec_commit, cargo’s configuration or toolchain file, any build script, or the build-script and test-target keys of any manifest (manifest) is refused: those choose what runs the tests.

The compiler’s list (list): before the rerun, for an M/H task whose command runs cargo, the same command runs at spec_commit in a tree, target directory and log of its own, with a target runner that lists each test binary’s tests instead of running them. The locked tests it lists must pass in the rerun, besides those the parser names.

Known gap: the code of the judged commit (its library, proc-macros, path and registry dependencies with their build scripts) runs at build time, as the same Unix user as the agent and the Instance. It can still change ~/.rustup, ~/.local/bin, ~/.cargo/bin, the toolchain or this Instance’s files, or act on the run in ways no file check sees. The code under test runs inside the test binary and can end it with exit 0: the harness report (gate_report.rs) catches that unless the code also forges a complete, consistent report. The locked files’ content, inode, mode and change time are checked after every command, so a rewrite shows even when the bytes were put back. Only a sandboxed run on pounce under the gate, with the locked paths bind mounted read-only and no write access outside the run (§5), closes the rest.

Structs§

GateDirs
The gate’s directories: work under the Instance’s data dir (private copies, the gate’s CARGO_HOME, targets), runs outside $HOME, the directory each run’s own directory is created in directly.
GateInputs
What G6 runs for one task: its risk, the commit its locked paths are pinned to, those paths, and the declared command.

Enums§

GateError
Why the gate could not judge: never a pass.
Missing
What G6 needs and the task view does not carry.

Constants§

RERUN_TIMEOUT
The longest the gate’s own run may take.

Functions§

changed_reason
The reason of a locked-path failure: every differing path with its kind.
check_locked_paths
The locked-path check of the handed-in worktree root against spec_commit (§5): every path under checked byte-identical, nothing new, deleted, untracked or of another type, no locked symlink resolving outside. It runs in the agent’s repository (the worktree is there) with the hardened git; g6_record adds the commit-to-commit check from a private copy, which no config of that repository reaches.
g6_record
The G6 record of the worktree root at the judged commit artifact, worked out in the gate’s directories dirs: the locked-path check of the commit and of the worktree first (a failure stops there, rule: locked_paths_changed), then the gate’s rerun of artifact, whose locked files are checked again after every command (a change there is the same failure). The worktree must be at artifact; otherwise the check would judge something else, and the gate refuses.
head_commit
HEAD of the worktree repo.
inputs_for
The inputs of G6 for a process task: from Cloud’s process fields and what it serves beside them (gate; M/H: the feature list; S: the repo’s declared command) and, for S, the commit this Instance’s claim started from.
recheck_commit
The check before verify (E48): the judged commit artifact against spec_commit, commit to commit (the verifier has no handed-in worktree), in a private copy fetched from repo into the Instance’s G6 directory work, so repo’s config, replace refs and attributes cannot hide a change. Nothing runs here, so no cargo config matters. The same kinds as on submit, except untracked (only a worktree has it) and outside_repo (a changed link text is modified).
resolve_commit
The full commit id rev names in repo.