import type { Database } from "../data/database.js"; /** Revision metadata for a member document in the asset registry. */ export interface DocumentMeta { revision: number; contentHash: string; contentLength: number; updatedAt?: number; updatedBy?: "user" | "member"; updatedByMemberId?: string; updatedByName?: string; } export interface DocumentIdentity { /** POSIX path relative to BOSSMODE_DIR, also the stable document key. */ path: string; layer: "persona" | "principles" | "mainline"; memberId?: string; /** Shared scopes key: bare room ID, dm:; absent for global. */ scopeId?: string; } export interface DocumentHistory { ordinal: number; revision: number; scopeId?: string; ts?: number; actorType?: "user" | "member"; actorMemberId?: string; actorName?: string; operation: string; reason: string; contentHash: string; contentLength: number; snapshotPath: string; snapshotHash: string; snapshotBytes: number; } export interface DocumentRecord extends DocumentIdentity { meta: DocumentMeta; } export declare function documentContentMeta(content: string): Pick; /** Asset references never escape the retained body roots or name non-Markdown files. */ export declare function validateDocumentPath(path: string): string; /** Content-addressed, immutable snapshots beside the current document. */ export declare function documentSnapshotPath(path: string, hash: string): string; export declare function getDocument(db: Database, path: string): DocumentRecord | undefined; export declare function assertDocumentIdentity(record: DocumentRecord | undefined, identity: DocumentIdentity): void; /** SQL-only initial ownership for a durably prepared body. The caller includes this strict * insert in its creation transaction; birth has no historical revision or invented actor. */ export declare function insertInitialDocument(db: Database, identity: DocumentIdentity, meta: Pick): void; export interface DocumentImportContext { /** Synchronous parent upgrade hook. Retain exact bytes; reject different existing content. * Returns only after bytes are safely staged for cutover. This is NOT the live writer. */ stageAsset(relativePath: string, bytes: Uint8Array): void; } export interface ImportedDocumentHistory { revision?: number; scopeId?: string; ts?: number; actorType?: "user" | "member"; actorMemberId?: string; actorName?: string; operation?: string; reason?: string; contentHash?: string; contentLength?: number; /** Legacy JSONL snapshot, required. Never substitute today's body for missing history. */ content: string; } export interface DocumentImport { identity: DocumentIdentity; /** Current body read by the startup inventory, never written by this importer. */ currentContent: string; /** The parent identifies the legacy authority explicitly: member-memory used event count; * legacy metadata files were authoritative when present (missing entry meant revision zero). */ metadataSource: "history" | "file"; /** File metadata, when present, remains authoritative even if revision differs from event count. */ meta?: DocumentMeta; /** Source order is significant. Member-memory revisions were the parsed event count. */ history: readonly ImportedDocumentHistory[]; } /** Pure, explicit startup import: no source discovery, reads, binding or initialization. * Prepare assets outside SQL, then insert one document atomically. Retry by rebuilding the staging DB; * duplicate import is rejected rather than replacing committed history. */ export declare function importDocument(db: Database, ctx: DocumentImportContext, input: DocumentImport): void; /** Persist prepared birth assets and directory entries before committing identity metadata. */ export declare function syncMemberBirthAssets(path: string): void; //# sourceMappingURL=assets.d.ts.map