Skip to content

Releases: ds1sqe/type-bridge

v1.4.4 — Cross-Type Attribute Lookup

09 Apr 08:48
ac51343

Choose a tag to compare

New Features

Cross-type attribute lookup (#117)

Entity.has / Relation.has / <Concrete>.has — find all instances that own a given attribute, optionally filtered by value or expression.

Python ORM — type_bridge.crud.has_lookup

  • Cross-type formEntity.has(db, Name) returns mixed concrete subtypes across all entities owning Name
  • Concrete-class narrowingHLPerson.has(db, Name) narrows to that type and its TypeDB subtypes via isa polymorphism. Abstract base subclasses get subtype matching for free
  • Role-player hydration — relation results always include hydrated role players. Entity lookups remain single-query; relations are re-fetched per result through concrete_class.manager(connection).get(_iid=iid)
  • Attribute.get_owners() — static discovery of attribute owners without a database connection, backed by a reverse _attribute_owners index in ModelRegistry

Bug Fix

  • type_bridge.__version__ corrected — was stale at 1.4.1 since the v1.4.2 and v1.4.3 bump commits missed it

Install

pip install type-bridge==1.4.4
# Cargo.toml
[dependencies]
type-bridge-core-lib = "1.4.4"

Full Changelog: v1.4.3...v1.4.4

v1.4.3

06 Apr 01:09
318c5a9

Choose a tag to compare

Bug Fixes

Rust Server — type-bridge-server

  • fix: extract_crud_info() now reports the write-target type for Match + Insert/Put queries (#121)
    • For Match + Insert(Relation) and Match + Put(Relation) queries, type_name was incorrectly set to the first matched entity instead of the actual relation being written
    • Downstream consumers that route or deserialize based on type_name no longer receive mismatched entity/relation data

Rust Core — type-bridge-core-lib

  • refactor: use idiomatic match guards in validation.rs

Full Changelog: v1.4.2...v1.4.3

What's Changed

  • fix(server): prefer write-clause type in extract_crud_info, bump to 1.4.3 (#121) by @ds1sqe in #122

Full Changelog: v1.4.2...v1.4.3

v1.4.2

04 Mar 10:16
ce505a7

Choose a tag to compare

What's Changed

  • feat(server): add CrudInfo, CrudInterceptor trait, and CrudInterceptorAdapter by @ds1sqe in #120

Full Changelog: v1.4.1...v1.4.2

v1.4.1 — Lifecycle Hooks & CRUD Interceptors

03 Mar 05:56

Choose a tag to compare


This release adds a three-layer lifecycle hook system for reacting to CRUD events — audit logging, input validation, cache invalidation, and async notifications — across the Python ORM, Rust ORM, and Rust server.

Highlights

  • Lifecycle hooks on Python and Rust ORM managers via add_hook() / remove_hook()
  • CRUD-aware interceptors for the Rust proxy server
  • Put (upsert) clause support in the Rust core AST
  • Server simplification — removed standalone CRUD module in favor of interceptor-based design

New Features

Lifecycle Hook System (PR #118, closes #116)

Python ORM — type_bridge.crud.hooks
  • CrudEvent enumPRE_INSERT, POST_INSERT, PRE_UPDATE, POST_UPDATE, PRE_DELETE, POST_DELETE, PRE_PUT, POST_PUT
  • CrudHook protocol — implement only the methods you need (pre_insert, post_delete, etc.)
  • HookCancelled exception — raise in a pre-hook to abort the operation
  • Per-manager registrationmanager.add_hook(hook) / manager.remove_hook(hook), chainable
  • should_run(event, sender) filtering by event type or model class
  • Pre-hooks run in registration order; post-hooks run in reverse order (middleware unwinding)
  • Zero overhead when no hooks are registered
Rust ORM — type-bridge-orm
  • LifecycleHook trait with HookContext, PreHookResult (Continue/Reject), and HookRunner
  • Integrated into EntityManager and RelationManager via add_hook()
  • Same semantics as the Python layer (registration-order pre-hooks, reverse-order post-hooks)

Put (Upsert) Clause — type-bridge-core-lib

  • Clause::Put(Vec<Statement>) for idempotent insert (upsert) operations
  • Full roundtrip support: parse → AST → compile → parse

Refactoring

Server API Simplification — type-bridge-server

  • Removed standalone CRUD module (/entities/*, /relations/*, CrudQueryBuilder, raw query) — superseded by interceptor-based design
  • Removed crud_builder benchmark and criterion dev-dependency
  • Server now has 4 endpoints: POST /query, POST /query/validate, GET /health, GET /schema

Bug Fixes

  • Export missing CrudHook protocol from top-level type_bridge package

Full Changelog: v1.4.0...v1.4.1

v1.4.0 — Rust Core Integration & Native ORM

20 Feb 04:49
1112191

Choose a tag to compare

This release introduces a complete Rust backend for TypeBridge — a ground-up rewrite of the parser, compiler, and validation engine in Rust with PyO3 bindings, plus a brand-new async Rust ORM with full Python feature parity.

Highlights

  • 5 new Rust crates: core-lib, orm, orm-derive, server, and python (PyO3 bindings)
  • Up to 40x faster validation and 2.5x faster query compilation via the Rust backend
  • Async Rust ORM with derive macros, chainable queries, and batch operations
  • Query-intercepting proxy server with REST endpoints
  • MkDocs Material documentation site

New Features

Rust Core — type-bridge-core-lib (PRs #95, #101-#108)

  • TypeQL schema parser with inheritance resolution and PyO3 bindings
  • TypeQL query parser with bidirectional AST roundtrip
  • Schema-aware query validation with statement and pattern validators
  • Rust-backed value coercion and format_value
  • Custom validation rules with portable JSON DSL
  • Wired Rust core into Python compiler and validation pipeline

Async Rust ORM — type-bridge-orm (PR #114)

  • Async ORM with entity CRUD and mock-testable session layer
  • Derive macros#[derive(TypeBridgeEntity)], #[derive(TypeBridgeRelation)], #[derive(TypeBridgeAttribute)]
  • Chainable query builders with expression filtering and aggregation
  • Schema management — registration, generation, diff, and sync
  • Abstract types with inheritance and code generation
  • Batch operationsinsert_many, delete_many, update_many
  • FieldRef<A> for type-safe query field references
  • include_schema! proc-macro for compile-time TQL codegen
  • Schema introspection from live TypeDB database
  • Group-by queries with GroupByResult
  • Role player field access for relation query filtering
  • Expression helpersin_range(), startswith(), endswith()
  • Connection pooling with Database::into_shared()
  • Serde support on all ORM model types
  • Structured tracing spans on all public methods

Query Intercept Proxy — type-bridge-server (PR #109)

  • REST CRUD endpoints with schema-aware query building
  • CrudQueryBuilder PyO3 class for TypeQL generation from Python
  • Extensible library/framework — pluggable QueryExecutor, Interceptor, SchemaSource
  • 207 tests with 100% MC/DC coverage

Performance: Python vs Rust

Benchmarked on Intel Xeon Gold 5220 (144 cores), CPython 3.13, Rust 1.95.0-nightly.

Validation

Operation Python Rust Speedup
Single type name 1.89 us 354.75 ns 5.3x
Long name (100+ chars) 24.90 us 620.52 ns 40.1x
Batch 1,000 names 5.32 ms 266.80 us 19.9x
Batch 5,000 names 28.02 ms 1.33 ms 21.1x
Unicode name 1.78 us 426.98 ns 4.2x
Role context 2.38 us 257.28 ns 9.3x
Attribute context 2.66 us 261.87 ns 10.2x

Query Compilation (via serde bridge)

Operation Python Rust Speedup
Standalone update 93.28 us 37.82 us 2.5x
Large batch (200 clauses) 2.26 ms 1.07 ms 2.1x
Heavy insert (100x6) 1.71 ms 896.19 us 1.9x
Long query (30 patterns) 156.24 us 87.61 us 1.8x
Batch (50 clauses) 209.22 us 132.88 us 1.6x
Complex (10 patterns) 40.99 us 29.43 us 1.4x

Native Rust (Criterion, no Python/serde overhead)

Operation Time
Simple match 325.69 ns
Complex 10-pattern 6.38 us
200-clause batch 251.25 us
8-hop graph traversal 14.93 us
Schema parse (120 types) 197.70 us
Type name validation 72.81 ns
Variable name validation 13.82 ns

Note: The current Python-to-Rust serde bridge adds overhead that limits E2E speedup on small queries. Direct Rust AST construction (bypassing Python dicts) would unlock the full 5-10x speedup seen in native benchmarks.


Documentation & CI

  • MkDocs + Material documentation site with auto-generated API reference (PR #98)
  • Rust crate CI with multi-platform wheel builds — Linux (x86_64, aarch64), macOS (x86_64, aarch64), Windows (x86_64) (PR #95)
  • Comprehensive benchmark suite with TOML storage, comparison reports, and markdown generation (PR #103)
  • Codecov integration for Rust coverage tracking (PR #109)

Bug Fixes

  • Resolve Rust 1.93.0 clippy lint errors
  • Pin Python 3.13 for Rust CI jobs and fix coverage script
  • Add version specifiers to inter-crate path dependencies for crates.io publishing
  • Make release workflow idempotent (skip already-published packages)

Contributors

Full Changelog: v1.3.0...v1.4.0

[v1.3.0] - API DTO Generator, Date Arithmetic, and TypeDB 3.8.0 Stable

08 Feb 23:33

Choose a tag to compare

Highlights

  • API DTO Generator - Generate typed Pydantic Create/Out/Patch DTOs from TypeQL schemas
  • Date arithmetic & arithmetic expressions - Full arithmetic support in queries
  • TypeDB 3.8.0 stable - Upgraded from rc0 to the stable release

What's New

API DTO Generator (PRs #96, #97, #99, #100)

Generate Pydantic DTOs (Create, Out, Patch variants) directly from parsed TypeQL schemas. Includes:

  • Composite DTOs - CompositeEntityConfig for flat/merged DTOs across entity types
  • Per-variant field overrides - FieldOverride and EntityFieldOverride to control field requiredness per variant
  • skip_variants - Skip specific variant classes while keeping the type Literal enum
  • extra_fields_out - Per-variant override for extra fields on Out DTOs
  • strict_out_models - Flag for required fields in Out DTOs
  • Reusable Jinja macros - Refactored templates into _dto_macros.jinja
  • CLI support - python -m type_bridge.generator now supports DTO generation

Date Arithmetic and Query-Level Arithmetic Expressions

  • Date now supports __add__, __radd__, __sub__ for Duration arithmetic, matching DateTime/DateTimeTZ
  • New ArithmeticExpr expression class with helpers: add, sub, mul, div, mod, pow_
  • ArithmeticValue AST node and compiler support for TypeQL infix operators

Improvements

  • TypeDB 3.8.0 stable (bumped from rc0)
  • TypeDB driver upgraded to 3.8.0
  • Expression module cleanup (boolean, comparison, string)
  • Field module cleanup (base, role)

Housekeeping

  • Applied ruff formatting to all test files
  • Added .coverage to .gitignore

Contributors


Full Changelog: v1.2.7...v1.3.0

v1.2.7

03 Feb 00:18
9cbadd2

Choose a tag to compare

What's Changed

  • TypeDB 3.8.0 support with code deduplication refactor by @CaliLuke in #93

Highlights

  • TypeDB 3.8.0 support - Full compatibility with the latest TypeDB version
  • Batch operations optimization - Faster inserts, puts, and deletes
  • Bug fixes - HydrationError handling, variable collisions, TypeDB 3.x syntax

What's New

TypeDB 3.8.0 Support (PR #93)

Full compatibility with TypeDB 3.8.0 including updated driver integration.

Performance: Batch Operations

  • Batch delete operations with disjunctive IID matching
  • Batch entity inserts and puts into single query
  • Optimized IID retrieval with single-query insert+fetch

Bug Fixes

  • Raise HydrationError instead of silently swallowing exceptions
  • Use double underscore separator to prevent variable collisions
  • Correct TypeDB 3.x relation insert syntax with links keyword
  • Fix multi-variable let assignment syntax

Contributors


Full Changelog: v1.2.6...v1.2.7

[v1.2.6] - Polymorphic role player type resolution and comprehensive query tests

01 Feb 08:53
9fd510f

Choose a tag to compare

What's Changed

  • Polymorphic role player type resolution and comprehensive query tests by @CaliLuke in #92

Summary

  • Polymorphic role player resolution: When querying relations with abstract role types, role players are now resolved to their concrete Python types (e.g., Person instead of Profile)
  • Relations as role players: Fixed hydration for relations serving as role players in other relations
  • Generator improvements: Role cardinality, docstrings, and annotations rendering enhancements

New Features

Polymorphic Role Player Type Resolution (PR #92)

  • Role players now resolve to their concrete Python types
  • Uses TypeQL label() function to fetch type labels and resolve to correct Python class

Relations as Role Players

  • Relations can now properly participate as role players in other relations
  • Comprehensive test suites added for this pattern

Improvements

Modular Helper Methods

  • Extracted _resolve_entity_class_from_label() and _hydrate_entity_from_data() helpers
  • Eliminates duplicate code in get() and get_by_iid() methods

Generator Enhancements

  • Role cardinality annotations now properly rendered
  • Docstrings and type annotations rendering improvements

Bug Fixes

  • Fixed polymorphic role validation and role player IIDs
  • Fixed manager.count()manager.filter().count() in tests
  • Renamed attribute types to avoid naming collisions

Testing

  • 19 new integration tests covering:
    • Deep inheritance (3-level: Entity → Profile → Person/Organization)
    • Self-referential symmetric relations (Friendship)
    • Geographic hierarchy chains (Person → City → Country)
    • Polymorphic role players with concrete type verification
    • Multi-value attributes with @card(0..*)
    • Chained relations and complex filter combinations

Full Changelog: v1.2.5...v1.2.6

[v1.2.5] - IID-preferring Role Player Matching

31 Jan 05:33
7c28956

Choose a tag to compare

What's New

IID-preferring Role Player Matching (PR #91)

RelationManager now prioritizes IID (internal ID) when matching role players in relation operations.

Key improvements:

  • Uses IID for exact entity matching when available
  • Falls back to key attribute matching for new entities
  • Clear error messages when entities lack identifiers
  • Applied to all CRUD methods and their batch variants

Full Changelog: v1.2.4...v1.2.5

[v1.2.4] - Built-in Functions Supports

30 Jan 01:33

Choose a tag to compare

Summary

TypeBridge 1.2.4 adds full support for TypeDB 3.8.0, including new built-in functions (iid(), label(), math functions), Unicode identifier validation, and several bug fixes.

New Features

TypeDB 3.8.0 Built-in Functions (PR #88)

Added support for all new TypeDB 3.8.0 built-in functions:

  • Identity functions: iid(), label()
  • Math functions: abs_(), ceil(), floor(), round_()
  • Collection functions: len_(), max_(), min_()

Usage Example:

from type_bridge.expressions import iid, label, abs_, ceil, floor, round_, len_, max_, min_

# Get entity IID
query = Person.manager(db).filter(iid() == "0x1a2b3c").execute()

# Use math functions in expressions
query = Person.manager(db).filter(abs_(Age.value) > 18).execute()

Unicode XID Identifier Validation (PR #88)

Added validation for TypeDB 3.8.0 Unicode identifier compatibility:

  • Validates identifiers follow Unicode XID_Start/XID_Continue rules
  • Ensures TypeQL identifiers are compatible with TypeDB 3.8.0
  • Clear error messages for invalid identifiers

Bug Fixes

Value Extraction Fix (PR #88)

  • Fixed value extraction for _Value concepts
    • Changed from .as_value() to .get() for proper value extraction
    • Fixes issues with function return values and aggregations
    • Location: type_bridge/session.py

Driver Initialization Warning Fix (PR #88)

  • Fixed "Failed to initialize logging" warning
    • Suppresses fd 2 (stderr) during TypeDB driver initialization
    • Eliminates spurious warning messages on startup
    • Location: type_bridge/typedb_driver.py

Documentation

  • Added AI Assistant Skill Documentation
    • New docs/SKILL.md for type-bridge AI assistant integration
    • Guidelines for using TypeBridge with AI code assistants

CI/CD

  • Updated CI to TypeDB 3.8.0-rc0
    • All tests now run against TypeDB 3.8.0-rc0
    • Ensures compatibility with latest TypeDB version

Testing

  • 32 new unit tests for builtin expressions
  • 7 new integration tests for iid() and label() functions
  • All existing tests pass with TypeDB 3.8.0-rc0
  • Fixed hardcoded port 1729 in tests to use TEST_DB_ADDRESS

Key Files Modified

  • type_bridge/expressions/builtins.py - New built-in function expressions
  • type_bridge/session.py - Value extraction fix
  • type_bridge/typedb_driver.py - Driver initialization fix
  • type_bridge/validation.py - Unicode identifier validation
  • docs/SKILL.md - New AI assistant documentation

Upgrade Notes

This release is fully backward compatible. No code changes required when upgrading from 1.2.3.

Recommended TypeDB Version: 3.8.0 or later

Contributors

Full Changelog: v1.2.3...v1.2.4