♻️ Rename app.graph.ingest to app.graph.export

The holder vocabulary names the persisted relation write an
export, so the batch tier takes app.graph.export, its file entry
point becomes export-file!, and the two on-connection helpers
follow inside the namespace. print-ingest! and the srepl
ingest-file-to-graph! keep their names, with their references
repointed; their own renames can ride a reviewer's ask.

AI-assisted-by: glm-5.3-flash
Signed-off-by: Álvaro Tejero Cantero <alvorithm@teje.ro>
This commit is contained in:
Álvaro Tejero Cantero 2026-10-06 22:30:54 +02:00
parent 277dfb39ca
commit 5fe52ecc9e
No known key found for this signature in database
6 changed files with 27 additions and 27 deletions

View File

@ -11,7 +11,7 @@
(`app.graph.relation-overlay`), maintained from the msgbus file-change feed by
`app.graph.relation-overlay.sync` and queried in Datalog through
`app.graph.relation-overlay.console`. The Ladybug engine no longer appears on
this path: it keeps the batch-export tier (`app.graph.ingest`), where
this path: it keeps the batch-export tier (`app.graph.export`), where
columnar output is the point. The overlay is immutable data in an atom,
so readers never lock and the sync loop is the only writer."
(:require

View File

@ -4,7 +4,7 @@
;;
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns app.graph.ingest
(ns app.graph.export
"Penpot file -> Ladybug graph projection."
(:require
[app.binfile.common :as bfc]
@ -39,7 +39,7 @@
:file-id (str file-id)))
[file-id file]))
(defn- ingest-on-connection*!
(defn- export-on-connection*!
[system ^Connection conn file-id ^BufferAllocator allocator
{:keys [db-path skip-stats? skip-validation?] :or {skip-stats? true}}]
(let [[file-id file] (fetch-file! system file-id)
@ -47,7 +47,7 @@
data (:data file)]
(when-not skip-validation?
(ctf/check-file-data data))
(l/inf :hint "graph ingest"
(l/inf :hint "graph export"
:file-id (str file-id)
:revn (:revn file)
:db-path db-path
@ -74,7 +74,7 @@
:stats (when-not skip-stats?
(stats/summarize-connection conn))}))))
(defn ingest-on-connection!
(defn export-on-connection!
"Project `file-id` into an already open Ladybug `conn`.
Takes `:arrow-alloc`, owned by the caller. The allocator must stay open
@ -86,10 +86,10 @@
(when-not arrow-alloc
(ex/raise :type :validation
:code :missing-arrow-allocator
:hint "ingest-on-connection! requires :arrow-alloc; nest with-allocator! outside the connection"))
(ingest-on-connection*! system conn file-id arrow-alloc opts))
:hint "export-on-connection! requires :arrow-alloc; nest with-allocator! outside the connection"))
(export-on-connection*! system conn file-id arrow-alloc opts))
(defn ingest-file!
(defn export-file!
[system file-id & {:keys [db-path reset-db? skip-stats? skip-validation?]
:or {reset-db? true}}]
(let [db-path (or db-path (ladybug/db-path-for-file (h/parse-uuid file-id)))]
@ -102,7 +102,7 @@
(fn [allocator]
(ladybug/with-connection! db-path
(fn [conn]
(ingest-on-connection*! system conn file-id allocator
(export-on-connection*! system conn file-id allocator
{:db-path db-path
:skip-stats? skip-stats?
:skip-validation? skip-validation?})))))))

View File

@ -30,9 +30,9 @@
(println! (kv-line table count))))
(defn print-ingest!
"Pretty-print the result map returned by `app.graph.ingest/ingest-file!`."
"Pretty-print the result map returned by `app.graph.export/export-file!`."
[{:keys [file-id revn name db-path schema-version projection transforms stats]}]
(section-title "Graph ingest")
(section-title "Graph export")
(println! (kv-line "File" (str name " (" file-id ")"))
(kv-line "Revision" revn)
(kv-line "Schema" schema-version)

View File

@ -396,7 +396,7 @@
;; `app.graph.*` resolves at call time, never at the top of this namespace.
;; `app.graph.debug` (the console session tier) is a pure datascript overlay
;; and no longer touches Ladybug, but `app.graph.ingest` still projects
;; and no longer touches Ladybug, but `app.graph.export` still projects
;; through `app.graph.ladybug`, which imports `com.ladybugdb.*` and links the
;; native library into the JVM; this namespace loads on every backend boot.
;; The routes below are registered only under the `:graph` flag, so with the
@ -405,19 +405,19 @@
(defn- graph-export-file
"Path of a freshly projected graph for `file-id`."
[cfg file-id]
(let [ingest-file! (requiring-resolve 'app.graph.ingest/ingest-file!)
{:keys [db-path]} (ingest-file! cfg file-id :skip-stats? true)]
(let [export-file! (requiring-resolve 'app.graph.export/export-file!)
{:keys [db-path]} (export-file! cfg file-id :skip-stats? true)]
(when-not (fs/exists? db-path)
(ex/raise :type :internal
:code :graph-file-not-found
:hint "graph database file missing after ingest"
:hint "graph database file missing after export"
:file-id (str file-id)
:db-path db-path))
db-path))
(defn graph-export-handler
"Stream a Ladybug `.lbug` database for a file, projected afresh from the
database by `app.graph.ingest/ingest-file!` — the reproducible artifact.
database by `app.graph.export/export-file!` — the reproducible artifact.
`source=session` is retired: a console session is a datascript overlay
with no database file to stream, so it raises
@ -480,7 +480,7 @@
::yres/headers {"location" "/dbg/graph"}})
(defn graph-reload-handler
"Re-ingest the currently loaded file into the in-memory graph session."
"Reload the currently loaded file into the in-memory graph session."
[cfg {:keys [::session/profile-id]}]
(let [session-info (requiring-resolve 'app.graph.debug/session-info)
load-session! (requiring-resolve 'app.graph.debug/load-session!)]
@ -956,7 +956,7 @@
;; With the flag on, the Ladybug native library belongs to this process,
;; so load it here. A missing or unusable library then fails the boot
;; instead of the first console request.
(require 'app.graph.debug 'app.graph.ingest))
(require 'app.graph.debug 'app.graph.export))
[["/readyz" {:handler (partial health-handler cfg)}]
dbg]))

View File

@ -497,11 +497,11 @@
Options:
- `:db-path` path or `:memory:`
- `:reset-db?` delete any existing db first (default true)
- `:skip-stats?` skip post-ingest MATCH count queries (default false)"
- `:skip-stats?` skip post-export MATCH count queries (default false)"
[file-id & opts]
(let [ingest-file! (requiring-resolve 'app.graph.ingest/ingest-file!)
(let [export-file! (requiring-resolve 'app.graph.export/export-file!)
print-ingest! (requiring-resolve 'app.graph.report/print-ingest!)
result (apply ingest-file! sys/system file-id opts)]
result (apply export-file! sys/system file-id opts)]
(print-ingest! result)
result))

View File

@ -4,19 +4,19 @@
;;
;; Copyright (c) KALEIDOS SUBSIDIARY SL
(ns backend-tests.graph-ingest-test
"The batch-export tier, `app.graph.ingest`, which survives the retirement of
(ns backend-tests.graph-export-test
"The batch-export tier, `app.graph.export`, which survives the retirement of
the Ladybug session sync."
(:require
[app.common.uuid :as uuid]
[app.graph.ingest :as ingest]
[app.graph.export :as export]
[clojure.test :as t]))
(t/deftest ingest-on-connection-requires-allocator
;; The allocator must outlive the connection, so ingest cannot make its own
(t/deftest export-on-connection-requires-allocator
;; The allocator must outlive the connection, so export cannot make its own
;; inside the call — see `app.graph.arrow/with-allocator!`.
(try
(ingest/ingest-on-connection! nil nil (uuid/next))
(export/export-on-connection! nil nil (uuid/next))
(t/is false "expected :missing-arrow-allocator")
(catch clojure.lang.ExceptionInfo e
(t/is (= :missing-arrow-allocator (:code (ex-data e)))))))