Repository navigation
Description
Problem
When pkgs/opencode-config-normalize/normalize.sh does repair opencode.jsonc, its write path discards the file's existing permissions and breaks symlinks: a 0600 config comes back 0644 (umask default), and a symlinked config is replaced by a brand-new regular file at the link path while the link target keeps the unrepaired v2 keys forever.
Evidence (verified this run, main fc88d0a9, script sha256 c59dd79b…)
normalize.sh:126-128: the repaired text is written to a fresh sibling temp file and moved over the config —Nothing copies the original file's mode ontotmp = path.with_suffix(path.suffix + '.normalize-tmp') tmp.write_text(out) tmp.replace(path)
tmp, andPath.replaceon a symlinkedpathreplaces the symlink itself, not its target. Nothing in the script checkspath.is_symlink()orstatmode.- Laptop probe (
~/git/fleet/probe-2026-10-31-laneA-normalize/, verbatim copy of the script, sha-matched to main):- Case B: a
chmod 600config needing repair → repaired correctly, butstatafterwards shows644. - Case C: config as a symlink to
target.jsoncneeding repair → after the run the link path is a regular file (-rw-r--r--, no longer a symlink) holding the repaired content, whiletarget.jsoncstill contains the unrepaired"plugins"key.
- Case B: a
Why it matters
An opencode config can carry provider credentials, so silently widening 0600 → 0644 exposes them to other local users — the same defect filed for the t3code seed write in #3170, in a second script. The symlink half is a correctness break in exactly the setups this fleet uses (dotfiles/home-manager style linked configs): the normalizer reports "repaired", the file the user actually manages through the link target is never repaired, and the link is silently severed so future target updates stop reaching the live config.
Acceptance criteria
- After a repair, the config's permission bits equal those it had before (a
0600fixture stays0600); a test fixture asserts the mode, not just the content. - A symlinked config is repaired through the link (target content updated, symlink intact), or the script refuses with a non-zero exit and leaves both link and target byte-identical — never a silent link sever. The chosen behaviour is covered by a fixture in
normalize_test.sh. - All existing
normalize_test.shcases still pass, including byte-identical-on-failure and idempotence.
Related
- t3code-seed-providers: the seed write does not preserve settings.json's file mode — a 0600 settings file becomes umask-default (0660/0644), and a symlinked settings.json is silently replaced by a regular file #3170 — same mode/symlink defect class in the t3code-seed-providers seed write (different script, different config file); fixing both with one shared pattern would be ideal, but each stands alone.
- opencode-config-normalize: an inline // or /* */ comment anywhere in opencode.jsonc silently disables every repair — the probe stripper only removes full-line comments, the parse fails, and the script exits 0 #3179 — the same script's JSONC comment gap (probe/parse side; this issue is the write side).
Dedup
Searched open + closed for opencode-config-normalize / normalize.sh: only #2364 (closed, agents-drop). No existing issue covers this script's write path, mode, or symlink behaviour.
Activity
dezren39 commentedon Oct 31, 2026
🤖 Agent note · filed
20 remaining items
dezren39 commentedon Nov 2, 2026
🤖 Agent note · done (PR opened)
repo-worker-code), OpenChamber scheduled lane93c921c58. The script now rejects symlink paths before reads/writes, preserves permission bits with a unique same-directory temporary file and atomic replacement, and has mode/symlink regression tests.bash pkgs/opencode-config-normalize/normalize_test.sh— all 8 cases pass;bash -nandgit diff --checkpass. Before the fix, a manual probe reproduced 0600→0644 and symlink replacement.gh pr checksreports only CodeRabbit skipping; no CI checks are configured/reported.queue/5654-3180-config-mode-symlink-refusal· worktree/home/user/git/fleet/5654dezren39 commentedon Nov 3, 2026
🤖 Agent note · picked up
fix(normalize): align mode/symlink fixtures with the v2 plugin rename (…
fix(normalize): preserve mode and reject symlink configs (#3180) (#4319)
dezren39 commentedon Nov 3, 2026
🤖 Agent note · done — fix landed
16728574018dc51ce6fcadce572df0e938a4e4e6; issue closed.normalize.shrefuses a symlinked config before any read or write (both the shell guard and the Python re-check), and the repair writes through a unique same-directorymkstemptemp withos.fchmod(original_mode)+fsyncbefore the atomicreplace— permissions preserved, symlink target never severed.maininto the branch (clean), then realigned the two opencode-config-normalize: the repair write discards the config's permissions (0600 -> 0644) and silently severs a symlinked config — tmp+replace with no mode copy and no symlink handling (normalize.sh:126-128) #3180 fixtures to main's canonical rename direction (plugin→plugins) so both cases still exercise a real rewrite.bash pkgs/opencode-config-normalize/normalize_test.sh→ all cases pass, includingmode-preserved(0600 retained) andsymlink-refused(exit 1, clear message, link and target byte-identical).