Skip to content

pxf: cpp pin to v0.75.0 + Result.directives/tables + validate_descriptor#6

Merged
trendvidia merged 1 commit into
mainfrom
cpp-pin-and-result-accessors
May 12, 2026
Merged

pxf: cpp pin to v0.75.0 + Result.directives/tables + validate_descriptor#6
trendvidia merged 1 commit into
mainfrom
cpp-pin-and-result-accessors

Conversation

@trendvidia
Copy link
Copy Markdown
Owner

Summary

First of three PRs in the Python v0.72–v0.75 catch-up. The sibling `protowire-cpp` shipped its v0.72-series feature set on v0.75.0 (cpp PRs #9 / #11 / #12 / #13 / #14). This PR:

  1. Bumps the CI cpp pin from the pre-v0.72 commit `9af2ec0` to the `v0.75.0` tag (3 workflows).
  2. Exposes the new pxf surface through the nanobind FFI:
    • `pxf.Result.directives` / `pxf.Result.tables` populated by `unmarshal_full`.
    • `pxf.Directive` / `pxf.TableDirective` frozen dataclasses (raw body bytes preserved verbatim; cells modeled as None / (kind, value) 2-tuples for the three-state grammar).
    • `pxf.validate_descriptor(msg)` + `pxf.Violation` for the schema reserved-name check (draft §3.13).
    • `skip_validate` keyword on `unmarshal` / `unmarshal_full` and the `_bytes` variants.

PR 2 will add `TableReader` streaming + `bind_row` (the iterator-protocol piece). PR 3 will cut v0.75.0.

Test plan

  • 16 new tests in `tests/test_pxf_directives.py` covering Result accessors, three-state cells, multi-table, directive+table coexistence, the validate_descriptor surface, skip_validate, and the Violation dataclass
  • All 62 tests pass locally (46 on main → +16 new)
  • CI green (Linux / macOS / Windows × Python 3.10–3.13, codeql)

First PR of the Python v0.72-v0.75 catch-up. The sibling cpp port
shipped its v0.72-series feature set on v0.75.0 (PRs #9 / #11 / #12
/ #13 / #14). This PR bumps the CI cpp pin from the pre-v0.72 commit
9af2ec0 to the v0.75.0 tag and exposes the new pxf surface through
the nanobind FFI.

Python surface additions (in src/protowire/pxf.py):
  - pxf.Result gains `directives: tuple[Directive, ...]` and
    `tables: tuple[TableDirective, ...]`, populated by
    `unmarshal_full`. Backward compat: existing
    set_paths / null_paths / is_set / is_null / is_absent /
    null_fields unchanged.
  - pxf.Directive(name, prefixes, type, body, has_body, line, column)
    is a frozen dataclass. body is the verbatim bytes between `{`
    and `}`; type keeps v0.72.0 single-prefix back-compat.
  - pxf.TableDirective(type, columns, rows) with cells modeled as
    None (absent) or (kind, value) 2-tuples. kind ∈ {null, string,
    int, float, bool, bytes, ident, timestamp, duration} — faithful
    to the three-state cell grammar (draft §3.4.4).
  - pxf.validate_descriptor(msg) → list[Violation] for the schema
    reserved-name check (draft §3.13).
  - pxf.Violation(kind, element, name, file) frozen dataclass.
  - skip_validate keyword on unmarshal / unmarshal_full and their
    _bytes variants.

FFI (src/_protowire/module.cc):
  - PxfValidateDescriptor returns list of (kind, element, name, file)
    tuples that pxf.py wraps into Violation dataclasses.
  - PxfUnmarshalFull now returns 5 elements: bytes, set_paths,
    null_paths, directives, tables. Cells are marshalled as either
    nb::none() (absent) or (kind, value) tuples via the visit-based
    CellToPyTuple helper.
  - skip_validate plumbed through PxfUnmarshal and PxfUnmarshalFull.

Tests (16 new in tests/test_pxf_directives.py, 62 total):
  - Result.directives / Result.tables across all shapes
  - Three-state cells, multi-table, directive+table coexistence
  - validate_descriptor against the conformant test schema
  - skip_validate happy path
  - Violation dataclass shape + frozen-instance check
@trendvidia trendvidia merged commit a3405fd into main May 12, 2026
18 checks passed
@trendvidia trendvidia deleted the cpp-pin-and-result-accessors branch May 12, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant