@phosphorco/bb-thread-metrics 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRACT.md +130 -0
- package/dist/bb.js +267 -17
- package/dist/index.js +428 -69
- package/dist/testing.js +70 -1
- package/dist/types/bb.d.ts +1064 -8
- package/dist/types/heat-settings.d.ts +413 -0
- package/dist/types/index.d.ts +19 -16
- package/dist/types/recent-session.d.ts +51 -0
- package/dist/types/recent.d.ts +5356 -363
- package/dist/types/testing.d.ts +8 -0
- package/package.json +2 -2
package/dist/testing.js
CHANGED
|
@@ -1,6 +1,74 @@
|
|
|
1
1
|
// src/testing.ts
|
|
2
2
|
import { createFakePluginHost } from "@get-bb/plugin-sdk/testing";
|
|
3
3
|
import { RECENT_LIMITS, recentSnapshotInputSchema, validateRecentSnapshot, METHODS, LIMITS, readInputSchema, detailInputSchema, describeEnvelopeSchema, parseBounded, negotiateVersion, validateReadResult, validateDetailResult } from "./index.js";
|
|
4
|
+
import { createHeatSettingsClient } from "./bb.js";
|
|
5
|
+
import { HEAT_SETTINGS_METHODS } from "./index.js";
|
|
6
|
+
async function runHeatSettingsConformance(options) {
|
|
7
|
+
const host = createFakePluginHost({ pluginId: options.pluginId }), checks = [];
|
|
8
|
+
const client = createHeatSettingsClient({ plugins: { list: async () => ({ plugins: [] }), callRpc: async (args) => await host.harness.behavior.callRpc(args.method, args.input) } }, options.pluginId);
|
|
9
|
+
const check = async (name, fn) => {
|
|
10
|
+
try {
|
|
11
|
+
await fn();
|
|
12
|
+
checks.push({ name, passed: true });
|
|
13
|
+
} catch (e) {
|
|
14
|
+
checks.push({ name, passed: false, error: String(e) });
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
try {
|
|
18
|
+
await options.register(host.bb);
|
|
19
|
+
const initial = await client.read({ protocolVersion: 1 });
|
|
20
|
+
const input = { protocolVersion: 1, operationKey: "kit:save", baseConfigVersion: initial.current.version, candidate: options.candidate };
|
|
21
|
+
let saved;
|
|
22
|
+
await check("heat-CAS-save", async () => {
|
|
23
|
+
saved = await client.save(input);
|
|
24
|
+
if (saved.kind !== "saved" || saved.record.version === initial.current.version)
|
|
25
|
+
throw new Error("CAS did not publish fresh config version");
|
|
26
|
+
});
|
|
27
|
+
await check("heat-root-domain-saved", async () => {
|
|
28
|
+
if (saved.record.value.schemaVersion !== 3 || saved.record.value.domain.kind !== "root-family")
|
|
29
|
+
throw new Error("Root-family domain missing from saved record");
|
|
30
|
+
});
|
|
31
|
+
await check("heat-required-domain", async () => {
|
|
32
|
+
const { domain, ...missing } = options.candidate;
|
|
33
|
+
let rejected = false;
|
|
34
|
+
try {
|
|
35
|
+
await host.harness.behavior.callRpc(HEAT_SETTINGS_METHODS.save, { ...input, operationKey: "kit:no-domain", candidate: missing });
|
|
36
|
+
} catch {
|
|
37
|
+
rejected = true;
|
|
38
|
+
}
|
|
39
|
+
if (!rejected)
|
|
40
|
+
throw new Error("Domain-less root candidate accepted");
|
|
41
|
+
});
|
|
42
|
+
await check("heat-idempotency", async () => {
|
|
43
|
+
const repeated = await client.save(input);
|
|
44
|
+
if (JSON.stringify(repeated) !== JSON.stringify(saved))
|
|
45
|
+
throw new Error("Idempotency changed result");
|
|
46
|
+
});
|
|
47
|
+
await check("heat-stale-base", async () => {
|
|
48
|
+
const conflict = await client.save({ ...input, operationKey: "kit:conflict" });
|
|
49
|
+
if (conflict.kind !== "conflict" || conflict.record.version !== saved.record.version)
|
|
50
|
+
throw new Error("Stale base wrote");
|
|
51
|
+
});
|
|
52
|
+
await check("heat-reconciliation", async () => {
|
|
53
|
+
const read = await client.read({ protocolVersion: 1, operationKey: input.operationKey });
|
|
54
|
+
if (read.outcome?.kind !== "saved" || read.outcome.record.version !== saved.record.version)
|
|
55
|
+
throw new Error("Missing operation receipt");
|
|
56
|
+
});
|
|
57
|
+
await check("heat-strict-nested-input", async () => {
|
|
58
|
+
let rejected = false;
|
|
59
|
+
try {
|
|
60
|
+
await host.harness.behavior.callRpc(HEAT_SETTINGS_METHODS.save, { ...input, operationKey: "kit:invalid", candidate: { ...input.candidate, unexpected: true } });
|
|
61
|
+
} catch {
|
|
62
|
+
rejected = true;
|
|
63
|
+
}
|
|
64
|
+
if (!rejected)
|
|
65
|
+
throw new Error("Nested unknown field accepted");
|
|
66
|
+
});
|
|
67
|
+
} finally {
|
|
68
|
+
await host.harness.lifecycle.dispose();
|
|
69
|
+
}
|
|
70
|
+
return { passed: checks.every((c) => c.passed), checks, proof: "source-conformance" };
|
|
71
|
+
}
|
|
4
72
|
async function runSupplierConformance(options) {
|
|
5
73
|
if (!options.readCases.length)
|
|
6
74
|
throw new Error("At least one real read case required");
|
|
@@ -88,5 +156,6 @@ async function runSupplierConformance(options) {
|
|
|
88
156
|
return { passed: checks.every((c) => c.passed), checks, proof: "source-conformance" };
|
|
89
157
|
}
|
|
90
158
|
export {
|
|
91
|
-
runSupplierConformance
|
|
159
|
+
runSupplierConformance,
|
|
160
|
+
runHeatSettingsConformance
|
|
92
161
|
};
|