-
Notifications
You must be signed in to change notification settings - Fork 0
Bind AgentCTL jobs to declared project environments #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d6de3b7
0be5e55
06e9ef4
a631197
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Verify the rendered rebuild entrypoints retain the environment contract gate. | ||
| { inputs, ... }: | ||
| { | ||
| perSystem = | ||
| { | ||
| pkgs, | ||
| system, | ||
| sinnixScriptRegistry, | ||
| ... | ||
| }: | ||
| let | ||
| commandRegistry = import ../command-registry.nix { | ||
| inherit inputs pkgs system sinnixScriptRegistry; | ||
| }; | ||
| rendered = pkgs.runCommand "command-registry-environment-gate" { } '' | ||
| cat > "$out" <<'EOF' | ||
| --- switch --- | ||
| ${commandRegistry.appCommands.switch.script} | ||
| --- boot --- | ||
| ${commandRegistry.appCommands.boot.script} | ||
| --- test-system --- | ||
| ${commandRegistry.appCommands.test-system.script} | ||
| --- test-vm --- | ||
| ${commandRegistry.appCommands.test-vm.script} | ||
| EOF | ||
| # Provably fails when a covered command loses its gate or the gate is | ||
| # moved after the command invocation. | ||
| test "$(grep -c 'sinnixd-project-environment-check' "$out")" = 3 | ||
| if awk '/--- switch ---/{section=1} /--- boot ---/{section=0} section && /sinnixd-project-environment-check/{gate=NR} section && /nh os switch/{switch_line=NR} END{exit !(gate && switch_line && gate < switch_line)}' "$out"; then :; else exit 1; fi | ||
| if awk '/--- boot ---/{section=1} /--- test-system ---/{section=0} section && /sinnixd-project-environment-check/{gate=NR} section && /nh os boot/{boot=NR} END{exit !(gate && boot && gate < boot)}' "$out"; then :; else exit 1; fi | ||
| if awk '/--- test-system ---/{section=1} /--- test-vm ---/{section=0} section && /sinnixd-project-environment-check/{gate=NR} section && /nh os test/{test=NR} END{exit !(gate && test && gate < test)}' "$out"; then :; else exit 1; fi | ||
| if awk '/--- test-vm ---/{section=1} section && /sinnixd-project-environment-check/{bad=1} END{exit bad}' "$out"; then :; else exit 1; fi | ||
| ''; | ||
| in | ||
| { | ||
| checks.command-registry-environment-gate = pkgs.runCommand "command-registry-environment-gate-check" { inherit rendered; } '' | ||
| test -s "$rendered" | ||
| touch "$out" | ||
| ''; | ||
| }; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -134,6 +134,11 @@ def start_agent( | |
| if not self.native_runner.is_file() or not os.access(self.native_runner, os.X_OK): | ||
| raise ContractError("native agent runner is unavailable") | ||
| checkout = self.projects.checkout(project_id, checkout_id) | ||
| project = self.projects.get(project_id) | ||
| if not project.environment.preflight: | ||
| raise ContractError( | ||
| f"project {project_id} does not declare an agent environment preflight" | ||
| ) | ||
|
Comment on lines
+138
to
+141
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
For a descriptor without Useful? React with 👍 / 👎. |
||
| binding = self._bead_binding(bead_binding, checkout) | ||
| job_id = str(uuid4()) | ||
| prompt_path = self.inputs_root / f"{job_id}.prompt" | ||
|
|
@@ -147,11 +152,13 @@ def start_agent( | |
| **({"bead_binding": binding} if binding is not None else {}), | ||
| } | ||
| private = { | ||
| "schema_version": 1, | ||
| "schema_version": 2, | ||
| "job_id": job_id, | ||
| "kind": "attested-agent", | ||
| "principal": principal, | ||
| "checkout": checkout.to_dict(), | ||
| "environment_command": list(project.environment.command), | ||
| "environment_preflight": list(project.environment.preflight), | ||
| "backend": backend, | ||
| "model": model, | ||
| "effort": effort, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Every gated
switch,boot, andtest-systeminvocation now performs this separate impure evaluation of the NixOS configuration beforenhevaluates the same configuration for the rebuild. Besides duplicating an expensive evaluation and creating another failure/divergence boundary, this directly violates the repository requirement not to preflight a switch with a duplicate evaluation; integrate the contract into the rebuild evaluation or obtain the roots without evaluatingnixosConfigurationsa second time.AGENTS.md reference: AGENTS.md:L203-L205
Useful? React with 👍 / 👎.