Skip to content

refactor: switch TCbuffer regular families to the generated mixin#90

Open
estebanzimanyi wants to merge 1 commit into
refactor/oo-codegen-meos-idlfrom
refactor/oo-codegen-tcbuffer-switch
Open

refactor: switch TCbuffer regular families to the generated mixin#90
estebanzimanyi wants to merge 1 commit into
refactor/oo-codegen-meos-idlfrom
refactor/oo-codegen-tcbuffer-switch

Conversation

@estebanzimanyi
Copy link
Copy Markdown
Member

The vertical-slice full working solution for the meos-idl.json-driven
OO codegen: TCbuffer's regular method families are now served by generated
code, wired into the class, with the existing test suite proving behavioural
equivalence.

What changed

  • Generator (tools/oo_codegen/codegen.py): a behaviourally-faithful
    --mixin emitter that reproduces the hand-written isinstance ladder,
    argument transforms (geo_to_gserialized, STBox border flag, distance
    arg), result post-processing (> 0 / == 1 / Temporal._factory /
    shapely / raw) and the super()/raise fallback exactly. Only
    modelled families are wired (one family per PR). The Draft _preview/
    path and the feat: meos-idl.json-driven OO method-family codegen (Draft preview) #89 coverage gate are untouched.
  • pymeos/main/_generated/tcbuffer_methods.py: generated
    TCbufferRegularMixin — 30 regular methods, each dispatching to the
    exact pymeos_cffi backing the hand-written method used.
  • pymeos/main/tcbuffer.py: inherits the mixin; the 30 now-generated
    regular methods are removed. never_* and the irregular hand-written
    core are kept.
  • Provenance: regen-from-meos-api.sh + README — the catalog is
    byte-schema-identical to MEOS-API run.py output and the generator runs
    unchanged on it (proven: a fresh run.py over local headers → 3544 fns →
    --check PASS).

Proof (the convincing artifact)

tests/main/tcbuffer_test.py is byte-identical before and after the
switch
: 26 passed, 1 failed. All 26 temporal TCbuffer* tests pass,
including every regular family the codegen serves (EverAlways, Distance,
SpatialRelationships). The single failure is TestCbuffer::test_from_as_hexwkb
— a pre-existing, unrelated pymeos_cffi cbuffer_as_hexwkb out-parameter
bug in the base Cbuffer class
(not temporal, not the codegen, not the
stubs); identical with or without this PR. Static check: 30/30 generated
methods are backing-and-fallback identical
to the hand-written oracle.

Stack / dependencies

Stacked on #89 (Draft codegen) → #88 (extended types). This relies on
#88 being instantiable: #88 was amended to add documented NotImplementedError
value-accessor stubs for TCbuffer (MEOS exposes no typed tcbuffer_* value
accessor / tcbufferinst_make; MF-JSON tracked upstream by MobilityDB#1051),
which makes the suite collectable. CI note: the bump/meos-1.4 base line does
not trigger test.yml, so these suites were never run in CI before — this PR
establishes the green proof locally.

Follow-up

Fan-out to the other five families (TNpoint also needs its NpointSet
abstract surface; TPose needs 2 ctor stubs) — each its own slice, same
pattern.

Promotes the meos-idl.json-driven OO codegen from Draft preview to a
wired-in solution for the TCbuffer vertical slice.

- Generator (tools/oo_codegen/codegen.py): adds a behaviourally-faithful
  emitter (--mixin) that reproduces the hand-written isinstance ladder,
  argument transforms, result post-processing and super()/raise fallback
  exactly; only modelled families are wired (one family per PR). The
  Draft _preview/ path and the #89 coverage gate are unchanged.
- pymeos/main/_generated/tcbuffer_methods.py: generated TCbufferRegularMixin
  (30 regular methods: comparison, spatial relationship, distance,
  restriction), each dispatching to the exact pymeos_cffi backing the
  hand-written method used.
- pymeos/main/tcbuffer.py: inherits TCbufferRegularMixin; the 30
  now-generated regular methods are removed (never_* and the irregular
  hand-written core are kept).
- Provenance: regen-from-meos-api.sh + README document that the catalog
  is byte-schema-identical to MEOS-API run.py output and the generator
  runs unchanged on it.

Behavioural equivalence is proven by the existing suite: the full
tests/main/tcbuffer_test.py is byte-identical before and after the
switch -- 26 passed, 1 failed, where the single failure is a pre-existing
unrelated pymeos_cffi cbuffer_as_hexwkb out-parameter bug in the base
Cbuffer class (not temporal, not codegen). Static check: 30/30 generated
methods are backing-and-fallback identical to the hand-written oracle.

Stacked on #89; relies on #88's TCbuffer being instantiable.
estebanzimanyi added a commit that referenced this pull request May 19, 2026
Implements the PyMEOS-side follow-up of RFC #94 §5: a consumer that
emits faithful geo/temporal mixins from the canonical
oo.<family>.<member>.dispatch blocks the parallel MEOS-API session is
adding to meta/meos-meta.json (merged into meos-idl.json).

Additive only -- the 4 shipped families' FAMILY_MODEL path
(emit_faithful_mixin) is untouched; #90/#91/#92/#93 mixins regenerate
byte-identical (regression-guarded) and #89 coverage gate stays green.

Proven correct WITHOUT waiting on the not-yet-published metadata:
_serialize_family_dispatch() expresses each of the 4 A/B-proven families
(cbuffer/pose/npoint/rgeo) in the RFC #94 §3 schema; feeding those back
through emit_from_oo_dispatch() reproduces their committed mixins
BYTE-IDENTICALLY for all 4 (the new --verify-oo-roundtrip gate +
OoDispatchConsumer test, permanently enforced). geo/temporal then plug
into this same proven consumer the instant MEOS-API emits their
oo.dispatch (via --mixin-from-dispatch), closing codegen 6/6 -- no
PyMEOS-local transcription, equivalence by construction at the catalog
level.

This is the non-wasted parallel prep: when the keystone enrichment
lands, PyMEOS converges immediately. Stacked on #94 (the RFC).
estebanzimanyi added a commit that referenced this pull request May 19, 2026
Implements the PyMEOS-side follow-up of RFC #94 §5: a consumer that
emits faithful geo/temporal mixins from the canonical
oo.<family>.<member>.dispatch blocks the parallel MEOS-API session is
adding to meta/meos-meta.json (merged into meos-idl.json).

Additive only -- the 4 shipped families' FAMILY_MODEL path
(emit_faithful_mixin) is untouched; #90/#91/#92/#93 mixins regenerate
byte-identical (regression-guarded) and #89 coverage gate stays green.

Proven correct WITHOUT waiting on the not-yet-published metadata:
_serialize_family_dispatch() expresses each of the 4 A/B-proven families
(cbuffer/pose/npoint/rgeo) in the RFC #94 §3 schema; feeding those back
through emit_from_oo_dispatch() reproduces their committed mixins
BYTE-IDENTICALLY for all 4 (the new --verify-oo-roundtrip gate +
OoDispatchConsumer test, permanently enforced). geo/temporal then plug
into this same proven consumer the instant MEOS-API emits their
oo.dispatch (via --mixin-from-dispatch), closing codegen 6/6 -- no
PyMEOS-local transcription, equivalence by construction at the catalog
level.

This is the non-wasted parallel prep: when the keystone enrichment
lands, PyMEOS converges immediately. Stacked on #94 (the RFC).
estebanzimanyi added a commit that referenced this pull request May 19, 2026
Implements the PyMEOS side of RFC #94 §5/§7: a consumer that emits
faithful geo/temporal mixins from the canonical objectModel.dispatch
metadata (MEOS-API #10 feat/object-model, merged into meos-idl.json),
closing the OO codegen to all 6 temporal type families with
equivalence by construction at the catalog level.

Additive only — the 4 derivable families' FAMILY_MODEL path
(emit_faithful_mixin) is untouched; #90/#91/#92/#93 mixins regenerate
byte-identical (--verify-oo-roundtrip + OoDispatchConsumer
.test_roundtrip_byte_identical, permanently enforced) and the #89
coverage gate stays green.

geo + the 4 temporal concretes (TFloat/TInt/TBool/TText) are not
derivable from the signature catalog (RFC #94 §1), so they are driven
by the verbatim objectModel.dispatch metadata and proven equivalent to
the hand-written oracle by dispatch-skeleton equality:

  * tools/oo_codegen/_d1-dispatch-extended-fixture.json — the verbatim
    §7 dispatch metadata (== MEOS-API #10 objectModel.dispatch).
  * tools/oo_codegen/_oracle_extended_methods.py — the byte-for-byte
    hand-written editorial methods (AST-extracted) the proof checks
    against; never executed, never imported.
  * --verify-oo-dispatch-extended + OoDispatchConsumer
    .test_extended_dispatch_matches_oracle: each of the 32 editorial
    methods (geo at/minus/distance/nearest_approach_distance + each
    concrete's always/ever/temporal eq·ne, at, minus) reduces to an
    identical ordered dispatch skeleton — isinstance type-set, backing
    symbol, arg transform, super-coerce, fallback, result wrap. 0
    divergence: same native calls, same transforms, never reimplemented.

The closed argTransform vocabulary maps to PyMEOS idioms
(scalarValue, scalarCast-per-base, geoToGserialized with
geodeticFromSelf, stboxToGeo, innerPtr, textsetMake, list[str],
coerce + via:super).

Stacked on #94 (the RFC, including the verbatim §7 SoT).
estebanzimanyi added a commit that referenced this pull request May 19, 2026
Implements the PyMEOS side of RFC #94 §5/§7: a consumer that emits
faithful geo/temporal mixins from the canonical objectModel.dispatch
metadata (MEOS-API #10 feat/object-model, merged into meos-idl.json),
closing the OO codegen to all 6 temporal type families with
equivalence by construction at the catalog level.

Additive only — the 4 derivable families' FAMILY_MODEL path
(emit_faithful_mixin) is untouched; #90/#91/#92/#93 mixins regenerate
byte-identical (--verify-oo-roundtrip + OoDispatchConsumer
.test_roundtrip_byte_identical, permanently enforced) and the #89
coverage gate stays green.

geo + the 4 temporal concretes (TFloat/TInt/TBool/TText) are not
derivable from the signature catalog (RFC #94 §1), so they are driven
by the verbatim objectModel.dispatch metadata and proven equivalent to
the hand-written oracle by dispatch-skeleton equality:

  * tools/oo_codegen/_d1-dispatch-extended-fixture.json — the verbatim
    §7 dispatch metadata (== MEOS-API #10 objectModel.dispatch).
  * tools/oo_codegen/_oracle_extended_methods.py — the byte-for-byte
    hand-written editorial methods (AST-extracted) the proof checks
    against; never executed, never imported.
  * --verify-oo-dispatch-extended + OoDispatchConsumer
    .test_extended_dispatch_matches_oracle: each of the 32 editorial
    methods (geo at/minus/distance/nearest_approach_distance + each
    concrete's always/ever/temporal eq·ne, at, minus) reduces to an
    identical ordered dispatch skeleton — isinstance type-set, backing
    symbol, arg transform, super-coerce, fallback, result wrap. 0
    divergence: same native calls, same transforms, never reimplemented.

The closed argTransform vocabulary maps to PyMEOS idioms
(scalarValue, scalarCast-per-base, geoToGserialized with
geodeticFromSelf, stboxToGeo, innerPtr, textsetMake, list[str],
coerce + via:super).

Stacked on #94 (the RFC, including the verbatim §7 SoT).
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