@noego/testing 0.7.5 → 0.7.6
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/dist/index.cjs +12 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +12 -6
- package/dist/index.js.map +1 -1
- package/package.json +8 -5
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/builder.ts","../src/errors.ts","../src/descriptors.ts","../src/method_state.ts","../src/seams.ts","../src/stub.ts","../src/selection.ts","../src/resource_context.ts","../src/lifecycle.ts","../src/resource_case.ts","../src/coverage.ts","../src/overlays.ts","../src/binding_overlays.ts","../src/executable_overlays.ts","../src/binding_catalog.ts"],"sourcesContent":["/**\n * @noego/testing — the canonical shared owner of real-IoC test composition\n * (`testIoc`) and the lowercase `test.*` method behavior/watch/expectation\n * language, built on @noego/ioc's production seams.\n *\n * The former generic runtime-mirror doubles (ManualClock, ScriptedFetchClient,\n * memory stores, recording sinks, contract suites, LeakDetector, …) are\n * retired; pin 0.1.x if you still need them, and see the NoEgo runtime/testing\n * deprecation plan for per-export dispositions.\n */\n\nexport { testIoc, TestIocBuilder } from './builder';\nexport type { BuildOptions, TestEnvironment, ConfigMap, MethodsConfig, UseInput } from './builder';\n\nexport { test, ENV_REGISTRY } from './descriptors';\nexport type {\n BehaviorDescriptor,\n CallsDescriptor,\n ExpectationDescriptor,\n MethodDescriptor,\n MethodInspection,\n OriginalDescriptor,\n RawMethodWrapper,\n RecordedCall,\n ReturnsDescriptor,\n ThrowsDescriptor,\n WatchDescriptor,\n} from './descriptors';\n\nexport {\n TestingError,\n MissingIocSeamError,\n UnwatchedInspectionError,\n CallScriptExhaustedError,\n ExpectationOverflowError,\n VerificationError,\n MethodNotCallableError,\n NonObjectMethodTargetError,\n UnknownTokenKeyError,\n AmbiguousNameKeyError,\n TokenIdentitySplitError,\n InvalidDescriptorError,\n} from './errors';\n\nexport { installSeams } from './seams';\nexport type { SeamsConfig, InstalledSeams } from './seams';\n\nexport { testStub, TestStub, stubEntries } from './stub';\nexport type {\n StubEntry, TestOwner, ReplacementOptions, ClassToken, ReplacementClass, ReplacementFunction,\n ExecutableReplacement, LoaderIdentity, LoaderReference,\n} from './stub';\nexport { normalizeTestSelection, selectSourceEntries, SourceSelectionError } from './selection';\nexport type { OwnerSelection, SourceSelectionEntry, SourceSelectionOptions } from './selection';\nexport { createTestScope, withTestScope, TestResourceScope, TestFinalizationError } from './lifecycle';\nexport { resourceCase } from './resource_case';\nexport { vitestCoverage, assertTestLanes, COVERAGE_METRICS, TestCoverageConfigurationError, TestDiscoveryError } from './coverage';\nexport type { VitestCoverageInput, CoverageExclusion, CoverageMetric, CoverageThresholds, TestLaneReport } from './coverage';\nexport { registerTestResource, runInResourceScope } from './resource_context';\nexport type { TestResource, VerifiableTestResource, FinalizationFailure } from './lifecycle';\nexport { resolveTestOverlays, TestOverlayError } from './overlays';\nexport type { TestOwnerCatalog, ResolvedTestOverlay } from './overlays';\nexport { applyTestBindings } from './binding_overlays';\nexport type { TestBindingPlan } from './binding_overlays';\nexport { createTestExecutables } from './executable_overlays';\nexport type { TestExecutableKind, TestExecutableOverlays } from './executable_overlays';\nexport { describeTestBindings } from './binding_catalog';\n","/**\n * `testIoc` — the canonical shared real-IoC test composition builder.\n *\n * Persistent immutable: every fluent call returns a new derived builder\n * sharing the ordered write log structurally. Non-conflicting writes are\n * order-insensitive; the last write to the same effective identity wins on\n * that derived branch. `.build()` is non-consuming and creates fresh runtime,\n * watch, and expectation state (spec 15, PBR-01..15).\n */\n\nimport {\n createContainer,\n ExecutionContext,\n flattenModule,\n LoadAs,\n SCOPED_CONTAINER,\n type ApplicationModule,\n type IContainer,\n} from '@noego/ioc';\n\nimport { ENV_REGISTRY, isDescriptor, type MethodDescriptor } from './descriptors';\nimport { createMethodDecorator, WatchRegistry, tokenLabel } from './method_state';\nimport { InvalidDescriptorError, MissingIocSeamError, UnknownTokenKeyError, AmbiguousNameKeyError,\n} from './errors';\n\nconst COMPONENT_OPTIONS_KEY = Symbol.for('ioc:component:options');\n\ntype Token = unknown;\ntype ClassLike = new (...args: any[]) => any;\n\n/** Config maps accept plain objects (string keys) or Maps (exact tokens). */\n/**\n * Composition input (spec 04 §2). The CANONICAL entry form is an array of\n * tuples — token-first, exact identity:\n *\n * .classes([[ProjectRepository, MemoryProjectRepository]])\n *\n * A `ReadonlyMap<Token, V>` is equivalent (token-keyed). A name-keyed\n * `Record<string, V>` remains accepted as COMPATIBILITY input: string keys\n * resolve against known token display names, fail on unknown names, and\n * fail on ambiguous names (two tokens sharing one display name never\n * collapse into one entry — tokens are identities, names are labels).\n */\nexport type ConfigMap<V> =\n | ReadonlyArray<readonly [Token, V]>\n | ReadonlyMap<Token, V>\n | Record<string, V>;\n\nexport type MethodsConfig = ConfigMap<Record<string, MethodDescriptor> | ReadonlyMap<string, MethodDescriptor>>;\n\nexport type UseInput = ApplicationModule | TestIocBuilder;\n\ntype Write =\n | { op: 'use'; module: ApplicationModule }\n | { op: 'classes'; key: Token; byName: boolean; implementation: ClassLike }\n | { op: 'functions'; key: Token; byName: boolean; factory: (...args: any[]) => any }\n | { op: 'values'; key: Token; byName: boolean; value: unknown }\n | { op: 'methods'; key: Token; byName: boolean; methods: ReadonlyMap<string, MethodDescriptor> };\n\nexport interface BuildOptions {\n /** Optional unresolved composition root. The returned environment owns its disposal. */\n root?: IContainer;\n /** Compose production registrations on the fresh root before the seams. */\n prepare?: (root: IContainer) => void | Promise<void>;\n /** Framework overlays may borrow caller-owned values without closing them. */\n borrowedTokens?: readonly unknown[];\n}\n\nexport interface TestEnvironment {\n readonly root: IContainer;\n get<T>(token: unknown, params?: any[]): Promise<T> | T;\n instance<T>(cls: new (...args: any[]) => T, params?: any[]): Promise<T> | T;\n extend(): IContainer;\n verify(): Promise<void>;\n dispose(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\nfunction* configEntries<V>(config: ConfigMap<V>): Iterable<[Token, boolean, V]> {\n if (Array.isArray(config)) {\n // Canonical tuple form: exact token identity, never name resolution.\n for (const entry of config as ReadonlyArray<readonly [Token, V]>) {\n if (!Array.isArray(entry) || entry.length !== 2) {\n throw new InvalidDescriptorError(\n 'canonical composition entries are [token, value] tuples, e.g. .classes([[Token, Impl]])',\n );\n }\n yield [entry[0], false, entry[1]];\n }\n } else if (config instanceof Map) {\n for (const [key, value] of config) yield [key, false, value];\n } else {\n for (const key of [...Object.getOwnPropertyNames(config), ...Object.getOwnPropertySymbols(config)]) {\n yield [key, typeof key === 'string', (config as any)[key]];\n }\n }\n}\n\nfunction componentScope(cls: any): LoadAs | undefined {\n const options =\n typeof Reflect !== 'undefined' && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(COMPONENT_OPTIONS_KEY, cls)\n : undefined;\n return options?.scope;\n}\n\nfunction lifetimeToLoadAs(lifetime: string): LoadAs {\n if (lifetime === 'singleton') return LoadAs.Singleton;\n if (lifetime === 'scoped') return LoadAs.Scoped;\n return LoadAs.Transient;\n}\n\nexport class TestIocBuilder {\n private constructor(private readonly log: readonly Write[]) {\n Object.freeze(this);\n }\n\n /** @internal */\n static create(inputs: readonly UseInput[]): TestIocBuilder {\n return new TestIocBuilder([]).useAll(inputs);\n }\n\n /** @internal — read by .use(builderPreset) */\n get writes(): readonly Write[] {\n return this.log;\n }\n\n private derive(writes: Write[]): TestIocBuilder {\n return new TestIocBuilder([...this.log, ...writes]);\n }\n\n private useAll(inputs: readonly UseInput[]): TestIocBuilder {\n let builder: TestIocBuilder = this;\n for (const input of inputs) builder = builder.use(input);\n return builder;\n }\n\n /** Apply a reusable composition preset: an ApplicationModule or a builder. */\n use(preset: UseInput): TestIocBuilder {\n if (preset instanceof TestIocBuilder) {\n return this.derive([...preset.writes]);\n }\n return this.derive([{ op: 'use', module: preset }]);\n }\n\n /** Replace the implementation for IoC class tokens in the built environment. */\n classes(config: ConfigMap<ClassLike>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, implementation] of configEntries(config)) {\n if (typeof implementation !== 'function' || !implementation.prototype) {\n throw new InvalidDescriptorError(\n `.classes() value for \"${tokenLabel(key)}\" must be a class constructor.`,\n );\n }\n writes.push({ op: 'classes', key, byName, implementation });\n }\n return this.derive(writes);\n }\n\n /** Replace IoC factory/provider registrations. */\n functions(config: ConfigMap<(...args: any[]) => any>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, factory] of configEntries(config)) {\n if (typeof factory !== 'function') {\n throw new InvalidDescriptorError(`.functions() value for \"${tokenLabel(key)}\" must be a function.`);\n }\n writes.push({ op: 'functions', key, byName, factory });\n }\n return this.derive(writes);\n }\n\n /** Provide/replace IoC value registrations. */\n values(config: ConfigMap<unknown>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, value] of configEntries(config)) {\n writes.push({ op: 'values', key, byName, value });\n }\n return this.derive(writes);\n }\n\n /** Install method behavior/observation descriptors on IoC-managed instances. */\n methods(config: MethodsConfig): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, methodsInput] of configEntries(config)) {\n const methods = new Map<string, MethodDescriptor>();\n const entries =\n methodsInput instanceof Map\n ? methodsInput.entries()\n : Object.entries(methodsInput as Record<string, MethodDescriptor>);\n for (const [name, descriptor] of entries) {\n if (typeof descriptor !== 'function' && !isDescriptor(descriptor)) {\n throw new InvalidDescriptorError(\n `.methods() entry ${tokenLabel(key)}.${name} must be a test.* descriptor or a raw wrapper function.`,\n );\n }\n methods.set(name, descriptor);\n }\n writes.push({ op: 'methods', key, byName, methods });\n }\n return this.derive(writes);\n }\n\n /**\n * Materialize a fresh, isolated real-IoC environment. Non-consuming.\n *\n * `prepare` runs on the fresh root BEFORE this builder's registrations and\n * the method-control decorator are applied: the place for an application's\n * production composition, so every declared seam shadows what production\n * registered for the same token, and instances constructed later are\n * decorated. Instances `prepare` constructs itself are not decorated.\n */\n async build(options: BuildOptions = {}): Promise<TestEnvironment> {\n const root = options.root ?? createContainer();\n try {\n return await this.buildOnRoot(root, options);\n } catch (primary) {\n try { await root.dispose(); }\n catch (cleanup) {\n throw new AggregateError([primary, cleanup], 'Test IoC build failed and rollback failed', { cause: primary });\n }\n throw primary;\n }\n }\n\n private async buildOnRoot(root: IContainer, options: BuildOptions): Promise<TestEnvironment> {\n if (typeof (root as any).setInstanceDecorator !== 'function') {\n throw new MissingIocSeamError();\n }\n await options.prepare?.(root);\n\n // ---- Materialize the ordered log: last write wins per effective identity\n // Known tokens (for resolving string keys of classes/functions/values)\n const knownByName = new Map<string, Token>();\n /** Display names claimed by more than one distinct token (spec 04 §5/§17). */\n const ambiguousNames = new Set<string>();\n const knownLifetimes = new Map<Token, LoadAs>();\n const note = (token: Token, loadAs: LoadAs | undefined) => {\n const name =\n typeof token === 'function' && (token as any).name\n ? (token as any).name as string\n : typeof token === 'string'\n ? token\n : null;\n if (name !== null) {\n const existing = knownByName.get(name);\n if (existing !== undefined && existing !== token) ambiguousNames.add(name);\n knownByName.set(name, token);\n }\n if (loadAs !== undefined) knownLifetimes.set(token, loadAs);\n };\n\n type Effective =\n | { space: 'class'; token: Token; implementation: ClassLike; loadAs?: LoadAs }\n | { space: 'factory'; token: Token; factory: (...args: any[]) => any; loadAs?: LoadAs; deps?: Token[] }\n | { space: 'value'; token: Token; value: unknown };\n\n // ordered map: identity → latest effective write (Map preserves first-write\n // position which is fine — later writes replace content, LWW)\n const effective = new Map<Token, Effective>();\n const methodWrites: { key: Token; byName: boolean; methods: Map<string, MethodDescriptor> }[] = [];\n\n const resolveKey = (key: Token, byName: boolean, space: string): Token => {\n if (!byName) return key;\n if (ambiguousNames.has(key as string)) {\n throw new AmbiguousNameKeyError(key as string, space);\n }\n const known = knownByName.get(key as string);\n if (known !== undefined) return known;\n if (space === 'values' || space === 'functions') return key; // string tokens are first-class\n throw new UnknownTokenKeyError(key as string, space, [...knownByName.keys()]);\n };\n\n for (const write of this.log) {\n switch (write.op) {\n case 'use': {\n for (const reg of flattenModule(write.module)) {\n const loadAs = lifetimeToLoadAs(reg.lifetime);\n note(reg.token, loadAs);\n if (reg.kind === 'class') {\n note(reg.implementation as Token, loadAs);\n effective.set(reg.token, {\n space: 'class',\n token: reg.token,\n implementation: reg.implementation as ClassLike,\n loadAs,\n });\n knownLifetimes.set(reg.token, loadAs);\n knownLifetimes.set(reg.implementation as Token, loadAs);\n } else if (reg.kind === 'factory') {\n effective.set(reg.token, {\n space: 'factory',\n token: reg.token,\n factory: reg.implementation as (...args: any[]) => any,\n loadAs,\n deps: [...reg.dependencies],\n });\n } else {\n effective.set(reg.token, { space: 'value', token: reg.token, value: reg.implementation });\n knownLifetimes.set(reg.token, LoadAs.Singleton);\n }\n }\n break;\n }\n case 'classes': {\n const token = resolveKey(write.key, write.byName, 'classes');\n note(write.implementation, undefined);\n if (!write.byName) note(token, undefined);\n effective.set(token, {\n space: 'class',\n token,\n implementation: write.implementation,\n // Lifetime priority: the replacement's own @Component scope, then\n // the lifetime the composition already knows for the token, then\n // the TOKEN class's declared @Component scope — a plain stub\n // class replacing a Singleton-scoped production service must not\n // silently degrade to Transient (captive-lifetime validation\n // would reject the production dependents).\n loadAs:\n componentScope(write.implementation)\n ?? knownLifetimes.get(token)\n ?? componentScope(token),\n });\n break;\n }\n case 'functions': {\n const token = resolveKey(write.key, write.byName, 'functions');\n const prior = effective.get(token);\n effective.set(token, {\n space: 'factory',\n token,\n factory: write.factory,\n // preserve configured lifetime unless the scenario overrides it\n loadAs: prior && prior.space === 'factory' ? prior.loadAs : knownLifetimes.get(token),\n deps: prior && prior.space === 'factory' ? prior.deps : undefined,\n });\n note(token, undefined);\n break;\n }\n case 'values': {\n const token = resolveKey(write.key, write.byName, 'values');\n effective.set(token, { space: 'value', token, value: write.value });\n note(token, LoadAs.Singleton);\n break;\n }\n case 'methods': {\n if (write.byName && ambiguousNames.has(write.key as string)) {\n throw new AmbiguousNameKeyError(write.key as string, 'methods');\n }\n const token = write.byName && knownByName.has(write.key as string)\n ? knownByName.get(write.key as string)!\n : write.key;\n methodWrites.push({\n key: token,\n byName: write.byName && !knownByName.has(write.key as string),\n methods: new Map(write.methods),\n });\n break;\n }\n }\n }\n\n // ---- Apply effective registrations to the fresh root\n const borrowed = new Set(options.borrowedTokens);\n for (const entry of effective.values()) {\n if (entry.space === 'class') {\n this.registerClassBinding(root, entry.token, entry.implementation, entry.loadAs);\n } else if (entry.space === 'factory') {\n root.registerFunction(entry.token, entry.factory, {\n loadAs: entry.loadAs,\n param: entry.deps,\n ...(borrowed.has(entry.token) ? { owned: false } : {}),\n } as any);\n } else {\n const value = entry.value;\n root.registerFunction(entry.token, () => value, {\n loadAs: LoadAs.Singleton,\n ...(borrowed.has(entry.token) ? { owned: false } : {}),\n } as any);\n }\n }\n\n // ---- Fresh watch/expectation state + the ioc decoration seam\n const registry = new WatchRegistry();\n // merge method writes: LWW per (entry key, method), deep-merge per token\n const mergedMethods = new Map<Token, { byName: boolean; methods: Map<string, MethodDescriptor> }>();\n for (const write of methodWrites) {\n const existing = mergedMethods.get(write.key);\n if (existing) {\n for (const [name, descriptor] of write.methods) existing.methods.set(name, descriptor);\n } else {\n mergedMethods.set(write.key, { byName: write.byName, methods: new Map(write.methods) });\n }\n }\n for (const [key, { byName, methods }] of mergedMethods) {\n registry.addEntry({ key, byName, methods });\n }\n (root as any).setInstanceDecorator(createMethodDecorator(registry));\n\n const env: TestEnvironment = {\n root: root as IContainer,\n get: (token, params) => ExecutionContext.run(root, () => root.get(token as any, params)),\n instance: (cls, params) => ExecutionContext.run(root, () => root.instance(cls, params)),\n extend: () => root.extend() as IContainer,\n verify: async () => registry.verify(),\n dispose: () => root.dispose(),\n [ENV_REGISTRY]: registry,\n };\n return env;\n }\n\n /**\n * Register a class binding. When token === implementation this is a plain\n * class registration. Otherwise an alias factory resolves the implementation\n * through real IoC, mirroring the implementation's effective lifetime so\n * lifetime validation (captive-lifetime checks) stays honest.\n */\n private registerClassBinding(\n root: IContainer,\n token: Token,\n implementation: ClassLike,\n configuredLoadAs?: LoadAs,\n ): void {\n const loadAs = configuredLoadAs ?? componentScope(implementation) ?? LoadAs.Transient;\n root.registerClass(implementation as any, configuredLoadAs !== undefined ? ({ loadAs } as any) : undefined);\n if (token === implementation) return;\n\n if (loadAs === LoadAs.Singleton) {\n root.registerFunction(token, () => root.get(implementation as any), {\n loadAs: LoadAs.Singleton,\n owned: false,\n } as any);\n } else {\n root.registerFunction(token, (scope: IContainer) => scope.get(implementation as any), {\n loadAs,\n param: [SCOPED_CONTAINER],\n owned: false,\n } as any);\n }\n }\n}\n\n/** Create a persistent immutable real-IoC test composition builder. */\nexport function testIoc(...inputs: UseInput[]): TestIocBuilder {\n return TestIocBuilder.create(inputs);\n}\n","/**\n * Diagnostics are first-class: every error names the real token/method and\n * what was expected vs what happened, never only internal wrapper machinery.\n */\n\nexport class TestingError extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n }\n}\n\n/** Thrown at build() when the installed @noego/ioc lacks the decoration seam. */\nexport class MissingIocSeamError extends TestingError {\n constructor() {\n super(\n '@noego/testing requires an @noego/ioc version that provides ' +\n 'Container.setInstanceDecorator (>= 0.5.x with the instance-decoration seam). ' +\n 'Upgrade @noego/ioc.',\n );\n }\n}\n\n/** test.inspect() on a method that is not watched in this environment. */\nexport class UnwatchedInspectionError extends TestingError {\n constructor(token: string, method: string) {\n super(\n `Method \"${method}\" on ${token} is not watched in this environment. ` +\n 'Only watched methods are inspectable — install test.watch() or any ' +\n 'test.* behavior/expectation descriptor for it.',\n );\n }\n}\n\n/** A call arrived after a test.calls([...]) script was fully consumed. */\nexport class CallScriptExhaustedError extends TestingError {\n constructor(token: string, method: string, scriptLength: number, callIndex: number) {\n super(\n `Call #${callIndex} to ${token}.${method} exceeds its test.calls() script ` +\n `of ${scriptLength} ${scriptLength === 1 ? 'entry' : 'entries'}.`,\n );\n }\n}\n\n/** An exact expectation (once/times/never) was exceeded at call time. */\nexport class ExpectationOverflowError extends TestingError {\n constructor(token: string, method: string, expected: number, attempted: number) {\n super(\n expected === 0\n ? `${token}.${method} was expected never to be called, but it was invoked.`\n : `${token}.${method} was expected exactly ${expected} ` +\n `${expected === 1 ? 'call' : 'calls'}, but call #${attempted} arrived.`,\n );\n }\n}\n\n/** Aggregated under-count failures reported by env.verify(). */\nexport class VerificationError extends TestingError {\n constructor(failures: readonly { token: string; method: string; expected: number; actual: number }[]) {\n super(\n 'Exact method expectations were not satisfied:\\n' +\n failures\n .map(\n (f) =>\n ` - ${f.token}.${f.method}: expected exactly ${f.expected} ` +\n `${f.expected === 1 ? 'call' : 'calls'}, observed ${f.actual}`,\n )\n .join('\\n'),\n );\n }\n}\n\n/** .methods configured for a token whose resolved value has no such callable method. */\nexport class MethodNotCallableError extends TestingError {\n constructor(token: string, method: string) {\n super(\n `Cannot install a test.* descriptor on ${token}.${method}: the resolved ` +\n 'instance has no callable method with that name.',\n );\n }\n}\n\n/** .methods configured for a token that resolved to a non-object value. */\nexport class NonObjectMethodTargetError extends TestingError {\n constructor(token: string) {\n super(\n `.methods() is configured for ${token}, but that token resolved to a ` +\n 'non-object value. Method descriptors apply only to IoC-managed instances.',\n );\n }\n}\n\n/** A string configuration key could not be resolved to a known IoC token. */\nexport class UnknownTokenKeyError extends TestingError {\n constructor(key: string, space: string, known: readonly string[]) {\n super(\n `Unknown ${space} key \"${key}\" — it does not match any token known to this ` +\n 'builder. Pass the class/token itself via a Map, or include the ' +\n 'registration through .use(...). Known tokens: ' +\n (known.length ? known.join(', ') : '(none)'),\n );\n }\n}\n\n/** Invalid descriptor construction (e.g. test.times(-1)). */\nexport class InvalidDescriptorError extends TestingError {}\n\n/**\n * A name-keyed compatibility entry referred to a display name claimed by\n * two or more distinct tokens. Tokens are identities; names are labels —\n * pass the exact token in canonical tuple form instead (spec 04 §5).\n */\nexport class AmbiguousNameKeyError extends TestingError {\n constructor(name: string, space: string) {\n super(\n `.${space}() key \"${name}\" is ambiguous: multiple distinct tokens share that display name. ` +\n `Use the canonical tuple form with the exact token: .${space}([[TheToken, ...]]).`,\n );\n this.name = 'AmbiguousNameKeyError';\n }\n}\n\n\n/**\n * A .methods() class token never matched any constructed instance while a\n * DIFFERENT class with the same display name did construct — the configured\n * behavior silently did not apply. Usual cause: two module registries loaded\n * the same source file (e.g. a vitest test file's import vs a framework\n * harness's native import of the production graph); fix by routing the\n * harness's imports through the caller's registry (testApp:\n * `.importer((p) => import(p))`) or by passing the token the graph actually\n * uses.\n */\nexport class TokenIdentitySplitError extends TestingError {\n constructor(names: readonly string[]) {\n super(\n `token identity split: .methods() entr${names.length === 1 ? 'y' : 'ies'} for ` +\n `${names.map((name) => `\"${name}\"`).join(', ')} never matched a constructed instance, ` +\n `but a DIFFERENT class with the same name was constructed. Two module registries ` +\n `have loaded the same class file (test-file import vs harness graph import) — the ` +\n `configured behavior did not apply. Route the harness's imports through your ` +\n `registry (e.g. testApp .importer((p) => import(p))) or pass the exact token the graph uses.`,\n );\n this.name = 'TokenIdentitySplitError';\n }\n}\n","/**\n * Lowercase `test.*` descriptors — immutable frozen values.\n *\n * Descriptors carry NO mutable state (no cursors, no counters, no histories);\n * all mutable invocation state lives in the built environment, so one\n * descriptor value is safe to share across builders and repeated builds.\n */\n\nimport { InvalidDescriptorError } from './errors';\n\nexport const DESCRIPTOR = Symbol.for('noego:testing:descriptor');\n\n/** A raw custom method wrapper: (original) => replacement. NOT auto-watched. */\nexport type RawMethodWrapper = (\n original: (...args: any[]) => any,\n) => (...args: any[]) => any;\n\nexport interface ReturnsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'returns';\n readonly value: unknown;\n}\n\nexport interface ThrowsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'throws';\n readonly error: unknown;\n}\n\nexport interface OriginalDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'original';\n}\n\nexport interface CallsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'calls';\n readonly script: readonly BehaviorDescriptor[];\n}\n\nexport type BehaviorDescriptor =\n | ReturnsDescriptor\n | ThrowsDescriptor\n | OriginalDescriptor\n | CallsDescriptor;\n\nexport interface WatchDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'watch';\n readonly wrapper?: RawMethodWrapper;\n}\n\nexport interface ExpectationDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'expect';\n /** Exact required call count; 0 for never(). */\n readonly expected: number;\n /** Behavior used for allowed calls; undefined = original effective behavior. */\n readonly behavior?: BehaviorDescriptor;\n}\n\n/** Everything installable through .methods({...}). */\nexport type MethodDescriptor =\n | BehaviorDescriptor\n | WatchDescriptor\n | ExpectationDescriptor\n | RawMethodWrapper;\n\nexport function isDescriptor(value: unknown): value is Exclude<MethodDescriptor, RawMethodWrapper> {\n return typeof value === 'object' && value !== null && (value as any)[DESCRIPTOR] === true;\n}\n\nfunction frozen<T extends object>(value: T): T {\n return Object.freeze(value);\n}\n\nfunction assertBehavior(value: unknown, where: string): asserts value is BehaviorDescriptor {\n if (!isDescriptor(value) || !['returns', 'throws', 'original', 'calls'].includes((value as any).kind)) {\n throw new InvalidDescriptorError(\n `${where} requires a behavior descriptor (test.returns/throws/original/calls).`,\n );\n }\n}\n\nexport const test = {\n /** Return the supplied value when the method is called. Auto-watches. */\n returns(value: unknown): ReturnsDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'returns' as const, value });\n },\n\n /** Throw/reject with the supplied error. Auto-watches. */\n throws(error: unknown): ThrowsDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'throws' as const, error });\n },\n\n /** Invoke the original effective method. Auto-watches. */\n original(): OriginalDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'original' as const });\n },\n\n /**\n * Per-invocation behavior script: call 1 uses entry 1, and so on. A call\n * after exhaustion fails immediately. Unused entries do not fail verification.\n */\n calls(script: readonly BehaviorDescriptor[]): CallsDescriptor {\n if (!Array.isArray(script)) {\n throw new InvalidDescriptorError('test.calls() requires an array of behavior descriptors.');\n }\n script.forEach((entry, i) => assertBehavior(entry, `test.calls() entry #${i + 1}`));\n return frozen({ [DESCRIPTOR]: true as const, kind: 'calls' as const, script: Object.freeze([...script]) });\n },\n\n /**\n * Keep original behavior and record calls. With a raw wrapper argument, the\n * wrapper's behavior runs and is recorded.\n */\n watch(wrapper?: RawMethodWrapper): WatchDescriptor {\n if (wrapper !== undefined && typeof wrapper !== 'function') {\n throw new InvalidDescriptorError('test.watch() accepts only a raw wrapper function.');\n }\n return frozen({ [DESCRIPTOR]: true as const, kind: 'watch' as const, wrapper });\n },\n\n /** Require exactly one call; with no behavior, the original runs. */\n once(behavior?: BehaviorDescriptor): ExpectationDescriptor {\n if (behavior !== undefined) assertBehavior(behavior, 'test.once()');\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: 1, behavior });\n },\n\n /** Require exactly `count` calls; with no behavior, the original runs. */\n times(count: number, behavior?: BehaviorDescriptor): ExpectationDescriptor {\n if (!Number.isInteger(count) || count < 0) {\n throw new InvalidDescriptorError(\n `test.times() requires a non-negative integer count, received ${String(count)}.`,\n );\n }\n if (behavior !== undefined) assertBehavior(behavior, 'test.times()');\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: count, behavior });\n },\n\n /** Require zero calls; the first invocation fails and skips the original. */\n never(): ExpectationDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: 0 });\n },\n\n /** Read the recorded history for a watched method in one environment. */\n inspect(environment: unknown, token: unknown, method: string): MethodInspection {\n const registry = (environment as any)?.[ENV_REGISTRY];\n if (!registry) {\n throw new InvalidDescriptorError(\n 'test.inspect() requires a built @noego/testing environment as its first argument.',\n );\n }\n return registry.inspect(token, method);\n },\n};\n\nObject.freeze(test);\n\n/** Symbol under which a built environment exposes its watch registry. */\nexport const ENV_REGISTRY = Symbol.for('noego:testing:env-registry');\n\nexport interface RecordedCall {\n /** 1-based invocation index in this environment. */\n readonly index: number;\n readonly args: readonly unknown[];\n /** Present once the call returned (resolved value for async methods). */\n readonly result?: unknown;\n /** Present once the call threw/rejected. */\n readonly error?: unknown;\n /** True while an async outcome is still pending. */\n readonly pending: boolean;\n readonly timestamp: number;\n}\n\nexport interface MethodInspection {\n readonly count: number;\n readonly calls: readonly RecordedCall[];\n}\n","/**\n * Environment-owned method behavior/observation runtime.\n *\n * All mutable state (histories, expectation counters, calls-script cursors)\n * lives here, created fresh at every build(). Descriptors stay immutable.\n */\n\nimport {\n type BehaviorDescriptor,\n type ExpectationDescriptor,\n type MethodDescriptor,\n type MethodInspection,\n type RawMethodWrapper,\n type RecordedCall,\n isDescriptor,\n} from './descriptors';\nimport {\n CallScriptExhaustedError,\n TokenIdentitySplitError,\n ExpectationOverflowError,\n MethodNotCallableError,\n NonObjectMethodTargetError,\n UnwatchedInspectionError,\n VerificationError,\n} from './errors';\n\nconst CONTEXT_WRAPPED = Symbol.for('ioc:context-wrapped');\nconst CONTEXT_OWNER = Symbol.for('ioc:context-owner');\n\nexport function tokenLabel(token: unknown): string {\n if (typeof token === 'function') return (token as { name?: string }).name || '[anonymous class]';\n if (typeof token === 'symbol') return String(token);\n return String(token);\n}\n\ninterface MutableCall {\n index: number;\n args: readonly unknown[];\n result?: unknown;\n error?: unknown;\n pending: boolean;\n timestamp: number;\n}\n\nexport class MethodState {\n readonly calls: MutableCall[] = [];\n /** Actual invocation count (includes the call currently executing). */\n actual = 0;\n /** Cursor into a test.calls() script. */\n scriptCursor = 0;\n\n constructor(\n readonly tokenName: string,\n readonly method: string,\n readonly descriptor: Exclude<MethodDescriptor, RawMethodWrapper>,\n ) {}\n\n get expectation(): ExpectationDescriptor | undefined {\n return this.descriptor.kind === 'expect' ? this.descriptor : undefined;\n }\n\n inspection(): MethodInspection {\n return {\n count: this.calls.length,\n calls: this.calls.map((c) => ({ ...c, args: [...c.args] }) as RecordedCall),\n };\n }\n}\n\n/** One method-config entry: how it was keyed, and its per-method descriptors. */\nexport interface MethodConfigEntry {\n /** Exact token (class/symbol/string) or a name string matched lazily. */\n readonly key: unknown;\n readonly byName: boolean;\n readonly methods: ReadonlyMap<string, MethodDescriptor>;\n}\n\nexport class WatchRegistry {\n /** entry-identity → method → state. Entries share states across instances. */\n private readonly states = new Map<unknown, Map<string, MethodState>>();\n private readonly nameIndex = new Map<string, unknown>();\n private readonly entries: MethodConfigEntry[] = [];\n /** Class-token entries that identity-matched at least one construction. */\n private readonly matchedEntryKeys = new Set<unknown>();\n /** Constructed class tokens that matched NO entry, by display name. */\n private readonly unmatchedConstructedByName = new Map<string, unknown>();\n\n addEntry(entry: MethodConfigEntry): void {\n this.entries.push(entry);\n const byMethod = new Map<string, MethodState>();\n for (const [method, descriptor] of entry.methods) {\n if (typeof descriptor === 'function') continue; // raw wrapper: unwatched, no state\n byMethod.set(method, new MethodState(this.entryLabel(entry), method, descriptor));\n }\n this.states.set(entry.key, byMethod);\n if (entry.byName) this.nameIndex.set(entry.key as string, entry.key);\n else if (typeof entry.key === 'function' && (entry.key as any).name) {\n this.nameIndex.set((entry.key as any).name, entry.key);\n }\n }\n\n private entryLabel(entry: MethodConfigEntry): string {\n return entry.byName ? String(entry.key) : tokenLabel(entry.key);\n }\n\n /** Entries applying to a resolving token (exact identity or name match). */\n matchEntries(token: unknown): MethodConfigEntry[] {\n const name = typeof token === 'function' ? (token as any).name : typeof token === 'string' ? token : undefined;\n const matched = this.entries.filter(\n (entry) => entry.key === token || (entry.byName && name !== undefined && entry.key === name),\n );\n // Split-registry tripwire bookkeeping (spec 04 §17 \"duplicate\n // human-readable token names without identity collision\"): remember which\n // class-token entries genuinely bound, and which constructions bound\n // nothing — verify() cross-references the two by display name.\n if (matched.length) {\n for (const entry of matched) this.matchedEntryKeys.add(entry.key);\n } else if (typeof token === 'function' && name) {\n this.unmatchedConstructedByName.set(name, token);\n }\n return matched;\n }\n\n state(entryKey: unknown, method: string): MethodState | undefined {\n return this.states.get(entryKey)?.get(method);\n }\n\n inspect(token: unknown, method: string): MethodInspection {\n const label = tokenLabel(token);\n const keys: unknown[] = [token];\n const name = typeof token === 'function' ? (token as any).name : typeof token === 'string' ? token : undefined;\n if (name !== undefined && this.nameIndex.has(name)) keys.push(this.nameIndex.get(name));\n for (const key of keys) {\n const state = this.states.get(key)?.get(method);\n if (state) return state.inspection();\n }\n throw new UnwatchedInspectionError(label, method);\n }\n\n /**\n * Class-token entries that never identity-matched a construction while a\n * DIFFERENT class with the same display name did construct. This is the\n * split-module-registry signature (a test-file class object vs the graph's\n * own load of the same file) — or two genuinely distinct same-named tokens\n * where the configured one never resolved. Either way the configured\n * behavior silently did not apply, which must be loud.\n */\n private identitySplits(): { name: string; entryToken: unknown }[] {\n const splits: { name: string; entryToken: unknown }[] = [];\n for (const entry of this.entries) {\n if (entry.byName || typeof entry.key !== 'function') continue;\n if (this.matchedEntryKeys.has(entry.key)) continue;\n const name = (entry.key as { name?: string }).name;\n if (!name) continue;\n const constructed = this.unmatchedConstructedByName.get(name);\n if (constructed !== undefined && constructed !== entry.key) {\n splits.push({ name, entryToken: entry.key });\n }\n }\n return splits;\n }\n\n /** Repeatable snapshot check of all exact expectations. */\n verify(): void {\n const splits = this.identitySplits();\n if (splits.length) {\n throw new TokenIdentitySplitError(splits.map((split) => split.name));\n }\n const failures: { token: string; method: string; expected: number; actual: number }[] = [];\n for (const byMethod of this.states.values()) {\n for (const state of byMethod.values()) {\n const expectation = state.expectation;\n if (!expectation) continue;\n if (state.actual !== expectation.expected) {\n failures.push({\n token: state.tokenName,\n method: state.method,\n expected: expectation.expected,\n actual: state.actual,\n });\n }\n }\n }\n if (failures.length) throw new VerificationError(failures);\n }\n}\n\nfunction isPromiseLike(value: unknown): value is Promise<unknown> {\n return !!value && typeof (value as any).then === 'function';\n}\n\nfunction recordOutcome(call: MutableCall, outcome: unknown, threw: boolean): unknown {\n if (!threw && isPromiseLike(outcome)) {\n call.pending = true;\n outcome.then(\n (value) => {\n call.result = value;\n call.pending = false;\n },\n (error) => {\n call.error = error;\n call.pending = false;\n },\n );\n return outcome;\n }\n call.pending = false;\n if (threw) call.error = outcome;\n else call.result = outcome;\n return outcome;\n}\n\n/**\n * Build the ioc instance decorator for one environment.\n *\n * Identity-stable (WeakMap), preserves sync/async call shape and `this`\n * binding, forwards the ioc context symbols by delegating to the underlying\n * (context-wrapped) target for everything unconfigured.\n */\nexport function createMethodDecorator(registry: WatchRegistry): (instance: any, token: any) => any {\n const wrappers = new WeakMap<object, any>();\n\n return function decorate(instance: any, token: any): any {\n const entries = registry.matchEntries(token);\n if (entries.length === 0) return instance;\n\n if (instance === null || (typeof instance !== 'object' && typeof instance !== 'function')) {\n throw new NonObjectMethodTargetError(tokenLabel(token));\n }\n\n if (wrappers.has(instance)) return wrappers.get(instance);\n\n // Effective per-method config: entries merge in write order, LWW per method\n const effective = new Map<string, { entryKey: unknown; descriptor: MethodDescriptor }>();\n for (const entry of entries) {\n for (const [method, descriptor] of entry.methods) {\n effective.set(method, { entryKey: entry.key, descriptor });\n }\n }\n\n // Validate configured methods exist and are callable\n for (const method of effective.keys()) {\n if (typeof instance[method] !== 'function') {\n throw new MethodNotCallableError(tokenLabel(token), method);\n }\n }\n\n const methodCache = new Map<string, (...args: any[]) => any>();\n\n const proxy = new Proxy(instance, {\n get(target, prop, receiver) {\n if (typeof prop === 'string' && effective.has(prop)) {\n let wrapped = methodCache.get(prop);\n if (!wrapped) {\n const { entryKey, descriptor } = effective.get(prop)!;\n wrapped = buildMethodWrapper(target, prop, descriptor, registry.state(entryKey, prop));\n methodCache.set(prop, wrapped);\n }\n return wrapped;\n }\n // Everything else (including ioc context symbols) delegates to the\n // underlying — usually context-wrapped — target.\n if (prop === CONTEXT_WRAPPED || prop === CONTEXT_OWNER) return (target as any)[prop];\n return Reflect.get(target, prop, receiver);\n },\n });\n\n wrappers.set(instance, proxy);\n return proxy;\n };\n}\n\nfunction buildMethodWrapper(\n target: any,\n method: string,\n descriptor: MethodDescriptor,\n state: MethodState | undefined,\n): (...args: any[]) => any {\n // The original effective method, read through the underlying target so the\n // ioc context proxy still owns context entry for real invocations.\n const callOriginal = (self: any, args: any[]) => {\n const fn = target[method];\n return fn.apply(self === undefined ? target : self, args);\n };\n\n // Raw custom wrapper: installed as-is, NOT watched, no recording.\n if (typeof descriptor === 'function') {\n const replacement = descriptor((...args: any[]) => callOriginal(target, args));\n return function (this: any, ...args: any[]) {\n return replacement.apply(this, args);\n };\n }\n\n if (!isDescriptor(descriptor)) {\n // Should be unreachable: builder validates descriptors on write.\n throw new TypeError(`Invalid method descriptor for ${method}`);\n }\n\n return function (this: any, ...args: any[]) {\n if (!state) throw new TypeError(`Missing method state for ${method}`);\n\n const expectation = state.expectation;\n const attempted = state.actual + 1;\n\n // Overflow fails immediately and never runs behavior/original\n if (expectation && attempted > expectation.expected) {\n state.actual = attempted;\n throw new ExpectationOverflowError(state.tokenName, method, expectation.expected, attempted);\n }\n\n state.actual = attempted;\n const call: MutableCall = {\n index: attempted,\n args: [...args],\n pending: false,\n timestamp: Date.now(),\n };\n state.calls.push(call);\n\n // Effective behavior for this invocation\n let behavior: BehaviorDescriptor | 'original-effective' | RawMethodWrapper;\n const base =\n descriptor.kind === 'expect'\n ? (descriptor.behavior ?? 'original-effective')\n : descriptor.kind === 'watch'\n ? (descriptor.wrapper ?? 'original-effective')\n : descriptor;\n\n if (base !== 'original-effective' && typeof base !== 'function' && base !== undefined && base.kind === 'calls') {\n if (state.scriptCursor >= base.script.length) {\n throw new CallScriptExhaustedError(state.tokenName, method, base.script.length, attempted);\n }\n behavior = base.script[state.scriptCursor]!;\n state.scriptCursor += 1;\n } else {\n behavior = base;\n }\n\n try {\n let outcome: unknown;\n if (behavior === 'original-effective') {\n outcome = callOriginal(this, args);\n } else if (typeof behavior === 'function') {\n // test.watch(rawWrapper): wrapper behavior runs and is recorded\n outcome = behavior((...inner: any[]) => callOriginal(this, inner)).apply(this, args);\n } else if (behavior.kind === 'returns') {\n outcome = behavior.value;\n } else if (behavior.kind === 'throws') {\n throw behavior.error;\n } else if (behavior.kind === 'original') {\n outcome = callOriginal(this, args);\n } else {\n throw new TypeError(`Nested test.calls() scripts are not supported (${method}).`);\n }\n return recordOutcome(call, outcome, false);\n } catch (error) {\n recordOutcome(call, error, true);\n throw error;\n }\n };\n}\n","/**\n * `installSeams` — apply the canonical substitution language (classes /\n * values / methods, exact tokens, `test.*` descriptors) to an EXISTING\n * container instead of a fresh `testIoc()` root.\n *\n * This is the seam surface for composed harnesses (application slices,\n * backend harnesses) that own their container construction but must speak\n * the same substitution language as every other tier: one vocabulary, one\n * verify contract, no harness-specific stubbing options.\n *\n * The returned handle carries the same watch registry marker as a\n * `TestEnvironment`, so `test.inspect(handle, Token, 'method')` works\n * unchanged.\n */\nimport { LoadAs, SCOPED_CONTAINER, type IContainer } from '@noego/ioc';\nimport { ENV_REGISTRY, isDescriptor, type MethodDescriptor } from './descriptors';\nimport { createMethodDecorator, WatchRegistry, tokenLabel } from './method_state';\nimport { InvalidDescriptorError, MissingIocSeamError } from './errors';\nimport type { ConfigMap, MethodsConfig } from './builder';\n\nconst COMPONENT_OPTIONS_KEY = Symbol.for('ioc:component:options');\n\ntype Token = unknown;\ntype ClassLike = new (...args: any[]) => any;\n\nexport interface SeamsConfig {\n classes?: ConfigMap<ClassLike>;\n values?: ConfigMap<unknown>;\n methods?: MethodsConfig;\n}\n\nexport interface InstalledSeams {\n /** Finalize call-count expectations (same semantics as env.verify()). */\n verify(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\nfunction componentScope(cls: any): LoadAs | undefined {\n const options =\n typeof Reflect !== 'undefined' && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(COMPONENT_OPTIONS_KEY, cls)\n : undefined;\n return options?.scope;\n}\n\nfunction* tupleEntries<V>(config: ConfigMap<V>, space: string): Iterable<[Token, V]> {\n if (Array.isArray(config)) {\n for (const entry of config as ReadonlyArray<readonly [Token, V]>) {\n if (!Array.isArray(entry) || entry.length !== 2) {\n throw new InvalidDescriptorError(\n `canonical ${space} entries are [token, value] tuples, e.g. .${space}([[Token, Impl]])`,\n );\n }\n yield [entry[0], entry[1]];\n }\n } else if (config instanceof Map) {\n for (const [key, value] of config) yield [key, value];\n } else {\n throw new InvalidDescriptorError(\n `installSeams accepts only exact-token ${space} entries (tuple array or Map); ` +\n 'name-keyed records need the composition knowledge only testIoc() has.',\n );\n }\n}\n\n/**\n * Register a class replacement honoring the replacement's own @Component\n * scope, falling back to the token class's declared scope — a plain stub\n * replacing a Singleton-scoped production service must not silently degrade\n * to Transient (mirrors TestIocBuilder.registerClassBinding).\n */\nfunction registerClassBinding(root: IContainer, token: Token, implementation: ClassLike): void {\n const loadAs = componentScope(implementation) ?? componentScope(token) ?? LoadAs.Singleton;\n (root as any).registerClass(implementation, { loadAs });\n if (token === implementation) return;\n if (loadAs === LoadAs.Singleton) {\n (root as any).registerFunction(token, () => (root as any).get(implementation), {\n loadAs: LoadAs.Singleton,\n });\n } else {\n (root as any).registerFunction(token, (scope: IContainer) => (scope as any).get(implementation), {\n loadAs,\n param: [SCOPED_CONTAINER],\n });\n }\n}\n\nexport function installSeams(root: IContainer, config: SeamsConfig): InstalledSeams {\n if (typeof (root as any).setInstanceDecorator !== 'function') {\n throw new MissingIocSeamError();\n }\n\n for (const [token, implementation] of tupleEntries(config.classes ?? [], 'classes')) {\n registerClassBinding(root, token, implementation);\n }\n for (const [token, value] of tupleEntries(config.values ?? [], 'values')) {\n (root as any).registerFunction(token, () => value, { loadAs: LoadAs.Singleton });\n }\n\n const registry = new WatchRegistry();\n // Merge per token (LWW per method) before registering: a registry entry per\n // tuple would let a later tuple for the same token shadow the earlier one's\n // method state (mirrors TestIocBuilder's mergedMethods).\n const mergedMethods = new Map<Token, Map<string, MethodDescriptor>>();\n for (const [token, methodsInput] of tupleEntries(config.methods ?? [], 'methods')) {\n const methods = mergedMethods.get(token) ?? new Map<string, MethodDescriptor>();\n const entries =\n methodsInput instanceof Map\n ? methodsInput.entries()\n : Object.entries(methodsInput as Record<string, MethodDescriptor>);\n for (const [name, descriptor] of entries) {\n if (typeof descriptor !== 'function' && !isDescriptor(descriptor)) {\n throw new InvalidDescriptorError(\n `.methods entry ${tokenLabel(token)}.${name} must be a test.* descriptor or a raw wrapper function.`,\n );\n }\n methods.set(name, descriptor);\n }\n mergedMethods.set(token, methods);\n }\n for (const [key, methods] of mergedMethods) {\n registry.addEntry({ key, byName: false, methods });\n }\n (root as any).setInstanceDecorator(createMethodDecorator(registry));\n\n return {\n verify: async () => registry.verify(),\n [ENV_REGISTRY]: registry,\n };\n}\n","import { isDescriptor, type MethodDescriptor } from './descriptors';\nimport { InvalidDescriptorError } from './errors';\n\nexport type TestOwner = 'server' | 'client' | 'main' | 'renderer';\nexport interface ReplacementOptions { readonly owner?: TestOwner }\nexport interface LoaderReference { readonly path: string; readonly export: string }\nexport type LoaderIdentity = string | LoaderReference;\nexport type ClassToken<T = any> = abstract new (...args: any[]) => T;\nexport type ReplacementClass<T = any> = new (...args: any[]) => T;\nexport type ReplacementFunction = (...args: any[]) => any;\nexport type ExecutableReplacement = ReplacementFunction | MethodDescriptor;\n\ninterface EntryBase {\n readonly owner?: TestOwner;\n /** Fluent entry index, prefixed by each enclosing .use entry index. */\n readonly provenance: readonly number[];\n}\nexport type StubEntry = EntryBase & (\n | { readonly kind: 'class'; readonly target: unknown; readonly replacement: ReplacementClass }\n | { readonly kind: 'function'; readonly target: unknown; readonly replacement: ReplacementFunction }\n | { readonly kind: 'value'; readonly target: unknown; readonly replacement: unknown }\n | { readonly kind: 'method'; readonly target: unknown; readonly method: string; readonly replacement: MethodDescriptor }\n | { readonly kind: 'middleware'; readonly target: string; readonly replacement: ExecutableReplacement }\n | { readonly kind: 'load'; readonly target: LoaderReference; readonly replacement: ExecutableReplacement }\n);\n\ntype EntryInput = StubEntry extends infer E\n ? E extends StubEntry ? Omit<E, 'provenance' | 'owner'> : never : never;\n\nconst owners: readonly TestOwner[] = ['server', 'client', 'main', 'renderer'];\nconst logs = new WeakMap<TestStub, { entries: readonly StubEntry[]; calls: number }>();\n\nfunction fail(message: string): never { throw new InvalidDescriptorError(message); }\nfunction label(value: unknown, name: string): asserts value is string {\n if (typeof value !== 'string' || !value.trim() || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n fail(name + ' requires a nonempty identity');\n }\n}\nfunction token(value: unknown): void {\n if (value === null || value === undefined || (typeof value === 'string' && !value.trim())) {\n fail('replacement requires an exact declared token');\n }\n}\nfunction executable(value: unknown, behaviorOnly = false, active = new Set<unknown>()): void {\n if (!behaviorOnly && typeof value === 'function') return;\n if (!isDescriptor(value)) fail('replacement requires a function or test.* descriptor');\n if (active.has(value)) fail('cyclic test.* descriptor');\n active.add(value);\n const d = value as any;\n try {\n if (d.kind === 'returns' || d.kind === 'throws' || d.kind === 'original') return;\n if (!behaviorOnly && d.kind === 'watch' && (d.wrapper === undefined || typeof d.wrapper === 'function')) return;\n if (!behaviorOnly && d.kind === 'expect' && Number.isInteger(d.expected) && d.expected >= 0) {\n if (d.behavior !== undefined) executable(d.behavior, true, active);\n return;\n }\n if (d.kind === 'calls' && Array.isArray(d.script)) {\n for (const child of d.script) executable(child, true, active);\n return;\n }\n fail('invalid test.* descriptor');\n } finally { active.delete(value); }\n}\nfunction snapshotExecutable(value: ExecutableReplacement): ExecutableReplacement {\n executable(value);\n if (typeof value === 'function') return value;\n if (value.kind === 'calls') {\n return Object.freeze({ ...value, script: Object.freeze(value.script.map(v => snapshotExecutable(v))) }) as MethodDescriptor;\n }\n if (value.kind === 'expect' && value.behavior !== undefined) {\n return Object.freeze({ ...value, behavior: snapshotExecutable(value.behavior) }) as MethodDescriptor;\n }\n return Object.freeze({ ...value });\n}\nfunction normalizeLoader(identity: LoaderIdentity): LoaderReference {\n const ref = typeof identity === 'string' ? { path: identity, export: 'default' } : identity;\n if (!ref || typeof ref !== 'object' || Reflect.ownKeys(ref).some(k => k !== 'path' && k !== 'export')) {\n fail('.load requires a project-relative path or { path, export }');\n }\n label(ref.path, '.load path');\n label(ref.export, '.load export');\n if (/^[\\/\\\\]|[\\\\?#:]/.test(ref.path) || ref.path.split('/').some(s => !s || s === '.' || s === '..')) {\n fail('.load requires a normalized project-relative source path');\n }\n return Object.freeze({ path: ref.path, export: ref.export });\n}\nfunction append(stub: TestStub, input: EntryInput, options?: ReplacementOptions): TestStub {\n if (options !== undefined && (!options || typeof options !== 'object' || Array.isArray(options)\n || Reflect.ownKeys(options).some(k => k !== 'owner')\n || (options.owner !== undefined && !owners.includes(options.owner)))) {\n fail('replacement options accept only owner: server | client | main | renderer');\n }\n const log = logs.get(stub)!;\n const entry = Object.freeze({ ...input, owner: options?.owner, provenance: Object.freeze([log.calls]) }) as StubEntry;\n return make([...log.entries, entry], log.calls + 1);\n}\n\n/** Immutable replacement description only; no container, resources or call history. */\nexport class TestStub {\n private constructor() {}\n class<T>(target: ClassToken<T>, replacement: ReplacementClass<T>, options?: ReplacementOptions): TestStub {\n token(target);\n if (typeof target !== 'function' || typeof replacement !== 'function' || !replacement.prototype) {\n fail('.class requires class tokens and a replacement constructor');\n }\n return append(this, { kind: 'class', target, replacement }, options);\n }\n function(target: unknown, replacement: ReplacementFunction, options?: ReplacementOptions): TestStub {\n token(target);\n if (typeof replacement !== 'function') fail('.function requires a callable/provider replacement');\n return append(this, { kind: 'function', target, replacement }, options);\n }\n method(target: unknown, method: string, replacement: MethodDescriptor, options?: ReplacementOptions): TestStub {\n token(target); label(method, '.method');\n return append(this, { kind: 'method', target, method, replacement: snapshotExecutable(replacement) as MethodDescriptor }, options);\n }\n value(target: unknown, replacement: unknown, options?: ReplacementOptions): TestStub {\n token(target);\n // Caller values are deliberately neither cloned nor frozen.\n return append(this, { kind: 'value', target, replacement }, options);\n }\n middleware(target: string, replacement: ExecutableReplacement, options?: ReplacementOptions): TestStub {\n label(target, '.middleware');\n return append(this, { kind: 'middleware', target, replacement: snapshotExecutable(replacement) }, options);\n }\n load(target: LoaderIdentity, replacement: ExecutableReplacement, options?: ReplacementOptions): TestStub {\n return append(this, { kind: 'load', target: normalizeLoader(target), replacement: snapshotExecutable(replacement) }, options);\n }\n use(other: TestStub): TestStub {\n const incoming = stubEntries(other);\n const log = logs.get(this)!;\n // Flatten at composition time. Only genuine immutable descriptions are accepted:\n // recursive object graphs and arbitrary functions never enter the log.\n return make([...log.entries, ...incoming.map(entry => Object.freeze({\n ...entry, provenance: Object.freeze([log.calls, ...entry.provenance]),\n }))], log.calls + 1);\n }\n}\nfunction make(entries: readonly StubEntry[], calls: number): TestStub {\n const stub = Object.create(TestStub.prototype) as TestStub;\n logs.set(stub, { entries: Object.freeze([...entries]), calls });\n return Object.freeze(stub);\n}\nexport function testStub(): TestStub { return make([], 0); }\n/** Framework adapter input. Entries are descriptions, not resolved replacements. */\nexport function stubEntries(stub: TestStub): readonly StubEntry[] {\n const log = logs.get(stub);\n if (!log) fail('.use requires an immutable testStub description (cyclic/foreign objects are not supported)');\n return log.entries;\n}\n","/** Shared source selection. Never parses source or constructs a runtime graph. */\nexport type OwnerSelection =\n | { readonly module: string | readonly string[]; readonly path?: never }\n | { readonly path: readonly string[]; readonly module?: never }\n | { readonly module?: never; readonly path?: never };\nexport interface SourceSelectionEntry { readonly path: string; readonly module?: string | null }\nexport interface SourceSelectionOptions {\n readonly owner?: string;\n readonly native?: boolean;\n /** Declared modules including empty modules, supplied by the production collector. */\n readonly modules?: readonly string[];\n}\nexport class SourceSelectionError extends Error {\n readonly code = 'testing/selection';\n constructor(message: string, readonly owner?: string, readonly choices: readonly string[] = []) {\n super((owner ? owner + ': ' : '') + message);\n this.name = 'SourceSelectionError';\n }\n}\nfunction record(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n}\ntype NormalizedOwnerSelection =\n | { readonly module: readonly string[]; readonly path?: never }\n | { readonly path: readonly string[]; readonly module?: never }\n | { readonly module?: never; readonly path?: never };\nfunction normalizeOwner(value: unknown, owner?: string): NormalizedOwnerSelection {\n const fail = (message: string): never => { throw new SourceSelectionError(message, owner); };\n if (!record(value)) return fail('select an owner with module, path, or {}');\n const keys = Reflect.ownKeys(value);\n if (keys.some(k => k !== 'module' && k !== 'path') || keys.length > 1) {\n return fail('select module OR path, or {}; no other selector keys are supported');\n }\n if (!keys.length) return Object.freeze({});\n const key = keys[0] as 'module' | 'path';\n const input = value[key];\n const list = key === 'module' && typeof input === 'string' ? [input] : input;\n if (!Array.isArray(list) || !list.length || list.some(x => typeof x !== 'string' || !x.trim() || /[\\u0000-\\u001f\\u007f]/.test(x))) {\n return fail(key + ' requires nonempty ' + (key === 'module' ? 'name(s)' : 'path array'));\n }\n const unique = Object.freeze([...new Set(list as string[])]);\n return key === 'module'\n ? Object.freeze({ module: unique })\n : Object.freeze({ path: unique });\n}\n\n/** Undefined means all declared owners; an explicit empty outer object is an error. */\nexport function normalizeTestSelection(\n selection: unknown,\n declaredOwners: readonly string[],\n): Readonly<Record<string, OwnerSelection>> {\n const declared = new Set(declaredOwners);\n if (selection === undefined) {\n return Object.freeze(Object.fromEntries([...declared].map(owner => [owner, Object.freeze({})])));\n }\n if (!record(selection) || !Reflect.ownKeys(selection).length) {\n throw new SourceSelectionError('select() requires at least one declared owner');\n }\n const result: Record<string, OwnerSelection> = {};\n for (const owner of Reflect.ownKeys(selection)) {\n if (typeof owner !== 'string' || !declared.has(owner)) {\n throw new SourceSelectionError('owner is absent or unknown; available: ' + [...declared].join(', '), String(owner), [...declared]);\n }\n Object.defineProperty(result, owner, { value: normalizeOwner(selection[owner], owner), enumerable: true });\n }\n return Object.freeze(result);\n}\n\nfunction validatePath(path: string, options: SourceSelectionOptions): void {\n const invalid = /[?#*\\[\\]\\\\\\u0000-\\u001f\\u007f]/.test(path)\n || path.includes('://') || path.includes('//')\n || path.split('/').some(segment => segment === '.' || segment === '..');\n const native = options.native && /^[A-Za-z0-9_$-]+(?:\\.[A-Za-z0-9_$-]+)*$/.test(path);\n if (invalid || (!path.startsWith('/') && !native)) {\n throw new SourceSelectionError('invalid source path selector \"' + path + '\"', options.owner);\n }\n}\nfunction matches(path: string, selector: string): boolean {\n if (selector === '/') return path.startsWith('/');\n if (selector.startsWith('/') && selector.endsWith('/')) {\n return path === selector.slice(0, -1) || path.startsWith(selector);\n }\n return path === selector;\n}\n/** Retains source order and every declared operation at each selected source path. */\nexport function selectSourceEntries<T extends SourceSelectionEntry>(\n source: readonly T[],\n input: OwnerSelection,\n options: SourceSelectionOptions = {},\n): T[] {\n const selection = normalizeOwner(input, options.owner);\n if (selection.module !== undefined) {\n const names = selection.module;\n const choices = [...new Set([...source.flatMap(e => e.module == null ? [] : [e.module]), ...(options.modules ?? [])])];\n for (const name of names) if (!choices.includes(name)) {\n throw new SourceSelectionError('unknown module \"' + name + '\"; available: ' + choices.join(', '), options.owner, choices);\n }\n return source.filter(e => e.module != null && names.includes(e.module));\n }\n if (selection.path !== undefined) {\n const paths = selection.path;\n const choices = [...new Set(source.map(e => e.path))];\n for (const path of paths) {\n validatePath(path, options);\n if (!source.some(e => matches(e.path, path))) {\n throw new SourceSelectionError('unknown path \"' + path + '\"; available: ' + choices.join(', '), options.owner, choices);\n }\n }\n return source.filter(e => paths.some(path => matches(e.path, path)));\n }\n return [...source];\n}\n","import type { TestResourceScope, TestResource, VerifiableTestResource } from './lifecycle';\n\n/** Cross-copy ABI: only async propagation is shared; scopes/resources remain per case. */\nconst ANCHOR = Symbol.for('@noego/testing.resource-scope.v1');\ninterface Storage {\n run<T>(scope: TestResourceScope, body: () => T): T;\n getStore(): TestResourceScope | undefined;\n}\nfunction storage(): Storage | undefined {\n const global = globalThis as Record<PropertyKey, any>;\n if (global[ANCHOR]) {\n const existing = global[ANCHOR];\n if (typeof existing.run !== 'function' || typeof existing.getStore !== 'function') {\n throw new Error('Incompatible NoEgo resource-scope v1 channel');\n }\n return existing as Storage;\n }\n let hooks: any;\n try {\n hooks = global.process?.getBuiltinModule?.('node:async_hooks')\n ?? require('node:async_hooks'); // unavailable in native ESM/browser: the catch below is the fallback\n } catch { return undefined; }\n if (!hooks?.AsyncLocalStorage) return undefined;\n const created = new hooks.AsyncLocalStorage() as Storage;\n Object.defineProperty(global, ANCHOR, { value: created, configurable: false, writable: false });\n return created;\n}\n\n/** No synchronous global-current fallback: browser callers retain explicit scope.own(). */\nexport function runInResourceScope<T>(scope: TestResourceScope, body: () => T): T {\n const channel = storage();\n return channel ? channel.run(scope, body) : body();\n}\n\n/** Called by framework build terminals; failed/late admission closes the new resource. */\nexport async function registerTestResource<T extends TestResource>(resource: T, owner = 'resource'): Promise<T> {\n try {\n const scope = storage()?.getStore();\n if (!scope) return resource;\n if (typeof (resource as Partial<VerifiableTestResource>).verify === 'function') {\n scope.environment(resource as T & VerifiableTestResource, owner);\n } else scope.own(resource, owner);\n return resource;\n } catch (primary) {\n try { await resource.dispose(); }\n catch (cleanup) { throw new AggregateError([primary, cleanup], 'Resource admission and cleanup failed', {cause: primary}); }\n throw primary;\n }\n}\n","/** Runner-neutral resource ownership. No global current test or automatic DB allocation. */\nimport { runInResourceScope } from './resource_context';\nexport interface TestResource { dispose(): unknown | Promise<unknown> }\nexport interface VerifiableTestResource extends TestResource {\n verify(): unknown | Promise<unknown>;\n /** Finish/cancel framework-owned finite work before checking expectations. */\n settle?(): unknown | Promise<unknown>;\n}\nexport interface FinalizationFailure {\n readonly owner: string;\n readonly phase: 'test' | 'settle' | 'verify' | 'dispose';\n readonly error: unknown;\n}\nexport class TestFinalizationError extends AggregateError {\n readonly failures: readonly FinalizationFailure[];\n constructor(failures: readonly FinalizationFailure[]) {\n super(failures.map(f => f.error), 'Test finalization failed: ' + failures.map(f => f.owner + '/' + f.phase).join(', '),\n { cause: failures[0]?.error });\n this.name = 'TestFinalizationError';\n this.failures = Object.freeze(failures.map(f => Object.freeze({ ...f })));\n }\n}\ninterface Owned {\n readonly resource: TestResource;\n readonly owner: string;\n verify?: () => unknown | Promise<unknown>;\n settle?: () => unknown | Promise<unknown>;\n}\n\n/**\n * Register immediately after acquisition; acquire dependencies before borrowers.\n * Each test/retry owns a new scope. Resources shared inside one restart test are\n * registered once, and disposed after that test's application borrowers.\n */\nexport class TestResourceScope implements TestResource {\n private readonly resources: Owned[] = [];\n private readonly owned = new Map<TestResource, Owned>();\n private closing: Promise<void> | undefined;\n private complete = false;\n /** Runner finalizers can avoid reporting an already-finished failure twice. */\n get finalized(): boolean { return this.complete; }\n own<T extends TestResource>(resource: T, owner = 'resource'): T {\n if (this.closing) throw new Error('Test resource scope is closed');\n if (!resource || typeof resource.dispose !== 'function') throw new TypeError('Test resource requires dispose()');\n if (!this.owned.has(resource)) {\n const entry = { resource, owner };\n this.owned.set(resource, entry);\n this.resources.push(entry);\n }\n return resource;\n }\n environment<T extends VerifiableTestResource>(resource: T, owner = 'application'): T {\n if (!resource || typeof resource.verify !== 'function') throw new TypeError('Test environment requires verify()');\n this.own(resource, owner);\n this.owned.get(resource)!.verify = () => resource.verify();\n if (resource.settle) this.owned.get(resource)!.settle = () => resource.settle!();\n return resource;\n }\n dispose(): Promise<void> {\n // Assign before any user disposer/verification executes (including reentrant code).\n return this.closing ??= Promise.resolve().then(async () => {\n const failures: FinalizationFailure[] = [];\n const reverse = [...this.resources].reverse();\n for (const entry of reverse) if (entry.settle) {\n try { await entry.settle(); }\n catch (error) { failures.push({ owner: entry.owner, phase: 'settle', error }); }\n }\n for (const entry of reverse) if (entry.verify) {\n try { await entry.verify(); }\n catch (error) { failures.push({ owner: entry.owner, phase: 'verify', error }); }\n }\n for (const entry of reverse) {\n try { await entry.resource.dispose(); }\n catch (error) { failures.push({ owner: entry.owner, phase: 'dispose', error }); }\n }\n if (failures.length) throw new TestFinalizationError(failures);\n }).finally(() => { this.complete = true; });\n }\n}\nexport function createTestScope(): TestResourceScope { return new TestResourceScope(); }\n\n/** Optional runner-neutral boundary; runner adapters can own the same scope directly. */\nexport async function withTestScope<T>(body: (scope: TestResourceScope) => T | Promise<T>): Promise<T> {\n const scope = createTestScope();\n let failed = false;\n let primary: unknown;\n let result!: T;\n try { result = await runInResourceScope(scope, () => body(scope)); }\n catch (error) { failed = true; primary = error; }\n try { await scope.dispose(); }\n catch (error) {\n if (!failed) throw error;\n const cleanup = error instanceof TestFinalizationError\n ? error.failures : [{ owner: 'scope', phase: 'dispose' as const, error }];\n throw new TestFinalizationError([{ owner: 'test', phase: 'test', error: primary }, ...cleanup]);\n }\n if (failed) throw primary;\n return result;\n}\n","import { withTestScope, type TestResourceScope } from './lifecycle';\n\n/**\n * Thin runner adapter for test functions (Vitest 2/3/4, Node test and Jest).\n * The runner still owns test discovery, assertions, retries and timeout reporting.\n * Every invocation/retry gets a new scope; framework builds register themselves\n * under async-capable Node runtimes. Browsers use the explicit scope argument.\n */\nexport function resourceCase<Args extends unknown[], Result>(\n body: (resources: TestResourceScope, ...args: Args) => Result | Promise<Result>,\n): (...args: Args) => Promise<Result> {\n return (...args) => withTestScope(resources => {\n // Use the PUBLIC per-test context, never a global current-test API. This\n // also finalizes a timed-out body that the runner stopped awaiting.\n const context = args.find(value => value && (typeof value === 'object' || typeof value === 'function')\n && typeof (value as {onTestFinished?: unknown}).onTestFinished === 'function') as\n {onTestFinished(callback: () => Promise<void>): void} | undefined;\n context?.onTestFinished(async () => {\n if (!resources.finalized) await resources.dispose();\n });\n return body(resources, ...args);\n });\n}\n","/** Runner configuration/report checks only: these functions never fabricate coverage or test counters. */\nexport const COVERAGE_METRICS = Object.freeze(['lines', 'statements', 'functions', 'branches'] as const);\nexport type CoverageMetric = typeof COVERAGE_METRICS[number];\nexport type CoverageThresholds = Record<CoverageMetric, number>;\nexport interface CoverageExclusion {\n pattern: string;\n kind: 'tests' | 'types' | 'generated' | 'nonexecutable' | 'separate-runtime';\n reason: string;\n /** Generated or separately qualified runtime code needs a concrete evidence reference. */\n evidence?: string;\n}\nexport interface VitestCoverageInput {\n runnerVersion: string;\n providerVersion: string;\n include: readonly string[];\n exclusions?: readonly CoverageExclusion[];\n thresholds?: Partial<CoverageThresholds>;\n}\nexport class TestCoverageConfigurationError extends Error {\n constructor(message: string) { super(message); this.name = 'TestCoverageConfigurationError'; }\n}\nconst DEFAULT_EXCLUSIONS: readonly CoverageExclusion[] = [\n { pattern: '**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}', kind: 'tests', reason: 'Test implementations are not product source.' },\n { pattern: '**/*.d.{ts,mts,cts}', kind: 'types', reason: 'Type declarations have no executable counters.' },\n];\nconst EXCLUSION_KINDS = ['tests', 'types', 'generated', 'nonexecutable', 'separate-runtime'];\nfunction nonempty(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || !value.trim()) throw new TestCoverageConfigurationError(label + ' must be a nonempty string');\n}\nfunction version(value: unknown): number {\n if (typeof value !== 'string' || !/^[234]\\.\\d+\\.\\d+$/.test(value)) {\n throw new TestCoverageConfigurationError('Declare a qualified stable Vitest/provider version in majors 2, 3, or 4');\n }\n return Number(value[0]);\n}\n/** V8 preset with explicit uncovered-source inclusion and reviewable exclusion provenance. */\nexport function vitestCoverage(input: VitestCoverageInput) {\n const major = version(input.runnerVersion);\n version(input.providerVersion);\n if (input.runnerVersion !== input.providerVersion) throw new TestCoverageConfigurationError('Vitest and @vitest/coverage-v8 versions must match exactly');\n if (!Array.isArray(input.include) || !input.include.length) throw new TestCoverageConfigurationError('coverage.include must name the complete eligible source set');\n for (const pattern of input.include) {\n nonempty(pattern, 'include pattern');\n if (pattern.startsWith('!')) throw new TestCoverageConfigurationError('Record exclusions separately with provenance, not as negative includes');\n }\n const include = [...new Set(input.include)];\n const thresholds: CoverageThresholds = { lines: 99, statements: 99, functions: 99, branches: 99, ...input.thresholds };\n if (Object.keys(thresholds).some(key => !COVERAGE_METRICS.includes(key as CoverageMetric))) throw new TestCoverageConfigurationError('Unknown coverage metric');\n for (const metric of COVERAGE_METRICS) {\n if (!Number.isFinite(thresholds[metric]) || thresholds[metric] < 0 || thresholds[metric] > 100) {\n throw new TestCoverageConfigurationError(metric + ' threshold must be between 0 and 100');\n }\n }\n const exclusions = [...DEFAULT_EXCLUSIONS, ...(input.exclusions ?? [])].map(entry => {\n nonempty(entry.pattern, 'exclusion pattern');\n nonempty(entry.reason, 'exclusion reason');\n if (!EXCLUSION_KINDS.includes(entry.kind)) throw new TestCoverageConfigurationError('Unknown exclusion kind');\n if (entry.kind === 'generated' || entry.kind === 'separate-runtime') nonempty(entry.evidence, 'exclusion evidence');\n return { ...entry };\n });\n if (new Set(exclusions.map(entry => entry.pattern)).size !== exclusions.length) throw new TestCoverageConfigurationError('Duplicate exclusion pattern');\n const options = {\n provider: 'v8' as const,\n include: [...include],\n exclude: exclusions.map(entry => entry.pattern),\n // v4 removed all: explicit include now includes covered AND uncovered files.\n ...(major < 4 ? { all: true } : {}),\n reporter: ['text-summary', 'json-summary', 'json'] as Array<'text-summary' | 'json-summary' | 'json'>,\n reportOnFailure: true,\n thresholds: { ...thresholds },\n };\n return {\n options,\n provenance: Object.freeze({\n runner: 'vitest', runnerVersion: input.runnerVersion,\n provider: '@vitest/coverage-v8', providerVersion: input.providerVersion,\n includesUnimported: true,\n include: Object.freeze(include),\n exclusions: Object.freeze(exclusions.map(entry => Object.freeze(entry))),\n thresholds: Object.freeze(thresholds),\n metrics: Object.freeze([...COVERAGE_METRICS]),\n }),\n };\n}\n\nexport interface TestLaneReport {\n name: string;\n total: number;\n passed: number;\n failed: number;\n skipped: number;\n}\nexport class TestDiscoveryError extends Error {\n constructor(readonly failures: readonly string[]) { super(failures.join('; ')); this.name = 'TestDiscoveryError'; }\n}\n/** Validate counts taken from native runner reports; this is not a test discovery implementation. */\nexport function assertTestLanes(required: readonly string[], reports: readonly TestLaneReport[]): void {\n if (!required.length) throw new TestDiscoveryError(['At least one required lane must be declared']);\n const names = new Set<string>();\n const failures: string[] = [];\n for (const name of required) nonempty(name, 'required lane name');\n if (new Set(required).size !== required.length) throw new TestDiscoveryError(['Duplicate required lane']);\n for (const report of reports) {\n nonempty(report.name, 'reported lane name');\n if (names.has(report.name)) throw new TestDiscoveryError(['Duplicate report for lane ' + report.name]);\n names.add(report.name);\n for (const key of ['total', 'passed', 'failed', 'skipped'] as const) {\n if (!Number.isSafeInteger(report[key]) || report[key] < 0) throw new TestDiscoveryError(['Invalid ' + key + ' count for ' + report.name]);\n }\n if (report.total !== report.passed + report.failed + report.skipped) throw new TestDiscoveryError(['Inconsistent counts for ' + report.name]);\n if (report.failed) failures.push(report.name + ': ' + report.failed + ' failed');\n if (required.includes(report.name)) {\n if (!report.total) failures.push(report.name + ': required lane is empty');\n if (report.skipped) failures.push(report.name + ': ' + report.skipped + ' skipped');\n }\n }\n for (const name of required) if (!names.has(name)) failures.push(name + ': required lane is missing');\n if (failures.length) throw new TestDiscoveryError(Object.freeze(failures));\n}\n","import type { NormalizedRegistration } from '@noego/ioc';\nimport { stubEntries, type LoaderReference, type StubEntry, type TestOwner, type TestStub } from './stub';\n\n/** Supplied by framework production discovery, never by a product-local route map. */\nexport interface TestOwnerCatalog {\n readonly owner: TestOwner;\n readonly bindings: readonly NormalizedRegistration[];\n readonly middleware?: readonly string[];\n readonly loaders?: readonly LoaderReference[];\n}\nexport interface ResolvedTestOverlay {\n readonly owner: TestOwner;\n readonly entry: StubEntry;\n readonly binding?: NormalizedRegistration;\n}\nexport class TestOverlayError extends Error {\n readonly code = 'testing/overlay';\n constructor(message: string, readonly entry: StubEntry) {\n super('entry ' + entry.provenance.join('.') + ': ' + message);\n this.name = 'TestOverlayError';\n }\n}\nfunction label(target: unknown): string {\n return typeof target === 'function' ? target.name : String(target);\n}\nfunction binding(catalog: TestOwnerCatalog, token: unknown): NormalizedRegistration | undefined {\n return catalog.bindings.find(b => b.token === token);\n}\nfunction owns(catalog: TestOwnerCatalog, entry: StubEntry): boolean {\n if (entry.kind === 'middleware') return catalog.middleware?.includes(entry.target) ?? false;\n if (entry.kind === 'load') return catalog.loaders?.some(l => l.path === entry.target.path && l.export === entry.target.export) ?? false;\n return binding(catalog, entry.target) !== undefined;\n}\nfunction sameSlot(a: ResolvedTestOverlay, b: ResolvedTestOverlay): boolean {\n if (a.owner !== b.owner) return false;\n const x = a.entry, y = b.entry;\n if (x.kind === 'load' && y.kind === 'load') return x.target.path === y.target.path && x.target.export === y.target.export;\n if (x.kind === 'middleware' || x.kind === 'load' || y.kind === 'middleware' || y.kind === 'load') {\n return x.kind === y.kind && x.target === y.target;\n }\n if (x.kind === 'method' || y.kind === 'method') {\n return x.kind === 'method' && y.kind === 'method' && x.target === y.target && x.method === y.method;\n }\n return x.target === y.target; // class/function/value share one binding slot\n}\n\n/**\n * Validate EVERY entry before reducing last-write-wins slots. Resolve identities\n * exactly, never by class display name; method seams remain independent of the\n * final binding slot and are installed after all binding replacements.\n */\nexport function resolveTestOverlays(stub: TestStub, catalogs: readonly TestOwnerCatalog[]): readonly ResolvedTestOverlay[] {\n const names = catalogs.map(c => c.owner);\n if (new Set(names).size !== names.length) throw new TypeError('duplicate test owner catalog');\n const result: ResolvedTestOverlay[] = [];\n for (const entry of stubEntries(stub)) {\n let candidates = catalogs.filter(c => owns(c, entry) && (entry.owner === undefined || c.owner === entry.owner));\n if (candidates.length === 0 && entry.kind !== 'middleware' && entry.kind !== 'load' && (typeof entry.target === 'function' || entry.kind === 'value')) {\n // A token no production registration reaches through constructor\n // metadata (resolved lazily at runtime) is still a real member of the\n // owner's graph. When the owner is unambiguous, admit it: class tokens\n // as a singleton class binding, and non-class tokens supplied through\n // .value as a value binding, so the replacement can shadow the lazy\n // resolution.\n const fallback = catalogs.filter(c => entry.owner === undefined || c.owner === entry.owner);\n if (fallback.length === 1) {\n const synthetic = (typeof entry.target === 'function'\n ? { token: entry.target, kind: 'class', lifetime: 'singleton', implementation: entry.target, dependencies: [] }\n : { token: entry.target, kind: 'value', lifetime: 'singleton', implementation: entry.replacement, dependencies: [] }) as unknown as NormalizedRegistration;\n candidates = [{ ...fallback[0]!, bindings: [...fallback[0]!.bindings, synthetic] }];\n }\n }\n if (candidates.length !== 1) {\n const identity = entry.kind === 'load' ? entry.target.path + '#' + entry.target.export : label(entry.target);\n throw new TestOverlayError((candidates.length ? 'Ambiguous' : 'Unknown') + ' ' + entry.kind + ' \"' + identity\n + '\" in selected owners [' + names.join(', ') + ']'\n + (entry.owner ? '; requested owner ' + entry.owner : '; specify { owner } when ambiguous'), entry);\n }\n const catalog = candidates[0]!;\n const declared = entry.kind === 'middleware' || entry.kind === 'load' ? undefined : binding(catalog, entry.target);\n // A class-declared token accepts a zero-argument provider too: the\n // replacement is invoked lazily (declared lifetime kept) and the produced\n // value is borrowed, never disposed by the application.\n if (entry.kind === 'function' && declared?.kind !== 'factory' && declared?.kind !== 'class'\n && !(declared?.kind === 'value' && typeof declared.implementation === 'function')) {\n throw new TestOverlayError('.function requires a declared factory/provider, class, or callable value binding', entry);\n }\n const resolved = Object.freeze({ owner: catalog.owner, entry, binding: declared });\n const prior = result.findIndex(e => sameSlot(e, resolved));\n if (prior !== -1) result.splice(prior, 1);\n result.push(resolved);\n }\n // Final binding comes before method attachment, regardless of fluent order.\n return Object.freeze([...result.filter(e => e.entry.kind !== 'method'), ...result.filter(e => e.entry.kind === 'method')]);\n}\n","import { defineModule } from '@noego/ioc';\nimport type { BuildOptions, TestIocBuilder } from './builder';\nimport { TestOverlayError, type ResolvedTestOverlay } from './overlays';\nimport type { TestOwner } from './stub';\n\nexport interface TestBindingPlan {\n readonly builder: TestIocBuilder;\n /** Pass to builder.build alongside the framework's unresolved root. */\n readonly buildOptions: Pick<BuildOptions, 'borrowedTokens'>;\n}\n\n/** Apply resolved binding entries to the existing real-IoC description. No new root. */\nexport function applyTestBindings(\n production: TestIocBuilder,\n overlays: readonly ResolvedTestOverlay[],\n owner: TestOwner,\n): TestBindingPlan {\n let builder = production;\n const entries = overlays.filter(e => e.owner === owner);\n const borrowed: unknown[] = [];\n for (const overlay of entries) {\n const { entry, binding } = overlay;\n if (entry.kind === 'middleware' || entry.kind === 'load' || entry.kind === 'method') continue;\n if (!binding) throw new TestOverlayError('missing production binding metadata', entry);\n builder = builder.use(defineModule('@noego/testing/' + owner + '/' + entry.provenance.join('.'), bind => {\n if (entry.kind === 'class') {\n bind(entry.target).to(entry.replacement)[binding.lifetime]();\n } else if (entry.kind === 'function' && binding.kind === 'factory') {\n bind(entry.target).toFactory(entry.replacement, [...binding.dependencies])[binding.lifetime]();\n } else if (entry.kind === 'function' && binding.kind === 'class') {\n // Zero-argument provider standing in for a class: lazy, declared\n // lifetime kept, produced value borrowed (never disposed by the app).\n bind(entry.target).toFactory(() => entry.replacement())[binding.lifetime]();\n borrowed.push(entry.target);\n } else {\n // .value and callable .function retain their declared lifetime but never\n // transfer ownership of caller-supplied resources to the application.\n bind(entry.target).toFactory(() => entry.replacement)[binding.lifetime]();\n borrowed.push(entry.target);\n }\n }));\n }\n for (const { entry } of entries) if (entry.kind === 'method') {\n builder = builder.methods([[entry.target, { [entry.method]: entry.replacement }]]);\n }\n return Object.freeze({ builder, buildOptions: Object.freeze({ borrowedTokens: Object.freeze(borrowed) }) });\n}\n","import { ENV_REGISTRY, test, type MethodDescriptor, type MethodInspection } from './descriptors';\nimport { createMethodDecorator, WatchRegistry } from './method_state';\nimport type { ResolvedTestOverlay } from './overlays';\nimport type { LoaderReference, ReplacementFunction, TestOwner } from './stub';\n\nexport type TestExecutableKind = 'middleware' | 'load';\nfunction identity(kind: TestExecutableKind, target: string | LoaderReference): string {\n if (kind === 'middleware') {\n if (typeof target !== 'string') throw new TypeError('middleware identity must be a string');\n return 'middleware:' + target;\n }\n if (typeof target === 'string') return 'load:' + target + '#default';\n return 'load:' + target.path + '#' + target.export;\n}\nexport interface TestExecutableOverlays {\n replace(kind: TestExecutableKind, target: string | LoaderReference, original: ReplacementFunction): ReplacementFunction;\n inspect(kind: TestExecutableKind, target: string | LoaderReference): MethodInspection;\n verify(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\n/** Per-environment executable seams; uses the same test.* runtime as IoC methods. */\nexport function createTestExecutables(overlays: readonly ResolvedTestOverlay[], owner: TestOwner): TestExecutableOverlays {\n const registry = new WatchRegistry();\n const decorator = createMethodDecorator(registry);\n const selected = new Set<string>();\n const installed = new Map<string, { original: ReplacementFunction; replacement: ReplacementFunction }>();\n for (const { owner: selectedOwner, entry } of overlays) {\n if (selectedOwner !== owner || (entry.kind !== 'middleware' && entry.kind !== 'load')) continue;\n const key = identity(entry.kind, entry.target);\n selected.add(key);\n // A function for middleware/load is a direct executable replacement, not\n // the raw original=>replacement form used specifically by .method.\n const behavior: MethodDescriptor = typeof entry.replacement === 'function'\n ? test.watch(() => entry.replacement as ReplacementFunction) : entry.replacement;\n registry.addEntry({ key, byName: false, methods: new Map([['invoke', behavior]]) });\n }\n return {\n replace(kind, target, original) {\n if (typeof original !== 'function') throw new TypeError('source executable must be callable');\n const key = identity(kind, target);\n if (!selected.has(key)) return original;\n const cached = installed.get(key);\n if (cached) {\n if (cached.original !== original) throw new TypeError('ambiguous source executable: ' + key);\n return cached.replacement;\n }\n const subject = decorator({ invoke: original }, key) as { invoke: ReplacementFunction };\n const replacement = function(this: unknown, ...args: unknown[]) { return subject.invoke.apply(this, args); };\n installed.set(key, { original, replacement });\n return replacement;\n },\n inspect: (kind, target) => registry.inspect(identity(kind, target), 'invoke'),\n verify: async () => registry.verify(),\n [ENV_REGISTRY]: registry,\n };\n}\n","import { defineModule, flattenModule, type NormalizedRegistration } from '@noego/ioc';\nimport type { TestIocBuilder } from './builder';\n\n/**\n * Framework discovery over registration descriptions and compiler-discovered\n * classes. Implicit injectable class dependencies are included without resolving\n * a container or matching a replacement by its display name.\n */\nexport function describeTestBindings(builder: TestIocBuilder, discovered: readonly unknown[] = []): readonly NormalizedRegistration[] {\n const declarations = new Map<unknown, NormalizedRegistration>();\n const classBinding = (token: unknown, implementation: new (...args: any[]) => unknown): NormalizedRegistration =>\n flattenModule(defineModule('@noego/testing/discovered', bind => { bind(token).to(implementation); }))[0]!;\n for (const write of builder.writes) {\n if (write.op === 'use') {\n for (const registration of flattenModule(write.module)) declarations.set(registration.token, registration);\n } else if (write.op === 'classes') {\n const registration = classBinding(write.key, write.implementation);\n declarations.set(write.key, { ...registration, lifetime: declarations.get(write.key)?.lifetime ?? registration.lifetime });\n } else if (write.op === 'functions' || write.op === 'values') {\n const prior = declarations.get(write.key);\n declarations.set(write.key, {\n token: write.key, kind: write.op === 'functions' ? 'factory' : 'value',\n lifetime: write.op === 'values' ? 'singleton' : prior?.lifetime ?? 'transient',\n dependencies: write.op === 'functions' && prior?.kind === 'factory' ? prior.dependencies : [],\n implementation: write.op === 'functions' ? write.factory : write.value,\n source: '@noego/testing/declared', requiredCapabilities: [],\n });\n }\n }\n const visited = new Set<unknown>();\n const visit = (token: unknown): void => {\n if (visited.has(token)) return;\n visited.add(token);\n let registration = declarations.get(token);\n if (!registration && typeof token === 'function' && token.prototype) {\n registration = classBinding(token, token as new (...args: any[]) => unknown);\n declarations.set(token, registration);\n }\n if (!registration) return;\n for (const dependency of registration.dependencies) visit(dependency);\n if (registration.kind === 'class' && registration.implementation !== token) visit(registration.implementation);\n };\n for (const token of [...declarations.keys(), ...discovered]) visit(token);\n return Object.freeze([...declarations.values()].map(r => Object.freeze({\n ...r, dependencies: Object.freeze([...r.dependencies]), requiredCapabilities: Object.freeze([...r.requiredCapabilities]),\n })));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,iBAQO;;;ACbA,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO,WAAW;AAAA,EACzB;AACF;AAGO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,cAAc;AACZ;AAAA,MACE;AAAA,IAGF;AAAA,EACF;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I,CAAC,gBAAgB,OAAOA,WAAU,cAAcA,OAAM,WAAW;AACnE,qBAAe,aAAaA,QAAOA,MAAwC;AAC3E,mBAAa,IAAIA,QAAO,YAAY;AAAA,IACtC;AACA,QAAI,CAAC,aAAc;AACnB,eAAW,cAAc,aAAa,aAAc,OAAM,UAAU;AACpE,QAAI,aAAa,SAAS,WAAW,aAAa,mBAAmBA,OAAO,OAAM,aAAa,cAAc;AAAA,EAC/G;AACA,aAAWA,UAAS,CAAC,GAAG,aAAa,KAAK,GAAG,GAAG,UAAU,EAAG,OAAMA,MAAK;AACxE,SAAO,OAAO,OAAO,CAAC,GAAG,aAAa,OAAO,CAAC,EAAE,IAAI,OAAK,OAAO,OAAO;AAAA,IACrE,GAAG;AAAA,IAAG,cAAc,OAAO,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC;AAAA,IAAG,sBAAsB,OAAO,OAAO,CAAC,GAAG,EAAE,oBAAoB,CAAC;AAAA,EACzH,CAAC,CAAC,CAAC;AACL;","names":["token","token","token","label","token","import_ioc","COMPONENT_OPTIONS_KEY","componentScope","token","identity","fail","label","label","token","identity","import_ioc","binding","import_ioc","token"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/builder.ts","../src/errors.ts","../src/descriptors.ts","../src/method_state.ts","../src/seams.ts","../src/stub.ts","../src/selection.ts","../src/resource_context.ts","../src/lifecycle.ts","../src/resource_case.ts","../src/coverage.ts","../src/overlays.ts","../src/binding_overlays.ts","../src/executable_overlays.ts","../src/binding_catalog.ts"],"sourcesContent":["/**\n * @noego/testing — the canonical shared owner of real-IoC test composition\n * (`testIoc`) and the lowercase `test.*` method behavior/watch/expectation\n * language, built on @noego/ioc's production seams.\n *\n * The former generic runtime-mirror doubles (ManualClock, ScriptedFetchClient,\n * memory stores, recording sinks, contract suites, LeakDetector, …) are\n * retired; pin 0.1.x if you still need them, and see the NoEgo runtime/testing\n * deprecation plan for per-export dispositions.\n */\n\nexport { testIoc, TestIocBuilder } from './builder';\nexport type { BuildOptions, TestEnvironment, ConfigMap, MethodsConfig, UseInput } from './builder';\n\nexport { test, ENV_REGISTRY } from './descriptors';\nexport type {\n BehaviorDescriptor,\n CallsDescriptor,\n ExpectationDescriptor,\n MethodDescriptor,\n MethodInspection,\n OriginalDescriptor,\n RawMethodWrapper,\n RecordedCall,\n ReturnsDescriptor,\n ThrowsDescriptor,\n WatchDescriptor,\n} from './descriptors';\n\nexport {\n TestingError,\n MissingIocSeamError,\n UnwatchedInspectionError,\n CallScriptExhaustedError,\n ExpectationOverflowError,\n VerificationError,\n MethodNotCallableError,\n NonObjectMethodTargetError,\n UnknownTokenKeyError,\n AmbiguousNameKeyError,\n TokenIdentitySplitError,\n InvalidDescriptorError,\n} from './errors';\n\nexport { installSeams } from './seams';\nexport type { SeamsConfig, InstalledSeams } from './seams';\n\nexport { testStub, TestStub, stubEntries } from './stub';\nexport type {\n StubEntry, TestOwner, ReplacementOptions, ClassToken, ReplacementClass, ReplacementFunction,\n ExecutableReplacement, LoaderIdentity, LoaderReference,\n} from './stub';\nexport { normalizeTestSelection, selectSourceEntries, SourceSelectionError } from './selection';\nexport type { OwnerSelection, SourceSelectionEntry, SourceSelectionOptions } from './selection';\nexport { createTestScope, withTestScope, TestResourceScope, TestFinalizationError } from './lifecycle';\nexport { resourceCase } from './resource_case';\nexport { vitestCoverage, assertTestLanes, COVERAGE_METRICS, TestCoverageConfigurationError, TestDiscoveryError } from './coverage';\nexport type { VitestCoverageInput, CoverageExclusion, CoverageMetric, CoverageThresholds, TestLaneReport } from './coverage';\nexport { registerTestResource, runInResourceScope } from './resource_context';\nexport type { TestResource, VerifiableTestResource, FinalizationFailure } from './lifecycle';\nexport { resolveTestOverlays, TestOverlayError } from './overlays';\nexport type { TestOwnerCatalog, ResolvedTestOverlay } from './overlays';\nexport { applyTestBindings } from './binding_overlays';\nexport type { TestBindingPlan } from './binding_overlays';\nexport { createTestExecutables } from './executable_overlays';\nexport type { TestExecutableKind, TestExecutableOverlays } from './executable_overlays';\nexport { describeTestBindings } from './binding_catalog';\n","/**\n * `testIoc` — the canonical shared real-IoC test composition builder.\n *\n * Persistent immutable: every fluent call returns a new derived builder\n * sharing the ordered write log structurally. Non-conflicting writes are\n * order-insensitive; the last write to the same effective identity wins on\n * that derived branch. `.build()` is non-consuming and creates fresh runtime,\n * watch, and expectation state (spec 15, PBR-01..15).\n */\n\nimport {\n createContainer,\n ExecutionContext,\n flattenModule,\n LoadAs,\n SCOPED_CONTAINER,\n type ApplicationModule,\n type IContainer,\n} from '@noego/ioc';\n\nimport { ENV_REGISTRY, isDescriptor, type MethodDescriptor } from './descriptors';\nimport { createMethodDecorator, WatchRegistry, tokenLabel } from './method_state';\nimport { InvalidDescriptorError, MissingIocSeamError, UnknownTokenKeyError, AmbiguousNameKeyError,\n} from './errors';\n\nconst COMPONENT_OPTIONS_KEY = Symbol.for('ioc:component:options');\n\ntype Token = unknown;\ntype ClassLike = new (...args: any[]) => any;\n\n/** Config maps accept plain objects (string keys) or Maps (exact tokens). */\n/**\n * Composition input (spec 04 §2). The CANONICAL entry form is an array of\n * tuples — token-first, exact identity:\n *\n * .classes([[ProjectRepository, MemoryProjectRepository]])\n *\n * A `ReadonlyMap<Token, V>` is equivalent (token-keyed). A name-keyed\n * `Record<string, V>` remains accepted as COMPATIBILITY input: string keys\n * resolve against known token display names, fail on unknown names, and\n * fail on ambiguous names (two tokens sharing one display name never\n * collapse into one entry — tokens are identities, names are labels).\n */\nexport type ConfigMap<V> =\n | ReadonlyArray<readonly [Token, V]>\n | ReadonlyMap<Token, V>\n | Record<string, V>;\n\nexport type MethodsConfig = ConfigMap<Record<string, MethodDescriptor> | ReadonlyMap<string, MethodDescriptor>>;\n\nexport type UseInput = ApplicationModule | TestIocBuilder;\n\ntype Write =\n | { op: 'use'; module: ApplicationModule }\n | { op: 'classes'; key: Token; byName: boolean; implementation: ClassLike }\n | { op: 'functions'; key: Token; byName: boolean; factory: (...args: any[]) => any }\n | { op: 'values'; key: Token; byName: boolean; value: unknown }\n | { op: 'methods'; key: Token; byName: boolean; methods: ReadonlyMap<string, MethodDescriptor> };\n\nexport interface BuildOptions {\n /** Optional unresolved composition root. The returned environment owns its disposal. */\n root?: IContainer;\n /** Compose production registrations on the fresh root before the seams. */\n prepare?: (root: IContainer) => void | Promise<void>;\n /** Framework overlays may borrow caller-owned values without closing them. */\n borrowedTokens?: readonly unknown[];\n}\n\nexport interface TestEnvironment {\n readonly root: IContainer;\n get<T>(token: unknown, params?: any[]): Promise<T> | T;\n instance<T>(cls: new (...args: any[]) => T, params?: any[]): Promise<T> | T;\n extend(): IContainer;\n verify(): Promise<void>;\n dispose(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\nfunction* configEntries<V>(config: ConfigMap<V>): Iterable<[Token, boolean, V]> {\n if (Array.isArray(config)) {\n // Canonical tuple form: exact token identity, never name resolution.\n for (const entry of config as ReadonlyArray<readonly [Token, V]>) {\n if (!Array.isArray(entry) || entry.length !== 2) {\n throw new InvalidDescriptorError(\n 'canonical composition entries are [token, value] tuples, e.g. .classes([[Token, Impl]])',\n );\n }\n yield [entry[0], false, entry[1]];\n }\n } else if (config instanceof Map) {\n for (const [key, value] of config) yield [key, false, value];\n } else {\n for (const key of [...Object.getOwnPropertyNames(config), ...Object.getOwnPropertySymbols(config)]) {\n yield [key, typeof key === 'string', (config as any)[key]];\n }\n }\n}\n\nfunction componentScope(cls: any): LoadAs | undefined {\n const options =\n typeof Reflect !== 'undefined' && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(COMPONENT_OPTIONS_KEY, cls)\n : undefined;\n return options?.scope;\n}\n\nfunction lifetimeToLoadAs(lifetime: string): LoadAs {\n if (lifetime === 'singleton') return LoadAs.Singleton;\n if (lifetime === 'scoped') return LoadAs.Scoped;\n return LoadAs.Transient;\n}\n\nexport class TestIocBuilder {\n private constructor(private readonly log: readonly Write[]) {\n Object.freeze(this);\n }\n\n /** @internal */\n static create(inputs: readonly UseInput[]): TestIocBuilder {\n return new TestIocBuilder([]).useAll(inputs);\n }\n\n /** @internal — read by .use(builderPreset) */\n get writes(): readonly Write[] {\n return this.log;\n }\n\n private derive(writes: Write[]): TestIocBuilder {\n return new TestIocBuilder([...this.log, ...writes]);\n }\n\n private useAll(inputs: readonly UseInput[]): TestIocBuilder {\n let builder: TestIocBuilder = this;\n for (const input of inputs) builder = builder.use(input);\n return builder;\n }\n\n /** Apply a reusable composition preset: an ApplicationModule or a builder. */\n use(preset: UseInput): TestIocBuilder {\n if (preset instanceof TestIocBuilder) {\n return this.derive([...preset.writes]);\n }\n return this.derive([{ op: 'use', module: preset }]);\n }\n\n /** Replace the implementation for IoC class tokens in the built environment. */\n classes(config: ConfigMap<ClassLike>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, implementation] of configEntries(config)) {\n if (typeof implementation !== 'function' || !implementation.prototype) {\n throw new InvalidDescriptorError(\n `.classes() value for \"${tokenLabel(key)}\" must be a class constructor.`,\n );\n }\n writes.push({ op: 'classes', key, byName, implementation });\n }\n return this.derive(writes);\n }\n\n /** Replace IoC factory/provider registrations. */\n functions(config: ConfigMap<(...args: any[]) => any>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, factory] of configEntries(config)) {\n if (typeof factory !== 'function') {\n throw new InvalidDescriptorError(`.functions() value for \"${tokenLabel(key)}\" must be a function.`);\n }\n writes.push({ op: 'functions', key, byName, factory });\n }\n return this.derive(writes);\n }\n\n /** Provide/replace IoC value registrations. */\n values(config: ConfigMap<unknown>): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, value] of configEntries(config)) {\n writes.push({ op: 'values', key, byName, value });\n }\n return this.derive(writes);\n }\n\n /** Install method behavior/observation descriptors on IoC-managed instances. */\n methods(config: MethodsConfig): TestIocBuilder {\n const writes: Write[] = [];\n for (const [key, byName, methodsInput] of configEntries(config)) {\n const methods = new Map<string, MethodDescriptor>();\n const entries =\n methodsInput instanceof Map\n ? methodsInput.entries()\n : Object.entries(methodsInput as Record<string, MethodDescriptor>);\n for (const [name, descriptor] of entries) {\n if (typeof descriptor !== 'function' && !isDescriptor(descriptor)) {\n throw new InvalidDescriptorError(\n `.methods() entry ${tokenLabel(key)}.${name} must be a test.* descriptor or a raw wrapper function.`,\n );\n }\n methods.set(name, descriptor);\n }\n writes.push({ op: 'methods', key, byName, methods });\n }\n return this.derive(writes);\n }\n\n /**\n * Materialize a fresh, isolated real-IoC environment. Non-consuming.\n *\n * `prepare` runs on the fresh root BEFORE this builder's registrations and\n * the method-control decorator are applied: the place for an application's\n * production composition, so every declared seam shadows what production\n * registered for the same token, and instances constructed later are\n * decorated. Instances `prepare` constructs itself are not decorated.\n */\n async build(options: BuildOptions = {}): Promise<TestEnvironment> {\n const root = options.root ?? createContainer();\n try {\n return await this.buildOnRoot(root, options);\n } catch (primary) {\n try { await root.dispose(); }\n catch (cleanup) {\n throw new AggregateError([primary, cleanup], 'Test IoC build failed and rollback failed', { cause: primary });\n }\n throw primary;\n }\n }\n\n private async buildOnRoot(root: IContainer, options: BuildOptions): Promise<TestEnvironment> {\n if (typeof (root as any).setInstanceDecorator !== 'function') {\n throw new MissingIocSeamError();\n }\n await options.prepare?.(root);\n\n // ---- Materialize the ordered log: last write wins per effective identity\n // Known tokens (for resolving string keys of classes/functions/values)\n const knownByName = new Map<string, Token>();\n /** Display names claimed by more than one distinct token (spec 04 §5/§17). */\n const ambiguousNames = new Set<string>();\n const knownLifetimes = new Map<Token, LoadAs>();\n const note = (token: Token, loadAs: LoadAs | undefined) => {\n const name =\n typeof token === 'function' && (token as any).name\n ? (token as any).name as string\n : typeof token === 'string'\n ? token\n : null;\n if (name !== null) {\n const existing = knownByName.get(name);\n if (existing !== undefined && existing !== token) ambiguousNames.add(name);\n knownByName.set(name, token);\n }\n if (loadAs !== undefined) knownLifetimes.set(token, loadAs);\n };\n\n type Effective =\n | { space: 'class'; token: Token; implementation: ClassLike; loadAs?: LoadAs }\n | { space: 'factory'; token: Token; factory: (...args: any[]) => any; loadAs?: LoadAs; deps?: Token[] }\n | { space: 'value'; token: Token; value: unknown };\n\n // ordered map: identity → latest effective write (Map preserves first-write\n // position which is fine — later writes replace content, LWW)\n const effective = new Map<Token, Effective>();\n const methodWrites: { key: Token; byName: boolean; methods: Map<string, MethodDescriptor> }[] = [];\n\n const resolveKey = (key: Token, byName: boolean, space: string): Token => {\n if (!byName) return key;\n if (ambiguousNames.has(key as string)) {\n throw new AmbiguousNameKeyError(key as string, space);\n }\n const known = knownByName.get(key as string);\n if (known !== undefined) return known;\n if (space === 'values' || space === 'functions') return key; // string tokens are first-class\n throw new UnknownTokenKeyError(key as string, space, [...knownByName.keys()]);\n };\n\n for (const write of this.log) {\n switch (write.op) {\n case 'use': {\n for (const reg of flattenModule(write.module)) {\n const loadAs = lifetimeToLoadAs(reg.lifetime);\n note(reg.token, loadAs);\n if (reg.kind === 'class') {\n note(reg.implementation as Token, loadAs);\n effective.set(reg.token, {\n space: 'class',\n token: reg.token,\n implementation: reg.implementation as ClassLike,\n loadAs,\n });\n knownLifetimes.set(reg.token, loadAs);\n knownLifetimes.set(reg.implementation as Token, loadAs);\n } else if (reg.kind === 'factory') {\n effective.set(reg.token, {\n space: 'factory',\n token: reg.token,\n factory: reg.implementation as (...args: any[]) => any,\n loadAs,\n deps: [...reg.dependencies],\n });\n } else {\n effective.set(reg.token, { space: 'value', token: reg.token, value: reg.implementation });\n knownLifetimes.set(reg.token, LoadAs.Singleton);\n }\n }\n break;\n }\n case 'classes': {\n const token = resolveKey(write.key, write.byName, 'classes');\n note(write.implementation, undefined);\n if (!write.byName) note(token, undefined);\n effective.set(token, {\n space: 'class',\n token,\n implementation: write.implementation,\n // Lifetime priority: the replacement's own @Component scope, then\n // the lifetime the composition already knows for the token, then\n // the TOKEN class's declared @Component scope — a plain stub\n // class replacing a Singleton-scoped production service must not\n // silently degrade to Transient (captive-lifetime validation\n // would reject the production dependents).\n loadAs:\n componentScope(write.implementation)\n ?? knownLifetimes.get(token)\n ?? componentScope(token),\n });\n break;\n }\n case 'functions': {\n const token = resolveKey(write.key, write.byName, 'functions');\n const prior = effective.get(token);\n effective.set(token, {\n space: 'factory',\n token,\n factory: write.factory,\n // preserve configured lifetime unless the scenario overrides it\n loadAs: prior && prior.space === 'factory' ? prior.loadAs : knownLifetimes.get(token),\n deps: prior && prior.space === 'factory' ? prior.deps : undefined,\n });\n note(token, undefined);\n break;\n }\n case 'values': {\n const token = resolveKey(write.key, write.byName, 'values');\n effective.set(token, { space: 'value', token, value: write.value });\n note(token, LoadAs.Singleton);\n break;\n }\n case 'methods': {\n if (write.byName && ambiguousNames.has(write.key as string)) {\n throw new AmbiguousNameKeyError(write.key as string, 'methods');\n }\n const token = write.byName && knownByName.has(write.key as string)\n ? knownByName.get(write.key as string)!\n : write.key;\n methodWrites.push({\n key: token,\n byName: write.byName && !knownByName.has(write.key as string),\n methods: new Map(write.methods),\n });\n break;\n }\n }\n }\n\n // ---- Apply effective registrations to the fresh root\n const borrowed = new Set(options.borrowedTokens);\n for (const entry of effective.values()) {\n if (entry.space === 'class') {\n this.registerClassBinding(root, entry.token, entry.implementation, entry.loadAs);\n } else if (entry.space === 'factory') {\n root.registerFunction(entry.token, entry.factory, {\n loadAs: entry.loadAs,\n param: entry.deps,\n ...(borrowed.has(entry.token) ? { owned: false } : {}),\n } as any);\n } else {\n const value = entry.value;\n root.registerFunction(entry.token, () => value, {\n loadAs: LoadAs.Singleton,\n ...(borrowed.has(entry.token) ? { owned: false } : {}),\n } as any);\n }\n }\n\n // ---- Fresh watch/expectation state + the ioc decoration seam\n const registry = new WatchRegistry();\n // merge method writes: LWW per (entry key, method), deep-merge per token\n const mergedMethods = new Map<Token, { byName: boolean; methods: Map<string, MethodDescriptor> }>();\n for (const write of methodWrites) {\n const existing = mergedMethods.get(write.key);\n if (existing) {\n for (const [name, descriptor] of write.methods) existing.methods.set(name, descriptor);\n } else {\n mergedMethods.set(write.key, { byName: write.byName, methods: new Map(write.methods) });\n }\n }\n for (const [key, { byName, methods }] of mergedMethods) {\n registry.addEntry({ key, byName, methods });\n }\n (root as any).setInstanceDecorator(createMethodDecorator(registry));\n\n const env: TestEnvironment = {\n root: root as IContainer,\n get: (token, params) => ExecutionContext.run(root, () => root.get(token as any, params)),\n instance: (cls, params) => ExecutionContext.run(root, () => root.instance(cls, params)),\n extend: () => root.extend() as IContainer,\n verify: async () => registry.verify(),\n dispose: () => root.dispose(),\n [ENV_REGISTRY]: registry,\n };\n return env;\n }\n\n /**\n * Register a class binding. When token === implementation this is a plain\n * class registration. Otherwise an alias factory resolves the implementation\n * through real IoC, mirroring the implementation's effective lifetime so\n * lifetime validation (captive-lifetime checks) stays honest.\n */\n private registerClassBinding(\n root: IContainer,\n token: Token,\n implementation: ClassLike,\n configuredLoadAs?: LoadAs,\n ): void {\n const loadAs = configuredLoadAs ?? componentScope(implementation) ?? LoadAs.Transient;\n root.registerClass(implementation as any, configuredLoadAs !== undefined ? ({ loadAs } as any) : undefined);\n if (token === implementation) return;\n\n if (loadAs === LoadAs.Singleton) {\n root.registerFunction(token, () => root.get(implementation as any), {\n loadAs: LoadAs.Singleton,\n owned: false,\n } as any);\n } else {\n root.registerFunction(token, (scope: IContainer) => scope.get(implementation as any), {\n loadAs,\n param: [SCOPED_CONTAINER],\n owned: false,\n } as any);\n }\n }\n}\n\n/** Create a persistent immutable real-IoC test composition builder. */\nexport function testIoc(...inputs: UseInput[]): TestIocBuilder {\n return TestIocBuilder.create(inputs);\n}\n","/**\n * Diagnostics are first-class: every error names the real token/method and\n * what was expected vs what happened, never only internal wrapper machinery.\n */\n\nexport class TestingError extends Error {\n constructor(message: string) {\n super(message);\n this.name = new.target.name;\n }\n}\n\n/** Thrown at build() when the installed @noego/ioc lacks the decoration seam. */\nexport class MissingIocSeamError extends TestingError {\n constructor() {\n super(\n '@noego/testing requires an @noego/ioc version that provides ' +\n 'Container.setInstanceDecorator (>= 0.5.x with the instance-decoration seam). ' +\n 'Upgrade @noego/ioc.',\n );\n }\n}\n\n/** test.inspect() on a method that is not watched in this environment. */\nexport class UnwatchedInspectionError extends TestingError {\n constructor(token: string, method: string) {\n super(\n `Method \"${method}\" on ${token} is not watched in this environment. ` +\n 'Only watched methods are inspectable — install test.watch() or any ' +\n 'test.* behavior/expectation descriptor for it.',\n );\n }\n}\n\n/** A call arrived after a test.calls([...]) script was fully consumed. */\nexport class CallScriptExhaustedError extends TestingError {\n constructor(token: string, method: string, scriptLength: number, callIndex: number) {\n super(\n `Call #${callIndex} to ${token}.${method} exceeds its test.calls() script ` +\n `of ${scriptLength} ${scriptLength === 1 ? 'entry' : 'entries'}.`,\n );\n }\n}\n\n/** An exact expectation (once/times/never) was exceeded at call time. */\nexport class ExpectationOverflowError extends TestingError {\n constructor(token: string, method: string, expected: number, attempted: number) {\n super(\n expected === 0\n ? `${token}.${method} was expected never to be called, but it was invoked.`\n : `${token}.${method} was expected exactly ${expected} ` +\n `${expected === 1 ? 'call' : 'calls'}, but call #${attempted} arrived.`,\n );\n }\n}\n\n/** Aggregated under-count failures reported by env.verify(). */\nexport class VerificationError extends TestingError {\n constructor(failures: readonly { token: string; method: string; expected: number; actual: number }[]) {\n super(\n 'Exact method expectations were not satisfied:\\n' +\n failures\n .map(\n (f) =>\n ` - ${f.token}.${f.method}: expected exactly ${f.expected} ` +\n `${f.expected === 1 ? 'call' : 'calls'}, observed ${f.actual}`,\n )\n .join('\\n'),\n );\n }\n}\n\n/** .methods configured for a token whose resolved value has no such callable method. */\nexport class MethodNotCallableError extends TestingError {\n constructor(token: string, method: string) {\n super(\n `Cannot install a test.* descriptor on ${token}.${method}: the resolved ` +\n 'instance has no callable method with that name.',\n );\n }\n}\n\n/** .methods configured for a token that resolved to a non-object value. */\nexport class NonObjectMethodTargetError extends TestingError {\n constructor(token: string) {\n super(\n `.methods() is configured for ${token}, but that token resolved to a ` +\n 'non-object value. Method descriptors apply only to IoC-managed instances.',\n );\n }\n}\n\n/** A string configuration key could not be resolved to a known IoC token. */\nexport class UnknownTokenKeyError extends TestingError {\n constructor(key: string, space: string, known: readonly string[]) {\n super(\n `Unknown ${space} key \"${key}\" — it does not match any token known to this ` +\n 'builder. Pass the class/token itself via a Map, or include the ' +\n 'registration through .use(...). Known tokens: ' +\n (known.length ? known.join(', ') : '(none)'),\n );\n }\n}\n\n/** Invalid descriptor construction (e.g. test.times(-1)). */\nexport class InvalidDescriptorError extends TestingError {}\n\n/**\n * A name-keyed compatibility entry referred to a display name claimed by\n * two or more distinct tokens. Tokens are identities; names are labels —\n * pass the exact token in canonical tuple form instead (spec 04 §5).\n */\nexport class AmbiguousNameKeyError extends TestingError {\n constructor(name: string, space: string) {\n super(\n `.${space}() key \"${name}\" is ambiguous: multiple distinct tokens share that display name. ` +\n `Use the canonical tuple form with the exact token: .${space}([[TheToken, ...]]).`,\n );\n this.name = 'AmbiguousNameKeyError';\n }\n}\n\n\n/**\n * A .methods() class token never matched any constructed instance while a\n * DIFFERENT class with the same display name did construct — the configured\n * behavior silently did not apply. Usual cause: two module registries loaded\n * the same source file (e.g. a vitest test file's import vs a framework\n * harness's native import of the production graph); fix by routing the\n * harness's imports through the caller's registry (testApp:\n * `.importer((p) => import(p))`) or by passing the token the graph actually\n * uses.\n */\nexport class TokenIdentitySplitError extends TestingError {\n constructor(names: readonly string[]) {\n super(\n `token identity split: .methods() entr${names.length === 1 ? 'y' : 'ies'} for ` +\n `${names.map((name) => `\"${name}\"`).join(', ')} never matched a constructed instance, ` +\n `but a DIFFERENT class with the same name was constructed. Two module registries ` +\n `have loaded the same class file (test-file import vs harness graph import) — the ` +\n `configured behavior did not apply. Route the harness's imports through your ` +\n `registry (e.g. testApp .importer((p) => import(p))) or pass the exact token the graph uses.`,\n );\n this.name = 'TokenIdentitySplitError';\n }\n}\n","/**\n * Lowercase `test.*` descriptors — immutable frozen values.\n *\n * Descriptors carry NO mutable state (no cursors, no counters, no histories);\n * all mutable invocation state lives in the built environment, so one\n * descriptor value is safe to share across builders and repeated builds.\n */\n\nimport { InvalidDescriptorError } from './errors';\n\nexport const DESCRIPTOR = Symbol.for('noego:testing:descriptor');\n\n/** A raw custom method wrapper: (original) => replacement. NOT auto-watched. */\nexport type RawMethodWrapper = (\n original: (...args: any[]) => any,\n) => (...args: any[]) => any;\n\nexport interface ReturnsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'returns';\n readonly value: unknown;\n}\n\nexport interface ThrowsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'throws';\n readonly error: unknown;\n}\n\nexport interface OriginalDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'original';\n}\n\nexport interface CallsDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'calls';\n readonly script: readonly BehaviorDescriptor[];\n}\n\nexport type BehaviorDescriptor =\n | ReturnsDescriptor\n | ThrowsDescriptor\n | OriginalDescriptor\n | CallsDescriptor;\n\nexport interface WatchDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'watch';\n readonly wrapper?: RawMethodWrapper;\n}\n\nexport interface ExpectationDescriptor {\n readonly [DESCRIPTOR]: true;\n readonly kind: 'expect';\n /** Exact required call count; 0 for never(). */\n readonly expected: number;\n /** Behavior used for allowed calls; undefined = original effective behavior. */\n readonly behavior?: BehaviorDescriptor;\n}\n\n/** Everything installable through .methods({...}). */\nexport type MethodDescriptor =\n | BehaviorDescriptor\n | WatchDescriptor\n | ExpectationDescriptor\n | RawMethodWrapper;\n\nexport function isDescriptor(value: unknown): value is Exclude<MethodDescriptor, RawMethodWrapper> {\n return typeof value === 'object' && value !== null && (value as any)[DESCRIPTOR] === true;\n}\n\nfunction frozen<T extends object>(value: T): T {\n return Object.freeze(value);\n}\n\nfunction assertBehavior(value: unknown, where: string): asserts value is BehaviorDescriptor {\n if (!isDescriptor(value) || !['returns', 'throws', 'original', 'calls'].includes((value as any).kind)) {\n throw new InvalidDescriptorError(\n `${where} requires a behavior descriptor (test.returns/throws/original/calls).`,\n );\n }\n}\n\nexport const test = {\n /** Return the supplied value when the method is called. Auto-watches. */\n returns(value: unknown): ReturnsDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'returns' as const, value });\n },\n\n /** Throw/reject with the supplied error. Auto-watches. */\n throws(error: unknown): ThrowsDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'throws' as const, error });\n },\n\n /** Invoke the original effective method. Auto-watches. */\n original(): OriginalDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'original' as const });\n },\n\n /**\n * Per-invocation behavior script: call 1 uses entry 1, and so on. A call\n * after exhaustion fails immediately. Unused entries do not fail verification.\n */\n calls(script: readonly BehaviorDescriptor[]): CallsDescriptor {\n if (!Array.isArray(script)) {\n throw new InvalidDescriptorError('test.calls() requires an array of behavior descriptors.');\n }\n script.forEach((entry, i) => assertBehavior(entry, `test.calls() entry #${i + 1}`));\n return frozen({ [DESCRIPTOR]: true as const, kind: 'calls' as const, script: Object.freeze([...script]) });\n },\n\n /**\n * Keep original behavior and record calls. With a raw wrapper argument, the\n * wrapper's behavior runs and is recorded.\n */\n watch(wrapper?: RawMethodWrapper): WatchDescriptor {\n if (wrapper !== undefined && typeof wrapper !== 'function') {\n throw new InvalidDescriptorError('test.watch() accepts only a raw wrapper function.');\n }\n return frozen({ [DESCRIPTOR]: true as const, kind: 'watch' as const, wrapper });\n },\n\n /** Require exactly one call; with no behavior, the original runs. */\n once(behavior?: BehaviorDescriptor): ExpectationDescriptor {\n if (behavior !== undefined) assertBehavior(behavior, 'test.once()');\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: 1, behavior });\n },\n\n /** Require exactly `count` calls; with no behavior, the original runs. */\n times(count: number, behavior?: BehaviorDescriptor): ExpectationDescriptor {\n if (!Number.isInteger(count) || count < 0) {\n throw new InvalidDescriptorError(\n `test.times() requires a non-negative integer count, received ${String(count)}.`,\n );\n }\n if (behavior !== undefined) assertBehavior(behavior, 'test.times()');\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: count, behavior });\n },\n\n /** Require zero calls; the first invocation fails and skips the original. */\n never(): ExpectationDescriptor {\n return frozen({ [DESCRIPTOR]: true as const, kind: 'expect' as const, expected: 0 });\n },\n\n /** Read the recorded history for a watched method in one environment. */\n inspect(environment: unknown, token: unknown, method: string): MethodInspection {\n const registry = (environment as any)?.[ENV_REGISTRY];\n if (!registry) {\n throw new InvalidDescriptorError(\n 'test.inspect() requires a built @noego/testing environment as its first argument.',\n );\n }\n return registry.inspect(token, method);\n },\n};\n\nObject.freeze(test);\n\n/** Symbol under which a built environment exposes its watch registry. */\nexport const ENV_REGISTRY = Symbol.for('noego:testing:env-registry');\n\nexport interface RecordedCall {\n /** 1-based invocation index in this environment. */\n readonly index: number;\n readonly args: readonly unknown[];\n /** Present once the call returned (resolved value for async methods). */\n readonly result?: unknown;\n /** Present once the call threw/rejected. */\n readonly error?: unknown;\n /** True while an async outcome is still pending. */\n readonly pending: boolean;\n readonly timestamp: number;\n}\n\nexport interface MethodInspection {\n readonly count: number;\n readonly calls: readonly RecordedCall[];\n}\n","/**\n * Environment-owned method behavior/observation runtime.\n *\n * All mutable state (histories, expectation counters, calls-script cursors)\n * lives here, created fresh at every build(). Descriptors stay immutable.\n */\n\nimport {\n type BehaviorDescriptor,\n type ExpectationDescriptor,\n type MethodDescriptor,\n type MethodInspection,\n type RawMethodWrapper,\n type RecordedCall,\n isDescriptor,\n} from './descriptors';\nimport {\n CallScriptExhaustedError,\n TokenIdentitySplitError,\n ExpectationOverflowError,\n MethodNotCallableError,\n NonObjectMethodTargetError,\n UnwatchedInspectionError,\n VerificationError,\n} from './errors';\n\nconst CONTEXT_WRAPPED = Symbol.for('ioc:context-wrapped');\nconst CONTEXT_OWNER = Symbol.for('ioc:context-owner');\n\nexport function tokenLabel(token: unknown): string {\n if (typeof token === 'function') return (token as { name?: string }).name || '[anonymous class]';\n if (typeof token === 'symbol') return String(token);\n return String(token);\n}\n\ninterface MutableCall {\n index: number;\n args: readonly unknown[];\n result?: unknown;\n error?: unknown;\n pending: boolean;\n timestamp: number;\n}\n\nexport class MethodState {\n readonly calls: MutableCall[] = [];\n /** Actual invocation count (includes the call currently executing). */\n actual = 0;\n /** Cursor into a test.calls() script. */\n scriptCursor = 0;\n\n constructor(\n readonly tokenName: string,\n readonly method: string,\n readonly descriptor: Exclude<MethodDescriptor, RawMethodWrapper>,\n ) {}\n\n get expectation(): ExpectationDescriptor | undefined {\n return this.descriptor.kind === 'expect' ? this.descriptor : undefined;\n }\n\n inspection(): MethodInspection {\n return {\n count: this.calls.length,\n calls: this.calls.map((c) => ({ ...c, args: [...c.args] }) as RecordedCall),\n };\n }\n}\n\n/** One method-config entry: how it was keyed, and its per-method descriptors. */\nexport interface MethodConfigEntry {\n /** Exact token (class/symbol/string) or a name string matched lazily. */\n readonly key: unknown;\n readonly byName: boolean;\n readonly methods: ReadonlyMap<string, MethodDescriptor>;\n}\n\nexport class WatchRegistry {\n /** entry-identity → method → state. Entries share states across instances. */\n private readonly states = new Map<unknown, Map<string, MethodState>>();\n private readonly nameIndex = new Map<string, unknown>();\n private readonly entries: MethodConfigEntry[] = [];\n /** Class-token entries that identity-matched at least one construction. */\n private readonly matchedEntryKeys = new Set<unknown>();\n /** Constructed class tokens that matched NO entry, by display name. */\n private readonly unmatchedConstructedByName = new Map<string, unknown>();\n\n addEntry(entry: MethodConfigEntry): void {\n this.entries.push(entry);\n const byMethod = new Map<string, MethodState>();\n for (const [method, descriptor] of entry.methods) {\n if (typeof descriptor === 'function') continue; // raw wrapper: unwatched, no state\n byMethod.set(method, new MethodState(this.entryLabel(entry), method, descriptor));\n }\n this.states.set(entry.key, byMethod);\n if (entry.byName) this.nameIndex.set(entry.key as string, entry.key);\n else if (typeof entry.key === 'function' && (entry.key as any).name) {\n this.nameIndex.set((entry.key as any).name, entry.key);\n }\n }\n\n private entryLabel(entry: MethodConfigEntry): string {\n return entry.byName ? String(entry.key) : tokenLabel(entry.key);\n }\n\n /** Entries applying to a resolving token (exact identity or name match). */\n matchEntries(token: unknown): MethodConfigEntry[] {\n const name = typeof token === 'function' ? (token as any).name : typeof token === 'string' ? token : undefined;\n const matched = this.entries.filter(\n (entry) => entry.key === token || (entry.byName && name !== undefined && entry.key === name),\n );\n // Split-registry tripwire bookkeeping (spec 04 §17 \"duplicate\n // human-readable token names without identity collision\"): remember which\n // class-token entries genuinely bound, and which constructions bound\n // nothing — verify() cross-references the two by display name.\n if (matched.length) {\n for (const entry of matched) this.matchedEntryKeys.add(entry.key);\n } else if (typeof token === 'function' && name) {\n this.unmatchedConstructedByName.set(name, token);\n }\n return matched;\n }\n\n state(entryKey: unknown, method: string): MethodState | undefined {\n return this.states.get(entryKey)?.get(method);\n }\n\n inspect(token: unknown, method: string): MethodInspection {\n const label = tokenLabel(token);\n const keys: unknown[] = [token];\n const name = typeof token === 'function' ? (token as any).name : typeof token === 'string' ? token : undefined;\n if (name !== undefined && this.nameIndex.has(name)) keys.push(this.nameIndex.get(name));\n for (const key of keys) {\n const state = this.states.get(key)?.get(method);\n if (state) return state.inspection();\n }\n throw new UnwatchedInspectionError(label, method);\n }\n\n /**\n * Class-token entries that never identity-matched a construction while a\n * DIFFERENT class with the same display name did construct. This is the\n * split-module-registry signature (a test-file class object vs the graph's\n * own load of the same file) — or two genuinely distinct same-named tokens\n * where the configured one never resolved. Either way the configured\n * behavior silently did not apply, which must be loud.\n */\n private identitySplits(): { name: string; entryToken: unknown }[] {\n const splits: { name: string; entryToken: unknown }[] = [];\n for (const entry of this.entries) {\n if (entry.byName || typeof entry.key !== 'function') continue;\n if (this.matchedEntryKeys.has(entry.key)) continue;\n const name = (entry.key as { name?: string }).name;\n if (!name) continue;\n const constructed = this.unmatchedConstructedByName.get(name);\n if (constructed !== undefined && constructed !== entry.key) {\n splits.push({ name, entryToken: entry.key });\n }\n }\n return splits;\n }\n\n /** Repeatable snapshot check of all exact expectations. */\n verify(): void {\n const splits = this.identitySplits();\n if (splits.length) {\n throw new TokenIdentitySplitError(splits.map((split) => split.name));\n }\n const failures: { token: string; method: string; expected: number; actual: number }[] = [];\n for (const byMethod of this.states.values()) {\n for (const state of byMethod.values()) {\n const expectation = state.expectation;\n if (!expectation) continue;\n if (state.actual !== expectation.expected) {\n failures.push({\n token: state.tokenName,\n method: state.method,\n expected: expectation.expected,\n actual: state.actual,\n });\n }\n }\n }\n if (failures.length) throw new VerificationError(failures);\n }\n}\n\nfunction isPromiseLike(value: unknown): value is Promise<unknown> {\n return !!value && typeof (value as any).then === 'function';\n}\n\nfunction recordOutcome(call: MutableCall, outcome: unknown, threw: boolean): unknown {\n if (!threw && isPromiseLike(outcome)) {\n call.pending = true;\n outcome.then(\n (value) => {\n call.result = value;\n call.pending = false;\n },\n (error) => {\n call.error = error;\n call.pending = false;\n },\n );\n return outcome;\n }\n call.pending = false;\n if (threw) call.error = outcome;\n else call.result = outcome;\n return outcome;\n}\n\n/**\n * Build the ioc instance decorator for one environment.\n *\n * Identity-stable (WeakMap), preserves sync/async call shape and `this`\n * binding, forwards the ioc context symbols by delegating to the underlying\n * (context-wrapped) target for everything unconfigured.\n */\nexport function createMethodDecorator(registry: WatchRegistry): (instance: any, token: any) => any {\n const wrappers = new WeakMap<object, any>();\n\n return function decorate(instance: any, token: any): any {\n const entries = registry.matchEntries(token);\n if (entries.length === 0) return instance;\n\n if (instance === null || (typeof instance !== 'object' && typeof instance !== 'function')) {\n throw new NonObjectMethodTargetError(tokenLabel(token));\n }\n\n if (wrappers.has(instance)) return wrappers.get(instance);\n\n // Effective per-method config: entries merge in write order, LWW per method\n const effective = new Map<string, { entryKey: unknown; descriptor: MethodDescriptor }>();\n for (const entry of entries) {\n for (const [method, descriptor] of entry.methods) {\n effective.set(method, { entryKey: entry.key, descriptor });\n }\n }\n\n // Validate configured methods exist and are callable\n for (const method of effective.keys()) {\n if (typeof instance[method] !== 'function') {\n throw new MethodNotCallableError(tokenLabel(token), method);\n }\n }\n\n const methodCache = new Map<string, (...args: any[]) => any>();\n\n const proxy = new Proxy(instance, {\n get(target, prop, receiver) {\n if (typeof prop === 'string' && effective.has(prop)) {\n let wrapped = methodCache.get(prop);\n if (!wrapped) {\n const { entryKey, descriptor } = effective.get(prop)!;\n wrapped = buildMethodWrapper(target, prop, descriptor, registry.state(entryKey, prop));\n methodCache.set(prop, wrapped);\n }\n return wrapped;\n }\n // Everything else (including ioc context symbols) delegates to the\n // underlying — usually context-wrapped — target.\n if (prop === CONTEXT_WRAPPED || prop === CONTEXT_OWNER) return (target as any)[prop];\n return Reflect.get(target, prop, receiver);\n },\n });\n\n wrappers.set(instance, proxy);\n return proxy;\n };\n}\n\nfunction buildMethodWrapper(\n target: any,\n method: string,\n descriptor: MethodDescriptor,\n state: MethodState | undefined,\n): (...args: any[]) => any {\n // The original effective method, read through the underlying target so the\n // ioc context proxy still owns context entry for real invocations.\n const callOriginal = (self: any, args: any[]) => {\n const fn = target[method];\n return fn.apply(self === undefined ? target : self, args);\n };\n\n // Raw custom wrapper: installed as-is, NOT watched, no recording.\n if (typeof descriptor === 'function') {\n const replacement = descriptor((...args: any[]) => callOriginal(target, args));\n return function (this: any, ...args: any[]) {\n return replacement.apply(this, args);\n };\n }\n\n if (!isDescriptor(descriptor)) {\n // Should be unreachable: builder validates descriptors on write.\n throw new TypeError(`Invalid method descriptor for ${method}`);\n }\n\n return function (this: any, ...args: any[]) {\n if (!state) throw new TypeError(`Missing method state for ${method}`);\n\n const expectation = state.expectation;\n const attempted = state.actual + 1;\n\n // Overflow fails immediately and never runs behavior/original\n if (expectation && attempted > expectation.expected) {\n state.actual = attempted;\n throw new ExpectationOverflowError(state.tokenName, method, expectation.expected, attempted);\n }\n\n state.actual = attempted;\n const call: MutableCall = {\n index: attempted,\n args: [...args],\n pending: false,\n timestamp: Date.now(),\n };\n state.calls.push(call);\n\n // Effective behavior for this invocation\n let behavior: BehaviorDescriptor | 'original-effective' | RawMethodWrapper;\n const base =\n descriptor.kind === 'expect'\n ? (descriptor.behavior ?? 'original-effective')\n : descriptor.kind === 'watch'\n ? (descriptor.wrapper ?? 'original-effective')\n : descriptor;\n\n if (base !== 'original-effective' && typeof base !== 'function' && base !== undefined && base.kind === 'calls') {\n if (state.scriptCursor >= base.script.length) {\n throw new CallScriptExhaustedError(state.tokenName, method, base.script.length, attempted);\n }\n behavior = base.script[state.scriptCursor]!;\n state.scriptCursor += 1;\n } else {\n behavior = base;\n }\n\n try {\n let outcome: unknown;\n if (behavior === 'original-effective') {\n outcome = callOriginal(this, args);\n } else if (typeof behavior === 'function') {\n // test.watch(rawWrapper): wrapper behavior runs and is recorded\n outcome = behavior((...inner: any[]) => callOriginal(this, inner)).apply(this, args);\n } else if (behavior.kind === 'returns') {\n outcome = behavior.value;\n } else if (behavior.kind === 'throws') {\n throw behavior.error;\n } else if (behavior.kind === 'original') {\n outcome = callOriginal(this, args);\n } else {\n throw new TypeError(`Nested test.calls() scripts are not supported (${method}).`);\n }\n return recordOutcome(call, outcome, false);\n } catch (error) {\n recordOutcome(call, error, true);\n throw error;\n }\n };\n}\n","/**\n * `installSeams` — apply the canonical substitution language (classes /\n * values / methods, exact tokens, `test.*` descriptors) to an EXISTING\n * container instead of a fresh `testIoc()` root.\n *\n * This is the seam surface for composed harnesses (application slices,\n * backend harnesses) that own their container construction but must speak\n * the same substitution language as every other tier: one vocabulary, one\n * verify contract, no harness-specific stubbing options.\n *\n * The returned handle carries the same watch registry marker as a\n * `TestEnvironment`, so `test.inspect(handle, Token, 'method')` works\n * unchanged.\n */\nimport { LoadAs, SCOPED_CONTAINER, type IContainer } from '@noego/ioc';\nimport { ENV_REGISTRY, isDescriptor, type MethodDescriptor } from './descriptors';\nimport { createMethodDecorator, WatchRegistry, tokenLabel } from './method_state';\nimport { InvalidDescriptorError, MissingIocSeamError } from './errors';\nimport type { ConfigMap, MethodsConfig } from './builder';\n\nconst COMPONENT_OPTIONS_KEY = Symbol.for('ioc:component:options');\n\ntype Token = unknown;\ntype ClassLike = new (...args: any[]) => any;\n\nexport interface SeamsConfig {\n classes?: ConfigMap<ClassLike>;\n values?: ConfigMap<unknown>;\n methods?: MethodsConfig;\n}\n\nexport interface InstalledSeams {\n /** Finalize call-count expectations (same semantics as env.verify()). */\n verify(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\nfunction componentScope(cls: any): LoadAs | undefined {\n const options =\n typeof Reflect !== 'undefined' && (Reflect as any).getMetadata\n ? (Reflect as any).getMetadata(COMPONENT_OPTIONS_KEY, cls)\n : undefined;\n return options?.scope;\n}\n\nfunction* tupleEntries<V>(config: ConfigMap<V>, space: string): Iterable<[Token, V]> {\n if (Array.isArray(config)) {\n for (const entry of config as ReadonlyArray<readonly [Token, V]>) {\n if (!Array.isArray(entry) || entry.length !== 2) {\n throw new InvalidDescriptorError(\n `canonical ${space} entries are [token, value] tuples, e.g. .${space}([[Token, Impl]])`,\n );\n }\n yield [entry[0], entry[1]];\n }\n } else if (config instanceof Map) {\n for (const [key, value] of config) yield [key, value];\n } else {\n throw new InvalidDescriptorError(\n `installSeams accepts only exact-token ${space} entries (tuple array or Map); ` +\n 'name-keyed records need the composition knowledge only testIoc() has.',\n );\n }\n}\n\n/**\n * Register a class replacement honoring the replacement's own @Component\n * scope, falling back to the token class's declared scope — a plain stub\n * replacing a Singleton-scoped production service must not silently degrade\n * to Transient (mirrors TestIocBuilder.registerClassBinding).\n */\nfunction registerClassBinding(root: IContainer, token: Token, implementation: ClassLike): void {\n const loadAs = componentScope(implementation) ?? componentScope(token) ?? LoadAs.Singleton;\n (root as any).registerClass(implementation, { loadAs });\n if (token === implementation) return;\n if (loadAs === LoadAs.Singleton) {\n (root as any).registerFunction(token, () => (root as any).get(implementation), {\n loadAs: LoadAs.Singleton,\n });\n } else {\n (root as any).registerFunction(token, (scope: IContainer) => (scope as any).get(implementation), {\n loadAs,\n param: [SCOPED_CONTAINER],\n });\n }\n}\n\nexport function installSeams(root: IContainer, config: SeamsConfig): InstalledSeams {\n if (typeof (root as any).setInstanceDecorator !== 'function') {\n throw new MissingIocSeamError();\n }\n\n for (const [token, implementation] of tupleEntries(config.classes ?? [], 'classes')) {\n registerClassBinding(root, token, implementation);\n }\n for (const [token, value] of tupleEntries(config.values ?? [], 'values')) {\n (root as any).registerFunction(token, () => value, { loadAs: LoadAs.Singleton });\n }\n\n const registry = new WatchRegistry();\n // Merge per token (LWW per method) before registering: a registry entry per\n // tuple would let a later tuple for the same token shadow the earlier one's\n // method state (mirrors TestIocBuilder's mergedMethods).\n const mergedMethods = new Map<Token, Map<string, MethodDescriptor>>();\n for (const [token, methodsInput] of tupleEntries(config.methods ?? [], 'methods')) {\n const methods = mergedMethods.get(token) ?? new Map<string, MethodDescriptor>();\n const entries =\n methodsInput instanceof Map\n ? methodsInput.entries()\n : Object.entries(methodsInput as Record<string, MethodDescriptor>);\n for (const [name, descriptor] of entries) {\n if (typeof descriptor !== 'function' && !isDescriptor(descriptor)) {\n throw new InvalidDescriptorError(\n `.methods entry ${tokenLabel(token)}.${name} must be a test.* descriptor or a raw wrapper function.`,\n );\n }\n methods.set(name, descriptor);\n }\n mergedMethods.set(token, methods);\n }\n for (const [key, methods] of mergedMethods) {\n registry.addEntry({ key, byName: false, methods });\n }\n (root as any).setInstanceDecorator(createMethodDecorator(registry));\n\n return {\n verify: async () => registry.verify(),\n [ENV_REGISTRY]: registry,\n };\n}\n","import { isDescriptor, type MethodDescriptor } from './descriptors';\nimport { InvalidDescriptorError } from './errors';\n\nexport type TestOwner = 'server' | 'client' | 'main' | 'renderer';\nexport interface ReplacementOptions { readonly owner?: TestOwner }\nexport interface LoaderReference { readonly path: string; readonly export: string }\nexport type LoaderIdentity = string | LoaderReference;\nexport type ClassToken<T = any> = abstract new (...args: any[]) => T;\nexport type ReplacementClass<T = any> = new (...args: any[]) => T;\nexport type ReplacementFunction = (...args: any[]) => any;\nexport type ExecutableReplacement = ReplacementFunction | MethodDescriptor;\n\ninterface EntryBase {\n readonly owner?: TestOwner;\n /** Fluent entry index, prefixed by each enclosing .use entry index. */\n readonly provenance: readonly number[];\n}\nexport type StubEntry = EntryBase & (\n | { readonly kind: 'class'; readonly target: unknown; readonly replacement: ReplacementClass }\n | { readonly kind: 'function'; readonly target: unknown; readonly replacement: ReplacementFunction }\n | { readonly kind: 'value'; readonly target: unknown; readonly replacement: unknown }\n | { readonly kind: 'method'; readonly target: unknown; readonly method: string; readonly replacement: MethodDescriptor }\n | { readonly kind: 'middleware'; readonly target: string; readonly replacement: ExecutableReplacement }\n | { readonly kind: 'load'; readonly target: LoaderReference; readonly replacement: ExecutableReplacement }\n);\n\ntype EntryInput = StubEntry extends infer E\n ? E extends StubEntry ? Omit<E, 'provenance' | 'owner'> : never : never;\n\nconst owners: readonly TestOwner[] = ['server', 'client', 'main', 'renderer'];\nconst logs = new WeakMap<TestStub, { entries: readonly StubEntry[]; calls: number }>();\n\nfunction fail(message: string): never { throw new InvalidDescriptorError(message); }\nfunction label(value: unknown, name: string): asserts value is string {\n if (typeof value !== 'string' || !value.trim() || /[\\u0000-\\u001f\\u007f]/.test(value)) {\n fail(name + ' requires a nonempty identity');\n }\n}\nfunction token(value: unknown): void {\n if (value === null || value === undefined || (typeof value === 'string' && !value.trim())) {\n fail('replacement requires an exact declared token');\n }\n}\nfunction executable(value: unknown, behaviorOnly = false, active = new Set<unknown>()): void {\n if (!behaviorOnly && typeof value === 'function') return;\n if (!isDescriptor(value)) fail('replacement requires a function or test.* descriptor');\n if (active.has(value)) fail('cyclic test.* descriptor');\n active.add(value);\n const d = value as any;\n try {\n if (d.kind === 'returns' || d.kind === 'throws' || d.kind === 'original') return;\n if (!behaviorOnly && d.kind === 'watch' && (d.wrapper === undefined || typeof d.wrapper === 'function')) return;\n if (!behaviorOnly && d.kind === 'expect' && Number.isInteger(d.expected) && d.expected >= 0) {\n if (d.behavior !== undefined) executable(d.behavior, true, active);\n return;\n }\n if (d.kind === 'calls' && Array.isArray(d.script)) {\n for (const child of d.script) executable(child, true, active);\n return;\n }\n fail('invalid test.* descriptor');\n } finally { active.delete(value); }\n}\nfunction snapshotExecutable(value: ExecutableReplacement): ExecutableReplacement {\n executable(value);\n if (typeof value === 'function') return value;\n if (value.kind === 'calls') {\n return Object.freeze({ ...value, script: Object.freeze(value.script.map(v => snapshotExecutable(v))) }) as MethodDescriptor;\n }\n if (value.kind === 'expect' && value.behavior !== undefined) {\n return Object.freeze({ ...value, behavior: snapshotExecutable(value.behavior) }) as MethodDescriptor;\n }\n return Object.freeze({ ...value });\n}\nfunction normalizeLoader(identity: LoaderIdentity): LoaderReference {\n const ref = typeof identity === 'string' ? { path: identity, export: 'default' } : identity;\n if (!ref || typeof ref !== 'object' || Reflect.ownKeys(ref).some(k => k !== 'path' && k !== 'export')) {\n fail('.load requires a project-relative path or { path, export }');\n }\n label(ref.path, '.load path');\n label(ref.export, '.load export');\n if (/^[\\/\\\\]|[\\\\?#:]/.test(ref.path) || ref.path.split('/').some(s => !s || s === '.' || s === '..')) {\n fail('.load requires a normalized project-relative source path');\n }\n return Object.freeze({ path: ref.path, export: ref.export });\n}\nfunction append(stub: TestStub, input: EntryInput, options?: ReplacementOptions): TestStub {\n if (options !== undefined && (!options || typeof options !== 'object' || Array.isArray(options)\n || Reflect.ownKeys(options).some(k => k !== 'owner')\n || (options.owner !== undefined && !owners.includes(options.owner)))) {\n fail('replacement options accept only owner: server | client | main | renderer');\n }\n const log = logs.get(stub)!;\n const entry = Object.freeze({ ...input, owner: options?.owner, provenance: Object.freeze([log.calls]) }) as StubEntry;\n return make([...log.entries, entry], log.calls + 1);\n}\n\n/** Immutable replacement description only; no container, resources or call history. */\nexport class TestStub {\n private constructor() {}\n class<T>(target: ClassToken<T>, replacement: ReplacementClass<T>, options?: ReplacementOptions): TestStub {\n token(target);\n if (typeof target !== 'function' || typeof replacement !== 'function' || !replacement.prototype) {\n fail('.class requires class tokens and a replacement constructor');\n }\n return append(this, { kind: 'class', target, replacement }, options);\n }\n function(target: unknown, replacement: ReplacementFunction, options?: ReplacementOptions): TestStub {\n token(target);\n if (typeof replacement !== 'function') fail('.function requires a callable/provider replacement');\n return append(this, { kind: 'function', target, replacement }, options);\n }\n method(target: unknown, method: string, replacement: MethodDescriptor, options?: ReplacementOptions): TestStub {\n token(target); label(method, '.method');\n return append(this, { kind: 'method', target, method, replacement: snapshotExecutable(replacement) as MethodDescriptor }, options);\n }\n value(target: unknown, replacement: unknown, options?: ReplacementOptions): TestStub {\n token(target);\n // Caller values are deliberately neither cloned nor frozen.\n return append(this, { kind: 'value', target, replacement }, options);\n }\n middleware(target: string, replacement: ExecutableReplacement, options?: ReplacementOptions): TestStub {\n label(target, '.middleware');\n return append(this, { kind: 'middleware', target, replacement: snapshotExecutable(replacement) }, options);\n }\n load(target: LoaderIdentity, replacement: ExecutableReplacement, options?: ReplacementOptions): TestStub {\n return append(this, { kind: 'load', target: normalizeLoader(target), replacement: snapshotExecutable(replacement) }, options);\n }\n use(other: TestStub): TestStub {\n const incoming = stubEntries(other);\n const log = logs.get(this)!;\n // Flatten at composition time. Only genuine immutable descriptions are accepted:\n // recursive object graphs and arbitrary functions never enter the log.\n return make([...log.entries, ...incoming.map(entry => Object.freeze({\n ...entry, provenance: Object.freeze([log.calls, ...entry.provenance]),\n }))], log.calls + 1);\n }\n}\nfunction make(entries: readonly StubEntry[], calls: number): TestStub {\n const stub = Object.create(TestStub.prototype) as TestStub;\n logs.set(stub, { entries: Object.freeze([...entries]), calls });\n return Object.freeze(stub);\n}\nexport function testStub(): TestStub { return make([], 0); }\n/** Framework adapter input. Entries are descriptions, not resolved replacements. */\nexport function stubEntries(stub: TestStub): readonly StubEntry[] {\n const log = logs.get(stub);\n if (!log) fail('.use requires an immutable testStub description (cyclic/foreign objects are not supported)');\n return log.entries;\n}\n","/** Shared source selection. Never parses source or constructs a runtime graph. */\nexport type OwnerSelection =\n | { readonly module: string | readonly string[]; readonly path?: never }\n | { readonly path: readonly string[]; readonly module?: never }\n | { readonly module?: never; readonly path?: never };\nexport interface SourceSelectionEntry { readonly path: string; readonly module?: string | null }\nexport interface SourceSelectionOptions {\n readonly owner?: string;\n readonly native?: boolean;\n /** Declared modules including empty modules, supplied by the production collector. */\n readonly modules?: readonly string[];\n}\nexport class SourceSelectionError extends Error {\n readonly code = 'testing/selection';\n constructor(message: string, readonly owner?: string, readonly choices: readonly string[] = []) {\n super((owner ? owner + ': ' : '') + message);\n this.name = 'SourceSelectionError';\n }\n}\nfunction record(value: unknown): value is Record<string, unknown> {\n return !!value && typeof value === 'object' && !Array.isArray(value)\n && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);\n}\ntype NormalizedOwnerSelection =\n | { readonly module: readonly string[]; readonly path?: never }\n | { readonly path: readonly string[]; readonly module?: never }\n | { readonly module?: never; readonly path?: never };\nfunction normalizeOwner(value: unknown, owner?: string): NormalizedOwnerSelection {\n const fail = (message: string): never => { throw new SourceSelectionError(message, owner); };\n if (!record(value)) return fail('select an owner with module, path, or {}');\n const keys = Reflect.ownKeys(value);\n if (keys.some(k => k !== 'module' && k !== 'path') || keys.length > 1) {\n return fail('select module OR path, or {}; no other selector keys are supported');\n }\n if (!keys.length) return Object.freeze({});\n const key = keys[0] as 'module' | 'path';\n const input = value[key];\n const list = key === 'module' && typeof input === 'string' ? [input] : input;\n if (!Array.isArray(list) || !list.length || list.some(x => typeof x !== 'string' || !x.trim() || /[\\u0000-\\u001f\\u007f]/.test(x))) {\n return fail(key + ' requires nonempty ' + (key === 'module' ? 'name(s)' : 'path array'));\n }\n const unique = Object.freeze([...new Set(list as string[])]);\n return key === 'module'\n ? Object.freeze({ module: unique })\n : Object.freeze({ path: unique });\n}\n\n/** Undefined means all declared owners; an explicit empty outer object is an error. */\nexport function normalizeTestSelection(\n selection: unknown,\n declaredOwners: readonly string[],\n): Readonly<Record<string, OwnerSelection>> {\n const declared = new Set(declaredOwners);\n if (selection === undefined) {\n return Object.freeze(Object.fromEntries([...declared].map(owner => [owner, Object.freeze({})])));\n }\n if (!record(selection) || !Reflect.ownKeys(selection).length) {\n throw new SourceSelectionError('select() requires at least one declared owner');\n }\n const result: Record<string, OwnerSelection> = {};\n for (const owner of Reflect.ownKeys(selection)) {\n if (typeof owner !== 'string' || !declared.has(owner)) {\n throw new SourceSelectionError('owner is absent or unknown; available: ' + [...declared].join(', '), String(owner), [...declared]);\n }\n Object.defineProperty(result, owner, { value: normalizeOwner(selection[owner], owner), enumerable: true });\n }\n return Object.freeze(result);\n}\n\nfunction validatePath(path: string, options: SourceSelectionOptions): void {\n const invalid = /[?#*\\[\\]\\\\\\u0000-\\u001f\\u007f]/.test(path)\n || path.includes('://') || path.includes('//')\n || path.split('/').some(segment => segment === '.' || segment === '..');\n const native = options.native && /^[A-Za-z0-9_$-]+(?:\\.[A-Za-z0-9_$-]+)*$/.test(path);\n if (invalid || (!path.startsWith('/') && !native)) {\n throw new SourceSelectionError('invalid source path selector \"' + path + '\"', options.owner);\n }\n}\nfunction matches(path: string, selector: string): boolean {\n if (selector === '/') return path.startsWith('/');\n if (selector.startsWith('/') && selector.endsWith('/')) {\n return path === selector.slice(0, -1) || path.startsWith(selector);\n }\n return path === selector;\n}\n/** Retains source order and every declared operation at each selected source path. */\nexport function selectSourceEntries<T extends SourceSelectionEntry>(\n source: readonly T[],\n input: OwnerSelection,\n options: SourceSelectionOptions = {},\n): T[] {\n const selection = normalizeOwner(input, options.owner);\n if (selection.module !== undefined) {\n const names = selection.module;\n const choices = [...new Set([...source.flatMap(e => e.module == null ? [] : [e.module]), ...(options.modules ?? [])])];\n for (const name of names) if (!choices.includes(name)) {\n throw new SourceSelectionError('unknown module \"' + name + '\"; available: ' + choices.join(', '), options.owner, choices);\n }\n return source.filter(e => e.module != null && names.includes(e.module));\n }\n if (selection.path !== undefined) {\n const paths = selection.path;\n const choices = [...new Set(source.map(e => e.path))];\n for (const path of paths) {\n validatePath(path, options);\n if (!source.some(e => matches(e.path, path))) {\n throw new SourceSelectionError('unknown path \"' + path + '\"; available: ' + choices.join(', '), options.owner, choices);\n }\n }\n return source.filter(e => paths.some(path => matches(e.path, path)));\n }\n return [...source];\n}\n","import type { TestResourceScope, TestResource, VerifiableTestResource } from './lifecycle';\n\n/** Cross-copy ABI: only async propagation is shared; scopes/resources remain per case. */\nconst ANCHOR = Symbol.for('@noego/testing.resource-scope.v1');\ninterface Storage {\n run<T>(scope: TestResourceScope, body: () => T): T;\n getStore(): TestResourceScope | undefined;\n}\nfunction storage(): Storage | undefined {\n const global = globalThis as Record<PropertyKey, any>;\n if (global[ANCHOR]) {\n const existing = global[ANCHOR];\n if (typeof existing.run !== 'function' || typeof existing.getStore !== 'function') {\n throw new Error('Incompatible NoEgo resource-scope v1 channel');\n }\n return existing as Storage;\n }\n let hooks: any;\n try {\n hooks = global.process?.getBuiltinModule?.('node:async_hooks')\n ?? require('node:async_hooks'); // unavailable in native ESM/browser: the catch below is the fallback\n } catch { return undefined; }\n if (!hooks?.AsyncLocalStorage) return undefined;\n const created = new hooks.AsyncLocalStorage() as Storage;\n Object.defineProperty(global, ANCHOR, { value: created, configurable: false, writable: false });\n return created;\n}\n\n/** No synchronous global-current fallback: browser callers retain explicit scope.own(). */\nexport function runInResourceScope<T>(scope: TestResourceScope, body: () => T): T {\n const channel = storage();\n return channel ? channel.run(scope, body) : body();\n}\n\n/** Called by framework build terminals; failed/late admission closes the new resource. */\nexport async function registerTestResource<T extends TestResource>(resource: T, owner = 'resource'): Promise<T> {\n try {\n const scope = storage()?.getStore();\n if (!scope) return resource;\n if (typeof (resource as Partial<VerifiableTestResource>).verify === 'function') {\n scope.environment(resource as T & VerifiableTestResource, owner);\n } else scope.own(resource, owner);\n return resource;\n } catch (primary) {\n try { await resource.dispose(); }\n catch (cleanup) { throw new AggregateError([primary, cleanup], 'Resource admission and cleanup failed', {cause: primary}); }\n throw primary;\n }\n}\n","/** Runner-neutral resource ownership. No global current test or automatic DB allocation. */\nimport { runInResourceScope } from './resource_context';\nexport interface TestResource { dispose(): unknown | Promise<unknown> }\nexport interface VerifiableTestResource extends TestResource {\n verify(): unknown | Promise<unknown>;\n /** Finish/cancel framework-owned finite work before checking expectations. */\n settle?(): unknown | Promise<unknown>;\n}\nexport interface FinalizationFailure {\n readonly owner: string;\n readonly phase: 'test' | 'settle' | 'verify' | 'dispose';\n readonly error: unknown;\n}\nexport class TestFinalizationError extends AggregateError {\n readonly failures: readonly FinalizationFailure[];\n constructor(failures: readonly FinalizationFailure[]) {\n super(failures.map(f => f.error), 'Test finalization failed: ' + failures.map(f => f.owner + '/' + f.phase).join(', '),\n { cause: failures[0]?.error });\n this.name = 'TestFinalizationError';\n this.failures = Object.freeze(failures.map(f => Object.freeze({ ...f })));\n }\n}\ninterface Owned {\n readonly resource: TestResource;\n readonly owner: string;\n verify?: () => unknown | Promise<unknown>;\n settle?: () => unknown | Promise<unknown>;\n}\n\n/**\n * Register immediately after acquisition; acquire dependencies before borrowers.\n * Each test/retry owns a new scope. Resources shared inside one restart test are\n * registered once, and disposed after that test's application borrowers.\n */\nexport class TestResourceScope implements TestResource {\n private readonly resources: Owned[] = [];\n private readonly owned = new Map<TestResource, Owned>();\n private closing: Promise<void> | undefined;\n private complete = false;\n /** Runner finalizers can avoid reporting an already-finished failure twice. */\n get finalized(): boolean { return this.complete; }\n own<T extends TestResource>(resource: T, owner = 'resource'): T {\n if (this.closing) throw new Error('Test resource scope is closed');\n if (!resource || typeof resource.dispose !== 'function') throw new TypeError('Test resource requires dispose()');\n if (!this.owned.has(resource)) {\n const entry = { resource, owner };\n this.owned.set(resource, entry);\n this.resources.push(entry);\n }\n return resource;\n }\n environment<T extends VerifiableTestResource>(resource: T, owner = 'application'): T {\n if (!resource || typeof resource.verify !== 'function') throw new TypeError('Test environment requires verify()');\n this.own(resource, owner);\n this.owned.get(resource)!.verify = () => resource.verify();\n if (resource.settle) this.owned.get(resource)!.settle = () => resource.settle!();\n return resource;\n }\n dispose(): Promise<void> {\n // Assign before any user disposer/verification executes (including reentrant code).\n return this.closing ??= Promise.resolve().then(async () => {\n const failures: FinalizationFailure[] = [];\n const reverse = [...this.resources].reverse();\n for (const entry of reverse) if (entry.settle) {\n try { await entry.settle(); }\n catch (error) { failures.push({ owner: entry.owner, phase: 'settle', error }); }\n }\n for (const entry of reverse) if (entry.verify) {\n try { await entry.verify(); }\n catch (error) { failures.push({ owner: entry.owner, phase: 'verify', error }); }\n }\n for (const entry of reverse) {\n try { await entry.resource.dispose(); }\n catch (error) { failures.push({ owner: entry.owner, phase: 'dispose', error }); }\n }\n if (failures.length) throw new TestFinalizationError(failures);\n }).finally(() => { this.complete = true; });\n }\n}\nexport function createTestScope(): TestResourceScope { return new TestResourceScope(); }\n\n/** Optional runner-neutral boundary; runner adapters can own the same scope directly. */\nexport async function withTestScope<T>(body: (scope: TestResourceScope) => T | Promise<T>): Promise<T> {\n const scope = createTestScope();\n let failed = false;\n let primary: unknown;\n let result!: T;\n try { result = await runInResourceScope(scope, () => body(scope)); }\n catch (error) { failed = true; primary = error; }\n try { await scope.dispose(); }\n catch (error) {\n if (!failed) throw error;\n const cleanup = error instanceof TestFinalizationError\n ? error.failures : [{ owner: 'scope', phase: 'dispose' as const, error }];\n throw new TestFinalizationError([{ owner: 'test', phase: 'test', error: primary }, ...cleanup]);\n }\n if (failed) throw primary;\n return result;\n}\n","import { withTestScope, type TestResourceScope } from './lifecycle';\n\n/**\n * Thin runner adapter for test functions (Vitest 2/3/4, Node test and Jest).\n * The runner still owns test discovery, assertions, retries and timeout reporting.\n * Every invocation/retry gets a new scope; framework builds register themselves\n * under async-capable Node runtimes. Browsers use the explicit scope argument.\n */\nexport function resourceCase<Args extends unknown[], Result>(\n body: (resources: TestResourceScope, ...args: Args) => Result | Promise<Result>,\n): (...args: Args) => Promise<Result> {\n return (...args) => withTestScope(resources => {\n // Use the PUBLIC per-test context, never a global current-test API. This\n // also finalizes a timed-out body that the runner stopped awaiting.\n const context = args.find(value => value && (typeof value === 'object' || typeof value === 'function')\n && typeof (value as {onTestFinished?: unknown}).onTestFinished === 'function') as\n {onTestFinished(callback: () => Promise<void>): void} | undefined;\n context?.onTestFinished(async () => {\n if (!resources.finalized) await resources.dispose();\n });\n return body(resources, ...args);\n });\n}\n","/** Runner configuration/report checks only: these functions never fabricate coverage or test counters. */\nexport const COVERAGE_METRICS = Object.freeze(['lines', 'statements', 'functions', 'branches'] as const);\nexport type CoverageMetric = typeof COVERAGE_METRICS[number];\nexport type CoverageThresholds = Record<CoverageMetric, number>;\nexport interface CoverageExclusion {\n pattern: string;\n kind: 'tests' | 'types' | 'generated' | 'nonexecutable' | 'separate-runtime';\n reason: string;\n /** Generated or separately qualified runtime code needs a concrete evidence reference. */\n evidence?: string;\n}\nexport interface VitestCoverageInput {\n runnerVersion: string;\n providerVersion: string;\n include: readonly string[];\n exclusions?: readonly CoverageExclusion[];\n thresholds?: Partial<CoverageThresholds>;\n}\nexport class TestCoverageConfigurationError extends Error {\n constructor(message: string) { super(message); this.name = 'TestCoverageConfigurationError'; }\n}\nconst DEFAULT_EXCLUSIONS: readonly CoverageExclusion[] = [\n { pattern: '**/*.{test,spec}.{js,jsx,ts,tsx,mjs,cjs,mts,cts}', kind: 'tests', reason: 'Test implementations are not product source.' },\n { pattern: '**/*.d.{ts,mts,cts}', kind: 'types', reason: 'Type declarations have no executable counters.' },\n];\nconst EXCLUSION_KINDS = ['tests', 'types', 'generated', 'nonexecutable', 'separate-runtime'];\nfunction nonempty(value: unknown, label: string): asserts value is string {\n if (typeof value !== 'string' || !value.trim()) throw new TestCoverageConfigurationError(label + ' must be a nonempty string');\n}\nfunction version(value: unknown): number {\n if (typeof value !== 'string' || !/^[234]\\.\\d+\\.\\d+$/.test(value)) {\n throw new TestCoverageConfigurationError('Declare a qualified stable Vitest/provider version in majors 2, 3, or 4');\n }\n return Number(value[0]);\n}\n/** V8 preset with explicit uncovered-source inclusion and reviewable exclusion provenance. */\nexport function vitestCoverage(input: VitestCoverageInput) {\n const major = version(input.runnerVersion);\n version(input.providerVersion);\n if (input.runnerVersion !== input.providerVersion) throw new TestCoverageConfigurationError('Vitest and @vitest/coverage-v8 versions must match exactly');\n if (!Array.isArray(input.include) || !input.include.length) throw new TestCoverageConfigurationError('coverage.include must name the complete eligible source set');\n for (const pattern of input.include) {\n nonempty(pattern, 'include pattern');\n if (pattern.startsWith('!')) throw new TestCoverageConfigurationError('Record exclusions separately with provenance, not as negative includes');\n }\n const include = [...new Set(input.include)];\n const thresholds: CoverageThresholds = { lines: 99, statements: 99, functions: 99, branches: 99, ...input.thresholds };\n if (Object.keys(thresholds).some(key => !COVERAGE_METRICS.includes(key as CoverageMetric))) throw new TestCoverageConfigurationError('Unknown coverage metric');\n for (const metric of COVERAGE_METRICS) {\n if (!Number.isFinite(thresholds[metric]) || thresholds[metric] < 0 || thresholds[metric] > 100) {\n throw new TestCoverageConfigurationError(metric + ' threshold must be between 0 and 100');\n }\n }\n const exclusions = [...DEFAULT_EXCLUSIONS, ...(input.exclusions ?? [])].map(entry => {\n nonempty(entry.pattern, 'exclusion pattern');\n nonempty(entry.reason, 'exclusion reason');\n if (!EXCLUSION_KINDS.includes(entry.kind)) throw new TestCoverageConfigurationError('Unknown exclusion kind');\n if (entry.kind === 'generated' || entry.kind === 'separate-runtime') nonempty(entry.evidence, 'exclusion evidence');\n return { ...entry };\n });\n if (new Set(exclusions.map(entry => entry.pattern)).size !== exclusions.length) throw new TestCoverageConfigurationError('Duplicate exclusion pattern');\n const options = {\n provider: 'v8' as const,\n include: [...include],\n exclude: exclusions.map(entry => entry.pattern),\n // v4 removed all: explicit include now includes covered AND uncovered files.\n ...(major < 4 ? { all: true } : {}),\n reporter: ['text-summary', 'json-summary', 'json'] as Array<'text-summary' | 'json-summary' | 'json'>,\n reportOnFailure: true,\n thresholds: { ...thresholds },\n };\n return {\n options,\n provenance: Object.freeze({\n runner: 'vitest', runnerVersion: input.runnerVersion,\n provider: '@vitest/coverage-v8', providerVersion: input.providerVersion,\n includesUnimported: true,\n include: Object.freeze(include),\n exclusions: Object.freeze(exclusions.map(entry => Object.freeze(entry))),\n thresholds: Object.freeze(thresholds),\n metrics: Object.freeze([...COVERAGE_METRICS]),\n }),\n };\n}\n\nexport interface TestLaneReport {\n name: string;\n total: number;\n passed: number;\n failed: number;\n skipped: number;\n}\nexport class TestDiscoveryError extends Error {\n constructor(readonly failures: readonly string[]) { super(failures.join('; ')); this.name = 'TestDiscoveryError'; }\n}\n/** Validate counts taken from native runner reports; this is not a test discovery implementation. */\nexport function assertTestLanes(required: readonly string[], reports: readonly TestLaneReport[]): void {\n if (!required.length) throw new TestDiscoveryError(['At least one required lane must be declared']);\n const names = new Set<string>();\n const failures: string[] = [];\n for (const name of required) nonempty(name, 'required lane name');\n if (new Set(required).size !== required.length) throw new TestDiscoveryError(['Duplicate required lane']);\n for (const report of reports) {\n nonempty(report.name, 'reported lane name');\n if (names.has(report.name)) throw new TestDiscoveryError(['Duplicate report for lane ' + report.name]);\n names.add(report.name);\n for (const key of ['total', 'passed', 'failed', 'skipped'] as const) {\n if (!Number.isSafeInteger(report[key]) || report[key] < 0) throw new TestDiscoveryError(['Invalid ' + key + ' count for ' + report.name]);\n }\n if (report.total !== report.passed + report.failed + report.skipped) throw new TestDiscoveryError(['Inconsistent counts for ' + report.name]);\n if (report.failed) failures.push(report.name + ': ' + report.failed + ' failed');\n if (required.includes(report.name)) {\n if (!report.total) failures.push(report.name + ': required lane is empty');\n if (report.skipped) failures.push(report.name + ': ' + report.skipped + ' skipped');\n }\n }\n for (const name of required) if (!names.has(name)) failures.push(name + ': required lane is missing');\n if (failures.length) throw new TestDiscoveryError(Object.freeze(failures));\n}\n","import { defineModule, flattenModule, type NormalizedRegistration } from '@noego/ioc';\nimport { stubEntries, type LoaderReference, type StubEntry, type TestOwner, type TestStub } from './stub';\n\n/**\n * Describe an undeclared class token exactly as the container itself would\n * register it: the class's own @Component scope when decorated, otherwise the\n * container default (transient). A test overlay must never promote a plain\n * class to a singleton the production graph never had — that changes its\n * captive-lifetime validation and its instance sharing.\n */\nfunction admittedClassBinding(token: new (...args: any[]) => unknown): NormalizedRegistration {\n return flattenModule(defineModule('@noego/testing/admitted', bind => { bind(token).toSelf(); }))[0]!;\n}\n\n/** Supplied by framework production discovery, never by a product-local route map. */\nexport interface TestOwnerCatalog {\n readonly owner: TestOwner;\n readonly bindings: readonly NormalizedRegistration[];\n readonly middleware?: readonly string[];\n readonly loaders?: readonly LoaderReference[];\n}\nexport interface ResolvedTestOverlay {\n readonly owner: TestOwner;\n readonly entry: StubEntry;\n readonly binding?: NormalizedRegistration;\n}\nexport class TestOverlayError extends Error {\n readonly code = 'testing/overlay';\n constructor(message: string, readonly entry: StubEntry) {\n super('entry ' + entry.provenance.join('.') + ': ' + message);\n this.name = 'TestOverlayError';\n }\n}\nfunction label(target: unknown): string {\n return typeof target === 'function' ? target.name : String(target);\n}\nfunction binding(catalog: TestOwnerCatalog, token: unknown): NormalizedRegistration | undefined {\n return catalog.bindings.find(b => b.token === token);\n}\nfunction owns(catalog: TestOwnerCatalog, entry: StubEntry): boolean {\n if (entry.kind === 'middleware') return catalog.middleware?.includes(entry.target) ?? false;\n if (entry.kind === 'load') return catalog.loaders?.some(l => l.path === entry.target.path && l.export === entry.target.export) ?? false;\n return binding(catalog, entry.target) !== undefined;\n}\nfunction sameSlot(a: ResolvedTestOverlay, b: ResolvedTestOverlay): boolean {\n if (a.owner !== b.owner) return false;\n const x = a.entry, y = b.entry;\n if (x.kind === 'load' && y.kind === 'load') return x.target.path === y.target.path && x.target.export === y.target.export;\n if (x.kind === 'middleware' || x.kind === 'load' || y.kind === 'middleware' || y.kind === 'load') {\n return x.kind === y.kind && x.target === y.target;\n }\n if (x.kind === 'method' || y.kind === 'method') {\n return x.kind === 'method' && y.kind === 'method' && x.target === y.target && x.method === y.method;\n }\n return x.target === y.target; // class/function/value share one binding slot\n}\n\n/**\n * Validate EVERY entry before reducing last-write-wins slots. Resolve identities\n * exactly, never by class display name; method seams remain independent of the\n * final binding slot and are installed after all binding replacements.\n */\nexport function resolveTestOverlays(stub: TestStub, catalogs: readonly TestOwnerCatalog[]): readonly ResolvedTestOverlay[] {\n const names = catalogs.map(c => c.owner);\n if (new Set(names).size !== names.length) throw new TypeError('duplicate test owner catalog');\n const result: ResolvedTestOverlay[] = [];\n for (const entry of stubEntries(stub)) {\n let candidates = catalogs.filter(c => owns(c, entry) && (entry.owner === undefined || c.owner === entry.owner));\n if (candidates.length === 0 && entry.kind !== 'middleware' && entry.kind !== 'load' && (typeof entry.target === 'function' || entry.kind === 'value')) {\n // A token no production registration reaches through constructor\n // metadata (resolved lazily at runtime) is still a real member of the\n // owner's graph. When the owner is unambiguous, admit it: class tokens\n // with the lifetime the container would give them (decorated scope or\n // transient), and non-class tokens supplied through .value as a value\n // binding, so the replacement can shadow the lazy resolution.\n const fallback = catalogs.filter(c => entry.owner === undefined || c.owner === entry.owner);\n if (fallback.length === 1) {\n const synthetic = (typeof entry.target === 'function'\n ? admittedClassBinding(entry.target as new (...args: any[]) => unknown)\n : { token: entry.target, kind: 'value', lifetime: 'singleton', implementation: entry.replacement, dependencies: [] }) as unknown as NormalizedRegistration;\n candidates = [{ ...fallback[0]!, bindings: [...fallback[0]!.bindings, synthetic] }];\n }\n }\n if (candidates.length !== 1) {\n const identity = entry.kind === 'load' ? entry.target.path + '#' + entry.target.export : label(entry.target);\n throw new TestOverlayError((candidates.length ? 'Ambiguous' : 'Unknown') + ' ' + entry.kind + ' \"' + identity\n + '\" in selected owners [' + names.join(', ') + ']'\n + (entry.owner ? '; requested owner ' + entry.owner : '; specify { owner } when ambiguous'), entry);\n }\n const catalog = candidates[0]!;\n const declared = entry.kind === 'middleware' || entry.kind === 'load' ? undefined : binding(catalog, entry.target);\n // A class-declared token accepts a zero-argument provider too: the\n // replacement is invoked lazily (declared lifetime kept) and the produced\n // value is borrowed, never disposed by the application.\n if (entry.kind === 'function' && declared?.kind !== 'factory' && declared?.kind !== 'class'\n && !(declared?.kind === 'value' && typeof declared.implementation === 'function')) {\n throw new TestOverlayError('.function requires a declared factory/provider, class, or callable value binding', entry);\n }\n const resolved = Object.freeze({ owner: catalog.owner, entry, binding: declared });\n const prior = result.findIndex(e => sameSlot(e, resolved));\n if (prior !== -1) result.splice(prior, 1);\n result.push(resolved);\n }\n // Final binding comes before method attachment, regardless of fluent order.\n return Object.freeze([...result.filter(e => e.entry.kind !== 'method'), ...result.filter(e => e.entry.kind === 'method')]);\n}\n","import { defineModule } from '@noego/ioc';\nimport type { BuildOptions, TestIocBuilder } from './builder';\nimport { TestOverlayError, type ResolvedTestOverlay } from './overlays';\nimport type { TestOwner } from './stub';\n\nexport interface TestBindingPlan {\n readonly builder: TestIocBuilder;\n /** Pass to builder.build alongside the framework's unresolved root. */\n readonly buildOptions: Pick<BuildOptions, 'borrowedTokens'>;\n}\n\n/** Apply resolved binding entries to the existing real-IoC description. No new root. */\nexport function applyTestBindings(\n production: TestIocBuilder,\n overlays: readonly ResolvedTestOverlay[],\n owner: TestOwner,\n): TestBindingPlan {\n let builder = production;\n const entries = overlays.filter(e => e.owner === owner);\n const borrowed: unknown[] = [];\n for (const overlay of entries) {\n const { entry, binding } = overlay;\n if (entry.kind === 'middleware' || entry.kind === 'load' || entry.kind === 'method') continue;\n if (!binding) throw new TestOverlayError('missing production binding metadata', entry);\n builder = builder.use(defineModule('@noego/testing/' + owner + '/' + entry.provenance.join('.'), bind => {\n if (entry.kind === 'class') {\n bind(entry.target).to(entry.replacement)[binding.lifetime]();\n } else if (entry.kind === 'function' && binding.kind === 'factory') {\n bind(entry.target).toFactory(entry.replacement, [...binding.dependencies])[binding.lifetime]();\n } else if (entry.kind === 'function' && binding.kind === 'class') {\n // Zero-argument provider standing in for a class: lazy, declared\n // lifetime kept, produced value borrowed (never disposed by the app).\n bind(entry.target).toFactory(() => entry.replacement())[binding.lifetime]();\n borrowed.push(entry.target);\n } else {\n // .value and callable .function retain their declared lifetime but never\n // transfer ownership of caller-supplied resources to the application.\n bind(entry.target).toFactory(() => entry.replacement)[binding.lifetime]();\n borrowed.push(entry.target);\n }\n }));\n }\n for (const { entry } of entries) if (entry.kind === 'method') {\n builder = builder.methods([[entry.target, { [entry.method]: entry.replacement }]]);\n }\n return Object.freeze({ builder, buildOptions: Object.freeze({ borrowedTokens: Object.freeze(borrowed) }) });\n}\n","import { ENV_REGISTRY, test, type MethodDescriptor, type MethodInspection } from './descriptors';\nimport { createMethodDecorator, WatchRegistry } from './method_state';\nimport type { ResolvedTestOverlay } from './overlays';\nimport type { LoaderReference, ReplacementFunction, TestOwner } from './stub';\n\nexport type TestExecutableKind = 'middleware' | 'load';\nfunction identity(kind: TestExecutableKind, target: string | LoaderReference): string {\n if (kind === 'middleware') {\n if (typeof target !== 'string') throw new TypeError('middleware identity must be a string');\n return 'middleware:' + target;\n }\n if (typeof target === 'string') return 'load:' + target + '#default';\n return 'load:' + target.path + '#' + target.export;\n}\nexport interface TestExecutableOverlays {\n replace(kind: TestExecutableKind, target: string | LoaderReference, original: ReplacementFunction): ReplacementFunction;\n inspect(kind: TestExecutableKind, target: string | LoaderReference): MethodInspection;\n verify(): Promise<void>;\n readonly [ENV_REGISTRY]: WatchRegistry;\n}\n\n/** Per-environment executable seams; uses the same test.* runtime as IoC methods. */\nexport function createTestExecutables(overlays: readonly ResolvedTestOverlay[], owner: TestOwner): TestExecutableOverlays {\n const registry = new WatchRegistry();\n const decorator = createMethodDecorator(registry);\n const selected = new Set<string>();\n const installed = new Map<string, { original: ReplacementFunction; replacement: ReplacementFunction }>();\n for (const { owner: selectedOwner, entry } of overlays) {\n if (selectedOwner !== owner || (entry.kind !== 'middleware' && entry.kind !== 'load')) continue;\n const key = identity(entry.kind, entry.target);\n selected.add(key);\n // A function for middleware/load is a direct executable replacement, not\n // the raw original=>replacement form used specifically by .method.\n const behavior: MethodDescriptor = typeof entry.replacement === 'function'\n ? test.watch(() => entry.replacement as ReplacementFunction) : entry.replacement;\n registry.addEntry({ key, byName: false, methods: new Map([['invoke', behavior]]) });\n }\n return {\n replace(kind, target, original) {\n if (typeof original !== 'function') throw new TypeError('source executable must be callable');\n const key = identity(kind, target);\n if (!selected.has(key)) return original;\n const cached = installed.get(key);\n if (cached) {\n if (cached.original !== original) throw new TypeError('ambiguous source executable: ' + key);\n return cached.replacement;\n }\n const subject = decorator({ invoke: original }, key) as { invoke: ReplacementFunction };\n const replacement = function(this: unknown, ...args: unknown[]) { return subject.invoke.apply(this, args); };\n installed.set(key, { original, replacement });\n return replacement;\n },\n inspect: (kind, target) => registry.inspect(identity(kind, target), 'invoke'),\n verify: async () => registry.verify(),\n [ENV_REGISTRY]: registry,\n };\n}\n","import { defineModule, flattenModule, type NormalizedRegistration } from '@noego/ioc';\nimport type { TestIocBuilder } from './builder';\n\n/**\n * Framework discovery over registration descriptions and compiler-discovered\n * classes. Implicit injectable class dependencies are included without resolving\n * a container or matching a replacement by its display name.\n */\nexport function describeTestBindings(builder: TestIocBuilder, discovered: readonly unknown[] = []): readonly NormalizedRegistration[] {\n const declarations = new Map<unknown, NormalizedRegistration>();\n const classBinding = (token: unknown, implementation: new (...args: any[]) => unknown): NormalizedRegistration =>\n flattenModule(defineModule('@noego/testing/discovered', bind => { bind(token).to(implementation); }))[0]!;\n for (const write of builder.writes) {\n if (write.op === 'use') {\n for (const registration of flattenModule(write.module)) declarations.set(registration.token, registration);\n } else if (write.op === 'classes') {\n const registration = classBinding(write.key, write.implementation);\n declarations.set(write.key, { ...registration, lifetime: declarations.get(write.key)?.lifetime ?? registration.lifetime });\n } else if (write.op === 'functions' || write.op === 'values') {\n const prior = declarations.get(write.key);\n declarations.set(write.key, {\n token: write.key, kind: write.op === 'functions' ? 'factory' : 'value',\n lifetime: write.op === 'values' ? 'singleton' : prior?.lifetime ?? 'transient',\n dependencies: write.op === 'functions' && prior?.kind === 'factory' ? prior.dependencies : [],\n implementation: write.op === 'functions' ? write.factory : write.value,\n source: '@noego/testing/declared', requiredCapabilities: [],\n });\n }\n }\n const visited = new Set<unknown>();\n const visit = (token: unknown): void => {\n if (visited.has(token)) return;\n visited.add(token);\n let registration = declarations.get(token);\n if (!registration && typeof token === 'function' && token.prototype) {\n registration = classBinding(token, token as new (...args: any[]) => unknown);\n declarations.set(token, registration);\n }\n if (!registration) return;\n for (const dependency of registration.dependencies) visit(dependency);\n if (registration.kind === 'class' && registration.implementation !== token) visit(registration.implementation);\n };\n for (const token of [...declarations.keys(), ...discovered]) visit(token);\n return Object.freeze([...declarations.values()].map(r => Object.freeze({\n ...r, dependencies: Object.freeze([...r.dependencies]), requiredCapabilities: Object.freeze([...r.requiredCapabilities]),\n })));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACUA,iBAQO;;;ACbA,IAAM,eAAN,cAA2B,MAAM;AAAA,EACtC,YAAY,SAAiB;AAC3B,UAAM,OAAO;AACb,SAAK,OAAO,WAAW;AAAA,EACzB;AACF;AAGO,IAAM,sBAAN,cAAkC,aAAa;AAAA,EACpD,cAAc;AACZ;AAAA,MACE;AAAA,IAGF;AAAA,EACF;AACF;AAGO,IAAM,2BAAN,cAAuC,aAAa;AAAA,EACzD,YAAYA,QAAe,QAAgB;AACzC;AAAA,MACE,WAAW,MAAM,QAAQA,MAAK;AAAA,IAGhC;AAAA,EACF;AACF;AAGO,IAAM,2BAAN,cAAuC,aAAa;AAAA,EACzD,YAAYA,QAAe,QAAgB,cAAsB,WAAmB;AAClF;AAAA,MACE,SAAS,SAAS,OAAOA,MAAK,IAAI,MAAM,uCAChC,YAAY,IAAI,iBAAiB,IAAI,UAAU,SAAS;AAAA,IAClE;AAAA,EACF;AACF;AAGO,IAAM,2BAAN,cAAuC,aAAa;AAAA,EACzD,YAAYA,QAAe,QAAgB,UAAkB,WAAmB;AAC9E;AAAA,MACE,aAAa,IACT,GAAGA,MAAK,IAAI,MAAM,0DAClB,GAAGA,MAAK,IA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AAC,EAAE,IAAI,OAAK,OAAO,OAAO;AAAA,IACrE,GAAG;AAAA,IAAG,cAAc,OAAO,OAAO,CAAC,GAAG,EAAE,YAAY,CAAC;AAAA,IAAG,sBAAsB,OAAO,OAAO,CAAC,GAAG,EAAE,oBAAoB,CAAC;AAAA,EACzH,CAAC,CAAC,CAAC;AACL;","names":["token","token","token","label","token","import_ioc","COMPONENT_OPTIONS_KEY","componentScope","token","identity","fail","label","import_ioc","token","label","identity","import_ioc","binding","import_ioc","token"]}
|