fix: harden invalidation registry governance

This commit is contained in:
DongHyeonka
2026-08-01 23:59:11 +09:00
parent 73a50426d6
commit 0eb23875cb
15 changed files with 906 additions and 147 deletions
@@ -106,6 +106,31 @@ describe("query invalidation registry", () => {
]);
});
it("snapshots a caller-owned namespace identity before indexing it", () => {
const mutableNamespace = {
namespaceId: "orders",
namespaceVersion: 1,
};
const index = indexInvalidationRegistry({
topics: [topic],
namespaces: [mutableNamespace],
edges: [{ topicId: topic, namespace: mutableNamespace }],
});
mutableNamespace.namespaceId = "mutated-orders";
mutableNamespace.namespaceVersion = 2;
const indexedNamespace = index.namespacesForTopic.get(topic)?.[0];
expect(indexedNamespace).toEqual({
namespaceId: "orders",
namespaceVersion: 1,
});
expect(Object.isFrozen(indexedNamespace)).toBe(true);
expect(
indexedNamespace && createQueryInvalidationPrefix(indexedNamespace),
).toEqual(["query", 2, "orders", 1]);
});
it("rejects duplicate namespace identities even when they are separate objects", () => {
const duplicate = defineQueryNamespaceIdentity("orders", 1);