feat(querier): RFC 0033 green (artifact) — template_map format + one-scan dual fold - #509
Conversation
…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
|
Warning Review limit reached
Next review available in: 21 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughAdds 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. ChangesCached template map artifact
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
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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+ArtifactReadwith JSON serialization/deserialization, canonicalization, and validation rules. - Extends audit scanning with
read_all_events_capturedto 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.
… code, not links Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y
…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
…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
…n error doc Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y
…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
…ort's tiebreak Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WQY9wfrfRggqSpMLH8Xj3Y
…'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
.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>
What
RFC 0033's first green slice: the artifact format + one-scan dual fold, discharging scenario RFC0033.1 (cached fold ≡ fresh fold, property-tested).
TemplateMapJsonwire format (manifest.rs house style): canonical-sortedfolded_filesfrontier (tenant-root-relative, validated against../absolute/foreign names so a hostile artifact cannot point outside the tenant subtree), registry entries in the miner's canonicalformat_templateform (the exact representation the audit stream stores — no second token encoding), alias classes canonical (ascending members, min-representative).UnknownVersion(notTorn); 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).TemplateMaphas private fields and exactly two constructors —derive_template_map(ONEread_all_events_capturedscan, both folds from the captured events + the frontier from the same listing) andfrom_json. A one-fold or split-frontier artifact is unrepresentable.ParquetAuditSinkone file per event so the §3.7.1 cross-file order is exercised; asserts registry, alias classes, frontier, and end-to-endresolves_toanswers 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_eventsdelegates 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
Tests