Cut 1: one step primitive and one freeze primitive (behaviour-preserving)
Deletes the driver-private Docker argv assembly in run_in_workspace and
base_run_args and the OperatorBinding/CompiledDeploymentPlan coupling inside
GitSourceDriver::freeze's fetch-and-archive core. Both become one shared
primitive apiece, the shape Cut 4's verify worker will reuse instead of
growing a second copy:
- ContainerSpec + docker_run_args(spec, workspace, working_directory, argv):
a plain, pure lowering to the exact `docker run` argv. ContainerSpec::for_step
is the one constructor (a DockerRunnerBinding, a step's required
environment, and the source stamp); it does the cache-root and secret
validation against the filesystem before docker_run_args ever runs.
run_in_workspace and materialize_external_input both build a ContainerSpec
and call docker_run_args now; base_run_args is gone (rg '"--cap-drop"'
src/ has exactly one hit).
- ExactSource {origin, checkout, gitlinks, recipe_path} plus
GitSourceDriver::freeze_exact(&ExactSource, revision, transaction_id, root),
which fetches, archives and hardens an exact revision with no
OperatorBinding or compiled plan. freeze() now derives an ExactSource from
the binding, keeps its own verify_exact_source pre-check against the
durable resolution, and delegates the archive to freeze_exact.
- A StepPort trait (DockerRunnerDriver::run_step) that runs a lowered step
and returns exit status plus a bounded stderr tail instead of bailing.
Not yet reached from materialize (Cut 4 wires it into the verify worker);
deploy keeps DockerRunnerDriver::docker's existing bail-on-failure error
text unchanged.
materialize_external_input's curl step now goes through the same lowering,
which adds a harmless --workdir /workspace and one inert IDUNN_EXTERNAL_INPUT_ID
env var to its argv; curl's behavior (an absolute --output path) is
unaffected. materialize_gitlink_archive's cache-directory name changed from
the operator binding's target label to a hash of the checkout path, since
ExactSource carries no target field; this is bookkeeping only; a UUID
already made every gitlink checkout unique.
Adds three unit tests: container_spec_lowers_to_exact_docker_argv pins the
full docker run argv; required_environment_is_the_only_environment pins F6
(a binding environment entry the step does not require never leaks in);
freeze_exact_is_byte_exact_and_recipe_checked and its negative twin
freeze_exact_rejects_a_recipe_the_archive_transforms (an export-subst
recipe, which git archive substitutes and git cat-file does not) exercise
freeze_exact directly, with no OperatorBinding in sight.
tools/verify-mutations/cut1.psd1 covers all five rules with a revert or
loosening mutant apiece, run through the Eureka harness in the stopgap
container. Verified on Yggdrasil at this commit: cargo test --lib is 130
passed, 0 failed, 2 ignored (the P1 baseline of 126/2 plus these four new
tests), and every mutation entry was killed by its own test.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
parent
4845e989aa
commit
95e15efca3
2 changed files with 742 additions and 178 deletions
848
src/drivers.rs
848
src/drivers.rs
File diff suppressed because it is too large
Load diff
72
tools/verify-mutations/cut1.psd1
Normal file
72
tools/verify-mutations/cut1.psd1
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
# Cut 1 mutation suite: the shared Docker argv lowering and the exact-revision
|
||||
# freeze primitive. Run with:
|
||||
#
|
||||
# pwsh tools/eureka-mutations.ps1 -Repo . -Entries tools/verify-mutations/cut1.psd1 `
|
||||
# -Target src/drivers.rs -Test 'cargo test --lib'
|
||||
#
|
||||
# (the harness itself lives in the Eureka skill repo; the stopgap copies it to
|
||||
# /harness/eureka-mutations.ps1 inside the verify container.)
|
||||
|
||||
@{
|
||||
Mutations = @(
|
||||
@{
|
||||
Id = 'cut1-cap-drop-revert'
|
||||
Rule = 'docker_run_args always drops every Linux capability (--cap-drop ALL).'
|
||||
Test = 'drivers::tests::container_spec_lowers_to_exact_docker_argv'
|
||||
Old = @'
|
||||
OsString::from("--cap-drop"),
|
||||
OsString::from("ALL"),
|
||||
OsString::from("--security-opt"),
|
||||
'@
|
||||
New = @'
|
||||
OsString::from("--security-opt"),
|
||||
'@
|
||||
}
|
||||
@{
|
||||
Id = 'cut1-network-default-loosening'
|
||||
Rule = 'A runner with no declared network_profile (or "none") is admitted with no network, never bridge.'
|
||||
Test = 'drivers::tests::container_spec_lowers_to_exact_docker_argv'
|
||||
Old = @'
|
||||
None | Some("none") => ContainerNetwork::None,
|
||||
'@
|
||||
New = @'
|
||||
None => ContainerNetwork::Bridge,
|
||||
Some("none") => ContainerNetwork::None,
|
||||
'@
|
||||
}
|
||||
@{
|
||||
Id = 'cut1-cpus-function-of-input'
|
||||
Rule = '--cpus is cpu_quota_percent / 100, to two decimal places.'
|
||||
Test = 'drivers::tests::container_spec_lowers_to_exact_docker_argv'
|
||||
Old = @'
|
||||
f64::from(spec.cpu_quota_percent) / 100.0
|
||||
'@
|
||||
New = @'
|
||||
f64::from(spec.cpu_quota_percent) / 50.0
|
||||
'@
|
||||
}
|
||||
@{
|
||||
Id = 'cut1-required-environment-only'
|
||||
Rule = 'A step container receives only the source stamp plus the names in required_environment, never every binding environment entry.'
|
||||
Test = 'drivers::tests::required_environment_is_the_only_environment'
|
||||
Old = @'
|
||||
for name in required_environment {
|
||||
'@
|
||||
New = @'
|
||||
for name in runner.environment.keys() {
|
||||
'@
|
||||
}
|
||||
@{
|
||||
Id = 'cut1-freeze-exact-recipe-check'
|
||||
Rule = 'freeze_exact refuses when the archived recipe file differs from the recipe blob it read from the same tree.'
|
||||
Test = 'drivers::tests::freeze_exact_rejects_a_recipe_the_archive_transforms'
|
||||
Old = @'
|
||||
ensure!(
|
||||
materialized_recipe == recipe_bytes,
|
||||
"frozen recipe differs from the selected tree's recipe blob"
|
||||
);
|
||||
'@
|
||||
New = ''
|
||||
}
|
||||
)
|
||||
}
|
||||
Loading…
Reference in a new issue