feat(rigging): configurable service database name (#24 follow-up) - #43
Merged
Conversation
rigging's service containers hardcoded the database to `postgres`/`mysql` and
gave the consuming repo no way to change it, so the only TEST_DATABASE_URL it
could emit ended in `/postgres`. A repo whose test harness guards on the DB
name (refusing to run unless it ends in `_test`, a common way to stop a stray
URL truncating dev/prod data) could not use rigging without hand-editing the
generated workflow.
Add an optional per-service `database` key. rigging composes the chosen name
into both the container's POSTGRES_DB/MYSQL_DATABASE and the connection URL.
The key is default-preserving: each service carries a default_database equal to
what it hardcoded before, so an omitted `database` reproduces every existing
golden byte-for-byte. It is rejected for redis (no database concept) rather
than silently ignored, and validated by a strict regex that refuses anything
needing YAML quoting or carrying a `${{` expression. Manual escape hatch like
testCommand/services -- init does not propose it, so the #33 round-trip
property test is untouched.
services.py: ServiceSpec splits base_env from the database pair, gains
database_env/default_database, and url becomes url(database). config.py: accept
and validate `database`, thread onto ResolvedService. plan.py: compose env+URL
from the chosen database. New golden node-postgres-database.yml; tests across
config/plan/render/services/injection. Suite 1441 -> 1456.
Closes the organization-monorepo adoption of rigging (issue #24 follow-up).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119qj5F9NnGhQCxHehLy99E
submtd
commented
Jul 23, 2026
submtd
left a comment
Owner
Author
There was a problem hiding this comment.
Self-review (author) — satisfies keel's reviewPolicy: review gate.
New optional per-service 'database' key for rigging service containers, closing the last #24-shaped adoption gap (a repo that guards its test DB by name).
Reviewed:
- Correctness — database composed into both the container env (POSTGRES_DB/MYSQL_DATABASE) and the connection URL; redis (no database concept) rejects the key with a field-named ConfigError rather than silently ignoring it.
- Byte-identity (the hard constraint) — default-preserving by construction: each service carries a default_database equal to what it hardcoded before, so the omitted path IS the default path. git diff touches no existing golden; a dedicated test asserts a set database moves only the POSTGRES_DB line and the URL segment.
- Injection — SERVICE_DATABASE_RE ([A-Za-z0-9_-]+) refuses whitespace, quotes, and ${{ at load; a hostile database is refused before render (test_hostile_service_database_is_refused_before_render).
- Scope/init — manual escape hatch like testCommand/services; init untouched, so SIGNAL_KEYS/propose_config and the #33 round-trip property test are unchanged.
- Tests — 1441 to 1456 (15 new, TDD); purity green.
- Changelog — Unreleased Added entry accurate and user-facing.
Ready to land.
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.
What & why
rigging's service containers hardcoded the database name to
postgres/mysqland gave the consuming repo no way to change it — so the onlyTEST_DATABASE_URLrigging could emit ended in/postgres. Many projects guard their destructive test suite by database name (refusing to run unless the target DB name matches a safe pattern, e.g. ending in_test, so a misconfigured URL can't truncate dev or prod data). Such a repo couldn't use rigging without hand-editing the generated workflow — the same shape as the #24 blockers, one narrower gap.This adds an optional per-service
databasekey:{"stacks": {"node": {"services": { "postgres": {"version": "16", "urlEnv": "TEST_DATABASE_URL", "database": "onelife_test"} }}}}renders
POSTGRES_DB: "onelife_test"andTEST_DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/onelife_test".Design (follows the engine's existing patterns)
services.py—ServiceSpecsplitsbase_envfrom the database pair and gainsdatabase_env(POSTGRES_DB/MYSQL_DATABASE/None) anddefault_database(postgres/mysql/None);urlbecomesurl(database). redis has neither field and its URL template ignores the argument.config.py—databaseadded to_SERVICE_KEYS, validated by a strictSERVICE_DATABASE_RE([A-Za-z0-9_-]+, refuses whitespace/quotes/${{), rejected for redis (field-namedConfigError, likepackageManageroff a non-node stack), threaded ontoResolvedService.plan.py—_resolve_servicespicksrs.database or spec.default_databaseand composes it into both the container env and the URL.testCommand/services, so the Every plugin needs a round-trip property test: propose_config output must load through load_config #33 round-trip property test is unaffected.Byte-identity (the hard constraint)
databaseis default-preserving: each service'sdefault_databaseequals the value it hardcoded before, so an omitteddatabasereproduces every existing golden byte-for-byte.git difftouches no existing golden — only the newnode-postgres-database.ymlis added.Verify
databasemoves only thePOSTGRES_DBline and the URL segment), injection (hostiledatabaserefused at load).pytestgreen; purity and the Every plugin needs a round-trip property test: propose_config output must load through load_config #33 round-trip test included.Closes the organization-monorepo adoption of rigging (issue #24 follow-up): a Postgres repo with a name-guarded test database was the last case rigging couldn't render without a hand-edit.
🤖 Generated with Claude Code