feat: ISSUE-398 — guild-config service layer#405
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new guild-config domain layer intended to centralize guild-level configuration reads and feature gating, plus initial persistence/seeding support to bootstrap config rows from environment variables.
Changes:
- Introduces
guild-configservice helpers (getGuildConfigOrNull,isFeatureEnabledForGuild) with a feature→DB-flag mapping. - Adds
guild_configspersistence: migration, repository, and an env-based seeder wired into startup. - Adds unit/integration test coverage for the new guild-config modules and updates Jest scripts to separate integration tests.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/index.ts | Wires guild-config seeding into startup when DB is configured. |
| src/domain/guild-config/guild-config.service.ts | Adds service-layer wrapper and feature-flag gating helper. |
| src/domain/guild-config/guild-config.seeder.ts | Seeds guild_configs rows from env vars for all cached guilds. |
| src/domain/guild-config/guild-config.repository.ts | Adds DB accessors for guild config read/upsert/list. |
| src/domain/guild-config/tests/guild-config.service.test.ts | Unit tests for service helpers. |
| src/domain/guild-config/tests/guild-config.seeder.test.ts | Unit tests for env parsing + seeding behavior. |
| src/domain/guild-config/tests/guild-config.repository.test.ts | Unit tests validating SQL construction/mapping via mocked db client. |
| src/domain/guild-config/tests/guild-config.repository.integration.test.ts | Optional integration tests against real Postgres. |
| src/tests/index.startup-readonly.test.ts | Updates startup wiring tests to mock the new seeder import. |
| package.json | Attempts to exclude integration tests from default npm test and adds test:integration. |
| migrations/1776961242514_add-guild-configs.cjs | Creates guild_configs table with defaults for all feature areas. |
| CLAUDE.md | Adds implementation protocol guidance. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…configs schema check, skip role setup on config load error
4761ad4 to
7286398
Compare
demianseiler
approved these changes
May 15, 2026
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
Establishes the guild-config persistence layer as a shared foundation for all per-guild configuration:
guild_configstable) — adds the schema, all columns, and sensible DB-level defaultsguild-config.repository.ts) —getGuildConfig,upsertGuildConfig,insertGuildConfigIfAbsent,getAllGuildConfigs, andensureGuildConfigsSchema(startup table health check)guild-config.seeder.ts) — seeds missing guild rows from env vars at startup; gates seeding behind!readOnlyMode; rejects non-positive integers viaenvInt()guild-config.service.ts) — thin wrappers +isFeatureEnabledForGuildwith aBooleanKeys<GuildConfig>-narrowedFEATURE_FLAG_MAP(compile-time guard against mapping a feature to a non-boolean field); re-exportsensureGuildConfigsSchemaindex.ts) — callsensureGuildConfigsSchema()afterensureNominationsSchema()to fail fast on missing migrations; skips role setup when guild config load throws (rather than falling back to hardcoded defaults)Test plan
guild-config.repository.test.ts— unit tests for all repository functions includingensureGuildConfigsSchema(table present vs missing)guild-config.repository.integration.test.ts— live DB round-trips for default values and partial patch semanticsguild-config.seeder.test.ts— env → patch mapping, read-only skip, per-guild seeding behaviourguild-config.service.test.ts— service wrappers,isFeatureEnabledForGuildexhaustive cases,ensureGuildConfigsSchemadelegation and error propagationindex.startup-readonly.test.ts— schema check, seeder read-only gate, config-load-throw skips role setupCloses #394
Closes #395
Closes #398