Repository navigation
feat(serve): add extension management v2 #6638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
doudouOUC
wants to merge
99
commits into
QwenLM:main
from
doudouOUC:codex/workspace-qualified-extensions
Closed
Changes from 89 commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
0a9fcc3
feat(cli): workspace-qualified extensions REST (daemon multi-workspace)
doudouOUC 563a173
qwen: address PR review feedback (#6638)
doudouOUC 59b2f88
qwen: address PR review feedback (#6638)
doudouOUC 9dd2e92
qwen: address PR review feedback (#6638)
doudouOUC d6c3b70
feat(cli): add concurrent extension preparation
doudouOUC f3e76ff
fix(cli): remove redundant extension context build
doudouOUC 40c9118
codex: address PR review feedback (#6638)
doudouOUC d47f4a7
codex: address PR review feedback (#6638)
doudouOUC d2c3e81
fix(cli): address extension review feedback
doudouOUC 4ff8c18
merge: resolve conflicts with origin/main for PR #6638
qwen-code-dev-bot db259e7
fix(extensions): address final review feedback
doudouOUC 8d9db32
fix(extensions): address latest review feedback
doudouOUC c6d4c83
codex: address PR review feedback (#6638)
doudouOUC 3c1cede
fix(core): reject links in npm extension archives
doudouOUC f34fbb8
fix(core): limit npm extension archive downloads
doudouOUC e8e5f84
fix(extensions): address review follow-ups
doudouOUC 113f896
fix(extensions): address latest review feedback
doudouOUC 3067e51
chore: merge main into workspace extension branch
doudouOUC 8e25074
chore: merge latest main into extension branch
doudouOUC 6cff963
fix(extensions): release rejected operation slots
doudouOUC 15004ea
fix(extensions): address operation review feedback
doudouOUC c1cae5e
fix(extensions): align archive handling contracts
doudouOUC 2643a3a
fix(extensions): preserve watcher generation state
doudouOUC 21207cc
docs(extensions): align management contracts
doudouOUC 2904340
fix(sdk): bound extension operation polls
doudouOUC 1e26633
test(core): cover forged prepared commits
doudouOUC 5658cb3
test(core): assert activation generation increment
doudouOUC 44afb9c
fix(extensions): close archive and polling gaps
doudouOUC 1654fa5
fix(cli): retry suppressed extension generations
doudouOUC 96f80ec
test(cli): cover archive URL extension updates
doudouOUC b60129c
fix(sdk): preserve unbounded operation waits
doudouOUC cce3571
fix(core): share npm redirect download deadline
doudouOUC 85387ec
fix(core): preserve extension reload diagnostics
doudouOUC a9aea07
fix(core): preserve installed Claude plugin paths
doudouOUC 25ccbc1
fix(cli): return committed activation state
doudouOUC ab3496f
fix(cli): preserve extension preparation errors
doudouOUC 5f23e58
fix(core): validate extension setting env vars
doudouOUC 59ab121
fix(cli): target extension reconciliation
doudouOUC abde5b4
codex: address PR review feedback (#6638)
doudouOUC b81c7be
codex: address PR review feedback (#6638)
doudouOUC 1e57061
codex: address PR review feedback (#6638)
doudouOUC 83cb011
codex: address PR review feedback (#6638)
doudouOUC 6b61cbb
codex: address PR review feedback (#6638)
doudouOUC f5ee95d
codex: address PR review feedback (#6638)
doudouOUC 9c5bb7c
codex: address PR review feedback (#6638)
doudouOUC 65e50f0
test(cli): cover resultless legacy commit warnings
doudouOUC bee57c8
fix(cli): retain suppressed extension generations
doudouOUC abffbc3
fix(cli): record legacy runtime reconciliation
doudouOUC e7cf348
fix(cli): validate extension clients by runtime
doudouOUC d92f71c
fix(cli): record workspace activation refresh
doudouOUC 85f9c35
test(cli): stop extension reconcilers after cases
doudouOUC 19885ce
fix(cli): resolve global runtimes at reconciliation
doudouOUC 0ed83ab
fix(cli): reconcile newly registered runtimes
doudouOUC adb59a4
fix(cli): prevent overlapping runtime reconciliation
doudouOUC 774975f
fix(cli): dispose late runtime apps during shutdown
doudouOUC cb38bdc
fix(core): keep projection repair best effort
doudouOUC 9183308
fix(core): preserve committed store results
doudouOUC 2566f1f
fix(core): quarantine corrupt store journals
doudouOUC 7a1679d
fix(core): harden npm download redirects
doudouOUC 420a5df
fix(extensions): address review edge cases
doudouOUC 04640a5
merge(serve): reconcile extension_management_v2 with origin/main work…
qwen-code-dev-bot 7f07ad7
chore: merge upstream main into extension management
doudouOUC 60c8596
chore: reconcile concurrent upstream merges
doudouOUC 4f34aa3
fix(extensions): honor cancellation between preparation stages
doudouOUC c0fbc57
fix(extensions): retry prepared cleanup failures
doudouOUC 4ab8a71
test(extensions): cover committed artifact recovery boundary
doudouOUC 8e3f2e8
fix(serve): release extension refresh queue on timeout
doudouOUC 6f38769
codex: address PR review feedback (#6638)
doudouOUC 8249a65
codex: address PR review feedback (#6638)
doudouOUC d557154
codex: address PR review feedback (#6638)
doudouOUC f524413
codex: address PR review feedback (#6638)
doudouOUC ec653f9
fix: address extension review feedback
doudouOUC 9fa98ca
codex: address PR review feedback (#6638)
doudouOUC 2f5e496
codex: address PR review feedback (#6638)
doudouOUC c1c6199
codex: address PR review feedback (#6638)
doudouOUC 4d55a5c
codex: address PR review feedback (#6638)
doudouOUC bd8c4d2
fix(core): reconcile extension store compatibility state
doudouOUC 2c7c08d
fix(core): bound npm redirects and isolate extension tests
doudouOUC 8893d3a
fix(core): make extension uninstall store-authoritative
doudouOUC ea1d112
fix(core): defer prepared extension secret mutations
doudouOUC 4549a39
fix(core): validate staged extensions before commit
doudouOUC 47b575e
fix(core): enforce public extension network policy
doudouOUC 4029e5a
fix(core): handle extension response failures
doudouOUC eaf6e7a
fix(extensions): surface committed refresh warnings
doudouOUC ba9fa61
fix(cli): guard timer unref calls
doudouOUC a81fe71
fix(extensions): release commit lane after durable writes
doudouOUC 5437ecc
test(serve): update mutation callback assertions
doudouOUC bb93910
fix(serve): refresh live extension instructions
doudouOUC 0bf9de6
fix(extensions): address latest review feedback
doudouOUC 7077c24
fix(extensions): address follow-up review findings
doudouOUC b3a8623
fix(extensions): address remaining activation feedback
doudouOUC 31e1b4a
fix(serve): preserve preparation queue status
doudouOUC 20c44fa
fix(extensions): enforce network request deadlines
doudouOUC f1d9ab2
docs(serve): clarify single-workspace capabilities
doudouOUC d8242a7
fix(extensions): guard deferred settings commit
doudouOUC 330d1e6
fix(extensions): cancel archive extraction
doudouOUC e70ab39
fix(extensions): harden refresh recovery
doudouOUC d5ebf30
fix(serve): serialize extension reconciliation
doudouOUC c215581
fix(extensions): address post-commit review feedback
doudouOUC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,186 @@ | ||
| # Extension Management V2 | ||
|
|
||
| ## Status | ||
|
|
||
| This design extends daemon protocol `v1` under the additive | ||
| `extension_management_v2` capability. The already-published | ||
| `workspace_extensions` capability and `/workspace/extensions/*` routes remain | ||
| available as a primary-workspace compatibility adapter. | ||
|
|
||
| ## Resource model | ||
|
|
||
| An installed extension is one user-level artifact in `QWEN_HOME/extensions`. | ||
| Activation is policy, not a second copy of that artifact: | ||
|
|
||
| 1. An exact workspace override (`enabled` or `disabled`). | ||
| 2. An internal exact `inherit` mask created while migrating legacy path rules. | ||
| 3. An ordered V1 path rule. | ||
| 4. The global default. | ||
|
|
||
| Workspace identity uses the daemon's canonical workspace path. A workspace | ||
| route selects an existing runtime by workspace id first and canonical cwd | ||
| second. Reads are allowed for untrusted runtimes; activation changes, refresh, | ||
| and workspace-scoped install require a trusted target. Global mutation uses the | ||
| normal daemon mutation authentication and install consent, not the trust state | ||
| of whichever workspace initiated the request. | ||
|
|
||
| ## Store and transaction boundary | ||
|
|
||
| `ExtensionStore` is the only writer of final extension directories and V2 | ||
| activation state. `ExtensionManager` remains the workspace-facing facade, but | ||
| CLI, TUI, auto-update, daemon, and SDK-backed operations delegate mutations to | ||
| the store. | ||
|
|
||
| The layout is: | ||
|
|
||
| ```text | ||
| ~/.qwen/ | ||
| ├── extensions/ | ||
| └── extension-store/ | ||
| ├── lock | ||
| ├── state.json | ||
| ├── state.previous.json | ||
| ├── staging/ | ||
| ├── rollback/ | ||
| └── transactions/ | ||
| ``` | ||
|
|
||
| The store and artifacts share a filesystem so artifact swaps are directory | ||
| renames. An in-process mutex and a `proper-lockfile` lock serialize commits | ||
| across all V2-aware processes. Every mutation re-reads state while holding the | ||
| lock and increments a monotonic generation, preventing lost updates. | ||
|
|
||
| Install/update preparation happens outside the final artifact directory. The | ||
| commit writes a `prepared` journal, moves the old artifact to rollback, moves | ||
| staging into place, and atomically writes `state.json`. That state rename is the | ||
| commit point. Before it, recovery rolls back; after it, recovery only completes | ||
| projection and cleanup. A committed policy is never rolled back because one | ||
| runtime refresh failed. | ||
|
|
||
| Store files use owner-only permissions and atomic no-follow writes. Extension | ||
| ids, direct-child artifact paths, transaction paths, and names are validated. | ||
| Failures are reported with credential-redacted sources. | ||
|
|
||
| ## V1 migration and downgrade projection | ||
|
|
||
| The first V2-aware process imports ordered rules from | ||
| `extension-enablement.json` without materializing the current set of registered | ||
| workspaces as exact overrides. V2 writes a compatible projection after each | ||
| state commit and stores its hash in `state.json`. | ||
|
|
||
| If hashes differ, modification order decides the recovery direction: an older | ||
| projection is repaired from authoritative V2 state; a projection modified after | ||
| V2 state is treated as a sequential write by a downgraded binary and is | ||
| re-imported with a new generation. Concurrent V1 and V2 writers sharing one | ||
| `QWEN_HOME` are intentionally unsupported. | ||
|
|
||
| Clearing a public workspace override normally deletes the exact record. If an | ||
| older path rule would then change the effective value, the store writes an | ||
| internal `inherit` mask so DELETE still means “inherit the global default.” | ||
|
|
||
| ## Daemon API | ||
|
|
||
| The global surface is: | ||
|
|
||
| ```text | ||
| GET /extensions | ||
| POST /extensions/install | ||
| POST /extensions/check-updates | ||
| POST /extensions/:extensionId/update | ||
| DELETE /extensions/:extensionId | ||
| PUT /extensions/:extensionId/activation | ||
| GET /extensions/operations/:operationId | ||
| ``` | ||
|
|
||
| Install requires explicit consent and initial activation: | ||
|
|
||
| ```ts | ||
| type InitialActivation = | ||
| | { scope: 'user' } | ||
| | { scope: 'workspace'; workspaceId: string }; | ||
| ``` | ||
|
|
||
| The daemon install endpoint accepts Git, GitHub Release, and npm sources. | ||
| Local/link remains a local CLI feature. Update preserves the extension id, | ||
| manifest name, settings, and activation policy. “Already current” is a | ||
| successful `updated: false` result. Uninstall is idempotent and removes both the | ||
| artifact and policy. | ||
|
|
||
| The workspace projection is: | ||
|
|
||
| ```text | ||
| GET /workspaces/:workspace/extensions | ||
| PUT /workspaces/:workspace/extensions/:extensionId/activation | ||
| DELETE /workspaces/:workspace/extensions/:extensionId/activation | ||
| POST /workspaces/:workspace/extensions/refresh | ||
| ``` | ||
|
|
||
| It intentionally has no workspace artifact mutation routes. Projection entries | ||
| include default, exact workspace value, effective value, and source. Desired | ||
| generation and locally applied generation are top-level response fields. | ||
|
|
||
| Potentially slow mutations return `202`, `Location`, and `Retry-After`. The | ||
| operation record is daemon-local memory, retains at most 100 terminal records, | ||
| and can disappear on restart. Catalog/store recovery is authoritative. SDK | ||
| polling timeout stops polling only; it never cancels accepted work. | ||
|
|
||
| The daemon admits at most 10 unfinished extension operations. A daemon-wide | ||
| FIFO preparation queue runs at most two downloads, extractions, conversions, | ||
| or single-extension update checks at once. Install and update use an explicit | ||
| `prepare -> commit/dispose` lifecycle: preparation owns only staging files and | ||
| does not change the store, cache, or runtime. Prepared mutations enter a | ||
| separate single-concurrency FIFO commit queue in the order preparation | ||
| finishes. Activation and uninstall enter only the commit queue; check-updates | ||
| enters only the preparation queue. Manual refresh is serialized through the | ||
| commit queue. The commit lane is released after the store commit and settings | ||
| commit; extension reload, manager runtime refresh, prepared-file cleanup, and | ||
| daemon runtime reconciliation run outside it. These post-commit steps do not | ||
| occupy either slot, so later commits may proceed while an earlier generation is | ||
| being applied or cleaned up. | ||
|
|
||
| The preparation deadline starts when an operation first acquires a preparation | ||
| slot, not while it waits. Abort is propagated to network operations. A started | ||
| task continues to occupy its slot until its underlying promise settles even if | ||
| it ignores abort. Commit is not cancellable. Prepared updates carry the target | ||
| artifact generation: unrelated extension or activation changes safely rebase, | ||
| while a stale update of the same artifact fails with `extension_conflict`. | ||
|
|
||
| ## Runtime reconciliation | ||
|
|
||
| A successful commit invalidates local status and refreshes affected runtimes. | ||
| Global artifact/default changes reconcile all runtimes in this daemon; an exact | ||
| workspace override reconciles only its target. Runtime reconciliation refreshes | ||
| extension and skill caches, extension tools, hierarchical memory, active chat | ||
| system instructions, and available commands. Per-workspace generation | ||
| coalescing means applying generation N also satisfies waiters for older | ||
| generations; a late lower-generation refresh therefore cannot move the applied | ||
| generation backwards. Partial refresh failure or post-commit reload/cleanup | ||
| failure produces `succeeded_with_warnings` with workspace-specific or commit | ||
| diagnostics, without rolling back the artifact. | ||
|
|
||
| The extension file watcher observes only `extension-store/state.json` for | ||
| policy generation and continues to observe installed/linked extension content | ||
| for command, skill, agent, hook, and MCP changes. A 30-second generation poll | ||
| repairs missed filesystem events and bounds convergence for other daemons that | ||
| share the store. | ||
|
|
||
| ## Compatibility | ||
|
|
||
| `workspace_extensions` remains the capability for the existing singular | ||
| surface. Its handlers call the same manager/coordinator and adapt responses: | ||
| project activation becomes a primary workspace override; user activation keeps | ||
| the legacy rule-clearing behavior; global mutation reconciles every local | ||
| runtime. The legacy operation endpoint maps V2 warning completion back to the | ||
| published legacy refresh-error status. | ||
|
|
||
| Clients must check `extension_management_v2`; neither daemon mode nor another | ||
| workspace capability implies this API. The abandoned | ||
| `workspace_qualified_extensions` proposal is not part of the protocol. | ||
|
|
||
| ## Non-goals | ||
|
|
||
| - Per-workspace artifact copies. | ||
| - A daemon registry or remote acknowledgement protocol. | ||
| - User cancellation of accepted operations. | ||
| - Concurrent old-binary and V2-aware writes to one `QWEN_HOME`. | ||
| - Removing the V1 adapter before a future protocol-v2 migration. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.