Repository navigation
feat(nix): run the T3 server on mbp as a launchd agent - #490
Conversation
Add the enableT3Service host flag, a home-manager launchd agent that runs the Nix t3 on loopback port 3774 with the existing ~/.t3 state, pmset -c sleep 0 on the flagged host, contract checks, and ADR-0045. Refs #489 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
|
@codex review |
Codex Review Summary: ✅ CompletedThis 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. |
Review summaryI reviewed the launchd What I checked:
Things to know, not defects:
|
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
agent-config を 0.5.1 に上げる.T3 で lane を回す手順の修正(待ち方,transport の優先順位,Start 前の branch 確認)と ADR-0028 の accepted が入る. | 入力 | 変更前 | 変更後 | | --- | --- | --- | | `agent-config` | `7e350e03`(v0.5.0) | `7f39859b`(v0.5.1) | - [ ] CI - [ ] 反映後,`delegation` skill の `references/t3.md` が新しい Wait 手順(`show` の polling,`latestRunId` の確認)になっている <details> <summary>内容と出典</summary> - furedea/agent-config#272:利用者が明示した transport を T3 より先に見る,Start 前に branch の有無を確かめる,失敗の原因は `server.trace.ndjson` で調べる - furedea/agent-config#273:Wait 手順の修正(承認待ちは `pendingRequestCount`,終了は `status`,Prompt 後は `latestRunId` の変化を待つ),ADR-0028 を accepted - 変更は `flake.lock` のみ.agent-harness は `follows` で変わらない - 反映は #490(T3 server の常駐)と同じ `darwin-rebuild switch` で行う.その前に mbp の desktop app で Local environment をオフにする(#489 の plan 手順 3) </details> 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
実機確認(2026-11-22)と追加確認の結果を ADR-0045 に記録し,status を `accepted` にする.決定内容は変えない. | 項目 | 変更前 | 変更後 | | --- | --- | --- | | status | `proposed` | `accepted` | | iOS の切断リスク | Safari を fallback とし,実機確認まで `proposed` | 報告(pingdotgg/t3code#25405,#24909)は残し,実機確認では起きず iPhone app が数分接続を保ったと記録 | | pairing 手順 | 記述なし | リポジトリ外の手順を Bad として追記 | | iOS の通知 | 記述なし | T3 account が必要で未使用のため iPhone は通知なし | - [x] `dprint check`:問題なし - [x] `autocorrect --lint`:問題なし - [x] 追加した行は 100 桁以内(29 行目の既存 101 桁は Decision Outcome のため変更しない) - [x] CI:`all-green` を含む全 check が pass,claude-review と codex-review は指摘なし <details> <summary>根拠と範囲</summary> - 根拠:PR #490 適用後の実機確認.mbp desktop を終了してもテスト thread が `completed` まで動き続けた.mbp desktop,mba desktop,iPhone app の 3 client を pairing 済み.mba desktop と iPhone app から approval に答えると thread が続いた.iPhone app は Tailscale 経由で数分接続を保った - pairing で必要だった手順:`tailscale serve --bg --https=8443 http://127.0.0.1:3774` を手動実行,tailnet ACL で `tcp:8443` を許可,token は一度きりで 5 分で失効,pairing URL と QR は `~/.t3/userdata/logs/launchd-server.log` に出る,Local environment を切ると古い "T3 Code Desktop" client が残る - 範囲外:Nix コード,plan comment,T3 の設定(#489 step 5),Moshi - plan:#489 (comment) - 計画からの逸脱:なし </details> Refs #489 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
概要
t3 serve --no-browser,127.0.0.1:3774,state は既存の~/.t3).Refs #489(plan:https://github.com/furedea/dotfiles/issues/489#issuecomment-7066118534)
flowchart LR MBPd["mbp:desktop app(Local env オフ)"] -->|loopback + pairing| T3 MBA["mba:desktop app"] -->|tailnet HTTPS 8443| TS["Tailscale Serve(mbp)"] Phone["iPhone"] -->|tailnet HTTPS 8443| TS TS --> T3["T3 server(launchd,127.0.0.1:3774,~/.t3)"]利用者の切り替え手順(plan の step 3)
darwin-rebuild switch(常駐 server が起動)t3 pair --tailscale --tailscale-serve-port 8443 --label <端末>で mbp の desktop app,mba の desktop app(Add environment),iPhone をつなぐserver の port は 3774 です(desktop 自身の 3773 と別).ログは
~/.t3/userdata/logs/launchd-server.log.変更
hosts.<host>.enableT3Servicetrue,mbafalset3-server(RunAtLoad,KeepAlive,ThrottleInterval = 60)pmset -c sleep 0(battery は変更なし.enableT3Serviceの host だけ)proposed.実機確認まで)t3(t3codePackage.署名済み Codex 入り)を実行し,env はHOME,PATH,T3CODE_HOME=~/.t3,T3CODE_HOST=127.0.0.1,T3CODE_PORT=3774だけ.credential は plist にも Nix store にも置かない.PATHは Nix の profile(/etc/profiles/per-user/kaito/bin,/run/current-system/sw/bin),provider の store path(t3codePackage.providerPackages),/usr/local/bin(Tailscale app の CLI wrapper),システムの標準 path.t3LogDirectory)で作る(launchd は親 directory を作らないため).再起動の設計
KeepAlive = trueとThrottleInterval = 60の組み合わせにした.~/.t3を握っている)で終わっても再試行は 1 分に 1 回で,desktop 側をオフにすれば自動で復帰する.KeepAlive = { SuccessfulExit = false }は exit 78 も異常終了なので連打対策にならず,正常終了(server 自身の再起動など)で戻らなくなるだけなので採らない.Hister(ADR-0018)と同じ 60 秒にそろえた.判断した点(brief との差)
launchd.user.agentsだが,t3codePackageはnix/home/default.nixにあるので,moshi と同じ home-manager のlaunchd.agentsに置いた(darwin への package 受け渡しを避けるため).standalone-home-services-match-hostが両者の一致を見張る.LimitLoadToSessionType = "Aqua":provider の認証が login Keychain にあるため.pmset -c sleep 0は mba のスリープ設定は変えないのでenableT3Serviceで条件付きにした.検証
nix/checks.nixに先に契約を追加し(agent が無い状態で赤),実装後に緑t3 serve --no-browser,loopback,port 3774,~/.t3,HOME,PATH(profile / provider / tailscale),ログ場所,credential らしい env 名がない,pmsetが mbp だけnix flake check:all checks passed(aarch64-darwin).port を 3773 に変えるとt3-service-own-portが落ちることを確認nixfmt --check,statix,deadnix,dprint,adr-check,lefthook(commit 時)Limits(review で出た注意.修正しない)
pmset -c sleep 0はenableT3Serviceを外しても自動では戻らない(手で sleep を戻す).launchd-server.logに rotation はない.T3CODE_HOSTとT3CODE_PORTをt3 serveが読むことは eval では確認できない(source には存在).実機確認でlsof -iTCP:3774が127.0.0.1だけであることを見る.Review:claude-review,codex-review ともに inline finding なし(thread 0 件).
範囲と前提
tailscaleが見つからず,ログに出る.t3コマンドは--help以外実行していない.darwin-rebuildも未実行(利用者が switch する).🤖 Generated with Claude Code