Skip to content

fix(cli): expand ~ in t3 policy templates --policy - #41438

Merged
juliusmarminge merged 2 commits into
pingdotgg:mainfrom
Marve10s:fix/policy-templates-tilde
Nov 23, 2026
Merged

juliusmarminge merged 2 commits into
pingdotgg:mainfrom
Marve10s:fix/policy-templates-tilde

Conversation

@Marve10s

Copy link
Copy Markdown
Contributor

Problem

t3 policy templates <directory> --policy=~/policy.json fails with No policy file at ~/policy.json., even when ~/policy.json exists. bash and zsh do not expand ~ after the = in --policy=~/…, so the CLI receives the literal ~/policy.json. The same happens with a quoted path or when a script passes the argument without a shell.

Change

The templates handler in apps/server/src/cli/policy.ts expands the path once with expandHomePath from os-jank.ts and uses the result for both the existence check and ManagedPolicy.load. The error message still shows the path as typed, as in #41271.

Scope

This is a small fix for an obvious bug, so it has no issue. It follows #41199 (project add --track), #41271 (thread --output-schema) and #41430 (environment link --from), which fixed the same gap for other flags. It changes only --policy. The positional policy check <file> and templates <directory> arguments are left alone, because the shell already expands an unquoted leading ~ there.

Verification

policy.test.ts had no templates test, so a new case in its it.layer block runs policy templates <home> --policy=~/policy.json through the CLI with HostProcess.HomeDirectory set to a temp dir. It checks that the generated macOS profile carries the policy's organization rather than the sample's.

main:  UserError: No policy file at ~/policy.json.
fix:   Tests  2 passed (2)

From a checkout, with a scratch HOME and ~/policy.json holding {"schemaVersion":1,"organization":"Tilde Corp"}:

node apps/server/src/bin.ts policy templates "$HOME/out" --policy=~/policy.json

Before:

ERROR
  No policy file at ~/policy.json.
exit 1

After (the profile contains Tilde Corp):

$HOME/out/windows/t3code.admx
$HOME/out/windows/en-US/t3code.adml
$HOME/out/macos/t3code.mobileconfig
exit 0

vp run check:changed upstream/main passes.

Claude Fable 5.2 (high, Claude Agent in T3 Code) found the bug. Claude Opus 5.5 (high) and GPT-6.2 Astra (high, Codex) reproduced it independently. Claude Opus 5.5 (Claude Agent in T3 Code) wrote the fix and test. Claude Opus 5.5 (xhigh), GPT-6.2 Sol, GPT-6.2 Astra (high, Codex), and Claude Fable 5.2 reviewed the patch in T3 Code.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T12:41:40.850783Z 3cbc63e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 3cbc63e and a139d32.

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

No actionable comments were generated in the recent review.

Walkthrough

The policy templates command now expands supplied policy paths before checking and loading them. A new CLI test checks template generation when the policy path starts with ~.

Changes: Policy path handling

Layer / File(s) Summary
Expand policy paths and verify template generation
apps/server/src/cli/policy.ts, apps/server/src/cli/policy.test.ts
The command expands the supplied path before checking for and loading the policy file. The missing-file error still uses the original argument. A CLI test checks that --policy=~/policy.json produces a macOS profile containing Tilde Corp.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#29862: Adds the policy templates command whose policy-file input handling this change updates.

Suggested labels: bugfix

Suggested reviewers: macroscopeapp

Merge Risk: Minimal · previous review 3cbc6

The policy templates command now expands a leading ~ in --policy paths, which fixes the case where the shell leaves it unexpanded. The change is narrow, covered by a new test, and has no identified merge-blocking risk.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(cli): expand ~ in t3 policy templates --policy" matches the main change. The PR makes the templates handler in apps/server/src/cli/policy.ts expand a leading ~ in the --policy path with…
Description check Passed The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each one is filled in. The Problem section gives the failing command and the shell behavi…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(cli): expand ~ in t3 policy templates --policy" matches the main change. The PR makes the templates handler in apps/server/src/cli/policy.ts expand a leading ~ in the --policy path with expandHomePath before the existence check and ManagedPolicy.load. It uses a conventional commit format and is concise and specific.

Full details: Description check

Explanation

The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each one is filled in. The Problem section gives the failing command and the shell behavior behind it. The Change section names the handler and helper. The Scope section explains why no issue is linked and says only --policy changes. The Verification section gives a new test, before and after output, and a repo check. The template's optional agent-model line is also filled in. The description does not link an issue, but it gives a reason for that, as the template allows for small obvious fixes.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 27ecc0f and 3cbc63e.

Files selected for processing: 2

  • apps/server/src/cli/policy.test.ts
  • apps/server/src/cli/policy.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
…tilde

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Created identical synthetic ~/policy.json files containing {"schemaVersion":1,"organization":"Tilde Corp"} in isolated homes. Ran t3 policy templates "$HOME/policy-templates-out" '--policy=~/policy.json' using each commit's built CLI on Linux x86_64. Base exited 1 and generated nothing; head exited 0, generated all three templates, and included “Tilde Corp” three times in the macOS profile. The shell-expanded control succeeded on both.

Before After
Before: literal tilde rejected After: templates generated successfully
6ec46a61e6 a139d3203e

Images are rendered CLI transcripts, including exit status and generated-file inspection. Before transcript · After transcript · Driver and seed script (arguments: base checkout, head checkout) · Generated macOS profile.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 23, 2026
@juliusmarminge
juliusmarminge merged commit 5e12857 into pingdotgg:main Nov 23, 2026
55 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants