fix(gateway-registry): adopt agentflare-db-kit migrations preventively - #573
Conversation
Same architectural gap as skill-registry (#519/PR #572), which gateway-registry's own doc comments say it mirrors: hand-rolled apply_schema() with no user_version tracking. Audited the git history (#104 -> #158 -> #347) -- the tools table's columns have never changed since creation, so there's no live "no such column" bug today, but the next column addition would hit the identical class of bug. Migrates to agentflare-db-kit's open_file/open_memory with a real migration list: 0001_initial replays the original (#104) narrow schema, 0002_fts_triggers unconditionally drops and recreates tools_fts as the external-content shape with sync triggers plus a backfill. No ALTER TABLE/migration hook needed here (unlike #519) since tools's columns are stable -- DROP ... IF EXISTS before a fresh CREATE is correct regardless of which pre-migration shape existed. Added GatewayError::DbInit for db_kit::open::Error and its error_kind match arm. All 60 gateway-registry unit tests pass, including the existing legacy-standalone-FTS conversion test; clippy (with the CI gate flags) and fmt are clean; the full agentflare binary compiles. Agentflare-Agent: claude-code_2-1-237_agent Agentflare-Branch: task/520-fix-gateway-registry-adopt-agentflare-db Agentflare-Item: 520
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
Included review availability: 0 reviews are currently available. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. 📝 WalkthroughWalkthroughThe gateway registry now uses versioned SQLite migrations for the tools schema and FTS synchronization. Database opening delegates to ChangesGateway registry database
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This PR adopts versioned database migrations without any supplied current-head merge-blocking risk; it is merge-ready after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant GatewayRegistry
participant DbKit
participant SQLite
GatewayRegistry->>DbKit: open database with migrations
DbKit->>SQLite: create or open connection
DbKit->>SQLite: execute 0001_initial and 0002_fts_triggers
SQLite-->>GatewayRegistry: connection or DbInit error
``
</details>
<!-- walkthrough_end -->
<!-- pre_merge_checks_walkthrough_start -->
<details>
<summary>🚥 Pre-merge checks | ✅ 5</summary>
<details>
<summary>✅ Passed checks (5 passed)</summary>
| Check name | Status | Explanation |
| :------------------------: | :------- | :----------------------------------------------------------------------------------------------------------------------------------- |
| Title check | ✅ Passed | The title clearly identifies the gateway-registry migration change and its preventive purpose. |
| Description check | ✅ Passed | The description explains the change and rationale and provides completed test results, but it omits the Notes for reviewers section. |
| Docstring Coverage | ✅ Passed | Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. |
| 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. |
</details>
</details>
<!-- pre_merge_checks_walkthrough_end -->
<!-- finishing_touch_checkbox_start -->
<details>
<summary>✨ Finishing Touches</summary>
<details>
<summary>📝 Generate docstrings</summary>
- [ ] <!-- {"checkboxId":"7962f53c-55bc-4827-bfbf-6a18da830691"} --> Create stacked PR
- [ ] <!-- {"checkboxId":"3e1879ae-f29b-4d0d-8e06-d12b7ba33d98"} --> Commit on current branch
</details>
<details>
<summary>🧪 Generate unit tests (beta)</summary>
- [ ] <!-- {"checkboxId": "f47ac10b-58cc-4372-a567-0e02b2c3d479", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Create PR with unit tests
- [ ] <!-- {"checkboxId": "6ba7b810-9dad-11d1-80b4-00c04fd430c8", "radioGroupId": "utg-output-choice-group-unknown_comment_id"} --> Commit unit tests in branch `task/520-fix-gateway-registry-adopt-agentflare-db`
</details>
</details>
<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->
---
<sub>Comment `@coderabbitai help` to get the list of available commands.</sub>
<!-- tips_end -->
|
Preventive follow-up to item #519 (PR #572).
gateway-registry'sdb.rsexplicitly mirrorsskill-registry's pre-migrationapply_schema()pattern. Audited its git history (#104 -> #158 -> #347): thetoolstable's columns have never changed since creation, so there's no live bug today -- but it carries the identical architectural gap (nouser_version, hand-rolled schema) and would hit the same class of bug the first time a column is added.Migrates to
agentflare-db-kit'sopen_file/open_memorywith a real migration list:0001_initial.sqlreplays the original (Add gateway_search/gateway_execute: aggregate downstream MCP servers behind 2 tools #104) narrow schema (toolstable + old standalonetools_fts)0002_fts_triggers.sqlunconditionally drops and recreatestools_ftsas the external-content shape with sync triggers plus a backfill -- noALTER TABLE/hook needed here sincetools's columns are stable (simpler than the skill-registry fix)Added
GatewayError::DbInitfordb_kit::open::Errorplus itserror_kindmatch arm.Test plan
cargo test -p agentflare-gateway-registry --lib(60/60, including the existing legacy-standalone-FTS conversion test)cargo clippy -p agentflare-gateway-registry --all-targets --all-features -- -D warnings -A unsafe_code -A clippy::pedantic(clean)cargo fmt -p agentflare-gateway-registry -- --check(clean)cargo check -p agentflare --bin agentflare(full binary compiles)Summary by CodeRabbit
New Features
Improvements