aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcos Magueta <maguetamarcos@gmail.com>2026-07-07 16:07:07 -0300
committerMarcos Magueta <maguetamarcos@gmail.com>2026-07-07 16:07:07 -0300
commit5a799734ddd523027a7d6ef8b0acab6d0b796ec6 (patch)
tree45f11504d8ca7ad55ba3cbb85ad778907e1ecf3f
parentab70e5461b98ddf2b56268c53c171cab89157027 (diff)
downloadRNT-5a799734ddd523027a7d6ef8b0acab6d0b796ec6.tar.gz
RNT-5a799734ddd523027a7d6ef8b0acab6d0b796ec6.zip
object manager initial model and sotrage stubs
-rw-r--r--.ocamlformat30
-rw-r--r--dune-project25
-rw-r--r--flake.lock27
-rw-r--r--flake.nix59
-rw-r--r--lib/ObjectManager.ml37
-rw-r--r--lib/StorageBackend.ml11
-rw-r--r--lib/dune4
-rw-r--r--lib/rnt.ml3
-rw-r--r--rnt.opam32
-rw-r--r--test/dune3
-rw-r--r--test/test_rnt.ml2
11 files changed, 233 insertions, 0 deletions
diff --git a/.ocamlformat b/.ocamlformat
new file mode 100644
index 0000000..280d9fc
--- /dev/null
+++ b/.ocamlformat
@@ -0,0 +1,30 @@
+version = 0.29.0
+# `compact`/`sparse` profiles were removed in 0.22; `ocamlformat` is the
+# densest remaining base. The knobs below tighten it further.
+profile = ocamlformat
+
+# Wider lines pack more per line -> fewer wraps, denser code.
+margin = 100
+
+# No blank lines forced between structure items / let bindings.
+module-item-spacing = compact
+let-binding-spacing = compact
+
+# Tight delimiters: no inner spaces in [..], {..}, (..), arrays.
+space-around-lists = false
+space-around-arrays = false
+space-around-records = false
+space-around-variants = false
+field-space = tight
+
+# Keep conditionals and matches on as few lines as fit.
+if-then-else = compact
+break-cases = fit
+break-infix = fit-or-vertical
+break-separators = after
+parens-tuple = multi-line-only
+sequence-style = terminator
+
+# Don't reflow comment text; leave doc comments as written.
+wrap-comments = false
+doc-comments = before \ No newline at end of file
diff --git a/dune-project b/dune-project
new file mode 100644
index 0000000..6835e07
--- /dev/null
+++ b/dune-project
@@ -0,0 +1,25 @@
+(lang dune 3.6)
+
+(name rnt)
+
+(generate_opam_files true)
+
+(source
+ (github dont-rely-on-nulls/RNT))
+
+(license AGPL-3.0-only)
+
+(authors "Marcos Magueta" "Estevan Castilho")
+
+(maintainers "Marcos Magueta <maguetamarcos@gmail.com>")
+
+(package
+ (name rnt)
+ (synopsis "Relations, Not Tables: an experimental database kernel")
+ (description
+ "RNT is an experimental database kernel inspired by the object-management model of the Windows NT kernel.")
+ (depends
+ (ocaml
+ (>= 4.14))
+ batteries
+ (alcotest :with-test)))
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..13ef078
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,27 @@
+{
+ "nodes": {
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1783224372,
+ "narHash": "sha256-8i/87eeoqiGE4yOTjwSA3Eh/ziJRQEmd/unYU+K27sk=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "d407951447dcd00442e97087bf374aad70c04cea",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixos-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "nixpkgs": "nixpkgs"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..47c6400
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,59 @@
+{
+ description = "RNT — Relations, Not Tables: an experimental database kernel (OCaml library)";
+
+ inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
+
+ outputs = { self, nixpkgs }:
+ let
+ systems = [
+ "x86_64-linux"
+ "aarch64-linux"
+ "x86_64-darwin"
+ "aarch64-darwin"
+ ];
+
+ forAllSystems = f:
+ nixpkgs.lib.genAttrs systems (system:
+ f (import nixpkgs { inherit system; }));
+ in
+ {
+ packages = forAllSystems (pkgs:
+ let ocamlPackages = pkgs.ocamlPackages; in
+ {
+ default = ocamlPackages.buildDunePackage {
+ pname = "rnt";
+ version = "0.1.0";
+ duneVersion = "3";
+ src = self;
+
+ propagatedBuildInputs = [ ocamlPackages.batteries ];
+ checkInputs = [ ocamlPackages.alcotest ];
+ doCheck = true;
+
+ meta = {
+ description =
+ "RNT database kernel inspired by the Windows NT object manager";
+ license = pkgs.lib.licenses.agpl3Only;
+ maintainers = [ { name = "Marcos Magueta"; } ];
+ };
+ };
+ });
+
+ devShells = forAllSystems (pkgs:
+ let ocamlPackages = pkgs.ocamlPackages; in
+ {
+ default = pkgs.mkShell {
+ inputsFrom = [ self.packages.${pkgs.system}.default ];
+ packages = [
+ pkgs.dune_3
+ ocamlPackages.ocaml
+ ocamlPackages.ocaml-lsp
+ ocamlPackages.ocamlformat
+ ocamlPackages.utop
+ ocamlPackages.batteries
+ ocamlPackages.alcotest
+ ];
+ };
+ });
+ };
+}
diff --git a/lib/ObjectManager.ml b/lib/ObjectManager.ml
new file mode 100644
index 0000000..b107b4e
--- /dev/null
+++ b/lib/ObjectManager.ml
@@ -0,0 +1,37 @@
+type multigroup = {merkle_root: string}
+type relation = {merkle_root: string}
+type ephemeral_relation = {merkle_root: string; dependencies: string BatFingerTree.t}
+type transaction = unit
+type session = {connection_context: unit; branch_overrides: string BatMap.String.t}
+type branch = {name: string; target_hash: string}
+type branch_tree = {merkle_root: string}
+
+type rnt_object_kind =
+ | Multigroup of multigroup
+ | Relation of relation
+ | EphemeralRelation of ephemeral_relation
+ | Session of session
+ | Branch of branch
+ | BranchTree of branch_tree
+
+type rnt_method = OPEN | CLOSE
+
+type rnt_object =
+ {kind: rnt_object_kind; disposable: bool; methods: rnt_method BatSet.t; exclsive: bool}
+
+type registry = {reference_count: int; handle_count: int; entry: rnt_object}
+
+type rnt_object_tree =
+ | Intermediary of {label: string; data: registry; subsequent: rnt_object_tree BatFingerTree.t}
+ | Final of {label: string; data: registry}
+
+let register (_object_path : string BatFingerTree.t) (_registry : rnt_object_tree)
+ (_rnt_object : rnt_object) : rnt_object_tree =
+ failwith "NOT IMPLEMENTED"
+
+let find (_object_path : string BatFingerTree.t) (_registry : rnt_object_tree) : registry =
+ failwith "NOT IMPLEMENTED"
+
+let unregister (_object_path : string BatFingerTree.t) (_registry : rnt_object_tree) :
+ rnt_object_tree =
+ failwith "NOT IMPLEMENTED"
diff --git a/lib/StorageBackend.ml b/lib/StorageBackend.ml
new file mode 100644
index 0000000..0e7106b
--- /dev/null
+++ b/lib/StorageBackend.ml
@@ -0,0 +1,11 @@
+module type T = sig
+ val put: bytes -> string
+ val get: string -> bytes option
+end
+
+module SQLite: T = struct
+ let put (_value: bytes) =
+ failwith "NOT IMPLEMENTED"
+ let get (_hash: string) =
+ failwith "NOT IMPLEMENTED"
+end
diff --git a/lib/dune b/lib/dune
new file mode 100644
index 0000000..7ab7df1
--- /dev/null
+++ b/lib/dune
@@ -0,0 +1,4 @@
+(library
+ (name rnt)
+ (public_name rnt)
+ (libraries batteries))
diff --git a/lib/rnt.ml b/lib/rnt.ml
new file mode 100644
index 0000000..7192e6b
--- /dev/null
+++ b/lib/rnt.ml
@@ -0,0 +1,3 @@
+(** RNT: Relations, Not Tables. *)
+
+let version = "0.1.0"
diff --git a/rnt.opam b/rnt.opam
new file mode 100644
index 0000000..be38e5b
--- /dev/null
+++ b/rnt.opam
@@ -0,0 +1,32 @@
+# This file is generated by dune, edit dune-project instead
+opam-version: "2.0"
+synopsis: "Relations, Not Tables: an experimental database kernel"
+description:
+ "RNT is an experimental database kernel inspired by the object-management model of the Windows NT kernel."
+maintainer: ["Marcos Magueta <maguetamarcos@gmail.com>"]
+authors: ["Marcos Magueta" "Estevan Castilho"]
+license: "AGPL-3.0-only"
+homepage: "https://github.com/dont-rely-on-nulls/RNT"
+bug-reports: "https://github.com/dont-rely-on-nulls/RNT/issues"
+depends: [
+ "dune" {>= "3.6"}
+ "ocaml" {>= "4.14"}
+ "batteries"
+ "alcotest" {with-test}
+ "odoc" {with-doc}
+]
+build: [
+ ["dune" "subst"] {dev}
+ [
+ "dune"
+ "build"
+ "-p"
+ name
+ "-j"
+ jobs
+ "@install"
+ "@runtest" {with-test}
+ "@doc" {with-doc}
+ ]
+]
+dev-repo: "git+https://github.com/dont-rely-on-nulls/RNT.git"
diff --git a/test/dune b/test/dune
new file mode 100644
index 0000000..3c52f25
--- /dev/null
+++ b/test/dune
@@ -0,0 +1,3 @@
+(test
+ (name test_rnt)
+ (libraries rnt alcotest))
diff --git a/test/test_rnt.ml b/test/test_rnt.ml
new file mode 100644
index 0000000..4838ff4
--- /dev/null
+++ b/test/test_rnt.ml
@@ -0,0 +1,2 @@
+let test_version () = Alcotest.(check string) "version" "0.1.0" Rnt.version
+let () = Alcotest.run "rnt" ["smoke", [Alcotest.test_case "version" `Quick test_version]]