Skip to content

feat: ISSUE-398 — guild-config service layer#405

Merged
GitAddRemote merged 1 commit into
mainfrom
feature/ISSUE-398
May 15, 2026
Merged

feat: ISSUE-398 — guild-config service layer#405
GitAddRemote merged 1 commit into
mainfrom
feature/ISSUE-398

Conversation

@GitAddRemote
Copy link
Copy Markdown
Collaborator

@GitAddRemote GitAddRemote commented Apr 23, 2026

Summary

Establishes the guild-config persistence layer as a shared foundation for all per-guild configuration:

  • Migration (guild_configs table) — adds the schema, all columns, and sensible DB-level defaults
  • Repository (guild-config.repository.ts) — getGuildConfig, upsertGuildConfig, insertGuildConfigIfAbsent, getAllGuildConfigs, and ensureGuildConfigsSchema (startup table health check)
  • Seeder (guild-config.seeder.ts) — seeds missing guild rows from env vars at startup; gates seeding behind !readOnlyMode; rejects non-positive integers via envInt()
  • Service (guild-config.service.ts) — thin wrappers + isFeatureEnabledForGuild with a BooleanKeys<GuildConfig>-narrowed FEATURE_FLAG_MAP (compile-time guard against mapping a feature to a non-boolean field); re-exports ensureGuildConfigsSchema
  • Startup wiring (index.ts) — calls ensureGuildConfigsSchema() after ensureNominationsSchema() to fail fast on missing migrations; skips role setup when guild config load throws (rather than falling back to hardcoded defaults)
  • CLAUDE.md — documents migration tooling and the guild-config layer

Test plan

  • guild-config.repository.test.ts — unit tests for all repository functions including ensureGuildConfigsSchema (table present vs missing)
  • guild-config.repository.integration.test.ts — live DB round-trips for default values and partial patch semantics
  • guild-config.seeder.test.ts — env → patch mapping, read-only skip, per-guild seeding behaviour
  • guild-config.service.test.ts — service wrappers, isFeatureEnabledForGuild exhaustive cases, ensureGuildConfigsSchema delegation and error propagation
  • index.startup-readonly.test.ts — schema check, seeder read-only gate, config-load-throw skips role setup

Closes #394
Closes #395
Closes #398

Copilot AI review requested due to automatic review settings April 23, 2026 16:57
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-config service helpers (getGuildConfigOrNull, isFeatureEnabledForGuild) with a feature→DB-flag mapping.
  • Adds guild_configs persistence: 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.

Comment thread src/domain/guild-config/guild-config.service.ts Outdated
Comment thread src/domain/guild-config/guild-config.seeder.ts Outdated
Comment thread package.json Outdated
Comment thread CLAUDE.md
Comment thread src/index.ts Outdated
Comment thread src/index.ts
…configs schema check, skip role setup on config load error
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated no new comments.

@GitAddRemote GitAddRemote requested a review from demianseiler May 15, 2026 20:28
@GitAddRemote GitAddRemote merged commit 66d1250 into main May 15, 2026
4 checks passed
@GitAddRemote GitAddRemote deleted the feature/ISSUE-398 branch May 15, 2026 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants