From c972784b43a8fdc3e89000d5e43bd225338a07e4 Mon Sep 17 00:00:00 2001 From: Nick Ponomarev Date: Wed, 4 Nov 2026 12:58:57 +0300 Subject: [PATCH 1/3] add: basic AGENTS.md --- AGENTS.md | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 AGENTS.md diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..c73a5fb --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,43 @@ +# QTreeFSharp + +F# prototype of GraphBLAS-style sparse linear algebra on quad-trees, used to implement graph algorithms. + +## Projects + +- `QuadTree/` — library; see `QuadTree.fsproj` for compile order (`Common`, `Result`, `AVLSet`, `Vector`, `Matrix`, `LinearAlgebra`, then graph algorithms). +- `QuadTree.Tests/` — xUnit + FsUnit + FsCheck tests. +- `QuadTree.Benchmark/` — BenchmarkDotNet console app. + +F# compiles files top-to-bottom: new source files must be added to the relevant `.fsproj` `` list in dependency order, or they will silently not be compiled. Benchmark classes must also be registered in `QuadTree.Benchmark/Main.fs`'s `BenchmarkSwitcher`. + +Requires .NET SDK 10 (`net10.0`). + +## Commands + +```bash +dotnet tool restore # once; installs pinned Fantomas 7.0.5 +dotnet fantomas --check . # CI format gate; runs before tests +dotnet fantomas . # apply formatting +dotnet build +dotnet test +dotnet test --filter "FullyQualifiedName~Graph.BFS" # focused suite/namespace +``` + +CI (`.github/workflows/dotnet-tests.yaml`) fails on any formatting diff, so run Fantomas before considering work complete. + +## Benchmarks + +```bash +dotnet run -c Release --project QuadTree.Benchmark -- --filter '*BFS*' +``` + +- Matrices go in `QuadTree.Benchmark/data/`. `Utils.DIR_WITH_MATRICES` is a seven-level relative path chosen so it resolves from BenchmarkDotNet's generated working directory; do not "fix" it to a repo-relative path. +- `*.mtx` is gitignored, but the small demo matrices are committed. Use `git add -f` only when intentionally adding one. + +## Conventions + +- `Matrix` is a 2D quad-tree and `Vector` a 1D binary tree. Storage is padded to the next power of two independently of the logical dimensions. +- Preserve the `Leaf Dummy` vs `Leaf (UserValue None)` distinction: `Dummy` means an entirely empty/out-of-range subtree, `UserValue None` an in-range empty cell. Several algorithms branch on this. +- Dimensions and indices use F# units of measure (`nrows`, `ncols`, `nvals`, `rowindex`, `colindex`, `dataLength`, `index`, `storageSize`) and are `uint64`. Keep units on new APIs. +- Errors are returned as `Result<_, Error>` using the repo's own `Result` module and `resultM { ... }` computation expression (`QuadTree/Result.fs`); do not throw for expected failures. +- Graph algorithms are generic over `op_add`/`op_mult` (semiring-style); algorithm modules live under `Graph.*`, while `AVLSet` uses the `QuadTree.AVLSet` namespace with a parallel variant in `ParallelAVLSet.fs`. From 4e29a818165edde2903dfdb1ccd79ea501febfd9 Mon Sep 17 00:00:00 2001 From: Nick Ponomarev Date: Wed, 4 Nov 2026 12:58:57 +0300 Subject: [PATCH 2/3] add: basic AGENTS.md and TODO.md --- AGENTS.md | 42 ++++++++++++++++++++++++++++++++++-------- TODO.md | 12 ++++++++++++ 2 files changed, 46 insertions(+), 8 deletions(-) create mode 100644 TODO.md diff --git a/AGENTS.md b/AGENTS.md index c73a5fb..ea96681 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,10 +1,36 @@ # QTreeFSharp -F# prototype of GraphBLAS-style sparse linear algebra on quad-trees, used to implement graph algorithms. +A F# sparse linear algebra suite used as a prototype for further translation to Interaction Nets interpreters such as [inpla](https://github.com/inpla/inpla), [bancai](https://github.com/Lamagraph/bancai) or [vine](https://github.com/VineLang/vine). + +## Research questions + +- RQ1: Which sparse matrix representation is most suitable (performant/easy to use) for Interaction Nets? + +## Philosophy + +- Algorithms must be decoupled from concrete matrix representation. +- In general, every representation must have a vector and a matrix implemented. +- Matrix operations must be decently fast, but writing C-like code for the sake of performance is discouraged. +- Functional-style constructions are preferred to OOP ones. E.g. passing a record with functions is preferred to implementing an interface. + +## Coding Conventions + +- Units of measure must be used for a clear distinction between dimensions and indices. They are usually of type `uint64`. Keep them on new APIs. +- Graph algorithms are generic over `op_add`/`op_mult` (semiring-style). +- Algorithm modules live under `Graph.*`, while `AVLSet` uses the `QuadTree.AVLSet` namespace with a parallel variant in `ParallelAVLSet.fs`. +- Main code must not use imperative or OOP constructions like `for`-loops or classes, implementation must be as functionally idiomatic as possible. Test and benchmarks aren't restricted by this rule. +- OOP-style exceptions are prohibited. Use `Result<_, Error>` and `resultM { ... }` computation expression from `QuadTree/Result.fs`. + +## Implementation Notes +(currently applies to quadtree representation) + +- `Matrix` is a 2D quad-tree and `Vector` a 1D binary tree. Storage is padded to the next power of two independently of the logical dimensions. +- Preserve the `Leaf Dummy` vs `Leaf (UserValue None)` distinction: `Dummy` means an entirely empty/out-of-range subtree, `UserValue None` an in-range empty cell. Several algorithms branch on this. + ## Projects -- `QuadTree/` — library; see `QuadTree.fsproj` for compile order (`Common`, `Result`, `AVLSet`, `Vector`, `Matrix`, `LinearAlgebra`, then graph algorithms). +- `QuadTree/` — library; see `QuadTree.fsproj` for compile order. - `QuadTree.Tests/` — xUnit + FsUnit + FsCheck tests. - `QuadTree.Benchmark/` — BenchmarkDotNet console app. @@ -34,10 +60,10 @@ dotnet run -c Release --project QuadTree.Benchmark -- --filter '*BFS*' - Matrices go in `QuadTree.Benchmark/data/`. `Utils.DIR_WITH_MATRICES` is a seven-level relative path chosen so it resolves from BenchmarkDotNet's generated working directory; do not "fix" it to a repo-relative path. - `*.mtx` is gitignored, but the small demo matrices are committed. Use `git add -f` only when intentionally adding one. -## Conventions +## User workflow -- `Matrix` is a 2D quad-tree and `Vector` a 1D binary tree. Storage is padded to the next power of two independently of the logical dimensions. -- Preserve the `Leaf Dummy` vs `Leaf (UserValue None)` distinction: `Dummy` means an entirely empty/out-of-range subtree, `UserValue None` an in-range empty cell. Several algorithms branch on this. -- Dimensions and indices use F# units of measure (`nrows`, `ncols`, `nvals`, `rowindex`, `colindex`, `dataLength`, `index`, `storageSize`) and are `uint64`. Keep units on new APIs. -- Errors are returned as `Result<_, Error>` using the repo's own `Result` module and `resultM { ... }` computation expression (`QuadTree/Result.fs`); do not throw for expected failures. -- Graph algorithms are generic over `op_add`/`op_mult` (semiring-style); algorithm modules live under `Graph.*`, while `AVLSet` uses the `QuadTree.AVLSet` namespace with a parallel variant in `ParallelAVLSet.fs`. +Repository owner's rely heavily on agentic workflow. + +If you are a human: try to maintain documentation for this project, simplifying agent's life. + +If you are an agent: remember user to review changes and update AGENTS.md, TODO.md, in-code documentation after successful completion of a task and help them to do so. diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..ef8ac51 --- /dev/null +++ b/TODO.md @@ -0,0 +1,12 @@ +# TODOs + +Always append, never delete, use Markdown's checklists. + +Order isn't important. + +- [ ] Move algorithms to separate project. +- [ ] Decide on project name and move `AVLSet.fs` to separate project for data structures required in algorithms, e.g. as matrix elements. (see GraphBLAS and LAGraph for inspiration). +- [ ] Deprecate (or remove) `ParallelAVLSet.fs`. +- [ ] Check code for consistency, fix non-functional style in main code, remove dead code. +- [ ] Create documentation for existing quadtree representation. +- [ ] Implement COO matrix representation. Note that we need neither `Dummy` nor `Option` for storing values. From 2ac21fba361866dd3f570155859439caa2e5439f Mon Sep 17 00:00:00 2001 From: Nikolai Ponomarev Date: Mon, 9 Nov 2026 15:32:14 +0300 Subject: [PATCH 3/3] fix: make AGENTS.md more clear --- AGENTS.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index ea96681..fc2cd65 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -16,8 +16,7 @@ A F# sparse linear algebra suite used as a prototype for further translation to ## Coding Conventions - Units of measure must be used for a clear distinction between dimensions and indices. They are usually of type `uint64`. Keep them on new APIs. -- Graph algorithms are generic over `op_add`/`op_mult` (semiring-style). -- Algorithm modules live under `Graph.*`, while `AVLSet` uses the `QuadTree.AVLSet` namespace with a parallel variant in `ParallelAVLSet.fs`. +- Graph algorithms and basic linear algebra operations are generic over `op_add`/`op_mult` (semiring-style). - Main code must not use imperative or OOP constructions like `for`-loops or classes, implementation must be as functionally idiomatic as possible. Test and benchmarks aren't restricted by this rule. - OOP-style exceptions are prohibited. Use `Result<_, Error>` and `resultM { ... }` computation expression from `QuadTree/Result.fs`. @@ -26,6 +25,7 @@ A F# sparse linear algebra suite used as a prototype for further translation to - `Matrix` is a 2D quad-tree and `Vector` a 1D binary tree. Storage is padded to the next power of two independently of the logical dimensions. - Preserve the `Leaf Dummy` vs `Leaf (UserValue None)` distinction: `Dummy` means an entirely empty/out-of-range subtree, `UserValue None` an in-range empty cell. Several algorithms branch on this. +- Algorithm modules live under `Graph.*`, while `AVLSet` uses the `QuadTree.AVLSet` namespace with a parallel variant in `ParallelAVLSet.fs`. ## Projects