import type { ActorDirectoryInput, ActorDirectoryPage } from './actor-directory.js'; import { SqlBookmarkRepository } from './bookmarks.js'; import { SqlNotificationRepository } from './notifications.js'; import { SqlParticipationRepository } from './participation-repository.js'; import type { MutationReceipt } from './mutation-receipts.js'; import type { ActorRef } from './policy.js'; import type { RecordAuthority, AddressableActor } from './policy.js'; import { DatabaseSync } from 'node:sqlite'; import type { SynomemRepository } from './ports/repository.js'; import { SynomemError } from './errors.js'; import type { ActorIdentity, SynomemConfig, SynomemConfigOverrides, AgentProfile, AgentRuntimeBinding, ChangePage, PostAcknowledgment, PostRoster, JsonValue, SynomemEvent, ItemListInput, ItemSummary, Topic, RecordKind, KudosListInput, KudosSummary, Page } from './types.js'; interface EventRow { id: string; payload: string; sequence?: bigint; } export interface EventScan { events: SynomemEvent[]; invalid: Array<{ id: string; error: SynomemError; }>; } export interface StorageOptions { actor?: ActorIdentity; authority?: RecordAuthority; home: string; readOnly: boolean; config?: SynomemConfigOverrides; } export declare class SynomemStorage implements SynomemRepository { readonly notifications: SqlNotificationRepository; private makeNotifications; readonly bookmarks: SqlBookmarkRepository; private makeBookmarks; readonly participation: SqlParticipationRepository; private makeParticipation; readonly home: string; readonly storageDirectory: string; readonly databasePath: string; readonly configPath: string; readonly readOnly: boolean; config: SynomemConfig; private database?; private cursorCodec?; private authority; private readonly boundActor?; private readonly configOverrides?; private validatedEventSequence; private readonly transactionState; constructor(options: StorageOptions); setAuthority(authority: RecordAuthority): void; init(): void; private prepare; private binding; private encodeCursor; private decodeCursor; private migrate; private assertSchemaSupported; db(): DatabaseSync; assertWritable(): void; transaction(operation: () => T | Promise): Promise; transactionSync(operation: () => T): T; insertEvent(event: SynomemEvent): Promise; private applyEventToCurrent; private applyEventToItems; rebuildItemsCurrentIndex(): void; rebuildParticipationCurrentIndex(): void; rebuildKudosCurrentIndex(): void; nextAggregateVersion(aggregateId: string): number; listKudosSummaries(input: Required> & KudosListInput, viewer: ActorIdentity): Page; listKudosChanges(after: string | undefined, limit: number, viewer: ActorIdentity): ChangePage; listItemSummaries(input: Required> & ItemListInput, viewer: ActorIdentity): Page; listItemChanges(after: string | undefined, limit: number, viewer: ActorIdentity, kinds?: RecordKind[]): ChangePage; getItemSummary(id: string): ItemSummary | undefined; getReadableItemEvents(id: string): SynomemEvent[]; currentIndexHealth(): { given: number; indexed: number; stateMismatches: number; }; itemIndexHealth(): { created: number; indexed: number; }; migrationState(): { schemaVersion: number; appliedVersions: number[]; }; /** * Aliases that also name an agent directly. * * Matches against the HANDLE as well as the canonical ID. With opaque IDs an * alias can no longer accidentally equal one, but it can easily equal another * agent's handle — which is the collision that actually makes a lookup * ambiguous now. */ aliasIdentityConflicts(): Array<{ alias: string; agentId: string; }>; private maxEventSequence; getEvent(id: string): SynomemEvent | undefined; getEventByIdempotency(actorKind: string, actorId: string, key: string): SynomemEvent | undefined; getEvents(): SynomemEvent[]; getReadableEvents(): SynomemEvent[]; getReadableSynomemEvents(kudosId: string): SynomemEvent[]; scanEvents(): EventScan; assertEventCompatibility(): void; rawEventRows(): EventRow[]; private parseEvent; canActorReadItem(id: string, actor: ActorRef): boolean; getMutationReceipt(actorKind: string, actorId: string, keyHash: string): MutationReceipt | undefined; insertMutationReceipt(actorKind: string, actorId: string, keyHash: string, receipt: MutationReceipt): void; compactMutationReceipts(before: string): number; getActor(ref: ActorRef): AddressableActor | undefined; actorCounts(target: ActorRef, viewer: ActorIdentity): { kudosReceived: number; usefulReceived: number; }; listActors(input: ActorDirectoryInput | undefined, viewer: ActorIdentity): ActorDirectoryPage; registerHuman(actor: AddressableActor): void; insertAgent(profile: AgentProfile): void; updateAgent(profile: AgentProfile, updatedAt: string): void; getAgent(idOrAlias: string): AgentProfile | undefined; /** * Resolves a name to a canonical agent, reporting ambiguity rather than * guessing. * * The plan is specific: `mycroft`, `Mycroft` and `Mike` may all resolve to one * agent, but a name two visible agents both claim must return candidates. An * alias that collides with a different agent's canonical ID is exactly that * case — silently preferring the ID would attribute work to the wrong agent, * and the person who typed the name would never know. */ resolveAgent(query: string): { match?: AgentProfile; candidates: AgentProfile[]; }; insertTopic(topic: Topic): void; updateTopic(topic: Topic, updatedAt: string): void; getTopic(idOrAlias: string): Topic | undefined; listTopics(status?: 'active' | 'archived'): Topic[]; /** Resolves a name case-insensitively, reporting ambiguity instead of guessing. */ resolveTopic(query: string): { match?: Topic; candidates: Topic[]; }; private topicFromRow; private insertTopicAliases; listPostAcknowledgments(postId: string): PostAcknowledgment[]; /** * Who has acknowledged a post and who has not. * * The denominator is agents that existed when the post was written. An agent * created afterwards is counted separately rather than listed as * outstanding — it was not there, and a roster that says otherwise accuses a * newcomer of ignoring something written before it arrived. */ postRoster(postId: string): PostRoster | undefined; listRuntimeBindings(agentId: string): AgentRuntimeBinding[]; bindRuntime(binding: { id: string; agentId: string; installationId?: string; runtime: string; profile?: string; capabilities?: Record; boundAt: string; }): void; unbindRuntime(bindingId: string): boolean; /** * Advisory only. Records that Synomem observed this binding act — never that * the runtime is reachable now, and never that a delivery succeeded. */ touchRuntimeBinding(agentId: string, runtime: string, at: string): void; /** * Writes an agent's aliases, refusing any that would make a name ambiguous. * * Two collisions matter and both are rejected here rather than at lookup: an * alias another agent already claims, and an alias equal to a different * agent's canonical ID. Catching them at write means the person adding the * alias sees the conflict, instead of a later reader silently getting one of * two possible agents. */ private insertAliases; listAgents(): AgentProfile[]; replaceProjectionManifest(paths: string[], generatedAt: string): void; /** * @param directory the agent's projection directory name, which is its * handle rather than its canonical ID: these rows are keyed by the path on * disk, and projections are named for people to read. */ replaceAgentProjectionManifest(directory: string, paths: string[], generatedAt: string): void; projectionManifest(): string[]; /** * Re-point manifest paths from one agent directory to another. * * The manifest records what Synomem generated and is what the stale-file * cleanup consults. After a directory moves, entries still naming the old * handle describe files that are no longer there, and the moved ones would * look unaccounted for. * * Rewritten row by row rather than with a LIKE update: a manifest is small, * and comparing an exact path prefix needs no thought about what characters * a pattern would treat specially. */ renameProjectionManifestPrefix(previousHandle: string, nextHandle: string): void; /** The manifest with the time each path was written, newest first. */ projectionManifestEntries(): { path: string; generatedAt: string; }[]; integrityCheck(): string[]; journalMode(): string; backup(destination: string): Promise; private restrictDatabaseFiles; close(): void; } export {}; //# sourceMappingURL=storage.d.ts.map