From b3d0f8b1e76521c461b77aa1cfb52051d67cda42 Mon Sep 17 00:00:00 2001 From: Roman Zaiev Date: Thu, 3 Dec 2026 18:22:02 +0000 Subject: [PATCH] Release 0.7.2: check the rules by litany and send agents to the docs make lint already ran litany, but on a set of spool's own; it now runs Hypha's lint set, with the gold copy held whole in the litany file, and the code meets it. spool's own forbid of invalid_arg stays beside it, and the page's client and the build-time program that prints it are its two per-paths, each with its reason. An agent using spool reaches its signatures in the switch's lib/, by go-to-definition, a hover or a read, and never opens its doc/, where the catalogue and the pages are installed. So every interface names its page, where a page is about it, or its package's catalogue, by its path through opam var, and the README's With an agent says the same. --- AGENTS.md | 9 +- CHANGES.md | 6 + Makefile | 5 +- README.md | 12 +- dashboard/bundle.mli | 5 +- dashboard/live.mli | 5 +- dashboard/spool_dashboard.mli | 6 + dashboard/wire.mli | 5 +- dune | 13 +- dune-project | 2 +- litany | 236 +++++++++++++++++++++++++++++++++- spool.opam | 2 +- src/cron.mli | 4 +- src/spool.ml | 30 +++-- src/spool.mli | 2 + test/test_spool.ml | 64 ++++----- 16 files changed, 344 insertions(+), 62 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index c2d7968..d2d4dc2 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -10,7 +10,7 @@ documentation site, [docs/](docs/src/content/docs/index.mdx). ```sh make setup # once: the switch spool, all dependencies make test # starts the test Postgres in Podman, runs every test -make lint # formatting, odoc, the release build, litany, and the dashboard's bundle rebuilt and compared +make lint # formatting, odoc, the release build, Hypha's rules by litany, and the dashboard's bundle rebuilt and compared make fmt # format in place make dashboard # the dashboard's page built into dashboard/assets, to commit make docs # the documentation site into _build/docs, as Pages publishes it, and @@ -163,4 +163,9 @@ you broke it. Cite an entry by its bold phrase. run; and the dashboard page's entry, built without the element it draws in -- each a constant written in source or a build. Symptom: `make lint`'s litany reports `restricted-dependency` outside `src/spool.ml` - and `dashboard/web/src/main.ml`. + and `dashboard/web/src/main.ml`, by spool's own forbid among Hypha's. +- **The `litany` file's two `per-path`s are the page's client and its + printer**: `dashboard/web/printer/`, a build-time program that prints the + client and its errors, and the client, `dashboard/web/src/api.ml`, which + Spindle's printer writes as the build runs, so its code is Spindle's to + hold. diff --git a/CHANGES.md b/CHANGES.md index a849934..242e4cc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,11 @@ # Changes +## 0.7.2 (2026-12-03) + +- Every package installs the documentation for agents, `llms.txt` and every + page, in `$(opam var :doc)`, and every interface it installs + names its page there, or `llms.txt`. The README's *With an agent* says so. + ## 0.7.1 (2026-11-22) - The spool package installs its documentation for agents: each page as diff --git a/Makefile b/Makefile index 0d46bf4..02d6a20 100644 --- a/Makefile +++ b/Makefile @@ -34,8 +34,9 @@ build: ## build everything test: db ## run the tests SPOOL_TEST_PG=$(PG_TEST_URL) $(OPAM) dune test --force -# Release is the profile opam installs with. -lint: dashboard-check ## check formatting, docs, the release build, litany's rules and the dashboard's bundle +# Release is the profile opam installs with. litany holds the code to +# Hypha's rules, as the litany file selects them. +lint: dashboard-check ## check formatting, docs, the release build, Hypha's rules and the dashboard's bundle $(OPAM) dune build @all @fmt @doc $(OPAM) dune build --profile release @all $(OPAM) litany check diff --git a/README.md b/README.md index e5c8f75..ff33c7c 100644 --- a/README.md +++ b/README.md @@ -84,14 +84,14 @@ and `Spool.Runner.stop` stops it. ## With an agent -Each release installs its documentation for an agent with it, at -`$(opam var spool:doc)`: `llms.txt`, and every page in Markdown. An agent -reads it when your project's `AGENTS.md` tells it to: +Every package of spool installs its documentation for an agent with it, at +`$(opam var :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 spool, read `$(opam var spool: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 spool, read `llms.txt` in `$(opam var :doc)`, for +any spool package the project installs, then the pages it lists for the parts +you need, and use those parts rather than writing your own. ``` ## Contributing diff --git a/dashboard/bundle.mli b/dashboard/bundle.mli index 7144df9..48235e8 100644 --- a/dashboard/bundle.mli +++ b/dashboard/bundle.mli @@ -1,6 +1,9 @@ (** The page's files, as Vite built them into [dashboard/assets/]: written by [ocaml-crunch] as the package builds, by their path below that directory -- - ["index.html"], ["assets/index-.js"]. *) + ["index.html"], ["assets/index-.js"]. + + Its documents, a page for each part: + [$(opam var spool-dashboard:doc)/llms.txt]. *) val file_list : string list val read : string -> string option diff --git a/dashboard/live.mli b/dashboard/live.mli index b6484cf..d1037ce 100644 --- a/dashboard/live.mli +++ b/dashboard/live.mli @@ -1,5 +1,8 @@ (** The queue's live state, read once a second by one fiber of the process while - anyone watches, and sent to every viewer as what changed. *) + anyone watches, and sent to every viewer as what changed. + + Its documents, a page for each part: + [$(opam var spool-dashboard:doc)/llms.txt]. *) type stream (** The live route's events. *) diff --git a/dashboard/spool_dashboard.mli b/dashboard/spool_dashboard.mli index 1c86993..37b00d3 100644 --- a/dashboard/spool_dashboard.mli +++ b/dashboard/spool_dashboard.mli @@ -1,6 +1,12 @@ (** A live dashboard for spool's queue, as routes of the application's own Spindle server. + Its documents, a page for each part: + [$(opam var spool-dashboard:doc)/llms.txt]. + + Its page, with its examples: + [$(opam var spool-dashboard:doc)/pages/guide/dashboard.md]. + {[ let db : Spindle_postgres.Pool.t Spindle.Dep.t = Spindle.Dep.of_resource "database" diff --git a/dashboard/wire.mli b/dashboard/wire.mli index c2eee55..5977f2d 100644 --- a/dashboard/wire.mli +++ b/dashboard/wire.mli @@ -1,5 +1,8 @@ (** What the dashboard's routes read and answer, as wiretype descriptions: the - one contract the page's client is printed from. *) + one contract the page's client is printed from. + + Its documents, a page for each part: + [$(opam var spool-dashboard:doc)/llms.txt]. *) type action = | View diff --git a/dune b/dune index 5c160e1..cf95505 100644 --- a/dune +++ b/dune @@ -18,11 +18,18 @@ (migrations/*.sql with_prefix migrations)))) ; The documentation for a user's agent, agents/, written from the site's pages -; by `make docs`: spool installs it whole, so $(opam var spool:doc) holds -; llms.txt and each page. +; by `make docs`: every package installs it whole, so a package installed +; alone, spool-dashboard without spool, still holds llms.txt and each page in +; $(opam var :doc). (install - (section doc) (package spool) + (section doc) + (source_trees + (agents as .))) + +(install + (package spool-dashboard) + (section doc) (source_trees (agents as .))) diff --git a/dune-project b/dune-project index 57b8c84..a4d7511 100644 --- a/dune-project +++ b/dune-project @@ -47,7 +47,7 @@ (timedesc (>= 3.1.2)) (eio_main (and :with-test (>= 1.5))) (alcotest (and :with-test (>= 1.9.1))) - (hypha-litany (and :with-dev-setup (>= 1.2.2) (< 2.0.0))) + (hypha-litany (and :with-dev-setup (>= 1.3.0) (< 2.0.0))) (merlin (and :with-dev-setup (>= 5.6-504))) (ocaml-lsp-server (and :with-dev-setup (>= 1.25.0))) (ocamlformat (and :with-dev-setup (= 0.29.0))) diff --git a/litany b/litany index a71c65a..52718b8 100644 --- a/litany +++ b/litany @@ -1,9 +1,239 @@ -; The rules of Hypha's and spool's own a lint holds, beyond litany's default set. +; 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 open-of-ordinary-module restricted-dependency)) + (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/**)) + ; spool's own: invalid_arg is a constant's alone, where AGENTS.md says. (forbid Stdlib.invalid_arg (use "a result: invalid_arg is a constant's, written in source: Kind.make's and Schedule.make's") - (except src/spool.ml dashboard/web/src/main.ml test/** examples/**))) + (except src/spool.ml dashboard/web/src/main.ml **/test/** **/examples/**))) + +; spool's own. + +(per-path + (paths dashboard/web/printer/**) + (ignore restricted-dependency) + (reason "a build-time program: it prints the page's client, which dune writes into api.ml, and its errors, and exits with its status")) + +(per-path + (paths _build/default/dashboard/web/src/api.ml) + (ignore unsafe-obj-magic unsafe-partial-stdlib wildcard-over-owned-variant) + (reason "the page's client as Spindle prints it while dune builds, never kept: its code is Spindle's printer's to hold, and no attribute of spool's can reach it")) diff --git a/spool.opam b/spool.opam index 0f5063f..d6a6d08 100644 --- a/spool.opam +++ b/spool.opam @@ -21,7 +21,7 @@ depends: [ "timedesc" {>= "3.1.2"} "eio_main" {with-test & >= "1.5"} "alcotest" {with-test & >= "1.9.1"} - "hypha-litany" {with-dev-setup & >= "1.2.2" & < "2.0.0"} + "hypha-litany" {with-dev-setup & >= "1.3.0" & < "2.0.0"} "merlin" {with-dev-setup & >= "5.6-504"} "ocaml-lsp-server" {with-dev-setup & >= "1.25.0"} "ocamlformat" {with-dev-setup & = "0.29.0"} diff --git a/src/cron.mli b/src/cron.mli index b641e1f..05edc19 100644 --- a/src/cron.mli +++ b/src/cron.mli @@ -1,5 +1,7 @@ (** A five-field cron expression -- minute, hour, day of the month, month, day - of the week -- read in a time zone, and the instants it names. *) + of the week -- read in a time zone, and the instants it names. + + Its documents, a page for each part: [$(opam var spool:doc)/llms.txt]. *) type t diff --git a/src/spool.ml b/src/spool.ml index 7b1776e..9cf20cc 100644 --- a/src/spool.ml +++ b/src/spool.ml @@ -1758,10 +1758,12 @@ module Runner = struct outlives it by a poll. *) let sleep t span = if not t.closed then - ignore - (Eio.Time.Timeout.run (Eio.Time.Timeout.v t.clock span) (fun () -> - Eio.Condition.await_no_mutex t.quit; - Ok ())) + match + Eio.Time.Timeout.run (Eio.Time.Timeout.v t.clock span) (fun () -> + Eio.Condition.await_no_mutex t.quit; + Ok ()) + with + | Ok () | Error `Timeout -> () let create ~sw ~net ~mono_clock ~now ?(pool_size = 2) ?(poll = Mtime.Span.s) ?(lease = Mtime.Span.min) ?(retain_completed = Mtime.Span.day) @@ -2107,7 +2109,9 @@ module Runner = struct let outcome = run_attempt t h row in Hashtbl.remove t.running id; let took = since t started in - ignore (finish t h ~id ~attempt ~max_attempts ~took outcome)) + ignore + (finish t h ~id ~attempt ~max_attempts ~took outcome + : state option)) with | Eio.Cancel.Cancelled _ -> Hashtbl.remove t.running id | e -> @@ -2233,10 +2237,12 @@ module Runner = struct in if q.dirty then q.dirty <- false else ( - ignore - (Eio.Time.Timeout.run (Eio.Time.Timeout.v t.clock wait) (fun () -> + (match + Eio.Time.Timeout.run (Eio.Time.Timeout.v t.clock wait) (fun () -> Eio.Condition.await_no_mutex q.cond; - Ok ())); + Ok ()) + with + | Ok () | Error `Timeout -> ()); q.dirty <- false); queue_loop t q end @@ -2487,12 +2493,14 @@ module Runner = struct if not t.closing then begin t.closing <- true; wake_all t; - ignore - (Eio.Time.Timeout.run (Eio.Time.Timeout.v t.clock grace) (fun () -> + (match + Eio.Time.Timeout.run (Eio.Time.Timeout.v t.clock grace) (fun () -> while Hashtbl.length t.running > 0 do Eio.Condition.await_no_mutex t.idle done; - Ok ())); + Ok ()) + with + | Ok () | Error `Timeout -> ()); let left = Hashtbl.fold (fun id r acc -> (id, r) :: acc) t.running [] in List.iter (fun (id, r) -> lost t id r Stopping) left; Eio.Fiber.yield (); diff --git a/src/spool.mli b/src/spool.mli index 0ec188d..d7fb3d0 100644 --- a/src/spool.mli +++ b/src/spool.mli @@ -1,5 +1,7 @@ (** A durable queue of work in an application's own Postgres. + Its documents, a page for each part: [$(opam var spool:doc)/llms.txt]. + A job is a row, written through the caller's connection in the transaction that made the work owed -- so a rollback leaves no job, and a commit leaves one nothing can lose. A {!Runner} claims it under a lease, runs its handler diff --git a/test/test_spool.ml b/test/test_spool.ml index b12d7b9..e25c3c8 100644 --- a/test/test_spool.ml +++ b/test/test_spool.ml @@ -305,7 +305,7 @@ let test_retry_in_waits_what_it_names () = Error (J.Retry_in (Mtime.Span.(7 * s), "rate limited"))); ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); Alcotest.check instant "seven seconds on" (plus (now ()) Mtime.Span.(7 * s)) (find conn id).scheduled_at; @@ -319,7 +319,7 @@ let test_the_last_attempt_discards () = let r = runner ~now target [ J.handle kind (fun _ _ -> Error (J.Retry "no")) ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); at := plus !at Mtime.Span.min; Alcotest.check outcomes "discarded" [ (id, J.Discarded) ] (drain r); let info = find conn id in @@ -460,7 +460,7 @@ let test_order_is_priority_then_instant_then_enqueueing () = let kind = text "ordered" in let seen = ref [] in let e ?priority ?at arg = - ignore (enqueue conn ~now:(now ()) ?priority ?at kind arg) + ignore (enqueue conn ~now:(now ()) ?priority ?at kind arg : J.Id.t) in e ~priority:5 "late priority"; e @@ -479,7 +479,7 @@ let test_order_is_priority_then_instant_then_enqueueing () = Ok ()); ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); Alcotest.(check (list string)) "in order" [ "earlier"; "first enqueued"; "second enqueued"; "late priority" ] @@ -522,14 +522,14 @@ let test_cancel_and_retry () = (Option.is_none (ok "retry" (J.retry conn ~now:(now ()) fails))); (* Discarded again, and meanwhile the key asked again: the retry is the job already waiting. *) - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); let fresh = enqueue conn ~now:(now ()) ~unique:"k" kind "fresh" in (match ok "retry" (J.retry conn ~now:(now ()) fails) with | Some id -> check_bool "the waiting one" true (J.Id.equal id fresh) | None -> Alcotest.fail "no answer"); Alcotest.check state "the retried row left finished" J.Discarded (find conn fails).state; - ignore (ok "retry" (J.retry conn ~now:(now ()) waiting)); + ignore (ok "retry" (J.retry conn ~now:(now ()) waiting) : J.Id.t option); Alcotest.check state "a cancelled job retried" J.Available (find conn waiting).state; J.Runner.stop r) @@ -735,7 +735,7 @@ let test_a_notification_wakes_a_sleeping_queue () = in J.Runner.start r; sleep Mtime.Span.(500 * ms); - ignore (enqueue conn ~now:(real_now ()) kind "x"); + ignore (enqueue conn ~now:(real_now ()) kind "x" : J.Id.t); eventually ~within:Mtime.Span.(2 * s) "run long before the poll" @@ -760,7 +760,7 @@ let test_a_runner_idle_past_the_heartbeat_still_runs_jobs () = in J.Runner.start r; sleep Mtime.Span.(12 * s); - ignore (enqueue conn ~now:(real_now ()) kind "x"); + ignore (enqueue conn ~now:(real_now ()) kind "x" : J.Id.t); eventually ~within:Mtime.Span.(3 * s) "heard, after the heartbeat" @@ -786,7 +786,7 @@ let test_jobs_run_without_the_listener () = Db_target.exec conn "select pg_terminate_backend(pid) from pg_stat_activity where datname \ = current_database() and query like 'LISTEN%'"; - ignore (enqueue conn ~now:(real_now ()) kind "x"); + ignore (enqueue conn ~now:(real_now ()) kind "x" : J.Id.t); eventually ~within:Mtime.Span.(3 * s) "run by the poll" (fun () -> !ran); J.Runner.stop r) @@ -828,7 +828,7 @@ let test_finished_rows_are_pruned_by_retention () = if String.equal arg "bad" then Error (J.Discard "no") else Ok () in let r = runner ~now target [ J.handle kind handler ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); J.Runner.stop r; at := plus !at Mtime.Span.(2 * day); let pruner = runner ~now target [ J.handle kind handler ] in @@ -919,7 +919,7 @@ let test_no_payload_reaches_a_log () = let now, at = clock () in let secret = "s3cr3t-payload" in let kind = text "private" in - ignore (enqueue conn ~now:(now ()) kind secret); + ignore (enqueue conn ~now:(now ()) kind secret : J.Id.t); let calls = ref 0 in let r = runner ~now target @@ -932,11 +932,11 @@ let test_no_payload_reaches_a_log () = | _ -> Ok ()); ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); at := plus !at Mtime.Span.min; - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); at := plus !at Mtime.Span.min; - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); J.Runner.stop r; check_bool "something was logged" true (!lines <> []); List.iter @@ -1040,7 +1040,7 @@ let test_each_attempt_is_counted_by_its_second () = | _ -> Ok ()); ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); let a_minute_ago = Option.value ~default:(now ()) (Ptime.sub_span (now ()) (Ptime.Span.of_int_s 60)) @@ -1080,7 +1080,7 @@ let test_delete_removes_any_job_but_a_running_one () = check_bool "gone" true (Option.is_none (ok "find" (J.find conn waiting))); let finished = enqueue conn ~now:(now ()) kind "f" in let r = runner ~now target [ J.handle kind done_ ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); check_bool "a finished job deleted" true (ok "delete" (J.delete conn ~now:(now ()) finished)); check_bool "an unknown id is no deletion" false @@ -1338,13 +1338,19 @@ let test_a_tick_is_one_job_across_runners () = ] in let a = start () and b = start () and c = start () in - List.iter (fun r -> ignore (drain r)) [ a; b; c ]; + List.iter + (fun r -> ignore (drain r : (J.Id.t * J.state) list)) + [ a; b; c ]; check_int "nothing before its first tick" 0 !ran; at := plus !at Mtime.Span.min; - List.iter (fun r -> ignore (drain r)) [ a; b; c ]; + List.iter + (fun r -> ignore (drain r : (J.Id.t * J.state) list)) + [ a; b; c ]; check_int "its tick, once" 1 !ran; at := plus !at Mtime.Span.(10 * min); - List.iter (fun r -> ignore (drain r)) [ a; b; c ]; + List.iter + (fun r -> ignore (drain r : (J.Id.t * J.state) list)) + [ a; b; c ]; check_int "ten missed, the latest alone" 2 !ran; (match ok "schedules" (J.Schedule.list conn) with | [ (i : J.Schedule.info) ] -> @@ -1492,7 +1498,7 @@ let test_many_are_enqueued_at_once () = Ok ()); ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); check_int "every one run" 503 !seen; J.Runner.stop r) @@ -1535,7 +1541,7 @@ let test_a_summary_runs_once_after_every_row () = Ok ()); ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); Alcotest.(check (list string)) "the summary last, once" [ "1"; "2"; "3"; "summary" ] @@ -1560,7 +1566,7 @@ let test_a_failed_row_cancels_what_waits_on_it () = J.handle summary done_; ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); let cancelled id = let info = find conn id in Alcotest.check state "cancelled" J.Cancelled info.state; @@ -1580,12 +1586,12 @@ let test_what_a_job_waits_for_may_be_gone_or_done () = let next = text "next" in let g = enqueue conn ~now:(now ()) gone "g" in let r = runner ~now target [ J.handle gone done_; J.handle next done_ ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); let n = enqueue_after conn ~now:(now ()) ~waits_for:[ g ] next "n" in Alcotest.check state "a completed job no longer kept is done" J.Available (find conn n).state; let c = enqueue conn ~now:(now ()) next "c" in - ignore (ok "cancel" (J.cancel conn ~now:(now ()) c)); + ignore (ok "cancel" (J.cancel conn ~now:(now ()) c) : bool); let w = enqueue_after conn ~now:(now ()) ~waits_for:[ c ] next "w" in Alcotest.check state "one waiting for a cancelled job is cancelled" J.Cancelled (find conn w).state; @@ -1597,7 +1603,7 @@ let test_cancelling_a_job_cancels_what_waits_on_it () = let kind = text "step" in let a = enqueue conn ~now:(now ()) kind "a" in let b = enqueue_after conn ~now:(now ()) ~waits_for:[ a ] kind "b" in - ignore (ok "cancel" (J.cancel conn ~now:(now ()) a)); + ignore (ok "cancel" (J.cancel conn ~now:(now ()) a) : bool); Alcotest.check state "cancelled with it" J.Cancelled (find conn b).state) let test_a_workflow_is_its_jobs_and_their_edges () = @@ -1682,7 +1688,7 @@ let test_jobs_are_listed_newest_first_a_page_at_a_time () = (List.length (ok "jobs" (J.jobs conn ~kind:"a" ~before:last ~limit:10))); check_int "by queue" 1 (List.length (ok "jobs" (J.jobs conn ~queue:"other" ~limit:10))); - ignore (ok "cancel" (J.cancel conn ~now:(now ()) other)); + ignore (ok "cancel" (J.cancel conn ~now:(now ()) other) : bool); check_int "by state" 1 (List.length (ok "jobs" (J.jobs conn ~state:J.Cancelled ~limit:10))); Alcotest.(check (list (triple string state int))) @@ -1730,10 +1736,10 @@ let test_jobs_are_found_by_when_an_attempt_finished () = ] in let start = now () in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); at := plus !at Mtime.Span.(2 * min); let ok_late = enqueue conn ~now:(now ()) kind "ok" in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); let first = (start, plus start Mtime.Span.min) in let ids which span = List.map @@ -1763,7 +1769,7 @@ let test_a_finished_job_runs_again_as_a_copy () = let kind = text ~queue:"default" "note" in let first = enqueue conn ~now:(now ()) ~unique:"k" kind "hello" in let r = runner ~now target [ J.handle kind done_ ] in - ignore (drain r); + ignore (drain r : (J.Id.t * J.state) list); (match ok "again" (J.run_again conn ~now:(now ()) first) with | None -> Alcotest.fail "not run again" | Some copy ->