Skip to content

api: make pool-config and worker-selection methods required on SubstrateAdapter #884

Open

Description

@SamGanYX

Problem

In crates/libs/api/src/controllers/substrate/mod.rs, four methods on SubstrateAdapter still carry default implementations that return SubstrateError::Unsupported:

  • list_pool_configs (mod.rs:1609)
  • upsert_pool_config (mod.rs:1616)
  • disable_pool_config (mod.rs:1626)
  • select_ready_worker_node_api_target (mod.rs:1648 — already implemented by both DirectSubstrate and KubernetesSubstrate and forwarded by Substrate, making the trait default dead code)

crates/libs/api/src/controllers/substrate/AGENTS.md states that SubstrateAdapter operations must be required methods so the compiler enforces an explicit implementation on each substrate and a forwarding arm in impl SubstrateAdapter for Substrate, and notes that the Unsupported trait defaults on list_pool_configs, upsert_pool_config, and disable_pool_config are debt.

Why it matters

Default Unsupported bodies on SubstrateAdapter weaken compile-time exhaustiveness across substrates: a missing arm in impl SubstrateAdapter for Substrate or on a substrate implementation silently returns 501 Not Implemented instead of failing to compile.

Proposed approach

  1. Remove the default bodies from list_pool_configs, upsert_pool_config, disable_pool_config, and select_ready_worker_node_api_target on trait SubstrateAdapter in crates/libs/api/src/controllers/substrate/mod.rs.
  2. Add explicit list_pool_configs, upsert_pool_config, and disable_pool_config implementations to impl SubstrateAdapter for DirectSubstrate in crates/libs/api/src/controllers/substrate/direct.rs returning the same SubstrateError::Unsupported error.
  3. Update crates/libs/api/src/controllers/substrate/AGENTS.md to remove the resolved trait-default debt reference.

Severity

Low (compile-time contract hardening; zero runtime behavior change).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions