@kronos-ts/app 0.1.0

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.
Files changed (61) hide show
  1. package/dist/app.d.ts +228 -0
  2. package/dist/app.d.ts.map +1 -0
  3. package/dist/app.js +519 -0
  4. package/dist/app.js.map +1 -0
  5. package/dist/components.d.ts +28 -0
  6. package/dist/components.d.ts.map +1 -0
  7. package/dist/components.js +14 -0
  8. package/dist/components.js.map +1 -0
  9. package/dist/decorator.d.ts +54 -0
  10. package/dist/decorator.d.ts.map +1 -0
  11. package/dist/decorator.js +36 -0
  12. package/dist/decorator.js.map +1 -0
  13. package/dist/defaults-handles.d.ts +25 -0
  14. package/dist/defaults-handles.d.ts.map +1 -0
  15. package/dist/defaults-handles.js +25 -0
  16. package/dist/defaults-handles.js.map +1 -0
  17. package/dist/defaults.d.ts +10 -0
  18. package/dist/defaults.d.ts.map +1 -0
  19. package/dist/defaults.js +49 -0
  20. package/dist/defaults.js.map +1 -0
  21. package/dist/errors.d.ts +37 -0
  22. package/dist/errors.d.ts.map +1 -0
  23. package/dist/errors.js +53 -0
  24. package/dist/errors.js.map +1 -0
  25. package/dist/index.d.ts +17 -0
  26. package/dist/index.d.ts.map +1 -0
  27. package/dist/index.js +12 -0
  28. package/dist/index.js.map +1 -0
  29. package/dist/kronos.d.ts +51 -0
  30. package/dist/kronos.d.ts.map +1 -0
  31. package/dist/kronos.js +74 -0
  32. package/dist/kronos.js.map +1 -0
  33. package/dist/lifecycle.d.ts +27 -0
  34. package/dist/lifecycle.d.ts.map +1 -0
  35. package/dist/lifecycle.js +7 -0
  36. package/dist/lifecycle.js.map +1 -0
  37. package/dist/resolved.d.ts +18 -0
  38. package/dist/resolved.d.ts.map +1 -0
  39. package/dist/resolved.js +43 -0
  40. package/dist/resolved.js.map +1 -0
  41. package/dist/slot-registry.d.ts +35 -0
  42. package/dist/slot-registry.d.ts.map +1 -0
  43. package/dist/slot-registry.js +50 -0
  44. package/dist/slot-registry.js.map +1 -0
  45. package/dist/warnings.d.ts +19 -0
  46. package/dist/warnings.d.ts.map +1 -0
  47. package/dist/warnings.js +14 -0
  48. package/dist/warnings.js.map +1 -0
  49. package/package.json +59 -0
  50. package/src/app.ts +795 -0
  51. package/src/components.ts +48 -0
  52. package/src/decorator.ts +88 -0
  53. package/src/defaults-handles.ts +29 -0
  54. package/src/defaults.ts +64 -0
  55. package/src/errors.ts +62 -0
  56. package/src/index.ts +38 -0
  57. package/src/kronos.ts +117 -0
  58. package/src/lifecycle.ts +33 -0
  59. package/src/resolved.ts +54 -0
  60. package/src/slot-registry.ts +89 -0
  61. package/src/warnings.ts +32 -0
package/dist/app.js ADDED
@@ -0,0 +1,519 @@
1
+ import { createStateManager } from "@kronos-ts/modelling";
2
+ import { registerCommandHandlersNatively, registerQueryHandlersNatively, createCommandGateway, createQueryGateway, createTrackingEventProcessor, createSubscribingEventProcessor, multiHandlerEnhancerDefinition, } from "@kronos-ts/messaging";
3
+ import { createEventSourcedRepository } from "@kronos-ts/eventsourcing";
4
+ import { ALL_SLOTS } from "./components.js";
5
+ import { SlotRegistry } from "./slot-registry.js";
6
+ import { buildResolved } from "./resolved.js";
7
+ import { applyDecorators } from "./decorator.js";
8
+ import { AppNotStartedError, UnknownDecoratorHandleError } from "./errors.js";
9
+ /** Thrown when the App's mutating methods are called after .start() (D-50 footgun closure). */
10
+ export class AppAlreadyStartedError extends Error {
11
+ constructor() {
12
+ super("[kronos] App has already been started; configuration is immutable after start().");
13
+ this.name = "AppAlreadyStartedError";
14
+ }
15
+ }
16
+ export class AppImpl {
17
+ _state;
18
+ _started = false;
19
+ identity;
20
+ _commandGateway = undefined;
21
+ _queryGateway = undefined;
22
+ /** D-77: per-stage timeout for native lifecycle execution. */
23
+ _stageTimeoutMs;
24
+ /**
25
+ * Live CommandGateway. Throws AppNotStartedError if accessed before the
26
+ * `register` lifecycle stage completes during `.start()`. (Plan 08-01.)
27
+ */
28
+ get commandGateway() {
29
+ if (!this._commandGateway)
30
+ throw new AppNotStartedError("commandGateway");
31
+ return this._commandGateway;
32
+ }
33
+ /**
34
+ * Live QueryGateway. Throws AppNotStartedError if accessed before the
35
+ * `register` lifecycle stage completes during `.start()`. (Plan 08-01.)
36
+ */
37
+ get queryGateway() {
38
+ if (!this._queryGateway)
39
+ throw new AppNotStartedError("queryGateway");
40
+ return this._queryGateway;
41
+ }
42
+ constructor(options) {
43
+ this._stageTimeoutMs = options.stageTimeoutMs ?? 5000;
44
+ this.identity = {
45
+ serviceName: options.serviceName ?? "kronos-app",
46
+ instanceId: options.instanceId ?? createDefaultInstanceId(),
47
+ };
48
+ this._state = {
49
+ slotRegistry: new SlotRegistry(),
50
+ stateEntries: [],
51
+ commandHandlers: [],
52
+ queryHandlers: [],
53
+ processors: [],
54
+ extensions: [],
55
+ warningChannel: options.warningChannel,
56
+ decoratorRegistrations: [],
57
+ commandDispatchInterceptors: [],
58
+ queryDispatchInterceptors: [],
59
+ eventDispatchInterceptors: [],
60
+ handlerInterceptors: [],
61
+ handlerEnhancers: [],
62
+ startHooks: [],
63
+ stopHooks: [],
64
+ };
65
+ }
66
+ /** @internal — used by tests + by registerInMemoryDefaults indirectly through setDefault. */
67
+ getRegistry() {
68
+ return this._state.slotRegistry;
69
+ }
70
+ /** @internal — used by Task 2's start() implementation. */
71
+ isStarted() {
72
+ return this._started;
73
+ }
74
+ /** @internal — set just before .start() returns; Task 2 toggles this. */
75
+ markStarted() {
76
+ this._started = true;
77
+ }
78
+ guard() {
79
+ if (this._started)
80
+ throw new AppAlreadyStartedError();
81
+ }
82
+ states(...args) {
83
+ this.guard();
84
+ for (const arg of args) {
85
+ if (Array.isArray(arg)) {
86
+ const [module, options] = arg;
87
+ this._state.stateEntries.push({ module, options });
88
+ }
89
+ else {
90
+ this._state.stateEntries.push({ module: arg, options: {} });
91
+ }
92
+ }
93
+ return this;
94
+ }
95
+ commands(...handlers) {
96
+ this.guard();
97
+ this._state.commandHandlers.push(...handlers);
98
+ return this;
99
+ }
100
+ queries(...handlers) {
101
+ this.guard();
102
+ this._state.queryHandlers.push(...handlers);
103
+ return this;
104
+ }
105
+ processors(...modules) {
106
+ if (modules.length === 0) {
107
+ // Frozen view so accidental .push() on the returned array doesn't smuggle
108
+ // mutations into _state. The underlying array is still mutable for the
109
+ // writer overload below.
110
+ return Object.freeze([...this._state.processors]);
111
+ }
112
+ this.guard();
113
+ this._state.processors.push(...modules);
114
+ return this;
115
+ }
116
+ use(extension) {
117
+ this.guard();
118
+ this._state.extensions.push(extension);
119
+ return this;
120
+ }
121
+ setDefault(slot, factory, meta) {
122
+ this.guard();
123
+ this._state.slotRegistry.setDefault(slot, factory, meta);
124
+ return this;
125
+ }
126
+ set(slot, factory) {
127
+ this.guard();
128
+ this._state.slotRegistry.set(slot, factory);
129
+ return this;
130
+ }
131
+ forceSet(slot, factory) {
132
+ this.guard();
133
+ this._state.slotRegistry.forceSet(slot, factory);
134
+ return this;
135
+ }
136
+ decorate(slot, factory) {
137
+ this.guard();
138
+ const handle = Object.freeze({
139
+ __slot: slot,
140
+ __id: Symbol(`user.${slot}`),
141
+ __name: `user.${slot}.${this._state.decoratorRegistrations.length}`,
142
+ });
143
+ this._state.decoratorRegistrations.push({
144
+ handle: handle,
145
+ factory: factory,
146
+ frameworkDefault: false,
147
+ });
148
+ return handle;
149
+ }
150
+ removeDecorator(handle) {
151
+ this.guard();
152
+ const idx = this._state.decoratorRegistrations.findIndex((entry) => entry.handle.__id === handle.__id);
153
+ if (idx < 0) {
154
+ throw new UnknownDecoratorHandleError(handle);
155
+ }
156
+ this._state.decoratorRegistrations.splice(idx, 1);
157
+ return this;
158
+ }
159
+ commandDispatchInterceptor(fn) {
160
+ this.guard();
161
+ this._state.commandDispatchInterceptors.push(fn);
162
+ return this;
163
+ }
164
+ queryDispatchInterceptor(fn) {
165
+ this.guard();
166
+ this._state.queryDispatchInterceptors.push(fn);
167
+ return this;
168
+ }
169
+ eventDispatchInterceptor(fn) {
170
+ this.guard();
171
+ this._state.eventDispatchInterceptors.push(fn);
172
+ return this;
173
+ }
174
+ handlerInterceptor(fn) {
175
+ this.guard();
176
+ this._state.handlerInterceptors.push(fn);
177
+ return this;
178
+ }
179
+ handlerEnhancer(def) {
180
+ this.guard();
181
+ this._state.handlerEnhancers.push(def);
182
+ return this;
183
+ }
184
+ onStart(stage, fn) {
185
+ this.guard();
186
+ this._state.startHooks.push({ stage, fn });
187
+ return this;
188
+ }
189
+ onStop(stage, fn) {
190
+ this.guard();
191
+ this._state.stopHooks.push({ stage, fn });
192
+ return this;
193
+ }
194
+ /**
195
+ * @internal — used by `kronos()` bootstrap (Plan 02) to register framework-default
196
+ * decorators with pre-allocated handle identities from `Defaults`. Distinguished
197
+ * from user `.decorate()` registrations by `frameworkDefault: true` — at `.start()`,
198
+ * framework defaults wrap innermost (handler-adjacent) and user decorators wrap
199
+ * outside them (D-62, DESIGN.md §8 line 248).
200
+ *
201
+ * Called once per slot per kronos() invocation. Idempotent guard not added here
202
+ * because kronos() bootstrap controls call sites.
203
+ */
204
+ _registerFrameworkDefaultDecorator(handle, factory) {
205
+ this._state.decoratorRegistrations.push({
206
+ handle: handle,
207
+ factory: factory,
208
+ frameworkDefault: true,
209
+ });
210
+ }
211
+ async start() {
212
+ if (this._started)
213
+ throw new AppAlreadyStartedError();
214
+ // 1. Run extensions FIRST so they can mutate the slot registry / accumulators (D-50).
215
+ for (const ext of this._state.extensions) {
216
+ const result = ext(this);
217
+ if (result instanceof Promise)
218
+ await result;
219
+ }
220
+ // 2. Mark started AFTER extensions ran (so extensions can mutate) but BEFORE slot resolution
221
+ // (so resolved factories can't trigger fluent calls — defensive).
222
+ this._started = true;
223
+ // 3. Build the lazy Resolved proxy and EAGERLY resolve all 8 slots up-front
224
+ // (Pitfall 1 — interleaving slot resolution with configurer registration creates stale-cache hazards).
225
+ const resolved = buildResolved(this._state.slotRegistry);
226
+ const built = {
227
+ eventStore: resolved.eventStore,
228
+ snapshotStore: resolved.snapshotStore,
229
+ commandBus: resolved.commandBus,
230
+ queryBus: resolved.queryBus,
231
+ eventBus: resolved.eventBus,
232
+ serializer: resolved.serializer,
233
+ unitOfWorkFactory: resolved.unitOfWorkFactory,
234
+ tagResolver: resolved.tagResolver,
235
+ // Plan 09-01 (D-84): two new typed slots — eagerly resolved so decorator
236
+ // application + processor wiring see the same instance.
237
+ tokenStore: resolved.tokenStore,
238
+ transactionManager: resolved.transactionManager,
239
+ };
240
+ // 3b. Apply decorators in two passes per slot (D-62, D-64, DESIGN.md §8):
241
+ // - framework defaults first (innermost, handler-adjacent)
242
+ // - user decorators after (outer; last .decorate() = outermost wrap)
243
+ // Pipeline visualization for slot K (outer → inner):
244
+ // [user decorators in registration order, last=outermost]
245
+ // [framework defaults in registration order, last=outermost]
246
+ // [base = resolved[K]]
247
+ const writableBuilt = built;
248
+ for (const slot of ALL_SLOTS) {
249
+ writableBuilt[slot] = applyDecorators(slot, built[slot], this._state.decoratorRegistrations, resolved);
250
+ }
251
+ // 4. Emit startup warnings for any slot still using a flagged in-memory default (SLT-04).
252
+ // Iterate ALL_SLOTS for deterministic order. Warning emission goes through the channel
253
+ // so quiet:true / logger options route correctly (D-51).
254
+ for (const slot of ALL_SLOTS) {
255
+ const entry = this._state.slotRegistry.getEntry(slot);
256
+ if (entry?.meta?.inMemory && entry.meta.warning) {
257
+ this._state.warningChannel.emit(entry.meta.warning);
258
+ }
259
+ }
260
+ // ----------------------------------------------------------------------
261
+ // 5. Native wiring (Plan 08-03a — Configurer chain deleted).
262
+ // Build StateManager from registered entities + resolved eventStore, then
263
+ // subscribe command/query handlers and event-handler subscribing processors
264
+ // directly off the resolved buses. No legacy configurer chain, no Module
265
+ // initialize() shells, no LifecycleRegistry numeric-phase bridge.
266
+ // ----------------------------------------------------------------------
267
+ // 5a. Construct StateManager from registered entities (mirrors the configurer's
268
+ // registerDefaults() pattern at eventsourcing-configurer.ts ~line 755).
269
+ // StateModule has no .initialize() — state modules are wired purely via
270
+ // repository registration on the StateManager.
271
+ // Plan 09-01 (D-88): per-state tuple options (snapshotPolicy, snapshotStore)
272
+ // thread through into createEventSourcedRepository.
273
+ const stateManager = createStateManager();
274
+ for (const { module, options } of this._state.stateEntries) {
275
+ stateManager.register(module, createEventSourcedRepository(module, built.eventStore, options.snapshotStore ?? built.snapshotStore, options.snapshotPolicy));
276
+ }
277
+ // 5b. Build the minimal Configuration shim that createCommandInvocation reads
278
+ // during dispatch (D-82). Surface kept narrow on purpose — anything outside
279
+ // the documented set throws loudly so misuse is obvious.
280
+ const configShim = createConfigShim(built, stateManager);
281
+ // Plan 09-01 (D-86, RESEARCH Open Question #4): compose the accumulated
282
+ // handlerEnhancers ONCE and thread the composed definition into command,
283
+ // query, tracking, and subscribing handler registration so cross-cutting
284
+ // (tracing, timing, security) wraps every handler kind uniformly.
285
+ const composedHandlerEnhancer = this._state.handlerEnhancers.length > 0
286
+ ? multiHandlerEnhancerDefinition(this._state.handlerEnhancers)
287
+ : undefined;
288
+ // 5c. Subscribe command handlers natively. createCommandInvocation seeds the
289
+ // ALS three-key set (STATE_MANAGER + COMMAND_BUS + QUERY_BUS) and registers
290
+ // the onPrepareCommit event-flush — verbatim from D-82.
291
+ registerCommandHandlersNatively(this._state.commandHandlers, {
292
+ commandBus: built.commandBus,
293
+ config: configShim,
294
+ moduleName: "commands",
295
+ handlerEnhancer: composedHandlerEnhancer,
296
+ });
297
+ // 5d. Subscribe query handlers directly onto the queryBus.
298
+ // Plan 09-01: query handlers receive the same enhancer treatment as
299
+ // commands (closes RESEARCH Open Question #4).
300
+ registerQueryHandlersNatively(this._state.queryHandlers, {
301
+ queryBus: built.queryBus,
302
+ moduleName: "queries",
303
+ handlerEnhancer: composedHandlerEnhancer,
304
+ });
305
+ // 5e. Build event processors from explicit `.processors(...)` modules.
306
+ // Users wanting a subscribing processor write
307
+ // `subscribingProcessor(name).eventHandlers(...).build()` and pass it
308
+ // to `app.processors(...)` — there is no implicit shortcut.
309
+ const builtProcessors = [];
310
+ for (const proc of this._state.processors) {
311
+ if (proc.kind === "subscribing") {
312
+ const subscribable = built.eventStore;
313
+ if (!subscribable.subscribe) {
314
+ throw new Error(`Event source does not support subscription. ` +
315
+ `Cannot create subscribing processor "${proc.name}".`);
316
+ }
317
+ builtProcessors.push(createSubscribingEventProcessor({
318
+ name: proc.name,
319
+ eventSource: subscribable,
320
+ eventHandlers: proc.eventHandlers,
321
+ stateManager,
322
+ commandBus: built.commandBus,
323
+ queryBus: built.queryBus,
324
+ unitOfWorkRunner: proc.unitOfWorkRunner ?? built.unitOfWorkFactory,
325
+ errorHandler: proc.errorHandler,
326
+ handlerEnhancer: composedHandlerEnhancer,
327
+ }));
328
+ }
329
+ else {
330
+ builtProcessors.push(createTrackingEventProcessor({
331
+ name: proc.name,
332
+ eventSource: built.eventStore,
333
+ eventHandlers: proc.eventHandlers,
334
+ stateManager,
335
+ commandBus: built.commandBus,
336
+ queryBus: built.queryBus,
337
+ unitOfWorkRunner: proc.unitOfWorkRunner ?? built.unitOfWorkFactory,
338
+ // Plan 09-01 (D-84): per-processor override wins, otherwise fall
339
+ // back to the resolved tokenStore slot so the default in-memory
340
+ // store (or any extension-supplied replacement) drives position
341
+ // persistence — the slot is the single source of truth.
342
+ tokenStore: proc.tokenStore ?? built.tokenStore,
343
+ batchSize: proc.batchSize,
344
+ pollingIntervalMs: proc.pollingIntervalMs,
345
+ errorHandler: proc.errorHandler,
346
+ handlerEnhancer: composedHandlerEnhancer,
347
+ // Plan 11-02: onReset lives on the tracking processor module.
348
+ // Tracking processors support reset; subscribing processors don't.
349
+ onReset: proc.onReset,
350
+ }));
351
+ }
352
+ }
353
+ // 5f. Build CommandGateway / QueryGateway from resolved buses, threading the
354
+ // configured UoW runner through so transactional wrappers span the dispatch
355
+ // boundary (CTX-04 / D-34). Gateways are constructed eagerly but the
356
+ // `app.commandGateway` / `app.queryGateway` accessors are only populated at
357
+ // the `register` stage — preserving the AppNotStartedError contract for
358
+ // pre-register hooks (Plan 08-01).
359
+ const commandGateway = createCommandGateway(built.commandBus, built.unitOfWorkFactory);
360
+ const queryGateway = createQueryGateway(built.queryBus, built.unitOfWorkFactory);
361
+ // 5g. Run typed-stage start hooks in forward order with D-77 warn-then-continue
362
+ // per-stage timeout. Hooks within a stage run concurrently via Promise.all.
363
+ // At the `register` stage, populate the live-gateway accessors so any
364
+ // register/processors/serve-stage hooks (and downstream handlers) see them.
365
+ for (const stage of FORWARD_STAGES) {
366
+ if (stage === "register") {
367
+ this._commandGateway = commandGateway;
368
+ this._queryGateway = queryGateway;
369
+ }
370
+ const hooks = this._state.startHooks.filter((h) => h.stage === stage);
371
+ if (hooks.length === 0)
372
+ continue;
373
+ await this._runStageWithTimeout(stage, hooks.map((h) => h.fn), this._stageTimeoutMs);
374
+ }
375
+ // 5h. Start event processors AFTER processors-stage hooks have run — mirrors
376
+ // the configurer's old sequencing (eventsourcing-configurer.ts lines 670+).
377
+ for (const proc of builtProcessors) {
378
+ await proc.start();
379
+ }
380
+ // 5i. Build the RunningApp. stop() reverses: processors first, then user stop
381
+ // hooks in reverse stage order, again with the warn-then-continue timeout.
382
+ const runStageWithTimeout = this._runStageWithTimeout.bind(this);
383
+ const stageTimeoutMs = this._stageTimeoutMs;
384
+ const stopHooks = this._state.stopHooks;
385
+ const identity = this.identity;
386
+ return {
387
+ get identity() {
388
+ return identity;
389
+ },
390
+ get commandGateway() {
391
+ return commandGateway;
392
+ },
393
+ get queryGateway() {
394
+ return queryGateway;
395
+ },
396
+ async stop() {
397
+ // Stop processors first (mirrors legacy shutdown order).
398
+ for (const proc of builtProcessors) {
399
+ proc.stop();
400
+ }
401
+ // Reverse stage order for stop hooks.
402
+ for (const stage of REVERSE_STAGES) {
403
+ const hooks = stopHooks.filter((h) => h.stage === stage);
404
+ if (hooks.length === 0)
405
+ continue;
406
+ await runStageWithTimeout(stage, hooks.map((h) => h.fn), stageTimeoutMs);
407
+ }
408
+ },
409
+ };
410
+ }
411
+ /**
412
+ * D-77 native lifecycle execution: per-stage Promise.all + Promise.race with
413
+ * warn-then-continue. If the stage exceeds `timeoutMs`, log a warning and
414
+ * STOP WAITING — the slow hooks continue to pend in the background; they are
415
+ * NOT cancelled. Reproduces createLifecycleRegistry's per-phase semantics
416
+ * verbatim, but over typed stages instead of numeric phases.
417
+ */
418
+ async _runStageWithTimeout(stage, fns, timeoutMs) {
419
+ const stageWork = Promise.all(fns.map((fn) => Promise.resolve(fn())));
420
+ let timer;
421
+ const timeout = new Promise((resolve) => {
422
+ timer = setTimeout(() => resolve("timeout"), timeoutMs);
423
+ });
424
+ // Swallow background rejections from the slow hooks if the stage has already
425
+ // returned via the timeout branch — without this, an unhandled rejection
426
+ // could surface long after start() resolved (the hook is intentionally not
427
+ // cancelled per D-77, but its eventual rejection is no longer observable).
428
+ stageWork.catch(() => {
429
+ /* warn-then-continue: failures after the timeout are intentionally dropped */
430
+ });
431
+ const result = await Promise.race([
432
+ stageWork.then(() => "done"),
433
+ timeout,
434
+ ]);
435
+ if (timer)
436
+ clearTimeout(timer);
437
+ if (result === "timeout") {
438
+ this._state.warningChannel.emit(`[kronos] Lifecycle stage '${stage}' exceeded ${timeoutMs}ms timeout — continuing without waiting for completion (warn-then-continue per D-77).`);
439
+ }
440
+ }
441
+ }
442
+ // ---------------------------------------------------------------------------
443
+ // Module-private helpers (Plan 08-03a native execution)
444
+ // ---------------------------------------------------------------------------
445
+ function createDefaultInstanceId() {
446
+ const randomUUID = globalThis.crypto?.randomUUID?.bind(globalThis.crypto);
447
+ if (randomUUID)
448
+ return randomUUID();
449
+ return `instance-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
450
+ }
451
+ /** Forward typed-stage order for `.start()` execution (D-77, LIF-01). */
452
+ const FORWARD_STAGES = [
453
+ "connect",
454
+ "warmup",
455
+ "register",
456
+ "processors",
457
+ "serve",
458
+ ];
459
+ /** Reverse typed-stage order for `.stop()` execution (D-77, LIF-01). */
460
+ const REVERSE_STAGES = [
461
+ "serve",
462
+ "processors",
463
+ "register",
464
+ "warmup",
465
+ "connect",
466
+ ];
467
+ /**
468
+ * Construct a minimal Configuration shim for createCommandInvocation (D-82).
469
+ *
470
+ * The shim implements ONLY the methods createCommandInvocation invokes:
471
+ * - hasComponent / getComponent for STATE_MANAGER, COMMAND_BUS, QUERY_BUS
472
+ * (the three keys seeded into ALS at command-invocation entry per D-82)
473
+ * - hasComponent / getComponent for EVENT_STORE (read inside the
474
+ * onPrepareCommit closure when flushing buffered events)
475
+ * - getOptionalComponent for TAG_RESOLVER (read inside onPrepareCommit when
476
+ * enriching events with tags)
477
+ *
478
+ * Everything else (decorators, modules, factories, getComponents, getParent)
479
+ * throws or returns empty — the configurer-era surface is gone. Plan 04 will
480
+ * delete the Configuration interface entirely; this shim is the bridge.
481
+ */
482
+ function createConfigShim(built, stateManager) {
483
+ // Inline string-literal keys mirror the kronos() framework defaults that
484
+ // createCommandInvocation reads (STATE_MANAGER, COMMAND_BUS, QUERY_BUS,
485
+ // EVENT_STORE, TAG_RESOLVER) plus the additional slot mirrors carried
486
+ // forward for parity with the previous Configuration shim.
487
+ const components = {
488
+ stateManager,
489
+ commandBus: built.commandBus,
490
+ queryBus: built.queryBus,
491
+ eventStore: built.eventStore,
492
+ eventBus: built.eventBus,
493
+ snapshotStore: built.snapshotStore,
494
+ serializer: built.serializer,
495
+ unitOfWorkFactory: built.unitOfWorkFactory,
496
+ tagResolver: built.tagResolver,
497
+ // Plan 09-01: shim mirrors of the two new typed slots so legacy
498
+ // enhancers / probes that look them up via the Configuration shape
499
+ // see the resolved instance.
500
+ tokenStore: built.tokenStore,
501
+ transactionManager: built.transactionManager,
502
+ };
503
+ const config = {
504
+ hasComponent(type, _name) {
505
+ return type in components;
506
+ },
507
+ getComponent(type, _name) {
508
+ if (!(type in components)) {
509
+ throw new Error(`[kronos] Configuration shim does not provide "${type}"`);
510
+ }
511
+ return components[type];
512
+ },
513
+ getOptionalComponent(type, _name) {
514
+ return components[type];
515
+ },
516
+ };
517
+ return config;
518
+ }
519
+ //# sourceMappingURL=app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AE,KAAc;YAClD,OAAO,UAAU,CAAC,IAAI,CAAkB,CAAA;QAC1C,CAAC;KACF,CAAA;IACD,OAAO,MAAM,CAAA;AACf,CAAC"}
@@ -0,0 +1,28 @@
1
+ import type { EventStore, SnapshotStore, TagResolver } from "@kronos-ts/eventsourcing";
2
+ import type { CommandBus, QueryBus, EventBus, UoWRunner, TokenStore, TransactionManager } from "@kronos-ts/messaging";
3
+ import type { Serializer } from "@kronos-ts/common";
4
+ /**
5
+ * Fixed slot interface. SLT-01: enumerates ALL 10 framework slots.
6
+ * No declaration merging, no string tokens — closed contract.
7
+ *
8
+ * Plan 09-01 (D-84): tokenStore + transactionManager added so persistence
9
+ * extensions (KronosDB, etc.) replace typed slots instead of routing through
10
+ * the deleted configurer's componentRegistry.
11
+ */
12
+ export interface KronosComponents {
13
+ eventStore: EventStore;
14
+ snapshotStore: SnapshotStore;
15
+ commandBus: CommandBus;
16
+ queryBus: QueryBus;
17
+ eventBus: EventBus;
18
+ serializer: Serializer;
19
+ unitOfWorkFactory: UoWRunner;
20
+ tagResolver: TagResolver;
21
+ tokenStore: TokenStore;
22
+ transactionManager: TransactionManager;
23
+ }
24
+ /** Type-level: keyof KronosComponents — for verb signatures. */
25
+ export type SlotName = keyof KronosComponents;
26
+ /** Sentinel listing every slot name; used by .start() to iterate slots and emit startup warnings. Order is stable for deterministic warning emission. */
27
+ export declare const ALL_SLOTS: readonly SlotName[];
28
+ //# sourceMappingURL=components.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtF,OAAO,KAAK,EACV,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,UAAU,EACV,kBAAkB,EACnB,MAAM,sBAAsB,CAAA;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,aAAa,CAAA;IAC5B,UAAU,EAAE,UAAU,CAAA;IACtB,QAAQ,EAAE,QAAQ,CAAA;IAClB,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,UAAU,CAAA;IACtB,iBAAiB,EAAE,SAAS,CAAA;IAC5B,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;IACtB,kBAAkB,EAAE,kBAAkB,CAAA;CACvC;AAED,gEAAgE;AAChE,MAAM,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CAAA;AAE7C,yJAAyJ;AACzJ,eAAO,MAAM,SAAS,EAAE,SAAS,QAAQ,EAW/B,CAAA"}
@@ -0,0 +1,14 @@
1
+ /** Sentinel listing every slot name; used by .start() to iterate slots and emit startup warnings. Order is stable for deterministic warning emission. */
2
+ export const ALL_SLOTS = [
3
+ "eventStore",
4
+ "snapshotStore",
5
+ "commandBus",
6
+ "queryBus",
7
+ "eventBus",
8
+ "serializer",
9
+ "unitOfWorkFactory",
10
+ "tagResolver",
11
+ "tokenStore",
12
+ "transactionManager",
13
+ ];
14
+ //# sourceMappingURL=components.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"components.js","sourceRoot":"","sources":["../src/components.ts"],"names":[],"mappings":"AAmCA,yJAAyJ;AACzJ,MAAM,CAAC,MAAM,SAAS,GAAwB;IAC5C,YAAY;IACZ,eAAe;IACf,YAAY;IACZ,UAAU;IACV,UAAU;IACV,YAAY;IACZ,mBAAmB;IACnB,aAAa;IACb,YAAY;IACZ,oBAAoB;CACZ,CAAA"}
@@ -0,0 +1,54 @@
1
+ import type { Resolved } from "./resolved.js";
2
+ import type { KronosComponents, SlotName } from "./components.js";
3
+ /**
4
+ * Slot-typed handle returned by `app.decorate()`. The `__slot` brand prevents
5
+ * cross-slot removal at compile time (DEC-03). `__id` is the runtime identity
6
+ * key used by `removeDecorator()` to locate the registration.
7
+ *
8
+ * Framework defaults expose pre-allocated handle constants on `Defaults` so
9
+ * users can write `app.removeDecorator(Defaults.commandBus.intercepting)`.
10
+ */
11
+ export interface DecoratorHandle<K extends SlotName> {
12
+ readonly __slot: K;
13
+ readonly __id: symbol;
14
+ readonly __name: string;
15
+ }
16
+ /**
17
+ * A decorator factory wraps the slot's resolved value. Polymorphic over the
18
+ * slot interface (DEC-04) — receives `KronosComponents[K]` and returns
19
+ * `KronosComponents[K]`. The `resolved` proxy is the same lazy proxy passed
20
+ * to slot factories (Phase 5 D-52); decorators may pull sibling slots through
21
+ * it (cycle detection covers this).
22
+ */
23
+ export type DecoratorFactory<K extends SlotName> = (inner: KronosComponents[K], resolved: Resolved) => KronosComponents[K];
24
+ /**
25
+ * Internal accumulator entry. Stored on `AppState.decoratorRegistrations` in
26
+ * registration order — pipeline order at `.start()` is left-to-right
27
+ * (last registered = outermost wrap, per D-61 / DESIGN.md §8).
28
+ *
29
+ * `frameworkDefault` distinguishes framework-registered defaults (Plan 02)
30
+ * from user-registered decorators (D-62 — user decorators wrap OUTSIDE
31
+ * framework defaults). The `.start()` decoration step partitions on this
32
+ * field and applies framework defaults first (innermost), then user
33
+ * decorators (outermost).
34
+ */
35
+ export interface DecoratorEntry<K extends SlotName = SlotName> {
36
+ readonly handle: DecoratorHandle<K>;
37
+ readonly factory: DecoratorFactory<K>;
38
+ readonly frameworkDefault: boolean;
39
+ }
40
+ /**
41
+ * @internal — used by `Defaults` and by `kronos()` bootstrap (Plan 02) to
42
+ * mint pre-allocated framework-default handles with stable identity.
43
+ */
44
+ export declare function makeFrameworkHandle<K extends SlotName>(slot: K, name: string): DecoratorHandle<K>;
45
+ /**
46
+ * Apply all decorator registrations for a given slot in two passes:
47
+ * 1. Framework defaults first (innermost, handler-adjacent)
48
+ * 2. User decorators after (outer; last .decorate() = outermost wrap)
49
+ *
50
+ * Both passes iterate `registrations` in registration order so a
51
+ * left-to-right reduce composes correctly (each factory wraps the current value).
52
+ */
53
+ export declare function applyDecorators<K extends SlotName>(slot: K, base: KronosComponents[K], registrations: ReadonlyArray<DecoratorEntry>, resolved: Resolved): KronosComponents[K];
54
+ //# sourceMappingURL=decorator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"decorator.d.ts","sourceRoot":"","sources":["../src/decorator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAA;AAEjE;;;;;;;GAOG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC,SAAS,QAAQ;IACjD,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAA;IAClB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,QAAQ,IAAI,CACjD,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,EAC1B,QAAQ,EAAE,QAAQ,KACf,gBAAgB,CAAC,CAAC,CAAC,CAAA;AAExB;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,QAAQ,GAAG,QAAQ;IAC3D,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;IACnC,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAC,CAAC,CAAA;IACrC,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;CACnC;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,QAAQ,EACpD,IAAI,EAAE,CAAC,EACP,IAAI,EAAE,MAAM,GACX,eAAe,CAAC,CAAC,CAAC,CAMpB;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,CAAC,SA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