Skip to content

feat(agent): expose active package policy - #1937

Draft
Benoît Cortier (CBenoit) wants to merge 2 commits into
masterfrom
cbenoit-plan-agent-policy-endpoint
Draft

feat(agent): expose active package policy#1937
Benoît Cortier (CBenoit) wants to merge 2 commits into
masterfrom
cbenoit-plan-agent-policy-endpoint

Conversation

@CBenoit

@CBenoit Benoît Cortier (CBenoit) commented Aug 17, 2026

Copy link
Copy Markdown
Member

Exposes the validated active package-broker policy through the shared authenticated GET /v1/policy route. Clients receive a stable policy snapshot, while unavailable policies return a structured 503 response without leaking policy source or file-security details.

Coordinated Phase 1 pull requests: Devolutions/now-libraries#93 defines the shared contract, #1937 implements the Agent endpoint, and Devolutions/UniGetUI#5292 consumes it.

The Agent implementation was integrated against exact shared contract commit 961e833c929793116b697e0943a7573ad6e21398 using a temporary external Cargo patch for now-policy, now-policy-api, and now-policy-server-template, preserving one PolicyDocument type identity. No local paths, git dependencies, temporary sources, or patched lockfile state are committed. Focused endpoint, authentication, serialization, method, and concurrent snapshot tests passed; focused and workspace Clippy passed; and the Devolutions Agent build passed.

The workspace test run reached 251 passed and 1 ignored before the pre-existing host-specific winget_app_exec_alias_passes_elevated_verification test rejected the local WindowsApps winget.exe DACL because it grants the current user write access.

This draft remains blocked until now-policy-api 0.4.0 and now-policy-server-template 0.4.0 are published and the final registry dependencies and lockfile are committed. Do not replace that publication gate with local or git dependencies.

Issue: Devolutions/now-libraries#93

Co-authored-by: Copilot App 223556219+Copilot@users.noreply.github.com

Expose the validated active package-broker policy through the shared
authenticated GET /v1/policy route. Return a structured unavailable
error without leaking policy source or file-security details.

This requires now-policy-api and now-policy-server-template 0.4.0 from
Devolutions/now-libraries#93 before the change can ship.

Issue: Devolutions/now-libraries#93

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@CBenoit

Copy link
Copy Markdown
Member Author

Implementation notes:

  • Implements the shared PackageBrokerServer::policy override from Add active package policy inspection contract now-libraries#93.
  • Reuses the named-pipe client's captured executable identity and existing Authenticode validation before policy access.
  • Clones the active Arc<PolicyDocument> while holding the read lock, releases the lock, and only then clones the owned response document for serialization.
  • Reuses the generic BrokerPaused error mapping for HTTP 503 and does not expose watcher errors, paths, source documents, security descriptors, or policy bodies in logs.
  • Covers empty and full policy serialization, structured unavailable responses, unsigned-client rejection, existing routes, implicit HEAD, rejected methods, unknown-route 404, and concurrent replacement without mixed snapshots.

Validated against frozen shared commit 961e833c929793116b697e0943a7573ad6e21398 by temporarily patching all three policy crates from one external checkout so PolicyDocument has a single Cargo package identity. No patch paths or temporary lockfile changes are committed.

Commands and results:

cargo +nightly fmt --all
# passed

cargo test --config <temporary-patch-config> -p now-package-broker server::tests::policy_route_rejects_unsigned_client
# 1 passed

cargo test --config <temporary-patch-config> -p now-package-broker --features dev-skip-broker-signature server::tests::policy_
# 4 passed

cargo test --config <temporary-patch-config> -p now-package-broker server::tests::concurrent_policy_replacement_returns_only_complete_snapshots
# 1 passed

cargo clippy --config <temporary-patch-config> -p now-package-broker --all-targets -- -D warnings
cargo clippy --config <temporary-patch-config> -p now-package-broker --all-targets --features dev-skip-broker-signature -- -D warnings
cargo clippy --workspace --tests --config <temporary-patch-config> -- -D warnings
# passed

cargo build -j 2 -p devolutions-agent --config <temporary-patch-config>
# passed

cargo test -j 2 --workspace --config <temporary-patch-config>
# stopped after 251 passed and 1 ignored because the existing host-specific
# winget_app_exec_alias_passes_elevated_verification test rejected the local
# WindowsApps winget.exe DACL

The draft remains blocked until now-policy-api 0.4.0 and now-policy-server-template 0.4.0 are published and the tracked manifest/lockfile can move from 0.3.x to those registry releases.

Note

LLM-assisted content (no human feedback).

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

Adds authenticated active-policy inspection to the Agent’s package broker.

Changes:

  • Implements GET /v1/policy with structured responses.
  • Reuses connection authentication and adds snapshot/concurrency tests.
  • Remains blocked on publishing and committing the 0.4.0 dependencies.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
crates/now-package-broker/src/server/mod.rs Implements and tests policy retrieval.
crates/now-package-broker/src/auth.rs Exposes connection-level authentication for the endpoint.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread crates/now-package-broker/src/server/mod.rs Outdated
Return a generic policy-unavailable message so clients cannot infer
whether the active policy is file-backed, missing, or corrupt.

Issue: Devolutions/now-libraries#93

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants