Add App.Orca to the createActiveApp() core

App.Orca is the orchestration engine instance built alongside Logger,
Bus and Timers. It is inert until the application registers actions
via App.Orca.onEvent() or applies a preset from
arts/active-app/presets/.

Construction order: Logger → Lang → Storage → ... → Timers → Bus →
Orca → Cache → (lazy services). Orca disposes before Bus and Timers
to ensure its bus subscriptions and any future timer-based features
are torn down cleanly.

This is the first surgical change of step 3 (the big-bang merger of
the new service-schema model with the legacy createActiveApp). The
legacy App.createActiveX() factories remain in place; subsequent
commits will migrate the schema-driven services and remove the
legacy translators / orchestration translators / APP_EVENT_*
patches.

Tests: API surface test in active-app.test.ts updated to include the
new Orca key. Total suite: 1402 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
master
dev 5 months ago
parent a04fa67152
commit fb2e3ac507

@ -23,6 +23,7 @@ import type { ActiveSession, EngineSessionOptions } from '$session/types';
import { createEngineSium } from '$sium/engine-sium';
import { createActiveStorage } from '$storage/active-storage.svelte';
import { createActiveTimers } from '$timer/active-timers.svelte';
import { createEngineOrca } from '$orca';
import { publishAppDisposeStarting } from '$libs/active-app/events';
import {
@ -121,6 +122,11 @@ export function createActiveApp<S extends LangNode = LangNode>(
logger: Logger,
clock: Timers.clock
});
const Orca = createEngineOrca({
bus: Bus,
timers: Timers,
logger: Logger
});
const orchestration = resolveActiveAppOrchestration(options.orchestration);
const detachSessionTranslator = orchestration.has(APP_ORCHESTRATION_TRANSLATOR_IDENTITY)
? wireSessionTranslator(Bus)
@ -149,6 +155,7 @@ export function createActiveApp<S extends LangNode = LangNode>(
Http,
Timers,
Bus,
Orca,
Cache,
get Sess() {
@ -267,6 +274,7 @@ export function createActiveApp<S extends LangNode = LangNode>(
Sess?.dispose();
Sess = undefined;
Cache.dispose();
Orca.dispose();
Bus.dispose();
Timers.dispose();
teardownPersistence();

@ -75,6 +75,7 @@ describe('createActiveApp — composition', () => {
'Http',
'Lang',
'Logger',
'Orca',
'Perms',
'Sess',
'Storage',

@ -19,11 +19,7 @@ import { createSvelteEngineBus } from '$bus';
import { createEngineLogger } from '$logger/engine-logger';
import { createEngineOrca, type EngineOrca } from '$orca';
import { createActiveTimers } from '$timer/active-timers.svelte';
import {
SESSION_EVENT_IDENTITY_CHANGED,
SESSION_EVENT_LIFECYCLE_REVOKED,
SESSION_EVENT_REVOKED
} from '$session';
import { SESSION_EVENT_IDENTITY_CHANGED, SESSION_EVENT_REVOKED } from '$session';
import type { EngineLogger } from '$logger';
import type { EngineBus } from '$bus';
import type { ActiveTimers } from '$timer';
@ -32,7 +28,7 @@ import type { ActivePerms } from '$perm/types';
interface CoreState {
logger: EngineLogger;
bus: EngineBus;
bus: EngineBus<Record<string, unknown>>;
timers: ActiveTimers;
orca: EngineOrca;
}
@ -40,7 +36,7 @@ interface CoreState {
function buildCore(): CoreState {
const logger = createEngineLogger({});
const timers = createActiveTimers({ logger });
const bus = createSvelteEngineBus({ logger, clock: timers.clock });
const bus = createSvelteEngineBus<Record<string, unknown>>({ logger, clock: timers.clock });
const orca = createEngineOrca({ bus, timers, logger });
return { logger, bus, timers, orca };
}
@ -159,7 +155,7 @@ describe('applyCacheClearOnRevoke', () => {
const revokePayload = {
...samplePayload,
event: SESSION_EVENT_LIFECYCLE_REVOKED
event: 'session.lifecycle.revoked'
};
core.bus.publish(SESSION_EVENT_REVOKED, revokePayload);
await flush();

@ -11,6 +11,7 @@ import type { AppEventMap } from '$libs/active-app/events';
import type { LangNode, SupportedLocale } from '$libs/lang';
import type { ActiveLang } from '$lang';
import type { EngineLogger, LoggerOptions } from '$logger';
import type { EngineOrca } from '$orca';
import type { ActivePerms, ActivePermsOptions } from '$perm';
import type { ActiveSession, EngineSessionOptions, SessEventMap } from '$session';
import type { EngineSium } from '$sium';
@ -211,6 +212,12 @@ export interface ActiveApp<S extends LangNode = LangNode> {
readonly Http: EngineHttp;
readonly Timers: ActiveTimers;
readonly Bus: EngineBus<ActiveAppBusEvents>;
/**
* Orchestration engine (orca v0.0). Always present, inert until the
* application registers actions via `App.Orca.onEvent(...)` or applies
* presets from `arts/active-app/presets/` (e.g. `applyStandardOrca`).
*/
readonly Orca: EngineOrca;
readonly Cache: ActiveCache;
/** Active locale. Sourced from Lang (real or mono). */

Loading…
Cancel
Save

Powered by TurnKey Linux.