@ultimat3/testing 30.9.0 → 31.0.0
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/CLAUDE.md +46 -55
- package/README.md +179 -39
- package/package.json +23 -17
- package/src/ai-conformance-answer.ts +67 -0
- package/src/ai-gateway-conformance.ts +105 -0
- package/src/ai-provider-conformance.ts +69 -0
- package/src/ai-provider-transport-conformance.ts +170 -0
- package/src/audit-sink-conformance.ts +204 -0
- package/src/auth-adapter-conformance-credentials.ts +124 -0
- package/src/auth-adapter-conformance-mfa.ts +70 -0
- package/src/auth-adapter-conformance-passkeys.ts +133 -0
- package/src/auth-adapter-conformance-sessions.ts +115 -0
- package/src/auth-adapter-conformance-support.ts +71 -0
- package/src/auth-adapter-conformance-users.ts +128 -0
- package/src/auth-adapter-conformance.ts +34 -0
- package/src/auth-limiter-factory-conformance.ts +224 -0
- package/src/auth-server-store-conformance-records.ts +69 -0
- package/src/auth-server-store-conformance.ts +208 -0
- package/src/cache-tier-conformance-checks.ts +142 -0
- package/src/cache-tier-conformance.ts +24 -0
- package/src/cassette-format.ts +8 -13
- package/src/cassette-record.ts +1 -1
- package/src/cdp-browser.ts +10 -11
- package/src/cdp-e2e-page.ts +2 -2
- package/src/cdp-e2e-session.ts +2 -2
- package/src/cdp-network-probe.ts +1 -1
- package/src/cdp-offline-script.ts +2 -2
- package/src/clock-conformance.ts +126 -0
- package/src/conformance.ts +239 -0
- package/src/e2e-browser-handle.ts +1 -2
- package/src/e2e-error-codes.ts +17 -16
- package/src/e2e-run.ts +4 -3
- package/src/embedder-conformance.ts +101 -0
- package/src/entity-conformance-aggregates.ts +210 -0
- package/src/entity-conformance-batches.ts +216 -0
- package/src/entity-conformance-bulk.ts +379 -0
- package/src/entity-conformance-checks.ts +27 -0
- package/src/entity-conformance-entities.ts +52 -0
- package/src/entity-conformance-locks.ts +286 -0
- package/src/entity-conformance-matrix.ts +397 -0
- package/src/entity-conformance-reads.ts +241 -0
- package/src/entity-conformance-support.ts +56 -0
- package/src/entity-conformance-tenancy.ts +296 -0
- package/src/entity-conformance-values.ts +305 -0
- package/src/entity-conformance-versions.ts +60 -0
- package/src/entity-conformance-writes.ts +348 -0
- package/src/entity-driver-conformance.ts +103 -0
- package/src/error-groups-store-conformance.ts +198 -0
- package/src/error-reporter-conformance.ts +119 -0
- package/src/errors.ts +20 -2
- package/src/event-bus-conformance.ts +161 -0
- package/src/exercise-drift-hint.ts +4 -1
- package/src/exercise-judge.ts +5 -3
- package/src/exercise-override-line.ts +98 -0
- package/src/exercise-report.ts +30 -51
- package/src/exercise.ts +12 -6
- package/src/factories.ts +192 -179
- package/src/factory-api.ts +131 -0
- package/src/factory-associations.ts +67 -0
- package/src/factory-errors.ts +38 -0
- package/src/factory-lint.ts +92 -0
- package/src/factory-persist.ts +74 -16
- package/src/factory-pipeline.ts +191 -0
- package/src/factory-registry.ts +2 -1
- package/src/factory-types.ts +131 -0
- package/src/failure-store-conformance.ts +137 -0
- package/src/fixture-jobs.ts +27 -11
- package/src/fixture-mail.ts +7 -7
- package/src/fixture-seed.ts +111 -0
- package/src/fixture-statements.ts +68 -52
- package/src/framework-fixtures.ts +1 -1
- package/src/idempotency-store-conformance.ts +186 -0
- package/src/idempotency-store-replay-conformance.ts +140 -0
- package/src/idempotency-store-tx-conformance.ts +132 -0
- package/src/idempotency-store-world-conformance.ts +82 -0
- package/src/identity-provider-conformance.ts +144 -0
- package/src/image-transform-conformance.ts +89 -0
- package/src/index.ts +68 -157
- package/src/isr-store-conformance.ts +113 -0
- package/src/job-sim-effects.ts +19 -31
- package/src/job-sim-world.ts +6 -15
- package/src/lease-store-conformance.ts +195 -0
- package/src/mail-driver-conformance.ts +108 -0
- package/src/matcher-doubles.ts +104 -0
- package/src/matcher-stub.ts +78 -0
- package/src/matcher-surface.ts +21 -0
- package/src/matchers.ts +19 -1
- package/src/mcp-confirmation-store-conformance.ts +262 -0
- package/src/meter-store-conformance.ts +135 -0
- package/src/notify-digest-conformance.ts +133 -0
- package/src/notify-inbox-conformance.ts +130 -0
- package/src/notify-ledger-conformance.ts +134 -0
- package/src/notify-preference-conformance.ts +49 -0
- package/src/notify-stores-conformance.ts +73 -0
- package/src/outbox-store-conformance-claims.ts +112 -0
- package/src/outbox-store-conformance-subject.ts +65 -0
- package/src/outbox-store-conformance.ts +71 -0
- package/src/per-test-reset.ts +55 -20
- package/src/preload.ts +4 -2
- package/src/purge-conformance.ts +79 -0
- package/src/push-device-conformance.ts +124 -0
- package/src/push-subscription-conformance.ts +123 -0
- package/src/quiet-logs.ts +4 -4
- package/src/rate-limit-store-conformance.ts +178 -0
- package/src/registry-leak-error.ts +8 -1
- package/src/scrape-driver-conformance-frame-checks.ts +97 -0
- package/src/scrape-driver-conformance-page-checks.ts +114 -0
- package/src/scrape-driver-conformance-site.ts +84 -0
- package/src/scrape-driver-conformance.ts +34 -0
- package/src/search-index-conformance-list.ts +76 -0
- package/src/search-index-conformance-support.ts +69 -0
- package/src/search-index-conformance-versions.ts +66 -0
- package/src/search-index-conformance.ts +126 -0
- package/src/secret-source-conformance.ts +91 -0
- package/src/seed-factories.ts +57 -0
- package/src/seed-writer.ts +8 -19
- package/src/semantic-cache-factory-conformance.ts +86 -0
- package/src/sms-transport-conformance.ts +102 -0
- package/src/step-store-conformance.ts +171 -0
- package/src/storage-conformance-read-checks.ts +132 -0
- package/src/storage-conformance-shape.ts +121 -0
- package/src/storage-conformance-stream-checks.ts +226 -0
- package/src/storage-conformance.ts +34 -0
- package/src/stub-action.ts +24 -0
- package/src/stub-errors.ts +86 -0
- package/src/stub-job.ts +30 -0
- package/src/stub-query.ts +25 -0
- package/src/stub-script.ts +76 -0
- package/src/stub-stack.ts +29 -0
- package/src/stub.ts +73 -0
- package/src/swap-adapter.ts +135 -0
- package/src/test-scope.ts +96 -0
- package/src/test-types.ts +1 -1
- package/src/totp-replay-guard-conformance.ts +76 -0
- package/src/transport-conformance.ts +179 -0
- package/src/upload-scanner-conformance.ts +112 -0
- package/src/vector-store-conformance-checks.ts +174 -0
- package/src/vector-store-conformance.ts +21 -0
- package/src/cdp-connection.ts +0 -291
- package/src/cdp-errors.ts +0 -179
- package/src/cdp-launch-attempt.ts +0 -224
- package/src/cdp-launch-candidates.ts +0 -62
- package/src/cdp-launch-profile.ts +0 -106
- package/src/cdp-launch-reap.ts +0 -68
- package/src/cdp-launch-wire.ts +0 -171
- package/src/cdp-launch.ts +0 -175
- package/src/cdp-pipe.ts +0 -77
- package/src/cdp-wire-watch.ts +0 -113
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
// The `errorReporter` port's contract as shared examples: `behavesLike(errorReporterConformance,
|
|
2
|
+
// () => ({ reporter, delivered }))`. `report()` runs inside every failure path's catch, so it may
|
|
3
|
+
// not throw, may not make the caller wait, and — unless it is a marked local sink — may not carry a
|
|
4
|
+
// secret off the box. `delivered()` is the text each report left as (an envelope, a row, a line).
|
|
5
|
+
|
|
6
|
+
import { expect, test } from 'bun:test';
|
|
7
|
+
import type { ErrorReport } from '@ultimat3/core';
|
|
8
|
+
import { errorReport, isLocalErrorSink, UltimateError } from '@ultimat3/core';
|
|
9
|
+
import type { ErrorReporter } from '@ultimat3/core/adapter';
|
|
10
|
+
import type { SharedExamples } from './shared-examples';
|
|
11
|
+
import { sharedExamples } from './shared-examples';
|
|
12
|
+
|
|
13
|
+
export interface ErrorReporterSubject {
|
|
14
|
+
readonly reporter: ErrorReporter;
|
|
15
|
+
/** What left the reporter so far, one string per delivered report, in order. */
|
|
16
|
+
delivered(): readonly string[];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface ErrorReporterCheck {
|
|
20
|
+
readonly name: string;
|
|
21
|
+
run(subject: ErrorReporterSubject): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const SECRET = 'hunter2-conformance-secret';
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* The registered code every conformance report carries — a suite invents no code of its own — so
|
|
28
|
+
* one report is told from another by its `cause`, which names `label`.
|
|
29
|
+
*/
|
|
30
|
+
const CODE = 'X_INVARIANT';
|
|
31
|
+
/** A runnable fix, opening with the command: what whoever is paged pastes. */
|
|
32
|
+
const FIX = 'bun test ./packages/testing/src/error-reporter-conformance.test.ts';
|
|
33
|
+
|
|
34
|
+
const causeOf = (label: string): string => `${label} happened during the conformance run`;
|
|
35
|
+
|
|
36
|
+
/** A report built the way `reportError` builds one, for a coded failure labelled `label`. */
|
|
37
|
+
export function conformanceReport(
|
|
38
|
+
label: string,
|
|
39
|
+
meta: Readonly<Record<string, unknown>> = {},
|
|
40
|
+
extra: Readonly<Record<string, unknown>> = {},
|
|
41
|
+
): ErrorReport {
|
|
42
|
+
const error = new UltimateError({
|
|
43
|
+
code: CODE,
|
|
44
|
+
cause: causeOf(label),
|
|
45
|
+
fix: FIX,
|
|
46
|
+
meta,
|
|
47
|
+
});
|
|
48
|
+
return errorReport(error, { source: 'http', scope: { operation: 'GET /orders', extra } });
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** A `meta` no naive serialiser survives: a bigint, a cycle, and a getter that throws. */
|
|
52
|
+
function hostileMeta(): Record<string, unknown> {
|
|
53
|
+
const cycle: Record<string, unknown> = { name: 'cycle' };
|
|
54
|
+
cycle['self'] = cycle;
|
|
55
|
+
const meta: Record<string, unknown> = { big: 10n ** 30n, cycle };
|
|
56
|
+
Object.defineProperty(meta, 'exploding', {
|
|
57
|
+
enumerable: true,
|
|
58
|
+
// A lazily parsed field whose source is corrupt: the throw a real getter makes.
|
|
59
|
+
get: (): unknown => JSON.parse('{ not json'),
|
|
60
|
+
});
|
|
61
|
+
return meta;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const ERROR_REPORTER_CHECKS: readonly ErrorReporterCheck[] = [
|
|
65
|
+
{
|
|
66
|
+
name: 'report() answers nothing, synchronously: the caller never waits on the monitor',
|
|
67
|
+
async run({ reporter }) {
|
|
68
|
+
const answered: unknown = reporter.report(conformanceReport('sync'));
|
|
69
|
+
expect(answered).toBeUndefined();
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'every report is delivered once, carrying its code, cause and runnable fix',
|
|
74
|
+
async run({ reporter, delivered }) {
|
|
75
|
+
const before = delivered().length;
|
|
76
|
+
reporter.report(conformanceReport('first'));
|
|
77
|
+
reporter.report(conformanceReport('second'));
|
|
78
|
+
const sent = delivered().slice(before);
|
|
79
|
+
expect(sent).toHaveLength(2);
|
|
80
|
+
for (const [text, label] of [
|
|
81
|
+
[sent[0] ?? '', 'first'],
|
|
82
|
+
[sent[1] ?? '', 'second'],
|
|
83
|
+
] as const) {
|
|
84
|
+
expect(text).toContain(CODE);
|
|
85
|
+
expect(text).toContain(causeOf(label));
|
|
86
|
+
expect(text).toContain(FIX);
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
name: 'a meta holding a bigint, a cycle and a throwing getter never throws into the caller',
|
|
92
|
+
async run({ reporter }) {
|
|
93
|
+
const report = conformanceReport('hostile', hostileMeta());
|
|
94
|
+
expect(() => reporter.report(report)).not.toThrow();
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: 'a reporter that is not a marked local sink carries no secret off the box',
|
|
99
|
+
async run({ reporter, delivered }) {
|
|
100
|
+
const before = delivered().length;
|
|
101
|
+
reporter.report(conformanceReport('secret', { password: SECRET }, { token: SECRET }));
|
|
102
|
+
const sent = delivered().slice(before).join('\n');
|
|
103
|
+
expect(sent).toContain(causeOf('secret'));
|
|
104
|
+
// A local sink keeps the report on the box, whole — what it holds is the process's own.
|
|
105
|
+
if (!isLocalErrorSink(reporter)) expect(sent).not.toContain(SECRET);
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
];
|
|
109
|
+
|
|
110
|
+
export const errorReporterConformance: SharedExamples<ErrorReporterSubject> = sharedExamples(
|
|
111
|
+
'an error reporter',
|
|
112
|
+
(subject) => {
|
|
113
|
+
for (const check of ERROR_REPORTER_CHECKS) {
|
|
114
|
+
test(check.name, async () => {
|
|
115
|
+
await check.run(subject());
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
);
|
package/src/errors.ts
CHANGED
|
@@ -68,6 +68,14 @@ export const TESTING_ERROR_CODES = [
|
|
|
68
68
|
'X_JOB_CRASH_UNBOUNDED',
|
|
69
69
|
'X_EXERCISE_ACTOR_USER_UNSEATED',
|
|
70
70
|
'X_EXERCISE_INPUT_THREW',
|
|
71
|
+
'X_TEST_SCOPE_UNINSTALLED',
|
|
72
|
+
'X_TEST_STUB_UNANSWERED',
|
|
73
|
+
'X_TEST_STUB_TARGET_UNSUPPORTED',
|
|
74
|
+
'X_TEST_EXPECTED_INPUT_INVALID',
|
|
75
|
+
'X_TEST_RUN_JOBS_EXPECTED',
|
|
76
|
+
'X_TEST_MAIL_EXPECTED',
|
|
77
|
+
'X_TEST_ADAPTER_PORT_UNSWAPPABLE',
|
|
78
|
+
'X_TEST_FACTORY_INVALID',
|
|
71
79
|
] as const;
|
|
72
80
|
|
|
73
81
|
export type TestingErrorCode = (typeof TESTING_ERROR_CODES)[number];
|
|
@@ -136,6 +144,16 @@ export const TESTING_ERROR_TITLES: Readonly<Record<TestingErrorCode, string>> =
|
|
|
136
144
|
X_JOB_CRASH_UNBOUNDED: 'a crash proof needs more kill points than its bound',
|
|
137
145
|
X_EXERCISE_ACTOR_USER_UNSEATED: "the exercise pass could not seat its actor's x_users row",
|
|
138
146
|
X_EXERCISE_INPUT_THREW: "an exercise entry's input threw",
|
|
147
|
+
X_TEST_SCOPE_UNINSTALLED:
|
|
148
|
+
'a test double was made in a process the testing preload did not set up',
|
|
149
|
+
X_TEST_STUB_UNANSWERED: 'a stubbed primitive was called before any answer was scripted',
|
|
150
|
+
X_TEST_STUB_TARGET_UNSUPPORTED:
|
|
151
|
+
'stub() was handed something that is not an action, llm(), query or job',
|
|
152
|
+
X_TEST_EXPECTED_INPUT_INVALID: "an assertion named an input its primitive's schema rejects",
|
|
153
|
+
X_TEST_RUN_JOBS_EXPECTED: 'toHaveEnqueued was handed something other than the runJobs fixture',
|
|
154
|
+
X_TEST_MAIL_EXPECTED: 'toHaveSentMail was handed something other than the mail fixture',
|
|
155
|
+
X_TEST_ADAPTER_PORT_UNSWAPPABLE: 'swapAdapter() was named a port it cannot swap for one test',
|
|
156
|
+
X_TEST_FACTORY_INVALID: 'a factory builds a row its own entity refuses',
|
|
139
157
|
};
|
|
140
158
|
|
|
141
159
|
// Titles must be registered for `format()` to render the contract's first line. Every code above is
|
|
@@ -409,8 +427,8 @@ export class FactoryNotPersistedError extends UltimateError {
|
|
|
409
427
|
constructor(input: { table: string }) {
|
|
410
428
|
super({
|
|
411
429
|
code: 'X_TEST_FACTORY_NOT_PERSISTED',
|
|
412
|
-
cause: `factory "${input.table}".create()
|
|
413
|
-
fix: '
|
|
430
|
+
cause: `factory "${input.table}".create() has nowhere to write: no persister is installed and its entity is not an entity() value, so it has no repository`,
|
|
431
|
+
fix: 'defineFactory(<the entity() value>, …) — create() then writes through its repository — or usePersister(entityPersister({ driver })) in the test preload, or build() for an in-memory row',
|
|
414
432
|
});
|
|
415
433
|
}
|
|
416
434
|
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// The `EventBus` contract of `@ultimat3/jobs` as shared examples: `behavesLike(eventBusConformance,
|
|
2
|
+
// () => ({ bus, elapse }))`. `find` answers earliest first in `(publishedAt, id)` order, compares a
|
|
3
|
+
// cursor and never looks it up, and never finds an expired event. Time passes through `elapse`
|
|
4
|
+
// (a frozen clock advances, a database ages its rows), never the wall clock.
|
|
5
|
+
|
|
6
|
+
import { expect, test } from 'bun:test';
|
|
7
|
+
import type { EventBus, JobEvent } from '@ultimat3/jobs';
|
|
8
|
+
import type { SharedExamples } from './shared-examples';
|
|
9
|
+
import { sharedExamples } from './shared-examples';
|
|
10
|
+
|
|
11
|
+
export interface EventBusSubject {
|
|
12
|
+
readonly bus: EventBus;
|
|
13
|
+
/** Let `ms` pass for every event: `clock.advance`, or both stamps moved back by `ms`. */
|
|
14
|
+
readonly elapse: (ms: number) => void | Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface EventBusCheck {
|
|
18
|
+
readonly name: string;
|
|
19
|
+
run(subject: EventBusSubject): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const HOUR_MS = 3_600_000;
|
|
23
|
+
const SHORT_TTL_MS = 5_000;
|
|
24
|
+
const PAST_SHORT_TTL_MS = 10_000;
|
|
25
|
+
/** Published back to back: on a frozen clock one millisecond, on a database a few. */
|
|
26
|
+
const BURST = 8;
|
|
27
|
+
|
|
28
|
+
let minted = 0;
|
|
29
|
+
/** An event name of this check's own, so checks sharing one table never find each other's. */
|
|
30
|
+
const nameOf = (): string => {
|
|
31
|
+
minted += 1;
|
|
32
|
+
return `conformance.event-${process.pid.toString(36)}-${minted.toString(36)}`;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const elapse = async (subject: EventBusSubject, ms: number): Promise<void> => {
|
|
36
|
+
await subject.elapse(ms);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const order = (a: JobEvent, b: JobEvent): number =>
|
|
40
|
+
a.publishedAt === b.publishedAt ? (a.id < b.id ? -1 : 1) : a.publishedAt - b.publishedAt;
|
|
41
|
+
|
|
42
|
+
export const EVENT_BUS_CHECKS: readonly EventBusCheck[] = [
|
|
43
|
+
{
|
|
44
|
+
name: 'publish answers the event it stored, stamped on the bus clock with its ttl',
|
|
45
|
+
async run({ bus }) {
|
|
46
|
+
const name = nameOf();
|
|
47
|
+
const before = await bus.now();
|
|
48
|
+
const event = await bus.publish(name, { n: 1 }, { correlationKey: 'k', ttl: HOUR_MS });
|
|
49
|
+
expect([event.name, event.payload, event.correlationKey]).toEqual([name, { n: 1 }, 'k']);
|
|
50
|
+
expect(event.publishedAt).toBeGreaterThanOrEqual(before);
|
|
51
|
+
// The expiry may keep sub-millisecond precision the stamp drops: never less than the ttl.
|
|
52
|
+
expect(event.expiresAt - event.publishedAt).toBeGreaterThanOrEqual(HOUR_MS);
|
|
53
|
+
expect(event.expiresAt - event.publishedAt).toBeLessThanOrEqual(HOUR_MS + 1);
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
name: 'find matches the name and the correlation key, and answers the payload',
|
|
58
|
+
async run({ bus }) {
|
|
59
|
+
const [name, other] = [nameOf(), nameOf()];
|
|
60
|
+
const floor = await bus.now();
|
|
61
|
+
await bus.publish(other, { wrong: 'name' });
|
|
62
|
+
const paid = await bus.publish(name, { order: 1 }, { correlationKey: 'order-1' });
|
|
63
|
+
expect(await bus.find(name, 'order-2', floor)).toBeUndefined();
|
|
64
|
+
const hit = await bus.find(name, 'order-1', floor);
|
|
65
|
+
expect([hit?.id, hit?.payload, hit?.publishedAt]).toEqual([
|
|
66
|
+
paid.id,
|
|
67
|
+
{ order: 1 },
|
|
68
|
+
paid.publishedAt,
|
|
69
|
+
]);
|
|
70
|
+
expect((await bus.find(name, undefined, floor))?.id).toBe(paid.id);
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
name: 'a cursor walks every event once, earliest first in (publishedAt, id) order',
|
|
75
|
+
async run({ bus }) {
|
|
76
|
+
const name = nameOf();
|
|
77
|
+
const floor = await bus.now();
|
|
78
|
+
const published: JobEvent[] = [];
|
|
79
|
+
for (let n = 0; n < BURST; n += 1) published.push(await bus.publish(name, { n }));
|
|
80
|
+
const expected = [...published].sort(order).map((each) => each.id);
|
|
81
|
+
const walked: string[] = [];
|
|
82
|
+
let hit = await bus.find(name, undefined, floor);
|
|
83
|
+
while (hit !== undefined && walked.length <= BURST) {
|
|
84
|
+
walked.push(hit.id);
|
|
85
|
+
hit = await bus.find(name, undefined, hit.publishedAt, hit.id);
|
|
86
|
+
}
|
|
87
|
+
expect(walked).toEqual(expected);
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
// It was looked up: a cursor whose event had been purged excluded nothing, and an event of its
|
|
92
|
+
// millisecond that came before it was handed to the wait again.
|
|
93
|
+
name: 'a cursor whose event was purged still excludes what came before it',
|
|
94
|
+
async run(subject) {
|
|
95
|
+
const { bus } = subject;
|
|
96
|
+
const name = nameOf();
|
|
97
|
+
const before = await bus.publish(name, { n: 'before' }, { ttl: HOUR_MS });
|
|
98
|
+
const cursor = await bus.publish(name, { n: 'cursor' }, { ttl: SHORT_TTL_MS });
|
|
99
|
+
expect(order(before, cursor)).toBeLessThan(0);
|
|
100
|
+
await elapse(subject, PAST_SHORT_TTL_MS);
|
|
101
|
+
expect(await bus.purgeExpired()).toBeGreaterThanOrEqual(1);
|
|
102
|
+
expect(await bus.find(name, undefined, cursor.publishedAt, cursor.id)).toBeUndefined();
|
|
103
|
+
const after = await bus.publish(name, { n: 'after' }, { ttl: HOUR_MS });
|
|
104
|
+
expect((await bus.find(name, undefined, cursor.publishedAt, cursor.id))?.id).toBe(after.id);
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
name: 'an expired event is never found, and purgeExpired deletes it',
|
|
109
|
+
async run(subject) {
|
|
110
|
+
const { bus } = subject;
|
|
111
|
+
const name = nameOf();
|
|
112
|
+
const floor = await bus.now();
|
|
113
|
+
const brief = await bus.publish(name, {}, { ttl: SHORT_TTL_MS });
|
|
114
|
+
expect((await bus.find(name, undefined, floor))?.id).toBe(brief.id);
|
|
115
|
+
await elapse(subject, PAST_SHORT_TTL_MS);
|
|
116
|
+
expect(await bus.find(name, undefined, floor)).toBeUndefined();
|
|
117
|
+
expect(await bus.purgeExpired()).toBeGreaterThanOrEqual(1);
|
|
118
|
+
expect((await bus.list(name)).map((each) => each.id)).not.toContain(brief.id);
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'since skips a refused event and anything stamped before the wait began',
|
|
123
|
+
async run(subject) {
|
|
124
|
+
const { bus } = subject;
|
|
125
|
+
const name = nameOf();
|
|
126
|
+
const early = await bus.publish(name, { n: 'early' });
|
|
127
|
+
await elapse(subject, 1_000);
|
|
128
|
+
const at = await bus.now();
|
|
129
|
+
const refused = await bus.publish(name, { n: 'refused' });
|
|
130
|
+
const wanted = await bus.publish(name, { n: 'wanted' });
|
|
131
|
+
const since = { at, refused: [refused.id] };
|
|
132
|
+
// A cursor at the epoch reaches back past `early`; only the wait's own line excludes it.
|
|
133
|
+
expect((await bus.find(name, undefined, 0))?.id).toBe(early.id);
|
|
134
|
+
expect((await bus.find(name, undefined, 0, undefined, undefined, since))?.id).toBe(wanted.id);
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
name: 'list(name) holds that name alone, in publish order',
|
|
139
|
+
async run({ bus }) {
|
|
140
|
+
const [name, other] = [nameOf(), nameOf()];
|
|
141
|
+
const first = await bus.publish(name, { n: 1 });
|
|
142
|
+
await bus.publish(other, { n: 2 });
|
|
143
|
+
const second = await bus.publish(name, { n: 3 });
|
|
144
|
+
const listed = await bus.list(name);
|
|
145
|
+
expect(listed.map((each) => each.id).sort()).toEqual([first.id, second.id].sort());
|
|
146
|
+
expect(listed.every((each) => each.name === name)).toBe(true);
|
|
147
|
+
expect(listed.map((each) => each.publishedAt)).toEqual(
|
|
148
|
+
listed.map((each) => each.publishedAt).sort((a, b) => a - b),
|
|
149
|
+
);
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
export const eventBusConformance: SharedExamples<EventBusSubject | Promise<EventBusSubject>> =
|
|
155
|
+
sharedExamples('an event bus', (subject) => {
|
|
156
|
+
for (const check of EVENT_BUS_CHECKS) {
|
|
157
|
+
test(check.name, async () => {
|
|
158
|
+
await check.run(await subject());
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { renderDrawnInput, renderExerciseKey, sampleGapBinding } from '@ultimat3/core';
|
|
6
6
|
import type { StandardSchemaV1 } from '@ultimat3/schema';
|
|
7
7
|
import type { Sampler } from './exercise-input';
|
|
8
|
+
import { UNBOUND_ID } from './exercise-override-line';
|
|
8
9
|
|
|
9
10
|
/** `idFields` are the input's id-shaped keys: each wants a real row's id, as the other hints say. */
|
|
10
11
|
export function driftOverrideLine(
|
|
@@ -12,13 +13,15 @@ export function driftOverrideLine(
|
|
|
12
13
|
schema: StandardSchemaV1,
|
|
13
14
|
sampler: Sampler,
|
|
14
15
|
idFields: readonly string[],
|
|
16
|
+
/** Each id field's seeded value, where the pass bound one: the line binds that row. */
|
|
17
|
+
ids: Readonly<Record<string, string>> = {},
|
|
15
18
|
): string {
|
|
16
19
|
const gaps = sampler.sampleGaps(schema);
|
|
17
20
|
const bindings = [
|
|
18
21
|
...gaps.map((path) => sampleGapBinding(path, sampler.describeSampleGap(schema, path))),
|
|
19
22
|
...idFields
|
|
20
23
|
.filter((field) => !gaps.includes(field))
|
|
21
|
-
.map((field) => ({ path: field, placeholder:
|
|
24
|
+
.map((field) => ({ path: field, placeholder: ids[field] ?? UNBOUND_ID })),
|
|
22
25
|
];
|
|
23
26
|
const input =
|
|
24
27
|
bindings.length === 0
|
package/src/exercise-judge.ts
CHANGED
|
@@ -8,8 +8,8 @@ import { exerciseEntryKey } from './define-exercise';
|
|
|
8
8
|
import { driftOverrideLine } from './exercise-drift-hint';
|
|
9
9
|
import type { Sampler } from './exercise-input';
|
|
10
10
|
import { idStem } from './exercise-input';
|
|
11
|
+
import { type OverrideHint, overrideLine } from './exercise-override-line';
|
|
11
12
|
import type { Observed } from './exercise-report';
|
|
12
|
-
import { overrideLine } from './exercise-report';
|
|
13
13
|
import type { Subject } from './exercise-subjects';
|
|
14
14
|
|
|
15
15
|
/**
|
|
@@ -38,6 +38,8 @@ export interface Run {
|
|
|
38
38
|
readonly answered: boolean;
|
|
39
39
|
readonly lastError: unknown;
|
|
40
40
|
readonly lastInput: unknown;
|
|
41
|
+
/** Who the pass ran as and the rows it bound: what makes the paste line exact. */
|
|
42
|
+
readonly hint?: OverrideHint | undefined;
|
|
41
43
|
}
|
|
42
44
|
|
|
43
45
|
export function judged(
|
|
@@ -55,7 +57,7 @@ export function judged(
|
|
|
55
57
|
outcome: 'unreached' as const,
|
|
56
58
|
...(code === undefined ? {} : { code }),
|
|
57
59
|
reason,
|
|
58
|
-
override: overrideLine(key, idFields(run.lastInput)),
|
|
60
|
+
override: overrideLine(key, idFields(run.lastInput), run.hint),
|
|
59
61
|
});
|
|
60
62
|
if (observed.refusedHosts.length > 0) {
|
|
61
63
|
// A call out is a refusal whatever the handler made of it: sealed, so never sent.
|
|
@@ -68,7 +70,7 @@ export function judged(
|
|
|
68
70
|
const fields = idFields(run.lastInput);
|
|
69
71
|
return {
|
|
70
72
|
...unreached('X_CONTRACT_DRIFT', 'its input schema refused every generated value'),
|
|
71
|
-
override: driftOverrideLine(key, subject.input, sampler, fields),
|
|
73
|
+
override: driftOverrideLine(key, subject.input, sampler, fields, run.hint?.ids),
|
|
72
74
|
};
|
|
73
75
|
}
|
|
74
76
|
if (run.verdict.kind === 'defect') {
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// The entry an unreached primitive's record says to paste into `exercise.ts`: valid TS, naming
|
|
2
|
+
// exactly what the pass ran with — the actor's grants and each id field's seeded row — so pasting
|
|
3
|
+
// it compiles, and the author edits a working line instead of filling `<…>` holes in a broken one.
|
|
4
|
+
|
|
5
|
+
import type { Actor } from '@ultimat3/core';
|
|
6
|
+
import { renderExerciseKey } from '@ultimat3/core';
|
|
7
|
+
import type { ExerciseOverride } from './define-exercise';
|
|
8
|
+
import type { IdLookup } from './exercise-input';
|
|
9
|
+
|
|
10
|
+
/** The actor the pass ran as, by its grants: `testActor(name, { roles, permissions }).actor`. */
|
|
11
|
+
export interface OverrideActor {
|
|
12
|
+
readonly name: string;
|
|
13
|
+
readonly roles: readonly string[];
|
|
14
|
+
readonly permissions: readonly string[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface OverrideHint {
|
|
18
|
+
/**
|
|
19
|
+
* `null`: the pass ran signed out (or as a job's worker) — `actor: null`. Absent: the entry
|
|
20
|
+
* already declares its actor, or the pass's pick cannot be spelled; the line leaves `actor` out
|
|
21
|
+
* and the pass picks as it did.
|
|
22
|
+
*/
|
|
23
|
+
readonly actor?: OverrideActor | null | undefined;
|
|
24
|
+
/** Each id field's value where the pass bound it to a seeded row: the line binds that row. */
|
|
25
|
+
readonly ids?: Readonly<Record<string, string>> | undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** What an id field the pass could not bind is left as: a string, so the line still compiles. */
|
|
29
|
+
export const UNBOUND_ID = '<a real id>';
|
|
30
|
+
|
|
31
|
+
/** A string literal by `JSON.stringify`: a newline, a quote, a backslash each escaped right. */
|
|
32
|
+
const quoted = (text: string): string => JSON.stringify(text);
|
|
33
|
+
const list = (items: readonly string[]): string => `[${items.map(quoted).join(', ')}]`;
|
|
34
|
+
|
|
35
|
+
function actorSource(actor: OverrideActor): string {
|
|
36
|
+
const init = [
|
|
37
|
+
...(actor.roles.length === 0 ? [] : [`roles: ${list(actor.roles)}`]),
|
|
38
|
+
...(actor.permissions.length === 0 ? [] : [`permissions: ${list(actor.permissions)}`]),
|
|
39
|
+
];
|
|
40
|
+
const second = init.length === 0 ? '' : `, { ${init.join(', ')} }`;
|
|
41
|
+
return `testActor(${quoted(actor.name)}${second}).actor`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* `publishPost: { actor: testActor("editor", { roles: ["editor"] }).actor, input: (drawn) => ({
|
|
46
|
+
* ...drawn, postId: "<seeded id>" }) }, // testActor: @ultimat3/policy` — the trailing comment is
|
|
47
|
+
* the one import the line needs, there only when the line uses it.
|
|
48
|
+
*/
|
|
49
|
+
export function overrideLine(
|
|
50
|
+
name: string,
|
|
51
|
+
idFields: readonly string[],
|
|
52
|
+
hint: OverrideHint = {},
|
|
53
|
+
): string {
|
|
54
|
+
const bound = idFields
|
|
55
|
+
.map((field) => `, ${renderExerciseKey(field)}: ${quoted(hint.ids?.[field] ?? UNBOUND_ID)}`)
|
|
56
|
+
.join('');
|
|
57
|
+
const actor =
|
|
58
|
+
hint.actor === undefined
|
|
59
|
+
? ''
|
|
60
|
+
: `actor: ${hint.actor === null ? 'null' : actorSource(hint.actor)}, `;
|
|
61
|
+
const line = `${renderExerciseKey(name)}: { ${actor}input: (drawn) => ({ ...drawn${bound} }) },`;
|
|
62
|
+
return hint.actor === undefined || hint.actor === null
|
|
63
|
+
? line
|
|
64
|
+
: `${line} // testActor: @ultimat3/policy`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The pick, spelled: absent when the entry declares its actor (the author's line already has it);
|
|
69
|
+
* `null` for a signed-out run or a job's worker; else the grants the picked actor was minted with.
|
|
70
|
+
*/
|
|
71
|
+
export function actorHintOf(
|
|
72
|
+
chosen: { readonly actor: Actor | null; readonly name: string },
|
|
73
|
+
override: ExerciseOverride | undefined,
|
|
74
|
+
): OverrideHint['actor'] {
|
|
75
|
+
if (override !== undefined && !('off' in override) && override.actor !== undefined) {
|
|
76
|
+
return undefined;
|
|
77
|
+
}
|
|
78
|
+
if (chosen.actor === null) return null;
|
|
79
|
+
return {
|
|
80
|
+
name: chosen.name,
|
|
81
|
+
roles: chosen.actor.roles ?? [],
|
|
82
|
+
permissions: chosen.actor.permissions ?? [],
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Each top-level id field of `input` holding the seeded row either lookup bound it to. */
|
|
87
|
+
export function seededIn(
|
|
88
|
+
input: unknown,
|
|
89
|
+
lookups: readonly IdLookup[],
|
|
90
|
+
): Readonly<Record<string, string>> {
|
|
91
|
+
if (typeof input !== 'object' || input === null) return {};
|
|
92
|
+
const ids: Record<string, string> = {};
|
|
93
|
+
for (const [field, value] of Object.entries(input)) {
|
|
94
|
+
if (typeof value !== 'string') continue;
|
|
95
|
+
if (lookups.some((lookup) => lookup(field)?.value === value)) ids[field] = value;
|
|
96
|
+
}
|
|
97
|
+
return ids;
|
|
98
|
+
}
|
package/src/exercise-report.ts
CHANGED
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
// every allow and mock cleared, the mail fixture, the clock frozen, statements and committed rows
|
|
3
3
|
// observed. Every seam is process-global, so the room hands back exactly what it found.
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
expectedSeqScanReason,
|
|
9
|
-
setStatementObserver,
|
|
10
|
-
statementFingerprint,
|
|
11
|
-
statementObserver,
|
|
12
|
-
} from '@ultimat3/db';
|
|
13
|
-
import type { RowObserver } from '@ultimat3/entity';
|
|
5
|
+
import type { DbStatementEvent } from '@ultimat3/core';
|
|
6
|
+
import { isSelfOrigin, peerAddressClass, subscribe } from '@ultimat3/core';
|
|
7
|
+
import { expectedSeqScanReason, statementFingerprint } from '@ultimat3/db';
|
|
14
8
|
import { captureDeterminism, installDeterminism, restoreCapturedDeterminism } from './determinism';
|
|
15
9
|
import type { ExerciseDefect } from './exercise-defect';
|
|
16
10
|
import { testMail } from './fixture-mail';
|
|
@@ -168,17 +162,6 @@ export interface EffectPayload {
|
|
|
168
162
|
readonly value: unknown;
|
|
169
163
|
}
|
|
170
164
|
|
|
171
|
-
const IDENTIFIER = /^[A-Za-z_$][\w$]*$/;
|
|
172
|
-
|
|
173
|
-
/** `publishPost: { actor, input: (drawn) => ({ ...drawn, postId: '<…>' }) },` — valid TS to paste. */
|
|
174
|
-
export function overrideLine(name: string, idFields: readonly string[]): string {
|
|
175
|
-
const key = IDENTIFIER.test(name) ? name : JSON.stringify(name);
|
|
176
|
-
const bound = idFields
|
|
177
|
-
.map((field) => `, ${IDENTIFIER.test(field) ? field : JSON.stringify(field)}: '<a real id>'`)
|
|
178
|
-
.join('');
|
|
179
|
-
return `${key}: { actor: <an actor its policy permits>, input: (drawn) => ({ ...drawn${bound} }) },`;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
165
|
const hostOf = (url: string): string => (URL.canParse(url) ? new URL(url).host : url);
|
|
183
166
|
|
|
184
167
|
/** `sealed-network.ts`'s own exemption: this machine and a server this process booted. */
|
|
@@ -218,7 +201,6 @@ export interface ExerciseRoom extends AsyncDisposable {
|
|
|
218
201
|
}
|
|
219
202
|
|
|
220
203
|
export async function openExerciseRoom(): Promise<ExerciseRoom> {
|
|
221
|
-
const { setRowObserver } = await import('@ultimat3/entity');
|
|
222
204
|
const clock = captureDeterminism();
|
|
223
205
|
if (!clock.installed) installDeterminism();
|
|
224
206
|
const network = captureNetwork();
|
|
@@ -234,35 +216,32 @@ export async function openExerciseRoom(): Promise<ExerciseRoom> {
|
|
|
234
216
|
const rows: string[] = [];
|
|
235
217
|
const shapes = new Map<string, { count: number; unexpected: number; expected?: string }>();
|
|
236
218
|
const sent = new Map<string, { primitives: Set<string>; scan?: string }>();
|
|
237
|
-
const
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
if (scan !== undefined) one.scan = scan;
|
|
255
|
-
sent.set(text, one);
|
|
256
|
-
},
|
|
257
|
-
};
|
|
258
|
-
setStatementObserver(counting);
|
|
259
|
-
const rowObserver: RowObserver = {
|
|
260
|
-
onChange: (change) => rows.push(`${change.entity}\u0000${change.op}`),
|
|
261
|
-
onBulk: (change) => {
|
|
262
|
-
for (let i = 0; i < change.rows; i += 1) rows.push(`${change.entity}\u0000${change.op}`);
|
|
263
|
-
},
|
|
219
|
+
const counting = (event: DbStatementEvent): void => {
|
|
220
|
+
statements += 1;
|
|
221
|
+
const fingerprint = statementFingerprint(event);
|
|
222
|
+
const shape = shapes.get(fingerprint) ?? { count: 0, unexpected: 0 };
|
|
223
|
+
shape.count += 1;
|
|
224
|
+
if (event.expected === undefined) shape.unexpected += 1;
|
|
225
|
+
else shape.expected = event.expected;
|
|
226
|
+
shapes.set(fingerprint, shape);
|
|
227
|
+
if (subject === undefined) return;
|
|
228
|
+
// Whitespace collapsed, so one builder's two indentations are one statement to plan.
|
|
229
|
+
const text = event.text.replace(/\s+/g, ' ').trim();
|
|
230
|
+
const one = sent.get(text) ?? { primitives: new Set<string>() };
|
|
231
|
+
one.primitives.add(subject);
|
|
232
|
+
// Read here, in the sender's own async context: the scope is the statement's, not the room's.
|
|
233
|
+
const scan = expectedSeqScanReason();
|
|
234
|
+
if (scan !== undefined) one.scan = scan;
|
|
235
|
+
sent.set(text, one);
|
|
264
236
|
};
|
|
265
|
-
|
|
237
|
+
// Subscribers on the bus, beside any outer one — released at dispose, never displacing it.
|
|
238
|
+
const offStatements = subscribe('db.statement', (event) => counting(event.payload));
|
|
239
|
+
const offRows = subscribe('entity', (event) => {
|
|
240
|
+
if (event.name === 'entity.row') rows.push(`${event.payload.entity}\u0000${event.payload.op}`);
|
|
241
|
+
if (event.name !== 'entity.bulk') return;
|
|
242
|
+
const { entity, op } = event.payload;
|
|
243
|
+
for (let i = 0; i < event.payload.rows; i += 1) rows.push(`${entity}\u0000${op}`);
|
|
244
|
+
});
|
|
266
245
|
|
|
267
246
|
return {
|
|
268
247
|
begin: (name) => {
|
|
@@ -327,8 +306,8 @@ export async function openExerciseRoom(): Promise<ExerciseRoom> {
|
|
|
327
306
|
try {
|
|
328
307
|
mail[Symbol.dispose]();
|
|
329
308
|
} finally {
|
|
330
|
-
|
|
331
|
-
|
|
309
|
+
offRows();
|
|
310
|
+
offStatements();
|
|
332
311
|
restoreCapturedNetwork(network);
|
|
333
312
|
if (!sealedBefore) unsealNetwork();
|
|
334
313
|
restoreCapturedDeterminism(clock);
|
package/src/exercise.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// what the input sent is never the call's, and a name two kinds share has an entry per kind.
|
|
11
11
|
|
|
12
12
|
import type { Actor, ExerciseAttempt, ExerciseVerdict } from '@ultimat3/core';
|
|
13
|
-
import { runExercise } from '@ultimat3/core';
|
|
13
|
+
import { runExercise, subscribe } from '@ultimat3/core';
|
|
14
14
|
import { LIVE_STATES, registeredJobs } from '@ultimat3/jobs';
|
|
15
15
|
import type { ExerciseOverride, ExerciseOverrides } from './define-exercise';
|
|
16
16
|
import { assertOverridesKnown, overrideFor, unknownDeclaration } from './define-exercise';
|
|
@@ -26,6 +26,7 @@ import { judged, labelFor } from './exercise-judge';
|
|
|
26
26
|
import { mergeObserved } from './exercise-observed';
|
|
27
27
|
import type { OverrideInput } from './exercise-override-input';
|
|
28
28
|
import { inputThrew, overrideInput } from './exercise-override-input';
|
|
29
|
+
import { actorHintOf, type OverrideHint, seededIn } from './exercise-override-line';
|
|
29
30
|
import type {
|
|
30
31
|
EffectPayload,
|
|
31
32
|
ExerciseEffect,
|
|
@@ -117,6 +118,8 @@ interface Prepared {
|
|
|
117
118
|
readonly declaredRuns: number | undefined;
|
|
118
119
|
readonly lookups: readonly [IdLookup, IdLookup];
|
|
119
120
|
readonly bindInput: OverrideInput | undefined;
|
|
121
|
+
/** The actor the pass picked, as the paste line spells it (`exercise-override-line.ts`). */
|
|
122
|
+
readonly actorHint: OverrideHint['actor'];
|
|
120
123
|
}
|
|
121
124
|
|
|
122
125
|
/** Thrown out of 39's loop by a bind that failed: the record is the entry's, never the loop's. */
|
|
@@ -204,7 +207,8 @@ async function control(
|
|
|
204
207
|
const ms = Math.round(performance.now() - started);
|
|
205
208
|
const observed = mergeObserved(segments);
|
|
206
209
|
const effects = [...observed.effects, ...(await enqueued(subject, mine))];
|
|
207
|
-
const
|
|
210
|
+
const hint = { actor: run.actorHint, ids: seededIn(lastInput, lookups) };
|
|
211
|
+
const outcome = { verdict, answered, lastError, lastInput, hint };
|
|
208
212
|
const verdictOf = judged(subject, key, outcome, observed, sampler);
|
|
209
213
|
// A 5xx's cause, statement and fields: the code alone sent the author to reproduce it by hand.
|
|
210
214
|
const defect =
|
|
@@ -239,10 +243,11 @@ async function attack(
|
|
|
239
243
|
// which proves nothing), so the attack that matters is a job of B's carrying A's ids.
|
|
240
244
|
const sent = seatIn(subject, input, tenant);
|
|
241
245
|
// Every `crossTenant()` B's call opened: a job's declared sweep is told from a leak by it alone.
|
|
242
|
-
//
|
|
243
|
-
const { setCrossTenantObserver } = await import('@ultimat3/entity');
|
|
246
|
+
// On the bus, so the barrel stays entity-free (`seed-writer.ts`'s rule) with no import at all.
|
|
244
247
|
const crossings: string[] = [];
|
|
245
|
-
|
|
248
|
+
const offCrossings = subscribe('entity.cross_tenant', (event) => {
|
|
249
|
+
crossings.push(event.payload.reason);
|
|
250
|
+
});
|
|
246
251
|
try {
|
|
247
252
|
const answer = await subject.call(sent, actor, tenant, jobs);
|
|
248
253
|
output = answer.output;
|
|
@@ -250,7 +255,7 @@ async function attack(
|
|
|
250
255
|
// B's refusal is the answer a scoped primitive gives: only what B got back, and what B's call
|
|
251
256
|
// did to A's rows, is judged — never whether B was refused.
|
|
252
257
|
} finally {
|
|
253
|
-
|
|
258
|
+
offCrossings();
|
|
254
259
|
}
|
|
255
260
|
const observed = room.end();
|
|
256
261
|
const payloads = [...observed.payloads, ...(await queuedPayloads(subject))];
|
|
@@ -308,6 +313,7 @@ async function exerciseOne(
|
|
|
308
313
|
declaredRuns,
|
|
309
314
|
lookups,
|
|
310
315
|
bindInput,
|
|
316
|
+
actorHint: actorHintOf(chosen, override),
|
|
311
317
|
};
|
|
312
318
|
// A's own first input, A's ids in it: B sends exactly what A legitimately would.
|
|
313
319
|
const drawn = bindIds(drawInput(sampler, subject.input, 0, 0), lookups[0]);
|