Repository navigation
Conversation
createDefaultSettings wrote defaults over an existing settings file, resetting run.timeout and deleting run.phases under a success banner. Guard on the file it writes; merge only flag-set keys onto the raw parsed object; report the decision; --force keeps the overwrite. Entire-Checkpoint: 7c277720c97f
# Conflicts: # CHANGELOG.md
This was referenced Sep 19, 2026
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.
Summary
createDefaultSettingswrotegenerateSettingsJsonc(DEFAULT_SETTINGS)straight over.sequant/settings.json, so an init over an existing install resetrun.timeout(5400 → 1800) and deleted the wholerun.phasesblock — under the success banner, with no diff, no backup and no mention.--forceis absent, only the keys the flags actually set are merged in (todayrun.agent); when no flag key changes, nothing is written at all, so the file stays byte-identical, JSONC comments included.--forcekeeps the old overwrite as the documented escape hatch.generateSettingsJsonc(emits norun.phases/run.modelRoles/scopeAssessment) orvalidateSettings(nested Zod schemas strip unknown keys) — either route would reproduce the exact data loss being fixed..sequant/settings.jsonitself, not the.claude/settings.jsonthat init's "already initialized" warning checks: a repo with tuned settings and no.claude/settings.jsonwas clobbered with no warning at all.settingsExist()— exported and dead since it was written — is now module-local and is the guard (AC-6).Pre-PR AC Verification
run.timeout/run.phasessurvivesrc/lib/settings.ts:1285guard;init.test.tscase "AC-1" — no write to the settings path at all--agent codexstill recordsrun.agentwhile preserving the rest (#1059 kept)preserveExistingSettingsraw-object merge;init.test.tscase "AC-2"--forcestill overwrites with defaults!force &&in the guard;init.test.tscase "AC-3" assertstimeoutback to 1800 and nophasessrc/commands/init.tsconsole.logof the decision;init.test.tscase "AC-4" asserts captured stdout names the file.claude/settings.jsoneitherSETTINGS_PATH;init.test.tscase "AC-5" with a fixture that has only.sequant/settings.jsonsettingsExist()used by the new guard or deleted — no exported dead codeexportdropped; called bycreateDefaultSettings. Evidence command printsPASSpreserveExistingSettingscatch branch;init.test.tscase "derived: leaves an unparseable settings file untouched and warns"--agent claude-codeswitches back off a recorded driver instead of a silent no-oprun.agenttreated asclaude-code;init.test.tscase "explicit --agent claude-code switches back"AC-7 — manual end-to-end repro
Ran the issue's script from the worktree root against this branch's own
dist/bin/cli.js(not the globalsequant, which points at main's dist). Captured output:The resulting
.sequant/settings.json—run.agentrecorded, tuned keys intact,run.phasesstill whole:{ "version": 1, "run": { "agent": "codex", "timeout": 5400, "phases": { "spec": "sonnet", "exec": "sonnet", "qa": "opus" } } }And the decision init printed (AC-4), from the same run:
AC-6 evidence
Mutation verification
Tree was committed clean before each probe and restored after (
git status --short→ 0).Mutation-verified: AC-1 — removed the
if (!force && (await settingsExist()))guard fromcreateDefaultSettingsso the defaults write unconditionally;init.test.ts > 1071 … > AC-1: preserves run.timeout and run.phases instead of writing defaultsfailed; restored.Mutation-verified: AC-5 — keyed
settingsExist()off.claude/settings.jsoninstead ofSETTINGS_PATH;init.test.ts > 1071 … > AC-5: preserves even with no .claude/settings.json presentfailed — and it was the only failure, so the case genuinely discriminates the file the guard keys off; restored.Test plan
npx vitest run src/commands/init.test.ts -t "1071"→ Tests 7 passed (AC-1's evidence pattern matches)npm run build→ clean;npm run lint→ clean (0 warnings,--max-warnings 0)lib/settingsorcommands/init→ 234 passedbatch-executor,prompt-wait,semgrep,mcp-serve.integration,relay-hook.integration. Pre-existing, not from this change: settled against base in this same worktree (fix(test): App.test.tsx's Ink fake-timer test blows the unit project's 5s default under full-suite load (sibling of #842) #880) by reverting only the three changed source files and re-running those same 5 files — base fails in the identical 5 files with a rotating case set (11 failures vs 13 on the branch, different individual cases each run). None of the 5 referencescreateDefaultSettings; a repo-wide grep shows onlyinit.tsandinit.test.tsdo. A concurrent chore(doctor/templates): timeout the codex+opencode CLI probes; add the missing templates/codex routing test #1075 suite was running in a sibling worktree during the full run.Known gaps
writeCodexConfigoverwrites.codex/config.tomlunconditionally andsaveConfigoverwrites.claude/.sequant/config.json. Both want a follow-up issue rather than widening this PR.saveSettings; a surgical JSONC line patch was considered and rejected in spec review as two code paths plus a regex over user-formatted JSONC.Closes #1071
🤖 Generated with Claude Code