d25d482dc2
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
145 lines
3.8 KiB
TypeScript
145 lines
3.8 KiB
TypeScript
/**
|
|
* @vitest-environment node
|
|
*/
|
|
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
const { mockMaterializeLargeValueRef } = vi.hoisted(() => ({
|
|
mockMaterializeLargeValueRef: vi.fn(),
|
|
}))
|
|
|
|
vi.mock('@/lib/execution/payloads/store', () => ({
|
|
materializeLargeValueRef: mockMaterializeLargeValueRef,
|
|
}))
|
|
|
|
import { warmLargeValueRefs } from '@/lib/execution/payloads/hydration'
|
|
|
|
describe('warmLargeValueRefs', () => {
|
|
beforeEach(() => {
|
|
vi.clearAllMocks()
|
|
})
|
|
|
|
it('does not warm manifest chunks before explicit navigation', async () => {
|
|
const chunkRef = {
|
|
__simLargeValueRef: true,
|
|
version: 1,
|
|
id: 'lv_ABCDEFGHIJKL',
|
|
kind: 'array',
|
|
size: 16,
|
|
executionId: 'execution-1',
|
|
}
|
|
const manifest = {
|
|
__simLargeArrayManifest: true,
|
|
version: 2,
|
|
kind: 'array',
|
|
totalCount: 1,
|
|
chunkCount: 1,
|
|
byteSize: 16,
|
|
chunks: [
|
|
{
|
|
ref: chunkRef,
|
|
count: 1,
|
|
byteSize: 16,
|
|
},
|
|
],
|
|
preview: [],
|
|
}
|
|
|
|
await warmLargeValueRefs({ issues: manifest }, { executionId: 'execution-1' })
|
|
|
|
expect(mockMaterializeLargeValueRef).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('records exact keys discovered while warming manifest preview refs', async () => {
|
|
const previewRef = {
|
|
__simLargeValueRef: true,
|
|
version: 1,
|
|
id: 'lv_ABCDEFGHIJKL',
|
|
kind: 'object',
|
|
size: 16,
|
|
key: 'execution/workspace-1/workflow-1/source-execution/large-value-lv_ABCDEFGHIJKL.json',
|
|
executionId: 'source-execution',
|
|
}
|
|
const nestedRef = {
|
|
__simLargeValueRef: true,
|
|
version: 1,
|
|
id: 'lv_MNOPQRSTUVWX',
|
|
kind: 'object',
|
|
size: 16,
|
|
key: 'execution/workspace-1/workflow-1/source-execution/large-value-lv_MNOPQRSTUVWX.json',
|
|
executionId: 'source-execution',
|
|
}
|
|
const file = {
|
|
id: 'file-1',
|
|
name: 'nested.txt',
|
|
key: 'execution/workspace-1/workflow-1/source-execution/nested.txt',
|
|
url: '/api/files/serve/execution/workspace-1/workflow-1/source-execution/nested.txt?context=execution',
|
|
size: 5,
|
|
type: 'text/plain',
|
|
context: 'execution',
|
|
}
|
|
const manifest = {
|
|
__simLargeArrayManifest: true,
|
|
version: 2,
|
|
kind: 'array',
|
|
totalCount: 1,
|
|
chunkCount: 1,
|
|
byteSize: 16,
|
|
chunks: [
|
|
{
|
|
ref: {
|
|
__simLargeValueRef: true,
|
|
version: 1,
|
|
id: 'lv_CHUNKREF0001',
|
|
kind: 'array',
|
|
size: 16,
|
|
executionId: 'source-execution',
|
|
},
|
|
count: 1,
|
|
byteSize: 16,
|
|
},
|
|
],
|
|
preview: [previewRef],
|
|
}
|
|
const context = {
|
|
executionId: 'execution-1',
|
|
largeValueKeys: [] as string[],
|
|
fileKeys: [] as string[],
|
|
}
|
|
mockMaterializeLargeValueRef.mockResolvedValueOnce([{ nestedRef, file }])
|
|
|
|
await warmLargeValueRefs({ issues: manifest }, context)
|
|
|
|
expect(mockMaterializeLargeValueRef).toHaveBeenCalledWith(previewRef, context)
|
|
expect(context.largeValueKeys).toEqual([nestedRef.key])
|
|
expect(context.fileKeys).toEqual([file.key])
|
|
})
|
|
|
|
it('warms manifest preview refs without exposing chunk internals as navigable metadata', async () => {
|
|
const previewRef = {
|
|
__simLargeValueRef: true,
|
|
version: 1,
|
|
id: 'lv_PREVIEWREF01',
|
|
kind: 'object',
|
|
size: 16,
|
|
executionId: 'execution-1',
|
|
}
|
|
const manifest = {
|
|
__simLargeArrayManifest: true,
|
|
version: 2,
|
|
kind: 'array',
|
|
totalCount: 0,
|
|
chunkCount: 0,
|
|
byteSize: 0,
|
|
chunks: [],
|
|
preview: [previewRef],
|
|
}
|
|
mockMaterializeLargeValueRef.mockResolvedValueOnce({ key: 'SIM-1' })
|
|
|
|
await warmLargeValueRefs({ issues: manifest }, { executionId: 'execution-1' })
|
|
|
|
expect(mockMaterializeLargeValueRef).toHaveBeenCalledWith(previewRef, {
|
|
executionId: 'execution-1',
|
|
})
|
|
})
|
|
})
|