Skip to content

Commit 03c3984

Browse files
authored
perf(contracts): granularize entry surfaces so hub importers stop evaluating the facade clump (callstack#1969)
* perf(contracts): granularize entry surfaces so hub importers stop evaluating the facade clump `@agent-device/contracts/platform` unions 32 vocabulary modules and `/interaction` another 18. A file that value-imports either evaluates the whole union to reach one function, and because permanent hubs sat behind them — `command-descriptor/registry.ts`, `core/capabilities.ts`, `interactors/register-builtins.ts`, `command-descriptor/platform-execution-entry.ts` — that union rode into roughly half the unit suite's test graphs. Give every vocabulary module its own entry subpath and move all value-importers onto the module that owns the symbol. Type-only importers are left alone: `import type` is erased, so it already evaluated nothing. Measured with the callstack#1950 eager-import-closure walker over all 974 unit-core test files, against base e5bfde3: aggregate eager module evaluations 143,248 -> 129,738 (-9.4%) facades/platform.ts carried by 466 -> 1 test graphs facades/interaction.ts carried by 451 -> 0 test graphs registry.ts 105 -> 66 capabilities.ts 113 -> 76 register-builtins.ts 111 -> 73 platform-execution-entry.ts 43 -> 3 dispatch.ts 134 -> 100 Three gate adjustments the split forces: - R11's pinned contracts subpath list grows to the new entries, and the resolver test's "must not resolve" example moves to `./clipboard`, since `./gesture-plan` is now a real entry. - R16 anchored the record-runtime join on the literal `contracts/platform` specifier. It now accepts any contracts entry — the assertion's provenance is what the rule pins, not which subpath carried it. - `gesture-plan.ts` became an entry target, and the no-bare-star rule rejects the `export * from './gesture-plan-types.ts'` it carried. Its one internal consumer now imports the owning module directly. Both facades keep their type re-exports for the ~490 type-only importers, so every symbol on them now reads as value-unused; one fallow entry records that and names retiring them as the follow-up. Closes callstack#1959 * test(contracts): text-filter the facade scan before parsing The repo-wide scan parsed all ~3000 sources, which the coverage lane's instrumentation pushed past both the 5s test timeout and the 2.5s slow-test budget. A file that never names the specifier cannot import it, so filter on the text first and parse only the ~490 candidates. Non-vacuity moves with it: instead of counting narrow imports across every file, require that the surviving type-only importers were seen and classified as erased — which an empty scan cannot satisfy.
1 parent 7f3e355 commit 03c3984

259 files changed

Lines changed: 1358 additions & 850 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.fallowrc.json‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,11 @@
169169
"file": "packages/provider-limrun/src/index.ts",
170170
"exports": ["LimrunIosCommandExecution"]
171171
},
172+
{
173+
"comment": "#1959 gave every contracts vocabulary module its own entry subpath and moved all ~230 value-importers onto them, so `./platform` and `./interaction` now carry zero value consumers — every re-export on them reads as unused. They stay as the compatibility surface for the ~490 type-only importers the granularization deliberately left alone (type imports are erased, so they cost nothing to load). Scoped to these two façades rather than listed symbol-by-symbol because the property is per-file: nothing on them is value-consumed any more. Retiring them entirely — moving the type-only importers too and deleting the files — is the follow-up that makes this entry unnecessary.",
174+
"file": "packages/contracts/src/facades/{platform,interaction}.ts",
175+
"exports": ["*"]
176+
},
172177
{
173178
"comment": "Converting the contracts façades from `export *` to explicit named re-exports (the pin-table retirement) made these individually visible to --production analysis for the first time; a bare star previously hid them from this exact check. GESTURE_INITIAL_ANGLE_DEGREES/GESTURE_SAMPLE_INTERVAL_MS/INTERACTION_GUARANTEES/INTERACTION_PATH_IDS/parseAndroidInputMethodPackage/isRecordingExportQuality have same-package test-tree consumers (invisible to --production, mirroring the packages/{ad-script,maestro} entry above); the rest currently have none. Kept rather than narrowed here so the façade's re-export surface stays byte-identical to the symbol set the retired pin table asserted — narrowing the surface is a follow-up with its own review, not a side effect of this mechanical conversion. The last five (COORDINATE_GESTURE_KINDS, normalizePublicGesture, DEFAULT_DRAG_*) are #1567's drag vocabulary, surfaced the same way by the same conversion and kept for the same reason.",
174179
"file": "packages/contracts/src/facades/{client,command,divergence,interaction,platform,recording}.ts",

‎packages/ad-script/src/internal/script.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { AppError } from '@agent-device/kernel/errors';
22
import { recordingQualityInputToExportQuality } from '@agent-device/contracts/recording';
3-
import { describeReplayGestureArityError } from '@agent-device/contracts/interaction';
3+
import { describeReplayGestureArityError } from '@agent-device/contracts/gesture-normalization';
44
import {
55
RETIRED_SCREENSHOT_MAX_SIZE,
66
readScreenshotScriptFlag,

‎packages/capture-kit/src/app-log-live-handle.ts‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { AppError } from '@agent-device/kernel/errors';
2+
import type {
3+
AppLogCompletion,
4+
AppLogLiveHandle,
5+
AppLogLiveSnapshot,
6+
} from '@agent-device/contracts/app-log-runtime';
27
import {
3-
isConfirmedCleanup,
4-
type AppLogCompletion,
5-
type AppLogLiveHandle,
6-
type AppLogLiveSnapshot,
78
type CleanupOutcome,
89
type FinishOutcome,
9-
} from '@agent-device/contracts/platform';
10+
isConfirmedCleanup,
11+
} from '@agent-device/contracts/durable-resource';
1012

1113
type AppLogLiveHandleImplementation = Readonly<{
1214
inspect(): AppLogLiveSnapshot;

‎packages/capture-kit/src/app-log-pid-runtime.test.ts‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import type { DeviceInfo } from '@agent-device/kernel/device';
22
import { expect, test, vi } from 'vitest';
3-
import {
4-
type AppLogBackgroundProcess,
5-
type AppLogRuntimeHost,
6-
type DurableDescriptorCodec,
7-
} from '@agent-device/contracts/platform';
3+
import type {
4+
AppLogBackgroundProcess,
5+
AppLogRuntimeHost,
6+
} from '@agent-device/contracts/app-log-runtime';
7+
import type { DurableDescriptorCodec } from '@agent-device/contracts/durable-resource-envelope';
88
import {
99
createDurableResourceEnvelope,
1010
encodeDurableDescriptor,

‎packages/capture-kit/src/app-log-pid-runtime.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
RuntimeFacts,
1717
RuntimeOwnerRef,
1818
} from '@agent-device/contracts/platform';
19-
import { localRuntimeOwner, sameRuntimeOwner } from '@agent-device/contracts/platform';
19+
import { localRuntimeOwner, sameRuntimeOwner } from '@agent-device/contracts/platform-runtime';
2020
import type { LogBackend } from '@agent-device/contracts/observability';
2121
import { createAppLogRecoveryOperations, createAppLogStartResult } from './app-log-runtime.ts';
2222
import {

‎packages/capture-kit/src/app-log-runtime.test.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import assert from 'node:assert/strict';
22
import { test, vi } from 'vitest';
33
import { AppError } from '@agent-device/kernel/errors';
4-
import {
5-
type AppLogCompletion,
6-
type AppLogBackgroundProcessRequest,
7-
type AppLogProcessOwnership,
8-
type AppLogProcessTransport,
9-
type AppLogRuntimeHost,
10-
type DurableDescriptorCodec,
11-
} from '@agent-device/contracts/platform';
4+
import type {
5+
AppLogBackgroundProcessRequest,
6+
AppLogCompletion,
7+
AppLogProcessOwnership,
8+
AppLogProcessTransport,
9+
AppLogRuntimeHost,
10+
} from '@agent-device/contracts/app-log-runtime';
11+
import type { DurableDescriptorCodec } from '@agent-device/contracts/durable-resource-envelope';
1212
import { APP_LOG_ENVELOPE_FIXTURE } from './durable-resource-envelope.fixtures.ts';
1313
import { createAppLogLiveHandle } from './app-log-live-handle.ts';
1414
import {

‎packages/capture-kit/src/app-log-runtime.ts‎

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
1-
import {
2-
PendingTransferGuard,
3-
type AppLogCompletion,
4-
type AppLogLiveHandle,
5-
type AppLogProcessMarkerReadOutcome,
6-
type AppLogRuntimeOperations,
7-
type AppLogStartResult,
8-
type CleanupOutcome,
9-
type DurableDescriptorCodec,
10-
type DurableResourceEnvelope,
11-
type ReattachOutcome,
12-
type ResourceOwnershipFence,
13-
} from '@agent-device/contracts/platform';
1+
import type {
2+
AppLogCompletion,
3+
AppLogLiveHandle,
4+
AppLogProcessMarkerReadOutcome,
5+
AppLogRuntimeOperations,
6+
AppLogStartResult,
7+
} from '@agent-device/contracts/app-log-runtime';
8+
import { PendingTransferGuard } from '@agent-device/contracts/async-lifecycle';
9+
import type { CleanupOutcome, ReattachOutcome } from '@agent-device/contracts/durable-resource';
10+
import type {
11+
DurableDescriptorCodec,
12+
DurableResourceEnvelope,
13+
} from '@agent-device/contracts/durable-resource-envelope';
14+
import type { ResourceOwnershipFence } from '@agent-device/contracts/platform-runtime';
1415
import { decodeDurableDescriptor } from './durable-descriptor-codec.ts';
1516

1617
const APP_LOG_RESOURCE_KIND = 'app-log' as const;

‎packages/capture-kit/src/durable-resource-envelope.ts‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,19 @@ import {
99
type Platform,
1010
} from '@agent-device/kernel/device';
1111
import type { JsonObject } from '@agent-device/contracts/client';
12+
import type {
13+
DurableDescriptorCodec,
14+
DurableEnvelopeDecodeOutcome,
15+
DurableResourceEnvelope,
16+
DurableResourceLifecycleState,
17+
EncodedDurableDescriptor,
18+
} from '@agent-device/contracts/durable-resource-envelope';
1219
import {
13-
localRuntimeOwner,
14-
providerRuntimeOwner,
15-
type DurableDescriptorCodec,
16-
type DurableEnvelopeDecodeOutcome,
17-
type DurableResourceEnvelope,
18-
type DurableResourceLifecycleState,
19-
type EncodedDurableDescriptor,
2020
type ResourceOwnershipFence,
2121
type RuntimeOwnerRef,
22-
} from '@agent-device/contracts/platform';
22+
localRuntimeOwner,
23+
providerRuntimeOwner,
24+
} from '@agent-device/contracts/platform-runtime';
2325
import { freezeJsonObject, isBoundedJsonObject } from './durable-json.ts';
2426

2527
const DURABLE_RESOURCE_ENVELOPE_VERSION = 1 as const;

‎packages/capture-kit/src/screen-recording-live-handle.ts‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { AppError } from '@agent-device/kernel/errors';
22
import {
3-
isConfirmedCleanup,
43
type CleanupOutcome,
54
type FinishOutcome,
6-
type RecordingGestureEvent,
7-
type ScreenRecordingCompletion,
8-
type ScreenRecordingLiveHandle,
9-
type ScreenRecordingLiveSnapshot,
10-
} from '@agent-device/contracts/platform';
5+
isConfirmedCleanup,
6+
} from '@agent-device/contracts/durable-resource';
7+
import type {
8+
RecordingGestureEvent,
9+
ScreenRecordingCompletion,
10+
ScreenRecordingLiveHandle,
11+
ScreenRecordingLiveSnapshot,
12+
} from '@agent-device/contracts/screen-recording-runtime';
1113
import type { GestureReferenceFrame } from '@agent-device/contracts/interaction';
1214

1315
type ScreenRecordingLiveHandleImplementation = Readonly<{

0 commit comments

Comments
 (0)