Skip to content

fix(config): sync MetaConfigSchema version default with package.json#275

Merged
xlabtg merged 2 commits intoxlabtg:mainfrom
konard:issue-273-1d981bc674ff
Apr 22, 2026
Merged

fix(config): sync MetaConfigSchema version default with package.json#275
xlabtg merged 2 commits intoxlabtg:mainfrom
konard:issue-273-1d981bc674ff

Conversation

@konard
Copy link
Copy Markdown

@konard konard commented Apr 22, 2026

Summary

Fixes #273.

MetaConfigSchema.version previously defaulted to the hardcoded string "1.0.0", which disagreed with the actual package version (0.8.10). Any config file without an explicit meta.version field would carry this misleading version string in logs and migrations.

Changes

  • src/config/schema.ts: Import pkg.version from package.json (JSON import — resolveJsonModule was already enabled) and use it as the Zod default, so the schema version stays in sync with package.json automatically on every release.
  • src/config/__tests__/loader.test.ts: Add acceptance-criteria unit test asserting that loadConfig on a minimal config (no meta block) returns meta.version === pkg.version.

How to reproduce the issue

Before the fix:

import { MetaConfigSchema } from "./src/config/schema.js";
console.log(MetaConfigSchema.parse({}).version); // "1.0.0"  ← wrong

After the fix:

console.log(MetaConfigSchema.parse({}).version); // "0.8.10" ← matches package.json

Test plan

  • New unit test should default meta.version to the package.json version in loader.test.ts — fails before fix, passes after.
  • All 52 existing tests in src/config/__tests__/loader.test.ts continue to pass.
  • tsc --noEmit passes with no new errors.
  • ESLint passes on changed files.

konard added 2 commits April 22, 2026 20:29
Adding .gitkeep for PR creation (default mode).
This file will be removed when the task is complete.

Issue: xlabtg#273
Previously `MetaConfigSchema.version` defaulted to the hardcoded string
"1.0.0", which disagreed with the actual package version (0.8.10).
Configs written without an explicit `meta.version` would therefore carry
a misleading version string in logs and migrations.

Fix: import `pkg.version` from package.json (resolveJsonModule is already
enabled) and use it as the Zod default so the two sources stay in sync
automatically on every release.

Also adds a unit test asserting that `loadConfig` on a minimal config
(no `meta` block) returns `meta.version === pkg.version`, per the
acceptance criteria in issue xlabtg#273.
@konard konard changed the title [WIP] audit-l1-config-version-default-mismatch fix(config): sync MetaConfigSchema version default with package.json Apr 22, 2026
@konard konard marked this pull request as ready for review April 22, 2026 20:37
@konard
Copy link
Copy Markdown
Author

konard commented Apr 22, 2026

Solution summary

Done. Here's a summary of what was done:

Root cause: MetaConfigSchema.version in src/config/schema.ts:189 had a hardcoded default of "1.0.0" while package.json declared version "0.8.10". Any config file omitting a meta.version field would silently receive the wrong version string.

Fix (2 files changed):

  1. src/config/schema.ts — Added import pkg from "../../package.json" with { type: "json" } and changed the default to z.string().default(pkg.version). resolveJsonModule was already enabled in tsconfig.json.

  2. src/config/__tests__/loader.test.ts — Added the acceptance-criteria unit test: should default meta.version to the package.json version (verifies loadConfig on a minimal config returns meta.version === pkg.version). All 52 tests pass.

PR: #275


This summary was automatically extracted from the AI working session output.

@konard
Copy link
Copy Markdown
Author

konard commented Apr 22, 2026

🤖 Solution Draft Log

This log file contains the complete execution trace of the AI solution draft process.

💰 Cost: $1.028432

📊 Context and tokens usage:

  • 52.2K / 1M (5%) input tokens, 9.5K / 64K (15%) output tokens

Total: (43.4K + 2.4M cached) input tokens, 9.5K output tokens, $1.028432 cost

🤖 Models used:

  • Tool: Anthropic Claude Code
  • Requested: sonnet
  • Model: Claude Sonnet 4.6 (claude-sonnet-4-6)

📎 Log file uploaded as Gist (1546KB)


Now working session is ended, feel free to review and add any feedback on the solution draft.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

audit-l1-config-version-default-mismatch

2 participants