feat(m2): T2-1 through T2-4 — schema_version, load_config enforcement, migrate_project - #190
Merged
Conversation
…a fields to TycoonProject (M2 T2-1) Both fields default so all existing tycoon.yml files load without changes. Includes 3 tests: backwards-compat load, runtimes parsing, metadata parsing.
Writes metadata: defaults and bumps version to 0.2.0 in existing tycoon.yml files. Operates on raw YAML so comments and ordering are preserved. Idempotent — second call returns False with no file write.
…ion bump Instantiate MetadataConfig once rather than twice. Guard the version bump so a file already at a future schema version is not written back down to SCHEMA_VERSION. Update docstring to accurately state that comments are not preserved through the yaml round-trip.
…a_version field Switch migrate_project from yaml.safe_load/yaml.dump to ruamel.yaml so comments and blank lines survive the round-trip. Add schema_version as a separate field on TycoonProject so the user's version field is never touched by migration. Add ruamel-yaml==0.19.1 as a runtime dependency. Adds two new tests: comments_preserved and user_version_not_overwritten.
…e versions Change SCHEMA_VERSION from a semver string to an integer (2) so version comparisons are unambiguous — string comparison would incorrectly treat "0.10.0" < "0.2.0" as True. Change schema_version field type to int | None. Add type guard before comparison: a float schema_version (e.g. 0.2 written unquoted in YAML) now raises ValueError with a clear message rather than a TypeError. A schema_version newer than SCHEMA_VERSION also raises rather than silently passing. Add two new tests covering both error paths.
…onstruction Each ingestion command (sources, run_all, sync_cmd, explore) now constructs TycoonConfig(project_root=_find_project_root()) at invocation time rather than importing the module-level singleton. Tests drop monkeypatch.setattr calls in favour of monkeypatch.chdir so _find_project_root resolves the correct tmp directory without brittle module-level patching. Closes #94
Add load_config() to config.py as a public entry point that wraps TycoonConfig(project_root=_find_project_root()), removing the need for command modules to import the private _find_project_root across module boundaries. Update all four ingestion command files to use it. Drop two dead cfg.reload() calls in sources.py (add_source and remove_source): cfg is function-local and nothing reads from it again after either call. Tracks remaining singleton uses in transform.py / db.py / status.py in issue #175.
load_project now emits a UserWarning when tycoon.yml has no schema_version or one older than SCHEMA_VERSION, pointing users to run the migration. tycoon init --upgrade calls migrate_project and prints whether the file was updated or was already current. Closes #96
… edge cases - Warning moved from load_project() to load_config() and switched to Rich console helper, so it renders in-band and does not appear on fresh projects or on tycoon init --upgrade (neither goes through load_config) - load_project() now raises ValueError for schema_version > SCHEMA_VERSION, mirroring migrate_project's three-way split - save_project() stamps schema_version on every write so a load+save round-trip (sources add/remove) silently upgrades the stamp - scaffold_blank_project() and scaffold_from_template() write schema_version on new projects, eliminating the false-alarm on init - migrate_project() checks isinstance(existing, bool) before int to catch schema_version: true - tycoon init --upgrade wraps migrate_project in try/except ValueError for clean error output instead of a typer traceback
…rsion in save_project - load_project no longer raises for schema_version > SCHEMA_VERSION; the enforcement now lives in load_config() alongside the stale-version warning, keeping the module-level singleton and --help import-safe - load_config errors and raises SystemExit(1) for a future schema_version so any data command fails cleanly rather than tracing through typer internals - save_project preserves whatever schema_version is already in the model instead of unconditionally stamping SCHEMA_VERSION; only migrate_project (via tycoon init --upgrade) advances the stamp - Update tests: load_project future-schema test flipped to assert no raise; save_project tests now assert preservation semantics; new test covers the load_config SystemExit path
feat(t2-4): schema_version enforcement — warn on stale, tycoon init --upgrade to migrate
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Contributor
Author
db-tycoon-stephen
added a commit
that referenced
this pull request
Aug 5, 2026
- pyproject + __init__ to 0.1.11, lockfile refreshed - CHANGELOG [0.1.11] entry: M2 schema work (#83/PR #190), ruff pin + format gate (PR #174), release-time dependency review (PR #180), and the four T2-4 review follow-ups closed on this branch (#185-#188) - docs/releases/v0.1.11.md + mkdocs nav entry Release date matches the planned 2026-08-07; adjust before tagging if the train slips. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Merged
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
Consolidates all M2 T2 tasks into
v0.1.11:schema_versioninteger field onTycoonProject;RuntimeEntry/MetadataConfigmodelsload_config()factory replaces globalconfigsingleton in command paths; deadreload()calls droppedload_config()(SystemExit(1));load_projectis now permissive (import-time safe);save_projectpreservesschema_versionfrom the model instead of unconditionally stamping;tycoon init --upgradescaffoldCloses #83
Test plan
TestSchemaVersionEnforcement—load_projectpermissive,save_projectpreserves version, no stamp when absentTestLoadConfigSchemaWarning— warns on stale version,SystemExit(1)on future versiontycoon init --upgradecreates migration path without touching unrelated fieldsNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.