Repository navigation
Description
kit config migrate re-serialises .kit.toml from the parsed object, so every comment in the file is deleted. The dry run does not mention it: it previews a one-line change and the real run makes a thirty-six-line one.
Measured on kit's own repo, migrating v0 → v1 (a step whose entire job is to stamp version = 1):
$ kit config migrate --dry-run
Planned migration (dry run)
v0 -> v1: Stamp schema version=1 (baseline; no field renames)
Changes:
+ version = 1
Would migrate v0 -> v1 (1 step(s)). Nothing written (--dry-run).
$ kit config migrate
✓ Migrated v0 -> v1. Original saved to …/.kit.toml.backup.
$ git diff --stat .kit.toml
.kit.toml | 36 ++++++++++++++++++++----------------
$ git show HEAD:.kit.toml | grep -c '^\s*#' # comment lines before
8
$ grep -c '^\s*#' .kit.toml # after
0
The data survives — parsed before/after are identical apart from the added version — so validation passes and nothing flags the loss. What is gone is the reasoning:
-# Security scanners kit's own `kit check` resolves mise-first. Declaring them here
-# means `kit install` provisions them so the trivy/secrets scans actually run
-# (otherwise they warn "not installed"). Scheme-qualified `aqua:` refs (matching
-# kit's own toml-generator) so the triage gate maps them to a repo triage and
-# installs on PASS — bare names are untriageable and the gate blocks them.
-# Scanner tokens (SNYK_TOKEN, …) resolve from the shared sandstream-common
-# Infisical project so `kit scan` works without an `infisical run` wrapper.
-environment = "dev" # dev, staging, prod (auto-detected from git branch if not set)
That last line is worth noting on its own: an inline comment documenting the accepted values of the field it sits on.
Why this matters more than a formatting nit
.kit.toml is where a repo declares its policy, and kit's whole argument is that policy should be reviewable. Comments are where the why lives — why these scanners, why scheme-qualified refs, which values a field accepts. A migration that silently deletes them converts reviewable policy into bare data, and it does so on the one command whose job is routine maintenance, in a step that changes nothing semantic.
It also defeats the safety story around it. docs/COMMANDS.md says a real run "backs up to .kit.toml.backup, re-validates, and restores on any failure" — and re-validation passes, because the data is fine. The backup is the only trace, and it is not in .gitignore, so the artifact is committable.
Proposed
- Patch the text, don't re-serialise. A migration that only adds or renames keys can edit the source: inserting
version = 1is a line, not a rewrite. The v0→v1 step in particular changes nothing else. - If a future migration genuinely needs a rewrite, refuse to lose comments silently. Count them, say so, and require an explicit flag: "3 comment line(s) cannot be preserved by this migration — re-run with
--allow-comment-loss". - Make the dry run tell the truth. The preview showed
+ version = 1while the real change touched 36 lines. Whatever the fix for (1) and (2), the dry run must report comment loss and the real line count — a preview that omits the destructive part of a change is worse than no preview. - Gitignore the backup in the template
.gitignorekit writes (.kit.toml.backup), so a migration does not leave a committable artifact behind.
Workaround
Stamp the version by hand — it is one line at the top of the file — or migrate and then restore the comments from git.
Related
- Config drift is silent both ways: the schema detector has no caller, and feature drift has no detector #511 — the
config schemarow that surfaced this at all: it reported kit's own config as v0, which is what prompted running the migration.
🤖 Generated with Claude Code
Activity
chore(config): stamp .kit.toml at schema v1 — by hand, because migrat…
fix(config): migrate by editing the text, so it stops deleting every …
chore(release): 6.8.0 (#516)