FIX [SCMS] Normalize env + DB handling, add safe auto-seed on dev boot#2
Merged
Conversation
…to-seed dev 🌱🦝 - Normalize NODE_ENV to development/test/production with runtime validation - Centralize dotenv loading and env parsing - Make DB resolution deterministic and safe across envs - Prevent test/prod DB spills with explicit guardrails - Align seed script with current schema (timestamps, coherence_score, content fields) - Add auto-seeding on first dev boot when DB is empty - Improve dev ergonomics and startup reliability co-authored-by: Lyric <lyric@thehumanpatternlab.com> co-authored-by: Carmel <carmel@thehumanpatternlab.com>
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.
Normalize env + DB handling, add safe auto-seed on dev boot
This PR started as “why won’t the CLI behave?” and evolved into a full cleanup and hardening of environment handling, database safety, and dev startup ergonomics.
The result is a deterministic, safer backend with improved developer experience and zero risk of accidental DB misuse.
✨ What changed
Environment handling
src/env.tsNODE_ENVtodevelopment | test | productionDatabase safety
development→lab.dev.dbtest→:memory:production→lab.dbSeeding improvements
created_at/updated_atcoherence_scoretestproductionunless explicitly allowedAuto-seed on dev boot
developmentDev ergonomics
🛡️ Why this matters
local,dev, etc.)🦝 Notes
This work was born out of debugging CLI and IDE behavior, but resulted in meaningful infrastructure improvements and clearer system boundaries. Consider this a small internal reset that pays dividends going forward.