@ultimat3/core 31.21.0 → 31.22.1

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/CLAUDE.md CHANGED
@@ -122,6 +122,8 @@ top-level `UltimateError` use in `error-codes.ts`.
122
122
  source of non-determinism. †
123
123
  - **`finiteOption` / `finiteCount` (`finite-option.ts`) are the framework's ONE screen for a numeric option.** Full rule: `docs/history/core.md`.
124
124
  - **`mcp-exposure.ts`'s `isMcpExposed` is the ONE answer to "did this opt into MCP?"** †
125
+ - **`service.ts` has no unregister for an app.** `registeredServices` / `restoreServices` are
126
+ test-only — `@ultimat3/testing`'s rerun seam; `resetServices` drops every module's for good.
125
127
 
126
128
  ## Metrics, tracing, reporting
127
129
 
package/README.md CHANGED
@@ -323,6 +323,8 @@ A service that reads the actor (`ctx.posts`, scoped to `ctx.actor.orgId`) regist
323
323
  for — importing the module that calls `defineService` is the registration, the same convention
324
324
  `registerActions` uses. Passing `services: { posts: ... }` to `ctxOf` still works and
325
325
  wins over a registered factory of the same name, for a test that wants to hand in a mock.
326
+ Test-only: `registeredServices()` reads `{ name, factory }[]` and `restoreServices(entries)` makes
327
+ the registry exactly that — `@ultimat3/testing`'s rerun seam forgets one file's names with them.
326
328
 
327
329
  A factory runs again on **every** `ctxOf` / `withChildContext` call and is never cached,
328
330
  because it closes over the ctx (actor, clock, tz) it was built for. `withChildContext` drops a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimat3/core",
3
- "version": "31.21.0",
3
+ "version": "31.22.1",
4
4
  "description": "Ultimate's foundation: errors, context, env, config, clock, ids, logging, telemetry, lifecycle",
5
5
  "keywords": [
6
6
  "ultimate",
@@ -54,6 +54,6 @@
54
54
  "test": "bun test"
55
55
  },
56
56
  "dependencies": {
57
- "@ultimat3/schema": "31.21.0"
57
+ "@ultimat3/schema": "31.22.1"
58
58
  }
59
59
  }
package/src/index.ts CHANGED
@@ -948,8 +948,11 @@ export {
948
948
  defineService,
949
949
  installedServices,
950
950
  registeredServiceNames,
951
+ registeredServices,
951
952
  resetServices,
953
+ restoreServices,
952
954
  type ServiceFactory,
955
+ type ServiceRegistration,
953
956
  } from './service';
954
957
  export { onSessionLost, sessionIsLost } from './session-lost';
955
958
  export { isSessionRefusal, isSessionRefusalCode } from './session-refusal';
package/src/service.ts CHANGED
@@ -73,3 +73,24 @@ export function resetServices(): void {
73
73
  export function registeredServiceNames(): readonly string[] {
74
74
  return [...factories.keys()];
75
75
  }
76
+
77
+ /** One registration, as `registeredServices` reads it and `restoreServices` writes it back. */
78
+ export interface ServiceRegistration {
79
+ readonly name: string;
80
+ readonly factory: ServiceFactory;
81
+ }
82
+
83
+ /** Test-only: every registered factory, in registration order — a copy, never the live map. */
84
+ export function registeredServices(): readonly ServiceRegistration[] {
85
+ return [...factories].map(([name, factory]) => ({ name, factory }));
86
+ }
87
+
88
+ /**
89
+ * Test-only: the registry becomes exactly `registrations`. The writer `resetServices` is not: a
90
+ * reset drops what every module imported earlier declared, and a module evaluates once per
91
+ * process — `@ultimat3/testing`'s rerun seam forgets one file's names with this and puts them back.
92
+ */
93
+ export function restoreServices(registrations: readonly ServiceRegistration[]): void {
94
+ factories.clear();
95
+ for (const { name, factory } of registrations) factories.set(name, factory);
96
+ }