This commit is contained in:
Michael Zhang 2023-03-22 20:31:24 -05:00
commit bf5098ed22
8 changed files with 225 additions and 0 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
node_modules
.pijul
.direnv

76
design.md Normal file
View file

@ -0,0 +1,76 @@
- CLI API
- `mznotes install` : Install a script into the database
- `mznotes show` : Show the information about a particular node, by ID
- Database of nodes + code
- Code
- Code is all interface-based. Interface implementations give specific ways
behaviors are implemented
- Standard interfaces:
- Indexed
- Node definition
```
struct Node {
metadata: KVStore,
implements: Set<InterfaceURI>,
edges: Set<(EdgeType, Edge)>,
}
```
- Within the metadata kv store, keys are namespaced, according to the
application name. Application names must be registered ahead of time
- Nodes implement interfaces, the code of which is fetched from the internet
and validated
- Nodes are namespaced, although namespacing isn't the primary hierarchy
protocol.
- This is needed because the database itself has a privileged namespace
- The privileged namespace is for keeping track of database state, for
example which scripts are trusted
- Database service:
- IFTTT Events
- Local vs. distributed IFTTT events?
- Local means that ur particular device is repsonsible for running it
- Distributed means any device can consume the event???
- is this even a good idea? Maybe just have one dedicated worker
device. For example, may not want to run certain automation tasks
on phone, while others may only be able to be run on phone
- Cron tasks
- Sync protocol:
- After a modification, the modification gets written to a queue
- CRDT?
- Other privileged concepts:
- User: a pub/priv key pair
- Use cases
- Personal journaling (like Logseq)
- Weight / fitness tracking
- Calendar app (store events)
- Git app (store code)
- File backup
- Chat / Mail?
- Photo viewer + indexing using ML models for face detection / keywords
- Not sure yet:
- Automatic sharing of database nodes? This seems like a bad idea for
multiple reasons. Maybe better to just have a specific app for
doing permission models
- Other concerns
- Local protection using libsecret?

93
flake.lock Normal file
View file

@ -0,0 +1,93 @@
{
"nodes": {
"fenix": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust-analyzer-src": "rust-analyzer-src"
},
"locked": {
"lastModified": 1679466129,
"narHash": "sha256-BQt0ADAhPAwuoq3z+iprmHyw1NeyerOw1GiIEJkANGc=",
"owner": "nix-community",
"repo": "fenix",
"rev": "49237f7a76b98954306e77a7bd42f6491ad5c6a7",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "fenix",
"type": "github"
}
},
"flake-utils": {
"locked": {
"lastModified": 1678901627,
"narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
"type": "github"
},
"original": {
"id": "flake-utils",
"type": "indirect"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1679262748,
"narHash": "sha256-DQCrrAFrkxijC6haUzOC5ZoFqpcv/tg2WxnyW3np1Cc=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "60c1d71f2ba4c80178ec84523c2ca0801522e0a6",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1663551060,
"narHash": "sha256-e2SR4cVx9p7aW/XnVsGsWZBplApA9ZJUjc0fejJhnYo=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "8a5b9ee7b7a2b38267c9481f5c629c015108ab0d",
"type": "github"
},
"original": {
"id": "nixpkgs",
"type": "indirect"
}
},
"root": {
"inputs": {
"fenix": "fenix",
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs_2"
}
},
"rust-analyzer-src": {
"flake": false,
"locked": {
"lastModified": 1679428647,
"narHash": "sha256-gyS7UDFNzQfRKJvUDlVuM8wXCIyreBmVq+aiPXhfTlk=",
"owner": "rust-lang",
"repo": "rust-analyzer",
"rev": "3321799e8fac622db50fe8c3284062f7d0f1bf53",
"type": "github"
},
"original": {
"owner": "rust-lang",
"ref": "nightly",
"repo": "rust-analyzer",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

35
flake.nix Normal file
View file

@ -0,0 +1,35 @@
{
inputs = { fenix.url = "github:nix-community/fenix"; };
outputs = { self, nixpkgs, flake-utils, fenix }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ fenix.overlays.default ];
};
toolchain = pkgs.fenix.stable;
in rec {
devShell = pkgs.mkShell {
packages = (with pkgs; [
cargo-deny
cargo-edit
cargo-expand
cargo-flamegraph
cargo-watch
deno
(python310.withPackages (p: with p; [ ipython numpy scipy sympy ]))
]) ++ (with toolchain; [
cargo
rustc
clippy
# Get the nightly version of rustfmt so we can wrap comments
pkgs.fenix.default.rustfmt
]);
};
});
}

4
proto/mznotes.proto Normal file
View file

@ -0,0 +1,4 @@
syntax = "proto3";
service Database {
}

1
src/core/app.ts Normal file
View file

@ -0,0 +1 @@
import { Database } from "./db.ts";

12
src/core/db.ts Normal file
View file

@ -0,0 +1,12 @@
export default class Database {
public createNode(): Node {
// TODO: Calculate the interfaces that must be implemented
// Using the interface application rules
let node = new Node();
}
}
export class Node {
public delete() {
}
}