Repository navigation
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 -->
|
* feat(item): add plan-gate pure logic module (item #573) Agentflare-Agent: claude-code_2-1-272_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: b2a9a8b7-a892-4ace-bc24-64c355019547 * feat(item): block claim() on an unapproved plan gate (item #573) Agentflare-Agent: claude-code_2-1-272_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: b2a9a8b7-a892-4ace-bc24-64c355019547 * feat(supervisor): skip plan-gated items in automatic dispatch (item #573) Agentflare-Agent: claude-code_2-1-272_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: b2a9a8b7-a892-4ace-bc24-64c355019547 * test(supervisor): assert dispatched job belongs to the approved item (item #573) Agentflare-Agent: claude-code_2-1-272_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: b2a9a8b7-a892-4ace-bc24-64c355019547 * feat(item): add plan_asset_id/plan_approver/reason fields and dispatch entries (item #573) Agentflare-Agent: claude-code_2-1-272_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: b2a9a8b7-a892-4ace-bc24-64c355019547 * feat(item): implement submit_plan/approve_plan/reject_plan (item #573) Agentflare-Agent: claude-code_2-1-272_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: b2a9a8b7-a892-4ace-bc24-64c355019547 * feat(supervisor): generalize Telegram approval flow for plan approval (item #573) Agentflare-Agent: claude-code_2-1-272_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: b2a9a8b7-a892-4ace-bc24-64c355019547 * feat(item): apply default plan-gate policy at create/update (item #573) Agentflare-Agent: claude-code_2-1-272_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: b2a9a8b7-a892-4ace-bc24-64c355019547 * fix: enforce human plan-approval, surface stalled auto-gated items, and other final-review fixes (item #573) Agentflare-Agent: claude-code_2-1-272_harness Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: 5c8c7535-39a4-4662-9251-0f3295609583 * fix: namespace the plan-gate ping dedup key, fix a stray fmt violation (item #573) Agentflare-Agent: claude-code_2-1-272_harness Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: 5c8c7535-39a4-4662-9251-0f3295609583 * Fix CodeRabbit findings on the plan-approval gate: self-approval bypass, malformed-metadata gate bypass, and metadata smuggling - item_submit_plan could not be downgraded from a stored plan_approver="human" by a caller-supplied plan_approver, closing a self-approval bypass where an agent could submit_plan(plan_approver="agent") then approve_plan itself on a human-gated item (Critical). - read_plan_gate now extracts each plan-gate field independently instead of one whole-struct deserialize, so a malformed unrelated field (e.g. a string plan_approved_at) can no longer fall back to PlanGateMeta::default() and silently open a plan_required=true gate (Major). - item_create/item_update now strip the server-authoritative plan-transition fields (plan_status, plan_approved_by, plan_approved_at, plan_rejection_reason) from caller metadata, so a caller can no longer create/update an item straight into plan_status="approved" (Major). - Corrected the plan_approver field's schemars description: it is read by submit_plan only, not create/update (Minor). Agentflare-Agent: claude-code_2-1-273_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: 61cf1e19-60fe-45bf-bcf6-8e9a434e297b * Fix CodeRabbit finding: keep the plan-approval Telegram button on a failed approval so a human can retry Agentflare-Agent: claude-code_2-1-273_agent Agentflare-Branch: task/573-feat-plan-mode-style-approval-gate-befor Agentflare-Item: 573 Agentflare-Session: 61cf1e19-60fe-45bf-bcf6-8e9a434e297b
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