mirror of
https://github.com/stablyai/orca.git
synced 2026-10-04 00:02:21 +00:00
test(mobile): share the recorder's fixture helper instead of copying it into eight adapters
The seam forbids one adapter importing another, not an adapter importing the engine, and the adapters already take `hookMount` and `observableModel` from there. So the eight byte-identical copies of `mountFixture` bought nothing: eight doc comments and eight cast suppressions for one four-line function that has no per-domain part. Export it from `recorder-fixture-shape.ts`, next to the type it checks against, and leave one suppression instead of nine. `adapter-seam.test.ts` 7/7 and `pnpm --dir mobile typecheck` stay clean. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
This commit is contained in:
+1
-12
@@ -2,7 +2,7 @@ import { hookMount, performHookAction } from '../hook-mount'
|
||||
import { observableModel, projectObservable } from '../observable-model'
|
||||
import type { MountAdapter, MountContext, MountedOperation } from '../recording-scenario'
|
||||
import type { operationModuleLoader } from '../operation-module-loader'
|
||||
import type { PartialRecorderFixture } from '../recorder-fixture-shape'
|
||||
import { mountFixture } from '../recorder-fixture-shape'
|
||||
|
||||
const REPO_ID = 'repo-1'
|
||||
|
||||
@@ -141,17 +141,6 @@ type ModelHookSpec<Actions> = {
|
||||
readonly state: (model: Record<string, unknown>) => Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
function mountModelHook<Actions>(
|
||||
context: MountContext,
|
||||
spec: ModelHookSpec<Actions>
|
||||
|
||||
+1
-12
@@ -2,7 +2,7 @@ import { hookMount, performHookAction } from '../hook-mount'
|
||||
import { observableModel, projectObservable } from '../observable-model'
|
||||
import type { MountAdapter, MountContext, MountedOperation } from '../recording-scenario'
|
||||
import type { operationModuleLoader } from '../operation-module-loader'
|
||||
import type { PartialRecorderFixture } from '../recorder-fixture-shape'
|
||||
import { mountFixture } from '../recorder-fixture-shape'
|
||||
|
||||
const REPO_ID = 'repo-1'
|
||||
|
||||
@@ -161,17 +161,6 @@ type ModelHookSpec<Actions> = {
|
||||
readonly state: (model: Record<string, unknown>) => Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
function mountModelHook<Actions>(
|
||||
context: MountContext,
|
||||
spec: ModelHookSpec<Actions>
|
||||
|
||||
+1
-12
@@ -2,7 +2,7 @@ import { hookMount, performHookAction } from '../hook-mount'
|
||||
import { observableModel, projectObservable } from '../observable-model'
|
||||
import type { MountAdapter, MountContext, MountedOperation } from '../recording-scenario'
|
||||
import type { operationModuleLoader } from '../operation-module-loader'
|
||||
import type { PartialRecorderFixture } from '../recorder-fixture-shape'
|
||||
import { mountFixture } from '../recorder-fixture-shape'
|
||||
|
||||
const REPO_ID = 'repo-1'
|
||||
|
||||
@@ -159,17 +159,6 @@ type ModelHookSpec<Actions> = {
|
||||
readonly state: (model: Record<string, unknown>) => Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
function mountModelHook<Actions>(
|
||||
context: MountContext,
|
||||
spec: ModelHookSpec<Actions>
|
||||
|
||||
@@ -2,7 +2,7 @@ import { hookMount, performHookAction } from '../hook-mount'
|
||||
import { observableModel, projectObservable } from '../observable-model'
|
||||
import type { MountAdapter, MountContext, MountedOperation } from '../recording-scenario'
|
||||
import type { operationModuleLoader } from '../operation-module-loader'
|
||||
import type { PartialRecorderFixture } from '../recorder-fixture-shape'
|
||||
import { mountFixture } from '../recorder-fixture-shape'
|
||||
|
||||
const REPO_ID = 'repo-1'
|
||||
|
||||
@@ -28,17 +28,6 @@ type ModelHookSpec<Actions> = {
|
||||
readonly state: (model: Record<string, unknown>) => Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
function mountModelHook<Actions>(
|
||||
context: MountContext,
|
||||
spec: ModelHookSpec<Actions>
|
||||
|
||||
+1
-12
@@ -2,7 +2,7 @@ import { hookMount, performHookAction } from '../hook-mount'
|
||||
import { observableModel, projectObservable } from '../observable-model'
|
||||
import type { MountAdapter, MountContext, MountedOperation } from '../recording-scenario'
|
||||
import type { operationModuleLoader } from '../operation-module-loader'
|
||||
import type { PartialRecorderFixture } from '../recorder-fixture-shape'
|
||||
import { mountFixture } from '../recorder-fixture-shape'
|
||||
|
||||
const REPO_ID = 'repo-1'
|
||||
|
||||
@@ -120,17 +120,6 @@ type ModelHookSpec<Actions> = {
|
||||
readonly state: (model: Record<string, unknown>) => Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
function mountModelHook<Actions>(
|
||||
context: MountContext,
|
||||
spec: ModelHookSpec<Actions>
|
||||
|
||||
+1
-12
@@ -2,7 +2,7 @@ import { hookMount, performHookAction } from '../hook-mount'
|
||||
import { observableModel, projectObservable } from '../observable-model'
|
||||
import type { MountAdapter, MountContext, MountedOperation } from '../recording-scenario'
|
||||
import type { operationModuleLoader } from '../operation-module-loader'
|
||||
import type { PartialRecorderFixture } from '../recorder-fixture-shape'
|
||||
import { mountFixture } from '../recorder-fixture-shape'
|
||||
|
||||
const REPO_ID = 'repo-1'
|
||||
|
||||
@@ -120,17 +120,6 @@ type ModelHookSpec<Actions> = {
|
||||
readonly state: (model: Record<string, unknown>) => Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
function mountModelHook<Actions>(
|
||||
context: MountContext,
|
||||
spec: ModelHookSpec<Actions>
|
||||
|
||||
+1
-12
@@ -2,7 +2,7 @@ import { hookMount, performHookAction } from '../hook-mount'
|
||||
import { observableModel, projectObservable } from '../observable-model'
|
||||
import type { MountAdapter, MountContext, MountedOperation } from '../recording-scenario'
|
||||
import type { operationModuleLoader } from '../operation-module-loader'
|
||||
import type { PartialRecorderFixture } from '../recorder-fixture-shape'
|
||||
import { mountFixture } from '../recorder-fixture-shape'
|
||||
|
||||
const REPO_ID = 'repo-1'
|
||||
|
||||
@@ -126,17 +126,6 @@ type ModelHookSpec<Actions> = {
|
||||
readonly state: (model: Record<string, unknown>) => Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
function mountModelHook<Actions>(
|
||||
context: MountContext,
|
||||
spec: ModelHookSpec<Actions>
|
||||
|
||||
+1
-12
@@ -2,7 +2,7 @@ import { hookMount, performHookAction } from '../hook-mount'
|
||||
import { observableModel, projectObservable } from '../observable-model'
|
||||
import type { MountAdapter, MountContext, MountedOperation } from '../recording-scenario'
|
||||
import type { operationModuleLoader } from '../operation-module-loader'
|
||||
import type { PartialRecorderFixture } from '../recorder-fixture-shape'
|
||||
import { mountFixture } from '../recorder-fixture-shape'
|
||||
|
||||
const REPO_ID = 'repo-1'
|
||||
|
||||
@@ -150,17 +150,6 @@ type ModelHookSpec<Actions> = {
|
||||
readonly state: (model: Record<string, unknown>) => Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
function mountModelHook<Actions>(
|
||||
context: MountContext,
|
||||
spec: ModelHookSpec<Actions>
|
||||
|
||||
@@ -4,11 +4,10 @@
|
||||
* type. That is what a mount fixture actually is — deliberately partial, because it carries only
|
||||
* what the mounted hook reads, yet still a subset of the real thing.
|
||||
*
|
||||
* Type-only, and here rather than outside the recorder because `mobile/scripts/rpc-recording.mts`
|
||||
* fences every path under `mobile/src` except this directory, so a file outside it fails recording
|
||||
* as an unpinned product source. It sits in the engine rather than under `adapters/` because the
|
||||
* mount helper that uses it is copied per module and the seam forbids one module importing another,
|
||||
* so this is what stops eleven copies of a recursive conditional type from existing.
|
||||
* Here rather than outside the recorder because `mobile/scripts/rpc-recording.mts` fences every
|
||||
* path under `mobile/src` except this directory, so a file outside it fails recording as an unpinned
|
||||
* product source. In the engine rather than under `adapters/` because the seam forbids one adapter
|
||||
* importing another, and every adapter may import the engine.
|
||||
*
|
||||
* Functions pass through whole: a fixture stub like `async () => 0` stands in for a callback, and
|
||||
* making its parameters optional would accept a stub the hook cannot call.
|
||||
@@ -26,3 +25,14 @@ export type PartialRecorderFixture<T> = T extends (...args: never[]) => unknown
|
||||
: T extends object
|
||||
? { readonly [Key in keyof T]?: PartialRecorderFixture<T[Key]> | null }
|
||||
: T
|
||||
|
||||
/**
|
||||
* The recorder supplies only the members the mounted action reads; completing the fixture into a
|
||||
* full domain object would invent data no scenario observes. `NoInfer` makes the target the
|
||||
* parameter's type rather than the fixture's, so a member the real type does not have is an error
|
||||
* here instead of a silently wrong recording.
|
||||
*/
|
||||
export function mountFixture<T>(value: PartialRecorderFixture<NoInfer<T>>): T {
|
||||
// oxlint-disable-next-line typescript/consistent-type-assertions -- SAFETY: checked as a deep subset of T above; the recorder supplies every member the action reads.
|
||||
return value as T
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user