From fc3a70f59f54b749ed48301e7fa9aa8e3c09b534 Mon Sep 17 00:00:00 2001 From: lab-agent-session Date: Thu, 12 Nov 2026 02:08:44 +0100 Subject: [PATCH] feat: SQL is back: make sql, tad engine in setup, the recipe Glimpse: g-20261112-010844 --- AGENTS.md | 7 +++++++ Makefile | 5 ++++- data/glimpses.json | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 540fe58..c0eedcb 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -35,6 +35,13 @@ A new field: declare it in `tables.toml` (a `[[tables..fields]]` entry wi Rename a field: `mlr -I --ijsonl --ojsonl rename old,new data/
.json`, make the same change in `tables.toml`, then `make canon` (forgetting the declaration is caught by `make check`). +Ask the data anything in SQL - joins, counts, what is missing - and change it the same way; a change through SQL is checked exactly as `tad set` is, and kept only if every rule still holds: +``` +tad sql "SELECT status, count(*) FROM backlog GROUP BY status" +tad sql "UPDATE backlog SET status = 'done' WHERE id = 'an-id'" +tad sql --file a-query.sql --format csv +``` + ## Why it is built this way - The data is plain text in git: one JSON object per line, so a change to one row is a one-line diff, readable without any tool. - `tables.toml` declares the tables as data (after Frictionless Data's Table Schema): a person reads it, and [tad](https://github.com/creation-guidelines/tad-engine) checks every row and every rule across tables against it. diff --git a/Makefile b/Makefile index 051a680..b8fb80e 100644 --- a/Makefile +++ b/Makefile @@ -3,15 +3,18 @@ SHELL := /bin/bash TAD ?= tad -.PHONY: setup check canon render verify +.PHONY: setup check canon render sql verify setup: ## install tad from its pinned release (its checksum checked) ./bin/install-tad.sh + $(TAD) engine check: ## every row and every rule across tables (tables.toml) $(TAD) check canon: ## rewrite data/ in canonical form (only when it checks out) $(TAD) canon render: ## data/ -> docs/ $(TAD) render +sql: ## ask the data in SQL: make sql Q="SELECT ..." (a change is kept only if every rule holds) + $(TAD) sql "$(Q)" verify: check ## what CI runs: data is valid and canonical, docs are fresh @before="$$(find data docs -type f -print0 | sort -z | xargs -0 sha256sum)"; \ $(TAD) canon && $(TAD) render; \ diff --git a/data/glimpses.json b/data/glimpses.json index 4806f3a..307fd2b 100644 --- a/data/glimpses.json +++ b/data/glimpses.json @@ -1,3 +1,4 @@ {"id":"g-20261111-213425","at":"2026-11-11T21:34:25Z","by":"lab-agent-session","kind":"chore","summary":"glimpses are recorded here from now on"} {"id":"g-20261111-223547","at":"2026-11-11T22:35:47Z","by":"tad update-pins","kind":"build","summary":"tad 0.4.0: the pin moved, the data and documents re-rendered"} {"id":"g-20261112-010648","at":"2026-11-12T01:06:48Z","by":"lab-agent-session","kind":"build","summary":"tad 0.5.0: the pin moved, the data and documents re-rendered"} +{"id":"g-20261112-010844","at":"2026-11-12T01:08:44Z","by":"lab-agent-session","kind":"feat","summary":"SQL is back: make sql, tad engine in setup, the recipe"}