Skip to content

dlovans/tenet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tenet

A declarative logic VM for JSON. Define rules, compute values, validate constraints — all in pure JSON.

Go License

What It Does

Tenet processes JSON documents through a rules engine:

Your JSON Schema → [Tenet VM] → Validated JSON with computed values

Use it for smart forms, compliance checks, game logic, workflow automation, or anything that needs deterministic rule evaluation.

Features

  • Reactive Rules — If-then logic that fires when conditions match
  • Computed Fields — Derived values calculated automatically
  • Constraint Validation — Min/max, required fields, patterns
  • Dynamic Visibility — Show/hide fields based on state
  • Temporal Routing — Version rules by effective date
  • Attestation Tracking — Validate that signatures were collected
  • Runtime Validation — Undefined variables, unknown operators, temporal conflicts
  • Static Linter — Catch errors before execution (Go CLI only)

Quick Start

# Build CLI
go build -o tenet ./cmd/tenet

# Run a schema
./tenet run -file schema.json

# Lint (static analysis)
./tenet lint -file schema.json

Example

{
  "definitions": {
    "income": {"type": "number", "value": 45000, "required": true},
    "tax_bracket": {"type": "string", "readonly": true}
  },
  "logic_tree": [
    {
      "id": "low_income",
      "when": {"<": [{"var": "income"}, 50000]},
      "then": {"set": {"tax_bracket": "low"}}
    },
    {
      "id": "high_income", 
      "when": {">=": [{"var": "income"}, 50000]},
      "then": {"set": {"tax_bracket": "high"}}
    }
  ]
}

Output: tax_bracket is computed as "low".

Documentation

API

Go

import "github.com/dlovans/tenet/pkg/tenet"

result, err := tenet.Run(jsonString, time.Now())
valid, err := tenet.Verify(completedDoc, baseSchema)

JavaScript

import { run, verify } from '@dlovans/tenet-core';

// No initialization needed - pure TypeScript
const result = run(schema);
console.log(result.result.status); // 'READY', 'INCOMPLETE', or 'INVALID'

// Verify transformation
const valid = verify(newSchema, oldSchema);

CLI

tenet run -file schema.json -date 2026-01-20
tenet verify -new completed.json -base schema.json
tenet lint -file schema.json

Document Status

Status Meaning
READY All validations pass
INCOMPLETE Missing required fields or attestations
INVALID Constraint violations

License

MIT — see LICENSE

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •