@workglow/test-contract 0.6.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.
Files changed (149) hide show
  1. package/README.md +232 -0
  2. package/dist/ai-provider/assertions/capabilityHonesty.d.ts +7 -0
  3. package/dist/ai-provider/assertions/dispose.d.ts +7 -0
  4. package/dist/ai-provider/assertions/inferAdvertisesRegistered.d.ts +15 -0
  5. package/dist/ai-provider/assertions/inferServesInferred.d.ts +20 -0
  6. package/dist/ai-provider/assertions/pricingMatchesModality.d.ts +36 -0
  7. package/dist/ai-provider/assertions/registryCoverage.d.ts +13 -0
  8. package/dist/ai-provider/assertions/sessionReuse.d.ts +7 -0
  9. package/dist/ai-provider/assertions/signalHonoring.d.ts +7 -0
  10. package/dist/ai-provider/assertions/structuredGeneration.d.ts +7 -0
  11. package/dist/ai-provider/assertions/textGenerationSmoke.d.ts +7 -0
  12. package/dist/ai-provider/assertions/toolCallAccumulator.d.ts +7 -0
  13. package/dist/ai-provider/assertions/toolCallMultiTurn.d.ts +7 -0
  14. package/dist/ai-provider/assertions/usageNormalization.d.ts +61 -0
  15. package/dist/ai-provider/fixtures.d.ts +8 -0
  16. package/dist/ai-provider/runAiProviderConformance.d.ts +7 -0
  17. package/dist/ai-provider/types.d.ts +75 -0
  18. package/dist/ai-provider.d.ts +25 -0
  19. package/dist/ai-provider.js +876 -0
  20. package/dist/ai-provider.js.map +26 -0
  21. package/dist/browser-context/ConformanceMockContext.d.ts +54 -0
  22. package/dist/browser-context/assertions/ariaRoundTrip.d.ts +7 -0
  23. package/dist/browser-context/assertions/capabilityHonesty.d.ts +7 -0
  24. package/dist/browser-context/assertions/itExpectFail.d.ts +8 -0
  25. package/dist/browser-context/assertions/networkIntrospection.d.ts +7 -0
  26. package/dist/browser-context/assertions/tabsLifecycle.d.ts +7 -0
  27. package/dist/browser-context/fixtures.d.ts +8 -0
  28. package/dist/browser-context/runIBrowserContextConformance.d.ts +7 -0
  29. package/dist/browser-context/types.d.ts +48 -0
  30. package/dist/browser-context.d.ts +18 -0
  31. package/dist/browser-context.js +567 -0
  32. package/dist/browser-context.js.map +17 -0
  33. package/dist/creditExhaustedSkip.d.ts +39 -0
  34. package/dist/creditExhaustedSkip.js +163 -0
  35. package/dist/creditExhaustedSkip.js.map +10 -0
  36. package/dist/entitlement-profile/assertions/denialShape.d.ts +13 -0
  37. package/dist/entitlement-profile/assertions/dispose.d.ts +16 -0
  38. package/dist/entitlement-profile/assertions/hierarchyHonoring.d.ts +11 -0
  39. package/dist/entitlement-profile/assertions/optionalNeverDenied.d.ts +11 -0
  40. package/dist/entitlement-profile/assertions/requestEntitlementShape.d.ts +12 -0
  41. package/dist/entitlement-profile/assertions/resourceScoping.d.ts +16 -0
  42. package/dist/entitlement-profile/assertions/subscribeGrant.d.ts +11 -0
  43. package/dist/entitlement-profile/assertions/subscribeReload.d.ts +11 -0
  44. package/dist/entitlement-profile/assertions/subscribeRevocation.d.ts +12 -0
  45. package/dist/entitlement-profile/assertions/surfaceCoverage.d.ts +7 -0
  46. package/dist/entitlement-profile/assertions/unsubscribeIdempotent.d.ts +7 -0
  47. package/dist/entitlement-profile/fixtures.d.ts +21 -0
  48. package/dist/entitlement-profile/runEntitlementProfileConformance.d.ts +7 -0
  49. package/dist/entitlement-profile/types.d.ts +45 -0
  50. package/dist/entitlement-profile.d.ts +23 -0
  51. package/dist/entitlement-profile.js +436 -0
  52. package/dist/entitlement-profile.js.map +22 -0
  53. package/dist/human-connector/MockHumanConnector.d.ts +29 -0
  54. package/dist/human-connector/assertions/abort.d.ts +7 -0
  55. package/dist/human-connector/assertions/capabilityHonesty.d.ts +7 -0
  56. package/dist/human-connector/assertions/concurrentIsolation.d.ts +7 -0
  57. package/dist/human-connector/assertions/multiTurnFollowUp.d.ts +7 -0
  58. package/dist/human-connector/assertions/notifyDisplayFastResolve.d.ts +7 -0
  59. package/dist/human-connector/assertions/roundtrip.d.ts +7 -0
  60. package/dist/human-connector/fixtures.d.ts +8 -0
  61. package/dist/human-connector/runHumanConnectorConformance.d.ts +9 -0
  62. package/dist/human-connector/types.d.ts +91 -0
  63. package/dist/human-connector.d.ts +19 -0
  64. package/dist/human-connector.js +843 -0
  65. package/dist/human-connector.js.map +20 -0
  66. package/dist/itExpectFail.d.ts +15 -0
  67. package/dist/itExpectFail.js +180 -0
  68. package/dist/itExpectFail.js.map +11 -0
  69. package/dist/storage-migrations/assertions/appliesAndRecords.d.ts +7 -0
  70. package/dist/storage-migrations/assertions/concurrentRunsSerialize.d.ts +18 -0
  71. package/dist/storage-migrations/assertions/ensureBookkeepingIdempotent.d.ts +7 -0
  72. package/dist/storage-migrations/assertions/failedMigrationLeavesNoPartialSchema.d.ts +14 -0
  73. package/dist/storage-migrations/assertions/failedMigrationNotRecorded.d.ts +7 -0
  74. package/dist/storage-migrations/assertions/idempotentRun.d.ts +7 -0
  75. package/dist/storage-migrations/assertions/incrementalApplication.d.ts +7 -0
  76. package/dist/storage-migrations/runMigrationRunnerContract.d.ts +9 -0
  77. package/dist/storage-migrations/types.d.ts +78 -0
  78. package/dist/storage-migrations.d.ts +18 -0
  79. package/dist/storage-migrations.js +473 -0
  80. package/dist/storage-migrations.js.map +20 -0
  81. package/dist/tabular-migrations/assertions/addAndDropIndex.d.ts +7 -0
  82. package/dist/tabular-migrations/assertions/addColumn.d.ts +7 -0
  83. package/dist/tabular-migrations/assertions/backfill.d.ts +7 -0
  84. package/dist/tabular-migrations/assertions/dropColumn.d.ts +7 -0
  85. package/dist/tabular-migrations/assertions/failedMigrationNotRecorded.d.ts +7 -0
  86. package/dist/tabular-migrations/assertions/freshDbFastPath.d.ts +7 -0
  87. package/dist/tabular-migrations/assertions/incrementalApplication.d.ts +7 -0
  88. package/dist/tabular-migrations/assertions/renameColumn.d.ts +7 -0
  89. package/dist/tabular-migrations/runTabularMigrationContract.d.ts +8 -0
  90. package/dist/tabular-migrations/types.d.ts +28 -0
  91. package/dist/tabular-migrations.d.ts +19 -0
  92. package/dist/tabular-migrations.js +257 -0
  93. package/dist/tabular-migrations.js.map +18 -0
  94. package/dist/tabular-storage/assertions/countMatchesQuery.d.ts +7 -0
  95. package/dist/tabular-storage/assertions/guardParity.d.ts +25 -0
  96. package/dist/tabular-storage/assertions/inListCriterion.d.ts +14 -0
  97. package/dist/tabular-storage/assertions/joinBoundedLeftRead.d.ts +29 -0
  98. package/dist/tabular-storage/assertions/joinPushdown.d.ts +13 -0
  99. package/dist/tabular-storage/assertions/notInListCriterion.d.ts +15 -0
  100. package/dist/tabular-storage/assertions/strategyParity.d.ts +31 -0
  101. package/dist/tabular-storage/assertions/subscribeToChanges.d.ts +21 -0
  102. package/dist/tabular-storage/assertions/vectorColumnFormat.d.ts +7 -0
  103. package/dist/tabular-storage/assertions/withConnectionTransaction.d.ts +7 -0
  104. package/dist/tabular-storage/assertions/withTransactionRollback.d.ts +7 -0
  105. package/dist/tabular-storage/fixtures.d.ts +33 -0
  106. package/dist/tabular-storage/joinFixtures.d.ts +66 -0
  107. package/dist/tabular-storage/runTabularJoinContract.d.ts +24 -0
  108. package/dist/tabular-storage/runTabularStorageContract.d.ts +9 -0
  109. package/dist/tabular-storage/types.d.ts +102 -0
  110. package/dist/tabular-storage.d.ts +25 -0
  111. package/dist/tabular-storage.js +1477 -0
  112. package/dist/tabular-storage.js.map +27 -0
  113. package/dist/vector-storage/assertions/dimensionValidation.d.ts +17 -0
  114. package/dist/vector-storage/assertions/legacyEncoding.d.ts +16 -0
  115. package/dist/vector-storage/assertions/metadataFilter.d.ts +16 -0
  116. package/dist/vector-storage/assertions/searchOptions.d.ts +16 -0
  117. package/dist/vector-storage/assertions/shared.d.ts +23 -0
  118. package/dist/vector-storage/assertions/similarityRanking.d.ts +18 -0
  119. package/dist/vector-storage/assertions/similaritySearchEvent.d.ts +16 -0
  120. package/dist/vector-storage/assertions/vectorRoundTrip.d.ts +17 -0
  121. package/dist/vector-storage/runVectorStorageContract.d.ts +20 -0
  122. package/dist/vector-storage/types.d.ts +87 -0
  123. package/dist/vector-storage.d.ts +19 -0
  124. package/dist/vector-storage.js +412 -0
  125. package/dist/vector-storage.js.map +21 -0
  126. package/dist/web-search/assertions/capabilityAgreement.d.ts +23 -0
  127. package/dist/web-search/assertions/credentialNaming.d.ts +21 -0
  128. package/dist/web-search/assertions/dateFiltering.d.ts +22 -0
  129. package/dist/web-search/assertions/domainNormalization.d.ts +24 -0
  130. package/dist/web-search/assertions/maxResultsCeiling.d.ts +22 -0
  131. package/dist/web-search/assertions/reportedQuery.d.ts +18 -0
  132. package/dist/web-search/assertions/signalThreading.d.ts +20 -0
  133. package/dist/web-search/fixtures.d.ts +40 -0
  134. package/dist/web-search/runWebSearchProviderConformance.d.ts +24 -0
  135. package/dist/web-search/types.d.ts +79 -0
  136. package/dist/web-search.d.ts +19 -0
  137. package/dist/web-search.js +560 -0
  138. package/dist/web-search.js.map +18 -0
  139. package/dist/worker-proxy/assertions/backlogOrdering.d.ts +7 -0
  140. package/dist/worker-proxy/assertions/disposeTerminatesWorker.d.ts +8 -0
  141. package/dist/worker-proxy/assertions/errorPropagation.d.ts +7 -0
  142. package/dist/worker-proxy/assertions/providerCallHelpers.d.ts +23 -0
  143. package/dist/worker-proxy/browserOnlyStub.d.ts +7 -0
  144. package/dist/worker-proxy/runWorkerProxyBoundary.d.ts +7 -0
  145. package/dist/worker-proxy/types.d.ts +47 -0
  146. package/dist/worker-proxy.d.ts +16 -0
  147. package/dist/worker-proxy.js +389 -0
  148. package/dist/worker-proxy.js.map +17 -0
  149. package/package.json +120 -0
@@ -0,0 +1,66 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ITabularStorage } from "@workglow/storage";
7
+ import type { FromSchema } from "@workglow/util/schema";
8
+ export declare const AuthorPrimaryKeyNames: readonly ["id"];
9
+ export declare const AuthorSchema: {
10
+ readonly type: "object";
11
+ readonly properties: {
12
+ readonly id: {
13
+ readonly type: "string";
14
+ };
15
+ readonly tenant: {
16
+ readonly type: "string";
17
+ };
18
+ readonly name: {
19
+ readonly type: "string";
20
+ };
21
+ readonly country: {
22
+ readonly anyOf: readonly [{
23
+ readonly type: "string";
24
+ }, {
25
+ readonly type: "null";
26
+ }];
27
+ };
28
+ };
29
+ readonly required: readonly ["id", "tenant", "name", "country"];
30
+ readonly additionalProperties: false;
31
+ };
32
+ export declare const PostPrimaryKeyNames: readonly ["id"];
33
+ export declare const PostSchema: {
34
+ readonly type: "object";
35
+ readonly properties: {
36
+ readonly id: {
37
+ readonly type: "string";
38
+ };
39
+ readonly tenant: {
40
+ readonly type: "string";
41
+ };
42
+ readonly author_id: {
43
+ readonly anyOf: readonly [{
44
+ readonly type: "string";
45
+ }, {
46
+ readonly type: "null";
47
+ }];
48
+ };
49
+ readonly title: {
50
+ readonly type: "string";
51
+ };
52
+ readonly views: {
53
+ readonly type: "number";
54
+ };
55
+ };
56
+ readonly required: readonly ["id", "tenant", "author_id", "title", "views"];
57
+ readonly additionalProperties: false;
58
+ };
59
+ export type AuthorStorage = ITabularStorage<typeof AuthorSchema, typeof AuthorPrimaryKeyNames>;
60
+ export type PostStorage = ITabularStorage<typeof PostSchema, typeof PostPrimaryKeyNames>;
61
+ export type JoinFixtureAuthor = FromSchema<typeof AuthorSchema>;
62
+ export type JoinFixturePost = FromSchema<typeof PostSchema>;
63
+ export declare const JOIN_FIXTURE_AUTHORS: JoinFixtureAuthor[];
64
+ export declare const JOIN_FIXTURE_POSTS: JoinFixturePost[];
65
+ /** Loads both fixture tables, right side first so a left read never races it. */
66
+ export declare function seedJoinFixtures(posts: ITabularStorage<typeof PostSchema, typeof PostPrimaryKeyNames>, authors: ITabularStorage<typeof AuthorSchema, typeof AuthorPrimaryKeyNames>): Promise<void>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { AuthorStorage, PostStorage } from "./joinFixtures";
7
+ export { AuthorPrimaryKeyNames, AuthorSchema, JOIN_FIXTURE_AUTHORS, JOIN_FIXTURE_POSTS, PostPrimaryKeyNames, PostSchema, seedJoinFixtures, } from "./joinFixtures";
8
+ export type { AuthorStorage, JoinFixtureAuthor, JoinFixturePost, PostStorage, } from "./joinFixtures";
9
+ export interface JoinTestOptions {
10
+ /**
11
+ * Which path the pair is expected to take. The proof is backend-agnostic:
12
+ * the right storage's `query` is never called on the pushed-down path
13
+ * (`true`) and always called on the hash-join path (`false`). Leave it unset
14
+ * for a wrapper pair — a wrapper hands its inner storage to the join, so
15
+ * the call lands on the inner's `query`, not the wrapper's.
16
+ */
17
+ readonly expectSqlPushdown?: boolean;
18
+ readonly timeout?: number;
19
+ }
20
+ /**
21
+ * Shared join behaviour, run per backend pair. `createPosts` is the left
22
+ * side; `createAuthors` the right. Both are created fresh for every test.
23
+ */
24
+ export declare function runTabularJoinContract(createPosts: () => Promise<PostStorage>, createAuthors: () => Promise<AuthorStorage>, opts?: JoinTestOptions): void;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { TabularStorageContractOpts } from "./types";
7
+ export declare function runTabularStorageContract(opts: TabularStorageContractOpts): void;
8
+ export { VectorItemPrimaryKeyNames, VectorItemSchema } from "./types";
9
+ export type { TabularStorageContractAssertion, TabularStorageContractOpts } from "./types";
@@ -0,0 +1,102 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import type { ITabularStorage } from "@workglow/storage";
7
+ import type { CompoundPrimaryKeyNames, CompoundSchema } from "./fixtures";
8
+ export declare const VectorItemPrimaryKeyNames: readonly ["id"];
9
+ export declare const VectorItemSchema: {
10
+ readonly type: "object";
11
+ readonly properties: {
12
+ readonly id: {
13
+ readonly type: "string";
14
+ };
15
+ readonly embedding: {
16
+ readonly type: "array";
17
+ readonly format: "TypedArray:Float32Array";
18
+ };
19
+ };
20
+ readonly required: readonly ["id", "embedding"];
21
+ readonly additionalProperties: false;
22
+ };
23
+ /**
24
+ * Closed string-literal union of tabular-storage contract assertions that
25
+ * adapters can mark as known failing. A typo in `expectedFailures` becomes
26
+ * a TS error rather than a silently-ignored entry.
27
+ */
28
+ export type TabularStorageContractAssertion = "subscribeToChanges" | "vectorColumnFormat" | "withTransactionRollback" | "withConnectionTransaction" | "countMatchesQuery" | "inListCriterion" | "notInListCriterion" | "joinPushdown" | "guardParity";
29
+ interface TabularStorageContractBaseOpts {
30
+ readonly name: string;
31
+ readonly skip?: boolean;
32
+ readonly timeout?: number;
33
+ readonly createStorage: () => Promise<ITabularStorage<typeof CompoundSchema, typeof CompoundPrimaryKeyNames>>;
34
+ /**
35
+ * Required when capabilities.supportsVectorColumns is true. Creates a fresh
36
+ * storage instance typed to VectorItemSchema for the round-trip assertion.
37
+ */
38
+ readonly createVectorStorage?: () => Promise<ITabularStorage<typeof VectorItemSchema, typeof VectorItemPrimaryKeyNames>>;
39
+ /**
40
+ * Creates a second table on the same connection handle as `primary`.
41
+ * Required for the `withConnectionTransaction` assertion; backends that
42
+ * cannot share a handle (InMemory, FsFolder, IndexedDB, Supabase) omit it
43
+ * and that block is skipped.
44
+ */
45
+ readonly createSiblingStorage?: (primary: ITabularStorage<typeof CompoundSchema, typeof CompoundPrimaryKeyNames>) => Promise<ITabularStorage<typeof CompoundSchema, typeof CompoundPrimaryKeyNames>>;
46
+ /**
47
+ * Releases whatever a factory allocated that the storage itself does not
48
+ * own — typically a connection handle the adapter opened so `createStorage`
49
+ * and `createSiblingStorage` could share one. Called from every `afterEach`
50
+ * after `destroy()`, and passed the same instance the factory returned.
51
+ *
52
+ * Without it an adapter that opens its own handle has nowhere to close it:
53
+ * `destroy()` deliberately leaves a caller-provided handle open, so the
54
+ * handles pile up until the file ends. The parameter is `object` because
55
+ * the hook is identity-keyed — the contract creates storages of two
56
+ * different schema types and a release hook only ever looks its argument up.
57
+ */
58
+ readonly releaseStorage?: (storage: object) => void | Promise<void>;
59
+ /**
60
+ * Names of contract assertions currently broken in this adapter; each
61
+ * named test wraps with `itExpectFail`. The string-literal union catches
62
+ * typos at compile time.
63
+ */
64
+ readonly expectedFailures?: ReadonlyArray<TabularStorageContractAssertion>;
65
+ }
66
+ interface SubscriptionCapableCapabilities {
67
+ readonly supportsSubscriptions: true;
68
+ readonly supportsVectorColumns: boolean;
69
+ readonly supportsTransactions: boolean;
70
+ /** Whether `query(criteria)` is supported. False for FsFolder etc. */
71
+ readonly supportsQuery: boolean;
72
+ }
73
+ interface SubscriptionCapableOpts extends TabularStorageContractBaseOpts {
74
+ readonly capabilities: SubscriptionCapableCapabilities;
75
+ /**
76
+ * Required when supportsSubscriptions is true. Selects between the two
77
+ * subscribeToChanges contract blocks:
78
+ * - false → eventDriven (strict commit order)
79
+ * - true → polling (set equality + count)
80
+ */
81
+ readonly usesPolling: boolean;
82
+ /** Polling interval forwarded to subscribeToChanges for polling-based implementations. */
83
+ readonly pollingIntervalMs?: number;
84
+ }
85
+ interface SubscriptionIncapableCapabilities {
86
+ readonly supportsSubscriptions: false;
87
+ readonly supportsVectorColumns: boolean;
88
+ readonly supportsTransactions: boolean;
89
+ /** Whether `query(criteria)` is supported. False for FsFolder etc. */
90
+ readonly supportsQuery: boolean;
91
+ }
92
+ interface SubscriptionIncapableOpts extends TabularStorageContractBaseOpts {
93
+ readonly capabilities: SubscriptionIncapableCapabilities;
94
+ /**
95
+ * Only meaningful when supportsSubscriptions is true. Permitted (but
96
+ * ignored) on incapable backends to keep wiring ergonomic.
97
+ */
98
+ readonly usesPolling?: boolean;
99
+ readonly pollingIntervalMs?: number;
100
+ }
101
+ export type TabularStorageContractOpts = SubscriptionCapableOpts | SubscriptionIncapableOpts;
102
+ export {};
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Steven Roussey <sroussey@gmail.com>
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Conformance suite for `ITabularStorage` — the behaviour every backend owes a
8
+ * caller, including the two join strategies and the guards that bound them.
9
+ */
10
+ export * from "./tabular-storage/assertions/countMatchesQuery";
11
+ export * from "./tabular-storage/assertions/guardParity";
12
+ export * from "./tabular-storage/assertions/inListCriterion";
13
+ export * from "./tabular-storage/assertions/joinBoundedLeftRead";
14
+ export * from "./tabular-storage/assertions/joinPushdown";
15
+ export * from "./tabular-storage/assertions/notInListCriterion";
16
+ export * from "./tabular-storage/assertions/strategyParity";
17
+ export * from "./tabular-storage/assertions/subscribeToChanges";
18
+ export * from "./tabular-storage/assertions/vectorColumnFormat";
19
+ export * from "./tabular-storage/assertions/withConnectionTransaction";
20
+ export * from "./tabular-storage/assertions/withTransactionRollback";
21
+ export * from "./tabular-storage/fixtures";
22
+ export * from "./tabular-storage/joinFixtures";
23
+ export * from "./tabular-storage/runTabularJoinContract";
24
+ export * from "./tabular-storage/runTabularStorageContract";
25
+ export * from "./tabular-storage/types";