Skip to content

[Feature] Add backend-driven layer schema endpoint to keep canvas layers and model compiler in sync #271

@Shivampal157

Description

@Shivampal157

Problem

Layer definitions are currently split across frontend and backend with no machine-readable shared contract.

This can cause UI/compiler drift:

  • frontend exposes a layer and its params
  • backend model generation does not support the same node type or validation rules

Recent bug reports show this mismatch risk in practice.

Why this matters

  • Users can build graphs that look valid in UI but fail at compile/train time
  • Adding new layers requires touching multiple files with duplicated metadata
  • Validation logic becomes inconsistent across frontend and backend

Proposed solution

Introduce a backend-driven layer schema endpoint (single source of truth), e.g.:

GET /api/layers/schema

Each layer schema entry should include:

  • type (e.g., customdense, customdropout)
  • display metadata (label, category)
  • parameter definitions (name, type, required, defaults, min/max/options)
  • backend support flag/version (for safe rollout)
  • validation constraints and error messages

Frontend should render node config forms and save guards from this schema instead of hardcoded per-layer forms.

Scope

  1. Backend:
    • create schema model + endpoint
    • centralize layer metadata in one registry
  2. Frontend:
    • consume endpoint
    • render dynamic layer parameter forms
    • use schema-based validation before save/train
  3. Compiler:
    • ensure schema-backed node types map to supported build handlers
  4. Tests:
    • contract tests for schema shape
    • integration test for at least one layer end-to-end from schema -> UI payload -> compiler

Acceptance criteria

  • Backend exposes GET /api/layers/schema with typed param constraints
  • Frontend no longer hardcodes layer form logic for core layers
  • Save/train validation uses shared schema constraints
  • New layer addition requires only registry/schema + compiler handler (no duplicated UI validation logic)
  • Tests cover contract consistency between schema and compiler support

Expected impact

  • Prevents future UI/backend layer mismatches
  • Reduces maintenance overhead when adding new layers
  • Improves reliability of visual model-building workflow

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions