Add document surface diagnostics
This commit is contained in:
parent
a17e10d198
commit
8bb85d7c47
6 changed files with 149 additions and 10 deletions
|
|
@ -280,6 +280,8 @@ export type CultMeshSurfaceKind =
|
|||
| "projection-recipe"
|
||||
| "live-feed"
|
||||
| "operation"
|
||||
| "document"
|
||||
| "collection"
|
||||
| "state-pointer"
|
||||
| "native-slice-view";
|
||||
|
||||
|
|
@ -301,6 +303,8 @@ export interface CultMeshSurfaceCatalogIndexDiagnostic {
|
|||
readonly projectionRecipes: readonly CultMeshSurfaceDiagnostic[];
|
||||
readonly liveFeeds: readonly CultMeshSurfaceDiagnostic[];
|
||||
readonly operations: readonly CultMeshSurfaceDiagnostic[];
|
||||
readonly documents: readonly CultMeshSurfaceDiagnostic[];
|
||||
readonly collections: readonly CultMeshSurfaceDiagnostic[];
|
||||
readonly statePointers: readonly CultMeshSurfaceDiagnostic[];
|
||||
readonly nativeSliceViews: readonly CultMeshSurfaceDiagnostic[];
|
||||
}
|
||||
|
|
@ -2504,6 +2508,16 @@ export function cultMeshDescribeSurface(
|
|||
readonly routeHint: CultMeshRouteHint;
|
||||
readonly sources: readonly CultMeshProjectionSource[];
|
||||
}
|
||||
| {
|
||||
readonly documentId: string;
|
||||
readonly routeHint: CultMeshRouteHint;
|
||||
readonly sources: readonly CultMeshProjectionSource[];
|
||||
}
|
||||
| {
|
||||
readonly collectionId: string;
|
||||
readonly routeHint: CultMeshRouteHint;
|
||||
readonly sources: readonly CultMeshProjectionSource[];
|
||||
}
|
||||
| {
|
||||
readonly pointerId: string;
|
||||
readonly routeHint?: CultMeshRouteHint;
|
||||
|
|
@ -2529,6 +2543,20 @@ export function cultMeshDescribeSurface(
|
|||
});
|
||||
}
|
||||
|
||||
if ("documentId" in surface) {
|
||||
return cultMeshSurfaceDiagnostic("document", surface.documentId, {
|
||||
routeHint: surface.routeHint,
|
||||
sources: surface.sources,
|
||||
});
|
||||
}
|
||||
|
||||
if ("collectionId" in surface) {
|
||||
return cultMeshSurfaceDiagnostic("collection", surface.collectionId, {
|
||||
routeHint: surface.routeHint,
|
||||
sources: surface.sources,
|
||||
});
|
||||
}
|
||||
|
||||
if ("viewId" in surface) {
|
||||
return cultMeshSurfaceDiagnostic("native-slice-view", surface.viewId, {
|
||||
routeHint: surface.route,
|
||||
|
|
@ -2608,6 +2636,8 @@ export function cultMeshSurfaceCatalogIndex(
|
|||
projectionRecipes: cultMeshSurfacesByKind(catalog, "projection-recipe"),
|
||||
liveFeeds: cultMeshSurfacesByKind(catalog, "live-feed"),
|
||||
operations: cultMeshSurfacesByKind(catalog, "operation"),
|
||||
documents: cultMeshSurfacesByKind(catalog, "document"),
|
||||
collections: cultMeshSurfacesByKind(catalog, "collection"),
|
||||
statePointers: cultMeshSurfacesByKind(catalog, "state-pointer"),
|
||||
nativeSliceViews: cultMeshSurfacesByKind(catalog, "native-slice-view"),
|
||||
};
|
||||
|
|
@ -3849,6 +3879,16 @@ export class CultMesh {
|
|||
| {
|
||||
readonly pointerId: string;
|
||||
}
|
||||
| {
|
||||
readonly documentId: string;
|
||||
readonly routeHint: CultMeshRouteHint;
|
||||
readonly sources: readonly CultMeshProjectionSource[];
|
||||
}
|
||||
| {
|
||||
readonly collectionId: string;
|
||||
readonly routeHint: CultMeshRouteHint;
|
||||
readonly sources: readonly CultMeshProjectionSource[];
|
||||
}
|
||||
| CultMeshNativeSliceViewDescriptor,
|
||||
): CultMeshSurfaceDiagnostic {
|
||||
return cultMeshDescribeSurface(surface);
|
||||
|
|
|
|||
|
|
@ -646,6 +646,24 @@ test("CultMesh TS describes typed surface catalogs for tools and generated bindi
|
|||
routeHint,
|
||||
},
|
||||
);
|
||||
const document = CultMesh.document(
|
||||
"daemon:aetheria.frame.latest.v1",
|
||||
{ schemaId: "gamecult.aetheria.daemon_frame.v1" },
|
||||
async () => ({ frameId: 1 }),
|
||||
{
|
||||
sources: [source],
|
||||
routeHint,
|
||||
},
|
||||
);
|
||||
const collection = CultMesh.collection(
|
||||
"daemon:aetheria.contacts.v1",
|
||||
{ schemaId: "gamecult.aetheria.contact.v1" },
|
||||
async () => [],
|
||||
{
|
||||
sources: [source],
|
||||
routeHint,
|
||||
},
|
||||
);
|
||||
const nativeView = CultMesh.nativeSliceView(
|
||||
"aetheria.zone.render",
|
||||
"gamecult.aetheria.render_body.v1",
|
||||
|
|
@ -658,17 +676,23 @@ test("CultMesh TS describes typed surface catalogs for tools and generated bindi
|
|||
const feedSurface = CultMesh.describeSurface(feed);
|
||||
const operationSurface = CultMesh.describeSurface(operation);
|
||||
const pointerSurface = CultMesh.describeSurface(pointer);
|
||||
const documentSurface = CultMesh.describeSurface(document);
|
||||
const collectionSurface = CultMesh.describeSurface(collection);
|
||||
const nativeViewSurface = CultMesh.describeSurface(nativeView);
|
||||
const catalog = CultMesh.describeSurfaceCatalog("gamecult.aetheria.rts.surfaces.v1", [
|
||||
querySurface,
|
||||
feedSurface,
|
||||
operationSurface,
|
||||
documentSurface,
|
||||
collectionSurface,
|
||||
pointerSurface,
|
||||
nativeViewSurface,
|
||||
]);
|
||||
|
||||
assert.equal(querySurface.kind, "query");
|
||||
assert.equal(feedSurface.kind, "live-feed");
|
||||
assert.equal(documentSurface.kind, "document");
|
||||
assert.equal(collectionSurface.kind, "collection");
|
||||
assert.equal(pointerSurface.kind, "state-pointer");
|
||||
assert.equal(pointerSurface.routeHint.kind, "shared-memory");
|
||||
assert.deepEqual(pointerSurface.sources.map(next => next.schemaId), [
|
||||
|
|
@ -680,6 +704,8 @@ test("CultMesh TS describes typed surface catalogs for tools and generated bindi
|
|||
"aetheria.zone.objects.visible",
|
||||
"aetheria.rts.viewport.feed",
|
||||
"aetheria.pilot.set_move_vector",
|
||||
"daemon:aetheria.frame.latest.v1",
|
||||
"daemon:aetheria.contacts.v1",
|
||||
"aetheria.selection.current",
|
||||
"aetheria.zone.render",
|
||||
]);
|
||||
|
|
@ -689,12 +715,16 @@ test("CultMesh TS describes typed surface catalogs for tools and generated bindi
|
|||
]);
|
||||
assert.notEqual(catalog.surfaces[0], querySurface);
|
||||
assert.notEqual(catalog.surfaces[0].sources, querySurface.sources);
|
||||
assert.equal(catalog.surfaces[4].routeHint.kind, "shared-memory");
|
||||
assert.equal(catalog.surfaces[6].routeHint.kind, "shared-memory");
|
||||
|
||||
assert.equal(
|
||||
CultMesh.findSurface(catalog, "aetheria.selection.current")?.kind,
|
||||
"state-pointer",
|
||||
);
|
||||
assert.equal(
|
||||
CultMesh.findSurface(catalog, "daemon:aetheria.frame.latest.v1")?.kind,
|
||||
"document",
|
||||
);
|
||||
assert.equal(CultMesh.findSurface(catalog, "missing"), undefined);
|
||||
|
||||
const operations = CultMesh.surfacesByKind(catalog, "operation");
|
||||
|
|
@ -715,6 +745,12 @@ test("CultMesh TS describes typed surface catalogs for tools and generated bindi
|
|||
assert.deepEqual(index.operations.map(surface => surface.surfaceId), [
|
||||
"aetheria.pilot.set_move_vector",
|
||||
]);
|
||||
assert.deepEqual(index.documents.map(surface => surface.surfaceId), [
|
||||
"daemon:aetheria.frame.latest.v1",
|
||||
]);
|
||||
assert.deepEqual(index.collections.map(surface => surface.surfaceId), [
|
||||
"daemon:aetheria.contacts.v1",
|
||||
]);
|
||||
assert.deepEqual(index.statePointers.map(surface => surface.surfaceId), [
|
||||
"aetheria.selection.current",
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -1454,6 +1454,35 @@ namespace GameCult.Mesh
|
|||
return new CultMeshSurfaceDiagnostic(CultMeshSurfaceKind.LiveFeed, feed.FeedId, feed.RouteHint, feed.Sources);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a typed document handle as one entry in a surface catalog.
|
||||
/// </summary>
|
||||
public static CultMeshSurfaceDiagnostic DescribeSurface(
|
||||
ICultMeshDocumentHandle document)
|
||||
{
|
||||
if (document == null) throw new ArgumentNullException(nameof(document));
|
||||
return new CultMeshSurfaceDiagnostic(
|
||||
CultMeshSurfaceKind.Document,
|
||||
document.DocumentId,
|
||||
document.RouteHint,
|
||||
document.Sources);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a typed collection handle as one entry in a surface catalog.
|
||||
/// </summary>
|
||||
public static CultMeshSurfaceDiagnostic DescribeSurface<TDocument>(
|
||||
CultMeshCollectionHandle<TDocument> collection)
|
||||
where TDocument : class
|
||||
{
|
||||
if (collection == null) throw new ArgumentNullException(nameof(collection));
|
||||
return new CultMeshSurfaceDiagnostic(
|
||||
CultMeshSurfaceKind.Collection,
|
||||
collection.CollectionId,
|
||||
collection.RouteHint,
|
||||
collection.Sources);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes a typed state pointer as one entry in a surface catalog.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1502,6 +1502,12 @@ namespace GameCult.Mesh
|
|||
/// <summary>A typed operation handle.</summary>
|
||||
Operation,
|
||||
|
||||
/// <summary>A typed reactive document handle.</summary>
|
||||
Document,
|
||||
|
||||
/// <summary>A typed reactive collection handle.</summary>
|
||||
Collection,
|
||||
|
||||
/// <summary>A typed pointer to Verse state.</summary>
|
||||
StatePointer,
|
||||
|
||||
|
|
@ -1608,6 +1614,8 @@ namespace GameCult.Mesh
|
|||
ProjectionRecipes = catalog.FindByKind(CultMeshSurfaceKind.ProjectionRecipe);
|
||||
LiveFeeds = catalog.FindByKind(CultMeshSurfaceKind.LiveFeed);
|
||||
Operations = catalog.FindByKind(CultMeshSurfaceKind.Operation);
|
||||
Documents = catalog.FindByKind(CultMeshSurfaceKind.Document);
|
||||
Collections = catalog.FindByKind(CultMeshSurfaceKind.Collection);
|
||||
StatePointers = catalog.FindByKind(CultMeshSurfaceKind.StatePointer);
|
||||
NativeSliceViews = catalog.FindByKind(CultMeshSurfaceKind.NativeSliceView);
|
||||
}
|
||||
|
|
@ -1627,6 +1635,12 @@ namespace GameCult.Mesh
|
|||
/// <summary>Gets typed operation handles.</summary>
|
||||
public IReadOnlyList<CultMeshSurfaceDiagnostic> Operations { get; }
|
||||
|
||||
/// <summary>Gets typed reactive document handles.</summary>
|
||||
public IReadOnlyList<CultMeshSurfaceDiagnostic> Documents { get; }
|
||||
|
||||
/// <summary>Gets typed reactive collection handles.</summary>
|
||||
public IReadOnlyList<CultMeshSurfaceDiagnostic> Collections { get; }
|
||||
|
||||
/// <summary>Gets typed pointers to Verse state.</summary>
|
||||
public IReadOnlyList<CultMeshSurfaceDiagnostic> StatePointers { get; }
|
||||
|
||||
|
|
|
|||
|
|
@ -388,19 +388,20 @@ diagnostic shape for generated clients, Eve/CultUI inspectors, MCP tools, and
|
|||
surface catalogs. Tooling should ask CultMesh for these descriptors instead of
|
||||
copying source lists and route hints by convention.
|
||||
`CultMesh.DescribeSurface(...)` and `CultMesh.DescribeSurfaceCatalog(...)`
|
||||
collect query surfaces, projection recipes, live feeds, operations, state
|
||||
pointers, and native views into one inspectable catalog for a runtime or
|
||||
generated binding package. State pointers are advertised by pointer id; native
|
||||
slice views are advertised by view id and route while the full column layout
|
||||
stays in `CultMeshNativeSliceViewDescriptor`.
|
||||
collect query surfaces, projection recipes, live feeds, operations, document
|
||||
handles, collection handles, state pointers, and native views into one
|
||||
inspectable catalog for a runtime or generated binding package. Documents are
|
||||
advertised by document id, collections by collection id, state pointers by
|
||||
pointer id, and native slice views by view id and route while the full column
|
||||
layout stays in `CultMeshNativeSliceViewDescriptor`.
|
||||
Catalog diagnostics support exact id lookup and kind filtering so tools can
|
||||
discover, for example, every operation or native view without local scan
|
||||
conventions. `CultMesh.DescribeSurfaceCatalogIndex(...)` / TS
|
||||
`CultMesh.surfaceCatalogIndex(...)` promotes that grouping into a shared
|
||||
diagnostic shape with `queries`, `projectionRecipes`, `liveFeeds`,
|
||||
`operations`, `statePointers`, and `nativeSliceViews`, so generated bindings
|
||||
and tools can ask for the semantic bucket they need without copying catalog
|
||||
scan logic.
|
||||
`operations`, `documents`, `collections`, `statePointers`, and
|
||||
`nativeSliceViews`, so generated bindings and tools can ask for the semantic
|
||||
bucket they need without copying catalog scan logic.
|
||||
|
||||
Live feeds compose several query surfaces into one client-facing snapshot
|
||||
without making the UI own refresh loops:
|
||||
|
|
|
|||
|
|
@ -911,6 +911,19 @@ public sealed class CultMeshStreamingTests
|
|||
() => new Subject<string>(),
|
||||
route,
|
||||
sources);
|
||||
var document = CultMesh.Document(
|
||||
"daemon:aetheria.frame.latest.v1",
|
||||
CultMesh.Verse("aetheria.local", "unity-raven").Context,
|
||||
_context => Task.FromResult(new MeshNoteDocument { Schema = "frame", Text = "current", Revision = 1 }),
|
||||
_context => new Subject<MeshNoteDocument>(),
|
||||
sources,
|
||||
route);
|
||||
var collection = new CultMeshCollectionHandle<MeshNoteDocument>(
|
||||
"daemon:aetheria.contacts.v1",
|
||||
() => Task.FromResult<IReadOnlyList<MeshNoteDocument>>(Array.Empty<MeshNoteDocument>()),
|
||||
() => new Subject<CultMeshCollectionChange<MeshNoteDocument>>(),
|
||||
sources,
|
||||
route);
|
||||
var nativeView = new CultMeshNativeSliceViewDescriptor(
|
||||
"aetheria.zone.render",
|
||||
"gamecult.aetheria.render_body.v1",
|
||||
|
|
@ -925,18 +938,22 @@ public sealed class CultMeshStreamingTests
|
|||
CultMesh.DescribeSurface(query),
|
||||
CultMesh.DescribeSurface(feed),
|
||||
CultMesh.DescribeSurface(operation),
|
||||
CultMesh.DescribeSurface(document),
|
||||
CultMesh.DescribeSurface(collection),
|
||||
CultMesh.DescribeSurface(pointer),
|
||||
CultMesh.DescribeSurface(nativeView)
|
||||
});
|
||||
|
||||
catalog.CatalogId.Should().Be("gamecult.aetheria.rts.surfaces.v1");
|
||||
catalog.Surfaces.Should().HaveCount(5);
|
||||
catalog.Surfaces.Should().HaveCount(7);
|
||||
catalog.Surfaces[0].Kind.Should().Be(CultMeshSurfaceKind.Query);
|
||||
catalog.Surfaces[0].SurfaceId.Should().Be("aetheria.zone.objects.visible");
|
||||
catalog.Surfaces[0].RouteHint.Kind.Should().Be(CultMeshLocalityKind.SharedMemory);
|
||||
catalog.Surfaces[0].Sources.Should().HaveCount(1);
|
||||
catalog.Find("aetheria.rts.viewport.feed")!.Kind.Should().Be(CultMeshSurfaceKind.LiveFeed);
|
||||
catalog.Find("aetheria.entity.pilot.move")!.Kind.Should().Be(CultMeshSurfaceKind.Operation);
|
||||
catalog.Find("daemon:aetheria.frame.latest.v1")!.Kind.Should().Be(CultMeshSurfaceKind.Document);
|
||||
catalog.Find("daemon:aetheria.contacts.v1")!.Kind.Should().Be(CultMeshSurfaceKind.Collection);
|
||||
catalog.Find("aetheria.selection.current")!.Kind.Should().Be(CultMeshSurfaceKind.StatePointer);
|
||||
catalog.Find("aetheria.selection.current")!.RouteHint.Kind.Should().Be(CultMeshLocalityKind.SharedMemory);
|
||||
catalog.Find("aetheria.selection.current")!.Sources.Should().ContainSingle();
|
||||
|
|
@ -957,6 +974,8 @@ public sealed class CultMeshStreamingTests
|
|||
index.Queries.Should().ContainSingle().Which.SurfaceId.Should().Be("aetheria.zone.objects.visible");
|
||||
index.LiveFeeds.Should().ContainSingle().Which.SurfaceId.Should().Be("aetheria.rts.viewport.feed");
|
||||
index.Operations.Should().ContainSingle().Which.SurfaceId.Should().Be("aetheria.entity.pilot.move");
|
||||
index.Documents.Should().ContainSingle().Which.SurfaceId.Should().Be("daemon:aetheria.frame.latest.v1");
|
||||
index.Collections.Should().ContainSingle().Which.SurfaceId.Should().Be("daemon:aetheria.contacts.v1");
|
||||
index.StatePointers.Should().ContainSingle().Which.SurfaceId.Should().Be("aetheria.selection.current");
|
||||
index.NativeSliceViews.Should().ContainSingle().Which.SurfaceId.Should().Be("aetheria.zone.render");
|
||||
index.ProjectionRecipes.Should().BeEmpty();
|
||||
|
|
|
|||
Loading…
Reference in a new issue