Skip to content

feat(m2): T2-1 through T2-4 — schema_version, load_config enforcement, migrate_project - #190

Merged
JesuFemi-O merged 12 commits into
v0.1.11from
feat/m2-t2-3
Aug 2, 2026
Merged

feat(m2): T2-1 through T2-4 — schema_version, load_config enforcement, migrate_project#190
JesuFemi-O merged 12 commits into
v0.1.11from
feat/m2-t2-3

Conversation

@JesuFemi-O

@JesuFemi-O JesuFemi-O commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Consolidates all M2 T2 tasks into v0.1.11:

  • T2-1: schema_version integer field on TycoonProject; RuntimeEntry / MetadataConfig models
  • T2-2: ruff format alignment for T2-1 additions
  • T2-3: load_config() factory replaces global config singleton in command paths; dead reload() calls dropped
  • T2-4: future-schema gate moved to load_config() (SystemExit(1)); load_project is now permissive (import-time safe); save_project preserves schema_version from the model instead of unconditionally stamping; tycoon init --upgrade scaffold

Closes #83

Test plan


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

JesuFemi-O and others added 12 commits August 2, 2026 08:30
…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
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@JesuFemi-O

Copy link
Copy Markdown
Contributor Author

Closed in favour of a direct merge with conflict resolution (uv.lock conflict from #180 deps-review). M2 T2-1 through T2-4 is now in v0.1.11 as of commit 91a8de0.

@JesuFemi-O
JesuFemi-O merged commit 91a8de0 into v0.1.11 Aug 2, 2026
9 checks passed
@db-tycoon-stephen
db-tycoon-stephen deleted the feat/m2-t2-3 branch August 2, 2026 21:43
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>
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.

1 participant