Skip to content

feat(auto-route): add ignore_pour_layers option for automatic GND pours #47

Description

@biosshot

Summary

Add an ignore_pour_layers input option to the auto_route MCP tool. The option must exclude selected copper layers from the automatic full-board GND pours created after autoroute import.

This option affects only the generated GND pours. It must not change the layers available to the autorouter and must not disable GND stitching vias.

Motivation

auto_route currently creates or rebuilds a full-board GND pour on every copper layer when pour_gnd is enabled. Some boards need signal-only layers, controlled impedance layers, antenna keepout layers, or layers whose copper pours will be created manually.

At the moment, avoiding a GND pour on one of these layers requires disabling all automatic GND pours with pour_gnd: false. Users should be able to keep automatic pours enabled while excluding individual layers.

This is a small extension of the existing full-board GND pour implementation. It is not intended to introduce or define the API of the future polygon engine.

Proposed API

Add the following property to AutoRouteInputSchema in mcp/src/tools/pcb/pcb-routing.ts:

ignore_pour_layers: z
    .array(PcbRoutingLayerSchema)
    .default([])
    .describe(
        'Copper layers excluded from automatic GND pours, e.g. ["TOP"] or ["INNER_1","INNER_2"]. Does not affect routing or GND stitching vias.',
    ),

Use the plural name ignore_pour_layers, because the option accepts multiple layers.

Example

{
  "route_layers": ["TOP", "BOTTOM"],
  "pour_gnd": true,
  "ignore_pour_layers": ["TOP"],
  "suture_gnd": true
}

Expected result:

  • the autorouter may route tracks on both TOP and BOTTOM;
  • the generated full-board GND pour is created on BOTTOM but not on TOP;
  • GND stitching vias are still generated according to the existing suture settings.

Required changes

MCP server

  • Add ignore_pour_layers to AutoRouteInputSchema with an empty-array default.
  • Pass the value through the import-pcb-autoroute-json bridge request.
  • Use camelCase (ignorePourLayers) in the internal bridge payload, consistently with the existing pourGround and sutureGround fields.
  • Do not reuse or modify route_layers: routing layer selection and pour layer exclusion are separate concerns.

EasyEDA client bridge

  • Read and validate body.ignorePourLayers as a string array.
  • Pass the normalized values to pourDefaultGroundAndSutureVias().
  • Missing input must behave as an empty exclusion list for backward compatibility.

GND pour generation

  • Extend the existing ground-pour options with ignorePourLayers?: string[].
  • Filter the result of getCopperLayers() by its canonical names: TOP, BOTTOM, and INNER_1 through INNER_30.
  • Continue removing previous Copilot-generated GND pours before rebuilding. This ensures that a pour generated by an earlier run is also removed when its layer is excluded by a later run.
  • Never delete user-created pours. Cleanup must remain limited to pours whose names start with the existing Copilot GND pour prefix.
  • Do not apply the exclusion list to GND stitching vias.

Behavior and edge cases

  • Default ignore_pour_layers: [] preserves the current behavior.
  • When pour_gnd is false, ignore_pour_layers has no effect.
  • Layers listed in ignore_pour_layers may still be used for routing when included in route_layers.
  • Duplicate layer names must not cause errors or otherwise change the result.
  • The Zod schema must reject unsupported layer names.
  • Layers that are valid copper layer names but are not present in the current PCB stack may be ignored without failing the autoroute operation.
  • If every copper layer in the current stack is excluded, remove existing Copilot-generated GND pours, create no new pours, emit a clear warning, and allow the successful route import to remain successful.
  • An empty or missing board outline must keep the existing warning/error behavior.

Acceptance criteria

  • auto_route exposes ignore_pour_layers with a default value of [].
  • Omitting the option produces exactly the same GND pours as before this change.
  • ignore_pour_layers: ["TOP"] prevents creation of the Copilot GND pour on TOP.
  • Non-excluded copper layers still receive their generated GND pours.
  • A Copilot GND pour left on an excluded layer by a previous run is removed during rebuild.
  • User-created pours are not deleted or modified.
  • route_layers behavior is unchanged.
  • GND stitching via behavior is unchanged.
  • Unsupported layer names are rejected by input validation.
  • Excluding all current copper layers does not make a successfully imported autoroute result fail.
  • Automated tests cover the default, one excluded outer layer, one excluded inner layer, duplicate exclusions, and all layers excluded.
  • The auto_route documentation includes an example that explains the difference between route_layers and ignore_pour_layers.

Out of scope

  • A generic polygon or copper-pour engine.
  • Creating pours for nets other than GND.
  • Per-layer clearance, priority, thermal relief, or polygon geometry settings.
  • Changing how GND stitching via candidates are generated.
  • Changing the pour_gnd or suture_gnd defaults.
  • Removing the existing post-autoroute GND workflow.

Implementation notes

The current data flow is:

AutoRouteInputSchema
    -> import-pcb-autoroute-json bridge request
    -> pourDefaultGroundAndSutureVias()
    -> drawDefaultGroundPours()
    -> getCopperLayers()

The exclusion list should be threaded through this path and applied only when drawDefaultGroundPours() selects the copper layers to rebuild. Keeping the filter near the existing layer enumeration prevents accidental coupling with autorouter layer selection.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions