Skip to content

feat(environments): explain package policy and Anaconda sign-in failures - #163

Open
romulorosa wants to merge 12 commits into
mainfrom
kilo/implement-policy-channel-error-handling-and-n
Open

romulorosa wants to merge 12 commits into
mainfrom
kilo/implement-policy-channel-error-handling-and-n

Conversation

@romulorosa

@romulorosa romulorosa commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Explain package-policy blocks and Anaconda sign-in failures in conda environments, for the agent and in Settings, and bump the bundled bridge payload to 0.1.23.

Payload 0.1.23 reports why a conda transaction failed (reason plus structured details) and authenticates to Anaconda's governed package repository with the signed-in user's Anaconda API key. Until now kilo.environments turned every failed transaction into SOLVE_FAILED ("Dependency conflict"), and raised auth:* errors became PROVIDER_NOT_READY ("backend not ready"). A package blocked by an organization's policy looked like a conflict, and a signed-out user looked like a starting backend. The bump and the mapping ship together, so no release shows signed-out users the old misleading errors.

Error codes and transport

  • Add POLICY_BLOCKED, NOT_SIGNED_IN and CHANNEL_ACCESS_DENIED (all BUSINESS). The error vocabulary now has 18 codes.
  • Map the bridge's reasons: blocked_by_policy → POLICY_BLOCKED; not_signed_in / auth:not-signed-in → NOT_SIGNED_IN; access_denied / auth:access-denied → CHANNEL_ACCESS_DENIED; no_channels_configured, package_not_found, channel_not_found → their existing codes. solve_failed, execution_failed, internal_error, unknown reasons and results from older bridges without a reason stay SOLVE_FAILED, so nothing regresses. Clone keeps its inline SOLVE_FAILED (the bridge never sets a reason on clones).
  • Applies to create, create-from-file, remove, install, uninstall, update and both previews. The local model server's CondaRuntime.create gets the same codes; kilo.local-inference has no code-specific "retry later" handling (it logs, tries the next channel set, then reports a generic configuration error).
  • Transport convention: KernelError carries only a code and a message, so the message keeps CODE: detail and gains one optional final line, [policy] {json}, holding a PolicyNotice (blocked[] with package, version, channel, org, policy, policyId, reason; policyNote; refused {org, channel}). The agent reads the line verbatim; parseEnvironmentsErrorMessage strips it from detail and returns it as policy; a malformed trailing line stays in detail. Failed job events carry policy too. The bridge's message text is never parsed for policy data.

Agent

  • Create, clone, install, update and conda.repodata.find tell the agent to report the package, policy, org and reason verbatim, never retry from another channel, pip or a URL, suggest asking the organization's administrator, and on NOT_SIGNED_IN / CHANNEL_ACCESS_DENIED ask the user to sign in to Anaconda (not Kilo) in Kilo Desktop, never asking for a token in the chat.
  • The conda-forge fallback guidance now says a blocked package is not "unavailable". The no-channels guidance names NO_CHANNELS_CONFIGURED.
  • The tools' Kilo requiresSignIn gate is unchanged: the Kilo and Anaconda sign-ins stay separate.

Settings

  • friendlyEnvironmentsError returns {code, message, detail?, policy?}. A policy block's message is the bridge's summary (the lines before the first blank line), and a sign-in refusal names the refused channel.
  • New PolicyErrorDetails: lists each blocked package with its policy, org and reason; shows the policy note; and offers "Sign in to Anaconda" through kilo.anaconda/account (optional in requires; the button is hidden without kilo.anaconda).
  • The Add packages and Update preview cards are titled per code ("Blocked by your organization's policy", "Sign in to Anaconda", "Dependency conflict", "Dependency conflict under your organization's policy", "Package not found", …) and re-run the preview after a sign-in. Job failure toasts show the same details.

Telemetry

  • New Environment Policy Blocked event (environment-policy-blocked), sent from the conda tools in main (surface: agent_tool, the first telemetry kilo.environments sends from main) and from the Settings catch paths (surface: ui). Data: surface, errorCode, blockedCount, policyNote, and up to 5 deduplicated policy UUIDs. It never includes package, channel, org or policy names, or reason text.

Docs

  • The security overview describes the bridge's Anaconda API key use, and its validation checklist covers the bridge's packaged conda configuration, which a system-wide conda configuration or an inherited conda root setting can bypass.
  • The plugin architecture's follow-ups list generic SOLVE_FAILED failures and Anaconda sign-out outside the model catalog. docs/plugins/schema.md is regenerated.

Release note
Conda environments now explain when your organization's package policy blocks a package, and when a channel needs you to sign in to Anaconda. Kilo Desktop's conda now authenticates to Anaconda's package repository with your Anaconda account. If you relied on repository tokens, or on ~/.condarc routing to anaconda-auth, sign in to Anaconda in Kilo Desktop.

Test plan

  • pnpm lint (oxlint, boundaries, schema doc, React Compiler check), pnpm format:check
  • pnpm check (all 28 typecheck tasks)
  • kilo.environments unit + integration tiers: 757 tests; browser tier: 218 tests; pnpm --filter @kilo-desktop/plugin-environments coverage passes the 80% gate (96% lines, 87% branches)
  • node scripts/check-plugin-isolation.mjs --build environments
  • apps/web kernel app tests and apps/desktop plugin/removability tests
  • New coverage: contract round trip and malformed trailer; every reason on every transaction path, auth:* domain codes, and results without a reason (SidecarCondaBackend.test.ts); job events carry the notice; tool guidance, the unchanged policy line and the telemetry payload (tools.test.ts, entry.test.ts through the FakeBridge); friendly messages and card titles; AddPackage (sign-in re-runs the preview, failed sign-in, no kilo.anaconda, policy toast) and Update (policy block, policy note) browser tests
  • Live, payload 0.1.23, signed in with a policy-restricted API key: installing a blocked package on defaults from the chat gives POLICY_BLOCKED with the policy and reason, the agent reports it verbatim and does not try conda-forge; the Add packages preview shows the policy card
  • Live, signed out of Anaconda: an install on a governed channel fails with NOT_SIGNED_IN (not PROVIDER_NOT_READY / SOLVE_FAILED); conda.repodata.find names the refused channel; "Sign in to Anaconda" opens the browser sign-in and the preview re-runs

…to their own codes

The bridge now reports why a transaction failed. Map blocked_by_policy to
POLICY_BLOCKED, not_signed_in and auth:not-signed-in to NOT_SIGNED_IN, and
access_denied and auth:access-denied to CHANNEL_ACCESS_DENIED, and give
no_channels_configured, package_not_found and channel_not_found their codes.
Other reasons, and results from older bridges without one, stay SOLVE_FAILED.

The blocked packages, the policy note and the refused org and channel ride
on one final `[policy] {json}` line of the error message, which the agent
reads as is and parseEnvironmentsErrorMessage strips from the detail. Failed
job events carry the notice too.
…and count them

The conda tools that solve (create, clone, install, update) and
conda.repodata.find now tell the agent to report a blocked package, its
policy, org and reason verbatim, never to retry from another channel, pip or
a URL, to suggest asking the org's administrator, and to ask the user to sign
in to Anaconda (not Kilo) on NOT_SIGNED_IN / CHANNEL_ACCESS_DENIED without
ever asking for a token. The conda-forge fallback guidance now says a
blocked package is not unavailable, and the no-channels guidance names
NO_CHANNELS_CONFIGURED.

A tool failure that is a policy block, an Anaconda sign-in refusal or a
solve failure with a policy note sends the new Environment Policy Blocked
event (surface, error code, counts and up to five policy UUIDs, never names)
and is rethrown unchanged.
…Settings

friendlyEnvironmentsError now returns the code, message, detail and policy
notice of a failure. A policy block's message is the bridge's summary, and a
sign-in refusal names the refused channel. The new PolicyErrorDetails lists
each blocked package with its policy, org and reason verbatim, shows the
policy note of a solve failure, and offers "Sign in to Anaconda" through
kilo.anaconda/account (optional; the button is hidden without it).

The Add packages and Update previews title their error card per code (a
policy block, an Anaconda sign-in or a dependency conflict) and re-run the
preview after a sign-in. Job failure toasts show the same details. Each
shown failure sends Environment Policy Blocked with surface ui.
…w-ups

The bundled conda bridge now authenticates to Anaconda's governed package
repository with the signed-in user's Anaconda API key, sends nothing when
the user is signed out, and never sends repository tokens. The security
overview says so, and its validation checklist covers the bridge's packaged
conda configuration, which a system-wide configuration or an inherited conda
root can bypass. The plugin architecture lists what this leaves open.
0.1.23 reports why a transaction failed (blocked_by_policy, not_signed_in,
access_denied, ...), explains policy blocks with the blocked packages, and
authenticates to Anaconda's governed package repository with the signed-in
user's Anaconda API key instead of repository tokens.
@kilo-code-bot

kilo-code-bot Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • plugins/environments/src/web/providers/conda/PolicyErrorDetails.tsx - blocked packages keyed by content instead of position; no indexing, ordering or React key defects
  • plugins/environments/src/web/providers/conda/environments-error-message.ts - new keyedBlockedPackages keys on every field of the schema-validated PolicyBlockedPackage, preserves insertion order, and drops only exact duplicates; no circular import
  • plugins/environments/src/web/providers/conda/environments-error-message.test.ts - covers reorder stability, per-field distinctness and exact-duplicate removal; assertions match the implementation
Previous Review Summaries (3 snapshots, latest commit 9154527)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 9154527)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (2 files)
  • plugins/environments/src/main/tools.ts - clone guidance now keeps the Anaconda sign-in remedy for NOT_SIGNED_IN / CHANNEL_ACCESS_DENIED; previous finding resolved
  • plugins/environments/src/main/tools.test.ts - assertions match the updated guidance; no conflicting clone assertions elsewhere

Previous review (commit 9aca6d5)

Status: 1 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 0
SUGGESTION 1
Issue Details (click to expand)

SUGGESTION

File Line Issue
plugins/environments/src/main/tools.ts 102 Clone guidance claims a clone never surfaces NOT_SIGNED_IN / CHANNEL_ACCESS_DENIED and drops the sign-in remedy, but raised auth:* bridge errors are classified for every call
Files Reviewed (13 files)
  • docs/plugins/dependency-graph.html - regenerated; edge matches plugin.json
  • plugins/environments/src/main/tools.ts - 1 issue (line 102)
  • plugins/environments/src/main/tools.test.ts - tests lock in the claim above
  • plugins/environments/src/test/environments-host.tsx - test helper; shell-hosted Toaster matches the real Frame
  • plugins/environments/src/web/providers/conda/environments-toasts.tsx - reporting now bound to the calling dialog
  • plugins/environments/src/web/providers/conda/environments-toasts.test.ts - no issues
  • plugins/environments/src/web/providers/conda/AddPackageDialog.tsx - no issues
  • plugins/environments/src/web/providers/conda/AddPackageDialog.browser.test.tsx - no issues
  • plugins/environments/src/web/providers/conda/CreateEnvironmentDialog.tsx - no issues
  • plugins/environments/src/web/providers/conda/CreateEnvironmentDialog.browser.test.tsx - no issues
  • plugins/environments/src/web/providers/conda/DeleteEnvironmentDialog.tsx - no issues
  • plugins/environments/src/web/providers/conda/ImportEnvironmentDialog.tsx - no issues
  • plugins/environments/src/web/providers/conda/UpdateConfirmationDialog.tsx - no issues

Fix these issues in Kilo Cloud

Previous review (commit d11ec62)

Status: 4 Issues Found | Recommendation: Address before merge

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 3
Issue Details (click to expand)

WARNING

File Line Issue
plugins/environments/src/web/providers/conda/environments-toasts.tsx 70 Policy telemetry from job-failure toasts is attributed to kilo.shell and dropped as undeclared, so the ui surface never sends for job failures
plugins/environments/plugin.json 13 Generated docs/plugins/dependency-graph.html not regenerated for the new kilo.anaconda/account require

SUGGESTION

File Line Issue
plugins/environments/src/main/tools.ts 162 Tool wrapper drops the ToolCallContext argument (latent loss of cancellation/chat identity)
plugins/environments/src/main/tools.ts 239 Clone guidance promises POLICY_BLOCKED and a [policy] line that clone cannot produce
Files Reviewed (37 files)
  • docs/plugin-architecture.md - no issues
  • docs/plugins/schema.md - generated; matches scripts/plugin-schema.mjs
  • docs/security-architecture-overview.md - no issues
  • plugins/environments/package.json - payload bump consistent
  • plugins/environments/plugin.json - 1 issue (line 13)
  • plugins/environments/src/contracts/common.ts (+ test) - no issues
  • plugins/environments/src/contracts/index.ts - no issues
  • plugins/environments/src/main/entry.ts (+ test) - no issues
  • plugins/environments/src/main/job-queue.ts (+ test) - no issues
  • plugins/environments/src/main/providers/conda/SidecarCondaBackend.ts (+ test) - no issues
  • plugins/environments/src/main/test-boot.ts - test helper
  • plugins/environments/src/main/tools.ts (+ test) - 2 issues (lines 162, 239)
  • plugins/environments/src/shared/policy-telemetry.ts (+ test) - no issues
  • plugins/environments/src/test/environments-host.tsx - test helper
  • plugins/environments/src/web/providers/conda/AddPackageDialog.tsx (+ browser test) - no issues
  • plugins/environments/src/web/providers/conda/BulkRemoveConfirmation.tsx - no issues
  • plugins/environments/src/web/providers/conda/CloneEnvironmentDialog.tsx - no issues
  • plugins/environments/src/web/providers/conda/DependencyPreview.tsx - no issues
  • plugins/environments/src/web/providers/conda/EnvironmentsPanelStates.tsx - no issues
  • plugins/environments/src/web/providers/conda/PackageInstallRequestDialog.tsx - no issues
  • plugins/environments/src/web/providers/conda/PolicyErrorDetails.tsx - no issues
  • plugins/environments/src/web/providers/conda/RemovePackageConfirmation.tsx - no issues
  • plugins/environments/src/web/providers/conda/UpdateConfirmationDialog.tsx (+ browser test) - no issues
  • plugins/environments/src/web/providers/conda/environments-error-message.ts (+ test) - no issues
  • plugins/environments/src/web/providers/conda/environments-toasts.tsx (+ test) - 1 issue (line 70)
  • plugins/environments/src/web/providers/conda/use-track-policy-failure.ts - no issues
  • pnpm-lock.yaml - consistent with package.json

Assumption: the toast-surface telemetry defect was verified against the kernel telemetry declaration gate and the shell-hosted <Toaster>; no runtime check was executed.

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash-1017 · Input: 38.3K · Output: 8K · Cached: 557.2K

…vironments

kilo.shell hosts <Toaster>, so a toast's content renders with kilo.shell's
sdk and the kernel dropped the environment-policy-blocked event it sent as
undeclared. The environments component that starts a job now binds its own
reporter (useJobToasts), and the failure is reported when its toast is
raised, not from inside the toast. Browser tests host the Toaster as
kilo.shell to prove the event is accepted for kilo.environments.
…rting tool wrapper

The wrapper that reports policy failures called each tool's run with its
input only, dropping the ToolCallContext (the call's abort signal and chat
identity) that the tool gateway passes.
…from conda.envs.clone

The backend reports every failed clone as SOLVE_FAILED without a policy
reason or a [policy] line, so clone's description no longer carries the
policy guidance; it says a policy or sign-in failure comes back as a
generic clone error and must not be routed around.
@romulorosa

Copy link
Copy Markdown
Collaborator Author

Addressed all four findings (each verified first):

  1. WARNING: job-failure policy telemetry attributed to kilo.shell. Confirmed. useTrack → useDomainObject → useSdk() reads the nearest SdkContext, and toasts render inside kilo.shell's <Toaster> (Frame), so the call reached kernel/telemetry with caller.pluginId = kilo.shell and was dropped as undeclared (kilo.shell/environment-policy-blocked). Fixed in e729aac: the environments component that starts a job now binds its own reporter through a new useJobToasts() hook. jobToastOptions / showJobError take that reporter and call it once when the failure toast is raised (the toast.promise error callback, or showJobError), never from inside the toast. This still works for backgrounded jobs after the dialog closes. Tests: a new ShellHostedToaster test helper renders <Toaster> with kilo.shell's identity on the real test kernel. The AddPackageDialog toast test failed with it before the fix (tracked was []) and passes after. A new CreateEnvironmentDialog test checks that a policy-blocked create moved to a background toast is accepted for kilo.environments exactly once. Unit tests check that the reporter is called once per failure and never on success.
  2. WARNING: stale docs/plugins/dependency-graph.html. Confirmed. Regenerated with pnpm docs:plugin-graph in 7729959, which adds ["environments", "anaconda", 1]. Note: pnpm lint checks only docs/plugins/schema.md (plugin-schema.mjs --check). Nothing checks the graph for staleness, so I didn't add a check in this PR.
  3. SUGGESTION: tool wrapper drops ToolCallContext. Confirmed: ToolImplementation.run(input, context), and before this PR run was passed through as is. Fixed in acdc289: the wrapper is now withPolicyFailureReporting(run, report), which forwards (input, context) unchanged and still reports and rethrows sync and async failures. Tests cover passing the context through and the sync-throw path.
  4. SUGGESTION: clone guidance promises POLICY_BLOCKED / [policy]. Confirmed: SidecarCondaBackend.clone throws SOLVE_FAILED with no policy notice, and raised conda:environment:failed-to-clone also maps to SOLVE_FAILED. Fixed in 9aca6d5: conda.envs.clone no longer carries POLICY_GUIDANCE. Instead it says a clone that policy or a missing Anaconda sign-in prevents fails as a generic SOLVE_FAILED clone error, to report it as given, and not to recreate the environment from another channel, pip or a URL. The tools tests now assert that clone's description doesn't mention POLICY_BLOCKED, [policy], NOT_SIGNED_IN or CHANNEL_ACCESS_DENIED.

Validation: pnpm lint, pnpm format, pnpm check are clean. pnpm --filter @kilo-desktop/plugin-environments coverage passed all tiers: 45 files, 979 tests, gate met (statements 96.2%, branches 87.6%, functions 92.5%, lines 97.2%).

Comment thread plugins/environments/src/main/tools.ts Resolved
@romulorosa

Copy link
Copy Markdown
Collaborator Author

Addressed the clone sign-in suggestion in 9154527: a raised auth:* bridge error is classified for every call, clone included, so conda.envs.clone's description again tells the agent that NOT_SIGNED_IN / CHANNEL_ACCESS_DENIED mean "sign in to Anaconda (not Kilo) in Kilo Desktop, or ask the administrator for access", and never to ask for a token. It still makes no POLICY_BLOCKED or [policy] promise, because a clone's success: false path is always a plain SOLVE_FAILED. The test now asserts the sign-in remedy is present instead of absent.

@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

React Doctor found no issues. 🎉

Reviewed by React Doctor for commit cf9bf3d.

…-channel-error-handling-and-n

# Conflicts:
#	docs/plugin-architecture.md
#	docs/security-architecture-overview.md

This branch has not been deployed

No deployments
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.

2 participants