Skip to content

chore(db): rename csi_sections → spec_sections + open-issue sweep#79

Merged
thewrz merged 3 commits into
mainfrom
chore/db-rename-csi-sections
May 18, 2026
Merged

chore(db): rename csi_sections → spec_sections + open-issue sweep#79
thewrz merged 3 commits into
mainfrom
chore/db-rename-csi-sections

Conversation

@thewrz
Copy link
Copy Markdown
Contributor

@thewrz thewrz commented May 18, 2026

Completes the deferred Phase C3 of PR #78. The internal csi_sections table becomes spec_sections, finishing the alignment with the Csi*Spec* type rename that already shipped.

Also includes housekeeping on open-issue bodies that still referenced the old AST type names. Those updates were applied via gh issue edit on issues #39, #44, #47, #53 (no code in this PR for that — just the migration + SQL refs + docs).

Migration approach

Reversible single-statement rename. No data copy, no downtime.

// up
pgm.renameTable('csi_sections', 'spec_sections');
pgm.sql('ALTER INDEX csi_sections_division_index RENAME TO spec_sections_division_index');

// down (symmetric)
pgm.sql('ALTER INDEX spec_sections_division_index RENAME TO csi_sections_division_index');
pgm.renameTable('spec_sections', 'csi_sections');

Postgres-derived constraint indexes (csi_sections_pkey, csi_sections_section_number_key) keep their auto-generated names — they're transparent to application code and don't appear in any query string. Renaming them would add churn for no benefit.

What changed

  • src/db/migrations/009_rename_csi_sections_to_spec_sections.ts — new migration
  • src/db/seed.ts, src/db/queries/search.ts — SQL string updates
  • listCsiSectionslistSpecSections, lookupCsiSectionTitlelookupSpecSectionTitle (+ propagation to all call sites in mcp/, lib/, tests)
  • src/lib/infer-section.integration.test.ts, src/mcp/server.integration.test.ts — test comment + SQL updates
  • ADRs 007, 012, 013, UFGS README, CLAUDE.md — table-name references aligned
  • New spec: docs/superpowers/specs/2026-05-18-csi-sections-rename-and-issue-sync.md

What didn't change

  • ADR-013 filename — kept as 013-csi-sections-seed-public-domain-derivation.md for stable cross-reference. A historical note in the body explains the rename.
  • Historical plan/spec files in docs/superpowers/plans/ and pre-2026-05-18 specs — execution records, immutable.
  • Migration 001_create_csi_sections.ts — still creates the table under its original name (that's the historical creation point; migration 009 renames it forward).
  • Function names where Csi was mid-identifier — already addressed in PR chore: trademark good-faith notices + Csi* → Spec* internal rename #78 for word-boundary matches. This PR catches the remaining DB-query function names.

Test plan

  • pnpm lint — clean
  • pnpm test — 462/462 pass
  • pnpm migrate && pnpm seed && pnpm test:integration locally — 169/170 pass (1 unrelated CPI fixture test fails on main too; not introduced by this PR)
  • pnpm migrate:down && pnpm migrate round-trip — verified locally
  • CI integration tests — all green on run 26055640499

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Documentation

    • Clarified that section-title lookup is based on UFGS reference material rather than authoritative CSI MasterFormat, with updated architecture documentation explaining coverage limitations and lookup result meanings.
  • Refactor

    • Internal consistency improvements to section reference handling across the codebase.

Review Change Stack

thewrz added 3 commits May 18, 2026 12:27
- Add reversible migration 009: ALTER TABLE RENAME + ALTER INDEX RENAME
- Update INSERT/SELECT/JOIN SQL strings in seed + search queries
- Rename listCsiSections / lookupCsiSectionTitle query functions to
  listSpecSections / lookupSpecSectionTitle and propagate to all
  call sites (file-loader, mcp/handlers, mcp/resources, db barrel
  + their tests)

Completes the deferred Phase C3 of PR #78 trademark good-faith pass.
Migration is reversible — round-trip verified locally.

See docs/superpowers/specs/2026-05-18-csi-sections-rename-and-issue-sync.md
Updates active ADRs (007, 012, 013), UFGS README, and CLAUDE.md to
reference spec_sections instead of csi_sections. ADR-013 keeps its
filename for stable cross-reference and includes a historical note
explaining the rename. Historical plan/spec files (pre-2026-05-18)
intentionally retain original names as execution records.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

📝 Walkthrough

Walkthrough

The PR renames the PostgreSQL table csi_sections to spec_sections and updates all corresponding code references, including database queries, function names, business logic, MCP integration, and project documentation. A database migration handles the schema change with reversible up/down operations on the table and its index.

Changes

Database table csi_sections to spec_sections rename

Layer / File(s) Summary
Database migration and query API
src/db/migrations/009_rename_csi_sections_to_spec_sections.ts, src/db/queries/search.ts, src/db/queries/search.integration.test.ts, src/db/index.ts, src/db/seed.ts
Migration 009 renames csi_sections to spec_sections with reversible index updates. Query functions listCsiSections and lookupCsiSectionTitle are replaced by listSpecSections and lookupSpecSectionTitle that target the renamed table. Database exports and seed logic updated accordingly.
File loader and inference updates
src/lib/file-loader.ts, src/lib/file-loader.test.ts, src/lib/infer-section.integration.test.ts
Business logic layers updated: resolveStandardTitle now calls lookupSpecSectionTitle; tests mock and assert against the renamed function; inference-related lookups against the new table are validated.
MCP handlers and resources
src/mcp/handlers.ts, src/mcp/resources.ts, src/mcp/server.integration.test.ts
MCP tool handlers and resources use renamed query functions; integration test fixture switches to spec_sections for test section selection.
Documentation and ADR updates
CLAUDE.md, docs/adr/007-all-divisions-from-day-one.md, docs/adr/012-ufgs-as-reference-not-authoritative-csi.md, docs/adr/013-csi-sections-seed-public-domain-derivation.md, docs/references/UFGS/README.md, docs/superpowers/specs/2026-05-18-csi-sections-rename-and-issue-sync.md
Project documentation, ADRs, and implementation spec updated to reference spec_sections and renamed functions. ADR-013 includes historical note and updated consequences/verification sections. Spec document provides comprehensive rename plan and verification checklist.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • wrzonance/SpecR#24: Initial MCP tools/resources that originally wired listCsiSections, now retargeted to listSpecSections by this rename.
  • wrzonance/SpecR#62: Inference pipeline that introduced lookupCsiSectionTitle for standard-title grounding, now updated to use lookupSpecSectionTitle throughout.
  • wrzonance/SpecR#78: Prior CSI→Spec internal refactoring work that this rename operationalizes at the database level.

Poem

🐰 From CSI to Spec, the tables now align,
No longer bound by outdated design,
Each query renamed, each lookup refreshed,
The database schema and code coalesce,
One rename, many files, all tests now pass!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main change: renaming the database table from csi_sections to spec_sections and updating related documentation.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/db-rename-csi-sections

Comment @coderabbitai help to get the list of available commands and usage tips.

@thewrz thewrz merged commit e52c38d into main May 18, 2026
5 checks passed
@thewrz thewrz deleted the chore/db-rename-csi-sections branch May 18, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant