Skip to content

Pipeline runner: flatten step / arr[] $ref grammar for grid fan-out (child of #94) #113

Description

@serge-ivo

Gap found by the #94 capstone (lead-finder declarative pipeline, workers/api/src/lib/pipelines/lead-finder.test.ts, "GAP #1").

Problem. The lead-finder recipe sweeps a grid of cells and runs one Places searchNearby per cell. Expressed declaratively that is fan_out (grid) → http_request with forEach: {$ref:"grid.cells"}. But a forEach step whose per-item tool returns an ARRAY (a page of places) binds an array-of-arrays [[place,…],[place,…]]. Nothing in the current step library or $ref grammar flattens it: map treats each inner array as a non-record and emits one {} per CELL, not per place. So the grid source cannot feed map/filter/dedupe_upsert.

Evidence. map([[{place_id:a}],[{place_id:b},{place_id:c}]])count:2 (cells), not 3 (places). Asserted in the capstone test.

Consequence. The shipped reference JSON (lead-finder.json) falls back to a SINGLE searchNearby at the geocoded centre — it drops the grid, so it covers less area than the live worker.

Proposed fix (pick one):

  1. A first-party flatten step ({items: $ref, depth?}) that concatenates an array-of-arrays — smallest, composes with everything.
  2. A flatten:true option on map/filter that pre-concats array-of-array items.
  3. A $ref array-projection grammar (grid.cells[].places) mirroring the responseMap arr[] grammar in connectors/http.ts.

Option 1 is the cleanest declarative primitive. Blocks the grid half of the epic proof.

Part of #94.

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