Add activated workspace reflection and Studio definition watches

Expose bounded snapshot-bound definition reads and latest-only watches from the serving checked bundle. Add checked reflection dependency ports, generated SDK bindings and selector-scoped invocation authority.

Move Studio factory, contract and query discovery to public reflection inventories. Share an active-definition watch across canvas and standalone routes and invalidate/reload on epoch changes instead of polling GetWorkspace.

Document the API and deferred scope; cover compiler/codegen, SDK injection, transport authorization, activation publication, pagination and reconnect behavior. Keep all work local; no deployment or publication.
This commit is contained in:
Timothy J. Aveni
2026-09-19 10:18:47 -07:00
parent 1aa55f7a35
commit 757531bb63
20 changed files with 2870 additions and 2105 deletions
File diff suppressed because one or more lines are too long
@@ -3,257 +3,259 @@ RESULT_BYTES=2
RPC_CALLS=3
DEADLINE_MS=4
QUERY=5
SPECIALIZE=6
ROOT=7
DOCUMENT=8
FRAGMENTS=9
VIEW=10
MAX=11
ALLOW=12
POLL=13
QUERYABLE=14
RPC=15
QUERY_REASON=16
TYPE=17
OBJECT=18
STORABLE=19
IMPLEMENTS=20
REF=21
FRAGMENT=22
IMPORT=23
EXTERNAL=24
ATOM=25
INTERFACE=26
INTERFACES=27
PACKAGE=28
VALUE=29
RELATION=30
OPERATION=31
FUNCTION=32
CONSTRUCTOR=33
CONSTRUCTS=34
INPUT=35
CONFORM=36
AS=37
BIND=38
STATIC=39
TO=40
PRIVATE=41
SHARED=42
STATE=43
EDGE=44
PROJECTION=45
WITH=46
USING=47
VIA=48
MATERIALIZE=49
IF=50
ABSENT=51
ON=52
POLICY=53
DEFAULT=54
SOURCE=55
REPOSITORY=56
COMMIT=57
REVISION=58
SEMANTIC_MAJOR=59
ON_DELETE=60
RETAIN_OTHER=61
KEYED=62
PUBLIC_TRAVERSAL=63
ID=64
DOC=65
MODE=66
EMITS=67
RECEIVER=68
REQUIRES=69
ANY=70
GET=71
SET=72
WATCH=73
START=74
STOP=75
READ=76
WRITE=77
RESOLVE=78
CONNECT=79
DISCONNECT=80
CALL=81
WATCH_START=82
WATCH_STOP=83
SUBSCRIBE=84
UNSUBSCRIBE=85
OPTIMISTIC_REGISTER=86
CRDT=87
OPTIONAL_ONE=88
EXACTLY_ONE=89
MANY_UNIQUE=90
MANY=91
ORDERED=92
UNIT=93
WATCH_HANDLE=94
MESSAGE=95
ATOM_REF=96
INTERFACE_REF=97
OPTIONAL=98
LIST=99
RECORD=100
BOOL=101
BYTES=102
DOUBLE=103
INT32=104
INT64=105
STRING=106
UINT32=107
UINT64=108
TRUE=109
FALSE=110
NULL=111
ARROW=112
COLON=113
SEMI=114
COMMA=115
DOT=116
LBRACE=117
RBRACE=118
LBRACK=119
RBRACK=120
LPAREN=121
RPAREN=122
LT=123
GT=124
AMP=125
EQUAL=126
INTEGER=127
JSON_NUMBER=128
IDENTIFIER=129
STRING_LITERAL=130
LINE_COMMENT=131
BLOCK_COMMENT=132
WS=133
REFLECTION=6
SPECIALIZE=7
ROOT=8
DOCUMENT=9
FRAGMENTS=10
VIEW=11
MAX=12
ALLOW=13
POLL=14
QUERYABLE=15
RPC=16
QUERY_REASON=17
TYPE=18
OBJECT=19
STORABLE=20
IMPLEMENTS=21
REF=22
FRAGMENT=23
IMPORT=24
EXTERNAL=25
ATOM=26
INTERFACE=27
INTERFACES=28
PACKAGE=29
VALUE=30
RELATION=31
OPERATION=32
FUNCTION=33
CONSTRUCTOR=34
CONSTRUCTS=35
INPUT=36
CONFORM=37
AS=38
BIND=39
STATIC=40
TO=41
PRIVATE=42
SHARED=43
STATE=44
EDGE=45
PROJECTION=46
WITH=47
USING=48
VIA=49
MATERIALIZE=50
IF=51
ABSENT=52
ON=53
POLICY=54
DEFAULT=55
SOURCE=56
REPOSITORY=57
COMMIT=58
REVISION=59
SEMANTIC_MAJOR=60
ON_DELETE=61
RETAIN_OTHER=62
KEYED=63
PUBLIC_TRAVERSAL=64
ID=65
DOC=66
MODE=67
EMITS=68
RECEIVER=69
REQUIRES=70
ANY=71
GET=72
SET=73
WATCH=74
START=75
STOP=76
READ=77
WRITE=78
RESOLVE=79
CONNECT=80
DISCONNECT=81
CALL=82
WATCH_START=83
WATCH_STOP=84
SUBSCRIBE=85
UNSUBSCRIBE=86
OPTIMISTIC_REGISTER=87
CRDT=88
OPTIONAL_ONE=89
EXACTLY_ONE=90
MANY_UNIQUE=91
MANY=92
ORDERED=93
UNIT=94
WATCH_HANDLE=95
MESSAGE=96
ATOM_REF=97
INTERFACE_REF=98
OPTIONAL=99
LIST=100
RECORD=101
BOOL=102
BYTES=103
DOUBLE=104
INT32=105
INT64=106
STRING=107
UINT32=108
UINT64=109
TRUE=110
FALSE=111
NULL=112
ARROW=113
COLON=114
SEMI=115
COMMA=116
DOT=117
LBRACE=118
RBRACE=119
LBRACK=120
RBRACK=121
LPAREN=122
RPAREN=123
LT=124
GT=125
AMP=126
EQUAL=127
INTEGER=128
JSON_NUMBER=129
IDENTIFIER=130
STRING_LITERAL=131
LINE_COMMENT=132
BLOCK_COMMENT=133
WS=134
'workspace'=1
'result-bytes'=2
'rpc-calls'=3
'deadline-ms'=4
'query'=5
'specialize'=6
'root'=7
'document'=8
'fragments'=9
'view'=10
'max'=11
'allow'=12
'poll'=13
'queryable'=14
'rpc'=15
'query-reason'=16
'type'=17
'object'=18
'storable'=19
'implements'=20
'ref'=21
'fragment'=22
'import'=23
'external'=24
'atom'=25
'interface'=26
'interfaces'=27
'package'=28
'value'=29
'relation'=30
'operation'=31
'function'=32
'constructor'=33
'constructs'=34
'input'=35
'conform'=36
'as'=37
'bind'=38
'static'=39
'to'=40
'private'=41
'shared'=42
'state'=43
'edge'=44
'projection'=45
'with'=46
'using'=47
'via'=48
'materialize'=49
'if'=50
'absent'=51
'on'=52
'policy'=53
'default'=54
'source'=55
'repository'=56
'commit'=57
'revision'=58
'semantic-major'=59
'on-delete'=60
'retain-other'=61
'keyed'=62
'public-traversal'=63
'id'=64
'doc'=65
'mode'=66
'emits'=67
'receiver'=68
'requires'=69
'any'=70
'get'=71
'set'=72
'watch'=73
'start'=74
'stop'=75
'read'=76
'write'=77
'resolve'=78
'connect'=79
'disconnect'=80
'call'=81
'watch-start'=82
'watch-stop'=83
'subscribe'=84
'unsubscribe'=85
'optimistic-register'=86
'crdt'=87
'optional-one'=88
'exactly-one'=89
'many-unique'=90
'many'=91
'ordered'=92
'unit'=93
'watch-handle'=94
'message'=95
'atom-ref'=96
'interface-ref'=97
'optional'=98
'list'=99
'record'=100
'bool'=101
'bytes'=102
'double'=103
'int32'=104
'int64'=105
'string'=106
'uint32'=107
'uint64'=108
'true'=109
'false'=110
'null'=111
'->'=112
':'=113
';'=114
','=115
'.'=116
'{'=117
'}'=118
'['=119
']'=120
'('=121
')'=122
'<'=123
'>'=124
'&'=125
'='=126
'reflection'=6
'specialize'=7
'root'=8
'document'=9
'fragments'=10
'view'=11
'max'=12
'allow'=13
'poll'=14
'queryable'=15
'rpc'=16
'query-reason'=17
'type'=18
'object'=19
'storable'=20
'implements'=21
'ref'=22
'fragment'=23
'import'=24
'external'=25
'atom'=26
'interface'=27
'interfaces'=28
'package'=29
'value'=30
'relation'=31
'operation'=32
'function'=33
'constructor'=34
'constructs'=35
'input'=36
'conform'=37
'as'=38
'bind'=39
'static'=40
'to'=41
'private'=42
'shared'=43
'state'=44
'edge'=45
'projection'=46
'with'=47
'using'=48
'via'=49
'materialize'=50
'if'=51
'absent'=52
'on'=53
'policy'=54
'default'=55
'source'=56
'repository'=57
'commit'=58
'revision'=59
'semantic-major'=60
'on-delete'=61
'retain-other'=62
'keyed'=63
'public-traversal'=64
'id'=65
'doc'=66
'mode'=67
'emits'=68
'receiver'=69
'requires'=70
'any'=71
'get'=72
'set'=73
'watch'=74
'start'=75
'stop'=76
'read'=77
'write'=78
'resolve'=79
'connect'=80
'disconnect'=81
'call'=82
'watch-start'=83
'watch-stop'=84
'subscribe'=85
'unsubscribe'=86
'optimistic-register'=87
'crdt'=88
'optional-one'=89
'exactly-one'=90
'many-unique'=91
'many'=92
'ordered'=93
'unit'=94
'watch-handle'=95
'message'=96
'atom-ref'=97
'interface-ref'=98
'optional'=99
'list'=100
'record'=101
'bool'=102
'bytes'=103
'double'=104
'int32'=105
'int64'=106
'string'=107
'uint32'=108
'uint64'=109
'true'=110
'false'=111
'null'=112
'->'=113
':'=114
';'=115
','=116
'.'=117
'{'=118
'}'=119
'['=120
']'=121
'('=122
')'=123
'<'=124
'>'=125
'&'=126
'='=127
File diff suppressed because one or more lines are too long
@@ -3,257 +3,259 @@ RESULT_BYTES=2
RPC_CALLS=3
DEADLINE_MS=4
QUERY=5
SPECIALIZE=6
ROOT=7
DOCUMENT=8
FRAGMENTS=9
VIEW=10
MAX=11
ALLOW=12
POLL=13
QUERYABLE=14
RPC=15
QUERY_REASON=16
TYPE=17
OBJECT=18
STORABLE=19
IMPLEMENTS=20
REF=21
FRAGMENT=22
IMPORT=23
EXTERNAL=24
ATOM=25
INTERFACE=26
INTERFACES=27
PACKAGE=28
VALUE=29
RELATION=30
OPERATION=31
FUNCTION=32
CONSTRUCTOR=33
CONSTRUCTS=34
INPUT=35
CONFORM=36
AS=37
BIND=38
STATIC=39
TO=40
PRIVATE=41
SHARED=42
STATE=43
EDGE=44
PROJECTION=45
WITH=46
USING=47
VIA=48
MATERIALIZE=49
IF=50
ABSENT=51
ON=52
POLICY=53
DEFAULT=54
SOURCE=55
REPOSITORY=56
COMMIT=57
REVISION=58
SEMANTIC_MAJOR=59
ON_DELETE=60
RETAIN_OTHER=61
KEYED=62
PUBLIC_TRAVERSAL=63
ID=64
DOC=65
MODE=66
EMITS=67
RECEIVER=68
REQUIRES=69
ANY=70
GET=71
SET=72
WATCH=73
START=74
STOP=75
READ=76
WRITE=77
RESOLVE=78
CONNECT=79
DISCONNECT=80
CALL=81
WATCH_START=82
WATCH_STOP=83
SUBSCRIBE=84
UNSUBSCRIBE=85
OPTIMISTIC_REGISTER=86
CRDT=87
OPTIONAL_ONE=88
EXACTLY_ONE=89
MANY_UNIQUE=90
MANY=91
ORDERED=92
UNIT=93
WATCH_HANDLE=94
MESSAGE=95
ATOM_REF=96
INTERFACE_REF=97
OPTIONAL=98
LIST=99
RECORD=100
BOOL=101
BYTES=102
DOUBLE=103
INT32=104
INT64=105
STRING=106
UINT32=107
UINT64=108
TRUE=109
FALSE=110
NULL=111
ARROW=112
COLON=113
SEMI=114
COMMA=115
DOT=116
LBRACE=117
RBRACE=118
LBRACK=119
RBRACK=120
LPAREN=121
RPAREN=122
LT=123
GT=124
AMP=125
EQUAL=126
INTEGER=127
JSON_NUMBER=128
IDENTIFIER=129
STRING_LITERAL=130
LINE_COMMENT=131
BLOCK_COMMENT=132
WS=133
REFLECTION=6
SPECIALIZE=7
ROOT=8
DOCUMENT=9
FRAGMENTS=10
VIEW=11
MAX=12
ALLOW=13
POLL=14
QUERYABLE=15
RPC=16
QUERY_REASON=17
TYPE=18
OBJECT=19
STORABLE=20
IMPLEMENTS=21
REF=22
FRAGMENT=23
IMPORT=24
EXTERNAL=25
ATOM=26
INTERFACE=27
INTERFACES=28
PACKAGE=29
VALUE=30
RELATION=31
OPERATION=32
FUNCTION=33
CONSTRUCTOR=34
CONSTRUCTS=35
INPUT=36
CONFORM=37
AS=38
BIND=39
STATIC=40
TO=41
PRIVATE=42
SHARED=43
STATE=44
EDGE=45
PROJECTION=46
WITH=47
USING=48
VIA=49
MATERIALIZE=50
IF=51
ABSENT=52
ON=53
POLICY=54
DEFAULT=55
SOURCE=56
REPOSITORY=57
COMMIT=58
REVISION=59
SEMANTIC_MAJOR=60
ON_DELETE=61
RETAIN_OTHER=62
KEYED=63
PUBLIC_TRAVERSAL=64
ID=65
DOC=66
MODE=67
EMITS=68
RECEIVER=69
REQUIRES=70
ANY=71
GET=72
SET=73
WATCH=74
START=75
STOP=76
READ=77
WRITE=78
RESOLVE=79
CONNECT=80
DISCONNECT=81
CALL=82
WATCH_START=83
WATCH_STOP=84
SUBSCRIBE=85
UNSUBSCRIBE=86
OPTIMISTIC_REGISTER=87
CRDT=88
OPTIONAL_ONE=89
EXACTLY_ONE=90
MANY_UNIQUE=91
MANY=92
ORDERED=93
UNIT=94
WATCH_HANDLE=95
MESSAGE=96
ATOM_REF=97
INTERFACE_REF=98
OPTIONAL=99
LIST=100
RECORD=101
BOOL=102
BYTES=103
DOUBLE=104
INT32=105
INT64=106
STRING=107
UINT32=108
UINT64=109
TRUE=110
FALSE=111
NULL=112
ARROW=113
COLON=114
SEMI=115
COMMA=116
DOT=117
LBRACE=118
RBRACE=119
LBRACK=120
RBRACK=121
LPAREN=122
RPAREN=123
LT=124
GT=125
AMP=126
EQUAL=127
INTEGER=128
JSON_NUMBER=129
IDENTIFIER=130
STRING_LITERAL=131
LINE_COMMENT=132
BLOCK_COMMENT=133
WS=134
'workspace'=1
'result-bytes'=2
'rpc-calls'=3
'deadline-ms'=4
'query'=5
'specialize'=6
'root'=7
'document'=8
'fragments'=9
'view'=10
'max'=11
'allow'=12
'poll'=13
'queryable'=14
'rpc'=15
'query-reason'=16
'type'=17
'object'=18
'storable'=19
'implements'=20
'ref'=21
'fragment'=22
'import'=23
'external'=24
'atom'=25
'interface'=26
'interfaces'=27
'package'=28
'value'=29
'relation'=30
'operation'=31
'function'=32
'constructor'=33
'constructs'=34
'input'=35
'conform'=36
'as'=37
'bind'=38
'static'=39
'to'=40
'private'=41
'shared'=42
'state'=43
'edge'=44
'projection'=45
'with'=46
'using'=47
'via'=48
'materialize'=49
'if'=50
'absent'=51
'on'=52
'policy'=53
'default'=54
'source'=55
'repository'=56
'commit'=57
'revision'=58
'semantic-major'=59
'on-delete'=60
'retain-other'=61
'keyed'=62
'public-traversal'=63
'id'=64
'doc'=65
'mode'=66
'emits'=67
'receiver'=68
'requires'=69
'any'=70
'get'=71
'set'=72
'watch'=73
'start'=74
'stop'=75
'read'=76
'write'=77
'resolve'=78
'connect'=79
'disconnect'=80
'call'=81
'watch-start'=82
'watch-stop'=83
'subscribe'=84
'unsubscribe'=85
'optimistic-register'=86
'crdt'=87
'optional-one'=88
'exactly-one'=89
'many-unique'=90
'many'=91
'ordered'=92
'unit'=93
'watch-handle'=94
'message'=95
'atom-ref'=96
'interface-ref'=97
'optional'=98
'list'=99
'record'=100
'bool'=101
'bytes'=102
'double'=103
'int32'=104
'int64'=105
'string'=106
'uint32'=107
'uint64'=108
'true'=109
'false'=110
'null'=111
'->'=112
':'=113
';'=114
','=115
'.'=116
'{'=117
'}'=118
'['=119
']'=120
'('=121
')'=122
'<'=123
'>'=124
'&'=125
'='=126
'reflection'=6
'specialize'=7
'root'=8
'document'=9
'fragments'=10
'view'=11
'max'=12
'allow'=13
'poll'=14
'queryable'=15
'rpc'=16
'query-reason'=17
'type'=18
'object'=19
'storable'=20
'implements'=21
'ref'=22
'fragment'=23
'import'=24
'external'=25
'atom'=26
'interface'=27
'interfaces'=28
'package'=29
'value'=30
'relation'=31
'operation'=32
'function'=33
'constructor'=34
'constructs'=35
'input'=36
'conform'=37
'as'=38
'bind'=39
'static'=40
'to'=41
'private'=42
'shared'=43
'state'=44
'edge'=45
'projection'=46
'with'=47
'using'=48
'via'=49
'materialize'=50
'if'=51
'absent'=52
'on'=53
'policy'=54
'default'=55
'source'=56
'repository'=57
'commit'=58
'revision'=59
'semantic-major'=60
'on-delete'=61
'retain-other'=62
'keyed'=63
'public-traversal'=64
'id'=65
'doc'=66
'mode'=67
'emits'=68
'receiver'=69
'requires'=70
'any'=71
'get'=72
'set'=73
'watch'=74
'start'=75
'stop'=76
'read'=77
'write'=78
'resolve'=79
'connect'=80
'disconnect'=81
'call'=82
'watch-start'=83
'watch-stop'=84
'subscribe'=85
'unsubscribe'=86
'optimistic-register'=87
'crdt'=88
'optional-one'=89
'exactly-one'=90
'many-unique'=91
'many'=92
'ordered'=93
'unit'=94
'watch-handle'=95
'message'=96
'atom-ref'=97
'interface-ref'=98
'optional'=99
'list'=100
'record'=101
'bool'=102
'bytes'=103
'double'=104
'int32'=105
'int64'=106
'string'=107
'uint32'=108
'uint64'=109
'true'=110
'false'=111
'null'=112
'->'=113
':'=114
';'=115
','=116
'.'=117
'{'=118
'}'=119
'['=120
']'=121
'('=122
')'=123
'<'=124
'>'=125
'&'=126
'='=127
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+15
View File
@@ -849,6 +849,12 @@ const lowerQueryReference = (
const lowerDependencyPort = (state: LoweringState, context: DependencyPortContext): DependencyPort | undefined => {
const name = identifier(context.identifier(0));
const id = capabilityId.dependencyPort(stringValue(context.stringLiteral()));
if (context.REFLECTION())
return {
id,
displayName: name,
requirement: { kind: "reflection", selectors: context.identifierList()!.identifier().map(identifier) },
};
if (context.QUERY()) {
const query = lowerQueryReference(
state,
@@ -1097,6 +1103,11 @@ const lowerGenericPackageExport = (
.primitiveList()
?.primitive()
.map((item) => text(item)) ?? [];
if (port.REFLECTION())
return {
...base,
requirement: { kind: "reflection", selectors: port.identifierList()!.identifier().map(identifier) },
};
if (port.QUERY()) {
const query = lowerQueryReference(state, identifier(port.identifier(1)), identifier(port.identifier(2)), port);
if (!query)
@@ -1575,6 +1586,10 @@ const lowerBoundDependencies = (
);
return projectionId ? { edgeTypeId: attachment.attachment.id, projectionId } : undefined;
};
if (entry.REFLECTION())
return [
{ portId, binding: { kind: "reflection", selectors: entry.identifierList()!.identifier().map(identifier) } },
];
if (entry.QUERY()) {
const query = lowerQueryReference(state, identifier(entry.identifier(1)), identifier(entry.identifier(2)), entry);
const via = entry.VIA() ? traversal(identifier(entry.identifier(3)), identifier(entry.identifier(4))) : undefined;