Skip to content

Fact Catalog & Concepts

The fact catalog is the project's unified description of "which fields rules can read." Studio autocomplete, contract validation, and test-case suggestions are all driven by it.

Why a Catalog

Common pain points without one:

  • Rulesets disagree on field names (user.id / customer_id / uid)
  • Type drift (a numeric field becomes a string after one release)
  • Field semantics live only in engineers' heads

The fact catalog makes these constraints explicit: every field has a name, type, description, and example, serving as the project's single source of truth.

Fact

An atomic field definition.

jsonc
// POST /api/v1/projects/:pid/facts
{
  "name": "user.age",
  "type": "number",
  "description": "User age in years",
  "example": 28,
  "tags": ["user", "demographic"]
}

Supported types: string · number · boolean · array<T> · object · concept:<name>.

Concept

A composite structure. When multiple rulesets need to refer to the same object (e.g. "User", "Order"), define the concept once and reference it from facts as concept:User.

jsonc
// POST /api/v1/projects/:pid/concepts
{
  "name": "User",
  "fields": [
    { "name": "id", "type": "string" },
    { "name": "age", "type": "number" },
    { "name": "vip", "type": "boolean" }
  ]
}

API

OperationEndpoint
List factsGET /api/v1/projects/:pid/facts
Create factPOST /api/v1/projects/:pid/facts
Update/deletePUT/DELETE /api/v1/projects/:pid/facts/:name
List conceptsGET /api/v1/projects/:pid/concepts
Create conceptPOST /api/v1/projects/:pid/concepts
Update/deletePUT/DELETE /api/v1/projects/:pid/concepts/:name

Coupling with Contracts & Studio

  • Contracts constrain a ruleset's input and output by referencing facts/concepts.
  • Studio expression autocomplete and type checks come from the catalog.
  • Test cases use the catalog to suggest input fields — the catalog is where all "type info" for a project converges.

Released under the MIT License.