Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ user-visible change updates.
make setup # once: the switch rowtype, all dependencies
make test # starts the test Postgres in Podman, runs every test;
# RUNTIME=docker for Docker
make lint # formatting, odoc, and the release build
make lint # formatting, odoc, the release build, and Hypha's rules by litany
make fmt # format in place
make docs # the documentation site into _build/docs, as Pages publishes it, and
# agents/ from its pages
Expand Down Expand Up @@ -207,9 +207,9 @@ Each rule comes with why it exists and the test that catches a break.
open is a span's alone**, `Mtime.Span.(10 * s)`. Why: the walk exists to
pattern-match that GADT, and every constructor qualified would bury the
match; a span's operators are made to be opened around the one
expression, as OCAML.md writes one. Symptom:
`rg -n '^\s*open |\b[A-Z]\w*\.[(\[{]' -g '*.ml' src postgres sqlite migrate | rg -v 'Mtime\.Span\.\('`
finds anything but `open Shape`.
expression, as OCAML.md writes one. Symptom: `make lint`'s litany
reports `open-of-ordinary-module`, which `open Shape` is allowed with
its reason beside it.

## Changes and releases

Expand Down
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changes

## 0.10.4 (2026-12-03)

- Every package installs the documentation for agents, `llms.txt` and every
page, in `$(opam var <package>:doc)`, and every interface it installs
names its page there, or `llms.txt`. The README's *With an agent* says so.
- The reference's table of packages names `rowtype-test`.

## 0.10.3 (2026-11-22)

- The rowtype package installs its documentation for agents: each page as
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ test: ## run the tests
$(OPAM) ./_build/default/testing/bin/main.exe run --runtime $(RUNTIME) -- \
$(OPAM) dune test --force

# Release is the profile opam installs with.
lint: ## check formatting, docs and the release build
# Release is the profile opam installs with. litany holds the code to
# Hypha's rules, as the litany file selects them.
lint: ## check formatting, docs, the release build and Hypha's rules
$(OPAM) dune build @all @fmt @doc
$(OPAM) dune build --profile release @all
$(OPAM) litany check

fmt: ## format the code
$(OPAM) dune fmt
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ The same statements run on SQLite unchanged: [SQLite](https://hyphatech.github.i

## With an agent

Each release installs its documentation for an agent with it, at
`$(opam var rowtype:doc)`: `llms.txt`, and every page in Markdown. An agent
reads it when your project's `AGENTS.md` tells it to:
Every package of rowtype installs its documentation for an agent with it, at
`$(opam var <package>:doc)`: `llms.txt`, and every page in Markdown. An
agent reads it when your project's `AGENTS.md` tells it to:

```md
Before writing code with rowtype, read `$(opam var rowtype:doc)/llms.txt` and
the pages it lists for the parts you need, and use those parts rather than
writing your own.
Before working with rowtype, read `llms.txt` in `$(opam var <package>:doc)`,
for any rowtype package the project installs, then the pages it lists for the
parts you need, and use those parts rather than writing your own.
```

## Contributing
Expand Down
1 change: 1 addition & 0 deletions agents/pages/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ names it as a module (`Rowtype_postgres`).
| `rowtype-postgres` | `rowtype-postgres` | The Postgres backend, over [postgres-eio](https://hyphatech.github.io/postgres-eio/) |
| `rowtype-sqlite` | `rowtype-sqlite` | The SQLite backend, over the [sqlite3](https://github.com/mmottl/sqlite3-ocaml) binding |
| `rowtype-migrate` | `rowtype-migrate`, `rowtype-migrate.postgres`, `rowtype-migrate.sqlite` | The migrations and the `rowtype-migrate` command, for each dialect installed beside it |
| `rowtype-test` | `rowtype-test` | A Postgres database a test run owns: a server for the run, a database of its own for each case that asks, and the `rowtype-test` command |

## rowtype

Expand Down
1 change: 1 addition & 0 deletions docs/src/content/docs/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ names it as a module (`Rowtype_postgres`).
| `rowtype-postgres` | `rowtype-postgres` | The Postgres backend, over [postgres-eio](https://hyphatech.github.io/postgres-eio/) |
| `rowtype-sqlite` | `rowtype-sqlite` | The SQLite backend, over the [sqlite3](https://github.com/mmottl/sqlite3-ocaml) binding |
| `rowtype-migrate` | `rowtype-migrate`, `rowtype-migrate.postgres`, `rowtype-migrate.sqlite` | The migrations and the `rowtype-migrate` command, for each dialect installed beside it |
| `rowtype-test` | `rowtype-test` | A Postgres database a test run owns: a server for the run, a database of its own for each case that asks, and the `rowtype-test` command |

## rowtype

Expand Down
29 changes: 27 additions & 2 deletions dune
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,36 @@
(:standard -w +a-4-40-41-42-44-45-48-67-70))))

; The documentation for a user's agent, agents/, written from the site's pages
; by `make docs`: rowtype, which every other package depends on, installs it
; whole, so $(opam var rowtype:doc) holds llms.txt and each page.
; by `make docs`: every package installs it whole, so a package installed
; alone, rowtype-migrate without rowtype, still holds llms.txt and each page in
; $(opam var <package>:doc).

(install
(package rowtype)
(section doc)
(source_trees
(agents as .)))

(install
(package rowtype-migrate)
(section doc)
(source_trees
(agents as .)))

(install
(package rowtype-postgres)
(section doc)
(source_trees
(agents as .)))

(install
(package rowtype-sqlite)
(section doc)
(source_trees
(agents as .)))

(install
(package rowtype-test)
(section doc)
(source_trees
(agents as .)))
7 changes: 6 additions & 1 deletion dune-project
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@
(ocamlformat
(and
:with-dev-setup
(= 0.29.0)))))
(= 0.29.0)))
(hypha-litany
(and
:with-dev-setup
(>= 1.3.0)
(< 2.0.0)))))

(package
(name rowtype-postgres)
Expand Down
223 changes: 223 additions & 0 deletions litany
Original file line number Diff line number Diff line change
@@ -0,0 +1,223 @@
; Hypha's lint set, as litany holds it. Every Hypha repository's litany file
; selects each rule here and keeps each forbid as it is written here; what is
; the repository's own -- a forbid more, a per-path -- is added with its
; reason. Hypha's OCAML.md says what each rule is for.

(litany-config 1)

(lint
(select default)
(extend
unsafe-partial-stdlib
unsafe-obj-magic
untyped-ignore
ignored-result
wildcard-over-owned-variant
open-of-ordinary-module
restricted-dependency))

(rule restricted-dependency
; Refused in every file.
(forbid Stdlib.failwith
(use "a result; a test that raises on purpose declares its own exception"))
(forbid Stdlib.compare
(use "the type's own comparison: Int.compare, String.compare"))
(forbid Stdlib.min
(use "the type's own: Int.min, Float.min"))
(forbid Stdlib.max
(use "the type's own: Int.max, Float.max"))
(forbid Unix.time
(use "the clock the caller gives, read as a Ptime.t"))
(forbid Unix.gettimeofday
(use "the clock the caller gives, read as a Ptime.t"))
(forbid Stdlib.Sys.time
(use "Eio.Time.Mono.now, for time that has passed"))
(forbid Unix.sleep
(use "Eio.Time.Mono.sleep_span"))
(forbid Unix.alarm
(use "Eio.Time.Timeout.v"))
(forbid Unix.setitimer
(use "Eio.Time.Timeout.v"))
(forbid Unix.getitimer
(use "Eio.Time.Mono.now"))
(forbid Eio_unix.sleep
(use "Eio.Time.Mono.sleep_span"))
(forbid Eio.Time.sleep
(use "Eio.Time.Mono.sleep_span"))
(forbid Eio.Time.sleep_until
(use "Eio.Time.Mono.sleep_span, over the span from now to the instant"))
(forbid Eio.Time.with_timeout
(use "Eio.Time.Timeout.v, given an Mtime.Span.t"))
(forbid Eio.Time.with_timeout_exn
(use "Eio.Time.Timeout.v, given an Mtime.Span.t"))
(forbid Eio.Time.Timeout.seconds
(use "Eio.Time.Timeout.v, given an Mtime.Span.t"))
(forbid Eio.Time.Mono.sleep
(use "Eio.Time.Mono.sleep_span"))
(forbid Uri.query
(use "what the router decoded and validated"))
(forbid Uri.get_query_param
(use "what the router decoded and validated"))
; Refused outside a library's clock module.
(forbid Eio.Time.now
(use "the library's instant.ml, which gives a Ptime.t")
(except **/instant.ml))
(forbid Unix.sleepf
(use "the library's instant.ml, which takes an Mtime.Span.t")
(except **/instant.ml))
; Refused in a library: a program, a test and an example own their process,
; wherever in the tree its bin/, test/, examples/ or bench/ is.
(forbid Stdlib.Sys.getenv
(use "a value the executable read at startup and passed in")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Sys.getenv_opt
(use "a value the executable read at startup and passed in")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Unix.getenv
(use "a value the executable read at startup and passed in")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Unix.environment
(use "a value the executable read at startup and passed in")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Unix.putenv
(use "an argument: a library sets no global state")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Sys.argv
(use "a value the executable read at startup and passed in")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Sys.signal
(use "the executable: it owns the process's signals")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Sys.set_signal
(use "the executable: it owns the process's signals")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Sys.chdir
(use "a directory capability the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Sys.command
(use "Eio.Process, on the process manager the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.at_exit
(use "Eio.Switch.on_release, on the switch the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Random.self_init
(use "a Random.State.t, or the secure random source the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Random.init
(use "a Random.State.t, or the secure random source the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Logs.set_reporter
(use "the executable: it configures the log reporter")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Logs.set_level
(use "the executable: it configures the log level")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.print_string
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.print_endline
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.print_bytes
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.print_char
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.print_int
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.print_float
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.print_newline
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.prerr_string
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.prerr_endline
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.prerr_bytes
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.prerr_char
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.prerr_int
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.prerr_float
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.prerr_newline
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.stdout
(use "a sink the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.stderr
(use "a sink the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Printf.printf
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Printf.eprintf
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Format.printf
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Format.eprintf
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Format.print_string
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Format.std_formatter
(use "a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Stdlib.Format.err_formatter
(use "a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Fmt.pr
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Fmt.epr
(use "a log on the library's own source, or a formatter the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Eio_main.run
(use "the env, switch or capability the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Ptime_clock.now
(use "the clock or ~now the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Mtime_clock.now
(use "the clock the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Mtime_clock.elapsed
(use "the clock the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Mtime_clock.counter
(use "the clock the caller gives")
(except **/bin/** **/test/** **/examples/** **/bench/**))
; Refused in a Melange library: the console is the page's.
(forbid Js.log
(use "a value returned to the caller")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Js.log2
(use "a value returned to the caller")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Js.log3
(use "a value returned to the caller")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Js.log4
(use "a value returned to the caller")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Js.logMany
(use "a value returned to the caller")
(except **/bin/** **/test/** **/examples/** **/bench/**))
(forbid Js.Console
(use "a value returned to the caller")
(except **/bin/** **/test/** **/examples/** **/bench/**)))
3 changes: 3 additions & 0 deletions migrate/postgres/rowtype_migrate_postgres.mli
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(** Migrations on Postgres, by {!Rowtype_migrate}'s files and rules: the library
[rowtype-migrate.postgres], built where [rowtype-postgres] is installed.

Its page, with its examples:
[$(opam var rowtype-migrate:doc)/pages/guide/migrations.md].

A run holds a Postgres advisory lock, so two processes migrating at once
take turns and the second finds nothing left to do; each migration runs only
on the session that took it. The connection's bounds are lifted for the run:
Expand Down
2 changes: 1 addition & 1 deletion migrate/rowtype_migrate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ let read migrations recorded =
| Some _ -> ((fun v -> v <= b.version), None)
| None -> ((fun _ -> false), Some b))
in
let highest = List.fold_left (fun h (v, _, _) -> max h v) 0 recorded in
let highest = List.fold_left (fun h (v, _, _) -> Int.max h v) 0 recorded in
let to_apply =
List.filter (fun m -> Option.is_none (recorded_as m.version)) migrations
|> List.sort (fun a b -> Int.compare a.version b.version)
Expand Down
6 changes: 6 additions & 0 deletions migrate/rowtype_migrate.mli
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
[rowtype-migrate.sqlite], built where that dialect's backend is installed,
so a program links the dialects it uses and no other.

Its documents, a page for each part:
[$(opam var rowtype-migrate:doc)/llms.txt].

Its page, with its examples:
[$(opam var rowtype-migrate:doc)/pages/guide/migrations.md].

A migration is a file named [<version>_<name>.sql] in one directory, the
version a UTC timestamp of fourteen digits. They are applied by the
[rowtype-migrate] command, which links no application:
Expand Down
Loading