feat(onboard): default to managed-DB node app; truly-static is explicit opt-out - #182
Merged
Conversation
Failing tests pin the P2 behavior: - Template .samohost.toml must have dbBackend=dblab, databaseUrlEnv, migrateCmd, rlsNonSuperuser, envDbVars as ACTIVE (uncommented) fields - onboard-synth (no .samohost.toml in repo) must produce an AppRecord with dbBackend=dblab, databaseUrlEnv, migrateCmd set - Synthesised TOML must parse OK and pass validateStaticNoDb - Static opt-out (kind=static + no DB fields) must still parse OK - Template must document the static opt-out path All 8 new assertions fail (expected) — template DB block is currently commented out, synth uses the template as-is. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…it opt-out Template .samohost.toml now ships with the DB block ACTIVE (not commented out): dbBackend="dblab", databaseUrlEnv="DATABASE_URL", migrateCmd="npm run migrate", rlsNonSuperuser=true, envDbVars=["DATABASE_URL"] This means onboard-synth (no existing .samohost.toml in repo) produces an AppRecord with dbBackend=dblab, databaseUrlEnv, migrateCmd set — a valid managed-DB node app that passes validateStaticNoDb. The static opt-out is now explicitly documented in the template with clear instructions: set kind="static" and remove ALL DB fields. This makes truly-static a deliberate, documented choice rather than the silent default. CLAUDE.md updated to reference @samo/auth (packages/auth/migrations/0001_auth.sql) as the canonical baseline auth migration for onboarded client apps. Scope: template + onboard scaffold defaults ONLY. - Global previewDbBackendFor/resolvedPreview resolver behavior is UNCHANGED. - Existing registered apps are unaffected (no AppRecord mutation, no fleet change). - validateStaticNoDb coherence: node+DB fields = allowed (never fires for node apps). Recommendation (out of scope for this PR): the global resolver default (previewDbBackendFor returning "dblab" for legacy apps with neither field set) is already correct and does NOT need changing here. That is a separate concern. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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.
Summary
templates/client-repo/.samohost.tomlhad the DB block commented out (dbBackend,databaseUrlEnv,migrateCmd,rlsNonSuperuser,envDbVarsall commented). Onboard-synth used the template as-is, so a freshly-onboarded client got a DB-less node app by default — the path of least resistance was always a DB-less app, which is how static-with-later-DB drift starts.dbBackend="dblab",databaseUrlEnv="DATABASE_URL",migrateCmd="npm run migrate",rlsNonSuperuser=true,envDbVars=["DATABASE_URL"].kind="static"(remove all DB fields). Static is now a deliberate documented choice, not the silent default.@samo/authandpackages/auth/migrations/0001_auth.sqlas the canonical baseline auth migration for new client apps.Scope (conservative — template + synth defaults ONLY)
templates/client-repo/.samohost.tomlandtemplates/client-repo/CLAUDE.mdchanged.previewDbBackendFor/resolvedPreviewresolver behavior is unchanged — existing registered apps are unaffected.validateStaticNoDbcoherence: node + DB fields = allowed (the check only fires forkind="static"apps).Tests
Strict TDD: RED commit first, GREEN commit second.
New test file:
test/onboard-managed-db-default.test.ts(19 tests):dbBackend,databaseUrlEnv,migrateCmd,rlsNonSuperuser,envDbVarsas ACTIVE fieldsvalidateStaticNoDbkind=staticonboard-synth(no.samohost.tomlin repo) → AppRecord hasdbBackend=dblab,databaseUrlEnv,migrateCmdvalidateStaticNoDbkind=static+ no DB fields) still parses OK@samo/authstaging.env.examplehasDATABASE_URLactiveFull suite: 2166 pass, 0 fail (the
packages/auth/test/pg.test.tsrequires a Postgres service and is expected to pass in CI with the postgres service container).Global resolver — recommendation only (not changed here)
previewDbBackendForalready returns"dblab"for legacy apps with neither field set (correct default). No change needed for the global resolver to make this P2 work. A future PR could make the default explicit rather than implicit if desired.Merged: false
🤖 Generated with Claude Code