Support captured CRDT changes in compound transaction contracts

This commit is contained in:
Timothy J. Aveni
2026-09-20 23:07:09 -07:00
parent 33f674321b
commit 2056c1e352
10 changed files with 171 additions and 16 deletions
+14
View File
@@ -0,0 +1,14 @@
external atom Note id "compound:note";
type Content = record { text: string; tags: list<string>; };
type Edit = record { change: change<Content>; resolved: bool; };
package EditRuntime id "compound:runtime" revision "compound:runtime@1" {
operation update id "compound:runtime:update" : Edit -> unit
mode call execution transaction targets [browser, server] receiver atom Note requires {
state content id "compound:edit:content" : Content [edit];
state resolved id "compound:edit:resolved" : bool [write];
} accept using check;
operation check id "compound:runtime:check" : Edit -> unit
mode call execution snapshot targets [server] receiver atom Note requires {
state allowed id "compound:check:allowed" : bool [read];
};
}
+18
View File
@@ -0,0 +1,18 @@
type Content = record { text: string; tags: list<string>; };
type Edit = record { change: change<Content>; resolved: bool; };
interface NoteData id "compound:data" revision "compound:data@1" {
operation update id "compound:update" : Edit -> unit {
call id "compound:update:call" execution transaction targets [browser, server];
}
queryable value content id "compound:content" : Content {
get id "compound:content:get" execution snapshot targets [browser, server];
edit id "compound:content:edit" execution transaction targets [browser, server];
}
queryable value resolved id "compound:resolved" : bool {
get id "compound:resolved:get" execution snapshot targets [browser, server];
}
queryable value title id "compound:title" : string {
get id "compound:title:get" execution snapshot targets [browser, server];
set id "compound:title:set" execution transaction targets [browser, server];
}
}
+22
View File
@@ -0,0 +1,22 @@
workspace Compound id "workspace:compound" revision "workspace:compound@1" commit "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" {
import interface NoteData;
import package EditRuntime;
type Content = record { text: string; tags: list<string>; };
atom Note id "compound:note";
conform Note as NoteData id "compound:note:data" {
private state Content id "compound:content-slot" on Note : Content policy crdt(Content);
private state Resolved id "compound:resolved-slot" on Note : bool policy register default false;
private state Title id "compound:title-slot" on Note : string policy register default "note";
private state Allowed id "compound:allowed-slot" on Note : bool policy register default true;
initialize { content to state Content; };
bind content.get to state Content.read;
bind content.edit to state Content.edit;
bind resolved.get to state Resolved.read;
bind title.get to state Title.read;
bind title.set to state Title.write;
bind update.call to package EditRuntime.update with {
content to state Content;
resolved to state Resolved;
} accept with { allowed to state Allowed; };
}
}