Skip to content

copilot: add a Databricks plugin module for the GitHub Copilot app - #1789

Open
xi-db wants to merge 19 commits into
mainfrom
xi-db/stack/copilot-app-plugin
Open

xi-db wants to merge 19 commits into
mainfrom
xi-db/stack/copilot-app-plugin

Conversation

@xi-db

@xi-db xi-db commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

🥞 Stacked PR

Use this link to review incremental changes.


Summary

First step of a plugin-based setup for the GitHub Copilot desktop app. It adds ucode.agents.desktop.copilot_app_plugin, a module nothing calls yet, that installs a Databricks plugin into the app.

  • Plugin: ug writes a local plugin marketplace it owns under ~/.ucode/copilot-app-plugin/: marketplace databricks-unity-gateway, with one plugin, unity-gateway, under plugins/unity-gateway/, and one extension. The extension's config holds:

    • the providers and models to serve, and the app's picker rows;
    • the workspace and the request headers;
    • ug's and the Databricks CLI's absolute paths.
  • Turning it on: ug adds exactly two keys to Copilot's settings.json (honoring $COPILOT_HOME), and the running app loads the plugin without a restart:

    • an extraKnownMarketplaces["databricks-unity-gateway"] entry pointing at the directory;
    • enabledPlugins["unity-gateway@databricks-unity-gateway"].

    Every other setting is kept, the file is written atomically, and it keeps its mode. A symlinked settings.json is refused. A settings.json that isn't a JSON object, which Copilot ignores whole, is never rewritten; ug reports it instead.

  • Earlier ids: builds before this one used marketplace unity-gateway and plugin key databricks@unity-gateway. When their source is ug's directory:

    • install moves them to the new id and deletes the old plugins/databricks/ copy;
    • status counts them as installed;
    • removal, including the extension's deferred one, takes them out.

    A marketplace of either name that points elsewhere isn't ug's and is left alone.

  • Remove: deletes ug's keys (no false left behind), waits a few seconds for the app to unload the extension, then deletes the directory. If ug created settings.json at install and nothing else is left in it, the file is deleted too; otherwise it's kept. status() reports installed, disabled, not installed, or invalid settings.

  • Deferred remove: with the app closed, ug can't delete its rows from the picker. defer_remove() marks the extension's config instead and leaves the plugin on. On the app's next start, the extension:

    • deletes ug's providers over the app's local API;
    • then removes ug's settings.json keys under the same rules as the Python writer;
    • serves nothing.

    A lock keeps sessions from racing. cleanup_leftover() deletes the directory on a later ug run once the keys are gone, and status() reports removal_pending until then.

  • What the extension does:

    • Picker rows: it writes ug's providers and model rows to the app's model picker over the app's local WebSocket API, and deletes ug's providers and rows the config no longer has. Each extension process (one per session) syncs only when the rows or the app's launch token changed, one at a time. A failure is logged and never stops it serving.
    • Restarts the app once after a sync that changed ug's rows. The app's window loads the picker's providers only when it starts, about 7 s before the first extension runs, so new or changed rows show a generic icon and no Databricks label until the next launch.
      • One extension process claims the restart under the sync lock, keyed by a hash of the rows without the launch token. So the relaunch's re-sync, another chat or an unchanged configure never restarts again.
      • The app stops the extension process a few seconds after a sync that changed its rows. Also, the extension's own executable is the Copilot runtime's binary, which runs no scripts. So as soon as the sync returns, the extension passes the app's target (platform, pid, executable or bundle id, Copilot home) to a detached ug copilot-app-restart, using the absolute ug path in its config.
      • It finds the app's pid in run/app-owner.pid (or a second field of run/ws.port), and on Windows the executable through Get-Process. With no display on Linux, no app pid or no ug path, it doesn't start one.
      • It posts "The GitHub Copilot app restarts once, as soon as no chat is running a turn, to finish loading the Databricks models.", or else the restart hint.
      • The idle watch and the restart itself are ug's command, added in copilot: set up the GitHub Copilot app on configure #1791.
      • It's one attempt per change on purpose: a later launch already loads the rows' labels.
    • Session ids: it re-supplies the same provider and model ids in the session, with the rows' names, token limits and vision support, and with reasoning_effort turned off where asked (Chat Completions models).
    • Requests: it sends them straight to the workspace's AI Gateway with the given headers, plus session-id: <the app session's id> (the session the extension process serves), like ug copilot. An admin header of that name wins.
      • Subagent requests get no thread-id: the SDK's provider headers are static, and it has no per-request header hook.
    • Tokens: it gets each request's bearer token from ug auth-token (built with ug's PAT and custom OAuth choices), sharing one in-flight mint and reusing the token until two minutes before it expires. A 401 drops the cached token, and the next mint passes --force-refresh.
    • Hints: when the token can't be minted, it posts a sign-in hint for the auth mode in the chat once per run of failures, or says ug wasn't found.

A follow-up wires this into ug configure --agents copilot, ug revert and ug status.

CI (.github/workflows/ci.yml, needs a code-owner approval): the plugin's node tests (tests/*.test.mjs) run with node --test in the existing VS Code extension job, which sets up Node 22 (with the global WebSocket the extension uses) and is part of the required test check. The pytest wrapper that ran them only where the unit-test runner had Node is gone. The pytest node --check syntax checks and the Python-to-extension removal test still skip without Node.

Review fixes:

  • Install refuses, before writing anything, when extraKnownMarketplaces or enabledPlugins isn't an object, or when another marketplace already uses ug's name.
  • The sync lock names its owner; only one process can take a stale lock over.
  • The first sync (or deferred remove) retries three times with a backoff.
  • A token within two minutes of its expiry is reused for 30 s.
  • The token command keeps Windows' Path casing.
  • A rejected session.log is caught.
  • A deferred remove also covers an earlier build's install.
  • Staged install (Polly): the plugin tree (marketplace and plugin manifests, extension files, config.json) is written to a sibling staging directory, synced, and swapped in by renames: the old tree moves aside first, for Windows, and comes back if the swap fails. The settings keys are merged only after that, reinstalls go the same way, the extension's state carries over, and a crashed run's leftovers are removed after ten minutes. So the app never reads a half-written plugin.
  • Quiesced sync (Polly): under the sync lock, the extension rereads the remove flag from its config.json before the sync and before every write, and stops when ug has marked the plugin for removal. sync_lock() lets ug take the same lock.

Test plan

  • uv run pytest tests/test_copilot_app_plugin.py covers:
    • config generation for the Anthropic, Responses and Chat Completions providers, the row fields (limits with the 32K output floor, vision, reasoning effort), the app rows, and the PAT and custom OAuth token commands and hints;
    • the plugin layout under the new id;
    • merge and removal in settings.json: other keys kept, idempotent, invalid JSON or non-object keys left alone, $COPILOT_HOME, a foreign marketplace, symlinks and file mode, removing the keys before the directory;
    • earlier ids: migrated on install, counted by status, removed, and left alone at another path;
    • status.
  • node --test tests/*.test.mjs (CI's VS Code extension job):
    • copilot_app_plugin.test.mjs: token caching by JWT expiry, a shared in-flight mint, invalidation and force refresh, the hints, PATH and header handling, and session-id on every provider (from SESSION_ID, an admin override in any case, none without an id);
    • copilot_app_rows.test.mjs, against a fake of the app's WebSocket API: writing and pruning rows, request_id matching, retries, the lock and stamp, a closed app, failures logged without throwing, and when a sync counts as a change;
    • copilot_app_remove.test.mjs: the deferred remove against the same fake. It covers both ids; keys removed while other keys and the mode are kept; invalid JSON, a non-object and a symlink refused; only ug's providers deleted; the lock under concurrent sessions; and a closed app keeping the keys.
    • copilot_app_restart.test.mjs: starting ug copilot-app-restart with the target and the ug path and the chat line, the hint when it can't (no ug path, no plan, a failed spawn), and the plan per platform and its refusals, including app-owner.pid.
  • ruff check, ruff format --check, ty check src/.
  • Live in the app (Linux, app 1.4.2): installing and syncing rows, and the restart mechanism (SIGTERM, then relaunch; labels correct, chats resume) were checked by hand. The full automatic restart is being verified against this branch.
  • No user-journey test: nothing calls the module yet. The wiring PR (copilot: set up the GitHub Copilot app on configure #1791) describes the journey gate.

This pull request and its description were written by Isaac.

@xi-db xi-db added the ug-review Run the automated UG review label Nov 20, 2026
Comment thread tests/copilot_app_plugin.test.mjs Resolved
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

UG review recommendation

RECOMMENDATION: REJECT (request changes)

Reasons:

  • app-restart.mjs (high): the restart spawns a copilot-app-restart command that doesn't exist in src/. The result is still reported as "started", so users are told the app will restart and it never does. This is a reproducible behavioral bug that ships a broken workflow.
  • test_copilot_app_plugin.py (high): the POSIX file-mode assertion will fail on the Windows unit-test leg. It needs a skipif for win32, as test_agent_claude.py already uses.
  • init.py (medium): _installed accepts the legacy plugins/databricks id, but the config read, the removal check and the write only look at the current plugin dir. On legacy installs, removal silently leaves rows and settings keys behind, which is incorrect configuration cleanup.
  • extension.mjs (medium): the session.log and loginHint promises are not caught. A rejected log becomes an unhandled rejection that can kill the extension mid-session.
  • copilot_app_remove.test.mjs (medium): there is no coverage for the sync→restart→tellRestart path or for the 401 → tokenSource.invalidate() wiring. This regression coverage is needed.
  • The low-severity findings (the redundant lock test and the hardcoded lock constants) are optional cleanups and do not block on their own.

Findings considered: 7 (severities: high: 2, low: 2, medium: 3); see the inline review comments.

Advisory only: this recommendation never approves or merges the pull request. The ready-to-approve label tracks it.

@github-actions

Copy link
Copy Markdown
Contributor

Polly AI Review

Blocking issues

None confirmed.

Security vulnerabilities

None confirmed. Actual gateway requests and workspace isolation remain unverified.

Non-blocking notes

  • src/ucode/copilot_app_plugin/__init__.py:105 — can we define whether workspace accepts resolved keys? https://host?w=123 puts the gateway path inside the query. Add a selector-header regression for the supported contract.
  • src/ucode/copilot_app_plugin/__init__.py:166 — can we stage replacement files before publication? a failed copy during reinstall can truncate the enabled extension. Add a failed-rewrite preservation test.
  • tests/copilot_app_plugin.test.mjs:40 — can we cover runCommand argument boundaries, process failure and empty stdout? the token-source tests replace it, leaving the actual subprocess boundary untested.
  • tests/test_copilot_app_plugin.py:266 — can we remove test_syntax[ug-plugin.mjs]? test_node_unit_tests already imports that module and catches syntax errors.

Approach

The native marketplace and provider-extension approach fits the outcome without adding a proxy. Existing workspace-splitting helpers and staged marketplace publication offer concrete reuse opportunities.

Summary

Diff size (computed): 5 files; +763 / -0 lines (763 changed text lines); 0 binary files.

Category Files Added Deleted Share of changed text lines
Tests and test support 2 398 0 52.2%
Documentation 0 0 0 0.0%
Dependencies and lockfiles 0 0 0 0.0%
Implementation / other 3 365 0 47.8%

Shares use additions + deletions, including generated text and lockfiles. Binary files have no line count. Tests include fixtures/helpers under test paths and colocated test/spec files; categories are path-based, not coverage measurements.

Changes

Adds a standalone Python plugin installer, two JavaScript extension modules, and Python/Node component tests. No dependencies, lockfiles or documentation change.

The size is proportional to settings ownership, plugin generation and token lifecycle handling. Reusing workspace normalization and the existing staged-publication pattern would reduce bespoke handling. CLI integration is explicitly deferred.

Tests

Test-by-test assessment

Assessment is static; no PR code or tests were executed.

Test / case Behavior protected Layer Needed? Action / rationale
tests/copilot_app_plugin.test.mjs: helpers config, jwt Explicit configuration and synthetic token setup Test support keep Small helpers support distinct token cases without substantial scaffolding.
tests/copilot_app_plugin.test.mjs: jwtExpiryMs reads exp and tolerates opaque tokens JWT expiry parsing and invalid/opaque-token fallback Unit keep Protects the lifetime-selection boundary.
tests/copilot_app_plugin.test.mjs: childEnv puts the configured dirs ahead of PATH PATH precedence and preservation of inherited environment Unit keep Covers GUI environments with incomplete PATH values.
tests/copilot_app_plugin.test.mjs: createTokenSource caches until shortly before expiry Cached-token reuse and refresh margin Unit keep Checks both sides of the expiry boundary.
tests/copilot_app_plugin.test.mjs: createTokenSource gives opaque tokens a default lifetime Fallback lifetime without JWT expiry Unit keep Protects a separate supported token format.
tests/copilot_app_plugin.test.mjs: concurrent requests share one mint, and a failure is not cached Shared in-flight mint and retry after rejection Unit keep Covers concurrency and failure recovery, not just successful caching.
tests/copilot_app_plugin.test.mjs: withLoginHint shows the hint once per run of failures Hint suppression and reset after success Unit keep Directly checks the stated notification contract.
tests/copilot_app_plugin.test.mjs: withLoginHint still throws the token error when the hint fails Notification failure does not replace the authentication error Unit keep Distinct failure-isolation behavior.
tests/copilot_app_plugin.test.mjs: buildProviders attaches the token provider to every provider Authentication callback attachment without input mutation Unit keep Protects provider configuration independently of caching.
tests/test_copilot_app_plugin.py: _config, home, _settings, NODE, PLUGIN_SOURCE Explicit configuration, isolated home and Node availability Test support keep Lightweight filesystem isolation and runtime detection.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_providers_keep_ids_wires_and_headers Provider identifiers, protocol mapping and configured headers Unit keep Protects the generated provider contract across supported protocols.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_models_match_the_picker_rows Model metadata and provider references Unit keep Checks generated picker configuration; does not establish native picker behavior.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_token_command_and_hint_name_the_workspace_and_profile Workspace/profile arguments, executable paths and login hint Unit keep Protects configuration passed across the process boundary.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_without_profile Optional profile omission Unit keep Covers a distinct command-construction branch.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_trailing_slash_on_workspace Gateway URL joining with a trailing slash Unit keep Covers URL normalization, but not workspace-selector keys.
tests/test_copilot_app_plugin.py::TestWritePlugin::test_layout Marketplace, manifest, extension sources and generated configuration Filesystem integration keep Establishes the on-disk bundle contract.
tests/test_copilot_app_plugin.py::TestWritePlugin::test_rewrite_replaces_config Configuration refresh on repeated generation Filesystem integration keep Protects successful updates; failed publication is not covered.
tests/test_copilot_app_plugin.py::TestSettings::test_install_merges_only_ug_keys Preservation of unrelated settings and plugin entries Filesystem integration keep Essential ownership coverage.
tests/test_copilot_app_plugin.py::TestSettings::test_install_creates_settings Installation without an existing settings file Filesystem integration keep Distinct initial state from merging existing settings.
tests/test_copilot_app_plugin.py::TestSettings::test_install_is_idempotent Stable repeated installation Filesystem integration keep Protects the repeated-run transition.
tests/test_copilot_app_plugin.py::TestSettings::test_invalid_settings_are_left_alone — "{not json", "// comment\n{}", "[]" Rejection without rewriting unsupported settings Filesystem integration keep All cases protect the declared plain-JSON-object contract and preservation on failure.
tests/test_copilot_app_plugin.py::TestSettings::test_non_object_plugin_keys_are_left_alone Refusal to replace malformed shared settings containers Filesystem integration keep Protects existing user values from destructive replacement.
tests/test_copilot_app_plugin.py::TestSettings::test_copilot_home COPILOT_HOME override Filesystem integration keep Protects the documented settings-location override.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_leaves_no_ug_state Removal of owned entries/files while retaining foreign state Filesystem integration keep Covers cleanup and repeated removal.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_drops_empty_keys Cleanup of containers emptied by removal Filesystem integration keep Distinct cleanup branch.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_with_invalid_settings_changes_nothing Preservation when settings cannot be safely edited Filesystem integration keep Protects the removal failure boundary.
tests/test_copilot_app_plugin.py::TestStatus::test_not_installed Status without installation Filesystem integration keep Baseline status state.
tests/test_copilot_app_plugin.py::TestStatus::test_installed Status for an enabled installation Filesystem integration keep Successful status state.
tests/test_copilot_app_plugin.py::TestStatus::test_disabled Status after disabling the plugin Filesystem integration keep Distinguishes disabled from absent.
tests/test_copilot_app_plugin.py::TestStatus::test_missing_directory_is_not_installed Status with stale settings and missing files Filesystem integration keep Protects a distinct inconsistent-state boundary.
tests/test_copilot_app_plugin.py::TestExtensionSource::test_syntax[extension.mjs] Entry-module syntax Static Node check keep The other tests do not load this entry module.
tests/test_copilot_app_plugin.py::TestExtensionSource::test_syntax[ug-plugin.mjs] Helper-module syntax Static Node check remove Duplicates parsing performed by test_node_unit_tests.
tests/test_copilot_app_plugin.py::TestExtensionSource::test_node_unit_tests Node suite participation in the pytest entry point Test integration keep Makes the JavaScript behavior checks available through the normal focused test command.

The component coverage is appropriate for local configuration and token logic. The actionable gaps are workspace-selector handling, interrupted bundle replacement and the real subprocess boundary, as noted above. Existing CLI/VS Code tests exercise different implementations and do not establish this desktop extension’s contract.

SDK acceptance, actual outgoing requests, response status/payloads, native model-picker labels, completed inference and downstream usage attribution are unverified. Before rollout, verify plugin loading in the app, select a configured model, complete a response, and correlate its gateway request and workspace headers.

Scope

All five changed files support the stated standalone plugin outcome. No unrelated changes were found. Configure/revert/status CLI wiring is deferred as described; whether PluginConfig.workspace accepts resolved workspace keys remains an API-contract question.


Automated review by Polly · workflow run

xi-db and others added 12 commits November 20, 2026 10:46
An unwired module that writes a ug-owned local plugin marketplace and turns it
on in Copilot's settings.json. The plugin's extension registers ug's provider
and model ids and serves them straight from the AI Gateway, minting a token
with `ug auth-token` per request (cached until shortly before expiry).

Co-authored-by: Isaac <no-reply@databricks.com>
The session uses the extension's model rows instead of the app's, so they
repeat the rows' token limits and, for Claude, vision support.

Co-authored-by: Isaac <no-reply@databricks.com>
… token

remove() now drops the settings keys, waits for the app to unload the
extension, then deletes the directory; deleting it first left running
extensions serving open chats. The extension drops its cached token when a
model call fails with a 401 and mints the next one with --force-refresh
(untested live).

Co-authored-by: Isaac <no-reply@databricks.com>
The extension now registers ug's providers and model rows over the app's
local WebSocket API when it starts, from rows in its config, and deletes
ug's providers and rows that the config no longer has. It syncs only when
the rows or the app's launch token changed, one extension process at a
time, and logs a failure without affecting the models it serves.

Model rows also turn off reasoning_effort where asked (Chat Completions
models), and never advertise an output limit below the 32K the runtime
asks for. The Databricks CLI's directory goes on the token command's PATH.

Co-authored-by: Isaac <no-reply@databricks.com>
- The token command comes from ug's own builders, so a PAT or custom OAuth
  setup keeps its mode: `ug auth-token --host` ignores the saved choices.
  The sign-in hint follows the mode.
- A failed token command shows a hint only for an auth failure, or says ug
  wasn't found; a hint the session couldn't show yet doesn't count as shown.
  A 401 also logs the sign-in hint, since the app's own message names
  Copilot's API-key settings.
- A mint running when the token is invalidated no longer caches its token.
- remove() leaves a unity-gateway marketplace that points elsewhere.
- settings.json: a symlink is refused, and rewrites keep the file's mode.
- The row-sync node tests skip on a Node without a global WebSocket.

Co-authored-by: Isaac <no-reply@databricks.com>
Desktop-app adapters live in agents/desktop/. The wheel keeps shipping the extension's .mjs files, since hatch includes every file in the package.

Co-authored-by: Isaac <no-reply@databricks.com>
With the GitHub Copilot app closed, ug can't delete its rows from the app's picker. defer_remove marks the plugin's config, and on the app's next start the extension deletes ug's providers over the app's local API, then removes ug's two settings.json keys under the same rules as the Python writer, and serves nothing. A lock keeps sessions from racing. cleanup_leftover deletes the directory on a later ug run once the keys are gone. Not yet checked against the live app.

Co-authored-by: Isaac <no-reply@databricks.com>
…mpty

install() records when Copilot's settings.json didn't exist before. remove(), and cleanup_leftover() after a deferred remove, delete the file only if ug created it and nothing is left in it; otherwise they keep it.

Co-authored-by: Isaac <no-reply@databricks.com>
The app's window loads the model picker's providers only when it starts,
about 7 s before the first extension runs, so rows the plugin has just
created or changed show a generic icon and no Databricks label until the
next launch. After a sync that changed ug's rows, one extension process
claims a restart under the sync lock, keyed by a hash of the rows, so a
relaunch, another chat or an unchanged configure never restarts again.

It waits until no chat in the app is running a turn (the app's session
event stream, else its own session, plus a quiet window), posts a line in
the chat, and a detached helper closes the app without forcing it, waits
for it to exit and starts it again with the user's session environment.
When it can't (no display on Linux, the app stays up, three minutes
without idle), it asks the user to restart instead.

Co-authored-by: Isaac <no-reply@databricks.com>
The pytest wrappers ran them only where the unit-test runner happened to
have Node, so they could skip. They now run in the VS Code extension
job, which sets up Node 22 (with the global WebSocket the extension
uses) and is part of the required test check. The pytest syntax checks
and the Python-to-extension removal test still skip without Node.

Co-authored-by: Isaac <no-reply@databricks.com>
…ateway

The plugin is now unity-gateway in the databricks-unity-gateway
marketplace, under plugins/unity-gateway. Configure moves an earlier
build's unity-gateway marketplace and databricks@unity-gateway key to the
new id when their source is ug's plugin directory, and deletes the old
plugin copy; status counts either as installed, and removal (also the
extension's deferred one) takes out both. A marketplace of either name at
another path is still left alone.

Co-authored-by: Isaac <no-reply@databricks.com>
…ests

Like ug copilot, every model request from the GitHub Copilot app now
carries session-id, so the gateway's usage table groups an app chat's
turns. It's the session the extension process serves (SESSION_ID, which
joinSession resumes), not a random id; an admin header of that name wins.
Subagent requests get no thread-id: the SDK's provider headers are static
and it has no per-request header hook.

Co-authored-by: Isaac <no-reply@databricks.com>
@xi-db
xi-db force-pushed the xi-db/stack/copilot-app-plugin branch from 640eded to 1f43107 Compare November 20, 2026 11:10
xi-db and others added 4 commits November 20, 2026 11:18
App 1.4.2 writes only the port to run/ws.port and its own pid to
run/app-owner.pid, so the restart never found the app and only posted
the hint. The pid now comes from app-owner.pid, with ws.port's second
field as a fallback.

The restart stays one attempt per change: a launch after a failed one
already loads the rows' labels, so it needs no retry.

Co-authored-by: Isaac <no-reply@databricks.com>
The app stops the extension process a few seconds after the sync that
changed its rows, so the idle wait and restart inside it never ran.
The extension now starts the detached helper as soon as the sync
returns (before the session is joined) and posts one line saying the
app restarts once no chat is busy. The helper opens its own watch of
the app's session events, waits for idle plus the quiet window, then
restarts the app. Without the session events, or when the app closes
while it waits, it gives up and leaves the app as it is.

Co-authored-by: Isaac <no-reply@databricks.com>
In the app, the extension's process.execPath is the Copilot runtime's
own binary, which refuses to run a script, so the detached restart
helper exited at once. The extension now passes the app's target to a
detached `ug copilot-app-restart`, using the absolute ug path its config
now carries; ug watches the app's session events, waits for idle and
restarts the app. The JavaScript watch and restart code goes away.

Co-authored-by: Isaac <no-reply@databricks.com>
- install checks that extraKnownMarketplaces and enabledPlugins are JSON
  objects before it writes the plugin, so a refusal leaves no orphan
  plugin directory behind;
- the token command's environment keeps Windows' Path casing instead of
  adding a second PATH key;
- a token the CLI hands out within two minutes of its expiry is reused
  for 30 s rather than minted again for every request;
- the sync lock names its owner, so a process whose lock was taken over
  as stale can't release the new owner's, and only one process can take
  a stale lock over;
- the first sync (or deferred remove) retries three times with a backoff
  when the app hasn't published its endpoint yet.

Co-authored-by: Isaac <no-reply@databricks.com>
@xi-db
xi-db marked this pull request as ready for review November 20, 2026 12:19
@xi-db
xi-db requested a review from billiam-wang as a code owner November 20, 2026 12:19
Copilot AI balanced review requested due to automatic review settings November 20, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Comment thread tests/copilot_app_remove.test.mjs Resolved
Comment thread tests/copilot_app_remove.test.mjs Resolved
Comment thread tests/copilot_app_rows.test.mjs Resolved
Comment thread tests/test_copilot_app_plugin.py Resolved
Copilot AI balanced review requested due to automatic review settings November 20, 2026 12:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

- A deferred remove on an earlier build's install marks that build's
  extension, under its own plugin directory, so the next app start still
  deletes the rows and keys; a pending removal is found there too.
- install leaves another marketplace of ug's name alone instead of
  pointing it at ug's plugin, and refuses before writing anything.
- The extension catches a rejected session.log, so a hint the chat can't
  show no longer ends the extension.
- Tests take the lock file name and staleness from app-rows.mjs, and the
  file-mode test skips on Windows, which has no POSIX modes.

Co-authored-by: Isaac <no-reply@databricks.com>
@github-actions

Copy link
Copy Markdown
Contributor

Polly AI Review

Blocking issues

  1. Foreign marketplace registration is lost — src/ucode/agents/desktop/copilot_app_plugin/__init__.py:386
    can we preserve a same-name marketplace pointing elsewhere? install overwrites its registration; subsequent removal deletes it rather than restoring it.

  2. Reinstall can be undone by deferred removal — src/ucode/agents/desktop/copilot_app_plugin/app-remove.mjs:137
    can install and removal share a lock or generation check? removal paused during provider deletion resumes after reinstall and deletes the newly enabled keys.

  3. A live synchronization lock can be stolen — src/ucode/agents/desktop/copilot_app_plugin/app-rows.mjs:234
    can takeover verify the owner has stopped? sequential requests can exceed 60 seconds; a second process enters, and the first later deletes its successor’s lock.

  4. Legacy installations cannot be removed through deferral — src/ucode/agents/desktop/copilot_app_plugin/__init__.py:464
    can deferral locate the installed legacy config? _installed() accepts plugins/databricks, but the config reader only checks plugins/unity-gateway, so removal returns false.

  5. A lost acknowledgement suppresses the required restart — src/ucode/agents/desktop/copilot_app_plugin/app-rows.mjs:283
    can restart intent survive a lost final upsert reply? the retry finds matching rows and records success without restarting, leaving the picker unchanged until a manual restart.

  6. The permission test fails on Windows — tests/test_copilot_app_plugin.py:413
    can this compare permissions before and after, or skip POSIX assertions on Windows? writable files report 0666, not the required 0644; Windows CI includes this test.

Security vulnerabilities

No additional demonstrated security vulnerabilities found. The settings-ownership data loss is reported above.

Non-blocking notes

  • tests/test_copilot_app_plugin.py::TestSettings::test_remove_drops_empty_keys: can we consolidate this with test_remove_drops_the_keys_before_the_directory, which asserts the same result?
  • tests/copilot_app_plugin.test.mjs:205: can we add native evidence when the stack is wired? constructed headers do not establish actual requests, completed inference, or usage attribution.

Approach

The native token-provider approach avoids another inference proxy. A concrete simplification is to generate the ownership identifiers once for Python and JavaScript, rather than maintain parallel removal rules.

Summary

Diff size (computed): 13 files; +2967 / -0 lines (2967 changed text lines); 0 binary files.

Category Files Added Deleted Share of changed text lines
Tests and test support 6 1712 0 57.7%
Documentation 0 0 0 0.0%
Dependencies and lockfiles 0 0 0 0.0%
Implementation / other 7 1255 0 42.3%

Shares use additions + deletions, including generated text and lockfiles. Binary files have no line count. Tests include fixtures/helpers under test paths and colocated test/spec files; categories are path-based, not coverage measurements.

Changes

Adds a local Copilot marketplace, plugin generation, authentication configuration, picker synchronization, restart planning, and immediate/deferred removal. The diff also adds focused Python and JavaScript tests, a fake WebSocket app, and CI wiring. No documentation, dependency, or generated-artifact changes are included.

The breadth is broadly proportional to the intended plugin lifecycle. Sharing ownership identifiers would reduce duplicated contract logic without removing behavior. The ownership and lifecycle failures above need resolution before approval.

Tests

Test-by-test assessment

Assessment is based on the frozen snapshot and relevant existing tests. JavaScript syntax checks and Python parsing passed. Behavioral tests, pytest collection, lint, and typecheck were not executed; network-isolated execution was unavailable.

“WS component” below means loopback WebSocket communication with the fake app, not native Copilot. These tests provide configuration, simulated protocol, and request-side evidence. Actual SDK compatibility, inference requests/responses, native picker labels, idle-safe restart, and downstream usage attribution remain unverified. The referenced tests/_helpers/README.md is absent from the trusted checkout.

Python configuration and lifecycle

Test / case Behavior protected Layer Needed? Action / rationale
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_providers_keep_ids_wires_and_headers Provider identifiers, protocol, URL, and headers Unit keep Protects the generated provider contract.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_models_match_the_picker_rows Model identifiers match picker rows Unit keep Detects inconsistent generated catalogs.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_models_repeat_the_rows_limits_and_vision Model limits and vision capabilities Unit keep Protects capability translation.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_a_small_output_limit_is_left_to_the_runtime Small output-limit handling Unit keep Covers the runtime-limit boundary.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_reasoning_effort_can_be_turned_off Explicitly disabled reasoning effort Unit keep Covers a distinct capability branch.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_app_rows_and_databricks_path Picker payload, owned providers, and CLI path Unit keep Checks the Python-to-extension configuration contract.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_a_pat_token_command_and_hint PAT authentication command and hint Unit keep Protects the PAT path.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_a_custom_oauth_token_command_and_hint Custom OAuth command with optional profile Unit keep Protects a separate authentication path.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_a_missing_ug_hint_names_its_path Actionable missing-executable hint Unit keep The executable-path assertion is distinct.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_token_command_and_hint_name_the_workspace_and_profile Default authentication arguments and executable search paths Unit keep Protects workspace/profile forwarding.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_without_profile Authentication without a profile Unit keep Covers omission of profile arguments.
tests/test_copilot_app_plugin.py::TestExtensionConfig::test_trailing_slash_on_workspace Workspace URL normalization Unit keep Covers an input boundary.
tests/test_copilot_app_plugin.py::TestWritePlugin::test_layout Marketplace, plugin, and extension layout Filesystem keep Verifies the files the app must discover.
tests/test_copilot_app_plugin.py::TestWritePlugin::test_rewrite_replaces_config Configuration replacement on repeated setup Filesystem keep Protects reconfiguration.
tests/test_copilot_app_plugin.py::TestSettings::test_install_merges_only_ug_keys Preservation of unrelated settings Filesystem keep Core ownership coverage; missing foreign-current-name installation coverage is noted below.
tests/test_copilot_app_plugin.py::TestSettings::test_install_creates_settings Creation of a new settings file Filesystem keep Protects initial installation and created-file tracking.
tests/test_copilot_app_plugin.py::TestSettings::test_install_is_idempotent Stable repeated installation Filesystem keep Protects repeated-run behavior.
tests/test_copilot_app_plugin.py::TestSettings::test_invalid_settings_are_left_alone — malformed JSON, commented JSON, array Invalid settings remain untouched Filesystem keep Covers parse failures and a distinct invalid top-level type.
tests/test_copilot_app_plugin.py::TestSettings::test_non_object_plugin_keys_are_left_alone Refusal of invalid nested settings shapes Filesystem keep Covers validation beyond the top-level object.
tests/test_copilot_app_plugin.py::TestSettings::test_copilot_home Settings location override Filesystem keep Protects COPILOT_HOME handling.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_leaves_no_ug_state Owned-state removal and repeat removal Filesystem keep Protects revert while preserving foreign settings.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_deletes_a_settings_file_ug_created Deletion of an otherwise empty UG-created file Filesystem keep Covers the positive created-file ownership case.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_keeps_a_created_settings_file_the_user_added_to Preservation of later user additions Filesystem keep Protects user data during revert.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_keeps_an_empty_settings_file_ug_didnt_create Preservation of a pre-existing empty file Filesystem keep Covers the negative ownership case.
tests/test_copilot_app_plugin.py::TestSettings::test_a_finished_deferred_remove_deletes_a_settings_file_ug_created Created-file cleanup after deferred removal Filesystem keep Distinct cleanup entry point.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_drops_the_keys_before_the_directory Disable, wait, then delete ordering Filesystem keep Protects extension-unload ordering and empty-parent cleanup.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_without_keys_deletes_the_directory_at_once Immediate deletion when already disabled Filesystem keep Protects the no-wait branch.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_keeps_a_foreign_unity_gateway_marketplace Foreign marketplace preservation during removal Filesystem keep Useful ownership boundary; does not cover installation overwriting it.
tests/test_copilot_app_plugin.py::TestSettings::test_a_symlinked_settings_file_is_refused Symlink target preservation Filesystem keep Protects a destructive-write boundary.
tests/test_copilot_app_plugin.py::TestSettings::test_rewriting_settings_keeps_their_mode Permission preservation across install/remove Filesystem keep Make the assertion portable as described in blocking issue 6.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_drops_empty_keys Empty parent-object cleanup Filesystem consolidate The same setup and final settings assertion appear in TestSettings::test_remove_drops_the_keys_before_the_directory.
tests/test_copilot_app_plugin.py::TestSettings::test_remove_with_invalid_settings_changes_nothing Safe removal failure Filesystem keep Verifies the directory remains when settings cannot be rewritten.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_defer_remove_marks_the_config_and_keeps_the_plugin_enabled Deferred flag and registration retention Filesystem keep Protects the core deferred-removal contract.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_defer_remove_without_a_plugin Missing-directory and missing-registration no-ops Filesystem keep Covers distinct incomplete-install states.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_defer_remove_refuses_invalid_settings — malformed JSON, array Invalid settings prevent marking removal Filesystem keep Protects the deferred-removal entry point.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_defer_remove_refuses_a_symlinked_settings_file Symlink refusal before deferred marking Filesystem keep Protects this separate write path.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_install_cancels_a_deferred_remove Sequential reinstall clears removal intent Filesystem keep Does not cover an already-running extension; add the race regression below.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_a_disabled_plugin_is_not_pending Disabled-state precedence Filesystem keep Covers a state transition involving pending removal.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_cleanup_leftover_waits_for_the_extension Cleanup waits for registration removal Filesystem keep Protects unload gating.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_cleanup_leftover_keeps_a_plugin_without_a_deferred_remove No cleanup without removal intent Filesystem keep Prevents accidental directory deletion.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_cleanup_leftover_keeps_the_directory_while_a_key_is_left Partial registration blocks deletion Filesystem keep Covers an intermediate state.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_cleanup_leftover_with_invalid_settings_changes_nothing Cleanup failure preserves state Filesystem keep Protects a material failure path.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_remove_after_the_extension_deletes_the_directory_at_once Immediate removal after extension cleanup Filesystem keep Expresses the deferred-to-final-cleanup journey.
tests/test_copilot_app_plugin.py::TestDeferredRemove::test_remove_while_pending_still_drops_the_keys_first Immediate removal during pending removal Filesystem keep Protects ordering in a distinct state transition.
tests/test_copilot_app_plugin.py::TestStatus::test_not_installed Absent installation status Unit keep Isolated baseline-status assertion.
tests/test_copilot_app_plugin.py::TestStatus::test_installed Installed status Unit keep Isolated status-contract assertion.
tests/test_copilot_app_plugin.py::TestStatus::test_disabled Disabled status Unit keep Isolated status-contract assertion.
tests/test_copilot_app_plugin.py::TestStatus::test_missing_directory_is_not_installed Registration without extension files Filesystem keep Covers an incomplete installation.
tests/test_copilot_app_plugin.py::TestExtensionSource::test_syntax — extension.mjs, ug-plugin.mjs, app-rows.mjs, app-remove.mjs, app-restart.mjs JavaScript source parses Parser subprocess keep Lightweight syntax coverage independent of successful SDK execution.
tests/test_copilot_app_plugin.py::TestExtensionSource::test_the_extension_finishes_a_deferred_remove_for_ug Python marking, JavaScript removal, Python cleanup Cross-language component keep Uniquely checks the cross-runtime configuration contract.
tests/test_copilot_app_plugin.py::TestEarlierIds::test_an_earlier_install_counts_as_installed Legacy-layout recognition Filesystem keep Protects the explicit migration contract.
tests/test_copilot_app_plugin.py::TestEarlierIds::test_install_moves_an_earlier_install_to_the_current_id Identifier migration and old-directory cleanup Filesystem keep Protects upgrade behavior.
tests/test_copilot_app_plugin.py::TestEarlierIds::test_remove_takes_out_an_earlier_install Immediate removal of legacy state Filesystem keep Does not establish deferred legacy removal.
tests/test_copilot_app_plugin.py::TestEarlierIds::test_an_earlier_id_at_another_path_isnt_ugs Foreign legacy registration preservation Filesystem keep Protects ownership during migration.

JavaScript support and authentication

Test / case Behavior protected Layer Needed? Action / rationale
tests/copilot_app_fake.mjs — support module, no test cases WebSocket framing, provider/model storage, recorded requests, injected faults Test support keep Shared transport setup; simulated responses are not independent evidence of the native app contract.
tests/copilot_app_plugin.test.mjs — jwtExpiryMs reads exp and tolerates opaque tokens JWT parsing and opaque-token fallback Unit keep Covers malformed-token boundaries.
tests/copilot_app_plugin.test.mjs — childEnv puts the Databricks CLI's dir on PATH Explicit CLI-directory discovery Unit keep Protects GUI-runtime executable lookup.
tests/copilot_app_plugin.test.mjs — childEnv puts the configured dirs ahead of PATH Search-path precedence and inherited environment Unit keep Covers configured-directory precedence.
tests/copilot_app_plugin.test.mjs — createTokenSource caches until shortly before expiry JWT refresh deadline Unit keep Exercises both sides of the deadline.
tests/copilot_app_plugin.test.mjs — createTokenSource gives opaque tokens a default lifetime Opaque-token cache lifetime Unit keep Uses a different expiry mechanism.
tests/copilot_app_plugin.test.mjs — concurrent requests share one mint, and a failure is not cached Concurrent authentication and retry Unit keep Protects failure recovery and shared work.
tests/copilot_app_plugin.test.mjs — withLoginHint shows the hint once per run of failures Failure-burst hint suppression and reset Unit keep Checks sequential hint state transitions.
tests/copilot_app_plugin.test.mjs — withLoginHint still throws the token error when the hint fails Original authentication error preservation Unit keep Logging must not replace the actual failure.
tests/copilot_app_plugin.test.mjs — withLoginHint tries again until a hint is shown Retry after an unsuccessful hint Unit keep Distinct from suppression after success.
tests/copilot_app_plugin.test.mjs — hintFor picks the hint by how ug auth-token failed Authentication failure classification Unit keep Distinguishes command failure from missing executable.
tests/copilot_app_plugin.test.mjs — an invalidate during a mint keeps its token out of the cache In-flight token invalidation Unit keep Covers a distinct generation race.
tests/copilot_app_plugin.test.mjs — buildProviders attaches the token provider to every provider Provider callback attachment without mutation Unit keep Protects generated SDK configuration.
tests/copilot_app_plugin.test.mjs — invalidate drops the cached token and force-refreshes the next mint once Cached-token invalidation and refresh flag Unit keep Checks once-per-invalidation command construction.
tests/copilot_app_plugin.test.mjs — isAuthRejection matches only 401 errors and call failures Authentication-event filtering Unit keep Native SDK event compatibility remains unverified.
tests/copilot_app_plugin.test.mjs — buildProviders sends the app session's id on every provider's requests Session header construction across providers Unit keep Checks configuration objects, not actual outgoing requests.
tests/copilot_app_plugin.test.mjs — buildProviders takes the session id the runtime gives the extension Default session-ID environment lookup Unit keep Covers the default-input branch.
tests/copilot_app_plugin.test.mjs — an admin's session-id header wins, in any case Case-insensitive explicit-header precedence Unit keep Protects administrator overrides.
tests/copilot_app_plugin.test.mjs — without a session id the headers stay as configured Missing-session fallback Unit keep Prevents unintended header insertion.

JavaScript removal

Test / case Behavior protected Layer Needed? Action / rationale
tests/copilot_app_remove.test.mjs — removeOnce deletes ug's providers, then its settings keys, keeping everything else Owned-row removal, settings preservation, and permissions WS component + filesystem keep Main deferred-removal contract.
tests/copilot_app_remove.test.mjs — removeOnce drops a parent object it leaves empty Empty ownership-container cleanup WS component + filesystem keep Covers a distinct resulting settings shape.
tests/copilot_app_remove.test.mjs — once the keys are gone, another session's extension does nothing Repeated-removal short circuit WS component keep Verifies no subsequent app connection.
tests/copilot_app_remove.test.mjs — only one extension process removes at a time; a stale lock is taken over Lock refusal and stale takeover WS component + filesystem keep Add live-owner expiry coverage; age alone does not prove abandonment.
tests/copilot_app_remove.test.mjs — concurrent extension processes delete each provider once Contended removal WS component keep Exercises concurrent calls, not independent OS processes.
tests/copilot_app_remove.test.mjs — settings that are invalid JSON are left alone, but the rows still go Parse-failure preservation with row cleanup WS component + filesystem keep Protects a material failure input.
tests/copilot_app_remove.test.mjs — settings that are a commented file are left alone, but the rows still go Commented-settings preservation WS component + filesystem keep Explicitly protects unsupported commented configuration.
tests/copilot_app_remove.test.mjs — settings that are a non-object are left alone, but the rows still go Invalid top-level type preservation WS component + filesystem keep Covers validation distinct from parsing.
tests/copilot_app_remove.test.mjs — a symlinked settings file is refused Symlink target preservation WS component + filesystem keep Protects a filesystem safety boundary.
tests/copilot_app_remove.test.mjs — an earlier build's keys go too Legacy settings-key removal Filesystem unit with fake-app setup keep Protects JavaScript migration compatibility independently of Python removal.
tests/copilot_app_remove.test.mjs — a foreign marketplace of ug's name and its plugin key stay Foreign registration preservation WS component + filesystem keep Checks ownership and absence of app calls.
tests/copilot_app_remove.test.mjs — the keys stay until the rows are gone Failed removal retention and retry WS component + filesystem keep Extend with reinstall while provider deletion is awaiting a reply.
tests/copilot_app_remove.test.mjs — a dropped connection is logged, not thrown Disconnect and logging-failure containment WS component keep Distinct from explicit API rejection.
tests/copilot_app_remove.test.mjs — without owned providers the keys go without connecting Settings-only cleanup WS component + filesystem keep Protects the no-provider branch.
tests/copilot_app_remove.test.mjs — a later install syncs its rows and restarts the app again Removal clears sync/restart stamps WS component keep Establishes sequential reinstall eligibility, not an actual restart.
tests/copilot_app_remove.test.mjs — outside remove mode nothing is removed Destructive-operation guard WS component keep Prevents accidental cleanup.
tests/copilot_app_remove.test.mjs — the settings file is found under COPILOT_HOME Settings-path construction Unit keep Protects the JavaScript-side path contract.
tests/copilot_app_remove.test.mjs — in remove mode the extension removes ug and joins its session without serving Removal entry-point wiring and empty registration Substituted SDK + WS component keep Checks cross-module wiring without claiming native SDK evidence.
tests/copilot_app_remove.test.mjs — in remove mode a failed join is logged, not thrown SDK-join failure containment Substituted SDK + WS component keep Protects a distinct entry-point failure.

JavaScript restart

Test / case Behavior protected Layer Needed? Action / rationale
tests/copilot_app_restart.test.mjs — the extension starts the helper with the app's target and says so in the chat Target forwarding and restart message Unit, mocked dependencies keep Checks orchestration, not helper execution or native restart.
tests/copilot_app_restart.test.mjs — when the helper can't restart the app here, the chat gets the restart hint Unsupported/start-failure fallback Unit, mocked dependencies keep Appropriate low-layer failure matrix.
tests/copilot_app_restart.test.mjs — planRestart takes the app's pid from its run file Legacy PID format and platform plans Filesystem unit keep Protects platform-specific planning inputs.
tests/copilot_app_restart.test.mjs — planRestart reads the app's pid from app-owner.pid, as the app writes it Current PID format and malformed PID refusal Filesystem unit keep Distinct input format and validation boundary.
tests/copilot_app_restart.test.mjs — planRestart gives up without a display, the app's pid or a known launcher Unsupported restart prerequisites Filesystem unit keep Keeps prerequisite matrices below native E2E.

JavaScript picker synchronization

Test / case Behavior protected Layer Needed? Action / rationale
tests/copilot_app_rows.test.mjs — readEndpoint reads the first value of each run file and honours COPILOT_HOME Endpoint parsing and home override Filesystem unit keep Protects endpoint discovery.
tests/copilot_app_rows.test.mjs — syncOnce writes the rows, then does nothing until they or the app launch change Initial CRUD, handshake, sync stamp, and secret preservation WS component keep Main successful synchronization scenario.
tests/copilot_app_rows.test.mjs — only the first sync that changes the app's rows asks for a restart Restart markers across configurations and launches WS component keep Checks restart intent, not app execution.
tests/copilot_app_rows.test.mjs — rows the app already has don't ask for a restart Matching persisted rows without a local marker WS component keep Covers a distinct initial state.
tests/copilot_app_rows.test.mjs — a deleted row, a new row or a missing secret is a change Model/provider drift detection WS component keep Appropriate low-layer mutation matrix.
tests/copilot_app_rows.test.mjs — an app that reports the rows differently asks for one restart, not one per launch Restart-loop suppression with normalized replies WS component keep Protects persistent-mismatch behavior.
tests/copilot_app_rows.test.mjs — of several extension processes, one asks for the restart Contended synchronization WS component keep Checks concurrent calls within one process.
tests/copilot_app_rows.test.mjs — syncOnce deletes ug's stale providers and rows but no one else's Stale owned-row cleanup and foreign-provider preservation WS component keep Protects deletion ownership.
tests/copilot_app_rows.test.mjs — repeated syncs leave exactly one copy of each row Fixed-ID upsert behavior across state directories WS component keep Distinct from contention over a shared lock.
tests/copilot_app_rows.test.mjs — only one extension process syncs at a time; a stale lock is taken over Lock refusal and age-based takeover WS component + filesystem keep Extend with a still-live owner exceeding the lease and successor-lock preservation.
tests/copilot_app_rows.test.mjs — a reply for another request is skipped Response/error correlation WS component keep Protects a meaningful transport boundary.
tests/copilot_app_rows.test.mjs — an error without a request_id answers the pending request Uncorrelated format-error handling WS component keep Covers a separate protocol branch.
tests/copilot_app_rows.test.mjs — the sync retries while the app applies another change Busy-response retry WS component keep Checks bounded recovery.
tests/copilot_app_rows.test.mjs — failures are logged, never thrown, and the next run retries API refusal/disconnect containment and retry WS component keep Add a persisted final upsert whose acknowledgement is dropped.
tests/copilot_app_rows.test.mjs — a closed app or a stale token is not synced Missing endpoint, rejected handshake, and connection refusal WS component + filesystem keep Covers connection-establishment failures.
tests/copilot_app_rows.test.mjs — no app rows in the config means nothing to sync Missing/empty optional configuration WS component keep Protects the optional-module boundary.

Missing coverage and verification

The existing scenarios do not protect the demonstrated foreign-marketplace install overwrite, legacy deferred removal, cancellation race, live-lock takeover, or lost-acknowledgement restart failure. Add filesystem regressions beside TestSettings and TestEarlierIds; extend the existing removal/row component scenarios for the asynchronous failures. These do not need native E2E tests.

After fixes, run:

  • uv run pytest tests/test_copilot_app_plugin.py on Linux and Windows.
  • node --test tests/copilot_app_plugin.test.mjs tests/copilot_app_remove.test.mjs tests/copilot_app_restart.test.mjs tests/copilot_app_rows.test.mjs in an approved isolated environment.

Once the stack is wired, verify readable model-picker entries, a completed Databricks response with correlated request/response evidence, idle-only restart, and removal/reinstall without changing a foreign marketplace. Header assertions alone do not establish downstream usage attribution.

Scope

All changed files support the stated Copilot plugin outcome, including its tests and CI wiring. No clearly unrelated changes were found. Missing CLI integration is consistent with this being the first module in a stack; the truncated description does not justify treating later integration work as a scope violation.


Automated review by Polly · workflow run

Copilot AI balanced review requested due to automatic review settings November 20, 2026 12:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

xi-db and others added 2 commits November 20, 2026 13:04
write_plugin used to write the marketplace, manifests, extension files
and config.json one by one in place, so an app reading the plugin
during configure, or a failed copy during a reinstall, could see a half
written plugin. It now writes the whole tree to a sibling staging
directory, syncs the files, and swaps it in by renames: the old tree
moves aside first, as Windows can't rename onto a directory, and comes
back if the swap fails. The extension's sync stamp, restart marker and
log, ug's created-settings marker and an earlier build's copy are
carried over. Settings keys are merged only after the swap, and
leftovers from a crashed run are removed after ten minutes.

Co-authored-by: Isaac <no-reply@databricks.com>
…oval

Before ug deletes its rows from a running app, it will mark the plugin
for removal, the flag the deferred removal already uses. Under the sync
lock, an extension now reads that flag from its config.json before the
sync and before every write, and stops instead of writing ug's rows back.
The plugin module also gets sync_lock(), which takes the extensions' lock
file under the same protocol (an owner-named file, an atomic stale
takeover), so ug can hold it while it unregisters.

Co-authored-by: Isaac <no-reply@databricks.com>
Copilot AI balanced review requested due to automatic review settings November 20, 2026 13:20

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

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

Labels

ug-review Run the automated UG review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants