Craticula

Craticula

CI coverage gate license spec version OpenSSF Scorecard

它是编译器,而不是客户端:把 AG Grid Server-Side Row Model 请求翻译成原生、 安全的后端查询——SQL、MongoDB、OpenSearch/Elasticsearch——全部来自同一个规范的 IR, 覆盖四种语言。

维护者: Christian Stephan(cstephan.dev、LinkedIn、GitHub)。Craticula 是基于 Apache-2.0 许可的开源项目; 项目网站是 craticula.pluries.dev。

状态: 早期设计阶段。维护者在内部保管一份技术需求文档(TRD:架构、 安全模型、路线图、未决问题);其需求编号(AR-1、SEM-1、GRP-7 等) 在本仓库中随处被引用,规范性规则见 spec/semantics.md (英文)。

为什么 #

每个后端团队都要重新实现把 AG Grid SSRM 请求 (filterModel、sortModel、rowGroupCols、groupKeys、valueCols、startRow/endRow) 翻译成数据库查询的工作,通常借助字符串形式的 DSL 中间层,结果是运算符缺失、 空值和大小写语义有缺陷、存在注入风险,并且不支持分组和搜索引擎。目前没有任何 持续维护的开源库能端到端地覆盖这些需求。

工作原理 #

AG Grid request SSRM JSON from the grid Request adapter Craticula.AgGrid, on your server Canonical IR Craticula.Core Query compiler Craticula.Sql / .Mongo / .Search Query artifact plain data; the core never runs it GridSchema The security and typing boundary of the core. It lists the fields a grid may touch, and their types. Anything else is refused. { sql, params[] } Mongo aggregation pipeline OpenSearch / ES query DSL run it Execution adapters (optional, separate packages) Run the artifact on your own connection, and shape the rows back into the grid response. Dapper EF Core MongoDB.Driver OpenSearch.Client grid response Compile-only core: a pure function from a request and a schema to a query artifact.

核心从不打开连接:编译是一个纯函数,输入是一个表格请求 加上一份架构配置(安全与类型的边界),输出是一个普通的查询产物。 执行——运行该产物,并把结果重新整理为表格响应—— 由独立且可选的适配器包负责,每个生态系统一个。

范围 (v1) #

TRD 的 §2.2(非目标)和 §14(路线图)说明了哪些内容明确不属于 v1 的范围。

仓库布局(规划中) #

spec/         IR JSON Schema, semantics.md, conformance fixtures — the source of truth
csharp/       reference implementation (Core, AgGrid adapter, compilers, execution adapters)
typescript/   TypeScript port (after spec freeze)
python/       Python port (after spec freeze)
go/           Go port (after spec freeze)
docs/adr/     architecture decision records (why the design is the way it is)
examples/     demo app (React + AG Grid + one sample backend)

打包 #

C# 实现被拆分为十个 NuGet 包,全部发布在 nuget.org 上:

NuGet

Craticula.Core、 Craticula.AgGrid、 Craticula.Sql、 Craticula.Mongo、 Craticula.Search、 Craticula.Export.Csv、 Craticula.EntityFrameworkCore、 Craticula.Dapper、 Craticula.MongoDB.Driver 和 Craticula.OpenSearch.Client。 使用 dotnet add package <name> 安装其中任意一个。要检查这些包能否构建,以及一个干净的使用方项目能否针对它们编译,请运行 bash scripts/pack-smoke.sh(需要 Python 3.10+ 和 .NET 10 SDK;大约 3 分钟)。

Claude 技能 #

Claude 技能(skill)会引导你从零开始,直到编译出第一个网格请求,并让 Claude 拒绝那些不安全的捷径。将它作为 Claude Code 插件安装:

claude plugin marketplace add pluries/craticula
claude plugin install craticula@craticula

或者将文件夹 skills/craticula 复制到 ~/.claude/skills/craticula/。该技能就是文本:Claude 的行为无法得到保证。参见 Claude 技能页面。

依赖项许可证 #

csharp/ 下的每个 NuGet 包,包括传递依赖和测试项目,都必须带有本项目接受的许可证。 python3 scripts/check-licenses.py 会对此进行检查(需要 Python 3.10+、.NET 10 SDK 和 nuget.org;请先在 csharp/ 中用 dotnet restore Craticula.sln 还原解决方案,再在同一目录用 dotnet tool restore 还原固定版本的工具)。同一个脚本会在每个 pull request 的 license-check 作业中运行,在包缓存已预热的情况下只需几秒钟。

演示 #

在线试用:PostgreSQL 和 MongoDB。两者通过同一个 AG Grid 页面展示相同的 合成订单数据;它们是只读的,并且有速率限制。

examples/demo 是它们背后的应用:一个 AG Grid 页面,通过基于本库构建的 C# API,从 PostgreSQL 或 MongoDB 读取相同的订单。要自己运行它,需要 Docker、.NET 10 SDK 和 Node 20.19 或更新版本。它是一个 展示项目,像本库的普通用户一样,从 nuget.org 安装已发布的包。

兼容性 #

规范版本.NET 目标
1.0.0net10.0

这些包以 net10.0 为目标。它们也能在 .NET 11 运行时上运行:构建和离线测试在 .NET SDK 11.0.100 上通过(2026-11-27 检查;理由见 ADR-0015)。

规范版本即 spec/VERSION 中的版本;每个包都在自己的 README 中注明它。 版本如何选定,见 VERSIONING.md。 这些包为其封装的库声明版本范围,绝不声明某个确切的单一版本。

许可证 #

Apache License 2.0——参见 LICENSE。