{"version":3,"file":"in-memory-inference-queue-store.d.ts","sourceRoot":"","sources":["../../../src/core/shared-inference/in-memory-inference-queue-store.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACN,KAAK,2BAA2B,EAChC,KAAK,yBAAyB,EAC9B,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAE5B,MAAM,sBAAsB,CAAC;AAE9B,qBAAa,2BAA4B,YAAW,mBAAmB;IACtE,QAAQ,CAAC,OAAO,YAAY;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA8C;IAEhE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAItG;IAEK,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAIjE;IAEK,MAAM,CAAC,CAAC,EACb,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,CAAC,OAAO,EAAE,uBAAuB,KAAK,uBAAuB,CAAC,CAAC,CAAC,GACxE,OAAO,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAazC;IAEK,aAAa,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAEvC;IAED,sDAAsD;IACtD,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS,CAE5D;CACD;AAED,wBAAgB,iCAAiC,IAAI,2BAA2B,CAE/E","sourcesContent":["/**\n * In-memory inference queue store (3.0.0 foundation).\n *\n * Deterministic, single-process implementation of the InferenceQueueStore port\n * for unit tests and the synthetic benchmark harness. Same ledger semantics as\n * the file store but without cross-process locking; mutations are synchronous\n * read-validate-write over an in-process map.\n */\n\nimport {\n\ttype InferenceLedgerCreateResult,\n\ttype InferenceLedgerLoadResult,\n\ttype InferenceLedgerMutateResult,\n\ttype InferenceLedgerMutation,\n\ttype InferenceQueueStore,\n\ttype InferenceResourceLedger,\n\tparseInferenceResourceLedger,\n} from \"./inference-queue.js\";\n\nexport class InMemoryInferenceQueueStore implements InferenceQueueStore {\n\treadonly storeId = \"memory\";\n\tprivate readonly ledgers = new Map<string, InferenceResourceLedger>();\n\n\tasync create(resourceId: string, ledger: InferenceResourceLedger): Promise<InferenceLedgerCreateResult> {\n\t\tif (this.ledgers.has(resourceId)) return { status: \"idempotent\", ledger: this.ledgers.get(resourceId)! };\n\t\tthis.ledgers.set(resourceId, structuredClone(ledger));\n\t\treturn { status: \"created\" };\n\t}\n\n\tasync load(resourceId: string): Promise<InferenceLedgerLoadResult> {\n\t\tconst ledger = this.ledgers.get(resourceId);\n\t\tif (!ledger) return { status: \"missing\" };\n\t\treturn { status: \"ok\", ledger: structuredClone(ledger) };\n\t}\n\n\tasync mutate<T>(\n\t\tresourceId: string,\n\t\tmutation: (current: InferenceResourceLedger) => InferenceLedgerMutation<T>,\n\t): Promise<InferenceLedgerMutateResult<T>> {\n\t\tconst current = this.ledgers.get(resourceId);\n\t\tif (!current) return { status: \"missing\" };\n\t\tconst output = mutation(structuredClone(current));\n\t\tif (output.kind === \"noop\") return { status: \"ok\", value: output.value };\n\t\tconst nextValidation = parseInferenceResourceLedger(output.next);\n\t\tif (!nextValidation.ok) {\n\t\t\tthrow new Error(\n\t\t\t\t`Inference mutation produced an invalid ledger for ${resourceId}: ${nextValidation.diagnostic}`,\n\t\t\t);\n\t\t}\n\t\tthis.ledgers.set(resourceId, structuredClone(output.next));\n\t\treturn { status: \"ok\", value: output.value };\n\t}\n\n\tasync listResources(): Promise<string[]> {\n\t\treturn [...this.ledgers.keys()].sort();\n\t}\n\n\t/** Test helper: read the raw ledger (not a clone). */\n\tpeek(resourceId: string): InferenceResourceLedger | undefined {\n\t\treturn this.ledgers.get(resourceId);\n\t}\n}\n\nexport function createInMemoryInferenceQueueStore(): InMemoryInferenceQueueStore {\n\treturn new InMemoryInferenceQueueStore();\n}\n"]}