Auto-resolve a runtime-category farm collision instead of asking - #18
Merged
Merged
Conversation
cli.ts, check.ts, and configure.ts each independently read
categories.default.json, parsed it against CategoryClassificationSchema,
read categories.local.json, and merged the two into the same
{ defaults, overlay? } shape — three copies of a validation step that
never varies between them, so a fourth call site (added next) would
have made it four.
loadClassification centralises this in config/classify.ts, next to the
classification domain logic it feeds, rather than as a generic
config/store.ts helper: everywhere else classification is used already
imports from this file. Each of the three sites drops its own
categories.default.json import, CategoryClassificationSchema/
CategoryClassificationOverlaySchema imports, and (where nothing else in
the file needed it) its own readJson import.
Every retained superseded farm found on a real, long-lived install collided on the same handful of names: .last-update-result.json, mcp-needs-auth-cache.json, .last-cleanup, cache, shell-snapshots. Every one of them classifies as runtime, whose own definition (see the README category table) is specifically live per-process or per-machine artifacts a swap has no business fighting over. Leaving them for `identity resolve` to ask about, one login at a time, turned a single crashed launch into a standing manual chore. carryOver now classifies a colliding name before reporting it. A runtime-category collision discards the old copy and keeps whatever the current farm already has, with no data moved and no callback invoked — this needs only the name's static classification, never the resolved shared/not-shared decision for the directory, since a runtime entry is disposable whether or not this identity currently chooses to share it. Every other category is unaffected: a genuine collision (settings, knowledge, history, an unclassified name) still retains the superseded farm and still asks. Threaded through both places a collision can surface. The automatic crash-recovery path (recoverFarm, called before identity.json is even read) gets classification from FarmRuntime, which is identity-independent and already available at that point. The interactive `identity resolve` command loads it the same way every other command now does. recoveryDiagnostics and identity resolve's own console output both name what was auto-resolved, distinctly from what still needs `identity resolve`, so the behaviour stays visible rather than silent.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Every retained superseded farm on a real, long-lived install (this session found 24 of them across 4 identities) collided on the same handful of names:
.last-update-result.json,mcp-needs-auth-cache.json,.last-cleanup,cache,shell-snapshots. Every one of those classifies asruntime, whose own definition (the README category table) is specifically live per-process or per-machine artifacts a swap has no business fighting over. Leaving them foridentity resolveto ask about turned a single crashed launch into a standing manual chore that had to be run identity by identity.carryOvernow classifies a colliding name before reporting it. Aruntime-category collision discards the old copy and keeps whatever the current farm already has — no data moved, no prompt. This only needs the name's static classification, never the resolved shared/not-shared decision for the directory, since aruntimeentry is disposable whether or not this identity currently chooses to share it. Every other category is unaffected: a genuine collision (settings, knowledge, history, an unclassified name) still retains the superseded farm and still asks, exactly as before.Threaded through both places a collision can surface — the automatic crash-recovery path that runs on every launch (
recoverFarm, which runs beforeidentity.jsonis even read; it gets classification fromFarmRuntime, which is identity-independent and already available at that point), and the interactiveidentity resolvecommand. Both report what was auto-resolved, distinctly from anything still needing a human decision.Also extracted
loadClassification(config/classify.ts) sincecli.ts,check.ts, andconfigure.tswere each independently repeating the identical read-defaults-plus-overlay block — a fourth copy foridentity resolvewould have made it four.Ran the built CLI against this machine's own real
~/.claude-use(24 retained farms, 4 identities) as an end-to-end check before opening this: every one auto-resolved with no prompt, all named.last-update-result.json/mcp-needs-auth-cache.json/.last-cleanup/cache/shell-snapshots,doctorstill reports every identity healthy afterward.