Skip to content

Instantly share code, notes, and snippets.

View Gozala's full-sized avatar
😱
Oh well

Irakli Gozalishvili Gozala

😱
Oh well
View GitHub Profile
error[E0308]: mismatched types
--> rust/dialog-query/src/join.rs:90:9
|
51 | pub fn empty() -> impl EvaluationPlan {
| -------------------
| |
| the expected opaque type
| one of the found opaque types
...
55 | pub fn and<L: EvaluationPlan, R: EvaluationPlan>(left: L, right: R) -> impl EvaluationPlan {

Commit History Encoding

Goal

Supporting concurrent writes into database implies that multiple actors can create concurrent commits (containing assertions / retractions) than need to be reconciled by all partial replicas. Reconciliation requirements following:

  1. Identifying concurrent changes.
  2. Order all changes (including concurrent ones)

To make this more concrete, when query reads set of facts we need to identify if some facts are conflicting - updated same state via concurrent changes. This would enable projecting concurrent states that consumer could choose from.

@Gozala
Gozala / work.clj
Created April 11, 2024 18:35
Sketch of the workflow syntax
;; Type definition for the Blob. It has no inputs and two outputs
; `digest` and `size`. It is kind of like a rule without a body
(Blob : { :digest Bytes :size Int })
(Site : { :url String :headers (Map :key string :value string) })
;; ℹ️ Unlabelled parameter can be refereced by `.`
(Result :error : (:ok . :error .error))
;; Composed task is rule that maps input to tasks and maps task outputs
;; to the output of the composed task
stateDiagram-v2
  add: 👩‍💻 /space/content/add/blob 🤖
  add: 🧾 { ok {} }

  allocate: 🤖 /service/blob/allocate 🤖
  allocate: 🧾 { ok { size 123 } }

  wait: 🤖 /service/blob/receive 🤖
 wait: 🧾 { ok {} } 
flowchart LR
    Add[👩‍💻 store/add 🤖]
    Allocate[🤖 blob/allocate 🤖]
    Receive[🤖 blob/receive 🤖]
    Write[🤖 blob/write 👩‍💻]
    Close[🤖 blob/close 🤖]
    Claim[🤖 assert/location 🌐]

 Add --&gt; Allocate
interface Account {
plan: AccountPlan
// ...
}
interface AccountPlan {
customer: AccountDID
request(): Plan
list(): Plan[]
interface Account {
subscriptions: AccountSubscriptions
// ...
}
interface AccountSubscriptions {
customer: AccountDID
request(): Subscription
list(): Subscription[]
@Gozala
Gozala / db.js
Last active December 14, 2023 19:34
import * as API from '@ucanto/interface'
/**
* @typedef {number} Integer
* @typedef {number} Float
* @typedef {Readonly<Uint8Array>} Bytes
* @typedef {string} UTF8
*
* @typedef {String} Entity
* @typedef {Integer|Float|Bytes|UTF8} Attribute
type ProviderDID =
| "did:web:web.storage"
| "did:web:nft.storage"
interface Principal {
did(): string
}
interface Space extends Principal {