refactor: runtime isolation — deprecate global singletons, add counter resets
config.ts: @deprecated on configure/getConfig/project/getProjectConfig. Current code has zero production callers — dead code path. Functions remain for backward compatibility but signal migration to scoped config. context.ts: @deprecated on setDefaultContext. Documents that consumers should call resetDefaultContext() after use in tests to prevent context-seed leakage. pipeline.ts: Export resetTraceCounter() for test isolation of _traceId counter variable. extraction.ts: Export resetPageCacheNamespaceCounter() for test isolation of pageCacheNamespaceCounter. Combined with prior fix (defaultPredicatesRegistered→sentinel check + compatibilityWarningEmitted→warnedUis WeakSet), 5 of 7 correctness- affecting global mutable state items are now tied down. Remaining: globalPredicateRegistry/globalClauseRegistry (already @deprecated with explicit injection path via LogicEngineOptions/EvalOptions). 605 SDK + 57 E2E = 662 tests pass.
This commit is contained in:
@@ -11,12 +11,12 @@ export interface ImhotepConfig {
|
||||
|
||||
let globalConfig: ImhotepConfig = {}
|
||||
|
||||
/** Sets or updates global Imhotep runtime configuration. */
|
||||
/** @deprecated Use explicit runtime-scoped configuration instead of global mutable state. */
|
||||
export function configure(config: ImhotepConfig): void {
|
||||
globalConfig = { ...globalConfig, ...config }
|
||||
}
|
||||
|
||||
/** Returns a shallow copy of the current global config. */
|
||||
/** @deprecated Use explicit runtime-scoped configuration. Returns a shallow copy of the global config. */
|
||||
export function getConfig(): ImhotepConfig {
|
||||
return { ...globalConfig }
|
||||
}
|
||||
@@ -31,12 +31,12 @@ export interface ProjectConfig {
|
||||
|
||||
let projectConfig: ProjectConfig = {}
|
||||
|
||||
/** Sets or updates project-level defaults, font corpora, and adapters. */
|
||||
/** @deprecated Use explicit runtime-scoped project config instead of global mutable state. */
|
||||
export function project(config: ProjectConfig): void {
|
||||
projectConfig = { ...projectConfig, ...config }
|
||||
}
|
||||
|
||||
/** Returns a shallow copy of the current project config. */
|
||||
/** @deprecated Returns a shallow copy of the global project config. */
|
||||
export function getProjectConfig(): ProjectConfig {
|
||||
return { ...projectConfig }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user