Skip to content

connectors off: the off file holds server names only - #76

Open
ExJtac wants to merge 2 commits into
mainfrom
fix-connectors-names-only
Open

ExJtac wants to merge 2 commits into
mainfrom
fix-connectors-names-only

Conversation

@ExJtac

@ExJtac ExJtac commented Nov 14, 2026

Copy link
Copy Markdown
Owner

Review item 3, the part still open after #66 (backup and undo were fixed there).

What changes

  • ~/.tokenstretch/connectors-off.json now holds {"off": {"<name>": "<switch that backed it up>"}}. No entry, so no env value, header, URL or argument is ever written to it. Before, the whole entry was moved into this file.
  • connectors on NAME takes the entry from the owner-only (0600) backup of ~/.claude.json made by the switch that turned it off. The reference is a manifest name, checked against a strict pattern, never a path.
  • Backup gone: on says so, changes nothing, and the name stays listed as off.
  • Off files from 0.9.7 or earlier (whole entries under mcpServers) are still read. The next switch rewrites the file with names only; the old file goes into that switch's backup, and undo puts it back exactly.
  • undo of a switch is unchanged, including the key-level undo when ~/.claude.json changed.

Tests

  • 5 new tests, 3 changed, in tests/test_connectors.py: no secret-shaped word in the off file after any switch; exact restore from backup; refusal with backup gone; old-format file read, migrated, and undone; made-up references never read outside the manifests folder.
  • Full suite: 551 passed, 1 skipped.
  • Network denied (sandbox-exec deny network*, -m 'not p00_outer'): 545 passed, 6 skipped (loopback-only tests), 1 deselected.

Not sure about

  • While a connector is off, its entry now lives only in the backup folder. Deleting ~/.tokenstretch/backups/ loses it; before, the off file still had it. Docs and the off message now say to keep that folder. This follows from "names only".
  • The backups still hold whole copies of ~/.claude.json (0600), as since connectors: a switch is backed up and recorded, so undo reverses it #66.
  • The safety scan flags tests/test_connectors.py:201: made-up canary values in the new test, same kind as the canaries in tests/test_bench.py.

🤖 Generated with Claude Code

The off file listed whole entries, which can hold a key in env, headers,
a URL or args. It now lists the names that are off and, for each, which
switch backed the entry up. `on` takes the entry from that owner-only
backup of the user file; if the backup is gone it says so and changes
nothing. An off file from 0.9.7 or earlier is still read and is rewritten
with names only by the next switch (the old file goes into the backup).

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The manifest's name carries the clock's offset from UTC, so it has a "+"
at or east of Greenwich. The check on the name in the off file allowed
"-" only, so `connectors on` found no saved entry there. CI (UTC) caught
it; the tests passed on a machine west of Greenwich.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@ExJtac

ExJtac commented Nov 14, 2026

Copy link
Copy Markdown
Owner Author

CI caught a real bug in the first commit: the backup's name carries the UTC offset, and my check on that name rejected "+", so connectors on found nothing at or east of UTC. Fixed in the second commit, with a test over four offsets. Suite now 555 passed, 1 skipped (also with TZ=UTC and TZ=Asia/Kolkata); network denied 549 passed, 6 skipped, 1 deselected.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant