@jam-overture/ loom/ testing/ contracts
The suites that tell you whether your own store, hold store or journal keeps its promises.
Everything below is exported from that import. The names, the signatures and the sentences are read from the package itself rather than written here, so this page says what the copy of Loom in your node_modules says — and it changes in the same pull request the code does.
32 exports, in 12 modules. Generated from ./dist/testing/contracts.d.ts, which is the declaration file this package publishes for @jam-overture/loom/testing/contracts. Each comment inside a declaration is shown as its first paragraph. The whole of it is in that file.
Install these first. @jam-overture/loom/testing/contracts loads them the moment the import runs. Without them, the import itself fails — before any of your own code has run.
drizzle-orm^0.45.2optional peer dependencyvitest^3.0.5optional peer dependency
pnpm add drizzle-orm vitest
No import here has everything behind it. @jam-overture/loom/testing/contracts publishes 32 of the 2,237 names this package publishes. The other 2,205 are behind one of the 19 other imports, and not one of those imports publishes a single name this one does. The imports do not nest: a name that is not on this page is not a name that does not exist, and the search at the top of the page says which import it comes from.
Application contract
testing/application-contract
One suite, run against every ApplicationStore.
applicationFixturefunction
const applicationFixture: (over?: Partial<Application>) => ApplicationdescribeApplicationStoreContractfunction
const describeApplicationStoreContract: (name: string, make: () => Promise<ApplicationStore> | ApplicationStore) => voidAudience overlay contract
testing/audience-overlay-contract
One suite, run against every AudienceOverlayStore.
CONTRACT_TREEvalue
const CONTRACT_TREE: TreeIdaudienceNamedfunction
const audienceNamed: (name: string) => AudienceIdruleForfunction
const ruleFor: (audienceId: AudienceId, key: string, value: string) => AudienceRuleformDeltafunction
A delta that is well-formed and is never applied by this suite — what is under test is custody, not composition, which compose.test.ts covers against the tree it belongs to.
const formDelta: (over?: Partial<TreeDelta>) => TreeDeltadescribeAudienceOverlayStoreContractfunction
const describeAudienceOverlayStoreContract: (name: string, make: () => Promise<AudienceOverlayStore> | AudienceOverlayStore) => voidHold contract
testing/hold-contract
One suite, run against every HoldStore.
heldProposalFixturefunction
A hold against a real tree.
const heldProposalFixture: (options?: { readonly heldAt?: string; readonly treeId?: TreeId; readonly actor?: string; readonly policyFingerprint?: string; }) => HeldProposal
describeHoldStoreContractfunction
const describeHoldStoreContract: (name: string, makeStore: () => HoldStore | Promise<HoldStore>) => voidJournal contract
testing/journal-contract
One suite, run against every TelemetryJournal.
sampleEpisodefunction
A whole episode, narrated: an intent, the proposal it produced, the Gate accepting it, and the change landing. Built through recordOf rather than by hand so the suite exercises the narrowing every host will use.
const sampleEpisode: (namespace?: string) => readonly TelemetryRecord[]describeTelemetryJournalContractfunction
const describeTelemetryJournalContract: (name: string, makeJournal: () => Promise<TelemetryJournal> | TelemetryJournal) => voidModel contract
testing/model-contract
One suite, run against every ModelClient.
ModelSituationtype
What happened, in terms every vendor has rather than one vendor's.
type ModelSituation = /** The service answered, with this text, served by this model. */ "answers" /** The service answered, and there was nothing in the reply that was text. */ | "answers-without-text" /** The answer stopped at the output ceiling, mid-sentence. */ | "truncates" /** The model declined to answer this content. */ | "refuses" /** A credential, entitlement or billing problem: 401, 402, 403. */ | "refuses-the-caller" /** The request itself is wrong and would fail again unchanged: 400, 404, 413, 422. */ | "refuses-the-request" /** Busy now, fine later: 408, 409, 429, 500, 503. */ | "asks-for-later" /** No response at all — a closed socket, a DNS failure, a TLS error. */ | "never-answers";
MODEL_SITUATIONSvalue
const MODEL_SITUATIONS: readonly ModelSituation[]CONTRACT_REPLYvalue
The text this suite sends through, and the model it says served it.
const CONTRACT_REPLY: stringCONTRACT_SERVED_BYvalue
const CONTRACT_SERVED_BY = "a-model-that-served-it"ModelSituationClienttype
A client wired to behave as one situation does, or a statement that this vendor has no such situation.
type ModelSituationClient = (() => ModelClient | Promise<ModelClient>) | "not-expressible";ModelClientContracttype
type ModelClientContract = Readonly<Record<ModelSituation, ModelSituationClient>>;contractRequestfunction
The request every case sends. Fixed, because none of these turn on its content.
const contractRequest: () => ModelRequestdescribeModelClientContractfunction
const describeModelClientContract: (name: string, contract: ModelClientContract) => voidPolicy log contract
testing/policy-log-contract
One suite, run against every PolicyLog.
policyNamedfunction
const policyNamed: (policyId: string, overrides?: Record<string, unknown>) => GatePolicyrecordingOffunction
A recording, with the two fields a caller always has to supply already filled in. actor is required by the type and is spelled out in every fixture rather than defaulted somewhere a test could forget it.
const recordingOf: (policy: GatePolicy, overrides?: Partial<RecordPolicyRequest>) => RecordPolicyRequestdescribePolicyLogContractfunction
const describePolicyLogContract: (name: string, build: () => PolicyLog | Promise<PolicyLog>) => voidProject contract
testing/project-contract
One suite, run against every ProjectStore.
projectFixturefunction
const projectFixture: (over?: Partial<Project>) => ProjectdescribeProjectStoreContractfunction
const describeProjectStoreContract: (name: string, make: () => Promise<ProjectStore> | ProjectStore) => voidReader region contract
testing/reader-region-contract
One suite, run against every ReaderRegionStore.
describeReaderRegionStoreContractfunction
Hand it a name and a maker. A store that has never been told anything is expected to answer an empty list rather than to fail, so a fresh deployment is not a broken one.
const describeReaderRegionStoreContract: (name: string, make: () => ReaderRegionStore | Promise<ReaderRegionStore>) => voidReader signal journal contract
testing/reader-signal-journal-contract
One suite, run against every ReaderSignalJournal.
describeReaderSignalJournalContractfunction
Hand it a name and a maker and it runs the whole contract against what the maker returns, once per case, so a failure names the property rather than the call that tripped over it.
const describeReaderSignalJournalContract: (name: string, make: () => ReaderSignalJournal | Promise<ReaderSignalJournal>) => voidReader tally contract
testing/reader-tally-contract
One suite, run against every ReaderTallyStore.
describeReaderTallyStoreContractfunction
Hand it a name and a maker. Every case starts from a store the maker has just built, so an applied delivery never leaks into the case after it — which is the one way a store with broken idempotence passes.
const describeReaderTallyStoreContract: (name: string, make: () => ReaderTallyStore | Promise<ReaderTallyStore>) => voidRow security
testing/row-security
Asking Postgres whether a table really is protected.
rowSecurityOnfunction
Whether Postgres has row level security on a table, read from the catalogue rather than inferred from having run the statement.
Shown in use on Testing what you built — Does your own store keep its promises?
const rowSecurityOn: (db: LoomDatabase, table: string) => Promise<boolean>Store contract
testing/store-contract
One suite, run against every TreeStore.
appendOffunction
const appendOf: (delta: TreeDelta, proposal?: string, /** * When the runtime applied it. Defaulted, because almost every case here is * about what a store does with a delta rather than when; named by the cases * that are, which cannot be written at all if every append shares one stamp. */ appliedAt?: string) => AppendRequest
removalOffunction
const removalOf: (tree: LoomTree, nodeId: string, baseRevision?: number) => TreeDeltatreeNamedfunction
const treeNamed: (namespace: string) => LoomTreedescribeTreeStoreContractfunction
makeStore returns a store with nothing in it. Each test gets its own, so the suite never depends on the order it runs in.
Shown in use on Testing what you built — Does your own store keep its promises?
const describeTreeStoreContract: (name: string, makeStore: () => Promise<TreeStore> | TreeStore) => void