feat(domain): add the typed registry view and its ClickHouse SQL compiler - #433
Closed
JeremyFunk wants to merge 1 commit into
Closed
feat(domain): add the typed registry view and its ClickHouse SQL compiler#433JeremyFunk wants to merge 1 commit into
JeremyFunk wants to merge 1 commit into
Conversation
This was referenced Aug 11, 2026
JeremyFunk
force-pushed
the
ai/04-registry-ts-sql-compiler
branch
from
August 12, 2026 20:04
fb861e6 to
1b7fc47
Compare
…iler Adds `@maple/domain/ai-registry`: an Effect Schema decode of `registry.json` at module load (so a bad resync fails the import, not the first classification), the semantic invariants Schema cannot express (`validate.ts`: globally unique priorities, the D4 priority bands, the closed slug set, `value_prefix` confined to pseudo-keys), and `compile-sql.ts`, which lowers the registry to ClickHouse expressions over a `traces` row. The SQL compiler exists so the Rust classifier can be proven equivalent to a SQL evaluation of the same artifact, and so the rollup rebuild job has a way to recompute vendors without reading the `AiVendor` column it is fixing. It emits no hash SQL, but only because nothing in v1 consumes one: `sessionKeyValueExpr` yields the winning candidate's raw value and `cityHash64` over it is a one-liner the caller can write. The subpath export keeps the ~280 KB artifact off the root `@maple/domain` barrel that web and cli import, and `resolveJsonModule` is enabled for the vendored JSON. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
JeremyFunk
force-pushed
the
ai/04-registry-ts-sql-compiler
branch
from
August 12, 2026 21:05
1b7fc47 to
e621844
Compare
Collaborator
Author
🍁 Maple PR previewNote Preview resources were removed when this pull request closed. Final commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this layer contains
Maple's typed view of the registry artifact, under the
@maple/domain/ai-registrysubpath export:schema.ts— Effect Schema for the whole document;registry.jsonis decoded at module load and exported deep-frozen.validate.ts/validate.test.ts— the semantic invariants Schema cannot express (globally unique integer priorities, the D4 priority bands, the closed slug set withunknown:reserved,value_prefixconfined to pseudo-keys, justification on sufficient resource matchers).compile-sql.tsand its unit + ClickHouse e2e tests — lowers the registry to ClickHouse expressions over atracesrow.registry-fixtures.ts,index.ts, the./ai-registryexport inpackage.json,resolveJsonModuleintsconfig.json, and the README's "TypeScript consumers" section.Why it is shaped this way
Decoding at module load means a resync that changes the artifact's shape fails the import rather than the first classification, and
validate.test.tsis the gate a future resync must pass — it reports violations and never repairs them, because a violation means the upstream compiler produced a bad artifact and must be fixed in trace-capture.The SQL compiler exists for two consumers that both need to evaluate the registry without the Rust classifier: the differential tests that prove the two evaluators agree, and the rollup rebuild job, which cannot read the stored
AiVendorbecause that is the column it is repairing. It emits no hash SQL, only because nothing in v1 consumes one:sessionKeyValueExpryields the winning candidate's raw value andcityHash64over it is a one-liner the caller can write. The subpath export keeps the ~280 KB artifact off the root@maple/domainbarrel that web and cli import.Gates run at this level
bun typecheck— 37/37 tasks pass.packages/domainvitest — 532 passed, 7 skipped.compile-sql.clickhouse.e2e.test.tsunderCLICKHOUSE_E2E=1against a real ClickHouse — 7 passed.Dependencies
Requires #430 for
registry.json. Independent of the Rust layer in #432 — the two evaluators are only tied together in #435.Partition note:
index.tshere exports everything except the rollup-enablement constants; that module belongs to the rollup and its export line is restored in #436.🤖 Generated with Claude Code
Stack created with GitHub Stacks CLI • Give Feedback 💬
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.