Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/architecture/feature-map.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ The Bot Runtime delegates Assignment creation and requests to [intake](../../pac
| Bot and Session runtime | The PersonaBot identity contract, Orchestrator and Assignment Session execution, turn serialization, stop and disposal, and the native Agent adapter. Feature tools use those execution paths. [`runtime/bot-runtime.ts`](../../packages/core/src/runtime/bot-runtime.ts), [`runtime/dsh-bot-agent-adapter.ts`](../../packages/core/src/runtime/dsh-bot-agent-adapter.ts), [`sessions/ownership.ts`](../../packages/core/src/sessions/ownership.ts) |
| Channel, Source Event and Admission | The Channel model, shared Channel transaction, Source Event identity and Bot Inbox admission. Feature ingress submits to these owners. [`channels/channel-record.ts`](../../packages/core/src/channels/channel-record.ts), [`channels/channel-message-types.ts`](../../packages/core/src/channels/channel-message-types.ts), [`channels/channel-message-validation.ts`](../../packages/core/src/channels/channel-message-validation.ts), [`channels/sqlite-store.ts`](../../packages/core/src/channels/sqlite-store.ts), [`runtime/inbound-envelope.ts`](../../packages/core/src/runtime/inbound-envelope.ts) |
| Host transport | Typert Service exposure, trusted Human resolution, Fetch and SSE dispatch, wire contracts and client transport. Feature handlers consume the authenticated invocation context. [`bridge/rpc.ts`](../../packages/core/src/bridge/rpc.ts), [`bridge/remote-descriptors.ts`](../../packages/core/src/bridge/remote-descriptors.ts), [`packages/host-protocol/src/wire.ts`](../../packages/host-protocol/src/wire.ts), [`packages/host-client/src/client.ts`](../../packages/host-client/src/client.ts) |
| Database engine | The Operational Database owner handles connection, leases, transaction and recovery mechanics. The schema engine validates and applies the ordered plan. [`database/owner.ts`](../../packages/core/src/database/owner.ts), [`database/schema.ts`](../../packages/core/src/database/schema.ts) |
| Database engine | The Operational Database owner handles connection, leases, transaction and recovery mechanics. Schema preparation validates the ordered plan and stages migrations before activation. [`database/owner.ts`](../../packages/core/src/database/owner.ts), [`database/schema-preparation.ts`](../../packages/core/src/database/schema-preparation.ts), [`database/schema.ts`](../../packages/core/src/database/schema.ts) |
| Application composition and UI shell | The composition root mounts the kernel and features. The Client shell owns Slots, Panel placement, conversation windowing and shared design primitives. Mobile uses the same remote contracts through its own shell. [`plugin.ts`](../../packages/core/src/plugin.ts), [`bot-main.tsx`](../../packages/client/src/client/features/channels/bot-main.tsx), [`packages/client/src/client/index.ts`](../../packages/client/src/client/index.ts), [`apps/mobile/src/host/host-session.ts`](../../apps/mobile/src/host/host-session.ts) |

The DSH Agent adapter keeps one [native handle registry](../../packages/core/src/runtime/dsh-bot-agent-adapter-state.ts) and delegates to [Orchestrator](../../packages/core/src/runtime/dsh-bot-agent-adapter-orchestrator.ts), [Assignment](../../packages/core/src/runtime/dsh-bot-agent-adapter-assignment.ts), and [alternate engine](../../packages/core/src/runtime/dsh-bot-agent-adapter-engine.ts) lifecycle modules.
Expand Down
46 changes: 46 additions & 0 deletions packages/core/src/database/owner-errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type {
OperationalDatabaseErrorCode,
OperationalDatabaseFaultStage,
OperationalDatabaseOwner,
OperationalDatabaseOwnerOptions,
} from './owner.js';

interface FaultTarget extends Pick<OperationalDatabaseOwnerOptions, 'faultInjector'> {
owner: OperationalDatabaseOwner;
}

export class OperationalDatabaseError extends Error {
readonly code: OperationalDatabaseErrorCode;

constructor(code: OperationalDatabaseErrorCode, message: string, options?: ErrorOptions) {
super(message, options);
this.name = 'OperationalDatabaseError';
this.code = code;
}
}

export function isThenable(value: unknown): value is PromiseLike<unknown> {
if ((typeof value !== 'object' && typeof value !== 'function') || value === null) return false;
return typeof (value as { then?: unknown }).then === 'function';
}

export function toOperationalError(
code: OperationalDatabaseErrorCode,
message: string,
cause: unknown,
): OperationalDatabaseError {
if (cause instanceof OperationalDatabaseError && cause.code === code) return cause;
return new OperationalDatabaseError(code, message, { cause });
}

export function injectFault(
internal: FaultTarget,
stage: OperationalDatabaseFaultStage,
stagingPath?: string,
): void {
internal.faultInjector?.({
stage,
activePath: internal.owner.databasePath,
...(stagingPath === undefined ? {} : { stagingPath }),
});
}
Loading