Bind AgentCTL jobs to declared project environments - #15
Conversation
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a631197612
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| preflight = subprocess.run( | ||
| preflight_command, | ||
| cwd=checkout, | ||
| check=False, | ||
| timeout=AGENT_PREFLIGHT_TIMEOUT_SECONDS, | ||
| ) |
There was a problem hiding this comment.
Remove the private prompt when preflight fails
When the declared preflight exits nonzero, times out, or cannot be executed, _run_agent raises before reaching the later try/finally that unlinks prompt_path. The contract input has already been deleted by main, so each such terminal job leaves its raw, potentially sensitive prompt indefinitely under the state directory; wrap the preflight and backend execution in the same cleanup scope.
Useful? React with 👍 / 👎.
| if not project.environment.preflight: | ||
| raise ContractError( | ||
| f"project {project_id} does not declare an agent environment preflight" | ||
| ) |
There was a problem hiding this comment.
Enforce the published agent-capable flag on launch
For a descriptor without [workspace] but with an optional non-empty environment.preflight, the catalog publishes agent_capable = false and the activation audit skips it, yet this check passes and start_agent proceeds because ProjectCatalog.checkout does not require a workspace policy. This makes the advertised capability unreliable and permits launches through a project that the new contract classifies as non-agent-capable; reject not project.agent_capable here as well.
Useful? React with 👍 / 👎.
| ${pkgs.nix}/bin/nix eval \ | ||
| "$_flake_dir#nixosConfigurations.sinnix-prime.config.sinnix.services.sinnixd.projectRoots" \ | ||
| --json \ | ||
| --impure \ | ||
| "''${nix_override_args[@]}" \ | ||
| | ${pkgs.jq}/bin/jq -r '.[]' |
There was a problem hiding this comment.
Avoid the duplicate activation evaluation
Every gated switch, boot, and test-system invocation now performs this separate impure evaluation of the NixOS configuration before nh evaluates 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 evaluating nixosConfigurations a second time.
AGENTS.md reference: AGENTS.md:L203-L205
Useful? React with 👍 / 👎.
| project = raw.get("project") | ||
| if isinstance(project, Mapping) and isinstance(project.get("id"), str): | ||
| project_name = project["id"] | ||
| adapter = load_project_adapter(root) |
There was a problem hiding this comment.
Reject duplicate project IDs in the activation gate
When two configured roots declare the same project.id, this loop validates each adapter independently and can let the gate pass, even though ProjectCatalog.__init__ rejects the same roots as duplicate IDs when the newly activated daemon starts. Thus a configuration accepted by the pre-activation gate can leave sinnixd unable to start; collect the loaded adapters and apply the same cross-root uniqueness check before succeeding.
AGENTS.md reference: AGENTS.md:L141-L142
Useful? React with 👍 / 👎.
Summary
Problem
AgentCTL workers could enter an assigned checkout without the command environment required by that project. Polylogue workers repeatedly had to rediscover the virtual environment and verification entrypoint, while an incautious worker could bypass the mandated harness. A partial runtime rollout would have made affected projects refuse dispatch only after activation.
Solution
Project descriptors now declare a bounded preflight executed through the checkout-bound project environment. Attested jobs use a strict versioned input contract, clear ambient language-runtime overrides, and surface effective environment capability. Switch, boot, test-system, and rendered command entrypoints all evaluate the configured-root completeness gate before activation. Stale private records fail closed without changing ordinary declared operations.
Verification
lintoperation succeeded, receipt7dc52ef0-c71f-4c16-9165-1f381449bb59No NixOS switch, boot activation, or service restart was performed by this PR.