Skip to content

BE-522: HashQL: Expand stdlib type system with temporal types#8674

Open
indietyp wants to merge 4 commits intobm/be-306-hashql-postgres-translationfrom
bm/be-522-hashql-expand-stdlib-type-definitions
Open

BE-522: HashQL: Expand stdlib type system with temporal types#8674
indietyp wants to merge 4 commits intobm/be-306-hashql-postgres-translationfrom
bm/be-522-hashql-expand-stdlib-type-definitions

Conversation

@indietyp
Copy link
Copy Markdown
Member

🌟 What is the purpose of this PR?

This PR expands the HashQL standard library's temporal type system and refactors how standard library types are defined and exposed. The QueryTemporalAxes type, previously a stub in the graph module, is replaced with a fully-specified temporal module containing a rich set of temporal bound and interval types (Timestamp, TemporalBound, Interval, LeftClosedTemporalInterval, RightBoundedTemporalInterval, PinnedTransactionTimeTemporalAxes, PinnedDecisionTimeTemporalAxes, QueryTemporalAxes, etc.). Entity types in the knowledge graph are updated to use real temporal metadata (using LeftClosedTemporalInterval) instead of opaque Unknown wrappers.

Alongside this, type construction logic is extracted into public types submodules for each standard library module, enabling external consumers to construct monomorphized type instances without going through the full module registration machinery. Several modules are made pub to support this. The ScratchPool allocator is introduced for multi-threaded bump allocation, and FromIn<&str, A> for Rc<str, A> is implemented. The RuntimeRepr symbol representation is refactored to use extern "C" unsized types and raw pointer field access to avoid provenance issues.

🔗 Related links

🔍 What does this change?

  • Introduces graph::temporal as a new standard library module with a full set of temporal types: Timestamp, DecisionTime, TransactionTime, UnboundedTemporalBound, InclusiveTemporalBound, ExclusiveTemporalBound, TemporalBound, FiniteTemporalBound, OpenTemporalBound, Interval, LeftClosedTemporalInterval, RightBoundedTemporalInterval, PinnedTransactionTimeTemporalAxes, PinnedDecisionTimeTemporalAxes, and QueryTemporalAxes.
  • Removes the stub QueryTemporalAxes (previously an empty opaque struct) from graph::Graph and moves it to the new temporal module.
  • Updates entity knowledge types to depend on graph::temporal::Temporal and use LeftClosedTemporalInterval for TemporalMetadata instead of an opaque Unknown wrapper.
  • Extracts type construction into public types submodules for core::option, core::url, core::uuid, graph::temporal, graph::types::ontology, graph::types::principal::actor_group, graph::types::principal::actor_group::web, and graph::types::knowledge::entity, each accepting optional dependency structs for injection.
  • Makes std_lib, std_lib::core, std_lib::graph, graph::types, graph::types::knowledge, graph::types::ontology, graph::types::principal, graph::types::principal::actor_group, graph::types::principal::actor_group::web, graph::temporal, module::std_lib, and module::std_lib::core::option/url/uuid public.
  • Adds ScratchPool and ScratchPoolGuard to the heap module, providing a Sync-capable pool of bump allocators backed by bump_scope::BumpPool.
  • Implements FromIn<&str, A> for Rc<str, A> with tests covering unicode, empty strings, and clone sharing.
  • Refactors RuntimeRepr to use an extern "C" unsized Unsize type and raw pointer field access (&raw const/mut) to avoid provenance narrowing issues, replacing str_from_raw_parts with str::from_utf8_unchecked and get_mut_unchecked/extern_types nightly features.
  • Migrates string literals used as symbol names and type paths to sym:: constants throughout, eliminating most heap.intern_symbol("...") calls.
  • Adds many new entries to the sym symbol table, including type names, field names, and fully-qualified path symbols for all new and existing types.

🛡 What tests cover this?

  • New unit tests for FromIn<&str, A> for Rc<str, A>: basic conversion, unicode, empty string, and clone pointer equality.
  • Existing standard library module integration tests cover the updated type definitions.

❓ How to test this?

  1. Run cargo test -p hashql-core and confirm all tests pass.
  2. Verify that the temporal module types are accessible and correctly structured via the standard library manifest.

feat: make Int size aware

feat: postgres serialization

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: errors

feat: psql codec

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: move bridge -> orchestrator

feat: move bridge -> orchestrator

feat: organize the runtime a bit more

feat: organize the runtime a bit more

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: checkpoint

feat: organize the runtime a bit more

feat: finish orchestrator first version

feat: finish orchestrator first version

feat: feat: move out suspension requests to own module

chore: clippy

feat: split out into more manageable functions

feat: split out into more manageable functions

chore: orchestrator docs

feat: organize the runtime a bit more

feat: test orchestrator

feat: better symbol repr

feat: orchestrator test harness

feat: orchestrator test harness

feat: orchestrator test harness

feat: orchestrator test harness

feat: orchestrator test harness

feat: test orchestrator

feat: pipeline

feat: bless snapshots

chore: tests

chore: masking

chore: tests

fix: SSA repair

chiore: ssa repair snapshots

feat: orchestrator test harness

chore: remove spec

fix: library features

chore: update snapshots

chore: update docs
@vercel vercel Bot temporarily deployed to Preview – petrinaut April 29, 2026 14:05 Inactive
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hash Ready Ready Preview, Comment May 8, 2026 8:46am
petrinaut Ready Ready Preview May 8, 2026 8:46am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview May 8, 2026 8:46am

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

Medium Risk
Medium risk due to new/modified core type definitions and extensive unsafe changes in symbol representation and allocator plumbing that could affect correctness across the compiler/runtime.

Overview
Expands HashQL stdlib with a first-class temporal type system. Introduces graph::temporal (and related sym:: entries) to replace the previous stub QueryTemporalAxes, and updates graph APIs/tests so time_axis is now a union of pinned decision/transaction temporal axes.

Refactors stdlib type construction and exposure. Extracts reusable type builders into public types submodules (e.g. core::{option,url,uuid}, graph::types::{ontology,principal,knowledge}, graph::temporal), makes several stdlib modules public, and migrates many hard-coded symbol/path strings to sym:: constants.

Heap/symbol infrastructure upgrades. Adds a thread-shareable bump ScratchPool, implements allocator-aware FromIn<&str, A> for Rc<str, A> with tests, adjusts allocator wrapper visibility for sibling types, and reworks symbol::RuntimeRepr’s allocation/layout and access patterns to avoid provenance issues (raw pointers + extern unsized type), updating affected golden test outputs.

Reviewed by Cursor Bugbot for commit 08c277c. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown
Member Author

indietyp commented Apr 29, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@vercel vercel Bot temporarily deployed to Preview – petrinaut April 29, 2026 14:09 Inactive
@github-actions github-actions Bot added the area/tests New or updated tests label Apr 29, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 29, 2026

Merging this PR will degrade performance by 17.91%

❌ 2 (👁 2) regressed benchmarks
✅ 78 untouched benchmarks

Performance Changes

Benchmark BASE HEAD Efficiency
👁 unique[100] 20.1 µs 24.5 µs -17.91%
👁 pattern_match_constant 180 ns 209.2 ns -13.94%

Comparing bm/be-522-hashql-expand-stdlib-type-definitions (7d9f781) with bm/be-306-hashql-postgres-translation (b399240)

Open in CodSpeed

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit d82e398. Configure here.

Comment thread libs/@local/hashql/core/src/symbol/sym.rs
@indietyp indietyp changed the title BE-435: HashQL: Expand stdlib type system with temporal types BE-522: HashQL: Expand stdlib type system with temporal types Apr 29, 2026
@graphite-app graphite-app Bot requested review from a team April 29, 2026 14:16
@vercel vercel Bot temporarily deployed to Preview – petrinaut April 29, 2026 15:32 Inactive
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 29, 2026

Codecov Report

❌ Patch coverage is 78.51623% with 139 lines in your changes missing coverage. Please review.
✅ Project coverage is 68.05%. Comparing base (b399240) to head (7d9f781).

Files with missing lines Patch % Lines
libs/@local/hashql/core/src/heap/pool.rs 29.67% 64 Missing ⚠️
...src/module/std_lib/graph/types/knowledge/entity.rs 87.07% 34 Missing ⚠️
...l/hashql/core/src/module/std_lib/graph/temporal.rs 77.85% 31 Missing ⚠️
...ore/src/module/std_lib/graph/types/ontology/mod.rs 85.71% 5 Missing ⚠️
...e/std_lib/graph/types/principal/actor_group/web.rs 81.25% 3 Missing ⚠️
...e/std_lib/graph/types/principal/actor_group/mod.rs 87.50% 2 Missing ⚠️
Additional details and impacted files
@@                            Coverage Diff                            @@
##           bm/be-306-hashql-postgres-translation    #8674      +/-   ##
=========================================================================
+ Coverage                                  65.23%   68.05%   +2.81%     
=========================================================================
  Files                                       1224      909     -315     
  Lines                                     127974    85798   -42176     
  Branches                                    5409     4539     -870     
=========================================================================
- Hits                                       83480    58386   -25094     
+ Misses                                     43628    26828   -16800     
+ Partials                                     866      584     -282     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.41% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
blockprotocol.type-system ?
local.claude-hooks ?
local.harpc-client ?
local.hash-backend-utils 0.00% <ø> (ø)
local.hash-graph-sdk 9.63% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.antsi ?
rust.error-stack ?
rust.harpc-codec ?
rust.harpc-net ?
rust.harpc-tower ?
rust.harpc-types ?
rust.harpc-wire-protocol ?
rust.hash-codec ?
rust.hash-graph-api 2.52% <ø> (?)
rust.hash-graph-authorization ?
rust.hash-graph-postgres-store ?
rust.hash-graph-store ?
rust.hash-graph-temporal-versioning ?
rust.hash-graph-types ?
rust.hash-graph-validation ?
rust.hashql-ast 87.23% <ø> (ø)
rust.hashql-compiletest 29.63% <ø> (ø)
rust.hashql-core 82.17% <78.51%> (-0.27%) ⬇️
rust.hashql-diagnostics ?
rust.hashql-eval 81.08% <ø> (ø)
rust.hashql-hir 89.06% <ø> (ø)
rust.hashql-mir 92.08% <ø> (ø)
rust.hashql-syntax-jexpr 94.05% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@augmentcode
Copy link
Copy Markdown

augmentcode Bot commented Apr 29, 2026

🤖 Augment PR Summary

Summary: Expands HashQL’s stdlib type system with first-class temporal bounds/intervals, and refactors stdlib type exposure so monomorphized type instances can be constructed externally.

Changes:

  • Adds a new ::graph::temporal module with Timestamp, temporal bound variants, Interval, and derived interval/axes types (including QueryTemporalAxes).
  • Removes the prior stub QueryTemporalAxes definition from ::graph and updates call sites to source it from ::graph::temporal.
  • Updates knowledge-graph entity stdlib types to use concrete temporal metadata (LeftClosedTemporalInterval) instead of opaque/unknown wrappers.
  • Introduces per-module types submodules for constructing TypeId values with optional dependency injection.
  • Makes several stdlib modules public to support external consumers building/using stdlib types.
  • Adds heap::ScratchPool/ScratchPoolGuard for parallel bump allocation.
  • Adds allocator-aware FromIn<&str, A> for Rc<str, A> plus unit tests.
  • Refactors runtime symbol representation (RuntimeRepr) to use an extern "C" unsized tail and raw-pointer field access to avoid provenance issues.
  • Extends the symbol table with new type/field/path symbols used across the updated stdlib.

Technical Notes: The PR increases public surface area (modules + types constructors) and introduces new unsafe internals around symbol representation; downstream consumers should validate any expected stdlib paths/names for compatibility.

🤖 Was this summary useful? React with 👍 or 👎

Copy link
Copy Markdown

@augmentcode augmentcode Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review completed. 1 suggestion posted.

Fix All in Augment

Comment augment review to trigger a new review at any time.

Comment thread libs/@local/hashql/core/src/module/std_lib/core/url.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/libs Relates to first-party libraries/crates/packages (area) area/tests New or updated tests type/eng > backend Owned by the @backend team

Development

Successfully merging this pull request may close these issues.

1 participant