Skip to content

feat(cli): enforce operator init distro#1255

Open
joshuajbouw wants to merge 11 commits into
mainfrom
agent/operator-default-distro
Open

feat(cli): enforce operator init distro#1255
joshuajbouw wants to merge 11 commits into
mainfrom
agent/operator-default-distro

Conversation

@joshuajbouw

@joshuajbouw joshuajbouw commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Linked Issue

Closes #1253

Depends on #1196. This PR targets main and contains settled #1196 head 34a3a02a7ad1ab266586c3dd548d6d2cac8f188e as a signed merge parent. Merge #1196 first; GitHub will then narrow this stacked diff to the enforced-distro hook.

Summary

Adds a generic embedding boundary for distributions that ship Astrid Runtime. A launcher can set the distro used by astrid init without copying Astrid's argument grammar, and Astrid rejects a simultaneous caller --distro override.

ASTRID_ENFORCED_DISTRO is a process environment input, not a privileged Astrid security boundary. An embedding launcher such as AOS must overwrite any inherited value before executing Astrid. A caller invoking standalone Astrid can set its own process environment; standalone Astrid remains neutral and still requires an explicit distro when the variable is absent.

Changes

  • resolve ASTRID_ENFORCED_DISTRO at init dispatch
  • reject caller --distro whenever an embedding launcher supplies the environment value
  • preserve standalone Astrid's explicit --distro requirement when the value is absent
  • fail closed on empty or non-UTF-8 values
  • retain feat(cli): grant installed distro capsules to the target principal #1196's checked distro provisioning, separate operator/target principal handling, and --grant-capsules path
  • cover neutral, enforced, override-rejection, malformed-value, leading-global-option, operator-vs-target, and enforced-distro-plus-capsule-grant cases
  • document the additive embedding hook under [Unreleased]

Verification

  • refreshed head: be84f920d2c921709ee92bd0fa4b8b9f0532d195
  • signed merge parents: prior child a83f537ad20728cedc89495a14df312dd8a46bec and settled feat(cli): grant installed distro capsules to the target principal #1196 34a3a02a7ad1ab266586c3dd548d6d2cac8f188e
  • refresh commit GPG signature verified
  • merge result matches the reviewed /private/tmp/astrid-1196-1255-preview-v2 integration tree exactly in both previously conflicting CLI files
  • cargo fmt --all -- --check
  • cargo metadata --locked --no-deps --format-version 1
  • git diff --check
  • focused astrid CLI execution was attempted locally, but the cold macOS build did not complete in a bounded window; replacement GitHub CI is the execution gate

Dependency handling

This PR still targets main. #1196 must land first; GitHub will then narrow the diff to this additive embedding hook. No product-specific privilege path is introduced.

Checklist

  • Linked to an issue
  • CHANGELOG.md updated under [Unreleased]

No release is created or published by this change.

@joshuajbouw joshuajbouw marked this pull request as ready for review July 15, 2026 03:32
Copilot AI review requested due to automatic review settings July 15, 2026 03:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an operator-controlled boundary for astrid init so embedded distributions can enforce an init distro via ASTRID_ENFORCED_DISTRO, preventing callers from overriding it while preserving standalone Astrid’s requirement for an explicit --distro when no operator value is present.

Changes:

  • Resolve ASTRID_ENFORCED_DISTRO during astrid init dispatch and reject any CLI --distro override when it’s set.
  • Add targeted unit tests for neutral/enforced/override-rejection and malformed operator values, plus a CLI parsing regression for leading global options.
  • Document the new operator hook in the changelog under [Unreleased].

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/astrid-cli/src/dispatch.rs Adds ASTRID_ENFORCED_DISTRO resolution logic for init and unit tests covering enforced/neutral/invalid cases.
crates/astrid-cli/src/cli.rs Adds a parsing regression test ensuring global options before init don’t interfere with --distro.
CHANGELOG.md Documents the new operator-enforced init distro hook under [Unreleased].

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

astrid init installed a distro's capsules per-principal but attached no
capsule-access grants, so a non-default principal ended up with the
capsule files yet no authority to invoke their tools — provisioning it
required an out-of-band, hand-SYNC'd `agent modify --add-capsule` step.

Add an opt-in --grant-capsules flag (only meaningful with --distro) that,
after the distro's capsules install, grants access for exactly the
installed set through the same admin.agent.modify kernel path as
`agent modify --add-capsule`, now factored into a shared
apply_agent_modify helper. Idempotent across re-runs (kernel apply_set_delta
dedups; a failed first grant recovers on the fresh-lock re-run). No-op for
the default principal, which holds admin *. Without the flag a non-default
install prints the exact agent modify command; on grant failure the capsules
are already installed and init exits non-zero with the recovery command.

Closes #1195
@joshuajbouw

Copy link
Copy Markdown
Contributor Author

@copilot review exact head be84f92

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow operators to enforce an init distro

2 participants