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 Apr 29, 2026 3:58pm
petrinaut Ready Ready Preview Apr 29, 2026 3:58pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
hashdotdesign-tokens Ignored Ignored Preview Apr 29, 2026 3:58pm

@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 29, 2026

PR Summary

High Risk
Touches core stdlib type modeling used throughout compilation/evaluation and changes unsafe symbol allocation/provenance code; regressions could surface as type mismatches, incorrect query typing, or UB if pointer/layout assumptions are wrong.

Overview
Adds a new graph::temporal stdlib module that models timestamps, bounds, intervals, and pinned/query temporal axes, and removes the previous stub QueryTemporalAxes from graph in favor of this richer representation.

Refactors stdlib type definitions to be externally constructible: several modules are made pub, type construction is extracted into types submodules (e.g. core::option/url/uuid, graph::types::*, graph::temporal, graph::types::knowledge::entity), and symbol/path literals are largely replaced with sym::* constants; entity/ontology/principal graph types are updated accordingly (including RecordId/TemporalMetadata and real temporal metadata types).

Extends allocator utilities by introducing ScratchPool/ScratchPoolGuard for thread-safe bump allocation and adds FromIn<&str, A> for Rc<str, A> plus tests. Updates RuntimeRepr’s internal layout/allocation/access patterns (raw pointers + extern unsized marker) to avoid provenance issues, and refreshes multiple UI test snapshots (AST/HIR/MIR) to match the new types and symbol IDs.

Reviewed by Cursor Bugbot for commit deb5f19. 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 27.89%

❌ 2 regressed benchmarks
✅ 78 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Benchmark BASE HEAD Efficiency
pattern_match_constant 150.8 ns 209.2 ns -27.89%
unique[100] 20.3 µs 24.7 µs -17.63%

Comparing bm/be-522-hashql-expand-stdlib-type-definitions (deb5f19) with bm/be-306-hashql-postgres-translation (8b510e5)1

Open in CodSpeed

Footnotes

  1. No successful run was found on bm/be-306-hashql-postgres-translation (c484cc9) during the generation of this report, so 65c5f8e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

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 63.19%. Comparing base (c484cc9) to head (deb5f19).

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                                  63.16%   63.19%   +0.02%     
=========================================================================
  Files                                       1336     1338       +2     
  Lines                                     137675   138468     +793     
  Branches                                    5551     5557       +6     
=========================================================================
+ Hits                                       86961    87499     +538     
- Misses                                     49794    50047     +253     
- Partials                                     920      922       +2     
Flag Coverage Δ
apps.hash-ai-worker-ts 1.40% <ø> (ø)
apps.hash-api 0.00% <ø> (ø)
local.hash-graph-sdk 9.63% <ø> (ø)
local.hash-isomorphic-utils 0.00% <ø> (ø)
rust.hash-graph-api 2.52% <ø> (ø)
rust.hashql-ast 87.23% <ø> (ø)
rust.hashql-compiletest 29.63% <ø> (ø)
rust.hashql-core 82.17% <78.51%> (-0.27%) ⬇️
rust.hashql-eval 81.08% <ø> (ø)
rust.hashql-mir 92.08% <ø> (-0.36%) ⬇️
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