Skip to content

fix(tokenless): preserve foreign QwenPaw plugins - #10931

Open
Jay1023CN wants to merge 1 commit into
agentic-os-org:mainfrom
Jay1023CN:fix/tokenless/qwenpaw-plugin-ownership
Open

Jay1023CN wants to merge 1 commit into
agentic-os-org:mainfrom
Jay1023CN:fix/tokenless/qwenpaw-plugin-ownership

Conversation

@Jay1023CN

@Jay1023CN Jay1023CN commented Nov 29, 2026 •

Copy link
Copy Markdown

Why

The receipt-driven Tokenless uninstaller runs QwenPaw's adapter uninstall
hook even if that installation never enabled QwenPaw. The hook used to
treat the directory plugins/tokenless as proof that it owned the bundle.
A same-name plugin with its own manifest and user-created files could be
deleted while the uninstaller reported success.

What changed

Check the installed manifest before touching a QwenPaw registration.
Recognize older ANOLISA bundles by their stable manifest fields and unlink
verified ANOLISA registrations directly when they are symlinks. If the CLI
removes the manifest but leaves files behind, clear them only in the
verified directory. Report an error if the manifest survives or the
directory was replaced.

Related Issue

Closes #10929

User / Agent impact

Tokenless uninstall preserves a same-name QwenPaw plugin from another
author. If the adapter cannot verify ownership, the uninstaller reports
the cause and retains the adapter files and receipt for a retry.

Risk and compatibility

  • Public CLI, API, configuration, or documented behavior changed
  • Privileged or security-sensitive behavior changed
  • Cross-component contract changed
  • Migration or rollback guidance is needed

The manual fallback removes a verified ANOLISA bundle when the QwenPaw
CLI is unavailable. Ownership verification uses QWENPAW_PYTHON, the
CLI interpreter, or the system python3.

Validation

Linux x86_64. The initial ownership regressions failed on main
(9a99f8782e56). Nine new checks failed on the first PR revision
(40134e50a69e). The current QwenPaw suite passes all 64 checks.

Four temporary-profile checks exercised the receipt-driven uninstaller.
They verified preservation of a foreign plugin, removal of an ANOLISA
symlink before deleting its target, cleanup when a stub CLI leaves
cache files, and a successful retry after repairing a malformed manifest.
The symlink and cache cases failed on the first PR revision.

make test-adapters, including the Tokenless CLI build and npm package
validation, and make test-install-methods both passed.

Documentation and rollback

The English and Chinese framework integration guides explain the QwenPaw
uninstall check. Reverting the change needs no state migration.

@github-actions github-actions Bot added component:tokenless src/tokenless/ scope:documentation ./docs/|./*.md|./NOTICE labels Nov 29, 2026
@Jay1023CN
Jay1023CN marked this pull request as ready for review November 29, 2026 05:22

@Forrest-ly Forrest-ly left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Overall

The direction is right. plugins/tokenless merely existing was never proof of ownership, and reading the installed manifest before touching it is the correct fix for #10929. The identity fields, the fail-closed default, and the quoting are all sound, and the suite passes here (54 passed, 0 failed).

Two of the new paths leave the component uninstaller worse off than main, though: a symlinked plugin directory now reports success while the registration survives, and a CLI that removes the manifest but leaves any other file behind now wedges the uninstall for good. Both are reproducible against main with the existing harness, so both are listed as blocking.

Verdict

Request changes.

Details

🔴 Must fix (blocking)

1. src/tokenless/adapters/tokenless/qwenpaw/scripts/uninstall.sh:31-34 — a symlinked plugin directory exits 0 while the registration survives

if [ -L "$PLUGIN_DST" ]; then
    echo "[${COMPONENT}] Leaving unmanaged plugin symlink in place: $PLUGIN_DST"
    exit 0
fi

This hook does not run standalone. src/tokenless/scripts/uninstall.sh:168-172 states the contract it runs under — "Frameworks register the adapter tree by reference — plugin directories, hook entries and symlinks that point into it" — and deregister_framework_adapters (src/tokenless/scripts/uninstall.sh:198-204) reads exit 0 as "deregistered", after which src/tokenless/scripts/uninstall.sh:562-563 runs rm -rf "$ADAPTERS_DIR". So a link we own (~/.qwenpaw/plugins/tokenless → <adapters>/tokenless/qwenpaw, which is how a local-source install or a plugin developer's setup registers it) is reported as removed and the tree it points into is then deleted, leaving QwenPaw holding a dangling tokenless registration. That is precisely what the surrounding comments and src/tokenless/tests/test-install-docs.sh:599-614 exist to prevent.

main did not have this hole. Verified side by side, same symlink, no CLI:

link afterwards exit
main removed (target preserved — rm does not follow a symlink's final component) 0 = genuinely deregistered
this branch still there 0 = claims deregistered

Repro, in the style of the existing harness:

mkdir -p "$FAKE_HOME/.qwenpaw/plugins"
ln -s "$ADAPTER_DIR/qwenpaw" "$FAKE_HOME/.qwenpaw/plugins/tokenless"
run env QWENPAW_BIN="$SANDBOX/missing-qwenpaw" bash "$UNINSTALL_SH"   # exit 0
[ -L "$FAKE_HOME/.qwenpaw/plugins/tokenless" ]                        # still true

Suggested fix — put the link through the same ownership check instead of assuming it is somebody else's:

if [ -L "$PLUGIN_DST" ]; then
    # A link is a registration like any other. Verify it, then drop the link
    # itself; never rm -rf through it, that would delete the target.
    #   manifest verifies as ours -> rm -- "$PLUGIN_DST"   (link only)
    #   manifest says other author -> keep it, exit 0
    #   manifest unverifiable      -> stderr + exit 1
fi

The ordering is the point: resolve and verify first, and only exit 0 on a link whose manifest says it belongs to another author. The Python block below already reads $PLUGIN_DST/plugin.json, which resolves through the link, so it can be reused as-is — hoist it above this branch rather than duplicating it.

2. src/tokenless/adapters/tokenless/qwenpaw/scripts/uninstall.sh:92-99 — a CLI that leaves any non-manifest file behind now fails permanently

The post-check widened from [ -f "$PLUGIN_DST/plugin.json" ] to [ -e "$PLUGIN_DST" ] || [ -L "$PLUGIN_DST" ], which is good and matches openclaw/scripts/uninstall.sh:52-58. But the trailing rm -rf "$PLUGIN_DST" was dropped from the CLI branch at the same time, and a hot-loaded Python plugin realistically leaves __pycache__ behind. With a stub CLI that removes plugin.json and leaves __pycache__/:

[tokenless] qwenpaw plugin uninstall did not remove ~/.qwenpaw/plugins/tokenless; ... Restart QwenPaw and run this script again.
exit=1

Every re-run then fails earlier and differently, because the CLI already deleted plugin.json:

[tokenless] Cannot verify plugin ownership from ~/.qwenpaw/plugins/tokenless/plugin.json. Leaving ~/.qwenpaw/plugins/tokenless in place.
exit=1

So neither remedy can ever succeed — not "Restart QwenPaw and run this script again", and not src/tokenless/scripts/uninstall.sh:201-202's "remove its registration manually: bash <script>". The component uninstaller stays at ADAPTERS_KEPT=1 and keeps the whole adapter tree until somebody deletes the directory by hand. On main the same scenario exits 0 and sweeps the leftovers clean (verified).

Suggested fix: keep the strict post-check, but separate "still registered" from "unregistered with leftovers". Once $PLUGIN_DST/plugin.json is gone the registration is gone — that is the fact the check is really about — so sweep the rest and say so:

if [ -f "$PLUGIN_DST/plugin.json" ]; then
    echo "[${COMPONENT}] qwenpaw plugin uninstall did not remove $PLUGIN_DST; a running QwenPaw may still have the plugin loaded. Restart QwenPaw and run this script again." >&2
    exit 1
fi
if [ -e "$PLUGIN_DST" ] || [ -L "$PLUGIN_DST" ]; then
    echo "[${COMPONENT}] qwenpaw unregistered ${PLUGIN_ID} but left files behind; removing $PLUGIN_DST" >&2
    rm -rf -- "$PLUGIN_DST"
fi

Ownership was already proven before the CLI was called, so this sweep cannot reach a foreign plugin. If you would rather keep failing hard here, make the message actionable the way OpenClaw does ("remove the paths above and run this script again") — as written it recommends a re-run that is a guaranteed no-op.

🟡 Recommended

3. uninstall.sh:47,69 — a missing interpreter is reported as a bad manifest. ${QWENPAW_PYTHON:-python3} is used with no command -v precheck, so on a host without python3 the user gets a raw line 68: python3: No such file or directory followed by Cannot verify plugin ownership from <a perfectly valid manifest> (reproduced). Two sibling adapters already handle this: qoder/scripts/uninstall.sh:63-66 fails with a dedicated message, hermes/scripts/uninstall.sh:55-58 degrades to unknown. There is also an asymmetry with the installer: install.sh:37-47 resolves the interpreter as QWENPAW_PYTHON → shebang of $QWENPAW_BIN → command -v, while uninstall tries only QWENPAW_PYTHON → python3. A QwenPaw that ships its own interpreter on a host with no system python3 therefore installs fine and cannot be uninstalled. Please reuse the installer's resolution order (a small shared helper would do) and give the "no interpreter" case its own message.

4. uninstall.sh:42-46 — fail-closed has no exit and no guidance. A directory with no plugin.json (interrupted copy, a user's own scratch directory) and a plugin.json that is itself a symlink both exit 1 forever; I confirmed both. Blocking is the right default, but the message has to say what to do next, because re-running cannot help: name the actual cause (missing / symlink / unparseable / no interpreter) and finish with an instruction, e.g. "inspect <path>; if it is not an ANOLISA bundle, move it aside and re-run". The new paragraphs in docs/user-guide/{en,zh}/tokenless/framework-integration.md describe the preservation behaviour but not that uninstall now exits non-zero — and therefore blocks the whole component uninstaller — in that case. One sentence in each language would save a confusing bug report.

5. The same ownership assumption still stands on the other two hooks (follow-up, not this PR). qwenpaw/scripts/detect.sh:149 treats the existence of $plugin_dst/plugin.json as ours, so a foreign same-name plugin is reported as a stale Tokenless install; and qwenpaw/scripts/install.sh:255 runs plugin install ... --force, which removes the destination directory — so adapter enable still destroys exactly the plugin this PR protects on adapter disable. Worth a follow-up that shares one ownership helper across detect / install / uninstall. (openclaw/scripts/uninstall.sh:36-38 has the same by-name rm -rf.)

6. Two of the new assertions can pass vacuously.

  • src/tokenless/tests/test-qwenpaw-adapter-install.sh:288-289: if the 0.0.0-test stamp constant ever changes, sed 's/0\.0\.0-test/0.0\.0-previous/' silently matches nothing and the case still passes without exercising "older release" at all. Assert the rewrite took effect (grep -q '0.0.0-previous' "$PLUGIN_DST/plugin.json" || fail ...).
  • src/tokenless/tests/test-qwenpaw-adapter-install.sh:290-291: [ ! -d "$PLUGIN_DST" ] is equally true when the preceding install.sh installed nothing. Assert [ -f "$PLUGIN_DST/plugin.json" ] right after the install so the case cannot pass without a removal having happened.
  • Untested paths this PR adds or changes: symlinked $PLUGIN_DST (finding 1), missing plugin.json, symlinked plugin.json, CLI leftovers (finding 2), interpreter unavailable. Each is ~5 lines in the existing style; findings 1 and 2 should land as regressions alongside their fixes.

🟢 Worth keeping

  • Checking id + author + entry.backend against the installed manifest is the right identity, and the "older release" case ties it to plugin.json.in through a real install.sh run — a future template change breaks the suite instead of silently mis-deleting.
  • python3 -I keeps PYTHONPATH / PYTHONSTARTUP / cwd out of the check, paths are passed as argv rather than interpolated into the program text, and the snippet stays compatible with old interpreters (it runs unchanged on Python 3.8).
  • [ -e ] || [ -L ] matches the OpenClaw post-condition idiom and catches a broken symlink that -e alone would miss; rm -rf -- and the quoting throughout are correct for paths containing spaces, which the harness's adapter root proves.
  • En and zh guides updated in the same change, and fail-closed is consistent with the top-level uninstaller's "unproven ownership is not ownership" rule.
  • Validation: bash src/tokenless/tests/test-qwenpaw-adapter-install.sh → 54 passed, 0 failed, reproduced independently.

The QwenPaw adapter uses the installed manifest to distinguish the
ANOLISA bundle from an unrelated plugin named tokenless. This protects
user files when the receipt-driven uninstaller visits the adapter, even
when QwenPaw's own CLI is unavailable. Older ANOLISA bundle versions
remain removable.

Fixes: 098a06d ("feat(tokenless): add QwenPaw plugin adapter")

User-visible changes:
- `anolisa adapter disable tokenless qwenpaw`: preserves same-name
  plugins from other authors and reports unreadable manifests.
- `bash scripts/uninstall.sh`: applies the same check through the
  receipt-driven QwenPaw uninstall hook.

Assisted-by: Codex
Signed-off-by: JAY1023 <jay1023nb666@gmail.com>
@Jay1023CN
Jay1023CN force-pushed the fix/tokenless/qwenpaw-plugin-ownership branch from 40134e5 to 5d31f55 Compare November 29, 2026 05:57

Jay1023CN commented Nov 29, 2026 •

Copy link
Copy Markdown
Author

Thanks for the review. The updated commit is 5d31f55.

  • Fixed (1). The installed manifest is checked for symlinked registrations too. A verified ANOLISA symlink is unlinked directly, preserving the target. Foreign links are preserved, and broken links return an error.
  • Fixed (2). After the CLI removes the manifest, the hook clears leftovers only in the original directory it verified. It reports an error if the manifest remains or the directory was replaced.
  • Fixed (3, 4, 6). The hook checks QWENPAW_PYTHON, the CLI shebang, and the system python3 fallback. It reports specific ownership-check failures with recovery instructions. The English and Chinese guides explain when the component uninstaller keeps the adapter tree, and the older-release regression now verifies the installed manifest and its version before uninstalling.
  • Deferred (5). Ownership checks for install and detect are a separate lifecycle follow-up.

The new checks reproduced nine failures on the previous revision. The updated QwenPaw suite passed all 64 checks. make test-adapters and make test-install-methods also passed.

GitHub Actions is waiting for fork-workflow approval on 5d31f55. @Forrest-ly, please approve the workflow and re-review when you have a chance. CI / Components

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

component:tokenless src/tokenless/ scope:documentation ./docs/|./*.md|./NOTICE

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(tokenless): QwenPaw uninstall removes unowned plugins

2 participants