Skip to content

feat(pull): delegate schema pull to the data plane engine capability - #1022

Draft
aparajon wants to merge 1 commit into
mainfrom
armand/pull-engine-capability
Draft

feat(pull): delegate schema pull to the data plane engine capability#1022
aparajon wants to merge 1 commit into
mainfrom
armand/pull-engine-capability

Conversation

@aparajon

Copy link
Copy Markdown
Collaborator

Summary

Pull support becomes the data plane's answer instead of a control-plane type gate. Whether a database type supports pull depends on which engine backs the deployment — something only the data plane knows — so the control plane now dispatches the pull unconditionally and derives the 501 from the reply.

before:  control plane ──[type gate: mysql|vitess only]──> data plane
after:   control plane ──────────────────────────────────> data plane
                                                             ├─ mysql/vitess: built-in pull paths (unchanged)
                                                             ├─ engine implements SchemaPuller: delegate
                                                             └─ otherwise: ErrPullSchemaUnsupportedType (fail closed)
  • pkg/tern: new SchemaPuller capability interface. LocalClient.PullSchema keeps the built-in MySQL/Vitess paths and delegates any other database type to the registered engine's capability — failing closed with ErrPullSchemaUnsupportedType when the engine doesn't provide it, on a nil engine response, and wrapping engine errors with database/type context. The request-type mismatch check now runs before dispatch.
  • pkg/api: the ExecutePullSchema type gate is deleted. A named predicate converts the data plane's "unsupported" reply — the typed sentinel locally, codes.Unimplemented from a remote deployment only — into the existing 501 error. Other pull failures pass through untouched, and the raw error is still logged with full routing detail before conversion.

No behavior change for mysql/vitess/postgres. Types without an engine capability move from a control-plane 501 to a data-plane 501 with the same HTTP status and message.


🤖 This PR was written by Claude Code (Claude Fable 5).

Pull support becomes the data plane's answer instead of a control-plane
type gate. LocalClient keeps the built-in MySQL/Vitess pull paths and
delegates any other database type to the configured engine's new
SchemaPuller capability, failing closed with ErrPullSchemaUnsupportedType
when the engine does not provide it. The control plane dispatches the
pull unconditionally and converts the data plane's unsupported reply
(the typed sentinel locally, codes.Unimplemented from a remote
deployment) into the same 501 response as before.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings August 13, 2026 10:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR shifts pull schema support determination from the control plane’s database-type gate to the data plane’s engine capabilities, so the control plane always dispatches pull and derives a 501 only from an “unsupported” response.

Changes:

  • Adds a SchemaPuller engine capability and updates LocalClient.PullSchema to delegate non-MySQL/Vitess pulls to the configured engine (failing closed when unsupported).
  • Removes the control-plane type gate in ExecutePullSchema and converts data-plane “unsupported” signals (local sentinel or remote codes.Unimplemented) into the existing 501.
  • Adds/updates tests to cover delegation, unsupported handling, and type-mismatch precedence.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/tern/local_client.go Delegates non-MySQL/Vitess pulls to an engine capability via a new helper.
pkg/tern/local_client_test.go Adds tests for delegation, unsupported capability behavior, and error cases.
pkg/tern/client.go Introduces the SchemaPuller capability interface.
pkg/api/plan_handlers.go Removes type gate and derives 501 from data-plane “unsupported” outcomes.
pkg/api/handlers_test.go Updates tests to validate unsupported conversion behavior for local vs remote clients.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +3745 to +3749
_, err := client.PullSchema(t.Context(), &ternv1.PullSchemaRequest{Database: "orders"})

require.Error(t, err)
assert.Contains(t, err.Error(), "nil response")
}
Comment thread pkg/api/plan_handlers.go
Comment on lines 62 to 64
func (e *unsupportedPullSchemaError) Error() string {
return fmt.Sprintf("pull schema supports %s and %s databases; got %s", storage.DatabaseTypeMySQL, storage.DatabaseTypeVitess, e.DatabaseType)
}
Comment thread pkg/tern/local_client.go
Comment on lines +649 to +651
if resp == nil {
return nil, fmt.Errorf("engine pull schema for database %s type %s returned a nil response", c.config.Database, c.config.Type)
}
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.

2 participants