Skip to content

feat: typed V2 plan authoring facades for Python and Node #195

Description

@ds1sqe

Summary

Ship idiomatic typed plan-authoring facades for Python and TypeScript
over the V2 prepared-query surface. Both bindings can already execute
prepared V2 plans (canonical plan bytes plus invocation JSON through the
native query_v2_runtime modules), but plans themselves can only be
authored in Rust; the cross-binding smoke tests embed Rust-generated
base64 plan fixtures.

Problem

The 2.0.0 contract deliberately scopes plan authoring to Rust: the
upgrade guide states binding facades follow in a later 2.0.x release.
Until they exist, a Python or TypeScript application that wants a new
query shape needs a Rust toolchain to produce the canonical plan bytes,
which undercuts the promise of one semantic engine reachable from every
binding.

Why

This is a multi-flight feature — a new native API surface across two
bindings plus full test matrices — and it no longer blocks 2.0.0: no
released document claims binding-level authoring exists, and no removal
is justified by it. It deserves its own tracked delivery rather than a
tail-end slice of the audit-remediation program.

Proposed change

  • Opaque native builder handles. Plan construction happens inside
    the native module through PyO3 / N-API handles; host languages never
    see or assemble serialized plan structure. The existing Rust
    QueryPlan constructors remain the single validation authority.
  • Python facade with complete type stubs. A typed builder API in
    type_bridge producing prepared plans that feed the existing
    execute/encode/decode functions unchanged.
  • TypeScript facade with generated declarations. The same builder
    shape through N-API, with .d.ts coverage and no never/unsafe
    casts in the public path.
  • Authoring test matrices. Representative basic and advanced plans
    (function calls, reduce, try, documents, bounded reachability)
    authored through the public facades in both bindings and executed
    both locally and through the versioned remote envelope against
    released artifacts — no embedded plan bytes anywhere in the suites.
  • Docs. The upgrade guide's plan-authoring scoping disclosure is
    replaced by documentation of the shipped surface.

Acceptance criteria

  • Python can author every plan shape the canonical vocabulary
    admits through a typed public facade with full stubs
  • TypeScript can author the same shapes with generated declarations
    and no unsafe casts in the public path
  • The cross-binding smoke suites author their plans through the
    public facades instead of embedded base64 fixtures
  • Authored plans execute locally and through the remote envelope
    with outcomes identical to Rust-authored equivalents
  • The upgrade guide documents the shipped authoring surface

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions