Update hivegrid-cloud reference to latest main
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e98d38e716
commit
7b21524c86
3781 files changed
+373484
-225607
No files matched your search
+35
-26
@@ -1,3 +1,12 @@
|
||||
// @vitest-environment node
|
||||
//
|
||||
// This is a backend worker suite. `invokeInSandbox` spawns a worker thread and,
|
||||
// when no compiled sandbox worker exists, bundles the source with esbuild.
|
||||
// esbuild asserts `new TextEncoder().encode("") instanceof Uint8Array`, which is
|
||||
// false under the repo-wide jsdom default (jsdom swaps the `Uint8Array` global
|
||||
// for its own realm). Pin this file to the node environment so the invariant
|
||||
// holds and esbuild can run.
|
||||
|
||||
/**
|
||||
* Phase 06 #21 / F-015 — bootstrapPluginInvokeDeps wiring tests.
|
||||
*
|
||||
@@ -109,7 +118,7 @@ const INFINITE_LOOP_WASM = new Uint8Array([
|
||||
function manifestWithCapabilities(capabilities: Array<{ name: "log" | "audit" }>) {
|
||||
return {
|
||||
schemaVersion: 1 as const,
|
||||
id: "de.toolctrl.test",
|
||||
id: "de.hivegrid.test",
|
||||
version: "1.0.0",
|
||||
name: "Test",
|
||||
entry: "plugin.wasm",
|
||||
@@ -167,12 +176,12 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
logger: noopLogger,
|
||||
});
|
||||
|
||||
await expect(deps.loadCapabilityGrants({ tenantId: "tenant-1", pluginId: "de.toolctrl.test" })).resolves.toEqual([
|
||||
await expect(deps.loadCapabilityGrants({ tenantId: "tenant-1", pluginId: "de.hivegrid.test" })).resolves.toEqual([
|
||||
{ capabilityName: "log", scopeJson: null },
|
||||
{ capabilityName: "http.outbound", scopeJson: { allowedHosts: ["api.example.com"] } },
|
||||
]);
|
||||
expect(prisma.tenantPluginCapabilityGrant.findMany).toHaveBeenCalledWith({
|
||||
where: { tenantId: "tenant-1", pluginId: "de.toolctrl.test" },
|
||||
where: { tenantId: "tenant-1", pluginId: "de.hivegrid.test" },
|
||||
select: { capabilityName: true, scopeJson: true },
|
||||
});
|
||||
});
|
||||
@@ -217,7 +226,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
const manifest = manifestWithCapabilities([{ name: "log" }]);
|
||||
prisma.plugin.findUnique = vi.fn(async () => ({
|
||||
tenantId: "t",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
version: "1.0.0",
|
||||
manifest,
|
||||
wasmSha256: "0".repeat(64),
|
||||
@@ -231,9 +240,9 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
logger: noopLogger,
|
||||
});
|
||||
|
||||
await expect(deps.loadPlugin({ tenantId: "t", pluginId: "de.toolctrl.test", version: "1.0.0" })).resolves.toMatchObject({
|
||||
await expect(deps.loadPlugin({ tenantId: "t", pluginId: "de.hivegrid.test", version: "1.0.0" })).resolves.toMatchObject({
|
||||
tenantId: "t",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
manifest,
|
||||
enabled: true,
|
||||
});
|
||||
@@ -243,7 +252,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
const prisma = makeFakePrisma();
|
||||
prisma.plugin.findUnique = vi.fn(async () => ({
|
||||
tenantId: "t",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
version: "1.0.0",
|
||||
manifest: { hooks: [{ name: "run", export: "run" }] },
|
||||
wasmSha256: "0".repeat(64),
|
||||
@@ -258,11 +267,11 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
logger,
|
||||
});
|
||||
|
||||
await expect(deps.loadPlugin({ tenantId: "t", pluginId: "de.toolctrl.test", version: "1.0.0" })).resolves.toBeNull();
|
||||
await expect(deps.loadPlugin({ tenantId: "t", pluginId: "de.hivegrid.test", version: "1.0.0" })).resolves.toBeNull();
|
||||
expect(logger.warn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
tenantId: "t",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
version: "1.0.0",
|
||||
}),
|
||||
"plugin.invoke.stored_manifest_invalid"
|
||||
@@ -283,7 +292,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
test("loadBinary refuses plugin paths that escape the configured base directory", async () => {
|
||||
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn() };
|
||||
const deps = bootstrapPluginInvokeDeps({
|
||||
env: { PLUGIN_BINARY_BASE_PATH: "/tmp/toolctrl-plugins" },
|
||||
env: { PLUGIN_BINARY_BASE_PATH: "/tmp/hivegrid-plugins" },
|
||||
prisma: makeFakePrisma(),
|
||||
store: makeFakeStore() as never,
|
||||
logger,
|
||||
@@ -329,7 +338,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
const result = await deps.invokeInSandbox({
|
||||
pluginInvocationId: "inv-1",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
wasmBuffer: HOST_IMPORT_WASM,
|
||||
manifest: manifestWithCapabilities(capabilities),
|
||||
hookName: "run",
|
||||
@@ -346,19 +355,19 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
priority: 20,
|
||||
payload: expect.objectContaining({
|
||||
tenantId: "tenant-1",
|
||||
actorId: "de.toolctrl.test",
|
||||
actorId: "de.hivegrid.test",
|
||||
actorType: "plugin",
|
||||
action: "plugin.audit.recorded",
|
||||
targetType: "plugin",
|
||||
targetId: "de.toolctrl.test",
|
||||
targetId: "de.hivegrid.test",
|
||||
requestId: "inv-1",
|
||||
sourceModule: "worker.plugin-runtime",
|
||||
outcome: "success",
|
||||
dataSensitivity: "internal",
|
||||
regulatoryScope: ["soc2"],
|
||||
metadata: expect.objectContaining({
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginManifestId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
pluginManifestId: "de.hivegrid.test",
|
||||
pluginInvocationId: "inv-1",
|
||||
version: "1.0.0",
|
||||
hookName: "run",
|
||||
@@ -388,7 +397,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
]);
|
||||
expect(logger.info).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
value: { value: 7 },
|
||||
version: "1.0.0",
|
||||
}),
|
||||
@@ -396,7 +405,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
);
|
||||
expect(logger.info).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
value: { value: 7 },
|
||||
version: "1.0.0",
|
||||
}),
|
||||
@@ -405,7 +414,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
expect(logger.info).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
pluginInvocationId: "inv-1",
|
||||
sequence: 0,
|
||||
}),
|
||||
@@ -429,7 +438,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
deps.invokeInSandbox({
|
||||
pluginInvocationId: "inv-audit-down",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
wasmBuffer: HOST_IMPORT_WASM,
|
||||
manifest: manifestWithCapabilities(capabilities),
|
||||
hookName: "run",
|
||||
@@ -441,7 +450,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
expect.objectContaining({
|
||||
pluginInvocationId: "inv-audit-down",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
entryCount: expect.any(Number),
|
||||
}),
|
||||
"plugin capability-use audit flush failed"
|
||||
@@ -463,7 +472,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
deps.invokeInSandbox({
|
||||
pluginInvocationId: "inv-audit-truncated",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
wasmBuffer: HOST_IMPORT_WASM,
|
||||
manifest: manifestWithCapabilities(capabilities),
|
||||
hookName: "run",
|
||||
@@ -501,7 +510,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
const result = await deps.invokeInSandbox({
|
||||
pluginInvocationId: "inv-duplicate",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
wasmBuffer: HOST_IMPORT_WASM,
|
||||
manifest: manifestWithCapabilities(capabilities),
|
||||
hookName: "run",
|
||||
@@ -547,7 +556,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
const result = await deps.invokeInSandbox({
|
||||
pluginInvocationId: "inv-host-audit-duplicate",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
wasmBuffer: HOST_IMPORT_WASM,
|
||||
manifest: manifestWithCapabilities(capabilities),
|
||||
hookName: "run",
|
||||
@@ -588,7 +597,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
const result = await deps.invokeInSandbox({
|
||||
pluginInvocationId: "inv-2",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
wasmBuffer: HOST_IMPORT_WASM,
|
||||
manifest: manifestWithCapabilities(capabilities),
|
||||
hookName: "run",
|
||||
@@ -642,7 +651,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
const result = await deps.invokeInSandbox({
|
||||
pluginInvocationId: "inv-missing-grant",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
wasmBuffer: HOST_IMPORT_WASM,
|
||||
manifest: manifestWithCapabilities(capabilities),
|
||||
hookName: "run",
|
||||
@@ -689,7 +698,7 @@ describe("bootstrapPluginInvokeDeps", () => {
|
||||
const result = await deps.invokeInSandbox({
|
||||
pluginInvocationId: "inv-timeout",
|
||||
tenantId: "tenant-1",
|
||||
pluginId: "de.toolctrl.test",
|
||||
pluginId: "de.hivegrid.test",
|
||||
wasmBuffer: INFINITE_LOOP_WASM,
|
||||
manifest: manifestWithCapabilities([]),
|
||||
hookName: "run",
|
||||
|
||||
Reference in new issue
Block a user