Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,6 @@
"types": "./src/device-shutdown-runtime.ts",
"default": "./src/device-shutdown-runtime.ts"
},
"./dispatch-disclosure-fixtures": {
"types": "./src/dispatch-disclosure.fixtures.ts",
"default": "./src/dispatch-disclosure.fixtures.ts"
},
"./divergence": {
"types": "./src/facades/divergence.ts",
"default": "./src/facades/divergence.ts"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,16 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
IOS_SIMULATOR,
MACOS_DEVICE,
} from '@agent-device/test-kit';
import type { SnapshotResult } from '@agent-device/contracts/interactor-types';
import { buildSnapshotState } from '@agent-device/capture-kit/snapshot-state';
import { AppError } from '@agent-device/kernel/errors';
import type { CommandFlags } from '@agent-device/contracts/command';
import type { Rect, SnapshotNode } from '@agent-device/kernel/snapshot';
import { emitDiagnostic } from '@agent-device/host-kit/diagnostics';
import { readScrollEdgeState } from '@agent-device/capture-kit/scroll-edge-state';
import { IOS_SIMULATOR, MACOS_DEVICE } from '@agent-device/test-kit';
import { makeSession } from '../../__tests__/support/session-factories.ts';
import { expireRefFrame } from '../../core/ref-frame.ts';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';
import { beforeEach, expect, test } from 'vitest';
import { makeIosSession } from '../../../__tests__/support/session-factories.ts';
import { makeSessionStore } from '../../../__tests__/support/store-factory.ts';
Expand Down
13 changes: 13 additions & 0 deletions packages/kernel/src/errors-dispatch-disclosure.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import assert from 'node:assert/strict';
import { test } from 'vitest';
import { AppError, discloseDispatch, discloseUnclassifiedDispatch } from './errors.ts';

test('a producer verdict overwrites; the seam verdict fills only an unclassified failure', () => {
const error = new AppError('COMMAND_FAILED', 'tap failed', { hint: 'retry' });
assert.equal(discloseUnclassifiedDispatch(error, 'unknown'), error);
assert.equal(error.details?.dispatched, 'unknown');
assert.equal(discloseDispatch(error, 'no', { dispatchedSteps: 2 }), error);
assert.deepEqual(error.details, { hint: 'retry', dispatchedSteps: 2, dispatched: 'no' });
discloseUnclassifiedDispatch(error, 'unknown');
assert.equal(error.details?.dispatched, 'no');
});
1 change: 1 addition & 0 deletions packages/platform-android/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@agent-device/xml": "workspace:*"
},
"devDependencies": {
"@agent-device/test-kit": "workspace:*",
"fast-check": "^4.9.0"
},
"exports": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';
import {
androidAdbResultError,
withAndroidAdbProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';
import {
withAndroidAdbProvider,
type AndroidAdbProcess,
Expand Down
1 change: 1 addition & 0 deletions packages/platform-android/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{ "path": "../host-kit" },
{ "path": "../kernel" },
{ "path": "../provision-kit" },
{ "path": "../test-kit" },
{ "path": "../xml" }
]
}
3 changes: 3 additions & 0 deletions packages/platform-apple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,8 @@
"types": "./src/tool-provider-facade.ts",
"default": "./src/tool-provider-facade.ts"
}
},
"devDependencies": {
"@agent-device/test-kit": "workspace:*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';
import { IOS_SIMULATOR } from './device-fixtures.ts';
import { handleRunnerTransportErrorAfterCommandSend } from '../runner-command-recovery.ts';
import { isReadOnlyRunnerCommand } from '../runner-command-traits.ts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';
import { IOS_SIMULATOR } from './device-fixtures.ts';
import { createTestRequestCancellation, makeRunnerSession } from './runner-session-fixtures.ts';
import { appleRunnerTestHost } from '../test-host.ts';
Expand Down
1 change: 1 addition & 0 deletions packages/platform-apple/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
{ "path": "../host-kit" },
{ "path": "../kernel" },
{ "path": "../provision-kit" },
{ "path": "../test-kit" },
{ "path": "../xml" }
]
}
3 changes: 3 additions & 0 deletions packages/platform-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,8 @@
"types": "./src/index.ts",
"default": "./src/index.ts"
}
},
"devDependencies": {
"@agent-device/test-kit": "workspace:*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';
import { AppError } from '@agent-device/kernel/errors';
import { withCommandExecutorOverride, type ExecResult } from '@agent-device/host-kit/command';
import {
Expand Down
3 changes: 2 additions & 1 deletion packages/platform-web/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{ "path": "../contracts" },
{ "path": "../host-kit" },
{ "path": "../kernel" },
{ "path": "../selectors" }
{ "path": "../selectors" },
{ "path": "../test-kit" }
]
}
3 changes: 3 additions & 0 deletions packages/provider-webdriver/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
"types": "./src/connection-verification.ts",
"default": "./src/connection-verification.ts"
}
},
"devDependencies": {
"@agent-device/test-kit": "workspace:*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';

type Call = { method: string; args: unknown[] };

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';
import {
WebDriverTransport,
isWebDriverConnectRefused,
Expand Down
1 change: 1 addition & 0 deletions packages/provider-webdriver/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
{ "path": "../contracts" },
{ "path": "../host-kit" },
{ "path": "../kernel" },
{ "path": "../test-kit" },
{ "path": "../xml" }
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { test } from 'vitest';
import {
AppError,
discloseDispatch,
discloseUnclassifiedDispatch,
} from '@agent-device/kernel/errors';
import {
DISPATCH_DISCLOSURE_DRIVER_OWNERS,
DISPATCH_DISCLOSURE_PRODUCERS,
Expand All @@ -20,16 +15,6 @@ import {
const REPO_ROOT = fileURLToPath(new URL('../../../', import.meta.url));
const DISPATCH_VALUES: readonly string[] = ['no', 'unknown'];

test('a producer verdict overwrites; the seam verdict fills only an unclassified failure', () => {
const error = new AppError('COMMAND_FAILED', 'tap failed', { hint: 'retry' });
assert.equal(discloseUnclassifiedDispatch(error, 'unknown'), error);
assert.equal(error.details?.dispatched, 'unknown');
assert.equal(discloseDispatch(error, 'no', { dispatchedSteps: 2 }), error);
assert.deepEqual(error.details, { hint: 'retry', dispatchedSteps: 2, dispatched: 'no' });
discloseUnclassifiedDispatch(error, 'unknown');
assert.equal(error.details?.dispatched, 'no');
});

test('dispatch-disclosure rows are unique and use the declared vocabulary', () => {
const rows = parseDispatchDisclosureTable(
fs.readFileSync(DISPATCH_DISCLOSURE_TABLE_PATH, 'utf8'),
Expand Down
5 changes: 5 additions & 0 deletions packages/test-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export {
VISIONOS_SIMULATOR,
WEB_DESKTOP_DEVICE,
} from './device-fixtures.ts';
export {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from './dispatch-disclosure.fixtures.ts';
export { restoreEnv } from './env.ts';
export {
type FilesystemBoundaryFixture,
Expand Down
15 changes: 15 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion scripts/layering/contracts-exports.snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@agent-device/contracts/device-boot",
"@agent-device/contracts/device-readiness-runtime",
"@agent-device/contracts/device-shutdown-runtime",
"@agent-device/contracts/dispatch-disclosure-fixtures",
"@agent-device/contracts/divergence",
"@agent-device/contracts/durable-resource",
"@agent-device/contracts/durable-resource-envelope",
Expand Down
27 changes: 27 additions & 0 deletions scripts/layering/platform-package-policy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,33 @@ test('platform packages may use capture-kit but no unrelated workspace implement
}
});

test('platform package tests may import test-kit, production source may not', () => {
const tests = validSources();
tests.set(
'packages/platform-apple/src/probe.test.ts',
"import { mkdtempForTest } from '@agent-device/test-kit';",
);
tests.set(
'packages/platform-apple/src/recording/fixtures.ts',
"import { mkdtempForTest } from '@agent-device/test-kit';",
);
tests.set(
'packages/platform-apple/src/probe.spec.ts',
"import { mkdtempForTest } from '@agent-device/test-kit';",
);
assert.deepEqual(checkPlatformPackagePolicy(tests, declarations()), []);

const production = validSources();
production.set(
'packages/platform-apple/src/probe.ts',
"import { mkdtempForTest } from '@agent-device/test-kit';",
);
assert.match(
messages(production).join('\n'),
/may import workspace code only from capture-kit, host-kit, provision-kit, contracts, kernel, or xml/,
);
});

test('package-owned tests may import their own public facade', () => {
const sources = validSources();
sources.set(
Expand Down
7 changes: 6 additions & 1 deletion scripts/layering/platform-package-policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,10 @@ function isWebPackageTestSelectorImport(file: string, family: string, specifier:
);
}

function isTestKitTestImport(file: string, specifier: string): boolean {
return specifier === '@agent-device/test-kit' && !isProductionSourceFile(file);
}

function checkDeclarations(packages: readonly PlatformPackageDeclaration[]): LayeringViolation[] {
const violations: LayeringViolation[] = [];
for (const family of CANONICAL_PLATFORM_FAMILIES) {
Expand Down Expand Up @@ -318,7 +322,8 @@ function checkSource(file: string, source: string): LayeringViolation[] {
site.spec !== '@agent-device/xml' &&
!isAppleFacadeSubpathImport(site.spec) &&
!isPackageOwnedFacadeTest(file, ownerFamily, site.spec) &&
!isWebPackageTestSelectorImport(file, ownerFamily, site.spec)
!isWebPackageTestSelectorImport(file, ownerFamily, site.spec) &&
!isTestKitTestImport(file, site.spec)
) {
violations.push(
violation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
} from '@agent-device/test-kit';
import { makeSessionStore } from '@agent-device/daemon/testing/__tests__/support/store-factory';
import { makeAndroidSession } from '@agent-device/daemon/testing/__tests__/support/session-factories';
import {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import {
assertDispatchDisclosureDriversMatchRows,
DISPATCH_DISCLOSURE_TABLE_PATH,
dispatchDisclosureRowsOwnedBy,
} from '@agent-device/contracts/dispatch-disclosure-fixtures';
mkdtempForTestSync,
} from '@agent-device/test-kit';
import { createTestDeviceInventoryGateways } from '@agent-device/device-selection/inventory-gateways-fixtures';
import {
makeAndroidSession,
makeIosAppSession,
makeSession,
} from '@agent-device/daemon/testing/__tests__/support/session-factories';
import { makeSessionStore } from '@agent-device/daemon/testing/__tests__/support/store-factory';
import { mkdtempForTestSync } from '@agent-device/test-kit';
import type { DaemonRequest } from '@agent-device/daemon';
import { discloseRequestDispatch } from '@agent-device/daemon/testing/request-dispatch-disclosure';
import { createRequestDispatchLedger } from '@agent-device/daemon/testing/request-dispatch-ledger';
Expand Down
Loading