Skip to content

fix(server): J5 state and home variable never collide with upstream T3 - #71

Merged
Jacksondr5 merged 2 commits into
j5/mainfrom
j5/issue-68
Sep 4, 2026
Merged

Jacksondr5 merged 2 commits into
j5/mainfrom
j5/issue-68

Conversation

@Jacksondr5

Copy link
Copy Markdown
Owner

Problem

An installed upstream T3 Code and J5 Code could still meet on disk. A linked worktree's dev state lived in <worktree>/.t3, and every base-directory read honored T3CODE_HOME: server config, pair, the dev runner's child export, desktop startup, the service launcher, and the generated systemd unit. A machine that sets T3CODE_HOME for upstream's own service silently pointed a J5 server at upstream's state. Jackson's ruling (2026-09-02): J5 Code must never share on-disk locations or environment names with an installed upstream T3 Code.

Fix

  • Worktree state directory is <worktree>/.j5code (shared devHome helper, dev runner, pair), same precedence as before: --home-dir > worktree dir > ambient variable.
  • The base-directory variable is J5CODE_HOME everywhere it is read or written: server CLI config, pair, dev runner child export, service launcher, systemd unit renderer, desktop DesktopConfig (the primary desktop read), the desktop early-startup read, the dev Electron launcher forward, and the WSL strip. No compatibility shim and no fallback read of T3CODE_HOME; an ambient T3CODE_HOME is ignored entirely.
  • .gitignore and the vitest exclude add a .j5code line beside upstream's .t3 line (add-beside; the state dir holds agent worktree checkouts with their own test files).
  • Telemetry: comment correction only. The anonymous id already lived at <stateDir>/anonymous-id under the J5 base dir.
  • Tests: the retained "uses ~/.j5code for a bare server without touching ~/.t3" guard gains its twin, "ignores an ambient T3CODE_HOME so an installed T3 Code never leaks in" (set on both process.env and the config provider). The systemd renderer test asserts Environment=J5CODE_HOME= and the absence of T3CODE_HOME. Desktop and dev-runner fixtures key on the new name.
  • Docs: docs/j5/dogfood-runtime.md unit and pair command, BRANDING.md bullet on the base-directory override.
  • FORK.md: new integration case 24 (all anchors and proofs of record); case 15's two now-false phrases corrected. Upstream prose that still names .t3 or T3CODE_HOME (AGENTS.md, .agents/skills/*, docs/internals, docs/operations, .cursor) is untouched by the J5 docs rule and logged on the friction list. The ~30 cosmetic T3CODE_* settings are deferred to the naming audit.

Live proof

Before (j5/main, from the worktree, no server running): pair probed the ambient upstream home.

$ T3CODE_HOME=/tmp/upstream-t3-throwaway node apps/server/src/bin.ts pair
NoRunningServerError: No running T3 Code server found.
  checked /Users/jackson/repos/jacksondr5/j5code-worktrees/issue-68/.t3/userdata/server-runtime.json
  checked /Users/jackson/repos/jacksondr5/j5code-worktrees/issue-68/.t3/dev/server-runtime.json
  checked /tmp/upstream-t3-throwaway/userdata/server-runtime.json
  checked /tmp/upstream-t3-throwaway/dev/server-runtime.json

After (this branch): dev server started from the worktree with an ambient T3CODE_HOME pointing at an empty throwaway directory. State landed in <worktree>/.j5code, the throwaway stayed empty, and pair resolved the same home and paired with the worktree server on its own port.

$ T3CODE_HOME=/tmp/upstream-t3-throwaway node scripts/dev-runner.ts dev:server   # from the worktree
[02:23:14.036] INFO (#1): [dev-runner] mode=dev:server source=worktree /Users/jackson/repos/jacksondr5/j5code-worktrees/issue-68 serverPort=15484 webPort=7444 baseDir=/Users/jackson/repos/jacksondr5/j5code-worktrees/issue-68/.j5code
[02:23:17.864] INFO (#2138): Listening on http://127.0.0.1:15484

$ ls -a <worktree> | grep -E "^\.(t3|j5code)$"
.j5code
$ ls <worktree>/.j5code/userdata
attachments
environment-id
keybindings.json
logs
secrets
server-runtime.json
state.sqlite
state.sqlite-shm
state.sqlite-wal
$ ls -A /tmp/upstream-t3-throwaway | wc -l
0

$ T3CODE_HOME=/tmp/upstream-t3-throwaway node apps/server/src/bin.ts pair   # from the worktree
Pairing with personal-macbook (http://127.0.0.1:15484).
Pairing URL: http://localhost:7444/pair#token=<redacted>
Expires: 2026-09-02T06:28:40.543Z

--- stopping tracked pid 37530 ---
pid 37530 exited

Verification

  • vp test run on devHome.test.ts, dev-runner.test.ts, config.test.ts, pair.test.ts, bootService.test.ts: 5 files, 107 tests passed.
  • vp test run on the 13 touched desktop test files: 145 tests passed.
  • vp run --filter t3 typecheck, --filter @t3tools/shared typecheck, --filter @t3tools/desktop typecheck: exit 0.
  • vp fmt applied; lockfile unchanged.

Built by Claude Fable 5.1 running as a J5 Code lane inside Claude Code.

Closes #68

@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 0c6e47d8-3679-4d0e-ba42-69dc3067e16b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 effective changed lines (test files excluded in mixed PRs). labels Sep 2, 2026
@Jacksondr5

Copy link
Copy Markdown
Owner Author

CodeRabbit CLI review

Run 1 (coderabbit review --committed --base j5/main --agent, at head 4b2508ada) emitted one finding and then died on the CodeRabbit side with Connection failed: WebSocket closed; coderabbit review findings afterwards reported no stored findings, so that run never completed. Run 2 (same command, at head 7442b3d7c) completed: review_completed, 0 findings, 35 files reviewed. One completed review per PR.

Finding from the dropped run, refuted

scripts/dev-runner.ts:863 — the --home-dir description says "Explicit T3 Code data directory" and CodeRabbit proposed "J5 Code".

Refuted as out of scope. That phrase is the product name in help copy, not a path or a variable, so it cannot collide with an installed T3 Code. It is the same class as the ~30 cosmetic T3CODE_* settings this PR deliberately defers to the naming audit, and the identical phrase in apps/server/src/cli/config.ts:35 was likewise left alone. This is distinct from the migrate-dev-db correction in 7442b3d7c: that help text made a path claim (<worktree>/.t3 as the default) which this change made false, whereas this one only names the product.

Jacksondr5 and others added 2 commits September 3, 2026 22:07
An installed upstream T3 Code and J5 Code could still meet on disk: a linked
worktree's dev state lived in `<worktree>/.t3`, and every base-directory read
(server config, pair, dev runner, desktop startup, service launcher, generated
systemd unit) honored `T3CODE_HOME`, so a machine that sets that variable for
upstream silently pointed a J5 server at upstream's state.

The worktree state directory is now `<worktree>/.j5code` and the variable is
`J5CODE_HOME` everywhere it is read or written, with no fallback read of
`T3CODE_HOME`. Precedence is unchanged. `.gitignore` and the vitest exclude
add a `.j5code` line beside upstream's `.t3` line. The telemetry comment is
corrected; the anonymous id already lived under the J5 base dir. The
retained "never touches ~/.t3" config test gains its twin: an ambient
`T3CODE_HOME` does not influence J5's base dir. Recorded as FORK.md case 24.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The script already followed the shared worktree-home helper, so its behavior
moved with it, but its header, not-in-worktree message, and --base-dir flag
descriptions still said the default was <worktree>/.t3. Comment and help-text
change only; the ~/.t3 source and protection paths are untouched.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@Jacksondr5
Jacksondr5 merged commit 54ea86e into j5/main Sep 4, 2026
15 of 16 checks passed
@Jacksondr5
Jacksondr5 deleted the j5/issue-68 branch September 4, 2026 02:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 effective changed lines (test files excluded in mixed PRs). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Finish separating J5 from upstream T3 on disk: worktree .t3 → .j5code, T3CODE_HOME → J5CODE_HOME

1 participant