Skip to content

feat(querier): RFC 0033 green (artifact) — template_map format + one-scan dual fold - #509

Merged
jensholdgaard merged 8 commits into
mainfrom
rfc0033-green-artifact
Jul 13, 2026
Merged

feat(querier): RFC 0033 green (artifact) — template_map format + one-scan dual fold#509
jensholdgaard merged 8 commits into
mainfrom
rfc0033-green-artifact

Conversation

@jensholdgaard

@jensholdgaard jensholdgaard commented Jul 13, 2026

Copy link
Copy Markdown
Owner

What

RFC 0033's first green slice: the artifact format + one-scan dual fold, discharging scenario RFC0033.1 (cached fold ≡ fresh fold, property-tested).

  • TemplateMapJson wire format (manifest.rs house style): canonical-sorted folded_files frontier (tenant-root-relative, validated against ../absolute/foreign names so a hostile artifact cannot point outside the tenant subtree), registry entries in the miner's canonical format_template form (the exact representation the audit stream stores — no second token encoding), alias classes canonical (ascending members, min-representative).
  • §3.3 dispositions implemented: two-pass parse so a future-version artifact classifies UnknownVersion (not Torn); parse/validation failures → Torn { detail }; both treated-as-absent by callers and distinguishable for the §3.7 telemetry slice; body-tenant mismatch fails loudly (row-vs-path stance).
  • No-partial-artifact at the type level (§3.5 rule): TemplateMap has private fields and exactly two constructors — derive_template_map (ONE read_all_events_captured scan, both folds from the captured events + the frontier from the same listing) and from_json. A one-fold or split-frontier artifact is unrepresentable.
  • RFC0033.1 green: proptest over generated audit histories (tie-heavy timestamps, all event kinds), flushed through the production ParquetAuditSink one file per event so the §3.7.1 cross-file order is exercised; asserts registry, alias classes, frontier, and end-to-end resolves_to answers identical between cached and fresh folds. Six stubs stay red.

Invariants / hazards

Hazard 5 adjacency (template evolution): the artifact caches the fold, not new semantics; the audit stream remains the source of truth (nothing reads the artifact yet — read-path wiring is the freshness + write-through slice). read_all_events delegates to the new captured variant with byte-identical behavior for existing folds.

Checks run

cargo fmt --all --check, cargo clippy --all-targets --all-features -- -D warnings (workspace-wide), cargo nextest run -p ourios-querier -p ourios-core -p ourios-bench (386 passed, 16 skipped) — re-verified after rebase onto the merged red.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Summary by CodeRabbit

  • New Features

    • Added support for generating and serializing a tenant template map containing template registry data, alias classes, and the audit files used to build them.
    • Added validation and clear handling for valid, corrupted, or unsupported template map artifacts.
    • Added alias class export and reconstruction capabilities.
    • Added tenant isolation checks and deterministic audit file tracking.
  • Tests

    • Added round-trip, validation, corruption handling, and end-to-end coverage for cached template maps.

…scan dual fold

RFC0033.1 discharged: the per-tenant cached template-map artifact's
format (format_version / tenant_id / folded_files frontier / registry
/ alias_map, the manifest.json serde precedent), the §3.3 read
dispositions (torn and unknown-version → treated as absent; body
tenant_id mismatch → loud Storage error, the row-vs-path stance), and
derive_template_map — ONE captured audit scan feeding both folds plus
the frontier, so a partial artifact (§3.5) is unrepresentable: the
type's only constructors are the dual-fold derivation and the
validated artifact read.

- audit_scan: read_all_events_captured returns events + bytes + the
  store-relative sorted frontier from the same single pass;
  read_all_events delegates (both existing folds unchanged).
- ourios-core AliasMap: classes / from_classes — the canonical
  projection out of and back into the folded equivalence classes the
  artifact stores.
- RFC0033.1 property test (proptest, RFC 0024 generator discipline):
  generated audit histories (creations/widenings/type-expansions/
  rejections, alias assertions/retractions, same-nanosecond ties)
  flushed through the production ParquetAuditSink; asserts the
  serialize→deserialize folds equal derive_template_registry /
  derive_alias_map per key, the frontier equals an independent walk,
  and a resolves_to answer is identical through either path. The
  other six §5 stubs stay ignored for their slices.

Invariants: §3.7 tenancy preserved (frontier entries validated
tenant-root-relative, foreign tenant_id fails loudly); no Parquet
schema change (§3.5 additive JSON object no existing scan matches).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y
@jensholdgaard
jensholdgaard requested a review from Copilot July 13, 2026 08:40
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@jensholdgaard, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 21 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 59d8c12d-ea2b-4dad-bcf4-479bf99c703d

📥 Commits

Reviewing files that changed from the base of the PR and between 1b43a2f and 3f76476.

📒 Files selected for processing (2)
  • crates/ourios-querier/src/audit_scan.rs
  • crates/ourios-querier/src/template_map.rs
📝 Walkthrough

Walkthrough

Adds RFC 0033.1 cached template-map artifacts containing registry and alias folds plus audit frontiers. It introduces canonical JSON read/write validation, captured audit scanning, alias projection APIs, public exports, and property-based integration coverage.

Changes

Cached template map artifact

Layer / File(s) Summary
Alias projection APIs
crates/ourios-core/src/alias.rs
Adds canonical alias-class extraction and reconstruction, ignoring empty and singleton classes.
Captured audit frontier
crates/ourios-querier/src/audit_scan.rs, crates/ourios-querier/src/alias_store.rs
Captures deterministic tenant-relative audit frontiers alongside folded events and bytes read, with documented storage errors.
Template map derivation and JSON
crates/ourios-querier/src/template_map.rs, crates/ourios-querier/src/template_registry.rs
Derives registry and alias folds from one scan, serializes canonical JSON, distinguishes torn artifacts from unknown versions, and validates tenant, ordering, alias, registry, and frontier invariants.
Public API and property coverage
crates/ourios-querier/src/lib.rs, crates/ourios-querier/tests/it/rfc0033_cached_template_map.rs
Exports the new APIs and adds generated end-to-end checks comparing cached artifacts with fresh folds and query results.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Querier
  participant AuditStore
  participant TemplateMap
  participant AliasMap
  Querier->>AuditStore: scan tenant audit files
  AuditStore-->>Querier: events, bytes_read, folded_files
  Querier->>AliasMap: fold alias events
  Querier->>TemplateMap: combine registry, aliases, and frontier
  TemplateMap-->>Querier: serialize or validate artifact JSON
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is informative, but it does not use the required Summary/Related/Checklist template and omits the RFC link and checklist items. Rewrite it with ## Summary, ## Related (including the RFC/issue link), and ## Checklist entries for fmt, clippy, tests, docs, and RFC linkage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: RFC 0033 template_map artifact work and one-scan dual-fold derivation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rfc0033-green-artifact

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Implements the first “green” slice of RFC 0033 for the querier by introducing a cached per-tenant template-map artifact format and a one-scan derivation path that folds both the template registry and alias map from a single captured audit scan, plus a property test for scenario RFC0033.1.

Changes:

  • Adds TemplateMap + ArtifactRead with JSON serialization/deserialization, canonicalization, and validation rules.
  • Extends audit scanning with read_all_events_captured to return a frontier (folded_files) consistent with the folded events.
  • Adds alias-class projection/rebuild helpers (AliasMap::{classes, from_classes}) and a proptest-based integration test for cached-vs-fresh fold equivalence.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/ourios-querier/tests/it/rfc0033_cached_template_map.rs Replaces RFC0033.1 stub with a property test comparing derived vs artifact-carried folds and frontier.
crates/ourios-querier/src/template_registry.rs Exposes fold_registry at pub(crate) for reuse by template-map derivation.
crates/ourios-querier/src/template_map.rs New module defining the artifact wire format, derivation, and read dispositions/validation.
crates/ourios-querier/src/lib.rs Wires in the new module and re-exports TemplateMap/ArtifactRead/derive_template_map (+ derive_alias_map).
crates/ourios-querier/src/audit_scan.rs Adds captured scans with frontier and refactors read_all_events to delegate to it.
crates/ourios-querier/src/alias_store.rs Makes derive_alias_map public and documents error semantics.
crates/ourios-core/src/alias.rs Adds canonical classes() projection and from_classes() inverse + tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/ourios-querier/src/template_map.rs Outdated
Comment thread crates/ourios-querier/src/template_map.rs
Comment thread crates/ourios-querier/tests/it/rfc0033_cached_template_map.rs Outdated
… code, not links

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread crates/ourios-querier/tests/it/rfc0033_cached_template_map.rs
Comment thread crates/ourios-querier/src/template_map.rs
…emplate validation

An empty alias class now fails to_json loudly (QueryError) instead of
silently serializing representative 0 into a torn artifact; validate()
round-trips every registry template through parse/format and classifies
non-canonical strings torn (untrusted-input hardening); the test
frontier oracle panics on unreadable dirs instead of shrinking.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread crates/ourios-querier/src/template_map.rs
…citly

parse/format round-trip alone cannot catch them: an empty segment
parses to Fixed("") and round-trips unchanged. Enforce what mine-time
tokenization guarantees — non-empty, whitespace-free tokens — with a
regression test over the smuggle cases.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Comment thread crates/ourios-querier/src/template_map.rs
Comment thread crates/ourios-querier/src/template_map.rs Outdated
…n error doc

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread crates/ourios-querier/src/template_map.rs
…kslashes

Path::components() normalizes doubled slashes away; the validator now
rejects non-canonical separators before the component check, with a
regression test over the slip cases.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Comment thread crates/ourios-querier/src/template_map.rs
Comment thread crates/ourios-querier/src/template_registry.rs
Comment thread crates/ourios-querier/src/alias_store.rs
Comment thread crates/ourios-querier/src/audit_scan.rs Outdated
…ort's tiebreak

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Comment thread crates/ourios-querier/src/template_map.rs
…'s layout

First segment year=…, no tenant_id=/audit segments — a foreign-tree
name can't escape (the frontier is compared, never dereferenced) but
must classify torn, not stale.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@jensholdgaard
jensholdgaard merged commit a63f04d into main Jul 13, 2026
26 checks passed
jensholdgaard added a commit that referenced this pull request Jul 13, 2026
.1 fold+format (#509), .3 publish (#510), .2/.4/.5 freshness +
write-through (#511), .6 comparative cold-vs-warm (#512, local arm
55.8x past the 10x gate), .7 observability (#513). The headline-corpus
warm measurement runs as comparative dispatch run #20.


Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants