Skip to content

CLI constructs SubcModuleTransport without subc.connection_file — strands doctor drain-authority, the escape hatch out of rust mode #443

Description

@iceteaSA

Summary

#376 threaded the configured subc.connection_file into SubcModuleTransport at the three plugin call sites. Three CLI call sites were missed and still construct it with no argument, so they silently fall back to getDefaultConnectionFile():

packages/cli/src/commands/doctor-authority.ts:138   const transport = new SubcModuleTransport();
packages/cli/src/commands/doctor-authority.ts:188   authorityClient(new SubcModuleTransport(), projectRoot)
packages/cli/src/commands/migrate-session.ts:652    const transport = new SubcModuleTransport();

versus the fixed plugin sites:

packages/plugin/src/hooks/magic-context/hook.ts:815  new SubcModuleTransport(deps.config.subc?.connection_file)
packages/plugin/src/index.ts:283                     new SubcModuleTransport(pluginConfig.subc?.connection_file)
packages/plugin/src/index.ts:289                     new SubcModuleTransport(pluginConfig.subc?.connection_file)

doctor-opencode.ts:534 and doctor-pi.ts:785 both read loaded.subc.connection_file correctly, so the CLI already knows how to do this — doctor-authority.ts just doesn't.

All refs against dc952bf3.

Why this one is worse than #375

doctor drain-authority is the designated recovery path out of rust mode. It is what the codebase itself tells you to run: context-authority.ts emits magic-context doctor drain-authority <root>, and migrate.test.ts:540 asserts that guidance. When the daemon publishes its connection file anywhere other than the default, the command fails:

$ bun packages/cli/src/index.ts doctor drain-authority /path/to/project
Module unreachable — writes fenced; run with rust mode or restore subc connectivity:
ENOENT: no such file or directory, stat '~/.local/share/cortexkit/run/subc-connection.json'

The message says "restore subc connectivity", but subc is perfectly reachable — the plugin is talking to it on the configured path at that very moment. So the failure is self-describing in a misleading direction: it blames the daemon for a path the CLI chose to ignore.

The practical shape: you flip to rust mode, hit a problem, go to drain back out, and the escape hatch refuses. The workaround is a symlink into the default location:

mkdir -p ~/.local/share/cortexkit/run
ln -sfn /run/user/1000/subc-connection.json ~/.local/share/cortexkit/run/subc-connection.json

After which the exact same command succeeds:

Authority drained back to TypeScript for git:93eea8cd….

The symlink resolves fine through the client's owner-only check, which confirms the path is the only problem.

Suggested fix

Same shape as #376 — load the config and pass it through, as the sibling doctor commands already do. doctor-authority.ts takes a project root, so loadPluginConfig(projectRoot) is available on both paths. migrate-session.ts:652 is the same one-line change.

Worth considering whether the no-arg constructor should stay available at all, or whether the default should be reserved for a single explicit accessor — three call sites drifted to it across two packages, and the failure mode is silent until the environment differs from the default.

Adjacent: shipped CLI dist is stale

Unrelated to the above but hit in the same session — the published packages/cli/dist/index.js refuses current databases:

Refusing to open …/context.db: database schema v10100 is newer than this CLI supports (max v73).

v73 is many releases back. Running the CLI from source works. Might be a release-pipeline gap rather than a code issue, but since doctor is the thing you reach for when something is wrong, a stale dist blocks diagnosis at the worst moment.

Environment

Fork on upstream dc952bf3 (v0.42.3), daemon ck 0.17.39, ck-mc built at matching generation. All four files cited are byte-identical to upstream at that sha, so the line numbers hold. Daemon publishes to /run/user/1000/subc-connection.json; user config sets subc.connection_file to exactly that, and the plugin honors it (verified: transform lane serving at 28–33ms over that path while the CLI could not find it).

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions