Skip to content

fix(tokenless): keep PATH after failed removal - #10940

Open
coder999o wants to merge 1 commit into
agentic-os-org:mainfrom
coder999o:dev-26112904
Open

coder999o wants to merge 1 commit into
agentic-os-org:mainfrom
coder999o:dev-26112904

Conversation

@coder999o

Copy link
Copy Markdown

Why

At official main 9a99f8782e56930db2345deef25299c49939d0ab, the receipt-driven Tokenless uninstaller removes the recorded shell PATH block even when npm is missing, refuses removal, or cannot run because a prefix launcher was taken over. The script retains the working CLI and receipt and returns 1, but a fresh shell can no longer find tokenless.

What changed

  • Keep the existing PATH block only when an npm interruption is recorded and the receipt lists a Tokenless launcher that remains a regular executable. Check metadata without invoking the CLI.
  • Continue removing stale PATH entries when the CLI is absent, non-executable, unrecorded, or partially removed, and when only adapter cleanup fails after CLI removal. Preserve the existing terminal ownership policies.
  • Add an isolated standard-library Python suite with both overlapping and separate npm-prefix/install-directory layouts. Run it from make test-install-script and the existing make test-adapters parallel runner used by CI.

Related issue

Closes #10938.

User / Agent impact

bash src/tokenless/scripts/uninstall.sh preserves shell access to the retained CLI after an incomplete npm removal. A successful retry removes the package, launchers, receipt and installer-owned PATH block while preserving unrelated shell settings and runtime data.

This corrects the existing recovery behavior. Command syntax, receipt schema, ownership decisions and incomplete-uninstall exit codes remain unchanged. The change does not recreate a PATH block removed by a previous uninstall attempt.

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 behavior change is limited to PATH retention for the existing npm interruption states. Receipt membership and regular-file/executable checks prevent retaining a stale entry solely because uninstall is incomplete. No dependency, privilege, workflow or receipt-format changes are introduced. Dry-run and purge previews remain read-only.

Validation

Tested revision: 4507595231bbe49c7c35c552aa727f16bbdffc2f (the committed files match the tested file hashes). Independent read-only review found no actionable defects.

Local environment: macOS arm64, Bash 3.2.57 and Python 3.13.0. Fixtures use a temporary HOME, valid schema-3 receipts and isolated npm stubs; no real installation or host npm was changed.

  • Regression proof: the new suite against the unchanged uninstaller fails the six PATH-retention cases. The local Make gate and existing tests/run-parallel.py both propagate that failure.
  • python3 -B src/tokenless/tests/test_uninstall_path.py: passes all 5 test methods / 25 parameterized scenarios, including fresh-shell lookup, successful retries, retained runtime data, no CLI invocation during uninstall, missing/non-executable/unrecorded/directory CLI, partial npm removal, adapter failure, terminal ownership policies, and unchanged dry-run snapshots.
  • python3 tests/run-parallel.py -- 'python3 tests/test_uninstall_path.py' from src/tokenless: passes on the candidate.
  • bash -n src/tokenless/scripts/uninstall.sh, Black 26.3.1 (--check --line-length 88 --target-version py311), git diff --check, and make -C src/tokenless test-install-docs: pass.
  • make -C src/tokenless test-install-script: the new suite passes, then the unchanged shell harness fails its first source-build assertion (expected '0', got '1'). Running the original shell harness before the fix produces the same failure on this macOS host.
  • make -C src/tokenless test-adapters: stops before the parallel runner in the unchanged test-package-npm-prebuilt.sh:187, whose stat -c invocation is incompatible with BSD stat on this host.

Full local acceptance is therefore incomplete. Python 3.11 runtime, Linux execution and GitHub CI results have not been verified locally; the suite is wired into the existing Python 3.11 CI job without changing its workflow.

Documentation and rollback

No command or configuration reference changes are needed for this correction to the existing recovery behavior. Reverting this commit restores the previous cleanup policy; no stored-data migration is required.

The receipt-driven Tokenless uninstaller now keeps its recorded shell
PATH entry when npm removal is interrupted and the recorded CLI is
still a regular executable. A fresh shell can continue using the kept
command until a successful uninstall retry removes the installation.

Check the existing npm retention flags and receipt file list without
executing the payload. Keep clearing stale PATH entries after partial
CLI removal or adapter-only failures. Add isolated public-script tests
to the local install gate and existing adapter CI runner.

User-visible changes:
- `bash src/tokenless/scripts/uninstall.sh`:
  Preserve the recorded PATH entry after an incomplete npm uninstall
  that retains the recorded executable Tokenless CLI. Successful retry
  still removes the entry. Arguments and exit codes are unchanged.

Fixes: 0a6fc32 ("feat(tokenless): add npm, curl, and skill routes")
Assisted-by: Codex
Signed-off-by: coder999o <soft_99@126.com>

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/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Failed npm uninstall removes PATH for the retained CLI

1 participant