@takboo/dsh-session-bin 0.2.2 → 0.2.4
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.
- package/README.md +15 -12
- package/dist/host/platform-files.d.ts +3 -1
- package/dist/index.js +8 -3
- package/dist/index.js.map +2 -2
- package/docs/client-interface.md +1 -1
- package/docs/host-lifecycle.md +1 -1
- package/package.json +5 -3
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.ts", "../src/host/lease.ts", "../src/host/platform-files.ts", "../src/host/native.ts", "../src/host/module.ts", "../src/operations/schema.ts", "../src/host/retirement.ts", "../src/operations/retirement.ts", "../src/operations/archive.ts", "../src/host/store.ts", "../src/host/retirement-store.ts", "../src/host/archive.ts", "../src/host/native-retirement-owner.ts", "../src/host/native-retirement-sdk.ts", "../src/host/native-jsonl-files.ts", "../src/host/native-retirement-persistence.ts", "../src/host/native-retirement-admission.ts", "../src/host/native-retirement-metadata.ts", "../src/host/retirement-owner.ts", "../src/operations/retirement-owner.ts", "../src/host/retirement-owner-store.ts", "../src/host/remote.ts", "../src/remote/contracts.ts"],
|
|
4
|
-
"sourcesContent": ["import { join } from 'node:path';\nimport { Context, Service } from '@deepseek-ai/cordis';\nimport schema from '@deepseek-ai/schemastery';\nimport { resolveDshHome } from '@deepseek-ai/dsh-home-paths';\nimport { workspaceDomainState } from '@deepseek-ai/dsh-workspace';\nimport type {} from '@deepseek-ai/dsh-session-persistence';\nimport { acquireBinLease } from './host/lease.js';\nimport { DshBinPort } from './host/native.js';\nimport { archiveDomainSpec, DomainArchiveStore, binDomainSpec, DomainBinStore } from './host/store.js';\nimport { retirementDomainSpec, DomainRetirementStore } from './host/retirement-store.js';\nimport type { PreparePurgeRequest, PurgePlan } from './operations/retirement.js';\nimport { purgePlanSchema } from './operations/retirement.js';\nimport { SessionBinModule, SessionBinError, sessionBinRefusal } from './host/module.js';\nimport { ArchiveModule } from './host/archive.js';\nimport { NativeRetirementOwner } from './host/native-retirement-owner.js';\nimport { installSessionBinRemote } from './host/remote.js';\nimport { planSchema } from './operations/schema.js';\nimport type { BinPlan } from './operations/schema.js';\nimport type { ArchivePlan, ArchivePrepareRequest } from './operations/archive.js';\n\nexport * from './host/platform-files.js';\nexport * from './host/native-retirement-owner.js';\nexport * from './host/native-jsonl-files.js';\nexport * from './host/native-retirement-metadata.js';\nexport * from './host/native-retirement-admission.js';\nexport * from './host/native-retirement-persistence.js';\nexport { acquireBinLease, BinLeaseError } from './host/lease.js';\nexport { DshBinPort } from './host/native.js';\nexport { binDomainSpec, DomainBinStore, archiveDomainSpec, DomainArchiveStore } from './host/store.js';\nexport type { BinStore, ArchiveStore } from './host/store.js';\nexport { SessionBinModule, SessionBinError } from './host/module.js';\nexport { ArchiveModule } from './host/archive.js';\nexport type { NativeArchivePort, ArchiveOptions } from './host/archive.js';\nexport * from './operations/archive.js';\nexport { SessionBinRemote, installSessionBinRemote } from './host/remote.js';\nexport type { NativeBinPort, NativeSessionState, ReconcileReport } from './host/module.js';\nexport type { BinEntry, BinPlan, BinResult, BinOperation, PrepareRequest } from './operations/schema.js';\nexport * from './operations/retirement.js';\nexport * from './host/retirement-store.js';\nexport { retirementManifestDigest } from './host/retirement.js';\nexport type { SessionRetirementOwnerV1, RetirementOptions, PurgeReconcileReport } from './host/retirement.js';\nexport * from './operations/retirement-owner.js';\nexport * from './host/retirement-owner-store.js';\nexport { RetirementOwnerCoordinator, RetirementOwnerError } from './host/retirement-owner.js';\nexport type {\n RetirementOwnerGuards, RetirementLifecycleScope, RetirementLifecyclePort,\n RetirementResourceParticipant, RetirementOwnerCoordinatorOptions, RetirementOwnerCheckpoint,\n RetirementResource, RetirementResourceReceipt,\n} from './host/retirement-owner.js';\n\nexport interface Config { coordinationDirectory?: string; permanentDeletion?: boolean }\nexport const Config = schema.object({\n permanentDeletion: schema.boolean().default(true).description('Enable the version-checked cold JSONL deletion Adapter when its complete composition is supported.'),\n coordinationDirectory: schema.string().description('Absolute shared directory for this Bin domain\u2019s lifetime lock; defaults to $DSH_HOME/session-bin.'),\n});\nexport const name = 'session-bin';\nexport const inject = ['storageDomain', 'workspaceRegistry', 'sessions', 'sessionPersistence', 'typert'];\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context { sessionBin: SessionBin }\n}\n\n/** Production native archive interface; v1 core is confined to compatibility. */\nexport class SessionBin extends Service {\n static inject = inject;\n private module!: ArchiveModule;\n private legacy!: SessionBinModule;\n private archiveStore!: DomainArchiveStore;\n private nativeOwner: NativeRetirementOwner | undefined;\n private ready = false;\n constructor(ctx: Context, private readonly config: Config = {},\n private readonly createNativeOwner: (ctx: Context) => Promise<NativeRetirementOwner | undefined> = ctx => NativeRetirementOwner.open(ctx)) {\n super(ctx, 'sessionBin');\n }\n\n async [Service.init](): Promise<void> {\n const directory = this.config.coordinationDirectory ?? join(resolveDshHome(), 'session-bin');\n const release = await acquireBinLease(directory);\n const domains: Array<() => Promise<void>> = [];\n let stopListening: (() => void) | undefined;\n let disposed = false;\n let finishInitializing!: () => void;\n const initializing = new Promise<void>(resolve => { finishInitializing = resolve; });\n const closeDomains = async () => {\n const errors: unknown[] = [];\n for (const close of [...domains].reverse()) try { await close(); } catch (error) { errors.push(error); }\n if (errors.length) throw new AggregateError(errors, 'Session Bin domains failed to close.');\n };\n try {\n this.ctx.effect(() => async () => {\n disposed = true;\n this.ready = false;\n await initializing;\n const errors: unknown[] = [];\n try { if (this.module) await this.module.close(); } catch (error) { errors.push(error); }\n try { if (this.legacy) await this.legacy.close(); } catch (error) { errors.push(error); }\n try { if (this.nativeOwner) await this.nativeOwner.close(); } catch (error) { errors.push(error); }\n try { stopListening?.(); } catch (error) { errors.push(error); }\n try { await closeDomains(); } catch (error) { errors.push(error); }\n try { await release(); } catch (error) { errors.push(error); }\n if (errors.length) throw new AggregateError(errors, 'Session Bin teardown failed.');\n }, 'session-bin.dispose');\n } catch (error) {\n finishInitializing();\n await release();\n throw error;\n }\n try {\n const domain = await this.ctx.storageDomain.open(binDomainSpec);\n domains.push(() => domain.close());\n this.ctx.fiber.assertActive();\n const retirementDomain = await this.ctx.storageDomain.open(retirementDomainSpec);\n domains.push(() => retirementDomain.close());\n this.ctx.fiber.assertActive();\n const archiveDomain = await this.ctx.storageDomain.open(archiveDomainSpec);\n domains.push(() => archiveDomain.close());\n this.ctx.fiber.assertActive();\n const native = new DshBinPort(this.ctx);\n const legacyStore = new DomainBinStore(domain);\n const retirementStore = new DomainRetirementStore(retirementDomain);\n this.nativeOwner = this.config.permanentDeletion === false ? undefined : await this.createNativeOwner(this.ctx);\n this.ctx.fiber.assertActive();\n // Observation and migration remain inert; only explicit preparation adopts\n // a lifecycle supplied by the independently checked native Adapter.\n this.legacy = new SessionBinModule(legacyStore, native, {\n legacyReadOnly: true, retirement: { store: retirementStore, closeStore: false },\n });\n this.archiveStore = new DomainArchiveStore(archiveDomain);\n this.module = new ArchiveModule(this.archiveStore, native, {\n retirement: { store: retirementStore, closeStore: false,\n ...(this.nativeOwner ? { owner: this.nativeOwner } : {}),\n resolveOwner: async () => {\n if (this.config.permanentDeletion === false) return undefined;\n if (!this.nativeOwner) this.nativeOwner = await this.createNativeOwner(this.ctx);\n return this.nativeOwner;\n },\n verifiedNativeArchive: capabilities => this.nativeOwner !== undefined\n && capabilities.ownerId === 'session-bin-native-jsonl-owner'\n && capabilities.hostVersion === '0.2.0-rc.2' && capabilities.providerId === 'jsonl-session-records-v1' },\n operationIdClaimed: id => legacyStore.operation(id) !== undefined,\n pendingPurge: id => retirementStore.operations().some(operation => operation.phase !== 'done' && operation.plan.sessionId === id),\n reconcileLegacy: () => this.legacy.operations(),\n reconcileLegacyPurge: () => this.legacy.reconcilePurge(),\n });\n stopListening = this.ctx.root.on('domain/changed', change => {\n if (change.domain !== 'workspace' || change.table !== '' || change.operation !== 'put') return;\n const state = workspaceDomainState.parse(change.value);\n // Both consumers capture the frame synchronously before their queues yield.\n const legacy = this.legacy.observeArchives(state.archivedSessionIds);\n const archive = this.module.observeArchives(state.archivedSessionIds);\n void Promise.all([legacy, archive]).catch(error => {\n this.ctx.logger.warn(`session-bin: reconciliation failed: ${String(error)}`);\n });\n });\n await this.legacy.reconcile();\n await this.module.reconcile();\n this.ctx.fiber.assertActive();\n if (!disposed) this.ready = true;\n } finally { finishInitializing(); }\n }\n\n private requireModule(): ArchiveModule {\n if (!this.ready) throw new SessionBinError('bin/not-ready', 'Session Bin has not finished initialization or is unloading.');\n return this.module;\n }\n private checkLegacyClaim(operationId: string) {\n if (this.archiveStore.operation(operationId)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to an archive request.');\n }\n }\n prepare(request: ArchivePrepareRequest) { return this.requireModule().prepare(request); }\n preparePurge(request: PreparePurgeRequest) { return this.requireModule().preparePurge(request); }\n executePurge(input: PurgePlan) {\n const plan = purgePlanSchema.parse(input);\n if (plan.schemaVersion === 2) return this.requireModule().executePurge(plan);\n return this.requireModule().compatibility(async () => { this.checkLegacyClaim(plan.operationId); return this.legacy.executePurge(plan); });\n }\n getPurgeOperation(operationId: string) { return this.requireModule().getPurgeOperation(operationId); }\n purgeOperations() { return this.requireModule().purgeOperations(); }\n reconcilePurge() { return this.requireModule().reconcilePurge(); }\n execute(input: ArchivePlan | BinPlan) {\n if (input.schemaVersion === 2) return this.requireModule().execute(input);\n const plan = planSchema.parse(input);\n return this.requireModule().compatibility(async () => { this.checkLegacyClaim(plan.operationId); return this.legacy.execute(plan); });\n }\n list() { return this.requireModule().list(); }\n operations() { return this.requireModule().operations(); }\n getOperation(operationId: string) {\n return this.requireModule().compatibility(async () => this.archiveStore.operation(operationId) ?? await this.legacy.getOperation(operationId));\n }\n reconcile() { return this.requireModule().reconcile(); }\n}\nexport async function apply(ctx: Context, config: Config = {}) {\n await ctx.plugin(SessionBin, config);\n await installSessionBinRemote(ctx);\n}\n", "import { constants } from 'node:fs';\nimport { mkdir, open, realpath, lstat } from 'node:fs/promises';\nimport { isAbsolute, join } from 'node:path';\nimport { tryLockExclusive } from '@deepseek-ai/node-addon-system/flock';\n\nimport { acquireWindowsSemaphore, nativePlatformCandidate } from './platform-files.js';\n\nexport class BinLeaseError extends Error {\n readonly code = 'bin/lease-unavailable';\n}\n\n// Own only this plugin's lock. Never unlink it: flock coordinates an inode.\n// The directory must be shared by every composition using the same Bin domain.\n// Windows uses a kernel semaphore; the persistent marker is never the arbiter.\nexport async function acquireBinLease(directory: string): Promise<() => Promise<void>> {\n if (!nativePlatformCandidate()) throw new BinLeaseError('This Host platform has no implemented kernel lease.');\n if (!isAbsolute(directory)) throw new BinLeaseError('Coordination directory must be absolute.');\n await mkdir(directory, { recursive: true, mode: 0o700 });\n const root = await realpath(directory);\n const rootIdentity = await lstat(root, { bigint: true });\n const filename = join(root, 'writer.lock');\n try {\n const previous = await lstat(filename, { bigint: true });\n if (!previous.isFile() || previous.nlink !== 1n || previous.size !== 0n) throw new BinLeaseError('The existing coordination marker is not an empty exclusive regular file.');\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n const handle = await open(filename, constants.O_CREAT | constants.O_RDWR | (constants.O_NOFOLLOW ?? 0), 0o600);\n let unlock: (() => Promise<void>) | undefined;\n try {\n if (process.platform === 'win32') unlock = await acquireWindowsSemaphore(filename, 'plugin');\n else await tryLockExclusive(handle.fd);\n const held = await handle.stat({ bigint: true });\n const current = await lstat(filename, { bigint: true });\n const currentRoot = await lstat(root, { bigint: true });\n if (!held.isFile() || !current.isFile() || held.nlink !== 1n || current.nlink !== 1n || held.size !== 0n || current.size !== 0n\n || held.ino !== current.ino || held.dev !== current.dev || held.birthtimeNs !== current.birthtimeNs\n || !currentRoot.isDirectory() || currentRoot.ino !== rootIdentity.ino || currentRoot.dev !== rootIdentity.dev\n || currentRoot.birthtimeNs !== rootIdentity.birthtimeNs || await realpath(directory) !== root) {\n throw new BinLeaseError('The coordination lock identity changed.');\n }\n } catch (cause) {\n const errors = [cause];\n try { await unlock?.(); } catch (error) { errors.push(error); }\n try { await handle.close(); } catch (error) { errors.push(error); }\n throw new BinLeaseError('Cannot acquire exclusive Bin ownership.', { cause: errors.length === 1 ? cause : new AggregateError(errors) });\n }\n let release: Promise<void> | undefined;\n return () => release ??= (async () => {\n const errors: unknown[] = [];\n try { await unlock?.(); } catch (error) { errors.push(error); }\n try { await handle.close(); } catch (error) { errors.push(error); }\n if (errors.length) throw new AggregateError(errors, 'Bin kernel lease release failed.');\n })();\n}\n", "import { createHash } from 'node:crypto';\nimport { constants } from 'node:fs';\nimport { lstat, open } from 'node:fs/promises';\nimport type { FileHandle } from 'node:fs/promises';\nimport { resolve, toNamespacedPath } from 'node:path';\n\nexport type NativePlatform = 'darwin' | 'linux' | 'win32';\nexport function nativePlatformCandidate(platform = process.platform, arch = process.arch): boolean {\n return ['darwin', 'linux', 'win32'].includes(platform) && ['arm64', 'x64'].includes(arch);\n}\n/** Actual erasure evidence is promoted separately from an implemented Adapter. */\nexport function nativePlatformVerified(platform = process.platform, arch = process.arch, node = process.versions.node, uv = process.versions.uv): boolean {\n if (node !== '24.18.1' || uv !== '1.52.1') return false;\n return new Set(['darwin/arm64', 'darwin/x64', 'linux/arm64', 'linux/x64', 'win32/x64']).has(`${platform}/${arch}`);\n}\n\ninterface WindowsKernel {\n createSemaphore(name: string): number;\n wait(handle: number): number;\n release(handle: number): number;\n close(handle: number): number;\n moveFile(source: string, destination: string, flags: number): number;\n lastError(): number;\n}\nlet windowsKernel: Promise<WindowsKernel> | undefined;\nfunction kernel(): Promise<WindowsKernel> {\n if (process.platform !== 'win32') throw new Error('Windows kernel operations require a native Windows runtime.');\n return windowsKernel ??= (async () => {\n const library = (await import('koffi')).default.load('kernel32.dll');\n const create = library.func('__stdcall', 'CreateSemaphoreW', 'intptr', ['void*', 'int', 'int', 'str16']);\n const wait = library.func('__stdcall', 'WaitForSingleObject', 'uint', ['intptr', 'uint']);\n const release = library.func('__stdcall', 'ReleaseSemaphore', 'int', ['intptr', 'int', 'void*']);\n const close = library.func('__stdcall', 'CloseHandle', 'int', ['intptr']);\n const moveFile = library.func('__stdcall', 'MoveFileExW', 'int', ['str16', 'str16', 'uint']);\n const lastError = library.func('__stdcall', 'GetLastError', 'uint', []);\n return { createSemaphore: name => create(null, 1, 1, name) as number,\n wait: handle => wait(handle, 0) as number, release: handle => release(handle, 1, null) as number,\n close: handle => close(handle) as number, moveFile: (source, destination, flags) => moveFile(source, destination, flags) as number,\n lastError: () => lastError() as number };\n })();\n}\n/** Session namespace matches the audited JSONL writer; plugin ownership is independent. */\nexport function windowsSemaphoreName(path: string, purpose: 'session' | 'plugin'): string {\n const digest = createHash('sha256').update(resolve(path).toLowerCase()).digest('hex');\n return `Local\\\\${purpose === 'session' ? 'dsh-session-lock' : 'dsh-session-bin-lock'}-${digest}`;\n}\nfunction windowsError(syscall: string, error: number): NodeJS.ErrnoException {\n return Object.assign(new Error(`${syscall} failed with Windows error ${error}.`),\n { code: [2, 3].includes(error) ? 'ENOENT' : [80, 183].includes(error) ? 'EEXIST' : error === 17 ? 'EXDEV'\n : error === 32 ? 'EBUSY' : error === 5 ? 'EACCES' : 'EIO', syscall, win32Code: error });\n}\n\n/** Same-volume rename whose metadata acknowledgement is written through. */\nexport async function renameWindowsWriteThrough(source: string, destination: string): Promise<void> {\n const api = await kernel();\n // MOVEFILE_WRITE_THROUGH only: replacing a destination or copying across a\n // volume would expand the caller's frozen path/identity scope.\n if (api.moveFile(toNamespacedPath(source), toNamespacedPath(destination), 8) === 0) throw windowsError('MoveFileExW', api.lastError());\n}\n/** No lock file, expiry, or stale-PID deletion; the last kernel handle owns its lifetime. */\nexport async function acquireWindowsSemaphore(path: string, purpose: 'session' | 'plugin'): Promise<() => Promise<void>> {\n const api = await kernel();\n const handle = api.createSemaphore(windowsSemaphoreName(path, purpose));\n if (handle === 0) throw windowsError('CreateSemaphoreW', api.lastError());\n const result = api.wait(handle);\n if (result !== 0) {\n const error = result === 258 ? 32 : api.lastError();\n if (api.close(handle) === 0) throw new AggregateError([windowsError('WaitForSingleObject', error), windowsError('CloseHandle', api.lastError())], 'Kernel lease acquisition cleanup failed.');\n throw windowsError('WaitForSingleObject', error);\n }\n let releasing: Promise<void> | undefined;\n return () => releasing ??= (async () => {\n const errors: Error[] = [];\n if (api.release(handle) === 0) errors.push(windowsError('ReleaseSemaphore', api.lastError()));\n if (api.close(handle) === 0) errors.push(windowsError('CloseHandle', api.lastError()));\n if (errors.length) throw new AggregateError(errors, 'Kernel lease release failed.');\n })();\n}\n\n/** POSIX namespace durability. Windows callers must use their audited owner protocol. */\nexport async function syncDirectory(path: string): Promise<void> {\n if (process.platform === 'win32') return;\n const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);\n try { await handle.sync(); } finally { await handle.close(); }\n}\n\nexport class RegularFileRefusal extends Error {\n constructor(readonly code: 'platform/unsafe-file' | 'platform/file-changed' | 'platform/identity-unavailable', message: string) { super(message); }\n}\n\n/** Refuse symlinks and compare the opened identity even when O_NOFOLLOW is unavailable. */\nexport async function openRegularFile(path: string, access: 'read' | 'write'): Promise<FileHandle> {\n const before = await lstat(path, { bigint: true });\n if (!before.isFile() || before.nlink !== 1n) throw new RegularFileRefusal('platform/unsafe-file', 'An exclusive regular file is required.');\n if (before.ino <= 0n || before.birthtimeNs <= 0n) throw new RegularFileRefusal('platform/identity-unavailable', 'The filesystem cannot certify this file incarnation.');\n const handle = await open(path, (access === 'read' ? constants.O_RDONLY : constants.O_RDWR) | (constants.O_NOFOLLOW ?? 0));\n try {\n const actual = await handle.stat({ bigint: true });\n if (!actual.isFile() || actual.nlink !== 1n) throw new RegularFileRefusal('platform/unsafe-file', 'The opened file is not exclusive.');\n if (actual.ino <= 0n || actual.birthtimeNs <= 0n) throw new RegularFileRefusal('platform/identity-unavailable', 'The descriptor cannot certify this file incarnation.');\n if (before.dev !== actual.dev || before.ino !== actual.ino || before.birthtimeNs !== actual.birthtimeNs) {\n throw new RegularFileRefusal('platform/file-changed', 'The regular file changed while opening its descriptor.');\n }\n return handle;\n } catch (error) { await handle.close(); throw error; }\n}\n", "import type { Context } from '@deepseek-ai/cordis';\nimport { SessionId } from '@deepseek-ai/dsh-session';\nimport { WorkspaceActiveSessionError, WorkspaceUnknownSessionError, workspaceDomainState } from '@deepseek-ai/dsh-workspace';\nimport { SessionBinError } from './module.js';\nimport type { NativeBinPort, NativeSessionState } from './module.js';\n\n/** All native actions stay on public SDK methods; cold inspection claims no writer. */\nexport class DshBinPort implements NativeBinPort {\n constructor(private readonly ctx: Context) {}\n archivedSessionIds(): readonly string[] {\n // Domain events publish the committed global snapshot before the Registry's\n // in-memory projection resumes its await. Read that public snapshot so list\n // and admission share the same durable native member set as the frame.\n const domain = this.ctx.storageDomain.get('workspace');\n if (!domain) throw new Error('Native workspace domain is unavailable.');\n return workspaceDomainState.parse(domain.global.get()).archivedSessionIds;\n }\n async inspect(rawId: string): Promise<NativeSessionState> {\n const id = SessionId(rawId);\n const live = this.ctx.sessions.get(id);\n const persisted = live ? undefined : await this.ctx.sessionPersistence.stat(id);\n return {\n archived: this.archivedSessionIds().includes(id),\n known: live !== undefined || persisted !== undefined,\n workspaceId: this.ctx.workspaceRegistry.list().find(workspace => workspace.sessionIds.includes(id))?.id ?? null,\n };\n }\n async activity(rawId: string): Promise<string[]> {\n const activity = await this.ctx.waterfall('workspace/session-activity',\n { sessionId: SessionId(rawId) }, async () => []);\n return activity.map(item => String(item.kind));\n }\n async archive(rawId: string): Promise<void> {\n try {\n await this.ctx.workspaceRegistry.archiveSession(SessionId(rawId));\n } catch (cause) {\n if (cause instanceof WorkspaceActiveSessionError) {\n throw new SessionBinError('session-active', cause.message, { cause });\n }\n if (cause instanceof WorkspaceUnknownSessionError) {\n throw new SessionBinError('session-not-found', cause.message, { cause });\n }\n throw cause;\n }\n }\n unarchive(rawId: string): Promise<void> {\n return this.ctx.workspaceRegistry.unarchiveSession(SessionId(rawId));\n }\n}\n", "import { randomUUID } from 'node:crypto';\nimport { entrySchema, planSchema, prepareRequestSchema, resultSchema } from '../operations/schema.js';\nimport type { BinBlocker, BinEntry, BinOperation, BinPlan, BinResult, PrepareRequest } from '../operations/schema.js';\nimport type { BinStore } from './store.js';\nimport { SessionBinPurgeModule } from './retirement.js';\nimport type { RetirementOptions } from './retirement.js';\nimport { preparePurgeRequestSchema, purgePlanSchema } from '../operations/retirement.js';\nimport type { PreparePurgeRequest, PurgePlan } from '../operations/retirement.js';\n\nexport class SessionBinError extends Error {\n constructor(readonly code: string, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'SessionBinError';\n }\n}\nconst businessRefusals = new WeakSet<SessionBinError>();\n/** Internal marker: external failures using the same public Error class remain unknown. */\nexport function sessionBinRefusal(code: string, message: string): SessionBinError {\n const error = new SessionBinError(code, message);\n businessRefusals.add(error);\n return error;\n}\nexport function isSessionBinRefusal(error: unknown): boolean {\n return error instanceof SessionBinError && businessRefusals.has(error);\n}\nexport interface NativeSessionState {\n archived: boolean;\n known: boolean;\n workspaceId: string | null;\n}\nexport interface NativeBinPort {\n inspect(sessionId: string): Promise<NativeSessionState>;\n activity(sessionId: string): Promise<string[]>;\n archive(sessionId: string): Promise<void>;\n unarchive(sessionId: string): Promise<void>;\n}\nexport interface ReconcileReport {\n completed: BinResult[];\n retryRequired: string[];\n releasedEntries: string[];\n}\n\n/** One Host owns this Module; its caller holds the lifetime lease before open. */\nexport class SessionBinModule {\n private tail: Promise<unknown> = Promise.resolve();\n private closing = false;\n private failed = false;\n private failure: unknown;\n private closePromise: Promise<void> | undefined;\n private readonly invalidated = new Set<string>();\n private readonly observedArchived = new Set<string>();\n private readonly purge: SessionBinPurgeModule | undefined;\n\n constructor(private readonly store: BinStore, private readonly native: NativeBinPort,\n private readonly options: { retirement?: RetirementOptions; legacyReadOnly?: boolean } = {}) {\n this.purge = options.retirement ? new SessionBinPurgeModule(options.retirement, {\n newRequestsDisabled: options.legacyReadOnly === true,\n entry: id => this.store.entry(id), invalidated: id => this.invalidated.has(id),\n archived: async id => (await this.native.inspect(id)).archived,\n activity: id => this.native.activity(id), deleteEntry: id => this.store.deleteEntry(id),\n hasArchiveOperation: id => this.store.operation(id) !== undefined,\n hasPendingArchiveOperation: id => this.store.operations().some(item => item.phase !== 'done' && item.plan.sessionId === id),\n }) : undefined;\n }\n\n preparePurge(request: PreparePurgeRequest) {\n const input = preparePurgeRequestSchema.parse(request);\n return this.enqueue(async () => {\n await this.reconcileInner();\n return this.requirePurge().prepare(input);\n });\n }\n executePurge(input: PurgePlan) {\n const plan = purgePlanSchema.parse(input);\n return this.enqueue(() => this.requirePurge().execute(plan));\n }\n getPurgeOperation(operationId: string) { return this.enqueue(async () => this.requirePurge().operation(operationId)); }\n purgeOperations() { return this.enqueue(async () => this.requirePurge().operations()); }\n reconcilePurge() { return this.enqueue(() => this.requirePurge().reconcile(true)); }\n private requirePurge(): SessionBinPurgeModule {\n if (!this.purge) throw sessionBinRefusal('bin/permanent-deletion-unsupported', 'No retirement journal/owner is composed.');\n return this.purge;\n }\n\n prepare(request: PrepareRequest): Promise<BinPlan> {\n const input = prepareRequestSchema.parse(request);\n return this.enqueue(async () => {\n await this.reconcileInner();\n const state = await this.native.inspect(input.sessionId);\n const entry = this.store.entry(input.sessionId);\n const plan: BinPlan = {\n schemaVersion: 1,\n operationId: input.operationId ?? randomUUID(),\n action: input.action,\n sessionId: input.sessionId,\n expected: { archived: state.archived, entryId: entry?.entryId ?? null },\n blockers: [],\n };\n plan.blockers = await this.blockers(plan, state, entry);\n return planSchema.parse(plan);\n });\n }\n\n execute(input: BinPlan): Promise<BinResult> {\n // Snapshot at admission: callers cannot mutate an enqueued request.\n const plan = planSchema.parse(input);\n return this.enqueue(async () => {\n if (this.purge?.operation(plan.operationId)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to a purge request.');\n }\n const previous = this.store.operation(plan.operationId);\n if (previous) {\n if (!this.sameRequest(previous.plan, plan)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to a different request.');\n }\n if (previous.result) return resultSchema.parse(previous.result);\n if (previous.phase === 'applied') return this.finalize(previous);\n }\n if (this.options.legacyReadOnly) {\n await this.reconcileInner();\n const receipt = this.store.operation(plan.operationId)?.result;\n return receipt ? resultSchema.parse(receipt) : this.finish(this.emptyOperation(plan), 'rejected', 'legacy-operation-disabled');\n }\n await this.reconcileInner();\n const recovered = this.store.operation(plan.operationId);\n if (recovered?.result) return resultSchema.parse(recovered.result);\n const state = await this.native.inspect(plan.sessionId);\n const current = this.store.entry(plan.sessionId);\n const stale = state.archived !== plan.expected.archived\n || (current?.entryId ?? null) !== plan.expected.entryId\n || (recovered?.entry && this.invalidated.has(recovered.entry.entryId));\n if (stale) return this.finish(recovered ?? this.emptyOperation(plan), 'conflict', 'state-changed');\n const blockers = await this.blockers(plan, state, current);\n if (blockers.length) return this.finish(recovered ?? this.emptyOperation(plan), 'rejected', blockers[0]!.code);\n const entry = recovered?.entry ?? (plan.action === 'bin' ? entrySchema.parse({\n schemaVersion: 1,\n sessionId: plan.sessionId,\n entryId: randomUUID(),\n operationId: plan.operationId,\n binnedAt: new Date().toISOString(),\n workspaceIdAtBin: state.workspaceId,\n wasArchived: state.archived,\n }) : current!);\n const operation: BinOperation = recovered ?? {\n ...this.emptyOperation(plan), entry, phase: 'intent',\n };\n if (plan.action === 'bin' && !recovered) await this.purge?.capture(entry);\n await this.store.putOperation(operation);\n // The intent write itself yields. Check native state and activity again;\n // ordinary native archive still performs its own admission waterfall.\n const fresh = await this.native.inspect(plan.sessionId);\n if (fresh.archived !== plan.expected.archived || this.invalidated.has(entry.entryId)) {\n return this.finish(operation, 'conflict', 'state-changed');\n }\n if (!fresh.known) return this.finish(operation, 'rejected', 'session-not-found');\n try {\n if (plan.action === 'bin') {\n if ((await this.native.activity(plan.sessionId)).length) {\n return this.finish(operation, 'rejected', 'session-active');\n }\n const admitted = await this.native.inspect(plan.sessionId);\n if (admitted.archived !== plan.expected.archived || this.invalidated.has(entry.entryId)) {\n return this.finish(operation, 'conflict', 'state-changed');\n }\n if (!admitted.known) return this.finish(operation, 'rejected', 'session-not-found');\n await this.native.archive(plan.sessionId);\n } else if (!entry.wasArchived) {\n await this.native.unarchive(plan.sessionId);\n }\n } catch (error) {\n if (error instanceof SessionBinError\n && (error.code === 'session-active' || error.code === 'session-not-found')) {\n return this.finish(operation, 'rejected', error.code);\n }\n throw error;\n }\n const applied: BinOperation = { ...operation, phase: 'applied' };\n await this.store.putOperation(applied);\n return this.finalize(applied);\n });\n }\n\n list(): Promise<BinEntry[]> {\n return this.enqueue(async () => {\n await this.reconcileInner();\n return this.store.entries();\n });\n }\n operations(): Promise<BinOperation[]> {\n return this.enqueue(async () => {\n await this.reconcileInner();\n return this.store.operations();\n });\n }\n getOperation(operationId: string): Promise<BinOperation | undefined> {\n return this.enqueue(async () => this.store.operation(operationId));\n }\n reconcile(): Promise<ReconcileReport> {\n return this.enqueue(async () => {\n await this.purge?.reconcile(true);\n return this.reconcileInner();\n });\n }\n\n /** Capture each native archive frame NOW, before queued reconciliation yields.\n * An observed unarchive/rearchive must not restore an old entry's ownership.\n * No archive-generation token exists in the SDK for an unobserved restart ABA.\n */\n observeArchives(archivedSessionIds: readonly string[]): Promise<ReconcileReport> {\n if (this.failed) return Promise.reject(this.unavailable());\n const archived = new Set(archivedSessionIds);\n try {\n for (const entry of this.store.entries()) {\n if (!archived.has(entry.sessionId)) this.invalidated.add(entry.entryId);\n }\n for (const operation of this.store.operations()) {\n const entry = operation.entry;\n if (operation.phase === 'done' || !entry) continue;\n if (archived.has(entry.sessionId)) this.observedArchived.add(entry.entryId);\n else if (operation.phase === 'applied' || entry.wasArchived\n || this.observedArchived.has(entry.entryId)) this.invalidated.add(entry.entryId);\n }\n } catch (error) {\n // Capture runs outside the queue so frames cannot be lost behind a yield.\n // Store reads here are still external I/O boundaries, never business refusals.\n this.failed = true; this.failure = error;\n return Promise.reject(error);\n }\n return this.closing\n ? Promise.resolve({ completed: [], retryRequired: [], releasedEntries: [] })\n : this.enqueue(() => this.reconcileInner());\n }\n\n close(): Promise<void> {\n this.closing = true;\n return this.closePromise ??= this.tail.then(async () => {\n try {\n if (!this.failed) await this.reconcileInner();\n } finally {\n try { await this.purge?.close(); }\n finally { await this.store.close(); }\n }\n });\n }\n\n private emptyOperation(plan: BinPlan): BinOperation {\n return { schemaVersion: 1, plan, createdAt: new Date().toISOString(), phase: 'done', ownershipInvalidated: false, entry: null, result: null };\n }\n private sameRequest(a: BinPlan, b: BinPlan): boolean {\n return a.action === b.action && a.sessionId === b.sessionId\n && a.expected.archived === b.expected.archived && a.expected.entryId === b.expected.entryId;\n }\n private async blockers(plan: BinPlan, state: NativeSessionState, entry: BinEntry | undefined): Promise<BinBlocker[]> {\n const blockers: BinBlocker[] = [];\n if (this.purge?.blocks(plan.sessionId)) blockers.push({ code: 'pending-deletion' });\n if (!state.known) blockers.push({ code: 'session-not-found' });\n if (plan.action === 'bin' && entry) blockers.push({ code: 'already-in-bin' });\n if (plan.action === 'restore' && !entry) blockers.push({ code: 'not-in-bin' });\n if (this.store.operations().some(operation => operation.phase !== 'done'\n && operation.plan.sessionId === plan.sessionId && operation.plan.operationId !== plan.operationId)) {\n blockers.push({ code: 'pending-operation' });\n }\n if (plan.action === 'bin' && state.known) {\n const activity = await this.native.activity(plan.sessionId);\n if (activity.length) blockers.push({ code: 'session-active', activity });\n }\n return blockers;\n }\n private async finish(operation: BinOperation, status: BinResult['status'], reason: string | null): Promise<BinResult> {\n const result = resultSchema.parse({\n operationId: operation.plan.operationId,\n action: operation.plan.action,\n sessionId: operation.plan.sessionId,\n status, reason, entryId: operation.entry?.entryId ?? null,\n });\n const ownershipInvalidated = operation.ownershipInvalidated\n || (operation.entry !== null && this.invalidated.has(operation.entry.entryId))\n || reason === 'archive-changed';\n await this.store.putOperation({ ...operation, phase: 'done', ownershipInvalidated, result });\n return resultSchema.parse(result);\n }\n private async finalize(operation: BinOperation): Promise<BinResult> {\n const entry = operation.entry!;\n const state = await this.native.inspect(operation.plan.sessionId);\n const targetArchived = operation.plan.action === 'bin' || entry.wasArchived;\n const lost = this.invalidated.has(entry.entryId)\n && (operation.plan.action === 'bin' || entry.wasArchived);\n if (state.archived !== targetArchived || lost) {\n return this.finish(operation, 'conflict', 'archive-changed');\n }\n if (!state.known) return this.finish(operation, 'conflict', 'session-not-found');\n if (operation.plan.action === 'bin' && this.purge && !(await this.purge.bindingMatches(entry))) {\n return this.finish(operation, 'conflict', 'lifecycle-changed');\n }\n const current = this.store.entry(entry.sessionId);\n if (current && current.entryId !== entry.entryId) {\n return this.finish(operation, 'conflict', 'entry-changed');\n }\n if (operation.plan.action === 'bin') {\n if (!current) await this.store.putEntry(entry);\n if (this.invalidated.has(entry.entryId)) {\n const result = await this.finish(operation, 'conflict', 'archive-changed');\n await this.store.deleteEntry(entry.sessionId);\n return result;\n }\n } else if (current) {\n await this.store.deleteEntry(entry.sessionId);\n }\n return this.finish(operation, 'success', null);\n }\n private async reconcileInner(): Promise<ReconcileReport> {\n const report: ReconcileReport = { completed: [], retryRequired: [], releasedEntries: [] };\n await this.purge?.reconcile();\n for (const operation of this.store.operations()) {\n if (operation.ownershipInvalidated && operation.entry) this.invalidated.add(operation.entry.entryId);\n }\n for (const operation of this.store.operations()) {\n if (operation.phase === 'done') continue;\n if (operation.phase === 'applied') {\n report.completed.push(await this.finalize(operation));\n continue;\n }\n // Equal before/after booleans cannot prove whether a native call ran and\n // was then undone. Retain a terminal receipt; a NEW explicit plan is needed.\n report.completed.push(await this.finish(operation, 'conflict', 'interrupted'));\n report.retryRequired.push(operation.plan.operationId);\n }\n for (const entry of this.store.entries()) {\n if (this.purge?.ownsPendingEntry(entry.entryId)) continue;\n if (this.invalidated.has(entry.entryId) || !(await this.native.inspect(entry.sessionId)).archived) {\n const owner = this.store.operation(entry.operationId);\n if (!owner || owner.entry?.entryId !== entry.entryId) {\n throw new Error('Bin entry has no matching ownership journal.');\n }\n if (!owner.ownershipInvalidated) {\n await this.store.putOperation({ ...owner, ownershipInvalidated: true });\n }\n await this.store.deleteEntry(entry.sessionId);\n report.releasedEntries.push(entry.sessionId);\n }\n }\n return report;\n }\n private unavailable(): SessionBinError {\n return new SessionBinError(this.failed ? 'bin/recovery-required' : 'bin/closed',\n this.failed ? 'An unexpected failure suspended this Module. Close and reopen before retrying.' : 'Session Bin is closing.',\n this.failed ? { cause: this.failure } : undefined);\n }\n private enqueue<T>(work: () => Promise<T>): Promise<T> {\n if (this.closing || this.failed) return Promise.reject(this.unavailable());\n const result = this.tail.then(async () => {\n if (this.failed) throw this.unavailable();\n try { return await work(); }\n catch (error) {\n // An I/O rejection may follow a durable rename. Do not keep writing from\n // an in-memory snapshot that could now differ from the backend medium.\n if (!isSessionBinRefusal(error)) { this.failed = true; this.failure = error; }\n throw error;\n }\n });\n this.tail = result.then(() => undefined, () => undefined);\n return result;\n }\n}\n", "import { z } from 'zod';\n\nconst identity = z.string().min(1).max(1024);\nexport const actionSchema = z.enum(['bin', 'restore']);\nexport const blockerSchema = z.object({\n code: z.string().min(1),\n activity: z.array(z.string()).optional(),\n}).strict();\nexport const entrySchema = z.object({\n schemaVersion: z.literal(1),\n sessionId: identity,\n entryId: z.uuid(),\n operationId: identity,\n binnedAt: z.iso.datetime(),\n workspaceIdAtBin: identity.nullable(),\n wasArchived: z.boolean(),\n}).strict();\nexport const planSchema = z.object({\n schemaVersion: z.literal(1),\n operationId: identity,\n action: actionSchema,\n sessionId: identity,\n expected: z.object({ archived: z.boolean(), entryId: z.uuid().nullable() }).strict(),\n blockers: z.array(blockerSchema),\n}).strict();\nexport const resultSchema = z.object({\n operationId: identity,\n action: actionSchema,\n sessionId: identity,\n status: z.enum(['success', 'rejected', 'conflict']),\n reason: z.string().min(1).nullable(),\n entryId: z.uuid().nullable(),\n}).strict();\nexport const operationSchema = z.object({\n schemaVersion: z.literal(1),\n plan: planSchema,\n createdAt: z.iso.datetime(),\n phase: z.enum(['intent', 'applied', 'done']),\n ownershipInvalidated: z.boolean(),\n entry: entrySchema.nullable(),\n result: resultSchema.nullable(),\n}).strict().superRefine((operation, ctx) => {\n const { plan, entry, result, phase } = operation;\n if ((phase === 'done') !== (result !== null)) {\n ctx.addIssue({ code: 'custom', message: 'Only a done operation has a result.' });\n }\n if (phase !== 'done' && entry === null) {\n ctx.addIssue({ code: 'custom', message: 'An unfinished operation requires its entry snapshot.' });\n }\n if (entry && (entry.sessionId !== plan.sessionId\n || (plan.action === 'bin' && (entry.operationId !== plan.operationId\n || entry.wasArchived !== plan.expected.archived))\n || (plan.action === 'restore' && entry.entryId !== plan.expected.entryId))) {\n ctx.addIssue({ code: 'custom', message: 'Entry snapshot does not match the operation.' });\n }\n if (result && ((result.status === 'success') !== (result.reason === null)\n || result.entryId !== (entry?.entryId ?? null)\n || (result.status === 'success' && !entry))) {\n ctx.addIssue({ code: 'custom', message: 'Result outcome or entry snapshot is inconsistent.' });\n }\n if (operation.ownershipInvalidated && !entry) {\n ctx.addIssue({ code: 'custom', message: 'Ownership invalidation requires an entry identity.' });\n }\n if (result && (result.operationId !== plan.operationId\n || result.sessionId !== plan.sessionId || result.action !== plan.action)) {\n ctx.addIssue({ code: 'custom', message: 'Result does not match the operation.' });\n }\n});\nexport const prepareRequestSchema = z.object({\n action: actionSchema,\n sessionId: identity,\n operationId: identity.optional(),\n}).strict();\n\nexport type BinEntry = z.infer<typeof entrySchema>;\nexport type BinPlan = z.infer<typeof planSchema>;\nexport type BinResult = z.infer<typeof resultSchema>;\nexport type BinOperation = z.infer<typeof operationSchema>;\nexport type BinBlocker = z.infer<typeof blockerSchema>;\nexport type PrepareRequest = z.infer<typeof prepareRequestSchema>;\n", "import { createHash, randomUUID } from 'node:crypto';\nimport type { BinEntry } from '../operations/schema.js';\nimport type { ArchiveEntry } from '../operations/archive.js';\nimport {\n lifecycleEqual, lifecycleKeySchema, preparePurgeRequestSchema, purgePlanSchema, purgeResultSchema,\n retirementBindingSchema, retirementCapabilitiesSchema, retirementManifestSchema, retirementStateSchema,\n retirementAuthorizationSchema, retirementRequestSchema,\n} from '../operations/retirement.js';\nimport type {\n LifecycleKey, PreparePurgeRequest, PurgeOperation, PurgePlan, PurgeResult, RetirementBinding,\n RetirementCapabilities, RetirementManifest, RetirementRequest, RetirementState, RetirementAuthorization,\n} from '../operations/retirement.js';\nimport type { RetirementStore } from './retirement-store.js';\nimport { sessionBinRefusal, isSessionBinRefusal, SessionBinError } from './module.js';\n\nconst ownerRefusals = new WeakSet<Error>();\nexport function isRetirementOwnerRefusal(error: unknown): boolean { return error instanceof Error && ownerRefusals.has(error); }\nexport function retirementOwnerRefusal(reason: string): Error {\n const error = new Error(reason); ownerRefusals.add(error); return error;\n}\n\n/** The resource owner implements its own durable admission fence and recovery.\n * This interface is a plugin seam, not a native DSH SDK service. */\nexport interface SessionRetirementOwnerV1 {\n capabilities(): Promise<RetirementCapabilities>;\n eligibility?(sessionId: string): Promise<string | null>;\n inspect(sessionId: string): Promise<LifecycleKey | null>;\n prepare(expected: LifecycleKey): Promise<RetirementManifest>;\n retire(request: RetirementRequest, authorize: () => Promise<RetirementAuthorization>, frozenManifest?: RetirementManifest): Promise<RetirementState>;\n getOperation(operationId: string): Promise<RetirementState | null>;\n recover(operationId: string): Promise<RetirementState>;\n}\nexport interface RetirementOptions {\n store: RetirementStore;\n /** False when the composition closes a journal shared by multiple consumers after draining both. */\n closeStore?: boolean;\n owner?: SessionRetirementOwnerV1;\n resolveOwner?: () => Promise<SessionRetirementOwnerV1 | undefined>;\n /** Admission is supplied by the Host composition, never by owner self-report or Client Config. */\n verified?: (capabilities: RetirementCapabilities) => boolean;\n /** Separate qualification for native archive admission and visibility coordination. */\n verifiedNativeArchive?: (capabilities: RetirementCapabilities) => boolean;\n}\nexport interface PurgeHooks {\n newRequestsDisabled?: boolean;\n target?: 'native-archive';\n entry(sessionId: string): BinEntry | ArchiveEntry | undefined;\n invalidated(entryId: string): boolean;\n archived(sessionId: string): Promise<boolean>;\n activity(sessionId: string): Promise<string[]>;\n deleteEntry(sessionId: string): Promise<void>;\n hasArchiveOperation(operationId: string): boolean;\n hasPendingArchiveOperation(sessionId: string): boolean;\n}\nexport interface PurgeReconcileReport { completed: PurgeResult[]; pending: string[] }\n\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value && typeof value === 'object') {\n return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical((value as Record<string, unknown>)[key])}`).join(',')}}`;\n }\n return JSON.stringify(value);\n}\nfunction capabilitiesKey(value: RetirementCapabilities): string {\n return canonical({ ...value, participants: [...value.participants].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0) });\n}\nexport function retirementManifestDigest(input: RetirementManifest): string {\n const manifest = retirementManifestSchema.parse(input);\n const ordered = { ...manifest, capabilities: JSON.parse(capabilitiesKey(manifest.capabilities)),\n resources: [...manifest.resources].sort((a, b) => {\n const first = JSON.stringify([a.ownerId, a.resourceId]);\n const second = JSON.stringify([b.ownerId, b.resourceId]);\n return first < second ? -1 : first > second ? 1 : 0;\n }) };\n return createHash('sha256').update(canonical(ordered)).digest('hex');\n}\nfunction sameBinding(a: RetirementBinding, b: RetirementBinding): boolean {\n return a.schemaVersion === b.schemaVersion && a.entryId === b.entryId && a.entryVersion === b.entryVersion && lifecycleEqual(a.lifecycle, b.lifecycle)\n && capabilitiesKey(a.capabilities) === capabilitiesKey(b.capabilities);\n}\nfunction samePlan(a: PurgePlan, b: PurgePlan): boolean {\n return a.schemaVersion === b.schemaVersion && a.sessionId === b.sessionId && a.expectedEntryId === b.expectedEntryId\n && (a.binding === null ? b.binding === null : b.binding !== null && sameBinding(a.binding, b.binding))\n && (a.manifest === null ? b.manifest === null : b.manifest !== null && retirementManifestDigest(a.manifest) === retirementManifestDigest(b.manifest));\n}\nfunction requestFor(plan: PurgePlan): RetirementRequest {\n if (!plan.binding || !plan.manifest) throw new Error('Executable purge lacks its lifecycle witness.');\n return retirementRequestSchema.parse({ operationId: plan.operationId, expected: plan.binding.lifecycle,\n bin: plan.binding.schemaVersion === 2\n ? { kind: 'native-archive', entryId: plan.binding.entryId, entryVersion: 2 }\n : { entryId: plan.binding.entryId, entryVersion: 1 },\n manifestDigest: retirementManifestDigest(plan.manifest) });\n}\n\nfunction externalFailure(context: string, cause: unknown): Error {\n const message = cause instanceof Error ? cause.message : String(cause);\n return new Error(`${context}: ${message}`, { cause });\n}\nfunction externalRead<T>(context: string, work: () => T): T {\n try { return work(); } catch (cause) { throw externalFailure(context, cause); }\n}\nasync function externalCall<T>(context: string, work: () => Promise<T>): Promise<T> {\n try { return await work(); } catch (cause) { throw externalFailure(context, cause); }\n}\n\n/** Inner operations only: the owning archive/legacy Module supplies the queue, failure fence and lifetime lease. */\nexport class SessionBinPurgeModule {\n private readonly store: RetirementStore;\n constructor(private readonly options: RetirementOptions, private readonly hooks: PurgeHooks) {\n const store = options.store;\n this.store = {\n binding: id => externalRead('Retirement journal read failed', () => store.binding(id)),\n operation: id => externalRead('Retirement journal read failed', () => store.operation(id)),\n operations: () => externalRead('Retirement journal read failed', () => store.operations()),\n putBinding: value => externalCall('Retirement journal write failed', () => store.putBinding(value)),\n putOperation: value => externalCall('Retirement journal write failed', () => store.putOperation(value)),\n close: () => externalCall('Retirement journal close failed', () => store.close()),\n };\n for (const operation of this.store.operations()) {\n if (hooks.hasArchiveOperation(operation.plan.operationId)) throw new Error('An operation identity is claimed by both Bin journals.');\n if (operation.ownerState) this.validateOwnerState(operation.plan, operation.ownerState, operation.authorizationId);\n }\n }\n operation(operationId: string): PurgeOperation | undefined { return this.store.operation(operationId); }\n operations(): PurgeOperation[] { return this.store.operations(); }\n blocks(sessionId: string): boolean {\n return this.store.operations().some(item => item.plan.sessionId === sessionId && item.phase !== 'done');\n }\n blocksTarget(sessionId: string): boolean {\n const version = this.hooks.target === 'native-archive' ? 2 : 1;\n return this.store.operations().some(item => item.schemaVersion === version && item.plan.sessionId === sessionId && item.phase !== 'done');\n }\n ownsPendingEntry(entryId: string): boolean {\n return this.store.operations().some(item => item.entry?.entryId === entryId && item.phase !== 'done');\n }\n close(): Promise<void> { return this.options.closeStore === false ? Promise.resolve() : this.store.close(); }\n\n async capture(entry: BinEntry): Promise<void> {\n const capabilities = await this.admittedCapabilities();\n if (!capabilities) return;\n const observed = await this.ownerCall(() => this.options.owner!.inspect(entry.sessionId));\n if (observed === null) return;\n const lifecycle = lifecycleKeySchema.parse(observed);\n if (lifecycle.sessionId !== entry.sessionId || lifecycle.storeId !== capabilities.storeId) {\n throw new Error('Resource owner inspection returned a different session/store.');\n }\n await this.store.putBinding({ schemaVersion: 1, entryId: entry.entryId, entryVersion: 1, lifecycle, capabilities });\n }\n async bindingMatches(entry: BinEntry): Promise<boolean> {\n const binding = this.store.binding(entry.entryId);\n if (!binding) return true; // Legacy/reversible entries carry no destructive authority.\n const capabilities = await this.admittedCapabilities();\n if (!capabilities || capabilitiesKey(capabilities) !== capabilitiesKey(binding.capabilities)) return false;\n const observed = await this.ownerCall(() => this.options.owner!.inspect(entry.sessionId));\n return observed !== null && lifecycleEqual(binding.lifecycle, lifecycleKeySchema.parse(observed));\n }\n\n async prepare(input: PreparePurgeRequest): Promise<PurgePlan> {\n const request = preparePurgeRequestSchema.parse(input);\n const version = this.hooks.target === 'native-archive' ? 2 : 1;\n const entry = this.hooks.entry(request.sessionId);\n let binding = entry ? this.store.binding(entry.entryId) ?? null : null;\n const plan: PurgePlan = { schemaVersion: version, action: 'purge', operationId: request.operationId ?? randomUUID(),\n sessionId: request.sessionId, expectedEntryId: entry?.entryId ?? null, binding, manifest: null, blockers: [] };\n if (version === 2 && (this.hooks.hasArchiveOperation(plan.operationId) || this.store.operation(plan.operationId))) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Prepare requires a fresh operation identity.');\n }\n try {\n // Explicit preparation alone may bind an observed native member. Listing,\n // startup and old Bin migration never mint lifecycle witnesses.\n if (version === 2 && entry && !binding && !this.blocks(entry.sessionId)\n && !this.hooks.hasPendingArchiveOperation(entry.sessionId) && !this.hooks.invalidated(entry.entryId)\n && await this.hooks.archived(entry.sessionId)) {\n const capabilities = await this.admittedCapabilities();\n if (capabilities && await this.eligibility(entry.sessionId) === null) {\n const observed = await this.ownerCall(() => this.options.owner!.inspect(entry.sessionId));\n if (observed !== null) {\n binding = retirementBindingSchema.parse({ schemaVersion: 2, target: 'native-archive',\n entryId: entry.entryId, entryVersion: 2, lifecycle: lifecycleKeySchema.parse(observed), capabilities });\n if (binding.lifecycle.sessionId !== entry.sessionId) throw new Error('Owner inspection changed the target session.');\n if (!this.hooks.invalidated(entry.entryId) && this.hooks.entry(entry.sessionId)?.entryId === entry.entryId\n && await this.hooks.archived(entry.sessionId)) {\n await this.store.putBinding(binding);\n plan.binding = binding;\n }\n }\n }\n }\n const reason = await this.check(plan, false);\n if (reason) plan.blockers.push({ code: reason });\n else {\n const manifest = retirementManifestSchema.parse(await this.ownerCall(() => this.options.owner!.prepare(lifecycleKeySchema.parse(plan.binding!.lifecycle))));\n this.validateManifest(plan.binding!, manifest);\n plan.manifest = manifest;\n const changed = await this.check(plan, true);\n if (changed) plan.blockers.push({ code: changed });\n }\n } catch (error) {\n const reason = this.refusalReason(error);\n if (reason === null) throw error;\n plan.manifest = null; plan.blockers.push({ code: reason });\n }\n return purgePlanSchema.parse(plan);\n }\n\n async execute(input: PurgePlan): Promise<PurgeResult> {\n const plan = purgePlanSchema.parse(input);\n if (this.hooks.hasArchiveOperation(plan.operationId)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to an archive request.');\n }\n const previous = this.store.operation(plan.operationId);\n if (previous) {\n if (!samePlan(previous.plan, plan)) throw sessionBinRefusal('bin/operation-id-reused', 'Purge identity belongs to a different request.');\n if (previous.phase === 'done') return purgeResultSchema.parse(previous.result);\n if (plan.schemaVersion !== (this.hooks.target === 'native-archive' ? 2 : 1)) {\n throw sessionBinRefusal('bin/deletion-target-mismatch', 'Pending deletion requires its original target consumer.');\n }\n return this.recover(previous);\n }\n if (plan.schemaVersion !== (this.hooks.target === 'native-archive' ? 2 : 1)) {\n throw sessionBinRefusal('bin/deletion-target-mismatch', 'Deletion plan belongs to a different target protocol.');\n }\n const current = this.hooks.entry(plan.sessionId);\n const entry = current?.entryId === plan.expectedEntryId ? current : null;\n const operation: PurgeOperation = { schemaVersion: plan.schemaVersion, plan, createdAt: new Date().toISOString(),\n phase: 'intent', entry, authorizationId: null, ownerState: null, result: null };\n if ((current?.entryId ?? null) !== plan.expectedEntryId) return this.finish(operation, 'conflict', 'entry-changed');\n const reason = await this.check(plan, true);\n if (reason) return this.finish(operation, 'rejected', reason);\n let fresh: RetirementManifest;\n try { fresh = retirementManifestSchema.parse(await this.ownerCall(() => this.options.owner!.prepare(lifecycleKeySchema.parse(plan.binding!.lifecycle)))); }\n catch (error) {\n const refusal = this.refusalReason(error);\n if (refusal === null) throw error;\n return this.finish(operation, 'rejected', refusal);\n }\n this.validateManifest(plan.binding!, fresh);\n if (retirementManifestDigest(fresh) !== retirementManifestDigest(plan.manifest!)) {\n return this.finish(operation, 'conflict', 'resource-scope-changed');\n }\n // Query before saving intent: an owner record with no local journal must\n // not be overwritten or silently treated as a new authorization.\n const existingOwnerOperation = await this.ownerCall(() => this.options.owner!.getOperation(plan.operationId));\n if (existingOwnerOperation !== null) {\n retirementStateSchema.parse(existingOwnerOperation);\n return this.finish(operation, 'conflict', 'owner-operation-id-reused');\n }\n await this.store.putOperation(operation);\n let authorizationId: string | null = null;\n let callbackUsed = false;\n let revoked = false;\n let authorizing: Promise<RetirementAuthorization> | undefined;\n let callbackViolation: Error | undefined;\n const assertLive = () => {\n if (revoked) throw new Error('Retirement authorization capability has been revoked.');\n };\n const refusedCall = (error: Error): Promise<RetirementAuthorization> => {\n const refused = Promise.reject<RetirementAuthorization>(error);\n void refused.catch(() => {}); // Contain an owner that ignores its rejected capability.\n return refused;\n };\n const authorize = (): Promise<RetirementAuthorization> => {\n if (revoked) return refusedCall(new Error('Retirement authorization capability has been revoked.'));\n if (callbackUsed) {\n callbackViolation = new Error('Retirement authorization capability is single-use.');\n return refusedCall(callbackViolation);\n }\n callbackUsed = true;\n authorizing = (async (): Promise<RetirementAuthorization> => {\n const reason = await this.check(plan, true, true);\n assertLive();\n if (reason !== null) return { authorized: false, reason };\n const nonce = randomUUID();\n await this.store.putOperation({ ...operation, phase: 'authorizing', authorizationId: nonce });\n assertLive();\n const afterWrite = await this.check(plan, true, true);\n assertLive();\n if (afterWrite !== null) return { authorized: false, reason: afterWrite };\n // The nonce is never in the request. Only a completed successful callback\n // hands it to the owner; a mere persisted attempt cannot prove admission.\n authorizationId = nonce;\n return retirementAuthorizationSchema.parse({ authorized: true, authorizationId: nonce });\n })();\n void authorizing.catch(() => {});\n return authorizing;\n };\n let state: RetirementState | undefined;\n const failures: unknown[] = [];\n try {\n state = await this.ownerCall(() => this.options.owner!.retire(requestFor(plan), authorize,\n retirementManifestSchema.parse(plan.manifest)));\n } catch (error) { failures.push(error); }\n finally {\n revoked = true;\n // An owner that started but did not await authorization cannot leave\n // writes running after this request, a terminal receipt, or lease release.\n if (authorizing) try { await authorizing; } catch (error) { failures.push(error); }\n }\n if (callbackViolation) failures.push(callbackViolation);\n if (failures.length) throw new AggregateError(failures, 'Retirement admission/authorization failed.');\n if (!state) throw new Error('Resource owner returned no retirement state.');\n const validated = this.validateOwnerState(plan, state, authorizationId);\n return this.acceptState(this.store.operation(plan.operationId)!, validated);\n }\n\n async reconcile(resume = false): Promise<PurgeReconcileReport> {\n const report: PurgeReconcileReport = { completed: [], pending: [] };\n for (const operation of this.store.operations()) {\n if (operation.schemaVersion !== (this.hooks.target === 'native-archive' ? 2 : 1)) continue;\n if (operation.phase === 'done') continue;\n const result = await this.recover(operation, resume);\n if (['success', 'rejected', 'conflict'].includes(result.status)) report.completed.push(result);\n else report.pending.push(operation.plan.operationId);\n }\n return report;\n }\n private async ownerCall<T>(work: () => Promise<T>): Promise<T> {\n try { return await work(); }\n catch (cause) {\n if (cause instanceof Error && ownerRefusals.has(cause)) throw sessionBinRefusal('bin/retirement-refused', cause.message);\n throw externalFailure('Retirement resource owner failed', cause);\n }\n }\n private refusalReason(error: unknown): string | null {\n return error instanceof SessionBinError && isSessionBinRefusal(error) && error.code === 'bin/retirement-refused' ? error.message : null;\n }\n private async eligibility(sessionId: string): Promise<string | null> {\n const owner = this.options.owner;\n if (!owner?.eligibility) return null;\n const reason = await this.ownerCall(() => owner.eligibility!(sessionId));\n if (reason !== null && (typeof reason !== 'string' || !reason.length || reason.length > 1024)) {\n throw new Error('Resource owner returned an invalid eligibility refusal.');\n }\n return reason;\n }\n private async admittedCapabilities(): Promise<RetirementCapabilities | null> {\n if (!this.options.owner && this.options.resolveOwner) {\n const resolved = await this.ownerCall(() => this.options.resolveOwner!());\n if (resolved) this.options.owner = resolved;\n }\n if (!this.options.owner) return null;\n const capabilities = retirementCapabilitiesSchema.parse(await this.ownerCall(() => this.options.owner!.capabilities()));\n return this.options.verified?.(retirementCapabilitiesSchema.parse(capabilities)) === true ? capabilities : null;\n }\n private async check(plan: PurgePlan, requireManifest: boolean, authorizing = false): Promise<string | null> {\n try { return await this.checkInner(plan, requireManifest, authorizing); }\n catch (error) { const reason = this.refusalReason(error); if (reason !== null) return reason; throw error; }\n }\n private async checkInner(plan: PurgePlan, requireManifest: boolean, authorizing = false): Promise<string | null> {\n if (this.hooks.newRequestsDisabled) {\n if (this.store.operations().some(item => item.phase !== 'done' && item.plan.sessionId === plan.sessionId\n && item.plan.operationId !== plan.operationId)) return 'pending-deletion';\n return await this.hooks.archived(plan.sessionId) ? 'permanent-deletion-unsupported' : 'not-archived';\n }\n const entry = this.hooks.entry(plan.sessionId);\n if (!entry) return this.hooks.target === 'native-archive' ? 'not-archived' : 'not-in-bin';\n if (entry.entryId !== plan.expectedEntryId) return 'entry-changed';\n if (this.hooks.invalidated(entry.entryId) || !(await this.hooks.archived(plan.sessionId))) return 'archive-changed';\n if (this.hooks.hasPendingArchiveOperation(plan.sessionId)) return 'pending-operation';\n if (!authorizing && this.store.operations().some(item => item.phase !== 'done'\n && item.plan.sessionId === plan.sessionId && item.plan.operationId !== plan.operationId)) return 'pending-deletion';\n const capabilities = await this.admittedCapabilities();\n if (!capabilities) return 'permanent-deletion-unsupported';\n const eligibility = await this.eligibility(plan.sessionId);\n if (eligibility !== null) return eligibility;\n const binding = this.store.binding(entry.entryId);\n if (!binding || !plan.binding) return 'lifecycle-unbound';\n if (entry.schemaVersion !== plan.schemaVersion || binding.schemaVersion !== plan.schemaVersion\n || !sameBinding(binding, plan.binding) || capabilitiesKey(capabilities) !== capabilitiesKey(binding.capabilities)) return 'lifecycle-changed';\n const observed = await this.ownerCall(() => this.options.owner!.inspect(plan.sessionId));\n if (observed === null || !lifecycleEqual(binding.lifecycle, lifecycleKeySchema.parse(observed))) return 'lifecycle-changed';\n if ((await this.hooks.activity(plan.sessionId)).length) return 'session-active';\n // activity() yields; capture archive invalidation and entry replacement once more.\n if (this.hooks.invalidated(entry.entryId) || this.hooks.entry(plan.sessionId)?.entryId !== entry.entryId\n || !(await this.hooks.archived(plan.sessionId))) return 'archive-changed';\n if (requireManifest && !plan.manifest) return 'resource-manifest-required';\n return null;\n }\n private validateManifest(binding: RetirementBinding, manifest: RetirementManifest): void {\n if (!lifecycleEqual(binding.lifecycle, manifest.lifecycle)\n || capabilitiesKey(binding.capabilities) !== capabilitiesKey(manifest.capabilities)) {\n throw new Error('Resource manifest does not belong to the bound owner and lifecycle.');\n }\n }\n private validateOwnerState(plan: PurgePlan, input: RetirementState, authorizationId: string | null): RetirementState {\n const state = retirementStateSchema.parse(input);\n if (canonical(state.request) !== canonical(requestFor(plan))\n || retirementManifestDigest(state.manifest) !== retirementManifestDigest(plan.manifest!)\n || (state.authorizationId !== null && (authorizationId === null || state.authorizationId !== authorizationId))) {\n throw new Error('Owner receipt changed the operation, lifecycle, Bin binding, resource manifest or Host authorization grant.');\n }\n return state;\n }\n private async recover(operation: PurgeOperation, resume = true): Promise<PurgeResult> {\n // A locally persisted complete owner receipt needs no provider or native\n // existence observation: only the matching plugin entry remains to commit.\n if (operation.ownerState?.phase === 'done') return this.finalize(operation);\n const capabilities = await this.admittedCapabilities();\n if (!capabilities || !operation.plan.binding\n || capabilitiesKey(capabilities) !== capabilitiesKey(operation.plan.binding.capabilities)) {\n return this.pendingResult(operation, 'retirement-owner-unavailable');\n }\n const observed = await this.ownerCall(() => this.options.owner!.getOperation(operation.plan.operationId));\n if (observed === null) {\n if (operation.ownerState !== null) throw new Error('Resource owner lost a previously acknowledged durable operation.');\n return this.finish(operation, 'conflict', 'interrupted');\n }\n const state = this.validateOwnerState(operation.plan, observed, operation.authorizationId);\n if (['done', 'rejected', 'conflict'].includes(state.phase)) return this.acceptState(operation, state);\n this.assertProgress(operation.ownerState, state);\n if (!resume) {\n if (operation.ownerState && canonical(operation.ownerState) === canonical(state) && operation.result) {\n return purgeResultSchema.parse(operation.result);\n }\n return this.acceptState(operation, state);\n }\n // Persist the durable admission we have actually observed BEFORE recovery\n // can yield, erase another resource or fail. A later null/refusal cannot\n // erase this witness and release a half-retired entry.\n await this.acceptState(operation, state);\n const witnessed = this.store.operation(operation.plan.operationId)!;\n const recovered = this.validateOwnerState(operation.plan,\n await this.ownerCall(() => this.options.owner!.recover(operation.plan.operationId)), operation.authorizationId);\n this.assertProgress(state, recovered);\n return this.acceptState(witnessed, recovered);\n }\n private assertProgress(previous: RetirementState | null, next: RetirementState): void {\n if (!previous) return;\n const phases = ['fenced', 'quiesced', 'erasing', 'converging', 'done'];\n if (phases.indexOf(next.phase) < phases.indexOf(previous.phase)) throw new Error('Resource owner regressed a durable retirement phase.');\n for (const receipt of previous.resources.filter(item => item.status !== 'failed')) {\n const current = next.resources.find(item => item.ownerId === receipt.ownerId && item.resourceId === receipt.resourceId);\n if (!current || canonical(current) !== canonical(receipt)) throw new Error('Resource owner lost an acknowledged resource receipt.');\n }\n }\n private async acceptState(operation: PurgeOperation, state: RetirementState): Promise<PurgeResult> {\n this.assertProgress(operation.ownerState, state);\n if (state.phase === 'rejected' || state.phase === 'conflict') {\n return this.finish({ ...operation, ownerState: state }, state.phase, state.reason!);\n }\n const result = purgeResultSchema.parse({ action: 'purge', operationId: operation.plan.operationId,\n sessionId: operation.plan.sessionId, entryId: operation.entry!.entryId,\n status: state.resources.some(item => item.status === 'failed') ? 'partial-failure' : 'pending-recovery',\n reason: state.resources.some(item => item.status === 'failed') ? 'resource-failure' : 'owner-incomplete', ownerState: state });\n const saved: PurgeOperation = { ...operation, phase: 'owner-pending', ownerState: state, result };\n // Preserve the validated owner receipt BEFORE any plugin entry mutation.\n await this.store.putOperation(saved);\n return state.phase === 'done' ? this.finalize(saved) : result;\n }\n private pendingResult(operation: PurgeOperation, reason: string): PurgeResult {\n return purgeResultSchema.parse({ action: 'purge', operationId: operation.plan.operationId,\n sessionId: operation.plan.sessionId, entryId: operation.entry!.entryId,\n status: 'pending-recovery', reason, ownerState: operation.ownerState });\n }\n private async finalize(operation: PurgeOperation): Promise<PurgeResult> {\n const current = this.hooks.entry(operation.plan.sessionId);\n if (current?.entryId === operation.entry!.entryId) {\n await externalCall('Retirement entry commit failed', () => this.hooks.deleteEntry(current.sessionId));\n }\n return this.finish(operation, 'success', null);\n }\n private async finish(operation: PurgeOperation, status: 'success' | 'rejected' | 'conflict', reason: string | null): Promise<PurgeResult> {\n const result = purgeResultSchema.parse({ action: 'purge', operationId: operation.plan.operationId,\n sessionId: operation.plan.sessionId, entryId: operation.entry?.entryId ?? null,\n status, reason, ownerState: operation.ownerState });\n await this.store.putOperation({ ...operation, phase: 'done', result });\n return result;\n }\n}\n", "import { z } from 'zod';\nimport { blockerSchema, entrySchema } from './schema.js';\nimport { archiveEntrySchema } from './archive.js';\n\nconst key = z.string().min(1).max(1024);\nexport const lifecycleKeySchema = z.object({ storeId: key, sessionId: key, lifecycleId: key }).strict();\nexport const retirementParticipantSchema = z.object({ id: key, version: key }).strict();\nexport const retirementCapabilitiesSchema = z.object({\n protocolVersion: z.literal(1), ownerId: key, hostVersion: key, providerId: key, storeId: key,\n participants: z.array(retirementParticipantSchema).min(1).max(64),\n}).strict().superRefine((value, ctx) => {\n if (new Set(value.participants.map(item => item.id)).size !== value.participants.length) {\n ctx.addIssue({ code: 'custom', message: 'Participant identities must be unique.' });\n }\n});\nconst legacyRetirementBindingSchema = z.object({\n schemaVersion: z.literal(1), entryId: z.uuid(), entryVersion: z.literal(1),\n lifecycle: lifecycleKeySchema, capabilities: retirementCapabilitiesSchema,\n}).strict();\nconst nativeRetirementBindingSchema = z.object({\n schemaVersion: z.literal(2), target: z.literal('native-archive'), entryId: z.uuid(), entryVersion: z.literal(2),\n lifecycle: lifecycleKeySchema, capabilities: retirementCapabilitiesSchema,\n}).strict();\nexport const retirementBindingSchema = z.union([legacyRetirementBindingSchema, nativeRetirementBindingSchema]).superRefine((value, ctx) => {\n if (value.lifecycle.storeId !== value.capabilities.storeId) {\n ctx.addIssue({ code: 'custom', message: 'Binding store differs from its owner.' });\n }\n});\nexport const retirementResourceSchema = z.object({\n ownerId: key, resourceId: key, revision: key,\n kind: z.enum(['transcript', 'workspace', 'index', 'cache', 'attachment', 'spill', 'coordination']),\n disposition: z.enum(['erase', 'release-reference', 'retain-shared', 'retain-coordination']),\n retention: z.object({\n reason: z.enum(['shared-reference', 'coordination-identity']),\n retainedBy: z.array(lifecycleKeySchema).max(4096),\n }).strict().nullable(),\n}).strict();\nexport const retirementManifestSchema = z.object({\n schemaVersion: z.literal(1), lifecycle: lifecycleKeySchema,\n capabilities: retirementCapabilitiesSchema,\n resources: z.array(retirementResourceSchema).min(1).max(4096),\n}).strict().superRefine((value, ctx) => {\n const owners = new Set(value.capabilities.participants.map(item => item.id));\n const resourceKeys = value.resources.map(item => JSON.stringify([item.ownerId, item.resourceId]));\n if (new Set(resourceKeys).size !== resourceKeys.length || value.resources.some(item => !owners.has(item.ownerId))) {\n ctx.addIssue({ code: 'custom', message: 'Resources require unique keys and declared owners.' });\n }\n if (value.lifecycle.storeId !== value.capabilities.storeId\n || !value.resources.some(item => item.kind === 'transcript' && item.disposition === 'erase')) {\n ctx.addIssue({ code: 'custom', message: 'Manifest must identify its store and erase the target transcript.' });\n }\n for (const resource of value.resources) {\n if (resource.kind === 'coordination' && resource.disposition !== 'retain-coordination') {\n ctx.addIssue({ code: 'custom', message: 'Stable coordination identity must be retained.' });\n }\n const retained = resource.retention;\n if (resource.disposition === 'retain-shared') {\n if (!retained || retained.reason !== 'shared-reference' || !retained.retainedBy.length\n || retained.retainedBy.some(key => lifecycleEqual(key, value.lifecycle))\n || new Set(retained.retainedBy.map(key => JSON.stringify([key.storeId, key.sessionId, key.lifecycleId]))).size !== retained.retainedBy.length) {\n ctx.addIssue({ code: 'custom', message: 'Shared retention requires distinct surviving lifecycle witnesses.' });\n }\n } else if (resource.disposition === 'retain-coordination') {\n if (resource.kind !== 'coordination' || !retained || retained.reason !== 'coordination-identity' || retained.retainedBy.length) {\n ctx.addIssue({ code: 'custom', message: 'Coordination retention must state its identity purpose.' });\n }\n } else if (retained !== null) {\n ctx.addIssue({ code: 'custom', message: 'Erasure/reference release does not retain this resource.' });\n }\n }\n});\nexport const retirementRequestSchema = z.object({\n operationId: key, expected: lifecycleKeySchema,\n bin: z.union([\n z.object({ entryId: z.uuid(), entryVersion: z.literal(1) }).strict(),\n z.object({ kind: z.literal('native-archive'), entryId: z.uuid(), entryVersion: z.literal(2) }).strict(),\n ]),\n manifestDigest: z.string().regex(/^[a-f0-9]{64}$/),\n}).strict();\nexport const retirementResourceReceiptSchema = z.object({\n ownerId: key, resourceId: key,\n status: z.enum(['erased', 'reference-released', 'retained', 'failed']), reason: key.nullable(),\n}).strict().superRefine((value, ctx) => {\n if ((value.status === 'failed' || value.status === 'retained') !== (value.reason !== null)) {\n ctx.addIssue({ code: 'custom', message: 'Failure and retention require a reason; erased/released resources do not.' });\n }\n});\nexport const retirementAuthorizationSchema = z.discriminatedUnion('authorized', [\n z.object({ authorized: z.literal(true), authorizationId: z.uuid() }).strict(),\n z.object({ authorized: z.literal(false), reason: key }).strict(),\n]);\nexport const retirementStateSchema = z.object({\n schemaVersion: z.literal(1), request: retirementRequestSchema, manifest: retirementManifestSchema,\n authorizationId: z.uuid().nullable(),\n phase: z.enum(['rejected', 'conflict', 'fenced', 'quiesced', 'erasing', 'converging', 'done']),\n reason: key.nullable(), resources: z.array(retirementResourceReceiptSchema).max(4096),\n}).strict().superRefine((value, ctx) => {\n if (!lifecycleEqual(value.request.expected, value.manifest.lifecycle)) {\n ctx.addIssue({ code: 'custom', message: 'Owner state changed the requested lifecycle.' });\n }\n const refused = value.phase === 'rejected' || value.phase === 'conflict';\n if (refused !== (value.authorizationId === null)) {\n ctx.addIssue({ code: 'custom', message: 'Admitted owner state requires its handed-off authorization grant.' });\n }\n if (refused !== (value.reason !== null)) {\n ctx.addIssue({ code: 'custom', message: 'Admission refusal requires a reason.' });\n }\n const keys = value.resources.map(item => JSON.stringify([item.ownerId, item.resourceId]));\n if (new Set(keys).size !== keys.length) ctx.addIssue({ code: 'custom', message: 'Duplicate resource receipts.' });\n for (const receipt of value.resources) {\n const resource = value.manifest.resources.find(item => item.ownerId === receipt.ownerId && item.resourceId === receipt.resourceId);\n if (!resource) ctx.addIssue({ code: 'custom', message: 'Receipt is outside the frozen manifest.' });\n if (resource && receipt.status !== 'failed') {\n const expected = resource.disposition === 'erase' ? 'erased'\n : resource.disposition === 'release-reference' ? 'reference-released' : 'retained';\n if (receipt.status !== expected || (receipt.status === 'retained' && receipt.reason !== resource.retention?.reason)) {\n ctx.addIssue({ code: 'custom', message: 'Resource acknowledgement did not satisfy its frozen disposition and retention reason.' });\n }\n }\n }\n if (value.phase === 'done' && (value.resources.length !== value.manifest.resources.length\n || value.resources.some(receipt => receipt.status === 'failed'))) {\n ctx.addIssue({ code: 'custom', message: 'Completion requires every resource receipt without failures.' });\n }\n if (['rejected', 'conflict', 'fenced', 'quiesced'].includes(value.phase) && value.resources.length) {\n ctx.addIssue({ code: 'custom', message: 'Admission and quiescence phases cannot include resource erasure effects.' });\n }\n});\nexport const preparePurgeRequestSchema = z.object({ sessionId: key, operationId: key.optional() }).strict();\nexport const purgePlanSchema = z.object({\n schemaVersion: z.union([z.literal(1), z.literal(2)]), action: z.literal('purge'), operationId: key, sessionId: key,\n expectedEntryId: z.uuid().nullable(), binding: retirementBindingSchema.nullable(),\n manifest: retirementManifestSchema.nullable(), blockers: z.array(blockerSchema),\n}).strict().superRefine((value, ctx) => {\n if (value.binding && value.binding.schemaVersion !== value.schemaVersion) {\n ctx.addIssue({ code: 'custom', message: 'Legacy Bin and native archive deletion bindings cannot be interchanged.' });\n }\n if (value.binding && (value.binding.entryId !== value.expectedEntryId || value.binding.lifecycle.sessionId !== value.sessionId)) {\n ctx.addIssue({ code: 'custom', message: 'Purge binding differs from its target entry.' });\n }\n if (value.manifest && (!value.binding || !lifecycleEqual(value.binding.lifecycle, value.manifest.lifecycle))) {\n ctx.addIssue({ code: 'custom', message: 'Purge manifest differs from its bound lifecycle.' });\n }\n});\nexport const purgeResultSchema = z.object({\n action: z.literal('purge'), operationId: key, sessionId: key, entryId: z.uuid().nullable(),\n status: z.enum(['success', 'rejected', 'conflict', 'pending-recovery', 'partial-failure']), reason: key.nullable(),\n ownerState: retirementStateSchema.nullable(),\n}).strict().superRefine((value, ctx) => {\n if ((value.status === 'success') !== (value.reason === null)\n || (value.status === 'success' && value.ownerState?.phase !== 'done')) {\n ctx.addIssue({ code: 'custom', message: 'Success requires a complete owner receipt.' });\n }\n if (value.ownerState && (value.ownerState.request.operationId !== value.operationId\n || value.ownerState.request.expected.sessionId !== value.sessionId\n || value.ownerState.request.bin.entryId !== value.entryId)) {\n ctx.addIssue({ code: 'custom', message: 'Purge result differs from its owner receipt.' });\n }\n});\nexport const purgeOperationSchema = z.object({\n schemaVersion: z.union([z.literal(1), z.literal(2)]), plan: purgePlanSchema, createdAt: z.iso.datetime(),\n phase: z.enum(['intent', 'authorizing', 'owner-pending', 'done']), entry: z.union([entrySchema, archiveEntrySchema]).nullable(),\n authorizationId: z.uuid().nullable(),\n ownerState: retirementStateSchema.nullable(), result: purgeResultSchema.nullable(),\n}).strict().superRefine((value, ctx) => {\n const { plan, entry, result, ownerState } = value;\n if (value.schemaVersion !== plan.schemaVersion || (entry && entry.schemaVersion !== plan.schemaVersion)\n || (ownerState && ownerState.request.bin.entryVersion !== plan.schemaVersion)) {\n ctx.addIssue({ code: 'custom', message: 'Deletion journal target versions must agree.' });\n }\n if (entry && (entry.entryId !== plan.expectedEntryId || entry.sessionId !== plan.sessionId)) {\n ctx.addIssue({ code: 'custom', message: 'Purge journal entry differs from the plan.' });\n }\n if (value.phase !== 'done' && (!entry || !plan.binding || !plan.manifest)) {\n ctx.addIssue({ code: 'custom', message: 'Unfinished purge requires an entry, binding and manifest.' });\n }\n const terminalResult = result && ['success', 'rejected', 'conflict'].includes(result.status);\n if ((value.phase === 'done') !== Boolean(terminalResult)\n || (['intent', 'authorizing'].includes(value.phase) && (ownerState !== null || result !== null))\n || (value.phase === 'intent' && value.authorizationId !== null)\n || (value.phase === 'authorizing' && value.authorizationId === null)\n || (ownerState && ownerState.authorizationId !== null && ownerState.authorizationId !== value.authorizationId)\n || (value.phase === 'owner-pending' && (ownerState === null || result === null))) {\n ctx.addIssue({ code: 'custom', message: 'Purge journal phase and receipt are inconsistent.' });\n }\n if (result && (result.operationId !== plan.operationId || result.sessionId !== plan.sessionId\n || result.entryId !== (entry?.entryId ?? null) || JSON.stringify(result.ownerState) !== JSON.stringify(ownerState))) {\n ctx.addIssue({ code: 'custom', message: 'Purge journal result differs from its saved state.' });\n }\n});\n\nexport type LifecycleKey = z.infer<typeof lifecycleKeySchema>;\nexport type RetirementCapabilities = z.infer<typeof retirementCapabilitiesSchema>;\nexport type RetirementBinding = z.infer<typeof retirementBindingSchema>;\nexport type RetirementManifest = z.infer<typeof retirementManifestSchema>;\nexport type RetirementRequest = z.infer<typeof retirementRequestSchema>;\nexport type RetirementAuthorization = z.infer<typeof retirementAuthorizationSchema>;\nexport type RetirementState = z.infer<typeof retirementStateSchema>;\nexport type PurgePlan = z.infer<typeof purgePlanSchema>;\nexport type PurgeResult = z.infer<typeof purgeResultSchema>;\nexport type PurgeOperation = z.infer<typeof purgeOperationSchema>;\nexport type PreparePurgeRequest = z.infer<typeof preparePurgeRequestSchema>;\nexport function lifecycleEqual(a: LifecycleKey, b: LifecycleKey): boolean {\n return a.storeId === b.storeId && a.sessionId === b.sessionId && a.lifecycleId === b.lifecycleId;\n}\n", "import { z } from 'zod';\nimport { blockerSchema } from './schema.js';\n\nconst identity = z.string().min(1).max(1024);\nexport const archiveEntrySchema = z.object({\n schemaVersion: z.literal(2), sessionId: identity, entryId: z.uuid(),\n}).strict();\nexport const archivePlanSchema = z.object({\n schemaVersion: z.literal(2), operationId: identity, action: z.literal('unarchive'), sessionId: identity,\n expected: z.object({ archived: z.boolean(), entryId: z.uuid().nullable() }).strict(),\n blockers: z.array(blockerSchema),\n}).strict();\nexport const archiveResultSchema = z.object({\n operationId: identity, action: z.literal('unarchive'), sessionId: identity,\n status: z.enum(['success', 'rejected', 'conflict']), reason: z.string().min(1).nullable(), entryId: z.uuid().nullable(),\n}).strict();\nexport const archiveOperationSchema = z.object({\n schemaVersion: z.literal(2), plan: archivePlanSchema, createdAt: z.iso.datetime(),\n phase: z.enum(['intent', 'applied', 'done']), entry: archiveEntrySchema.nullable(), result: archiveResultSchema.nullable(),\n}).strict().superRefine(({ plan, entry, result, phase }, ctx) => {\n if ((phase === 'done') !== (result !== null) || (phase !== 'done' && (entry === null || !plan.expected.archived))) {\n ctx.addIssue({ code: 'custom', message: 'Only done operations have results; unfinished operations require an entry.' });\n }\n if (entry && (entry.sessionId !== plan.sessionId || entry.entryId !== plan.expected.entryId)) {\n ctx.addIssue({ code: 'custom', message: 'Entry snapshot does not match the plan.' });\n }\n if (result && (result.operationId !== plan.operationId || result.sessionId !== plan.sessionId\n || result.action !== plan.action || result.entryId !== (entry?.entryId ?? null)\n || (result.status === 'success') !== (result.reason === null) || (result.status === 'success' && !entry))) {\n ctx.addIssue({ code: 'custom', message: 'Result does not match the operation.' });\n }\n});\nexport const archivePrepareRequestSchema = z.object({\n action: z.literal('unarchive'), sessionId: identity, operationId: identity.optional(),\n}).strict();\nexport type ArchiveEntry = z.infer<typeof archiveEntrySchema>;\nexport type ArchivePlan = z.infer<typeof archivePlanSchema>;\nexport type ArchiveResult = z.infer<typeof archiveResultSchema>;\nexport type ArchiveOperation = z.infer<typeof archiveOperationSchema>;\nexport type ArchivePrepareRequest = z.infer<typeof archivePrepareRequestSchema>;\n", "import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';\nimport type { Domain } from '@deepseek-ai/dsh-storage-domain';\nimport { archiveEntrySchema, archiveOperationSchema } from '../operations/archive.js';\nimport type { ArchiveEntry, ArchiveOperation } from '../operations/archive.js';\nimport { entrySchema, operationSchema } from '../operations/schema.js';\nimport type { BinEntry, BinOperation } from '../operations/schema.js';\n\nexport const binDomainSpec = defineDomain({\n name: 'session_bin',\n version: 1,\n layout: 'single',\n tables: {\n entries: domainTable(entrySchema),\n operations: domainTable(operationSchema),\n },\n} as const);\n\nexport interface BinStore {\n entries(): BinEntry[];\n operations(): BinOperation[];\n entry(sessionId: string): BinEntry | undefined;\n operation(operationId: string): BinOperation | undefined;\n putEntry(entry: BinEntry): Promise<void>;\n deleteEntry(sessionId: string): Promise<void>;\n putOperation(operation: BinOperation): Promise<void>;\n close(): Promise<void>;\n}\n\n// Domain.put/update do not validate in the pinned SDK. Keep the handle private;\n// parse synchronously before enqueuing, and return independent read snapshots.\nexport class DomainBinStore implements BinStore {\n constructor(private readonly domain: Domain<typeof binDomainSpec>) {\n for (const [key, entry] of domain.table('entries').entries()) {\n if (key !== entry.sessionId) throw new Error('Bin entry key does not match its session.');\n const owner = domain.table('operations').get(entry.operationId);\n if (!owner || owner.plan.action !== 'bin' || owner.entry?.entryId !== entry.entryId\n || owner.entry.sessionId !== entry.sessionId) {\n throw new Error('Bin entry has no matching ownership journal.');\n }\n }\n for (const [key, operation] of domain.table('operations').entries()) {\n if (key !== operation.plan.operationId) throw new Error('Bin operation key does not match its identity.');\n }\n }\n entries(): BinEntry[] {\n return [...this.domain.table('entries').entries()].map(([, value]) => entrySchema.parse(value));\n }\n operations(): BinOperation[] {\n return [...this.domain.table('operations').entries()].map(([, value]) => operationSchema.parse(value));\n }\n entry(sessionId: string): BinEntry | undefined {\n const value = this.domain.table('entries').get(sessionId);\n return value === undefined ? undefined : entrySchema.parse(value);\n }\n operation(operationId: string): BinOperation | undefined {\n const value = this.domain.table('operations').get(operationId);\n return value === undefined ? undefined : operationSchema.parse(value);\n }\n putEntry(value: BinEntry): Promise<void> {\n const snapshot = entrySchema.parse(value);\n return this.domain.table('entries').put(snapshot.sessionId, snapshot);\n }\n async deleteEntry(sessionId: string): Promise<void> {\n await this.domain.table('entries').delete(sessionId);\n }\n putOperation(value: BinOperation): Promise<void> {\n const snapshot = operationSchema.parse(value);\n return this.domain.table('operations').put(snapshot.plan.operationId, snapshot);\n }\n close(): Promise<void> { return this.domain.close(); }\n}\n\n/** Observation identities live apart from the immutable v1 ownership journal. */\nexport const archiveDomainSpec = defineDomain({\n name: 'session_archive', version: 1, layout: 'single',\n tables: { entries: domainTable(archiveEntrySchema), operations: domainTable(archiveOperationSchema) },\n} as const);\nexport interface ArchiveStore {\n entries(): ArchiveEntry[];\n entry(sessionId: string): ArchiveEntry | undefined;\n operations(): ArchiveOperation[];\n operation(operationId: string): ArchiveOperation | undefined;\n putEntry(entry: ArchiveEntry): Promise<void>;\n deleteEntry(sessionId: string): Promise<void>;\n putOperation(operation: ArchiveOperation): Promise<void>;\n close(): Promise<void>;\n}\nexport class DomainArchiveStore implements ArchiveStore {\n constructor(private readonly domain: Domain<typeof archiveDomainSpec>) {\n for (const [key, entry] of domain.table('entries').entries()) {\n if (key !== entry.sessionId) throw new Error('Archive entry key does not match its session.');\n }\n for (const [key, operation] of domain.table('operations').entries()) {\n if (key !== operation.plan.operationId) throw new Error('Archive operation key does not match its identity.');\n }\n }\n entries() { return [...this.domain.table('entries').entries()].map(([, value]) => archiveEntrySchema.parse(value)); }\n entry(sessionId: string) {\n const value = this.domain.table('entries').get(sessionId);\n return value === undefined ? undefined : archiveEntrySchema.parse(value);\n }\n operations() { return [...this.domain.table('operations').entries()].map(([, value]) => archiveOperationSchema.parse(value)); }\n operation(operationId: string) {\n const value = this.domain.table('operations').get(operationId);\n return value === undefined ? undefined : archiveOperationSchema.parse(value);\n }\n putEntry(value: ArchiveEntry) {\n const snapshot = archiveEntrySchema.parse(value);\n return this.domain.table('entries').put(snapshot.sessionId, snapshot);\n }\n async deleteEntry(sessionId: string) { await this.domain.table('entries').delete(sessionId); }\n putOperation(value: ArchiveOperation) {\n const snapshot = archiveOperationSchema.parse(value);\n return this.domain.table('operations').put(snapshot.plan.operationId, snapshot);\n }\n close() { return this.domain.close(); }\n}\n", "import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';\nimport type { Domain } from '@deepseek-ai/dsh-storage-domain';\nimport { purgeOperationSchema, retirementBindingSchema } from '../operations/retirement.js';\nimport type { PurgeOperation, RetirementBinding } from '../operations/retirement.js';\n\n/** Separate sidecar accepts unchanged legacy v1 records and explicitly tagged native v2 records.\n * Its storage domain version stays 1; no automatic data migration or native mutation. */\nexport const retirementDomainSpec = defineDomain({\n name: 'session_bin_purge', version: 1, layout: 'single',\n tables: { bindings: domainTable(retirementBindingSchema), operations: domainTable(purgeOperationSchema) },\n} as const);\nexport interface RetirementStore {\n binding(entryId: string): RetirementBinding | undefined;\n putBinding(binding: RetirementBinding): Promise<void>;\n operation(operationId: string): PurgeOperation | undefined;\n operations(): PurgeOperation[];\n putOperation(operation: PurgeOperation): Promise<void>;\n close(): Promise<void>;\n}\nexport class DomainRetirementStore implements RetirementStore {\n constructor(private readonly domain: Domain<typeof retirementDomainSpec>) {\n for (const [key, value] of domain.table('bindings').entries()) {\n if (key !== value.entryId) throw new Error('Retirement binding key differs from its entry.');\n }\n for (const [key, value] of domain.table('operations').entries()) {\n if (key !== value.plan.operationId) throw new Error('Retirement operation key differs from its request.');\n }\n }\n binding(entryId: string): RetirementBinding | undefined {\n const value = this.domain.table('bindings').get(entryId);\n return value === undefined ? undefined : retirementBindingSchema.parse(value);\n }\n putBinding(value: RetirementBinding): Promise<void> {\n const snapshot = retirementBindingSchema.parse(value);\n const existing = this.binding(snapshot.entryId);\n if (existing && JSON.stringify(existing) !== JSON.stringify(snapshot)) {\n throw new Error('An immutable entry lifecycle binding cannot be replaced.');\n }\n return this.domain.table('bindings').put(snapshot.entryId, snapshot);\n }\n operation(operationId: string): PurgeOperation | undefined {\n const value = this.domain.table('operations').get(operationId);\n return value === undefined ? undefined : purgeOperationSchema.parse(value);\n }\n operations(): PurgeOperation[] {\n return [...this.domain.table('operations').entries()].map(([, value]) => purgeOperationSchema.parse(value));\n }\n putOperation(value: PurgeOperation): Promise<void> {\n const snapshot = purgeOperationSchema.parse(value);\n return this.domain.table('operations').put(snapshot.plan.operationId, snapshot);\n }\n close(): Promise<void> { return this.domain.close(); }\n}\n", "import { randomUUID } from 'node:crypto';\nimport { archiveEntrySchema, archivePlanSchema, archivePrepareRequestSchema, archiveResultSchema } from '../operations/archive.js';\nimport type { ArchiveEntry, ArchiveOperation, ArchivePlan, ArchivePrepareRequest, ArchiveResult } from '../operations/archive.js';\nimport type { BinBlocker } from '../operations/schema.js';\nimport type { ArchiveStore } from './store.js';\nimport { SessionBinError, sessionBinRefusal, isSessionBinRefusal } from './module.js';\nimport type { NativeSessionState } from './module.js';\nimport { SessionBinPurgeModule } from './retirement.js';\nimport type { RetirementOptions, PurgeReconcileReport } from './retirement.js';\nimport { preparePurgeRequestSchema, purgePlanSchema } from '../operations/retirement.js';\nimport type { PreparePurgeRequest, PurgePlan } from '../operations/retirement.js';\n\nexport interface NativeArchivePort {\n archivedSessionIds(): readonly string[];\n inspect(sessionId: string): Promise<NativeSessionState>;\n activity?(sessionId: string): Promise<string[]>;\n unarchive(sessionId: string): Promise<void>;\n}\nexport interface ArchiveOptions {\n retirement?: RetirementOptions;\n operationIdClaimed?: (operationId: string) => boolean;\n pendingPurge?: (sessionId: string) => boolean;\n reconcileLegacy?: () => Promise<unknown>;\n reconcileLegacyPurge?: () => Promise<PurgeReconcileReport>;\n}\n\n/** Native archive membership, with durable observation identities, never deletion grants. */\nexport class ArchiveModule {\n private tail: Promise<unknown> = Promise.resolve();\n private closing = false;\n private failed = false;\n private failure: unknown;\n private closePromise: Promise<void> | undefined;\n private readonly invalidated = new Set<string>();\n private readonly rearchived = new Set<string>();\n // Track allocated identities before put settles so a frame cannot miss them.\n private readonly identities = new Map<string, ArchiveEntry>();\n private readonly purge: SessionBinPurgeModule | undefined;\n constructor(private readonly store: ArchiveStore, private readonly native: NativeArchivePort,\n private readonly options: ArchiveOptions = {}) {\n this.purge = options.retirement ? new SessionBinPurgeModule({ ...options.retirement,\n verified: caps => options.retirement!.verifiedNativeArchive?.(caps) === true }, {\n target: 'native-archive', entry: id => store.entry(id), invalidated: id => this.invalidated.has(id),\n archived: async id => native.archivedSessionIds().includes(id),\n activity: id => {\n if (!native.activity) throw new Error('Native retirement requires an activity port.');\n return native.activity(id);\n },\n deleteEntry: id => store.deleteEntry(id),\n hasArchiveOperation: id => store.operation(id) !== undefined || options.operationIdClaimed?.(id) === true,\n hasPendingArchiveOperation: id => store.operations().some(item => item.phase !== 'done' && item.plan.sessionId === id),\n }) : undefined;\n for (const entry of store.entries()) this.identities.set(entry.entryId, entry);\n for (const operation of store.operations()) {\n this.checkClaim(operation.plan.operationId);\n if (operation.phase !== 'done' && operation.entry) this.identities.set(operation.entry.entryId, operation.entry);\n }\n }\n\n prepare(request: ArchivePrepareRequest): Promise<ArchivePlan> {\n const input = archivePrepareRequestSchema.parse(request);\n return this.enqueue(async () => {\n await this.reconcileInner();\n const state = await this.native.inspect(input.sessionId);\n await this.syncEntries();\n const entry = this.store.entry(input.sessionId);\n const plan: ArchivePlan = {\n schemaVersion: 2, operationId: input.operationId ?? randomUUID(), action: 'unarchive', sessionId: input.sessionId,\n expected: { archived: state.archived, entryId: entry?.entryId ?? null }, blockers: [],\n };\n this.checkClaim(plan.operationId);\n plan.blockers = this.blockers(plan, state, entry);\n return archivePlanSchema.parse(plan);\n });\n }\n\n execute(input: ArchivePlan): Promise<ArchiveResult> {\n const plan = archivePlanSchema.parse(input);\n return this.enqueue(async () => {\n this.checkClaim(plan.operationId);\n const previous = this.store.operation(plan.operationId);\n if (previous && !this.sameRequest(previous.plan, plan)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to a different request.');\n }\n if (previous?.result) return archiveResultSchema.parse(previous.result);\n await this.reconcileInner();\n const recovered = this.store.operation(plan.operationId);\n if (recovered?.result) return archiveResultSchema.parse(recovered.result);\n const state = await this.native.inspect(plan.sessionId);\n await this.syncEntries();\n const entry = this.store.entry(plan.sessionId);\n const operation: ArchiveOperation = {\n schemaVersion: 2, plan, createdAt: new Date().toISOString(), phase: 'done',\n entry: entry?.entryId === plan.expected.entryId ? entry : null, result: null,\n };\n if (this.stale(plan, state, entry)) return this.finish(operation, 'conflict', 'state-changed');\n const blockers = this.blockers(plan, state, entry);\n if (blockers.length) return this.finish(operation, 'rejected', blockers[0]!.code);\n const intent: ArchiveOperation = { ...operation, phase: 'intent' };\n await this.store.putOperation(intent);\n // The intent and existence inspection yield. Capture invalidation outside\n // this queue, then inspect the current member/identity immediately at admission.\n const fresh = await this.native.inspect(plan.sessionId);\n if (this.stale(plan, fresh, this.store.entry(plan.sessionId))) return this.finish(intent, 'conflict', 'state-changed');\n const freshBlockers = this.blockers(plan, fresh, this.store.entry(plan.sessionId));\n if (freshBlockers.length) return this.finish(intent, 'rejected', freshBlockers[0]!.code);\n await this.native.unarchive(plan.sessionId);\n const applied: ArchiveOperation = { ...intent, phase: 'applied' };\n await this.store.putOperation(applied);\n return this.finalize(applied);\n });\n }\n\n preparePurge(request: PreparePurgeRequest) {\n const input = preparePurgeRequestSchema.parse(request);\n return this.enqueue(async () => { await this.reconcileInner(); return this.requirePurge().prepare(input); });\n }\n executePurge(input: PurgePlan) {\n const plan = purgePlanSchema.parse(input);\n return this.enqueue(() => this.requirePurge().execute(plan));\n }\n getPurgeOperation(id: string) { return this.enqueue(async () => this.requirePurge().operation(id)); }\n purgeOperations() { return this.enqueue(async () => this.requirePurge().operations()); }\n reconcilePurge() {\n return this.enqueue(async () => {\n const legacy = await this.options.reconcileLegacyPurge?.();\n const native = await this.requirePurge().reconcile(true);\n return { completed: [...(legacy?.completed ?? []), ...native.completed], pending: [...(legacy?.pending ?? []), ...native.pending] };\n });\n }\n private requirePurge() {\n if (!this.purge) throw sessionBinRefusal('bin/permanent-deletion-unsupported', 'No retirement journal/owner is composed.');\n return this.purge;\n }\n compatibility<T>(work: () => Promise<T>): Promise<T> { return this.enqueue(work); }\n list(): Promise<ArchiveEntry[]> {\n return this.enqueue(async () => {\n await this.reconcileInner();\n return this.store.entries().filter(entry => this.native.archivedSessionIds().includes(entry.sessionId));\n });\n }\n getOperation(operationId: string): Promise<ArchiveOperation | undefined> {\n return this.enqueue(async () => this.store.operation(operationId));\n }\n operations(): Promise<ArchiveOperation[]> {\n return this.enqueue(async () => { await this.reconcileInner(); return this.store.operations(); });\n }\n reconcile(): Promise<void> {\n return this.enqueue(async () => {\n await this.options.reconcileLegacyPurge?.();\n await this.purge?.reconcile(true); await this.reconcileInner();\n });\n }\n observeArchives(ids: readonly string[]): Promise<void> {\n if (this.failed) return Promise.reject(this.unavailable());\n const members = new Set(ids);\n for (const entry of this.identities.values()) {\n if (!members.has(entry.sessionId)) this.invalidated.add(entry.entryId);\n else if (this.invalidated.has(entry.entryId)) this.rearchived.add(entry.entryId);\n }\n return this.closing ? Promise.resolve() : this.enqueue(() => this.reconcileInner());\n }\n close(): Promise<void> {\n this.closing = true;\n return this.closePromise ??= this.tail.then(async () => {\n try { if (!this.failed) await this.reconcileInner(); }\n finally {\n try { await this.purge?.close(); }\n finally { await this.store.close(); }\n }\n });\n }\n\n private checkClaim(operationId: string) {\n if (this.purge?.operation(operationId) || this.options.operationIdClaimed?.(operationId)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to a legacy or purge request.');\n }\n }\n private sameRequest(a: ArchivePlan, b: ArchivePlan) {\n return a.sessionId === b.sessionId && a.action === b.action\n && a.expected.archived === b.expected.archived && a.expected.entryId === b.expected.entryId;\n }\n private stale(plan: ArchivePlan, state: NativeSessionState, entry: ArchiveEntry | undefined) {\n return state.archived !== plan.expected.archived\n || this.native.archivedSessionIds().includes(plan.sessionId) !== plan.expected.archived\n || (entry?.entryId ?? null) !== plan.expected.entryId\n || (entry !== undefined && this.invalidated.has(entry.entryId));\n }\n private blockers(plan: ArchivePlan, state: NativeSessionState, entry: ArchiveEntry | undefined): BinBlocker[] {\n const blockers: BinBlocker[] = [];\n if (this.purge?.blocks(plan.sessionId) || this.options.pendingPurge?.(plan.sessionId)) blockers.push({ code: 'pending-deletion' });\n if (!state.known) blockers.push({ code: 'session-not-found' });\n if (!state.archived || !entry || this.invalidated.has(entry.entryId)) blockers.push({ code: 'not-archived' });\n if (this.store.operations().some(item => item.phase !== 'done' && item.plan.sessionId === plan.sessionId\n && item.plan.operationId !== plan.operationId)) blockers.push({ code: 'pending-operation' });\n return blockers;\n }\n private async finish(operation: ArchiveOperation, status: ArchiveResult['status'], reason: string | null) {\n const result = archiveResultSchema.parse({ operationId: operation.plan.operationId, action: 'unarchive',\n sessionId: operation.plan.sessionId, status, reason, entryId: operation.entry?.entryId ?? null });\n await this.store.putOperation({ ...operation, phase: 'done', result });\n return archiveResultSchema.parse(result);\n }\n private async finalize(operation: ArchiveOperation) {\n const state = await this.native.inspect(operation.plan.sessionId);\n if (state.archived || this.native.archivedSessionIds().includes(operation.plan.sessionId)\n || (operation.entry && this.rearchived.has(operation.entry.entryId))) {\n return this.finish(operation, 'conflict', 'archive-changed');\n }\n if (!state.known) return this.finish(operation, 'conflict', 'session-not-found');\n const current = this.store.entry(operation.plan.sessionId);\n if (current && current.entryId !== operation.entry?.entryId) return this.finish(operation, 'conflict', 'entry-changed');\n if (current) await this.store.deleteEntry(current.sessionId);\n return this.finish(operation, 'success', null);\n }\n private async reconcileInner(): Promise<void> {\n await this.options.reconcileLegacy?.();\n await this.purge?.reconcile(false);\n for (const operation of this.store.operations()) {\n if (operation.phase === 'done') continue;\n if (operation.phase === 'applied') await this.finalize(operation);\n else await this.finish(operation, 'conflict', 'interrupted');\n }\n await this.syncEntries();\n }\n private async syncEntries(): Promise<void> {\n // Re-read after every yielded write. A list is a complete current native\n // set even when another archive/unarchive happens during a slow sidecar put.\n while (true) {\n const before = new Set(this.native.archivedSessionIds());\n for (const entry of this.store.entries()) {\n if (this.purge?.ownsPendingEntry(entry.entryId)) continue;\n if (this.invalidated.has(entry.entryId) || !before.has(entry.sessionId)) {\n await this.store.deleteEntry(entry.sessionId);\n }\n }\n for (const sessionId of this.native.archivedSessionIds()) {\n const current = this.store.entry(sessionId);\n if (this.purge?.blocksTarget(sessionId)) continue;\n if (!current || this.invalidated.has(current.entryId)) {\n const entry = archiveEntrySchema.parse({ schemaVersion: 2, sessionId, entryId: randomUUID() });\n this.identities.set(entry.entryId, entry);\n await this.store.putEntry(entry);\n }\n }\n const members = new Set(this.native.archivedSessionIds());\n const entries = this.store.entries().filter(entry => !this.purge?.blocksTarget(entry.sessionId));\n const ordinary = [...members].filter(id => !this.purge?.blocksTarget(id));\n if (entries.length === ordinary.length && entries.every(entry => members.has(entry.sessionId)\n && !this.invalidated.has(entry.entryId))) break;\n }\n const retained = new Set(this.store.entries().map(entry => entry.entryId));\n for (const operation of this.store.operations()) {\n if (operation.phase !== 'done' && operation.entry) retained.add(operation.entry.entryId);\n }\n for (const entryId of this.identities.keys()) {\n if (retained.has(entryId)) continue;\n this.identities.delete(entryId);\n this.invalidated.delete(entryId);\n this.rearchived.delete(entryId);\n }\n }\n private unavailable() {\n return new SessionBinError(this.failed ? 'bin/recovery-required' : 'bin/closed',\n this.failed ? 'Close and reopen the archive service after an unexpected failure.' : 'Archive service is closing.',\n this.failed ? { cause: this.failure } : undefined);\n }\n private enqueue<T>(work: () => Promise<T>): Promise<T> {\n if (this.closing || this.failed) return Promise.reject(this.unavailable());\n const result = this.tail.then(async () => {\n if (this.failed) throw this.unavailable();\n try { return await work(); }\n catch (error) {\n if (!isSessionBinRefusal(error)) {\n this.failed = true; this.failure = error;\n }\n throw error;\n }\n });\n this.tail = result.then(() => undefined, () => undefined);\n return result;\n }\n}\n", "import { createHash, randomUUID } from 'node:crypto';\nimport { createRequire } from 'node:module';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type { Context } from '@deepseek-ai/cordis';\nimport { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';\nimport type { Domain } from '@deepseek-ai/dsh-storage-domain';\nimport { SessionId } from '@deepseek-ai/dsh-session';\nimport { z } from 'zod';\nimport { nativePlatformCandidate, nativePlatformVerified } from './platform-files.js';\nimport { legacyDurableHostContract, nativeRetirementSdkFingerprint } from './native-retirement-sdk.js';\nimport { NativeJsonlFiles, NativeJsonlRefusal, nativeJsonlInventorySchema } from './native-jsonl-files.js';\nimport type { NativeJsonlInventory } from './native-jsonl-files.js';\nimport { NativeMetadataAdapter, NativeMetadataRefusal, nativeMetadataSnapshotSchema } from './native-retirement-metadata.js';\nimport type { NativeMetadataSnapshot } from './native-retirement-metadata.js';\nimport { NativeAdmission, NativeAdmissionError } from './native-retirement-admission.js';\nimport { NativePersistenceAdapter, nativeServiceInstance } from './native-retirement-persistence.js';\nimport { RetirementOwnerCoordinator, RetirementOwnerError } from './retirement-owner.js';\nimport type { RetirementLifecycleScope, RetirementResourceParticipant, RetirementOwnerCoordinatorOptions } from './retirement-owner.js';\nimport { DomainRetirementOwnerStore, retirementOwnerDomainSpec } from './retirement-owner-store.js';\nimport type { RetirementOwnerStore } from './retirement-owner-store.js';\nimport { lifecycleKeySchema, lifecycleEqual, retirementCapabilitiesSchema } from '../operations/retirement.js';\nimport type { LifecycleKey, RetirementCapabilities, RetirementManifest, RetirementRequest, RetirementAuthorization, RetirementState } from '../operations/retirement.js';\nimport { retirementOwnerRefusal, isRetirementOwnerRefusal } from './retirement.js';\nimport type { SessionRetirementOwnerV1 } from './retirement.js';\nimport type { RetirementOwnerRecord } from '../operations/retirement-owner.js';\n\nconst nativeOwnerRegistry = Symbol.for('dsh-session-bin.native-retirement-owner');\ntype GuardRegistration = { owner: NativeRetirementOwner; root: string; fingerprint: string; storeId: string };\n\nconst witnessSchema = z.object({ schemaVersion: z.literal(1), lifecycle: lifecycleKeySchema,\n inventory: nativeJsonlInventorySchema, metadata: nativeMetadataSnapshotSchema }).strict().superRefine((value, ctx) => {\n if (value.lifecycle.sessionId !== value.inventory.sessionId || value.lifecycle.sessionId !== value.metadata.sessionId) {\n ctx.addIssue({ code: 'custom', message: 'Native witness resources differ from its exact lifecycle.' });\n }\n});\nexport const nativeRetirementDomainSpec = defineDomain({ name: 'session_bin_jsonl_resources', version: 1, layout: 'single',\n global: { schema: z.object({ schemaVersion: z.literal(1), storeId: z.uuid().nullable(), root: z.string().nullable(), fingerprint: z.string().nullable() }).strict(),\n initial: { schemaVersion: 1, storeId: null, root: null, fingerprint: null } },\n tables: { witnesses: domainTable(witnessSchema) } } as const);\nexport const nativeRetirementOwnerDomainSpec = defineDomain({ ...retirementOwnerDomainSpec, name: 'session_bin_jsonl_retirement_owner' } as const);\ntype Witness = z.infer<typeof witnessSchema>;\ntype Scope = { witness: Witness; inventory: NativeJsonlInventory; metadata: NativeMetadataSnapshot;\n blocked: string | null; lease: { release(): Promise<void> } | undefined; releaseAdmission: () => void };\n\nconst hash = (value: unknown) => createHash('sha256').update(JSON.stringify(value)).digest('hex');\nconst metadataRevision = (value: NativeMetadataSnapshot) => hash({ sessionId: value.sessionId, global: value.global,\n workspaces: value.workspaces.map(item => ({ workspaceId: item.workspaceId, path: item.record.path })).sort((a, b) => a.workspaceId.localeCompare(b.workspaceId)),\n cache: value.cache, queryProvider: value.queryProvider, queryPath: value.queryPath });\nconst equal = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b);\nfunction known(error: unknown): string | null {\n if (error instanceof NativeJsonlRefusal || error instanceof NativeMetadataRefusal) return error.code;\n if (error instanceof NativeAdmissionError) return 'native/session-busy';\n return null;\n}\nexport interface NativeRetirementOptions {\n /** Independent composition qualification, used by isolated candidate-platform fixtures.\n * The production Service never takes this callback from Host configuration. */\n platformQualification?: (runtime: { platform: NodeJS.Platform; arch: string; node: string }) => boolean;\n checkpoint?: RetirementOwnerCoordinatorOptions['checkpoint'];\n canAdvance?: RetirementOwnerCoordinatorOptions['canAdvance'];\n}\n\n/** Actual native log erasure, limited to the audited cold JSONL/Workspace composition. */\nexport class NativeRetirementOwner implements SessionRetirementOwnerV1 {\n private readonly scopes = new Map<string, Scope>();\n private readonly coordinator: RetirementOwnerCoordinator;\n private readonly descriptor: RetirementCapabilities;\n private readonly provider: NativePersistenceAdapter;\n private readonly originalProvider: object;\n private readonly restore: Array<() => Promise<void>> = [];\n private readonly observations = new Set<Promise<unknown>>();\n private fullyClosed = false;\n private observationsClosed = false;\n private closing: Promise<void> | undefined;\n\n private constructor(private readonly ctx: Context, private readonly files: NativeJsonlFiles,\n private readonly metadata: NativeMetadataAdapter, private readonly admission: NativeAdmission,\n private readonly domain: Domain<typeof nativeRetirementDomainSpec>, private readonly journal: RetirementOwnerStore,\n fingerprint: string, options: NativeRetirementOptions) {\n this.originalProvider = nativeServiceInstance(ctx.sessionPersistence);\n this.provider = new NativePersistenceAdapter(ctx.sessionPersistence, admission);\n this.descriptor = retirementCapabilitiesSchema.parse({ protocolVersion: 1, ownerId: 'session-bin-native-jsonl-owner',\n hostVersion: legacyDurableHostContract, providerId: 'jsonl-session-records-v1', storeId: domain.global.get().storeId,\n participants: [{ id: 'native-jsonl-files', version: fingerprint }, { id: 'native-metadata', version: fingerprint }] });\n for (const record of journal.operations()) if (!['rejected', 'conflict'].includes(record.state.phase)) admission.markRetired(record.state.request.expected.sessionId);\n const guardedStore: RetirementOwnerStore = {\n bindCapabilities: value => this.io(() => journal.bindCapabilities(value)),\n operation: id => this.read(() => journal.operation(id)), operations: () => this.read(() => journal.operations()),\n putOperation: value => this.io(async () => {\n // Fail closed even if a medium commit succeeds but acknowledgement fails.\n if (!['rejected', 'conflict'].includes(value.state.phase)) admission.markRetired(value.state.request.expected.sessionId);\n await journal.putOperation(value);\n }), close: () => journal.close(),\n };\n const participants = [this.fileParticipant(fingerprint), this.metadataParticipant(fingerprint)];\n this.coordinator = new RetirementOwnerCoordinator({ capabilities: this.descriptor, store: guardedStore,\n lifecycle: { inspect: id => this.inspect(id), bindGuards: async () => async () => {},\n acquire: (expected, maintenance) => this.acquire(expected, maintenance) }, participants,\n ...(options.checkpoint ? { checkpoint: options.checkpoint } : {}), ...(options.canAdvance ? { canAdvance: options.canAdvance } : {}) });\n }\n static async open(ctx: Context, options: NativeRetirementOptions = {}): Promise<NativeRetirementOwner | undefined> {\n // An implemented candidate is not production evidence. Never derive this\n // composition callback from permanentDeletion:true or client input.\n if (process.versions.node !== '24.18.1' || process.versions.uv !== '1.52.1' || !nativePlatformCandidate()) return;\n if (!nativePlatformVerified() && !options.platformQualification?.({\n platform: process.platform, arch: process.arch, node: process.versions.node,\n })) return;\n const fingerprint = await nativeRetirementSdkFingerprint();\n if (fingerprint === null) return;\n for (const name of ['sessionQuery', 'sessionProjectionCache', 'sessionController'] as const) {\n const pending = ctx.get(name, false);\n if (pending !== undefined && ctx.get(name) === undefined) {\n const instance = nativeServiceInstance(pending as object) as { ctx?: { fiber?: { await(): Promise<unknown> } } };\n if (!instance.ctx?.fiber) return;\n await instance.ctx.fiber.await();\n if (ctx.get(name) === undefined) return;\n }\n }\n const files = await NativeJsonlFiles.open(ctx.sessionPersistence);\n if (!files) return;\n const admission = new NativeAdmission();\n const providerInstance = nativeServiceInstance(ctx.sessionPersistence);\n const previous = Reflect.get(providerInstance, nativeOwnerRegistry) as GuardRegistration | undefined;\n if (previous && (!previous.owner.fullyClosed || previous.root !== files.root || previous.fingerprint !== fingerprint)) return;\n const metadata = await NativeMetadataAdapter.open(ctx, admission);\n if (!metadata) return;\n let domain: Domain<typeof nativeRetirementDomainSpec> | undefined;\n let journalDomain: Domain<typeof nativeRetirementOwnerDomainSpec> | undefined;\n let owner: NativeRetirementOwner | undefined;\n try {\n domain = await ctx.storageDomain.open(nativeRetirementDomainSpec);\n const global = domain.global.get();\n if (global.storeId === null) {\n await domain.global.set({ schemaVersion: 1, storeId: randomUUID(), root: files.root, fingerprint });\n } else if (global.root !== files.root || global.fingerprint !== fingerprint) {\n throw new Error('Native retirement resources belong to another root or audited composition.');\n }\n if (previous && previous.storeId !== domain.global.get().storeId) throw new Error('Native guard takeover belongs to another durable store.');\n journalDomain = await ctx.storageDomain.open(nativeRetirementOwnerDomainSpec);\n // Identical public record/global schemas; only this owner's domain name differs.\n const journal = new DomainRetirementOwnerStore(journalDomain as unknown as Domain<typeof retirementOwnerDomainSpec>);\n owner = new NativeRetirementOwner(ctx, files, metadata, admission, domain, journal, fingerprint, options);\n await owner.coordinator.initialize();\n admission.activate();\n if (previous) previous.owner.relinquishGuards();\n owner.restore.push(owner.provider.install());\n owner.restore.push(await metadata.install());\n Reflect.set(providerInstance, nativeOwnerRegistry, { owner, root: files.root, fingerprint, storeId: owner.descriptor.storeId } satisfies GuardRegistration);\n return owner;\n } catch (error) {\n admission.suspend();\n const errors = [error];\n for (const action of [() => owner?.close(), () => journalDomain?.close(), () => domain?.close()]) {\n try { await action(); } catch (cleanup) { errors.push(cleanup); }\n }\n if (errors.length > 1) throw new AggregateError(errors, 'Native retirement initialization/cleanup failed.');\n throw error;\n }\n }\n capabilities(): Promise<RetirementCapabilities> {\n if (this.admission.requiresRecovery()) return Promise.reject(new Error('Native retirement requires a complete reopen after unknown I/O.'));\n return this.coordinator.capabilities();\n }\n eligibility(id: string): Promise<string | null> { return this.observe(() => this.eligibilityInner(id)); }\n private async eligibilityInner(id: string): Promise<string | null> {\n if (nativeServiceInstance(this.ctx.sessionPersistence) !== this.originalProvider) return 'native/composition-changed';\n if (this.admission.isRetired(id)) return 'native/session-retired';\n try {\n const scope = this.scopes.get(id);\n if (scope) {\n if (this.provider.busy(id)) return 'native/persistence-retained';\n if (scope.blocked) return scope.blocked;\n await this.metadata.capture(id);\n return null;\n }\n const release = await this.admission.acquire(id);\n try {\n await this.metadata.releaseIdle(id);\n await this.admission.drain(id);\n if (this.provider.busy(id)) return 'native/persistence-retained';\n await this.metadata.capture(id);\n const snapshot = await this.provider.stat(id);\n if (!snapshot) return 'session-not-found';\n if (snapshot.header.origin === 'subagent') return 'native/subagent-unsupported';\n const inventory = await this.files.inspect(id, snapshot.header);\n const lease = await this.files.acquire(inventory);\n try { await this.files.current(inventory); } finally { await lease.release(); }\n return null;\n } finally { release(); }\n } catch (error) { const reason = known(error); if (reason !== null) return reason; this.admission.suspend(); throw error; }\n }\n inspect(id: string): Promise<LifecycleKey | null> { return this.observe(() => this.inspectInner(id)); }\n private async inspectInner(id: string): Promise<LifecycleKey | null> {\n if (this.admission.isRetired(id) && !this.scopes.has(id)) return null;\n const scope = this.scopes.get(id);\n if (scope) return scope.blocked ? null : lifecycleKeySchema.parse(scope.witness.lifecycle);\n const release = await this.admission.acquire(id);\n let lease: { release(): Promise<void> } | undefined;\n try {\n if (this.provider.busy(id)) throw retirementOwnerRefusal('native/persistence-retained');\n const snapshot = await this.provider.stat(id);\n if (!snapshot) return null;\n if (snapshot.header.origin === 'subagent') throw retirementOwnerRefusal('native/subagent-unsupported');\n const initial = await this.files.inspect(id, snapshot.header);\n lease = await this.files.acquire(initial);\n const inventory = await this.files.current(initial);\n const metadata = await this.metadata.capture(id);\n const previous = this.witness(id);\n const lifecycle = previous && equal(previous.inventory.anchor, inventory.anchor)\n ? previous.lifecycle : { storeId: this.descriptor.storeId, sessionId: id, lifecycleId: randomUUID() };\n await this.putWitness({ schemaVersion: 1, lifecycle, inventory, metadata });\n return lifecycleKeySchema.parse(lifecycle);\n } catch (error) {\n const reason = known(error); if (reason !== null) throw retirementOwnerRefusal(reason);\n throw error;\n } finally { try { await lease?.release(); } finally { release(); } }\n }\n async prepare(expected: LifecycleKey): Promise<RetirementManifest> {\n try { return await this.coordinator.prepare(expected); }\n catch (error) {\n if (this.coordinator.isRefusal(error)) throw retirementOwnerRefusal(error instanceof RetirementOwnerError ? error.code : 'native/lifecycle-changed');\n this.admission.suspend(); throw error;\n }\n }\n async retire(request: RetirementRequest, authorize: () => Promise<RetirementAuthorization>, manifest?: RetirementManifest): Promise<RetirementState> {\n try { return await this.coordinator.retire(request, authorize, manifest); }\n catch (error) {\n if (this.coordinator.isRefusal(error)) throw retirementOwnerRefusal(error instanceof RetirementOwnerError ? error.code : 'native/operation-refused');\n this.admission.suspend(); throw error;\n }\n }\n getOperation(id: string): Promise<RetirementState | null> { return this.coordinator.getOperation(id); }\n async recover(id: string): Promise<RetirementState> {\n try { return await this.coordinator.recover(id); }\n catch (error) {\n if (this.coordinator.isRefusal(error)) throw retirementOwnerRefusal(error instanceof RetirementOwnerError ? error.code : 'native/operation-refused');\n this.admission.suspend(); throw error;\n }\n }\n private async acquire(expected: LifecycleKey, maintenance: RetirementOwnerRecord | null): Promise<RetirementLifecycleScope> {\n const witness = this.witness(expected.sessionId);\n if (!witness || !lifecycleEqual(expected, witness.lifecycle)) throw new Error('Native lifecycle witness is missing or changed.');\n const releaseAdmission = await this.admission.acquire(expected.sessionId, maintenance !== null);\n const scope: Scope = { witness, inventory: witness.inventory, metadata: witness.metadata, blocked: null, lease: undefined, releaseAdmission };\n try {\n if (this.provider.busy(expected.sessionId)) scope.blocked = 'native/persistence-retained';\n if (!scope.blocked) {\n if (maintenance === null) {\n const snapshot = await this.provider.stat(expected.sessionId);\n if (!snapshot) scope.blocked = 'native/lifecycle-changed';\n else {\n const inventory = await this.files.inspect(expected.sessionId, snapshot.header);\n if (!equal(inventory.anchor, witness.inventory.anchor)) scope.blocked = 'native/lifecycle-changed';\n else scope.inventory = inventory;\n }\n }\n if (!scope.blocked) {\n scope.lease = await this.files.acquire(scope.inventory, { recovering: maintenance !== null });\n scope.inventory = await this.files.current(scope.inventory);\n if (maintenance === null) scope.metadata = await this.metadata.capture(expected.sessionId);\n }\n }\n } catch (error) {\n const reason = known(error);\n if (reason !== null && maintenance === null) scope.blocked = reason;\n else { this.admission.suspend(); try { await scope.lease?.release(); } finally { releaseAdmission(); } throw error; }\n }\n this.scopes.set(expected.sessionId, scope);\n return { lifecycle: expected, current: async () => scope.blocked ? null : expected,\n activity: async () => scope.blocked ? [scope.blocked] : (await this.ctx.waterfall('workspace/session-activity', { sessionId: SessionId(expected.sessionId) }, async () => [])).map(item => String(item.kind)),\n quiesce: async () => {\n await this.admission.drain(expected.sessionId);\n if (scope.blocked || this.provider.busy(expected.sessionId)) return false;\n await this.metadata.capture(expected.sessionId); return true;\n },\n finalize: async () => {\n if (this.provider.busy(expected.sessionId)) return false;\n this.provider.forget(expected.sessionId); return true;\n },\n release: async () => {\n this.scopes.delete(expected.sessionId);\n try { await scope.lease?.release(); } finally { releaseAdmission(); }\n } };\n }\n private observe<T>(work: () => Promise<T>): Promise<T> {\n if (this.admission.requiresRecovery()) return Promise.reject(new Error('Native retirement requires a complete reopen after unknown I/O.'));\n if (this.observationsClosed && !this.coordinator.ownsCurrentMaintenanceFrame()) return Promise.reject(retirementOwnerRefusal('native/closing'));\n const task = Promise.resolve().then(work).catch(error => {\n const reason = known(error);\n if (reason !== null) throw retirementOwnerRefusal(reason);\n // Only our trusted marker remains a business refusal; cleanup/FS errors\n // are unknown and fence the affected retirement candidates immediately.\n if (!isRetirementOwnerRefusal(error)) this.admission.suspend();\n throw error;\n });\n this.observations.add(task);\n void task.finally(() => this.observations.delete(task)).catch(() => {});\n return task;\n }\n private fileParticipant(version: string): RetirementResourceParticipant {\n return { identity: { id: 'native-jsonl-files', version }, bindGuards: async () => async () => {},\n manifest: async expected => {\n const scope = this.requireScope(expected);\n if (!scope.blocked) scope.inventory = await this.files.current(scope.inventory);\n return scope.inventory.files.map(row => ({ ownerId: 'native-jsonl-files', resourceId: row.resourceId, revision: row.revision,\n kind: 'transcript' as const, disposition: 'erase' as const, retention: null }));\n }, fence: async () => true, quiesce: async () => true,\n applyResource: async (request, resource) => {\n const scope = this.requireScope(request.expected);\n const row = scope.witness.inventory.files.find(item => item.resourceId === resource.resourceId && item.revision === resource.revision);\n if (!row || scope.blocked) throw new Error('Frozen native file witness is unavailable.');\n await this.files.erase(scope.witness.inventory, row);\n return { ownerId: resource.ownerId, resourceId: resource.resourceId, status: 'erased', reason: null };\n }, converge: async request => (await this.files.current(this.requireScope(request.expected).witness.inventory)).files.length === 0 };\n }\n private metadataParticipant(version: string): RetirementResourceParticipant {\n return { identity: { id: 'native-metadata', version }, bindGuards: async () => async () => {},\n manifest: async expected => {\n const scope = this.requireScope(expected);\n if (!scope.blocked) scope.metadata = await this.metadata.capture(expected.sessionId);\n // Commit the complete physical/metadata witness before the plan can be\n // admitted; recovery never resolves resources from a new same-ID object.\n if (!scope.blocked) {\n scope.witness = { ...scope.witness, inventory: scope.inventory, metadata: scope.metadata };\n await this.putWitness(scope.witness);\n }\n const kinds = ['workspace', ...(scope.metadata.cache.location !== null ? ['cache'] : []), ...(scope.metadata.queryProvider === 'sqlite-0.2.0-rc.2' ? ['index'] : [])] as const;\n return kinds.map(kind => ({ ownerId: 'native-metadata', resourceId: `native-${kind}`, revision: metadataRevision(scope.metadata),\n kind: kind as 'workspace' | 'cache' | 'index', disposition: 'erase' as const, retention: null }));\n }, fence: async () => true, quiesce: async () => true,\n applyResource: async (request, resource) => {\n const scope = this.requireScope(request.expected);\n if ((await this.files.current(scope.witness.inventory)).files.length !== 0) {\n return { ownerId: resource.ownerId, resourceId: resource.resourceId, status: 'failed', reason: 'native/files-remain' };\n }\n if (!await this.metadata.converge(scope.witness.metadata, request.expected, request)) {\n return { ownerId: resource.ownerId, resourceId: resource.resourceId, status: 'failed', reason: 'native/metadata-pending' };\n }\n return { ownerId: resource.ownerId, resourceId: resource.resourceId, status: 'erased', reason: null };\n }, converge: async request => {\n const scope = this.requireScope(request.expected);\n return this.metadata.converge(scope.witness.metadata, request.expected, request);\n } };\n }\n private requireScope(expected: LifecycleKey): Scope {\n const scope = this.scopes.get(expected.sessionId);\n if (!scope || !lifecycleEqual(scope.witness.lifecycle, expected)) throw new Error('Native resource action requires its exact held scope.');\n return scope;\n }\n private witness(id: string): Witness | undefined {\n return this.read(() => { const value = this.domain.table('witnesses').get(id); return value === undefined ? undefined : witnessSchema.parse(value); });\n }\n private putWitness(value: Witness): Promise<void> {\n const snapshot = witnessSchema.parse(value);\n return this.io(() => this.domain.table('witnesses').put(snapshot.lifecycle.sessionId, snapshot));\n }\n private read<T>(work: () => T): T { try { return work(); } catch (error) { this.admission.suspend(); throw error; } }\n private async io<T>(work: () => Promise<T>): Promise<T> { try { return await work(); } catch (error) { this.admission.suspend(); throw error; } }\n private relinquishGuards(): void {\n if (!this.fullyClosed) throw new Error('An active native retirement owner cannot surrender its guards.');\n this.metadata.forceRestore(); this.provider.forceRestore();\n }\n close(): Promise<void> {\n this.observationsClosed = true;\n return this.closing ??= (async () => {\n const errors: unknown[] = [];\n try { await this.coordinator.close(); } catch (error) { errors.push(error); }\n while (this.observations.size) await Promise.allSettled([...this.observations]);\n this.admission.beginClose();\n try { await this.admission.drain(); } catch (error) { errors.push(error); }\n for (const restore of this.restore.reverse()) try { await restore(); } catch (error) { errors.push(error); }\n try { await this.domain.close(); } catch (error) { errors.push(error); }\n this.fullyClosed = errors.length === 0;\n if (errors.length) throw new AggregateError(errors, 'Native retirement shutdown failed.');\n })();\n }\n}\n", "import { createRequire } from 'node:module';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { createHash } from 'node:crypto';\n\n/** Locked public npm implementation files actually inspected and tested. */\nexport const nativeRetirementSdkSources = {\n \"cordis\": {\n \"version\": \"4.0.5\",\n \"files\": {\n \"lib/index.js\": \"6a9394c0877ff45218818c6e815edd038f8057e1a1deb390a8d43ec81c57691e\"\n }\n },\n \"dsh-session\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"2f5dd07cb5c744a29abbb8003a8a4cefd9e582c6e2538074ca299a0ddd02a3bf\",\n \"lib/types/index.js\": \"59cced30c7ee65813c62f4858c2fc15c8c636df96507b60c15543468178b72f2\"\n }\n },\n \"dsh-session-persistence\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"cc0b6d3a224133af611b428d5a49020e300f86c3b4ba28037aeb219029bde3eb\"\n }\n },\n \"dsh-session-persistence-jsonl\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"973dd78679b2661d6f492343bc22b124ae958aa597d3b36c698a2c650f909984\"\n }\n },\n \"dsh-session-format-catalog\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"836bbb772ab505c299f1a4a246164c50c7c08b67ab0d17f1251d7ea2cd8c1818\",\n \"lib/types/index.js\": \"c7d797760bf2b9bc654751f2f8cb0b8a6b98998c8d9c1e41323c71a4d5f316f2\"\n }\n },\n \"dsh-storage-domain\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"a54f7664d2f64fe04a08c7058ca5bff4fc69ed6a0d30c2bc11561b620698ef16\"\n }\n },\n \"dsh-storage-json\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"0a6b75d5569db3379edd93e863570170e1f4121b6c9fabd856f5b476cffe8df4\"\n }\n },\n \"dsh-workspace\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"931ca0cb10c5102066c7723690a887f0e6e8e7ab0ffdee1a782686745b0b934f\",\n \"lib/types/index.js\": \"ed69989d8286598fddb3a40030723810a1238968e91ccfec05fc84657bb5ec74\"\n }\n },\n \"dsh-session-query\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"76ce2944e561c12f48b5e240d68cafe54ce6d667b1d20722e6939ed834489939\"\n }\n },\n \"dsh-session-query-sqlite\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"dbecf83320e10d93d735b3d01384ab817a0b90102ccecb0a22c013c71dfe70a0\"\n }\n },\n \"dsh-session-projection-cache\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"faf307dce5db2fb7ff58b4c7d9e544fc7cad5de2f270a89326a8d7bb2bda9c80\"\n }\n },\n \"dsh-api-session-controller\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"a9801acb577b03053c5d5a3191ff555c5f1d791d0acddec113bea4511e33b386\",\n \"lib/types/index.js\": \"616ced16623b7448afa908ff65093eb6ef2a478d32e5ef9bc22634bfa9f80472\"\n }\n }\n} as const;\n\n/** Schema-1 resource identity, preserved across the audited runtime upgrade.\n * These are historical wire identifiers, not the installed SDK version. */\nexport const legacyDurableHostContract = '0.2.0-rc.2';\nconst legacyDurableContractFingerprint = '2618a33decce99fe8ae893245236273d10ac5536bb9dd582dddd115ef27069f3';\n\nexport async function nativeRetirementSdkFingerprint(): Promise<string | null> {\n const root = createRequire(import.meta.url);\n const hostPath = root.resolve('@deepseek-ai/dsh/package.json');\n if (JSON.parse(await readFile(hostPath, 'utf8')).version !== '0.2.1-rc.2') return null;\n const base = createRequire(hostPath);\n for (const [name, expected] of Object.entries(nativeRetirementSdkSources)) {\n let path: string;\n try { path = root.resolve(`@deepseek-ai/${name}/package.json`); }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') throw error;\n try { path = base.resolve(`@deepseek-ai/${name}/package.json`); }\n catch (cause) { if ((cause as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') return null; throw cause; }\n }\n const meta = JSON.parse(await readFile(path, 'utf8')) as { version?: string };\n if (meta.version !== expected.version) return null;\n for (const [file, digest] of Object.entries(expected.files)) {\n if (createHash('sha256').update(await readFile(join(dirname(path), file))).digest('hex') !== digest) return null;\n }\n }\n // Idle API lifecycle release additionally uses the returned AgentHandle and\n // the driver's phase (maintenance is publicly reported as idle). These extra\n // runtime checks do not change the existing durable resource/journal identity.\n const runtime = createRequire(base.resolve('@deepseek-ai/dsh-base/package.json'));\n for (const [name, expected] of Object.entries({\n 'dsh-agent': '7b59cf82c2784c25bdce4e3e24e5e5303b02b9f1003efacf50255492d17baf8b',\n 'dsh-agent-loop': 'cf57e3ecd487ac5c2553455aaa5cef2c6fb41e6bd61be5aa455675d1d7193033',\n })) {\n let path: string;\n try { path = runtime.resolve(`@deepseek-ai/${name}/package.json`); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') return null; throw error; }\n if ((JSON.parse(await readFile(path, 'utf8')) as { version: string }).version !== '0.2.1-rc.2'\n || createHash('sha256').update(await readFile(join(dirname(path), 'lib/index.js'))).digest('hex') !== expected) return null;\n }\n return legacyDurableContractFingerprint;\n}\n", "import type { BigIntStats } from 'node:fs';\nimport { lstat, realpath, readdir, unlink } from 'node:fs/promises';\nimport type { FileHandle } from 'node:fs/promises';\nimport { isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { createRequire } from 'node:module';\nimport { zstdDecompressSync } from 'node:zlib';\nimport { SessionPersistence } from '@deepseek-ai/dsh-session-persistence';\nimport { SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session';\nimport type { SessionHeader } from '@deepseek-ai/dsh-session';\nimport { sessionFormatCatalog } from '@deepseek-ai/dsh-session-format-catalog';\nimport { tryLockExclusive } from '@deepseek-ai/node-addon-system/flock';\nimport { acquireWindowsSemaphore, nativePlatformCandidate, openRegularFile, RegularFileRefusal, syncDirectory, windowsSemaphoreName } from './platform-files.js';\nimport { z } from 'zod';\nimport { nativeServiceInstance } from './native-retirement-persistence.js';\n\nconst integer = z.string().regex(/^\\d+$/);\nconst hash = z.string().regex(/^[a-f0-9]{64}$/);\nconst positiveInteger = z.string().regex(/^[1-9]\\d*$/);\nconst nodeIdentitySchema = z.object({ dev: integer, ino: positiveInteger, birthtimeNs: positiveInteger }).strict();\nconst fileIdentitySchema = nodeIdentitySchema.extend({ size: integer, mtimeNs: integer, ctimeNs: integer, nlink: z.literal('1') }).strict();\nconst lockIdentitySchema = nodeIdentitySchema.extend({ size: z.literal('0'), nlink: z.literal('1') }).strict();\nconst windowsLockSchema = z.object({ kind: z.literal('win32-semaphore'), name: z.string().min(1) }).strict();\nconst nativeLockSchema = z.union([lockIdentitySchema, windowsLockSchema]);\nconst headerIdentitySchema = z.object({ id: z.string().min(1), createdAt: z.number().int().nonnegative(), cwd: z.string().nullable(),\n parentSession: z.string().nullable(), origin: z.literal('subagent').nullable(), isSeeded: z.boolean(),\n delegationDepth: z.number().int().nonnegative(), agentPreset: z.string().nullable() }).strict();\nconst fileRowSchema = z.object({ resourceId: z.string().min(1), kind: z.enum(['generation', 'staging']),\n formatVersion: z.number().int().min(0).max(4), compression: z.enum(['none', 'zstd']),\n identity: fileIdentitySchema, digest: hash, header: headerIdentitySchema, revision: hash }).strict().superRefine((value, ctx) => {\n try {\n const kind = classify(value.resourceId);\n if (kind.kind !== value.kind || kind.version !== value.formatVersion || kind.compression !== value.compression\n || value.revision !== sha(JSON.stringify({ identity: value.identity, digest: value.digest, header: value.header }))) {\n ctx.addIssue({ code: 'custom', message: 'Resource classification and identity digest must agree.' });\n }\n } catch { ctx.addIssue({ code: 'custom', message: 'Unknown physical resource name.' }); }\n });\nexport const nativeJsonlFileSchema = fileRowSchema;\nexport const nativeJsonlInventorySchema = z.object({ schemaVersion: z.literal(1), root: z.string(),\n rootIdentity: nodeIdentitySchema, directory: z.string(), directoryIdentity: nodeIdentitySchema,\n sessionId: z.string().min(1), compression: z.enum(['none', 'zstd']), header: headerIdentitySchema,\n anchor: z.object({ resourceId: z.string(), identity: nodeIdentitySchema, header: headerIdentitySchema }).strict(),\n lock: nativeLockSchema, files: z.array(fileRowSchema).max(4096), revision: hash }).strict().superRefine((value, ctx) => {\n try {\n const anchor = generation(value.anchor.resourceId);\n if (!isAbsolute(value.root) || value.directory !== join(project(value.header.cwd), segment(value.sessionId))\n || value.header.id !== value.sessionId || !same(value.anchor.header, value.header)\n || !anchor || anchor.compression !== value.compression\n || new Set(value.files.map(row => row.resourceId)).size !== value.files.length\n || value.files.some(row => row.compression !== value.compression || !same(row.header, value.header))\n || value.revision !== sha(JSON.stringify(value.files))) {\n ctx.addIssue({ code: 'custom', message: 'Frozen directory, header identities, file scope and digest must agree.' });\n }\n } catch { ctx.addIssue({ code: 'custom', message: 'Invalid frozen directory or anchor.' }); }\n });\nexport type NativeJsonlInventory = z.infer<typeof nativeJsonlInventorySchema>;\nexport type NativeJsonlFileRow = z.infer<typeof fileRowSchema>;\ntype NodeIdentity = z.infer<typeof nodeIdentitySchema>;\ntype HeaderIdentity = z.infer<typeof headerIdentitySchema>;\ntype Encoding = 'none' | 'zstd';\n\nexport class NativeJsonlRefusal extends Error {\n constructor(readonly code: string, message: string) { super(message); this.name = 'NativeJsonlRefusal'; }\n}\nfunction refuse(code: string, message: string): never { throw new NativeJsonlRefusal(code, message); }\nfunction sha(value: string | Buffer): string { return createHash('sha256').update(value).digest('hex'); }\nfunction same(a: unknown, b: unknown): boolean { return JSON.stringify(a) === JSON.stringify(b); }\nfunction nodeIdentity(stat: BigIntStats): NodeIdentity {\n if (stat.ino <= 0n || stat.birthtimeNs <= 0n) refuse('jsonl/identity-unavailable', 'The filesystem does not provide a stable inode and creation identity.');\n return { dev: String(stat.dev), ino: String(stat.ino), birthtimeNs: String(stat.birthtimeNs) };\n}\nfunction nodeIdentityFromRow(row: NativeJsonlFileRow): NodeIdentity {\n return { dev: row.identity.dev, ino: row.identity.ino, birthtimeNs: row.identity.birthtimeNs };\n}\nfunction fileIdentity(stat: BigIntStats) {\n if (!stat.isFile() || stat.nlink !== 1n) refuse('jsonl/unsafe-file', 'Resources must be exclusive regular files without additional hard links.');\n return fileIdentitySchema.parse({ ...nodeIdentity(stat), size: String(stat.size), mtimeNs: String(stat.mtimeNs), ctimeNs: String(stat.ctimeNs), nlink: '1' });\n}\nfunction lockIdentity(stat: BigIntStats) {\n const identity = fileIdentity(stat);\n if (identity.size !== '0') refuse('jsonl/lock-invalid', 'The existing stable lock must contain no session content.');\n return lockIdentitySchema.parse({ ...nodeIdentity(stat), size: '0', nlink: '1' });\n}\nfunction headerIdentity(header: { id: string; createdAt: number; cwd?: string; parentSession?: string; origin?: 'subagent'; isSeeded: boolean; delegationDepth?: number; agentPreset?: string }): HeaderIdentity {\n return headerIdentitySchema.parse({ id: header.id, createdAt: header.createdAt, cwd: header.cwd ?? null,\n parentSession: header.parentSession ?? null, origin: header.origin ?? null, isSeeded: header.isSeeded,\n delegationDepth: header.delegationDepth ?? 0, agentPreset: header.agentPreset ?? null });\n}\n// Independently expressed rules of the pinned on-disk layout; no private SDK imports.\nfunction segment(value: string): string {\n if (!value) refuse('jsonl/identity-invalid', 'A path identity cannot be empty.');\n if (value === '.' || value === '..') return value.replace(/\\./g, '~002E');\n return value.replace(/[^A-Za-z0-9._-]/g, unit => `~${unit.charCodeAt(0).toString(16).toUpperCase().padStart(4, '0')}`);\n}\nfunction project(cwd: string | null): string {\n if (cwd === null) return '_no-cwd';\n if (!isAbsolute(cwd)) refuse('jsonl/identity-invalid', 'The stored cwd must be absolute.');\n const readable = segment(cwd.replace(/[/\\\\:]+/g, '-')).replace(/^-+/, '') || 'root';\n return `--${readable.slice(0, 251)}--`;\n}\nfunction generation(name: string): { version: number; compression: Encoding } | undefined {\n const match = /^session(?:\\.v([1-9]\\d*))?\\.jsonl(\\.zstd)?$/.exec(name);\n if (!match) return;\n const version = match[1] === undefined ? 0 : Number(match[1]);\n if (!Number.isSafeInteger(version) || version > SESSION_FORMAT_VERSION) refuse('jsonl/unsupported-generation', 'Unknown future physical generations cannot be retired.');\n return { version, compression: match[2] ? 'zstd' : 'none' };\n}\nfunction classify(name: string) {\n const committed = generation(name);\n if (committed) return { ...committed, kind: 'generation' as const };\n const materializing = /^(session(?:\\.v[1-9]\\d*)?\\.jsonl(?:\\.zstd)?)\\.[a-f0-9]{12}\\.tmp$/.exec(name);\n if (materializing) return { ...generation(materializing[1]!)!, kind: 'staging' as const };\n const migrating = /^session\\.migration\\.[a-f0-9]{16}\\.jsonl(\\.zstd)?\\.tmp$/.exec(name);\n if (migrating) return { version: SESSION_FORMAT_VERSION, compression: migrating[1] ? 'zstd' as const : 'none' as const, kind: 'staging' as const };\n refuse('jsonl/unknown-resource', `Unclassified session resource: ${name}`);\n}\n\nconst HEADER_LIMIT = 1024 * 1024;\n// Locate one standard Zstandard frame by its frame header and block lengths.\n// Decode exactly that frame; a torn later event frame does not hide the header.\nfunction firstFrameEnd(bytes: Buffer): number | undefined {\n if (bytes.length < 5) return;\n if (bytes.readUInt32LE(0) !== 0xfd2fb528) refuse('jsonl/header-invalid', 'The first Zstandard frame is not a standard frame.');\n const descriptor = bytes[4]!;\n if (descriptor & 0x18) refuse('jsonl/header-invalid', 'Reserved Zstandard frame flags are unsupported.');\n const single = Boolean(descriptor & 0x20);\n const sizeFlag = descriptor >>> 6;\n const dictionaryBytes = [0, 1, 2, 4][descriptor & 3]!;\n const sizeBytes = sizeFlag === 0 ? single ? 1 : 0 : [0, 2, 4, 8][sizeFlag]!;\n let cursor = 5 + (single ? 0 : 1) + dictionaryBytes + sizeBytes;\n if (cursor > bytes.length) return;\n for (;;) {\n if (cursor + 3 > bytes.length) return;\n const block = bytes.readUIntLE(cursor, 3);\n const type = (block >>> 1) & 3;\n if (type === 3) refuse('jsonl/header-invalid', 'Reserved Zstandard block type.');\n cursor += 3 + (type === 1 ? 1 : block >>> 3);\n if (cursor > bytes.length) return;\n if (block & 1) {\n cursor += descriptor & 4 ? 4 : 0;\n return cursor <= bytes.length ? cursor : undefined;\n }\n }\n}\nfunction decodeHeader(bytes: Buffer, compression: Encoding, version: number): HeaderIdentity {\n let line: Buffer;\n if (compression === 'none') {\n const newline = bytes.indexOf(10);\n if (newline < 0) refuse('jsonl/header-invalid', 'A complete physical header is required, including for staging.');\n line = bytes.subarray(0, newline);\n } else {\n const end = firstFrameEnd(bytes);\n if (end === undefined) refuse('jsonl/header-invalid', 'A complete Zstandard header frame is required.');\n let decoded: Buffer;\n try { decoded = zstdDecompressSync(bytes.subarray(0, end), { maxOutputLength: HEADER_LIMIT }); }\n catch { refuse('jsonl/header-invalid', 'The bounded first Zstandard frame cannot be decoded.'); }\n if (!decoded.length || decoded.indexOf(10) !== decoded.length - 1) refuse('jsonl/header-invalid', 'The header frame must contain exactly one newline-terminated record.');\n line = decoded.subarray(0, -1);\n }\n try {\n const raw: unknown = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(line));\n const result = sessionFormatCatalog.readHeader(raw);\n if (result.status !== 'current' && result.status !== 'migration-required') refuse('jsonl/header-invalid', 'Malformed or unsupported physical Session header.');\n if (result.storedVersion !== version) refuse('jsonl/header-invalid', 'Physical filename and header versions differ.');\n return headerIdentity(result.header);\n } catch (error) {\n if (error instanceof NativeJsonlRefusal) throw error;\n refuse('jsonl/header-invalid', 'The physical Session header cannot be decoded and identified.');\n }\n}\nfunction missing(error: unknown): boolean { return (error as NodeJS.ErrnoException | undefined)?.code === 'ENOENT'; }\n\ninterface HeldFileLease {\n stamp: string;\n closing: boolean;\n tail: Promise<void>;\n pending: Set<Promise<void>>;\n recovering: boolean;\n}\nfunction leaseStamp(inventory: NativeJsonlInventory): string {\n return JSON.stringify({ root: inventory.root, rootIdentity: inventory.rootIdentity, directory: inventory.directory,\n directoryIdentity: inventory.directoryIdentity, sessionId: inventory.sessionId, compression: inventory.compression,\n header: inventory.header, anchor: inventory.anchor, lock: inventory.lock });\n}\n\n/** Exact file erasure; platform kernel leases share the audited JSONL writer namespace. */\nexport class NativeJsonlFiles {\n private readonly leases = new Map<string, HeldFileLease>();\n private constructor(private readonly provider: SessionPersistence & { config: { root: string; compression?: Encoding } }, readonly root: string, readonly compression: Encoding,\n private readonly rootIdentity: NodeIdentity) {}\n\n static async open(provider: unknown): Promise<NativeJsonlFiles | undefined> {\n if (!nativePlatformCandidate()) return;\n if (!(provider instanceof SessionPersistence) || provider.constructor.name !== 'JsonlSessionPersistence'\n || provider.name !== 'session-persistence-jsonl' || SESSION_FORMAT_VERSION !== 4) return;\n // The pinned SDK keeps the concrete class private. Verify its complete official npm\n // implementation instead of accepting a provider by a class-name match.\n if (createHash('sha256').update(Function.prototype.toString.call(nativeServiceInstance(provider).constructor)).digest('hex')\n !== 'bb0e12b14bd21adec58c51934f00014e482380102f09aa5e935536c57c0d6e1e') return;\n const internals = provider as unknown as { root?: unknown; compression?: unknown; config?: { root?: unknown; compression?: unknown } };\n const config = internals.config;\n if (typeof internals.root !== 'string' || !isAbsolute(internals.root)\n || (internals.compression !== 'none' && internals.compression !== 'zstd')\n || typeof config?.root !== 'string' || resolve(config.root) !== internals.root\n || (config.compression ?? 'zstd') !== internals.compression) return;\n const require = createRequire(import.meta.url);\n const metadata: unknown = require('@deepseek-ai/dsh-session-persistence-jsonl/package.json');\n if ((metadata as { version?: unknown }).version !== '0.2.1-rc.2') return;\n let root: string;\n try { root = await realpath(internals.root); }\n catch (error) { if (missing(error)) return; throw error; }\n if (process.platform === 'win32' && resolve(internals.root).toLowerCase() !== root.toLowerCase()) return;\n const identity = await lstat(root, { bigint: true });\n if (!identity.isDirectory()) refuse('jsonl/root-invalid', 'The configured root must be an existing directory.');\n if (identity.ino <= 0n || identity.birthtimeNs <= 0n) return;\n return new NativeJsonlFiles(provider as SessionPersistence & { config: { root: string; compression?: Encoding } }, root, internals.compression, nodeIdentity(identity));\n }\n\n async inspect(sessionId: string, header: SessionHeader): Promise<NativeJsonlInventory> {\n if (header.version !== SESSION_FORMAT_VERSION) refuse('jsonl/identity-invalid', 'Inspection requires the current logical Session header.');\n const identity = headerIdentity(header);\n if (sessionId !== identity.id) refuse('jsonl/identity-invalid', 'Requested session and header identities differ.');\n const directory = join(project(identity.cwd), segment(sessionId));\n const base = await this.directory(directory, sessionId, identity);\n const files = await this.rows(base.path, identity);\n const canonical = files.filter(row => row.kind === 'generation').sort((a, b) => a.formatVersion - b.formatVersion)[0];\n if (!canonical) refuse('jsonl/session-not-found', 'No identified committed generation exists.');\n const inventory = { schemaVersion: 1 as const, root: this.root, rootIdentity: this.rootIdentity,\n directory, directoryIdentity: base.identity, sessionId, compression: this.compression, header: identity,\n anchor: { resourceId: canonical.resourceId,\n identity: { dev: canonical.identity.dev, ino: canonical.identity.ino, birthtimeNs: canonical.identity.birthtimeNs }, header: identity },\n lock: await this.lockIdentity(base.path), files, revision: sha(JSON.stringify(files)) };\n await this.directory(directory, sessionId, identity);\n return nativeJsonlInventorySchema.parse(inventory);\n }\n\n /** Re-enumerate the entire scope without changing its original durable anchor. */\n async current(input: NativeJsonlInventory): Promise<NativeJsonlInventory> {\n const inventory = this.validate(input);\n const base = await this.assertDirectory(inventory);\n const files = await this.rows(base.path, inventory.header, inventory);\n const lock = await this.lockIdentity(base.path);\n if (!same(lock, inventory.lock)) refuse('jsonl/lock-changed', 'The stable coordination file changed.');\n return nativeJsonlInventorySchema.parse({ ...inventory, files, revision: sha(JSON.stringify(files)) });\n }\n\n async acquire(input: NativeJsonlInventory, options: { recovering?: boolean } = {}): Promise<{ release(): Promise<void> }> {\n const inventory = this.validate(input);\n const base = await this.assertDirectory(inventory);\n let fd: FileHandle | undefined;\n let unlock: (() => Promise<void>) | undefined;\n const record: HeldFileLease = { stamp: leaseStamp(inventory), closing: false, tail: Promise.resolve(), pending: new Set(),\n recovering: options.recovering === true };\n let held = false;\n try {\n if (process.platform === 'win32') {\n try { unlock = await acquireWindowsSemaphore(join(base.path, 'session.lock'), 'session'); }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'EBUSY') refuse('jsonl/writer-active', 'Another writer holds the session kernel lease.');\n throw error;\n }\n } else {\n fd = await this.openFile(join(base.path, 'session.lock'), 'write');\n if (!same(lockIdentity(await fd.stat({ bigint: true })), inventory.lock)) refuse('jsonl/lock-changed', 'The frozen stable lock changed.');\n try { await tryLockExclusive(fd.fd); }\n catch (error) {\n if (['EAGAIN', 'EWOULDBLOCK'].includes((error as NodeJS.ErrnoException).code ?? '')) refuse('jsonl/writer-active', 'Another writer holds the session lock.');\n throw error;\n }\n }\n await this.assertDirectory(inventory);\n if (!same(await this.lockIdentity(base.path), inventory.lock)) refuse('jsonl/lock-changed', 'The held lock no longer has its frozen namespace identity.');\n this.leases.set(inventory.directory, record);\n held = true;\n } finally {\n if (!held) {\n try { await unlock?.(); } finally { await fd?.close(); }\n }\n }\n let releasing: Promise<void> | undefined;\n return { release: () => releasing ??= (async () => {\n record.closing = true;\n await Promise.allSettled([...record.pending]);\n try { try { await unlock?.(); } finally { await fd?.close(); } }\n finally { if (this.leases.get(inventory.directory) === record) this.leases.delete(inventory.directory); }\n })() };\n }\n\n /** Caller must have persisted the exact retirement intent before this method. */\n async erase(input: NativeJsonlInventory, inputRow: NativeJsonlFileRow): Promise<void> {\n const inventory = this.validate(input); const row = fileRowSchema.parse(inputRow);\n const lease = this.leases.get(inventory.directory);\n if (!lease || lease.closing || lease.stamp !== leaseStamp(inventory)) refuse('jsonl/lease-required', 'Erasure requires the same stable namespace kernel lease.');\n if (!inventory.files.some(saved => same(saved, row))) refuse('jsonl/scope-changed', 'The resource is outside the frozen inventory.');\n const operation = lease.tail.then(() => this.eraseInner(inventory, row));\n lease.tail = operation.then(() => undefined, () => undefined);\n lease.pending.add(operation);\n try { await operation; } finally { lease.pending.delete(operation); }\n }\n\n private async eraseInner(inventory: NativeJsonlInventory, row: NativeJsonlFileRow): Promise<void> {\n const base = await this.assertDirectory(inventory);\n const names = await readdir(base.path);\n if (names.some(name => name !== 'session.lock' && !inventory.files.some(saved => saved.resourceId === name))) refuse('jsonl/scope-changed', 'A new or unknown file entered the frozen scope.');\n if (!same(await this.lockIdentity(base.path), inventory.lock)) refuse('jsonl/lock-changed', 'The held lock changed.');\n const absolute = join(base.path, row.resourceId);\n const target = resolve(absolute);\n if (target !== absolute || relative(base.path, target) !== row.resourceId) refuse('jsonl/path-invalid', 'The exact resource must be a direct child of its bound directory.');\n const remainder = await this.isWindowsErasureRemainder(inventory, row);\n try {\n if (!remainder) {\n const observed = await this.readRow(base.path, row.resourceId, inventory.header);\n if (!same(row, observed)) refuse('jsonl/resource-changed', 'The physical resource identity or bytes changed after confirmation.');\n }\n } catch (error) { if (missing(error)) { await this.syncDirectory(base.path); return; } throw error; }\n await this.assertDirectory(inventory);\n const latest = fileIdentity(await lstat(absolute, { bigint: true }));\n if (remainder ? latest.size !== '0' || !same(nodeIdentity(await lstat(absolute, { bigint: true })), nodeIdentityFromRow(row))\n : !same(latest, row.identity)) refuse('jsonl/resource-changed', 'The exact resource changed before erasure.');\n if (process.platform === 'win32') {\n // Node cannot fsync a Windows directory. Clear and sync the exact exclusive\n // file before removing its name, so an unlink rollback cannot restore logs.\n // Only a saved maintenance operation may resume an interrupted empty file.\n const handle = await this.openFile(absolute, 'write');\n try {\n const opened = fileIdentity(await handle.stat({ bigint: true }));\n if (remainder ? opened.size !== '0' || !same(nodeIdentity(await handle.stat({ bigint: true })), nodeIdentityFromRow(row))\n : !same(opened, row.identity)) refuse('jsonl/resource-changed', 'The opened erasure object differs from the frozen file.');\n await handle.truncate(0);\n await handle.sync();\n } finally { await handle.close(); }\n const cleared = await lstat(absolute, { bigint: true });\n if (!cleared.isFile() || cleared.nlink !== 1n || cleared.size !== 0n\n || !same(nodeIdentity(cleared), nodeIdentityFromRow(row))) refuse('jsonl/resource-changed', 'The cleared erasure object changed before unlink.');\n }\n await unlink(absolute);\n await this.syncDirectory(base.path);\n }\n\n private validate(input: NativeJsonlInventory): NativeJsonlInventory {\n const value = nativeJsonlInventorySchema.parse(input);\n if (value.root !== this.root || value.compression !== this.compression || !same(value.rootIdentity, this.rootIdentity)\n || value.sessionId !== value.header.id || value.directory !== join(project(value.header.cwd), segment(value.sessionId))\n || value.files.some(row => row.resourceId.includes(sep) || row.resourceId.includes('/') || row.resourceId.includes('\\\\')\n || row.resourceId === 'session.lock' || !same(row.header, value.header))) refuse('jsonl/binding-invalid', 'The inventory is not bound to this adapter and exact directory.');\n const windowsLock = 'kind' in value.lock;\n if ((process.platform === 'win32') !== windowsLock\n || ('kind' in value.lock && value.lock.name !== windowsSemaphoreName(join(this.root, value.directory, 'session.lock'), 'session'))) {\n refuse('jsonl/binding-invalid', 'The inventory kernel lease belongs to another platform or namespace.');\n }\n if (new Set(value.files.map(row => row.resourceId)).size !== value.files.length || value.revision !== sha(JSON.stringify(value.files))) refuse('jsonl/binding-invalid', 'The frozen resource inventory digest is invalid.');\n for (const row of value.files) {\n const classified = classify(row.resourceId);\n if (classified.kind !== row.kind || classified.version !== row.formatVersion || classified.compression !== row.compression\n || row.revision !== sha(JSON.stringify({ identity: row.identity, digest: row.digest, header: row.header }))) refuse('jsonl/binding-invalid', 'Frozen resource classification or digest changed.');\n }\n return value;\n }\n\n private async directory(directory: string, sessionId: string, header: HeaderIdentity) {\n const internals = this.provider as unknown as { root: string; compression: Encoding };\n if (await realpath(internals.root) !== this.root || internals.compression !== this.compression\n || (process.platform === 'win32' && resolve(internals.root).toLowerCase() !== this.root.toLowerCase())\n || resolve(this.provider.config.root) !== internals.root || (this.provider.config.compression ?? 'zstd') !== this.compression) refuse('jsonl/provider-changed', 'The provider root or encoding changed.');\n const root = await lstat(this.root, { bigint: true });\n if (!root.isDirectory() || !same(nodeIdentity(root), this.rootIdentity)) refuse('jsonl/root-changed', 'The configured root identity changed.');\n if (directory !== join(project(header.cwd), segment(sessionId))) refuse('jsonl/path-invalid', 'Directory does not match the stored identity.');\n const matches: string[] = [];\n for (const entry of await readdir(this.root, { withFileTypes: true })) {\n const projectPath = join(this.root, entry.name);\n if ([`${segment(sessionId)}.jsonl`, `${segment(sessionId)}.jsonl.zstd`].includes(entry.name)) refuse('jsonl/legacy-layout', 'Root-level flat session artifacts are not admitted.');\n if (entry.isSymbolicLink()) refuse('jsonl/unsafe-directory', 'Symlink project directories cannot certify a unique target.');\n if (!entry.isDirectory()) continue;\n for (const suffix of ['.jsonl', '.jsonl.zstd']) {\n try { await lstat(join(projectPath, segment(sessionId) + suffix)); refuse('jsonl/legacy-layout', 'Flat session artifacts are not admitted.'); }\n catch (error) { if (!missing(error)) throw error; }\n }\n const candidate = join(projectPath, segment(sessionId));\n try {\n const stat = await lstat(candidate, { bigint: true });\n if (!stat.isDirectory()) refuse('jsonl/unsafe-directory', 'Session directories must be direct regular directories.');\n matches.push(candidate);\n } catch (error) { if (!missing(error)) throw error; }\n }\n const path = join(this.root, directory);\n if (matches.length !== 1 || matches[0] !== path) refuse('jsonl/identity-ambiguous', 'The session directory is missing, misplaced, or duplicated across projects.');\n const actual = await realpath(path);\n const rel = relative(this.root, actual);\n if (actual !== path || rel !== directory || rel.startsWith(`..${sep}`) || isAbsolute(rel)) refuse('jsonl/unsafe-directory', 'The session directory leaves the configured root.');\n return { path, identity: nodeIdentity(await lstat(path, { bigint: true })) };\n }\n private async assertDirectory(inventory: NativeJsonlInventory) {\n const base = await this.directory(inventory.directory, inventory.sessionId, inventory.header);\n if (!same(base.identity, inventory.directoryIdentity)) refuse('jsonl/directory-changed', 'The bound directory incarnation changed.');\n return base;\n }\n private async lockIdentity(directory: string): Promise<z.infer<typeof nativeLockSchema>> {\n if (process.platform === 'win32') return { kind: 'win32-semaphore', name: windowsSemaphoreName(join(directory, 'session.lock'), 'session') };\n return lockIdentity(await lstat(join(directory, 'session.lock'), { bigint: true }));\n }\n private async isWindowsErasureRemainder(inventory: NativeJsonlInventory, row: NativeJsonlFileRow): Promise<boolean> {\n const lease = this.leases.get(inventory.directory);\n if (process.platform !== 'win32' || !lease?.recovering || lease.stamp !== leaseStamp(inventory)) return false;\n try {\n const handle = await this.openFile(join(this.root, inventory.directory, row.resourceId), 'read');\n try {\n const stat = await handle.stat({ bigint: true });\n return stat.size === 0n && same(nodeIdentity(stat), nodeIdentityFromRow(row));\n } finally { await handle.close(); }\n } catch (error) { if (missing(error)) return false; throw error; }\n }\n private async rows(directory: string, header: HeaderIdentity, frozen?: NativeJsonlInventory): Promise<NativeJsonlFileRow[]> {\n const names = (await readdir(directory)).sort();\n if (names.length > 4097) refuse('jsonl/scope-too-large', 'Session scope exceeds the bounded inventory.');\n const posix = process.platform !== 'win32';\n if (posix && !names.includes('session.lock')) refuse('jsonl/lock-missing', 'The existing stable writer lock is required.');\n const rows: NativeJsonlFileRow[] = [];\n for (const name of names) {\n if (posix && name === 'session.lock') continue;\n const original = frozen?.files.find(row => row.resourceId === name);\n if (frozen && original && await this.isWindowsErasureRemainder(frozen, original)) rows.push(original);\n else rows.push(await this.readRow(directory, name, header));\n }\n if (!same(names, (await readdir(directory)).sort())) refuse('jsonl/scope-changed', 'The directory changed while enumerating resources.');\n return rows;\n }\n private async readRow(directory: string, name: string, expected: HeaderIdentity): Promise<NativeJsonlFileRow> {\n const classified = classify(name);\n if (classified.compression !== this.compression) refuse('jsonl/encoding-mismatch', 'Mixed raw and Zstandard session generations are not admitted.');\n const path = join(directory, name);\n const before = fileIdentity(await lstat(path, { bigint: true }));\n const fd = await this.openFile(path, 'read');\n try {\n if (!same(before, fileIdentity(await fd.stat({ bigint: true })))) refuse('jsonl/resource-changed', 'Resource was replaced before reading.');\n const digest = createHash('sha256'); const chunks: Buffer[] = []; let headerBytes = 0;\n const buffer = Buffer.alloc(64 * 1024); let total = 0n;\n for (;;) {\n const { bytesRead } = await fd.read(buffer, 0, buffer.length, null);\n if (!bytesRead) break;\n total += BigInt(bytesRead); digest.update(buffer.subarray(0, bytesRead));\n if (headerBytes < HEADER_LIMIT) { const chunk = Buffer.from(buffer.subarray(0, Math.min(bytesRead, HEADER_LIMIT - headerBytes))); chunks.push(chunk); headerBytes += chunk.length; }\n }\n if (String(total) !== before.size || !same(before, fileIdentity(await fd.stat({ bigint: true })))\n || !same(before, fileIdentity(await lstat(path, { bigint: true })))) refuse('jsonl/resource-changed', 'The resource changed while hashing its exact bytes.');\n const header = decodeHeader(Buffer.concat(chunks), classified.compression, classified.version);\n if (!same(header, expected)) refuse('jsonl/identity-changed', 'A physical generation or staging header belongs to another lifecycle.');\n const value = { resourceId: name, kind: classified.kind, formatVersion: classified.version, compression: classified.compression,\n identity: before, digest: digest.digest('hex'), header };\n return fileRowSchema.parse({ ...value, revision: sha(JSON.stringify({ identity: value.identity, digest: value.digest, header })) });\n } finally { await fd.close(); }\n }\n private async openFile(path: string, access: 'read' | 'write'): Promise<FileHandle> {\n try { return await openRegularFile(path, access); }\n catch (error) {\n if (error instanceof RegularFileRefusal) refuse(error.code === 'platform/unsafe-file' ? 'jsonl/unsafe-file'\n : error.code === 'platform/identity-unavailable' ? 'jsonl/identity-unavailable' : 'jsonl/resource-changed', error.message);\n throw error;\n }\n }\n private async syncDirectory(directory: string) { await syncDirectory(directory); }\n}\n", "import type { SessionHeader } from '@deepseek-ai/dsh-session';\nimport { SessionId } from '@deepseek-ai/dsh-session';\nimport type { SessionHandle, SessionPersistence, SessionPersistenceSnapshot } from '@deepseek-ai/dsh-session-persistence';\nimport { NativeAdmission, NativeAdmissionError } from './native-retirement-admission.js';\n\ninterface PinnedJsonlInternals {\n tracker: { openHandles: Set<SessionHandle>; writers: Map<string, SessionHandle | null>; pending: Map<string, unknown> };\n migrationPreparations: Map<string, unknown>;\n coldLogMemo: Map<string, unknown>;\n [key: string]: unknown;\n}\n\nexport function nativeServiceInstance<T extends object>(value: T): T {\n return (Reflect.get(value, Symbol.for('cordis.original')) as T | undefined) ?? value;\n}\n\n/** Version-bound instance Adapter. It never patches prototypes or other Hosts. */\nexport class NativePersistenceAdapter {\n private readonly raw: PinnedJsonlInternals;\n private originalStat: SessionPersistence['stat'];\n private originalList: SessionPersistence['list'];\n private readonly restore: Array<() => void> = [];\n private detached = false;\n private active = true;\n private readonly managedHandles = new WeakSet<object>();\n constructor(private readonly provider: SessionPersistence, private readonly admission: NativeAdmission) {\n const raw = nativeServiceInstance(provider) as unknown as PinnedJsonlInternals;\n if (!(raw.tracker?.openHandles instanceof Set) || !(raw.tracker.writers instanceof Map)\n || !(raw.tracker.pending instanceof Map) || !(raw.migrationPreparations instanceof Map)\n || !(raw.coldLogMemo instanceof Map)) throw new Error('JSONL retirement runtime shape does not match the pinned provider.');\n this.raw = raw;\n this.originalStat = provider.stat.bind(provider);\n this.originalList = provider.list.bind(provider);\n }\n stat(id: string): Promise<SessionPersistenceSnapshot | undefined> { return this.originalStat(SessionId(id)); }\n list(): Promise<readonly SessionPersistenceSnapshot[]> { return this.originalList(); }\n busy(id: string): boolean {\n return this.raw.tracker.pending.has(id) || this.raw.tracker.writers.has(id)\n || [...this.raw.tracker.openHandles].some(handle => handle.id === id)\n || this.raw.migrationPreparations.size !== 0;\n }\n forget(id: string): void {\n if (this.busy(id)) throw new NativeAdmissionError('A persistence reference still owns this session.');\n this.raw.coldLogMemo.delete(id);\n }\n install(): () => Promise<void> {\n this.originalStat = this.provider.stat.bind(this.provider);\n this.originalList = this.provider.list.bind(this.provider);\n const route = (target: object, name: string, idFor: (args: unknown[]) => string, transform?: (value: unknown) => unknown, globalRead = false) => {\n target = nativeServiceInstance(target);\n const record = target as Record<string, unknown>;\n const original = record[name];\n if (typeof original !== 'function') throw new Error(`Missing pinned JSONL route ${name}.`);\n const own = Object.getOwnPropertyDescriptor(target, name);\n const adapter = this;\n const wrapper = function (this: object, ...args: unknown[]) {\n const receiver = this;\n if (adapter.detached) return Promise.reject(new NativeAdmissionError('This native guard belongs to a replaced retirement owner.'));\n const id = idFor(args);\n if (!adapter.active) {\n if (adapter.admission.isRetired(id)) return Promise.reject(new NativeAdmissionError('This session has a retirement tombstone.'));\n return Reflect.apply(original, receiver, args);\n }\n const run = () => adapter.admission.track(id, async () => {\n const value = await Reflect.apply(original, receiver, args);\n return transform ? transform(value) : value;\n });\n return globalRead ? adapter.admission.trackGlobal(run) : run();\n };\n Object.defineProperty(target, name, { configurable: true, writable: true, value: wrapper });\n this.restore.push(() => {\n if (record[name] !== wrapper) throw new Error(`JSONL route ${name} changed while retirement was installed.`);\n if (own) Object.defineProperty(target, name, own); else delete record[name];\n });\n };\n const headerId = (args: unknown[]) => String((args[0] as SessionHeader).id);\n route(this.provider, 'create', headerId, value => this.manage(value as SessionHandle));\n route(this.provider, 'open', args => String(args[0]), value => this.manage(value as SessionHandle), true);\n for (const method of ['persistBatch', 'persistHeader', 'truncateTornTail', 'acquireWriteLease']) {\n route(this.provider, method, headerId);\n }\n route(this.provider, 'readStoredLog', args => String(args[1]), undefined, true);\n route(this.provider, 'resolveCurrentLog', args => String(args[0]));\n // Metadata observations must omit admitted/retired lifecycles, including a\n // read which began before the durable fence and returns afterwards.\n const instance = nativeServiceInstance(this.provider);\n const rawStat = instance.stat;\n const rawList = instance.list;\n const adapter = this;\n instance.stat = async function (id, options) {\n if (adapter.detached) throw new NativeAdmissionError('This native observer belongs to a replaced retirement owner.');\n if (adapter.admission.isRetired(id)) return undefined;\n const value = await adapter.admission.trackGlobal(() => adapter.admission.track(id, () => rawStat.call(this, id, options)));\n return adapter.admission.isRetired(id) ? undefined : value;\n };\n instance.list = async function (options) {\n if (adapter.detached) throw new NativeAdmissionError('This native observer belongs to a replaced retirement owner.');\n return (await adapter.admission.trackGlobal(() => rawList.call(this, options))).filter(item => !adapter.admission.isRetired(item.header.id));\n };\n this.restore.push(() => { instance.stat = rawStat; instance.list = rawList; });\n return async () => {\n await this.admission.drain();\n this.active = false;\n // Retired IDs retain a narrow fail-closed guard after plugin withdrawal.\n // Other IDs continue to use the same original native instance routes.\n if (this.originalRetired()) return;\n for (const undo of [...this.restore].reverse()) undo();\n this.restore.length = 0;\n };\n }\n forceRestore(): void {\n this.detached = true; this.active = false;\n for (const undo of [...this.restore].reverse()) undo();\n this.restore.length = 0;\n }\n private originalRetired(): boolean {\n // Querying the native inventory cannot discover erased IDs; the controller\n // owns the durable tombstone snapshot independently of the closed domain.\n return this.admission.hasTombstones();\n }\n private manage(handle: SessionHandle): SessionHandle {\n if (this.managedHandles.has(handle)) return handle;\n this.managedHandles.add(handle);\n const methods = ['read', 'append', 'flush'] as const;\n for (const name of methods) {\n const original = handle[name];\n Object.defineProperty(handle, name, { configurable: true, writable: true,\n value: (...args: unknown[]) => !this.active && !this.admission.isRetired(handle.id)\n ? Reflect.apply(original, handle, args)\n : this.admission.track(handle.id, async () => Reflect.apply(original, handle, args)) });\n }\n return handle;\n }\n}\n", "import { AsyncLocalStorage } from 'node:async_hooks';\n\nexport class NativeAdmissionError extends Error { readonly code = 'native/session-busy'; }\n\n/** Shared per-target mutation gates and global header/migration read barriers. */\nexport class NativeAdmission {\n private readonly maintenance = new AsyncLocalStorage<{ id: string; active: boolean } | undefined>();\n private readonly acceptedFrames = new AsyncLocalStorage<symbol>();\n private readonly activeAcceptedFrames = new Set<symbol>();\n private readonly held = new Set<string>();\n private readonly released = new Map<string, { promise: Promise<void>; resolve(): void }>();\n private readonly pending = new Map<string, Set<Promise<unknown>>>();\n private readonly globalReads = new Set<Promise<unknown>>();\n private readonly retired = new Set<string>();\n private readonly candidates = new Set<string>();\n private closing = false;\n private failed = false;\n private ready = false;\n\n requiresRecovery(): boolean { return this.failed; }\n activate(): void { this.ready = true; }\n suspend(): void { this.failed = true; }\n beginClose(): void { this.closing = true; }\n isRetired(id: string): boolean { return this.retired.has(id) || (this.failed && this.candidates.has(id)); }\n hasTombstones(): boolean { return this.retired.size > 0 || (this.failed && this.candidates.size > 0); }\n markRetired(id: string): void { this.retired.add(id); }\n private isAcceptedFrame(): boolean { const frame = this.acceptedFrames.getStore(); return frame !== undefined && this.activeAcceptedFrames.has(frame); }\n assertAllowed(id: string): void {\n const maintenance = this.maintenance.getStore();\n if (maintenance?.active && maintenance.id === id && !(this.failed && this.candidates.has(id))) return;\n if (!this.ready || (this.closing && !this.isAcceptedFrame()) || (this.failed && this.candidates.has(id)) || this.retired.has(id)\n || (this.held.has(id) && !this.isAcceptedFrame())) {\n throw new NativeAdmissionError('The session is reserved for retirement or awaiting recovery.');\n }\n }\n bypass<T>(id: string, work: () => T): T {\n const token = { id, active: true };\n try {\n const value = this.maintenance.run(token, work);\n if (value && typeof (value as { then?: unknown }).then === 'function') {\n return Promise.resolve(value).finally(() => { token.active = false; }) as T;\n }\n token.active = false; return value;\n } catch (error) { token.active = false; throw error; }\n }\n withoutBypass<T>(work: () => T): T { return this.maintenance.run(undefined, work); }\n track<T>(id: string, work: () => Promise<T>): Promise<T> {\n this.assertAllowed(id);\n const tasks = this.pending.get(id) ?? new Set<Promise<unknown>>();\n this.pending.set(id, tasks);\n const frame = Symbol('native-accepted-operation');\n this.activeAcceptedFrames.add(frame);\n const task = this.acceptedFrames.run(frame, () => Promise.resolve().then(work));\n tasks.add(task);\n void task.finally(() => {\n this.activeAcceptedFrames.delete(frame);\n tasks.delete(task); if (!tasks.size) this.pending.delete(id);\n }).catch(() => {});\n return task;\n }\n async trackGlobal<T>(work: () => Promise<T>): Promise<T> {\n // Existing global reads may nest target reads; admission waits for the whole\n // accepted frame. New normal scans wait outside the drain set until release.\n if (this.closing && !this.isAcceptedFrame() && !this.maintenance.getStore()?.active) {\n throw new NativeAdmissionError('Native admission is closing.');\n }\n while (this.held.size && !this.maintenance.getStore()?.active && !this.isAcceptedFrame()) {\n await Promise.all([...this.released.values()].map(signal => signal.promise));\n }\n if (!this.ready || (this.closing && !this.isAcceptedFrame() && !this.maintenance.getStore()?.active)) {\n throw new NativeAdmissionError('Native admission is not accepting another request.');\n }\n const frame = Symbol('native-header-read');\n this.activeAcceptedFrames.add(frame);\n const task = this.acceptedFrames.run(frame, () => Promise.resolve().then(work));\n this.globalReads.add(task);\n try { return await task; }\n finally { this.activeAcceptedFrames.delete(frame); this.globalReads.delete(task); }\n }\n async drain(id?: string): Promise<void> {\n for (;;) {\n const tasks = id === undefined ? [...this.pending.values()].flatMap(set => [...set]) : [...(this.pending.get(id) ?? [])];\n tasks.push(...this.globalReads);\n if (!tasks.length) return;\n await Promise.allSettled(tasks);\n }\n }\n async acquire(id: string, recovery = false): Promise<() => void> {\n while (this.held.has(id)) await this.released.get(id)!.promise;\n if (this.failed || this.closing || !this.ready || (!recovery && this.retired.has(id))) {\n throw new NativeAdmissionError('The session cannot enter another retirement scope.');\n }\n let resolve!: () => void;\n const signal = { promise: new Promise<void>(done => { resolve = done; }), resolve: () => resolve() };\n this.held.add(id); this.released.set(id, signal); this.candidates.add(id);\n const release = () => {\n this.held.delete(id); this.released.delete(id); signal.resolve();\n };\n try { await this.drain(id); }\n catch (error) { release(); throw error; }\n let done = false;\n return () => { if (!done) { done = true; release(); } };\n }\n}\n", "import { AsyncLocalStorage } from 'node:async_hooks';\nimport { createHash } from 'node:crypto';\nimport { readdir, realpath, lstat, unlink } from 'node:fs/promises';\nimport type { FileHandle } from 'node:fs/promises';\nimport { openRegularFile, RegularFileRefusal, renameWindowsWriteThrough, syncDirectory } from './platform-files.js';\nimport { dirname, join, resolve } from 'node:path';\nimport type { Context } from '@deepseek-ai/cordis';\nimport { workspaceDomainState, workspaceRecord } from '@deepseek-ai/dsh-workspace';\nimport { z } from 'zod';\nimport type { LifecycleKey, RetirementRequest } from '../operations/retirement.js';\n\nexport interface NativeMetadataAdmission {\n assertAllowed(sessionId: string): void;\n track<T>(sessionId: string, work: () => Promise<T>): Promise<T>;\n trackGlobal<T>(work: () => Promise<T>): Promise<T>;\n isRetired(sessionId: string): boolean;\n bypass<T>(sessionId: string, work: () => T): T;\n withoutBypass<T>(work: () => T): T;\n}\nexport class NativeMetadataRefusal extends Error {\n constructor(readonly code: string, message: string) { super(message); this.name = 'NativeMetadataRefusal'; }\n}\nconst cachePhysicalIdentitySchema = z.object({\n dev: z.string().regex(/^\\d+$/), ino: z.string().regex(/^[1-9]\\d*$/), birthtimeNs: z.string().regex(/^[1-9]\\d*$/),\n}).strict();\nexport const nativeMetadataSnapshotSchema = z.object({\n schemaVersion: z.literal(1), sessionId: z.string().min(1),\n global: z.object({ archived: z.boolean(), pinned: z.boolean() }).strict(),\n workspaces: z.array(z.object({ workspaceId: z.string(), record: workspaceRecord }).strict()),\n cache: z.object({ present: z.boolean(), digest: z.string().nullable(), location: z.string().nullable(),\n documentDigest: z.string().nullable(), memoryDigest: z.string().nullable(), physicalIdentity: cachePhysicalIdentitySchema.optional() }).strict(),\n queryProvider: z.enum(['none', 'sqlite-0.2.0-rc.2', 'sqlite-memory-disabled-0.2.0-rc.2']), queryPath: z.string().nullable(),\n}).strict();\nexport type NativeMetadataSnapshot = z.infer<typeof nativeMetadataSnapshotSchema>;\n\ntype Method = (...args: any[]) => any;\ntype ObjectPort = Record<PropertyKey, any>;\nfunction object(value: unknown): ObjectPort | undefined {\n return value !== null && typeof value === 'object' ? value as ObjectPort : undefined;\n}\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value !== null && typeof value === 'object') return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical((value as Record<string, unknown>)[key])}`).join(',')}}`;\n return JSON.stringify(value);\n}\nfunction digest(value: unknown): string { return createHash('sha256').update(canonical(value)).digest('hex'); }\nconst methods = (port: ObjectPort, names: string[]) => names.every(name => typeof port[name] === 'function');\nconst windowsCacheStagePrefix = '.dsh-session-bin-cache-';\ntype CachePhysicalIdentity = NonNullable<NativeMetadataSnapshot['cache']['physicalIdentity']>;\nfunction physicalIdentity(stat: { dev: bigint; ino: bigint; birthtimeNs: bigint }): CachePhysicalIdentity {\n return { dev: String(stat.dev), ino: String(stat.ino), birthtimeNs: String(stat.birthtimeNs) };\n}\nfunction samePhysicalIdentity(left: CachePhysicalIdentity | undefined, right: CachePhysicalIdentity | undefined): boolean {\n return left !== undefined && right !== undefined && left.dev === right.dev && left.ino === right.ino\n && left.birthtimeNs === right.birthtimeNs;\n}\nfunction cacheStageBasename(snapshot: NativeMetadataSnapshot['cache'], expected: LifecycleKey, request: RetirementRequest): string {\n const value = digest({ schemaVersion: 1, expected, request, cache: snapshot });\n return `${windowsCacheStagePrefix}${value}.stage`;\n}\n\n/** Version-bound metadata participant. The composition verifies package/source\n * fingerprints before open; this adapter additionally checks concrete instance\n * shape. It neither removes files nor writes SQLite rows. */\nexport class NativeMetadataAdapter {\n private readonly targets = new Set<string>();\n private readonly retained = new Map<string, number>();\n private readonly followers = new Map<string, number>();\n private readonly followerStops = new Map<string, Set<() => Promise<void>>>();\n private readonly activationTarget = new AsyncLocalStorage<string>();\n private readonly apiHandles = new Map<string, ObjectPort>();\n private readonly operations = new Map<string, number>();\n private readonly queueTarget = new AsyncLocalStorage<string>();\n private readonly receivers = new AsyncLocalStorage<ObjectPort>();\n private readonly restores: Array<() => void> = [];\n private readonly guardedMethods: Array<{ port: ObjectPort; name: string; replacement: Method }> = [];\n private readonly guardedEntities = new WeakSet<object>();\n private installed = false;\n private disposed = false;\n private detached = false;\n private fallbackRetired = new Set<string>();\n private readonly queryConfiguration: { path: string; openAt: string } | undefined;\n private readonly queryProvider: NativeMetadataSnapshot['queryProvider'];\n private readonly cacheTable: ObjectPort | undefined;\n private readonly cacheDirectory: string | undefined;\n private readonly agents: ObjectPort | undefined;\n private moveCacheDocument = renameWindowsWriteThrough;\n private clearCacheStage = async (handle: FileHandle): Promise<void> => { await handle.truncate(0); await handle.sync(); };\n private removeCacheStage = unlink;\n\n private constructor(private readonly ctx: Context, private readonly admission: NativeMetadataAdmission,\n private readonly workspace: ObjectPort, private readonly sessions: ObjectPort,\n private readonly cache: ObjectPort | undefined, private readonly query: ObjectPort | undefined,\n private readonly controller: ObjectPort | undefined) {\n this.queryConfiguration = query ? { path: query.config.path, openAt: query.config.openAt } : undefined;\n this.queryProvider = !query ? 'none' : query.config.openAt === 'never' ? 'sqlite-memory-disabled-0.2.0-rc.2' : 'sqlite-0.2.0-rc.2';\n this.cacheTable = cache?.requireTable();\n this.cacheDirectory = this.cacheTable?.host.unit.dir;\n this.agents = controller ? NativeMetadataAdapter.get(ctx, 'agents') : undefined;\n }\n\n private static get(ctx: Context, name: string): ObjectPort | undefined {\n const value = object(ctx.get(name));\n return object(value?.[Symbol.for('cordis.original')] ?? value);\n }\n static async open(ctx: Context, admission: NativeMetadataAdmission): Promise<NativeMetadataAdapter | undefined> {\n const workspace = this.get(ctx, 'workspaceRegistry');\n const sessions = this.get(ctx, 'sessions');\n const cache = this.get(ctx, 'sessionProjectionCache');\n const query = this.get(ctx, 'sessionQuery');\n const controller = this.get(ctx, 'sessionController');\n if (!workspace || !sessions || workspace.constructor.name !== 'WorkspaceRegistry' || sessions.constructor.name !== 'SessionStore'\n || !methods(workspace, ['list', 'requireTable', 'requireState', 'setState', 'enqueueOperation', 'indexHeader', 'readSessionHeader'])\n || ![workspace.headers, workspace.sessionPaths, workspace.invalidSessionPaths].every(map => map instanceof Map)\n || !(workspace.missingSessionPaths instanceof Set)\n || !methods(sessions, ['get', 'prepare', 'enter', 'announce'])) return undefined;\n if (cache && (cache.constructor.name !== 'SessionProjectionCache' || !(cache.dirty instanceof Map)\n || !methods(cache, ['put', 'requireTable', 'write', 'coldSnapshot', 'hydratePrepared', 'cachedSnapshot', 'cachedPredecessorTitle']))) return undefined;\n if (cache) {\n const table = cache.requireTable(); const domain = ctx.storageDomain.get('session_projcache') as unknown as ObjectPort | undefined;\n if (table?.constructor.name !== 'KvTableImpl' || table.tableName !== 'sessions' || !(table.records instanceof Map)\n || table.host?.domainName !== 'session_projcache' || table.host.unit?.constructor.name !== 'PerRecordJsonUnit'\n || table.host.unit.descriptor?.name !== 'session_projcache' || table.host.unit.descriptor.version !== 7\n || table.host.unit.descriptor.layout !== 'per-record' || typeof table.host.unit.dir !== 'string'\n || !methods(table.host, ['enqueue', 'emitChanged', 'assertReadable'])\n || !methods(table.host.unit, ['loadAll', 'deleteRecord', 'tableDir']) || domain?.unit !== table.host.unit) return undefined;\n }\n if (query) {\n const enabled = ['startup', 'first-search'].includes(query.config?.openAt);\n const disabledMemory = query.config?.openAt === 'never' && query.config.path === ':memory:'\n && query._db === undefined && query._ready === undefined;\n if (query.constructor.name !== 'SqliteSessionQueryEngine' || (!enabled && !disabledMemory)\n || typeof query.config?.path !== 'string'\n || !methods(query, ['searchSessions', 'listSessions', 'observeSession', '_serialized']) || !(query._observations?.cache instanceof Map)\n || !methods(query._observations, ['read', 'store'])) return undefined;\n }\n if (controller && (controller.constructor.name !== 'SessionController' || !(controller.history?.closeFollowers instanceof Set)\n || !methods(controller.history, ['page', 'follow', 'sourceFor'])\n || controller.agents?.constructor.name !== 'ApiSessionAgentController'\n || !methods(controller.agents, ['resumeObserved', 'claim', 'createAgent'])\n || !methods(controller.listState ?? {}, ['summarizeCold'])\n || !methods(this.get(ctx, 'agents') ?? {}, ['create', 'resume', 'get']))) return undefined;\n return new NativeMetadataAdapter(ctx, admission, workspace, sessions, cache, query, controller);\n }\n private assert(id: string): void {\n this.targets.add(id);\n if (this.disposed) {\n if (this.fallbackRetired.has(id)) throw new NativeMetadataRefusal('native/retired', 'This retired session remains fenced after adapter withdrawal.');\n return;\n }\n this.admission.assertAllowed(id);\n }\n private tracked<T>(id: string, work: () => Promise<T>): Promise<T> {\n this.targets.add(id);\n if (this.disposed) { this.assert(id); return work(); }\n return this.admission.trackGlobal(() => this.admission.track(id, async () => {\n this.assert(id);\n this.increment(this.operations, id, 1);\n try { return await work(); }\n finally { this.increment(this.operations, id, -1); }\n }));\n }\n private increment(map: Map<string, number>, id: string, delta: number): void {\n const next = (map.get(id) ?? 0) + delta;\n if (next === 0) map.delete(id); else map.set(id, next);\n }\n private refuse(code: string, message: string): never { throw new NativeMetadataRefusal(code, message); }\n private assertInstances(): void {\n if (this.guardedMethods.some(({ port, name, replacement }) => port[name] !== replacement)) {\n this.refuse('native/guard-replaced', 'A native metadata admission guard was replaced.');\n }\n if (NativeMetadataAdapter.get(this.ctx, 'workspaceRegistry') !== this.workspace\n || NativeMetadataAdapter.get(this.ctx, 'sessions') !== this.sessions\n || NativeMetadataAdapter.get(this.ctx, 'sessionProjectionCache') !== this.cache\n || NativeMetadataAdapter.get(this.ctx, 'sessionQuery') !== this.query\n || NativeMetadataAdapter.get(this.ctx, 'sessionController') !== this.controller\n || (this.controller && NativeMetadataAdapter.get(this.ctx, 'agents') !== this.agents)\n || (this.cache && (this.cache.requireTable() !== this.cacheTable || this.cacheTable!.host.unit.dir !== this.cacheDirectory))\n || (this.query && (this.query.config.path !== this.queryConfiguration!.path\n || this.query.config.openAt !== this.queryConfiguration!.openAt))\n || (this.queryProvider === 'sqlite-memory-disabled-0.2.0-rc.2' && (this.query!._db !== undefined || this.query!._ready !== undefined))) {\n this.refuse('native/composition-changed', 'Native metadata service composition changed.');\n }\n }\n private assertCold(id: string): void {\n if (this.sessions.get(id) !== undefined || NativeMetadataAdapter.get(this.ctx, 'agents')?.get(id) !== undefined) {\n this.refuse('native/session-live', 'Native deletion currently accepts only cold sessions.');\n }\n const cached = this.query?._observations.cache.get(id);\n if (cached?.refs > 0 || (this.retained.get(id) ?? 0) > 0) this.refuse('native/query-retained', 'A retained query observation still owns this session.');\n if ((this.followers.get(id) ?? 0) > 0) this.refuse('native/follow-retained', 'A history follower still owns this session.');\n // Followers predating install have no target key in this SDK. Refuse rather\n // than closing unrelated streams or assuming that removed disposed them.\n const knownFollowers = [...this.followers.values()].reduce((sum, count) => sum + count, 0);\n if ((this.controller?.history.closeFollowers.size ?? 0) > knownFollowers) this.refuse('native/unknown-follow', 'A history follower predates native admission tracking.');\n if (this.cache && [...this.cache.dirty.keys()].some(session => session.id === id)) this.refuse('native/cache-dirty', 'Target cache write-behind is not quiescent.');\n }\n /** Explicit deletion preparation may unload an idle API-owned lifecycle.\n * No bare registry Agent, foreign handle, or unknown reader is disposed. */\n async releaseIdle(id: string): Promise<void> {\n this.assertInstances();\n const handle = this.apiHandles.get(id);\n if (!handle) return;\n const agent = handle.agent;\n const registry = this.agents!;\n if (registry.get(id) !== agent || this.sessions.get(id) !== agent.session) return;\n const activity = await this.admission.withoutBypass(() => this.ctx.waterfall('workspace/session-activity',\n { sessionId: id as never }, async () => []));\n // Inspect after the asynchronous activity query; dispose starts in this\n // same synchronous turn, before another activation can be admitted.\n if (activity.length || agent.constructor.name !== 'ReactLoopAgent' || agent.phase?.kind !== 'idle'\n || agent.status !== 'idle' || !Array.isArray(agent.inbox?.nextTurn)\n || !Array.isArray(agent.inbox?.nextStep) || agent.inbox.nextTurn.length || agent.inbox.nextStep.length) {\n this.refuse('native/session-active', 'Native deletion refuses active or queued work.');\n }\n if (!this.workspace.archivedSessionIds.includes(id)) this.refuse('native/not-archived', 'Only an archived target may be unloaded.');\n if (registry.get(id) !== agent || this.sessions.get(id) !== agent.session) this.refuse('native/session-live', 'The API lifecycle changed.');\n await this.admission.bypass(id, async () => {\n await handle.dispose();\n for (const stop of [...(this.followerStops.get(id) ?? [])]) await stop();\n // Disposal checkpoints projections asynchronously. Join its actual put\n // operations and the durable table queue before taking the cold snapshot.\n if (this.cache) await this.cache.requireTable().host.enqueue(async () => undefined);\n const summary = this.controller!.listState.summarizeCold({ header: agent.session.header });\n this.admission.withoutBypass(() => (this.ctx.emit as Method)('api-session/added', summary));\n });\n this.apiHandles.delete(id);\n }\n private async cacheView(table: ObjectPort, id: string, acceptedStage?: string): Promise<NativeMetadataSnapshot['cache']> {\n table.host.assertReadable();\n if (!/^[a-zA-Z0-9_-]+$/.test(id)) this.refuse('native/cache-key-unsupported', 'The pinned cache backend cannot own this record key.');\n const directory = resolve(table.host.unit.dir);\n // The pinned PerRecordJsonUnit bootstraps an empty tree from this retained\n // whole-unit file on every OS. Never certify erasure while that source exists.\n const legacyPath = join(dirname(directory), `${table.host.unit.descriptor.name}.json`);\n try {\n await lstat(legacyPath);\n this.refuse('native/cache-unclassified-resource', 'A legacy whole-unit cache could republish the retired target document.');\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n let location: string;\n try { location = await realpath(directory); }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n location = join(await realpath(dirname(directory)), 'session_projcache');\n }\n const tableDirectory: string = table.host.unit.tableDir('sessions');\n let names: string[];\n try { names = await readdir(tableDirectory); }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; names = []; }\n if (names.some(name => name.startsWith(`${id}.json.bak.`) || /^\\.[a-f0-9-]+\\.tmp$/.test(name)\n || (name.startsWith(windowsCacheStagePrefix) && name !== acceptedStage))) {\n this.refuse('native/cache-unclassified-resource', 'A cache backup or unclassified staging document prevents complete target erasure.');\n }\n let documentDigest: string | null = null;\n let documentIdentity: CachePhysicalIdentity | undefined;\n const path = join(tableDirectory, `${id}.json`);\n try {\n let handle;\n try { handle = await openRegularFile(path, 'read'); }\n catch (error) {\n if (error instanceof RegularFileRefusal) this.refuse(error.code === 'platform/unsafe-file' ? 'native/cache-unsafe-document' : 'native/cache-document-changed', error.message);\n throw error;\n }\n try {\n const before = await handle.stat({ bigint: true });\n const bytes = await handle.readFile();\n const after = await handle.stat({ bigint: true });\n const current = await lstat(path, { bigint: true });\n if (!current.isFile() || before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size\n || before.birthtimeNs !== after.birthtimeNs || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs\n || after.nlink !== 1n || after.dev !== current.dev || after.ino !== current.ino\n || after.birthtimeNs !== current.birthtimeNs || after.size !== current.size\n || after.mtimeNs !== current.mtimeNs || after.ctimeNs !== current.ctimeNs) {\n this.refuse('native/cache-document-changed', 'The physical cache document changed while observing its bytes.');\n }\n documentDigest = createHash('sha256').update(bytes).digest('hex');\n if (process.platform === 'win32') documentIdentity = physicalIdentity(after);\n } finally { await handle.close(); }\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n const memory = table.records.get(id);\n const memoryDigest = memory === undefined ? null : digest(memory);\n const present = documentDigest !== null || memoryDigest !== null;\n return { present, digest: present ? digest({ documentDigest, memoryDigest }) : null,\n location, documentDigest, memoryDigest, ...(documentIdentity ? { physicalIdentity: documentIdentity } : {}) };\n }\n private async openCacheDocument(path: string, access: 'read' | 'write'): Promise<FileHandle> {\n try { return await openRegularFile(path, access); }\n catch (error) {\n if (error instanceof RegularFileRefusal) this.refuse(error.code === 'platform/unsafe-file' ? 'native/cache-unsafe-document' : 'native/cache-document-changed', error.message);\n throw error;\n }\n }\n private async pathAbsent(path: string): Promise<boolean> {\n try { await lstat(path); return false; }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return true; throw error; }\n }\n private async frozenCacheBytes(handle: FileHandle, snapshot: NativeMetadataSnapshot['cache'], allowCleared: boolean): Promise<boolean> {\n const before = await handle.stat({ bigint: true });\n if (!before.isFile() || before.nlink !== 1n || !samePhysicalIdentity(physicalIdentity(before), snapshot.physicalIdentity)) return false;\n const bytes = await handle.readFile();\n const after = await handle.stat({ bigint: true });\n if (before.dev !== after.dev || before.ino !== after.ino || before.birthtimeNs !== after.birthtimeNs\n || before.size !== after.size || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs || after.nlink !== 1n) return false;\n return allowCleared && bytes.length === 0\n || snapshot.documentDigest !== null && createHash('sha256').update(bytes).digest('hex') === snapshot.documentDigest;\n }\n private async eraseWindowsCache(snapshot: NativeMetadataSnapshot['cache'], id: string,\n expected: LifecycleKey, request: RetirementRequest, table: ObjectPort): Promise<boolean> {\n if (snapshot.documentDigest !== null && snapshot.physicalIdentity === undefined) return false;\n if (snapshot.documentDigest === null && snapshot.physicalIdentity !== undefined) return false;\n const tableDirectory: string = table.host.unit.tableDir('sessions');\n const originalPath = join(tableDirectory, `${id}.json`);\n const stageName = cacheStageBasename(snapshot, expected, request);\n const stagePath = join(tableDirectory, stageName);\n const current = await this.cacheView(table, id, stageName);\n if (current.location !== snapshot.location || (current.documentDigest !== null && current.documentDigest !== snapshot.documentDigest)\n || (current.memoryDigest !== null && current.memoryDigest !== snapshot.memoryDigest)\n || (!snapshot.present && current.present)) return false;\n let originalAbsent = await this.pathAbsent(originalPath);\n let stageAbsent = await this.pathAbsent(stagePath);\n if (!originalAbsent && !stageAbsent) return false;\n if (!originalAbsent) {\n if (snapshot.physicalIdentity === undefined || current.documentDigest !== snapshot.documentDigest\n || !samePhysicalIdentity(current.physicalIdentity, snapshot.physicalIdentity)) return false;\n let handle: FileHandle;\n try { handle = await this.openCacheDocument(originalPath, 'write'); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false; throw error; }\n try {\n if (!await this.frozenCacheBytes(handle, snapshot, false)) return false;\n try { await this.moveCacheDocument(originalPath, stagePath); }\n catch (error) {\n if (['EEXIST', 'EXDEV', 'ENOENT'].includes((error as NodeJS.ErrnoException).code ?? '')) return false;\n throw error;\n }\n } finally { await handle.close(); }\n originalAbsent = await this.pathAbsent(originalPath);\n stageAbsent = await this.pathAbsent(stagePath);\n if (!originalAbsent || stageAbsent) return false;\n }\n if (!stageAbsent) {\n let handle: FileHandle;\n try { handle = await this.openCacheDocument(stagePath, 'write'); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false; throw error; }\n try {\n if (!await this.frozenCacheBytes(handle, snapshot, true)) return false;\n await this.clearCacheStage(handle);\n } finally { await handle.close(); }\n await this.removeCacheStage(stagePath);\n if (!await this.pathAbsent(stagePath)) return false;\n }\n if (!await this.pathAbsent(originalPath) || !await this.pathAbsent(stagePath)) return false;\n table.records.delete(id);\n this.admission.withoutBypass(() => table.host.emitChanged({ domain: table.host.domainName, table: 'sessions', key: id, operation: 'deleted' }));\n const final = await this.cacheView(table, id, stageName);\n return final.location === snapshot.location && !final.present && await this.pathAbsent(stagePath);\n }\n private async eraseCache(snapshot: NativeMetadataSnapshot['cache'], id: string,\n expected: LifecycleKey, request: RetirementRequest): Promise<boolean> {\n const table = this.cacheTable;\n if (!table) return !snapshot.present && snapshot.location === null;\n return table.host.enqueue(async () => {\n if (process.platform === 'win32') return this.eraseWindowsCache(snapshot, id, expected, request, table);\n const current = await this.cacheView(table, id);\n if (current.location !== snapshot.location || (current.documentDigest !== null && current.documentDigest !== snapshot.documentDigest)\n || (current.memoryDigest !== null && current.memoryDigest !== snapshot.memoryDigest)\n || (!snapshot.present && current.present)) return false;\n // KvTable.delete skips the medium when memory lacks the key. This owner\n // endpoint must remove the exact record document even after lost put ack.\n await table.host.unit.deleteRecord('sessions', id);\n const tableDirectory: string = table.host.unit.tableDir('sessions');\n try { await syncDirectory(tableDirectory); }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n table.records.delete(id);\n this.admission.withoutBypass(() => table.host.emitChanged({ domain: table.host.domainName, table: 'sessions', key: id, operation: 'deleted' }));\n const final = await this.cacheView(table, id);\n return final.location === snapshot.location && !final.present;\n });\n }\n async capture(sessionId: string): Promise<NativeMetadataSnapshot> {\n return this.admission.bypass(sessionId, () => this.captureInner(sessionId));\n }\n private async captureInner(sessionId: string): Promise<NativeMetadataSnapshot> {\n this.targets.add(sessionId);\n this.assertInstances(); this.assertCold(sessionId);\n const activity = await this.admission.withoutBypass(() => this.ctx.waterfall('workspace/session-activity',\n { sessionId: sessionId as never }, async () => []));\n if (activity.length !== 0) this.refuse('native/session-active', 'Native deletion refuses active work.');\n this.assertCold(sessionId);\n const domain = this.ctx.storageDomain.get('workspace');\n if (!domain) throw new Error('Native workspace domain is unavailable.');\n const global = workspaceDomainState.parse(domain.global.get());\n if (!global.archivedSessionIds.some(id => id === sessionId)) this.refuse('native/not-archived', 'Native metadata preparation requires an archived session.');\n const workspaces: NativeMetadataSnapshot['workspaces'] = [];\n for (const [workspaceId, raw] of this.workspace.requireTable().entries()) {\n const record = workspaceRecord.parse(raw);\n if (!record.sessionIds.some(id => id === sessionId)) continue;\n if (record.sessionIds.some(id => id !== sessionId && this.workspace.sessionPaths.get(id) !== record.path\n && !this.workspace.missingSessionPaths.has(id))) {\n this.refuse('native/workspace-pruning-required', 'Target removal would prune an unrelated Workspace candidate.');\n }\n workspaces.push({ workspaceId, record });\n }\n const cache = this.cacheTable ? await this.cacheTable.host.enqueue(() => this.cacheView(this.cacheTable!, sessionId))\n : { present: false, digest: null, location: null, documentDigest: null, memoryDigest: null };\n return nativeMetadataSnapshotSchema.parse({ schemaVersion: 1, sessionId,\n global: { archived: global.archivedSessionIds.includes(sessionId as never), pinned: global.pinnedSessionIds.includes(sessionId as never) },\n workspaces, cache,\n queryProvider: this.queryProvider, queryPath: this.queryConfiguration?.path ?? null });\n }\n private wrap(port: ObjectPort, name: string, replace: (original: Method) => Method): void {\n const descriptor = Object.getOwnPropertyDescriptor(port, name);\n const original: Method = port[name];\n const adapter = this;\n const guarded = replace((...args: unknown[]) => Reflect.apply(original, adapter.receivers.getStore() ?? port, args));\n const replacement = function (this: ObjectPort, ...args: unknown[]) {\n if (adapter.detached) throw new NativeMetadataRefusal('native/stale-reference', 'Reacquire native methods after retirement adapter takeover.');\n return adapter.receivers.run(this, () => guarded(...args));\n };\n Object.defineProperty(port, name, { configurable: true, writable: true, value: replacement });\n this.guardedMethods.push({ port, name, replacement });\n this.restores.push(() => {\n if (port[name] !== replacement) throw new Error(`Native metadata guard ${name} was replaced before withdrawal.`);\n if (descriptor) Object.defineProperty(port, name, descriptor); else delete port[name];\n });\n }\n private guardEntity(entity: ObjectPort): void {\n if (this.guardedEntities.has(entity)) return;\n this.guardedEntities.add(entity);\n this.wrap(entity, 'attachSession', original => (id: string) => this.tracked(id, async () => {\n const result = await original(id); this.assert(id); return result;\n }));\n }\n private guardedObservation(id: string, observation: ObjectPort): ObjectPort {\n this.increment(this.retained, id, 1);\n let disposed = false;\n return new Proxy(observation, { get: (target, property) => {\n if (property === Symbol.dispose) return () => {\n if (disposed) return;\n disposed = true;\n try { target[Symbol.dispose](); }\n finally { this.increment(this.retained, id, -1); }\n };\n if (property === 'retain') return () => { this.assert(id); return this.guardedObservation(id, target.retain()); };\n if (property === 'events' || property === 'projections') this.assert(id);\n return Reflect.get(target, property, target);\n } });\n }\n async install(): Promise<() => Promise<void>> {\n if (this.installed) throw new Error('Native metadata adapter is already installed.');\n this.assertInstances(); this.installed = true;\n try {\n for (const name of ['workspace', ...(this.cache ? ['session_projcache'] : [])]) {\n const domain = this.ctx.storageDomain.get(name) as unknown as ObjectPort | undefined;\n if (!domain || domain.constructor.name !== 'DomainImpl' || !methods(domain, ['emitChanged'])) {\n throw new Error('Native metadata domain publication shape changed.');\n }\n this.wrap(domain, 'emitChanged', original => (change: unknown) => this.admission.withoutBypass(() => original(change)));\n }\n for (const name of ['archiveSession', 'unarchiveSession', 'pinSession', 'unpinSession']) {\n this.wrap(this.workspace, name, original => (id: string, ...args: unknown[]) => this.tracked(id,\n () => this.queueTarget.run(id, async () => original(id, ...args))));\n }\n this.wrap(this.workspace, 'enqueueOperation', original => (operation: () => Promise<unknown>) => {\n const id = this.queueTarget.getStore();\n return original(async () => { if (id !== undefined) this.assert(id); return operation(); });\n });\n this.wrap(this.workspace, 'setState', original => async (next: ObjectPort) => {\n const id = this.queueTarget.getStore();\n if (id !== undefined) this.assert(id);\n return original(next);\n });\n this.wrap(this.workspace, 'indexHeader', original => (header: ObjectPort) => this.tracked(header.id, async () => {\n const result = await original(header); this.assert(header.id); return result;\n }));\n this.wrap(this.workspace, 'readSessionHeader', original => (id: string) => this.tracked(id, async () => {\n const result = await original(id); this.assert(id); return result;\n }));\n for (const entity of this.workspace.list()) this.guardEntity(entity);\n for (const name of ['create', 'initializeDefault']) this.wrap(this.workspace, name, original => async (...args: unknown[]) => {\n const entity = await original(...args); if (entity) this.guardEntity(entity); return entity;\n });\n this.wrap(this.sessions, 'prepare', original => (id: string | undefined, ...args: unknown[]) => {\n if (id !== undefined) this.assert(id);\n const session = original(id, ...args); this.assert(session.id); return session;\n });\n for (const name of ['enter', 'announce']) this.wrap(this.sessions, name, original => (session: ObjectPort) => {\n this.assert(session.id); return original(session);\n });\n if (this.cache) {\n this.wrap(this.cache, 'put', original => (id: string, ...args: unknown[]) => this.tracked(id, async () => original(id, ...args)));\n for (const name of ['cachedSnapshot', 'cachedPredecessorTitle', 'coldSnapshot']) this.wrap(this.cache, name,\n original => (header: ObjectPort, ...args: unknown[]) => { this.assert(header.id); return original(header, ...args); });\n this.wrap(this.cache, 'hydratePrepared', original => (session: ObjectPort, ...args: unknown[]) => {\n this.assert(session.id); return original(session, ...args);\n });\n }\n if (this.query) {\n this.wrap(this.query, '_serialized', original => (signal: AbortSignal | undefined, operation: () => Promise<unknown>) =>\n this.admission.trackGlobal(async () => original(signal, operation)));\n this.wrap(this.query._observations, 'read', original => (id: string, ...args: unknown[]) => this.tracked(id, async () => {\n const observation = await original(id, ...args);\n try { this.assert(id); return this.guardedObservation(id, observation); }\n catch (error) { observation[Symbol.dispose](); throw error; }\n }));\n this.wrap(this.query._observations, 'store', original => (id: string, ...args: unknown[]) => { this.assert(id); return original(id, ...args); });\n for (const name of ['readSession', 'readTitle', 'readTitleSnapshot', 'listEvents', 'filterEvents', 'readSurface', 'traceSession']) {\n if (typeof this.query[name] === 'function') this.wrap(this.query, name, original => (id: string, ...args: unknown[]) =>\n this.tracked(id, async () => { const result = await original(id, ...args); this.assert(id); return result; }));\n }\n for (const name of ['searchEvents', 'readEvent', 'traceEvent']) if (typeof this.query[name] === 'function') {\n this.wrap(this.query, name, original => (request: ObjectPort, ...args: unknown[]) => this.tracked(request.sessionId,\n async () => { const result = await original(request, ...args); this.assert(request.sessionId); return result; }));\n }\n }\n if (this.controller) {\n const adapter = this;\n // API Session drops the returned AgentHandle after activation. Retain\n // that exact disposal capability only inside its matching target call.\n for (const name of ['resumeObserved', 'claim', 'createAgent']) {\n this.wrap(this.controller.agents, name, original => (id: string, ...args: unknown[]) =>\n this.tracked(id, () => this.activationTarget.run(id, async () => original(id, ...args))));\n }\n const agents = this.agents!;\n for (const name of ['create', 'resume']) {\n this.wrap(agents, name, original => (options: ObjectPort, ...args: unknown[]) => {\n const id = String(name === 'create' ? options.sessionId : options.resumeSessionId);\n return this.tracked(id, async () => {\n const handle = await original(options, ...args);\n if (this.activationTarget.getStore() === id && options.parentAgent === undefined\n && handle.agent.id === id && handle.agent.session.header.origin !== 'subagent'\n && typeof handle.dispose === 'function') this.apiHandles.set(id, handle);\n return handle;\n });\n });\n }\n this.restores.push((this.ctx.on as Method)('agent/disposed', ({ agent }: { agent: ObjectPort }) => {\n if (this.apiHandles.get(agent.id)?.agent === agent) this.apiHandles.delete(agent.id);\n }, { global: true }));\n this.wrap(this.controller.history, 'follow', original => function (request: ObjectPort, signal: AbortSignal) {\n const id = String(request.address.sessionId);\n adapter.assert(id);\n return (async function* () {\n adapter.assert(id); adapter.increment(adapter.followers, id, 1);\n const cancellation = new AbortController();\n const iterator = original(request, AbortSignal.any([signal, cancellation.signal]));\n const stops = adapter.followerStops.get(id) ?? new Set<() => Promise<void>>();\n adapter.followerStops.set(id, stops);\n let finished = false;\n const finish = () => {\n if (finished) return;\n finished = true;\n adapter.increment(adapter.followers, id, -1);\n stops.delete(stop); if (!stops.size) adapter.followerStops.delete(id);\n };\n const stop = async () => { cancellation.abort(); await iterator.return(); finish(); };\n stops.add(stop);\n try { for await (const frame of iterator) { adapter.assert(id); yield frame; } }\n finally { finish(); }\n })();\n });\n }\n } catch (error) {\n for (const restore of [...this.restores].reverse()) restore();\n this.restores.length = 0; this.installed = false; throw error;\n }\n let closing: Promise<void> | undefined;\n return () => closing ??= (async () => {\n this.fallbackRetired = new Set([...this.targets].filter(id => this.admission.isRetired(id)));\n this.disposed = true;\n this.apiHandles.clear();\n if (this.fallbackRetired.size === 0) {\n for (const restore of [...this.restores].reverse()) restore();\n this.restores.length = 0;\n }\n })();\n }\n /** The verified owner completes all asynchronous takeover work before this\n * synchronous restoration and installs its successor guards without yielding. */\n forceRestore(): void {\n if (this.restores.length && this.guardedMethods.some(({ port, name, replacement }) => port[name] !== replacement)) {\n throw new Error('Native metadata guards changed before trusted takeover.');\n }\n this.detached = true; this.disposed = true;\n for (const restore of [...this.restores].reverse()) restore();\n this.restores.length = 0; this.guardedMethods.length = 0; this.fallbackRetired.clear(); this.apiHandles.clear();\n }\n async converge(input: NativeMetadataSnapshot, expected: LifecycleKey, request: RetirementRequest): Promise<boolean> {\n const snapshot = nativeMetadataSnapshotSchema.parse(input);\n const id = snapshot.sessionId;\n this.targets.add(id); this.assertInstances();\n if (snapshot.queryProvider !== this.queryProvider\n || snapshot.queryPath !== (this.queryConfiguration?.path ?? null)) return false;\n if (id !== expected.sessionId || id !== request.expected.sessionId || expected.storeId !== request.expected.storeId\n || expected.lifecycleId !== request.expected.lifecycleId || !this.admission.isRetired(id)) {\n this.refuse('native/maintenance-binding-changed', 'Native convergence requires the exact durable retirement binding.');\n }\n if ((this.operations.get(id) ?? 0) > 0 || (this.retained.get(id) ?? 0) > 0 || (this.followers.get(id) ?? 0) > 0) return false;\n this.assertCold(id);\n return this.admission.bypass(id, async () => {\n if (!await this.eraseCache(snapshot.cache, id, expected, request)) return false;\n this.query?._observations.cache.delete(id);\n const frozenIds = new Set(snapshot.workspaces.map(item => item.workspaceId));\n const convergeWorkspace = async () => {\n for (const [workspaceId, raw] of this.workspace.requireTable().entries()) {\n const record = workspaceRecord.parse(raw);\n if (!record.sessionIds.some(sessionId => sessionId === id)) continue;\n if (!frozenIds.has(workspaceId) || record.sessionIds.some(other => other !== id\n && this.workspace.sessionPaths.get(other) !== record.path && !this.workspace.missingSessionPaths.has(other))) return false;\n const entity = this.workspace.get(workspaceId);\n if (!entity) throw new Error('Native Workspace account lost its runtime entity.');\n await entity.detachSession(id);\n }\n const state = workspaceDomainState.parse(this.workspace.requireState());\n if (state.archivedSessionIds.includes(id as never) || state.pinnedSessionIds.includes(id as never)) {\n await this.workspace.setState({ ...state,\n archivedSessionIds: state.archivedSessionIds.filter(other => other !== id),\n pinnedSessionIds: state.pinnedSessionIds.filter(other => other !== id) });\n }\n this.workspace.headers.delete(id); this.workspace.sessionPaths.delete(id); this.workspace.invalidSessionPaths.delete(id);\n this.workspace.missingSessionPaths.delete(id);\n return true;\n };\n if (!await this.workspace.enqueueOperation(convergeWorkspace)) return false;\n if (this.query) {\n if (this.queryProvider === 'sqlite-0.2.0-rc.2') {\n await this.query.searchSessions({ query: 'native-retirement-reconciliation', limit: 1 });\n }\n if ((await this.query.listSessions()).some((record: ObjectPort) => record.header.id === id)) return false;\n this.assertInstances();\n }\n // This is a presentation edge only. Resource completion comes from the\n // owner journal and query/Workspace confirmations above.\n this.admission.withoutBypass(() => (this.ctx.emit as Method)('api-session/removed', id));\n return true;\n });\n }\n}\n", "import { AsyncLocalStorage } from 'node:async_hooks';\nimport { z } from 'zod';\nimport {\n lifecycleEqual, lifecycleKeySchema, retirementAuthorizationSchema, retirementCapabilitiesSchema,\n retirementManifestSchema, retirementParticipantSchema, retirementRequestSchema,\n retirementResourceReceiptSchema, retirementResourceSchema, retirementStateSchema,\n} from '../operations/retirement.js';\nimport type {\n LifecycleKey, RetirementAuthorization, RetirementCapabilities, RetirementManifest, RetirementRequest, RetirementState,\n} from '../operations/retirement.js';\nimport { retirementOwnerRecordSchema } from '../operations/retirement-owner.js';\nimport type { RetirementOwnerRecord } from '../operations/retirement-owner.js';\nimport type { SessionRetirementOwnerV1 } from './retirement.js';\nimport { retirementManifestDigest } from './retirement.js';\nimport { sameRetirementCapabilities } from './retirement-owner-store.js';\nimport type { RetirementOwnerStore } from './retirement-owner-store.js';\n\nexport type RetirementResource = z.infer<typeof retirementResourceSchema>;\nexport type RetirementResourceReceipt = z.infer<typeof retirementResourceReceiptSchema>;\nexport interface RetirementOwnerGuards {\n /** Synchronous checks apply to retained handles and late writes as well as new opens. */\n assertCanUse(lifecycle: LifecycleKey): void;\n assertCanCreate(sessionId: string): void;\n}\nexport interface RetirementLifecycleScope {\n readonly lifecycle: LifecycleKey;\n current(): Promise<LifecycleKey | null>;\n activity(): Promise<string[]>;\n /** false acknowledges a known pending barrier; throws mean unknown outcome. */\n quiesce(request: RetirementRequest): Promise<boolean>;\n finalize(request: RetirementRequest): Promise<boolean>;\n release(): Promise<void>;\n}\nexport interface RetirementLifecyclePort {\n inspect(sessionId: string): Promise<LifecycleKey | null>;\n /** Teardown disables these routes/retained references, rather than making them unguarded. */\n bindGuards(guards: RetirementOwnerGuards): Promise<() => Promise<void>>;\n /** A saved record grants maintenance access to exactly its retired lifecycle.\n * Recovery must work after transcript removal/finalization without create/resume.\n * Every acquire must restore current runtime exclusion/reservations for all\n * participants; persisted quiescence acknowledgements are not live leases. */\n acquire(expected: LifecycleKey, maintenance: RetirementOwnerRecord | null): Promise<RetirementLifecycleScope>;\n}\nexport interface RetirementResourceParticipant {\n readonly identity: { id: string; version: string };\n bindGuards(guards: RetirementOwnerGuards): Promise<() => Promise<void>>;\n manifest(expected: LifecycleKey): Promise<RetirementResource[]>;\n fence(request: RetirementRequest): Promise<boolean>;\n quiesce(request: RetirementRequest): Promise<boolean>;\n /** Exact operation/resource/revision actions and all barriers are idempotent. */\n applyResource(request: RetirementRequest, resource: RetirementResource): Promise<RetirementResourceReceipt>;\n converge(request: RetirementRequest): Promise<boolean>;\n}\nexport interface RetirementOwnerCheckpoint {\n request: RetirementRequest;\n manifest: RetirementManifest;\n record: RetirementOwnerRecord | null;\n resource: RetirementResource | null;\n}\nexport interface RetirementOwnerCoordinatorOptions {\n capabilities: RetirementCapabilities;\n store: RetirementOwnerStore;\n lifecycle: RetirementLifecyclePort;\n participants: readonly RetirementResourceParticipant[];\n /** A bounded worker may pause only after a durable acknowledgement; the fence remains. */\n canAdvance?: (record: RetirementOwnerRecord) => boolean;\n checkpoint?: (name: string, context: RetirementOwnerCheckpoint) => Promise<void> | void;\n}\nexport class RetirementOwnerError extends Error {\n constructor(readonly code: string, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RetirementOwnerError';\n }\n}\nfunction requestEqual(a: RetirementRequest, b: RetirementRequest): boolean {\n return a.operationId === b.operationId && lifecycleEqual(a.expected, b.expected)\n && a.bin.entryId === b.bin.entryId && a.bin.entryVersion === b.bin.entryVersion && a.manifestDigest === b.manifestDigest;\n}\nfunction refused(phase: RetirementState['phase']): boolean { return phase === 'rejected' || phase === 'conflict'; }\nfunction resourceOrder(a: RetirementResource, b: RetirementResource): number {\n const dispositions = ['release-reference', 'erase', 'retain-shared', 'retain-coordination'];\n const rank = dispositions.indexOf(a.disposition) - dispositions.indexOf(b.disposition);\n const first = JSON.stringify([a.ownerId, a.resourceId]);\n const second = JSON.stringify([b.ownerId, b.resourceId]);\n return rank || (first < second ? -1 : first > second ? 1 : 0);\n}\n\n/** Provider-neutral owner machinery. Ports must own the actual resources and\n * admission paths; this class supplies no native deletion or private-file adapter. */\nexport class RetirementOwnerCoordinator implements SessionRetirementOwnerV1 {\n private readonly descriptor: RetirementCapabilities;\n private readonly participants: readonly RetirementResourceParticipant[];\n private tail: Promise<unknown> = Promise.resolve();\n private failure: Error | undefined;\n private ready = false;\n private readonly frames = new AsyncLocalStorage<symbol>();\n private readonly activeFrames = new Set<symbol>();\n private readonly observations = new Set<Promise<unknown>>();\n private closing = false;\n private initializing: Promise<void> | undefined;\n private closePromise: Promise<void> | undefined;\n private readonly disposers: Array<() => Promise<void>> = [];\n private readonly expectedErrors = new WeakSet<Error>();\n readonly guards: RetirementOwnerGuards;\n\n constructor(private readonly options: RetirementOwnerCoordinatorOptions) {\n this.descriptor = retirementCapabilitiesSchema.parse(options.capabilities);\n this.participants = [...options.participants];\n this.verifyParticipants();\n this.validateJournal();\n this.guards = Object.freeze({\n assertCanUse: (input: LifecycleKey) => {\n this.requireReady();\n this.assertUnfenced(lifecycleKeySchema.parse(input));\n },\n assertCanCreate: (sessionId: string) => {\n this.requireReady();\n if (this.records().some(record => !refused(record.state.phase) && record.state.phase !== 'done'\n && record.state.request.expected.sessionId === sessionId)) {\n throw this.known('owner/session-fenced', 'An unfinished retirement fences this session identity.');\n }\n },\n });\n }\n initialize(): Promise<void> {\n if (this.closing) return Promise.reject(this.unavailable());\n return this.initializing ??= (async () => {\n try {\n await this.call('Owner journal capability binding', () => this.options.store.bindCapabilities(this.capabilitiesSnapshot()));\n this.validateJournal();\n const bind = async (work: () => Promise<() => Promise<void>>) => {\n const dispose = await this.call('Owner guard registration', work, false, false);\n if (typeof dispose !== 'function') throw new Error('Owner guard registration did not provide route teardown.');\n this.disposers.push(dispose);\n this.assertHealthy();\n if (this.closing) throw this.unavailable();\n };\n await bind(() => this.options.lifecycle.bindGuards(this.guards));\n for (const participant of this.participants) await bind(() => participant.bindGuards(this.guards));\n this.verifyParticipants();\n this.ready = true;\n } catch (error) {\n this.rememberFailure(error);\n this.ready = false;\n throw error;\n }\n })();\n }\n ownsCurrentMaintenanceFrame(): boolean {\n const frame = this.frames.getStore(); return frame !== undefined && this.activeFrames.has(frame);\n }\n isRefusal(error: unknown): boolean { return error instanceof Error && this.expectedErrors.has(error); }\n capabilities(): Promise<RetirementCapabilities> {\n this.requireControlReady();\n return Promise.resolve(this.capabilitiesSnapshot());\n }\n inspect(sessionId: string): Promise<LifecycleKey | null> {\n // Callback observations do not reenter the maintenance queue, but their\n // lifetime still belongs to close/drain and unknown-outcome handling.\n this.requireControlReady();\n const observation = (async () => {\n try {\n const input = await this.call('Owner lifecycle inspection', () => this.options.lifecycle.inspect(sessionId));\n this.requireControlReady();\n const value = input === null ? null : lifecycleKeySchema.parse(input);\n if (value && (value.sessionId !== sessionId || value.storeId !== this.descriptor.storeId)) throw new Error('Lifecycle observation belongs to another target/store.');\n return value;\n } catch (error) {\n if (!(error instanceof Error && this.expectedErrors.has(error))) this.rememberFailure(error);\n throw error;\n }\n })();\n this.observations.add(observation);\n void observation.finally(() => this.observations.delete(observation)).catch(() => {});\n return observation;\n }\n prepare(input: LifecycleKey): Promise<RetirementManifest> {\n const expected = lifecycleKeySchema.parse(input);\n return this.enqueue(async () => {\n this.assertMaintenanceUse(expected);\n return this.withScope(expected, null, async scope => {\n const current = await this.current(scope);\n if (!current || !lifecycleEqual(current, expected)) throw this.known('owner/lifecycle-changed', 'Lifecycle is not current.');\n this.assertMaintenanceUse(expected);\n return this.manifest(expected);\n });\n });\n }\n getOperation(operationId: string): Promise<RetirementState | null> {\n this.requireControlReady();\n const record = this.read(() => this.options.store.operation(operationId));\n return Promise.resolve(record ? retirementStateSchema.parse(record.state) : null);\n }\n getRecord(operationId: string): RetirementOwnerRecord | undefined {\n this.requireControlReady();\n const value = this.read(() => this.options.store.operation(operationId));\n return value ? retirementOwnerRecordSchema.parse(value) : undefined;\n }\n retire(input: RetirementRequest, authorize: () => Promise<RetirementAuthorization>, frozenInput?: RetirementManifest): Promise<RetirementState> {\n const request = retirementRequestSchema.parse(input);\n const frozen = frozenInput === undefined ? undefined : retirementManifestSchema.parse(frozenInput);\n return this.enqueue(async () => {\n const previous = this.read(() => this.options.store.operation(request.operationId));\n if (previous) {\n if (!requestEqual(previous.state.request, request)) throw this.known('owner/operation-id-reused', 'Operation identity already belongs to another request.');\n if (frozen) this.validateFrozen(request, frozen);\n return retirementStateSchema.parse(previous.state);\n }\n if (!frozen) throw this.known('owner/manifest-required', 'New retirement requires its full frozen confirmation manifest.');\n this.validateFrozen(request, frozen);\n this.assertMaintenanceUse(request.expected);\n return this.withScope(request.expected, null, async scope => {\n const current = await this.current(scope);\n if (!current || !lifecycleEqual(current, request.expected)) return this.refusal(request, frozen, 'conflict', 'lifecycle-changed');\n this.assertMaintenanceUse(request.expected);\n const fresh = await this.manifest(request.expected);\n if (retirementManifestDigest(fresh) !== request.manifestDigest) return this.refusal(request, frozen, 'conflict', 'resource-scope-changed');\n const activity = z.array(z.string().min(1).max(1024)).parse(await this.call('Owner activity inspection', () => scope.activity()));\n if (activity.length) return this.refusal(request, frozen, 'rejected', 'session-active');\n await this.checkpoint('before-authorize', this.context(request, frozen, null));\n const grant = retirementAuthorizationSchema.parse(await this.call('Host authorization callback', authorize));\n if (!grant.authorized) return this.refusal(request, frozen, 'rejected', grant.reason);\n const after = await this.current(scope);\n if (!after || !lifecycleEqual(after, request.expected)) return this.refusal(request, frozen, 'conflict', 'lifecycle-changed');\n if (retirementManifestDigest(await this.manifest(request.expected)) !== request.manifestDigest) return this.refusal(request, frozen, 'conflict', 'resource-scope-changed');\n const finalActivity = z.array(z.string().min(1).max(1024)).parse(await this.call('Owner final activity inspection', () => scope.activity()));\n if (finalActivity.length) return this.refusal(request, frozen, 'rejected', 'session-active');\n let record = this.emptyRecord({ schemaVersion: 1, request, manifest: frozen,\n authorizationId: grant.authorizationId, phase: 'fenced', reason: null, resources: [] });\n record = await this.save(record);\n await this.checkpoint('owner-fenced', this.contextFor(record));\n return this.advance(record, scope);\n });\n });\n }\n recover(operationId: string): Promise<RetirementState> {\n return this.enqueue(async () => {\n const record = this.read(() => this.options.store.operation(operationId));\n if (!record) throw this.known('owner/operation-not-found', 'Recovery requires a saved owner operation.');\n if (refused(record.state.phase) || record.state.phase === 'done') return retirementStateSchema.parse(record.state);\n return this.withScope(record.state.request.expected, record, scope => this.advance(record, scope));\n });\n }\n close(): Promise<void> {\n this.closing = true;\n return this.closePromise ??= (async () => {\n const errors: unknown[] = [];\n try { await this.initializing; } catch (error) { errors.push(error); }\n await this.tail;\n while (this.observations.size) await Promise.allSettled([...this.observations]);\n this.ready = false;\n for (const dispose of [...this.disposers].reverse()) try { await dispose(); } catch (error) { errors.push(error); }\n try { await this.options.store.close(); } catch (error) { errors.push(error); }\n if (errors.length) throw new AggregateError(errors, 'Retirement owner teardown failed.');\n })();\n }\n\n private async advance(input: RetirementOwnerRecord, scope: RetirementLifecycleScope): Promise<RetirementState> {\n let record = retirementOwnerRecordSchema.parse(input);\n const request = record.state.request;\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n if (record.state.phase === 'fenced') {\n for (const participant of this.participants) {\n const progress = record.participants.find(value => value.id === participant.identity.id)!;\n if (progress.fenced) continue;\n if (!await this.barrier('Participant fence', () => participant.fence(retirementRequestSchema.parse(request)))) {\n return this.pending(record, 'participant-fence-pending');\n }\n record = await this.save({ ...record, blockedReason: null,\n participants: record.participants.map(value => value.id === progress.id ? { ...value, fenced: true } : value) });\n await this.checkpoint('participant-fenced', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (!record.lifecycleQuiesced) {\n if (!await this.barrier('Lifecycle quiescence', () => scope.quiesce(retirementRequestSchema.parse(request)))) return this.pending(record, 'lifecycle-quiescence-pending');\n record = await this.save({ ...record, blockedReason: null, lifecycleQuiesced: true });\n await this.checkpoint('lifecycle-quiesced', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n for (const participant of this.participants) {\n const progress = record.participants.find(value => value.id === participant.identity.id)!;\n if (progress.quiesced) continue;\n if (!await this.barrier('Participant quiescence', () => participant.quiesce(retirementRequestSchema.parse(request)))) return this.pending(record, 'participant-quiescence-pending');\n record = await this.save({ ...record, blockedReason: null,\n participants: record.participants.map(value => value.id === progress.id ? { ...value, quiesced: true } : value) });\n await this.checkpoint('participant-quiesced', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n record = await this.save({ ...record, state: { ...record.state, phase: 'quiesced' }, blockedReason: null });\n await this.checkpoint('owner-quiesced', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (record.state.phase === 'quiesced') {\n // Draining can publish an already-admitted generation/write. Such a change\n // must not silently enlarge the confirmation, even under the durable fence.\n if (retirementManifestDigest(await this.manifest(request.expected)) !== request.manifestDigest) return this.pending(record, 'resource-scope-changed-after-quiescence');\n record = await this.save({ ...record, state: { ...record.state, phase: 'erasing' }, blockedReason: null });\n await this.checkpoint('owner-erasing', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (record.state.phase === 'erasing') {\n for (const resource of [...record.state.manifest.resources].sort(resourceOrder)) {\n const previous = record.state.resources.find(value => value.ownerId === resource.ownerId && value.resourceId === resource.resourceId);\n if (previous && previous.status !== 'failed') continue;\n const participant = this.participants.find(value => value.identity.id === resource.ownerId)!;\n const receipt = retirementResourceReceiptSchema.parse(await this.call('Participant resource action', () =>\n participant.applyResource(retirementRequestSchema.parse(request), retirementResourceSchema.parse(resource))));\n if (receipt.ownerId !== resource.ownerId || receipt.resourceId !== resource.resourceId) throw new Error('Participant receipt changed its frozen resource identity.');\n await this.checkpoint('resource-effect', this.contextFor(record, resource));\n record = await this.save({ ...record, blockedReason: receipt.status === 'failed' ? receipt.reason : null,\n state: { ...record.state, resources: [...record.state.resources.filter(value => value.ownerId !== resource.ownerId || value.resourceId !== resource.resourceId), receipt] } });\n await this.checkpoint('resource-receipt', this.contextFor(record, resource));\n if (receipt.status === 'failed' || !this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n record = await this.save({ ...record, state: { ...record.state, phase: 'converging' }, blockedReason: null });\n await this.checkpoint('owner-converging', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (record.state.phase === 'converging') {\n for (const participant of this.participants) {\n const progress = record.participants.find(value => value.id === participant.identity.id)!;\n if (progress.converged) continue;\n if (!await this.barrier('Participant convergence', () => participant.converge(retirementRequestSchema.parse(request)))) return this.pending(record, 'participant-convergence-pending');\n record = await this.save({ ...record, blockedReason: null,\n participants: record.participants.map(value => value.id === progress.id ? { ...value, converged: true } : value) });\n await this.checkpoint('participant-converged', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (!record.lifecycleFinalized) {\n if (!await this.barrier('Lifecycle finalization', () => scope.finalize(retirementRequestSchema.parse(request)))) return this.pending(record, 'lifecycle-finalization-pending');\n await this.checkpoint('lifecycle-finalize-effect', this.contextFor(record));\n record = await this.save({ ...record, blockedReason: null, lifecycleFinalized: true });\n await this.checkpoint('lifecycle-finalized', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n record = await this.save({ ...record, state: { ...record.state, phase: 'done' }, blockedReason: null });\n await this.checkpoint('owner-done', this.contextFor(record));\n }\n return retirementStateSchema.parse(record.state);\n }\n private emptyRecord(state: RetirementState): RetirementOwnerRecord {\n return retirementOwnerRecordSchema.parse({ schemaVersion: 1, state,\n participants: this.descriptor.participants.map(value => ({ ...value, fenced: false, quiesced: false, converged: false })),\n lifecycleQuiesced: false, lifecycleFinalized: false, blockedReason: null });\n }\n private async refusal(request: RetirementRequest, manifest: RetirementManifest, phase: 'rejected' | 'conflict', reason: string): Promise<RetirementState> {\n const record = await this.save(this.emptyRecord({ schemaVersion: 1, request, manifest, authorizationId: null, phase, reason, resources: [] }));\n return retirementStateSchema.parse(record.state);\n }\n private async pending(record: RetirementOwnerRecord, reason: string): Promise<RetirementState> {\n return retirementStateSchema.parse((await this.save({ ...record, blockedReason: reason })).state);\n }\n private async manifest(expected: LifecycleKey): Promise<RetirementManifest> {\n const resources: RetirementResource[] = [];\n for (const participant of this.participants) {\n const owned = z.array(retirementResourceSchema).max(4096).parse(await this.call('Participant resource inventory', () => participant.manifest(lifecycleKeySchema.parse(expected))));\n if (owned.some(value => value.ownerId !== participant.identity.id)) throw new Error('Participant inventory claimed another owner.');\n resources.push(...owned);\n }\n return retirementManifestSchema.parse({ schemaVersion: 1, lifecycle: expected, capabilities: this.capabilitiesSnapshot(), resources });\n }\n private validateFrozen(request: RetirementRequest, manifest: RetirementManifest): void {\n if (!lifecycleEqual(request.expected, manifest.lifecycle) || !sameRetirementCapabilities(this.descriptor, manifest.capabilities)\n || retirementManifestDigest(manifest) !== request.manifestDigest) throw this.known('owner/manifest-mismatch', 'Frozen confirmation does not match the request and owner composition.');\n }\n private async current(scope: RetirementLifecycleScope): Promise<LifecycleKey | null> {\n const value = await this.call('Scoped lifecycle observation', () => scope.current());\n return value === null ? null : lifecycleKeySchema.parse(value);\n }\n private async withScope<T>(expected: LifecycleKey, record: RetirementOwnerRecord | null, work: (scope: RetirementLifecycleScope) => Promise<T>): Promise<T> {\n let scope: RetirementLifecycleScope | undefined;\n let result!: T;\n const errors: unknown[] = [];\n try {\n scope = await this.call('Lifecycle maintenance scope', () => this.options.lifecycle.acquire(\n lifecycleKeySchema.parse(expected), record ? retirementOwnerRecordSchema.parse(record) : null), false, false);\n this.assertHealthy();\n if (!lifecycleEqual(lifecycleKeySchema.parse(scope.lifecycle), expected)) throw new Error('Maintenance scope belongs to a different lifecycle.');\n result = await work(scope);\n } catch (error) {\n if (!(error instanceof Error && this.expectedErrors.has(error))) this.rememberFailure(error);\n errors.push(error);\n }\n const acquired = scope;\n if (acquired) try { await this.call('Lifecycle scope release', () => acquired.release(), true); } catch (error) { errors.push(error); }\n if (errors.length === 1) throw errors[0];\n if (errors.length) throw new AggregateError(errors, 'Retirement scope and release failed.');\n return result;\n }\n private context(request: RetirementRequest, manifest: RetirementManifest, record: RetirementOwnerRecord | null, resource: RetirementResource | null = null): RetirementOwnerCheckpoint {\n return { request: retirementRequestSchema.parse(request), manifest: retirementManifestSchema.parse(manifest),\n record: record ? retirementOwnerRecordSchema.parse(record) : null, resource: resource ? retirementResourceSchema.parse(resource) : null };\n }\n private contextFor(record: RetirementOwnerRecord, resource: RetirementResource | null = null): RetirementOwnerCheckpoint {\n return this.context(record.state.request, record.state.manifest, record, resource);\n }\n private async checkpoint(name: string, context: RetirementOwnerCheckpoint): Promise<void> {\n if (this.options.checkpoint) await this.call('Owner checkpoint observer', async () => { await this.options.checkpoint!(name, context); });\n }\n private canAdvance(record: RetirementOwnerRecord): boolean {\n this.assertHealthy();\n try {\n const allowed = this.options.canAdvance ? z.boolean().parse(this.options.canAdvance(retirementOwnerRecordSchema.parse(record))) : true;\n this.assertHealthy();\n return allowed;\n } catch (cause) { throw this.rememberFailure(new Error('Owner work budget failed.', { cause })); }\n }\n private async barrier(name: string, work: () => Promise<boolean>): Promise<boolean> { return z.boolean().parse(await this.call(name, work)); }\n private async save(input: RetirementOwnerRecord): Promise<RetirementOwnerRecord> {\n const record = retirementOwnerRecordSchema.parse(input);\n this.validateFrozen(record.state.request, record.state.manifest);\n await this.call('Owner journal write', () => this.options.store.putOperation(retirementOwnerRecordSchema.parse(record)));\n return retirementOwnerRecordSchema.parse(record);\n }\n private records(): RetirementOwnerRecord[] {\n return this.read(() => this.options.store.operations()).map(value => retirementOwnerRecordSchema.parse(value));\n }\n private validateJournal(): void {\n for (const record of this.records()) {\n this.validateFrozen(record.state.request, record.state.manifest);\n }\n }\n private verifyParticipants(): void {\n const actual = this.participants.map(value => retirementParticipantSchema.parse(value.identity));\n if (actual.length !== this.descriptor.participants.length || new Set(actual.map(value => value.id)).size !== actual.length\n || actual.some(value => !this.descriptor.participants.some(expected => expected.id === value.id && expected.version === value.version))) {\n throw new Error('Owner participant set/version does not match the fixed composition.');\n }\n }\n private capabilitiesSnapshot(): RetirementCapabilities { return retirementCapabilitiesSchema.parse(this.descriptor); }\n private known(code: string, message: string): RetirementOwnerError {\n const error = new RetirementOwnerError(code, message);\n this.expectedErrors.add(error);\n return error;\n }\n private unavailable(): RetirementOwnerError {\n return new RetirementOwnerError('owner/unavailable', 'Retirement owner is not ready, closing or requires a fresh journal reopen.', this.failure ? { cause: this.failure } : undefined);\n }\n private assertMaintenanceUse(expected: LifecycleKey): void {\n this.requireControlReady();\n this.assertUnfenced(expected);\n }\n private assertUnfenced(expected: LifecycleKey): void {\n if (expected.storeId !== this.descriptor.storeId) throw this.known('owner/store-mismatch', 'Lifecycle belongs to another store.');\n if (this.records().some(record => !refused(record.state.phase)\n && (record.state.phase === 'done' ? lifecycleEqual(record.state.request.expected, expected)\n : record.state.request.expected.sessionId === expected.sessionId))) {\n throw this.known('owner/lifecycle-retired', 'Lifecycle is fenced or permanently retired.');\n }\n }\n private rememberFailure(cause: unknown): Error {\n const error = cause instanceof Error ? cause : new Error('Retirement owner received an unexpected rejection.', { cause });\n this.failure ??= error;\n return error;\n }\n private requireControlReady(): void {\n const frame = this.frames.getStore();\n if (!this.ready || this.failure) throw this.unavailable();\n if (this.closing && (frame === undefined || !this.activeFrames.has(frame))) {\n throw this.known('owner/closing', 'Retirement owner control routes are closing.');\n }\n this.assertHealthy();\n }\n private requireReady(): void {\n if (!this.ready || this.closing || this.failure) throw this.unavailable();\n this.assertHealthy();\n }\n private read<T>(work: () => T): T {\n try { return work(); }\n catch (cause) { throw this.rememberFailure(new Error('Owner journal observation failed.', { cause })); }\n }\n private assertHealthy(): void {\n if (this.failure) throw this.unavailable();\n try { this.verifyParticipants(); } catch (error) { throw this.rememberFailure(error); }\n }\n private async call<T>(name: string, work: () => Promise<T>, cleanup = false, postcheck = true): Promise<T> {\n if (!cleanup) this.assertHealthy();\n try {\n const value = await work();\n if (!cleanup && postcheck) this.assertHealthy();\n return value;\n } catch (cause) {\n throw this.rememberFailure(new Error(`${name} failed.`, { cause }));\n }\n }\n private enqueue<T>(work: () => Promise<T>): Promise<T> {\n this.requireReady();\n const result = this.tail.then(() => {\n const frame = Symbol('retirement-maintenance');\n return this.frames.run(frame, async () => {\n if (this.failure) throw this.unavailable();\n this.assertHealthy();\n this.activeFrames.add(frame);\n try { return await work(); }\n catch (error) {\n if (!(error instanceof Error && this.expectedErrors.has(error))) throw this.rememberFailure(error);\n throw error;\n } finally { this.activeFrames.delete(frame); }\n });\n });\n this.tail = result.then(() => undefined, () => undefined);\n return result;\n }\n}\n", "import { z } from 'zod';\nimport { retirementCapabilitiesSchema, retirementParticipantSchema, retirementStateSchema } from './retirement.js';\n\nexport const retirementOwnerParticipantProgressSchema = retirementParticipantSchema.extend({\n fenced: z.boolean(), quiesced: z.boolean(), converged: z.boolean(),\n}).strict();\nexport const retirementOwnerRecordSchema = z.object({\n schemaVersion: z.literal(1), state: retirementStateSchema,\n participants: z.array(retirementOwnerParticipantProgressSchema).min(1).max(64),\n lifecycleQuiesced: z.boolean(), lifecycleFinalized: z.boolean(),\n blockedReason: z.string().min(1).max(1024).nullable(),\n}).strict().superRefine((record, ctx) => {\n const declared = record.state.manifest.capabilities.participants;\n const { phase } = record.state;\n const terminalRefusal = phase === 'rejected' || phase === 'conflict';\n if (record.participants.length !== declared.length\n || new Set(record.participants.map(participant => participant.id)).size !== record.participants.length\n || record.participants.some(participant => !declared.some(expected => expected.id === participant.id && expected.version === participant.version))) {\n ctx.addIssue({ code: 'custom', message: 'Owner progress must cover exactly the frozen participants.' });\n }\n if ((record.lifecycleQuiesced && record.participants.some(participant => !participant.fenced))\n || (!record.lifecycleQuiesced && record.participants.some(participant => participant.quiesced))) {\n ctx.addIssue({ code: 'custom', message: 'Lifecycle quiescence follows every fence and precedes participant quiescence.' });\n }\n if (record.participants.some(participant => (participant.quiesced && !participant.fenced)\n || (participant.converged && !participant.quiesced))) {\n ctx.addIssue({ code: 'custom', message: 'Participant confirmation stages must be ordered.' });\n }\n if (terminalRefusal && (record.lifecycleQuiesced || record.lifecycleFinalized\n || record.participants.some(participant => participant.fenced || participant.quiesced || participant.converged))) {\n ctx.addIssue({ code: 'custom', message: 'Refusal cannot acknowledge retirement effects.' });\n }\n if (['quiesced', 'erasing', 'converging', 'done'].includes(phase)\n && (!record.lifecycleQuiesced || record.participants.some(participant => !participant.fenced || !participant.quiesced))) {\n ctx.addIssue({ code: 'custom', message: 'Resource erasure requires every quiescence confirmation.' });\n }\n if ((record.lifecycleFinalized || record.participants.some(participant => participant.converged))\n && !['converging', 'done'].includes(phase)) {\n ctx.addIssue({ code: 'custom', message: 'Convergence cannot precede resource erasure.' });\n }\n if (['converging', 'done'].includes(phase) && (record.state.resources.length !== record.state.manifest.resources.length\n || record.state.resources.some(receipt => receipt.status === 'failed'))) {\n ctx.addIssue({ code: 'custom', message: 'Convergence requires every successful resource acknowledgement.' });\n }\n if (record.lifecycleFinalized && record.participants.some(participant => !participant.converged)) {\n ctx.addIssue({ code: 'custom', message: 'Lifecycle finalization requires every participant convergence acknowledgement.' });\n }\n if (phase === 'done' && (!record.lifecycleFinalized || record.participants.some(participant => !participant.converged))) {\n ctx.addIssue({ code: 'custom', message: 'Owner completion requires the lifecycle and every participant.' });\n }\n});\nexport const retirementOwnerGlobalSchema = z.object({\n schemaVersion: z.literal(1), capabilities: retirementCapabilitiesSchema.nullable(),\n}).strict();\nexport type RetirementOwnerRecord = z.infer<typeof retirementOwnerRecordSchema>;\nexport type RetirementOwnerParticipantProgress = z.infer<typeof retirementOwnerParticipantProgressSchema>;\n", "import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';\nimport type { Domain } from '@deepseek-ai/dsh-storage-domain';\nimport { retirementCapabilitiesSchema } from '../operations/retirement.js';\nimport type { RetirementCapabilities } from '../operations/retirement.js';\nimport { retirementOwnerGlobalSchema, retirementOwnerRecordSchema } from '../operations/retirement-owner.js';\nimport type { RetirementOwnerRecord } from '../operations/retirement-owner.js';\nimport { retirementManifestDigest } from './retirement.js';\n\nexport const retirementOwnerDomainSpec = defineDomain({\n name: 'session_bin_retirement_owner', version: 1, layout: 'single',\n global: { schema: retirementOwnerGlobalSchema, initial: { schemaVersion: 1, capabilities: null } },\n tables: { operations: domainTable(retirementOwnerRecordSchema) },\n} as const);\nexport interface RetirementOwnerStore {\n bindCapabilities(capabilities: RetirementCapabilities): Promise<void>;\n operation(operationId: string): RetirementOwnerRecord | undefined;\n operations(): RetirementOwnerRecord[];\n putOperation(record: RetirementOwnerRecord): Promise<void>;\n close(): Promise<void>;\n}\nexport function sameRetirementCapabilities(a: RetirementCapabilities, b: RetirementCapabilities): boolean {\n const canonical = (value: RetirementCapabilities) => JSON.stringify([\n value.protocolVersion, value.ownerId, value.hostVersion, value.providerId, value.storeId,\n value.participants.map(participant => [participant.id, participant.version]).sort((first, second) =>\n JSON.stringify(first) < JSON.stringify(second) ? -1 : JSON.stringify(first) > JSON.stringify(second) ? 1 : 0),\n ]);\n return canonical(retirementCapabilitiesSchema.parse(a)) === canonical(retirementCapabilitiesSchema.parse(b));\n}\nfunction validateRecord(value: RetirementOwnerRecord): RetirementOwnerRecord {\n const record = retirementOwnerRecordSchema.parse(value);\n if (record.state.request.manifestDigest !== retirementManifestDigest(record.state.manifest)) {\n throw new Error('Owner record does not carry its original frozen manifest digest.');\n }\n return record;\n}\nfunction assertMonotonic(previous: RetirementOwnerRecord, next: RetirementOwnerRecord): void {\n const a = previous.state;\n const b = next.state;\n if (JSON.stringify(a.request) !== JSON.stringify(b.request)\n || retirementManifestDigest(a.manifest) !== retirementManifestDigest(b.manifest)\n || a.authorizationId !== b.authorizationId) throw new Error('Owner journal cannot change a saved request, manifest or grant.');\n const phases = ['fenced', 'quiesced', 'erasing', 'converging', 'done'];\n if (['rejected', 'conflict', 'done'].includes(a.phase)) {\n if (JSON.stringify(previous) !== JSON.stringify(next)) throw new Error('Terminal owner receipts are immutable.');\n return;\n }\n if (phases.indexOf(b.phase) < phases.indexOf(a.phase)) throw new Error('Owner journal phase cannot regress.');\n for (const part of previous.participants) {\n const current = next.participants.find(value => value.id === part.id && value.version === part.version);\n if (!current || (part.fenced && !current.fenced) || (part.quiesced && !current.quiesced) || (part.converged && !current.converged)) {\n throw new Error('Owner journal cannot lose a participant acknowledgement.');\n }\n }\n if ((previous.lifecycleQuiesced && !next.lifecycleQuiesced) || (previous.lifecycleFinalized && !next.lifecycleFinalized)) {\n throw new Error('Owner journal cannot lose lifecycle settlement.');\n }\n for (const receipt of a.resources.filter(value => value.status !== 'failed')) {\n const current = b.resources.find(value => value.ownerId === receipt.ownerId && value.resourceId === receipt.resourceId);\n if (!current || JSON.stringify(current) !== JSON.stringify(receipt)) throw new Error('Owner journal cannot lose a resource acknowledgement.');\n }\n}\n\n/** The caller must hold the composition's lifetime lease before opening this domain. */\nexport class DomainRetirementOwnerStore implements RetirementOwnerStore {\n constructor(private readonly domain: Domain<typeof retirementOwnerDomainSpec>) {\n const capabilities = domain.global.get().capabilities;\n for (const [key, value] of domain.table('operations').entries()) {\n const record = validateRecord(value);\n if (key !== record.state.request.operationId || !capabilities\n || !sameRetirementCapabilities(capabilities, record.state.manifest.capabilities)) {\n throw new Error('Owner operation has no matching journal identity and capability binding.');\n }\n }\n }\n async bindCapabilities(input: RetirementCapabilities): Promise<void> {\n const capabilities = retirementCapabilitiesSchema.parse(input);\n const previous = this.domain.global.get().capabilities;\n if (previous) {\n if (!sameRetirementCapabilities(previous, capabilities)) throw new Error('Owner journal belongs to a different composition.');\n return;\n }\n if (this.operations().length) throw new Error('Owner records cannot be adopted without their capability binding.');\n await this.domain.global.set({ schemaVersion: 1, capabilities });\n }\n operation(operationId: string): RetirementOwnerRecord | undefined {\n const value = this.domain.table('operations').get(operationId);\n return value === undefined ? undefined : validateRecord(value);\n }\n operations(): RetirementOwnerRecord[] {\n return [...this.domain.table('operations').entries()].map(([, value]) => validateRecord(value));\n }\n putOperation(input: RetirementOwnerRecord): Promise<void> {\n const record = validateRecord(input);\n const capabilities = this.domain.global.get().capabilities;\n if (!capabilities || !sameRetirementCapabilities(capabilities, record.state.manifest.capabilities)) {\n throw new Error('Cannot write an owner operation for an unbound composition.');\n }\n const previous = this.operation(record.state.request.operationId);\n if (previous) assertMonotonic(previous, record);\n return this.domain.table('operations').put(record.state.request.operationId, record);\n }\n close(): Promise<void> { return this.domain.close(); }\n}\n", "import { Context } from '@deepseek-ai/cordis';\nimport { RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';\nimport type { RemoteStream } from '@deepseek-ai/dsh-typert-protocol';\nimport type {} from '../index.js';\nimport { SessionBinError } from './module.js';\nimport { entriesSchema, optionalOperationSchema, sessionBinHostContribution, sessionBinRemoteNamespace,\n sessionBinRemoteServiceKey, snapshotSchema, binRemoteErrorCodes } from '../remote/contracts.js';\nimport type { BinRemoteErrorCode, BinSnapshot } from '../remote/contracts.js';\nimport { archivePlanSchema as planSchema, archiveResultSchema as resultSchema } from '../operations/archive.js';\nimport type { ArchiveOperation, ArchivePlan as BinPlan, ArchiveResult as BinResult, ArchivePrepareRequest as PrepareRequest } from '../operations/archive.js';\nimport type { BinOperation } from '../operations/schema.js';\nimport { nativePurgePlanSchema, optionalPurgeOperationSchema, purgeOperationsSchema } from '../remote/contracts.js';\nimport { purgeResultSchema } from '../operations/retirement.js';\nimport type { PreparePurgeRequest, PurgePlan, PurgeResult, PurgeOperation } from '../operations/retirement.js';\n\nconst knownRemoteCodes = new Set<string>(binRemoteErrorCodes);\nfunction isBinRemoteCode(code: string): code is BinRemoteErrorCode { return knownRemoteCodes.has(code); }\nfunction wakeGate(): { promise: Promise<void>; resolve: () => void } {\n let finish!: () => void;\n const promise = new Promise<void>(resolve => { finish = resolve; });\n return { promise, resolve: finish };\n}\n\n/** Public strict Typert adapter; all native mutation stays in the existing Module. */\nexport class SessionBinRemote extends TypertRemoteService {\n static inject = ['sessionBin', 'typert'];\n private readonly lifetime = new AbortController();\n private readonly streams = new Set<AsyncIterableIterator<BinSnapshot>>();\n private closed = false;\n\n constructor(ctx: Context) {\n super(ctx, sessionBinRemoteServiceKey, { namespace: sessionBinRemoteNamespace });\n ctx.typert.register(sessionBinHostContribution);\n ctx.effect(() => async () => {\n this.closed = true;\n this.lifetime.abort();\n const streams = [...this.streams];\n this.streams.clear();\n // Await generator cleanup even when a consumer paused after a snapshot.\n await Promise.allSettled(streams.map(stream => stream.return?.()));\n }, 'session-bin.remote.dispose');\n }\n\n prepare(request: PrepareRequest, signal: AbortSignal): Promise<BinPlan> {\n return this.call(signal, async () => planSchema.parse(await this.ctx.sessionBin.prepare(request)));\n }\n execute(plan: BinPlan, signal: AbortSignal): Promise<BinResult> {\n // Cancellation fences admission. An accepted operation is awaited through\n // durability, so a dropped reply can be recovered by its operation identity.\n return this.call(signal, async () => resultSchema.parse(await this.ctx.sessionBin.execute(plan)));\n }\n list(signal: AbortSignal) {\n return this.call(signal, async () => entriesSchema.parse(await this.ctx.sessionBin.list()));\n }\n getOperation(operationId: string, signal: AbortSignal): Promise<ArchiveOperation | BinOperation | null> {\n return this.call(signal, async () => optionalOperationSchema.parse(await this.ctx.sessionBin.getOperation(operationId) ?? null));\n }\n\n preparePurge(request: PreparePurgeRequest, signal: AbortSignal): Promise<PurgePlan> {\n return this.call(signal, async () => nativePurgePlanSchema.parse(await this.ctx.sessionBin.preparePurge(request)));\n }\n executePurge(input: PurgePlan, signal: AbortSignal): Promise<PurgeResult> {\n const plan = nativePurgePlanSchema.parse(input);\n return this.call(signal, async () => purgeResultSchema.parse(await this.ctx.sessionBin.executePurge(plan)));\n }\n getPurgeOperation(operationId: string, signal: AbortSignal): Promise<PurgeOperation | null> {\n return this.call(signal, async () => optionalPurgeOperationSchema.parse(await this.ctx.sessionBin.getPurgeOperation(operationId) ?? null));\n }\n\n purgeOperations(signal: AbortSignal): Promise<PurgeOperation[]> {\n return this.call(signal, async () => purgeOperationsSchema.parse(await this.ctx.sessionBin.purgeOperations()));\n }\n\n follow(signal: AbortSignal): RemoteStream<BinSnapshot> {\n const cancelled = new AbortController();\n const lifetime = AbortSignal.any([signal, this.lifetime.signal, cancelled.signal]);\n const source = this.snapshots(lifetime);\n const streams = this.streams;\n const iterator: AsyncIterableIterator<BinSnapshot> = {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n try {\n const next = await source.next();\n if (next.done) streams.delete(iterator);\n return next;\n } catch (error) { streams.delete(iterator); throw error; }\n },\n async return() {\n cancelled.abort();\n streams.delete(iterator);\n return source.return();\n },\n async throw(error: unknown) {\n cancelled.abort(error);\n streams.delete(iterator);\n return source.throw(error);\n },\n };\n streams.add(iterator);\n return iterator;\n }\n\n private async *snapshots(signal: AbortSignal): AsyncGenerator<BinSnapshot, void, unknown> {\n if (signal.aborted || this.closed) return;\n let dirty = true;\n let deletionDirty = false;\n let wake = wakeGate();\n const changed = () => { dirty = true; wake.resolve(); };\n // Subscribe before the first list. Every generation receives a full baseline;\n // notifications are coalesced into replacement snapshots, with no replay cursor.\n const off = this.ctx.root.on('domain/changed', change => {\n if (change.domain === 'session_bin_purge') { deletionDirty = true; changed(); }\n else if (change.domain === 'session_archive' || change.domain === 'workspace') changed();\n });\n signal.addEventListener('abort', changed, { once: true });\n let previous: string | undefined;\n try {\n while (!signal.aborted && !this.closed) {\n if (dirty) {\n dirty = false;\n const snapshot = await this.call(signal, async () => snapshotSchema.parse({\n schemaVersion: 2, entries: await this.ctx.sessionBin.list(),\n }));\n if (signal.aborted || this.closed) return;\n const signature = JSON.stringify(snapshot);\n if (signature !== previous || deletionDirty) {\n previous = signature;\n deletionDirty = false;\n yield snapshot;\n }\n continue;\n }\n await wake.promise;\n wake = wakeGate();\n }\n } finally {\n off();\n signal.removeEventListener('abort', changed);\n }\n }\n\n private async call<Result>(signal: AbortSignal, operation: () => Promise<Result>): Promise<Result> {\n if (this.closed) throw new RemoteError('bin/closed', 'Session Bin Remote is unloading.', {});\n signal.throwIfAborted();\n try { return await operation(); }\n catch (error) {\n if (error instanceof SessionBinError && isBinRemoteCode(error.code)) {\n throw new RemoteError(error.code, error.message, {}, { cause: error });\n }\n throw error;\n }\n }\n}\n\n/** The parent Host calls this only after its SessionBin Module has initialized. */\nexport async function installSessionBinRemote(ctx: Context): Promise<() => Promise<void>> {\n const fiber = ctx.plugin(SessionBinRemote);\n try { await fiber; }\n catch (error) { await fiber.dispose(); throw error; }\n return async () => { await fiber.dispose(); };\n}\n", "import { z } from 'zod';\nimport type { InvocationDescriptor, RemoteResult, RemoteStreamHandle, TypertCodec, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';\nimport type { TypertContribution } from '@deepseek-ai/dsh-typert-registry';\nimport { operationSchema } from '../operations/schema.js';\nimport type { BinOperation } from '../operations/schema.js';\nimport { archiveEntrySchema, archiveOperationSchema, archivePlanSchema, archivePrepareRequestSchema, archiveResultSchema } from '../operations/archive.js';\nimport type { ArchiveEntry, ArchiveOperation, ArchivePlan, ArchivePrepareRequest, ArchiveResult } from '../operations/archive.js';\nimport { preparePurgeRequestSchema, purgePlanSchema, purgeResultSchema, purgeOperationSchema } from '../operations/retirement.js';\nimport type { PreparePurgeRequest, PurgePlan, PurgeResult, PurgeOperation } from '../operations/retirement.js';\n\nexport const sessionBinRemoteNamespace = 'sessionBin';\nexport const sessionBinRemoteServiceKey = 'sessionBinRemote';\nexport const snapshotSchema = z.object({ schemaVersion: z.literal(2), entries: z.array(archiveEntrySchema) }).strict();\nexport type BinSnapshot = z.infer<typeof snapshotSchema>;\nexport type ArchiveSnapshot = BinSnapshot;\nexport const operationIdSchema = z.string().min(1).max(1024);\nexport const entriesSchema = z.array(archiveEntrySchema);\nexport const optionalOperationSchema = z.union([archiveOperationSchema, operationSchema]).nullable();\nexport const nativePurgePlanSchema = purgePlanSchema.refine(plan => plan.schemaVersion === 2, 'Only native archive v2 deletion plans may be executed remotely.');\nexport const optionalPurgeOperationSchema = purgeOperationSchema.nullable();\nexport const purgeOperationsSchema = z.array(purgeOperationSchema);\n\n/** Browser-safe contract. Native archive is the sole entry path. */\nexport interface SessionBinRemoteApi {\n prepare(request: ArchivePrepareRequest, signal?: AbortSignal): Promise<RemoteResult<ArchivePlan>>;\n execute(plan: ArchivePlan, signal?: AbortSignal): Promise<RemoteResult<ArchiveResult>>;\n list(signal?: AbortSignal): Promise<RemoteResult<ArchiveEntry[]>>;\n getOperation(operationId: string, signal?: AbortSignal): Promise<RemoteResult<ArchiveOperation | BinOperation | null>>;\n preparePurge(request: PreparePurgeRequest, signal?: AbortSignal): Promise<RemoteResult<PurgePlan>>;\n executePurge(plan: PurgePlan, signal?: AbortSignal): Promise<RemoteResult<PurgeResult>>;\n getPurgeOperation(operationId: string, signal?: AbortSignal): Promise<RemoteResult<PurgeOperation | null>>;\n purgeOperations(signal?: AbortSignal): Promise<RemoteResult<PurgeOperation[]>>;\n follow(signal?: AbortSignal): RemoteStreamHandle<BinSnapshot, never>;\n}\nexport const binRemoteErrorCodes = ['bin/closed', 'bin/recovery-required', 'bin/not-ready', 'bin/operation-id-reused'] as const;\nexport type BinRemoteErrorCode = typeof binRemoteErrorCodes[number];\ndeclare module '@deepseek-ai/dsh-typert-protocol' {\n interface RemoteErrorDetailsMap {\n 'bin/closed': {};\n 'bin/recovery-required': {};\n 'bin/not-ready': {};\n 'bin/operation-id-reused': {};\n }\n}\nfunction strictCodec<Output>(name: string, schema: z.ZodType<Output>): TypertCodec {\n return { mode: 'strict', typeSymbol: `@takboo/dsh-session-bin#${name}`, create: () => schema,\n encode: value => schema.parse(value), decode: value => schema.parse(value) };\n}\nconst codecs = {\n request: strictCodec('ArchivePrepareRequest', archivePrepareRequestSchema),\n plan: strictCodec('ArchivePlan', archivePlanSchema),\n result: strictCodec('ArchiveResult', archiveResultSchema),\n entries: strictCodec('ArchiveEntries', entriesSchema),\n operationId: strictCodec('OperationId', operationIdSchema),\n operation: strictCodec('OptionalArchiveOperation', optionalOperationSchema),\n purgeRequest: strictCodec('PreparePurgeRequest', preparePurgeRequestSchema),\n purgePlan: strictCodec('NativePurgePlan', nativePurgePlanSchema),\n purgeResult: strictCodec('PurgeResult', purgeResultSchema),\n purgeOperation: strictCodec('OptionalPurgeOperation', optionalPurgeOperationSchema),\n purgeOperations: strictCodec('PurgeOperations', purgeOperationsSchema),\n snapshot: strictCodec('ArchiveSnapshot', snapshotSchema),\n};\nfunction descriptor(method: string, parameters: InvocationDescriptor['parameters'], result: TypertCodec,\n mode?: 'stream'): InvocationDescriptor {\n return { id: `@takboo/dsh-session-bin#sessionBin/${method}`, service: sessionBinRemoteServiceKey,\n namespace: sessionBinRemoteNamespace, method, invocation: { kind: 'direct' }, parameters, result,\n cancellation: { parameter: 'signal' }, ...(mode === undefined ? {} : { mode }) };\n}\nconst descriptors: readonly InvocationDescriptor[] = [\n descriptor('prepare', [{ name: 'request', wire: 'request', source: 'json', codec: codecs.request }], codecs.plan),\n descriptor('execute', [{ name: 'plan', wire: 'plan', source: 'json', codec: codecs.plan }], codecs.result),\n descriptor('list', [], codecs.entries),\n descriptor('getOperation', [{ name: 'operationId', wire: 'operationId', source: 'json', codec: codecs.operationId }], codecs.operation),\n descriptor('preparePurge', [{ name: 'request', wire: 'request', source: 'json', codec: codecs.purgeRequest }], codecs.purgePlan),\n descriptor('executePurge', [{ name: 'plan', wire: 'plan', source: 'json', codec: codecs.purgePlan }], codecs.purgeResult),\n descriptor('getPurgeOperation', [{ name: 'operationId', wire: 'operationId', source: 'json', codec: codecs.operationId }], codecs.purgeOperation),\n descriptor('purgeOperations', [], codecs.purgeOperations),\n descriptor('follow', [], codecs.snapshot, 'stream'),\n];\nexport const sessionBinRemoteContribution: TypertRemoteContribution = { package: '@takboo/dsh-session-bin', descriptors };\nexport const sessionBinHostContribution: TypertContribution = {\n package: '@takboo/dsh-session-bin', face: 'host',\n schemas: [\n { name: 'ArchivePrepareRequest', create: () => archivePrepareRequestSchema },\n { name: 'ArchiveEntry', create: () => archiveEntrySchema },\n { name: 'ArchivePlan', create: () => archivePlanSchema },\n { name: 'ArchiveResult', create: () => archiveResultSchema },\n { name: 'ArchiveOperation', create: () => archiveOperationSchema },\n { name: 'ArchiveEntries', create: () => entriesSchema },\n { name: 'OperationId', create: () => operationIdSchema },\n { name: 'OptionalArchiveOperation', create: () => optionalOperationSchema },\n { name: 'PreparePurgeRequest', create: () => preparePurgeRequestSchema },\n { name: 'NativePurgePlan', create: () => nativePurgePlanSchema },\n { name: 'PurgeResult', create: () => purgeResultSchema },\n { name: 'OptionalPurgeOperation', create: () => optionalPurgeOperationSchema },\n { name: 'PurgeOperations', create: () => purgeOperationsSchema },\n { name: 'ArchiveSnapshot', create: () => snapshotSchema },\n ],\n model: { services: [{ key: sessionBinRemoteServiceKey, exportName: 'SessionBinRemote',\n description: 'Typed native archive management adapter.', tags: [], members: [\n { kind: 'method', name: 'prepare', signature: 'prepare(request: ArchivePrepareRequest, signal: AbortSignal): Promise<ArchivePlan>' },\n { kind: 'method', name: 'execute', signature: 'execute(plan: ArchivePlan, signal: AbortSignal): Promise<ArchiveResult>' },\n { kind: 'method', name: 'list', signature: 'list(signal: AbortSignal): Promise<ArchiveEntry[]>' },\n { kind: 'method', name: 'getOperation', signature: 'getOperation(operationId: string, signal: AbortSignal): Promise<ArchiveOperation | BinOperation | null>' },\n { kind: 'method', name: 'preparePurge', signature: 'preparePurge(request: PreparePurgeRequest, signal: AbortSignal): Promise<PurgePlan>' },\n { kind: 'method', name: 'executePurge', signature: 'executePurge(plan: PurgePlan, signal: AbortSignal): Promise<PurgeResult>' },\n { kind: 'method', name: 'getPurgeOperation', signature: 'getPurgeOperation(operationId: string, signal: AbortSignal): Promise<PurgeOperation | null>' },\n { kind: 'method', name: 'purgeOperations', signature: 'purgeOperations(signal: AbortSignal): Promise<PurgeOperation[]>' },\n { kind: 'method', name: 'follow', signature: 'follow(signal: AbortSignal): RemoteStream<ArchiveSnapshot>' },\n ], types: [] }], events: [], objects: [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} from 'node:path';\nimport { Context, Service } from '@deepseek-ai/cordis';\nimport schema from '@deepseek-ai/schemastery';\nimport { resolveDshHome } from '@deepseek-ai/dsh-home-paths';\nimport { workspaceDomainState } from '@deepseek-ai/dsh-workspace';\nimport type {} from '@deepseek-ai/dsh-session-persistence';\nimport { acquireBinLease } from './host/lease.js';\nimport { DshBinPort } from './host/native.js';\nimport { archiveDomainSpec, DomainArchiveStore, binDomainSpec, DomainBinStore } from './host/store.js';\nimport { retirementDomainSpec, DomainRetirementStore } from './host/retirement-store.js';\nimport type { PreparePurgeRequest, PurgePlan } from './operations/retirement.js';\nimport { purgePlanSchema } from './operations/retirement.js';\nimport { SessionBinModule, SessionBinError, sessionBinRefusal } from './host/module.js';\nimport { ArchiveModule } from './host/archive.js';\nimport { NativeRetirementOwner } from './host/native-retirement-owner.js';\nimport { installSessionBinRemote } from './host/remote.js';\nimport { planSchema } from './operations/schema.js';\nimport type { BinPlan } from './operations/schema.js';\nimport type { ArchivePlan, ArchivePrepareRequest } from './operations/archive.js';\n\nexport * from './host/platform-files.js';\nexport * from './host/native-retirement-owner.js';\nexport * from './host/native-jsonl-files.js';\nexport * from './host/native-retirement-metadata.js';\nexport * from './host/native-retirement-admission.js';\nexport * from './host/native-retirement-persistence.js';\nexport { acquireBinLease, BinLeaseError } from './host/lease.js';\nexport { DshBinPort } from './host/native.js';\nexport { binDomainSpec, DomainBinStore, archiveDomainSpec, DomainArchiveStore } from './host/store.js';\nexport type { BinStore, ArchiveStore } from './host/store.js';\nexport { SessionBinModule, SessionBinError } from './host/module.js';\nexport { ArchiveModule } from './host/archive.js';\nexport type { NativeArchivePort, ArchiveOptions } from './host/archive.js';\nexport * from './operations/archive.js';\nexport { SessionBinRemote, installSessionBinRemote } from './host/remote.js';\nexport type { NativeBinPort, NativeSessionState, ReconcileReport } from './host/module.js';\nexport type { BinEntry, BinPlan, BinResult, BinOperation, PrepareRequest } from './operations/schema.js';\nexport * from './operations/retirement.js';\nexport * from './host/retirement-store.js';\nexport { retirementManifestDigest } from './host/retirement.js';\nexport type { SessionRetirementOwnerV1, RetirementOptions, PurgeReconcileReport } from './host/retirement.js';\nexport * from './operations/retirement-owner.js';\nexport * from './host/retirement-owner-store.js';\nexport { RetirementOwnerCoordinator, RetirementOwnerError } from './host/retirement-owner.js';\nexport type {\n RetirementOwnerGuards, RetirementLifecycleScope, RetirementLifecyclePort,\n RetirementResourceParticipant, RetirementOwnerCoordinatorOptions, RetirementOwnerCheckpoint,\n RetirementResource, RetirementResourceReceipt,\n} from './host/retirement-owner.js';\n\nexport interface Config { coordinationDirectory?: string; permanentDeletion?: boolean }\nexport const Config = schema.object({\n permanentDeletion: schema.boolean().default(true).description('Enable the version-checked cold JSONL deletion Adapter when its complete composition is supported.'),\n coordinationDirectory: schema.string().description('Absolute shared directory for this Bin domain\u2019s lifetime lock; defaults to $DSH_HOME/session-bin.'),\n});\nexport const name = 'session-bin';\nexport const inject = ['storageDomain', 'workspaceRegistry', 'sessions', 'sessionPersistence', 'typert'];\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context { sessionBin: SessionBin }\n}\n\n/** Production native archive interface; v1 core is confined to compatibility. */\nexport class SessionBin extends Service {\n static inject = inject;\n private module!: ArchiveModule;\n private legacy!: SessionBinModule;\n private archiveStore!: DomainArchiveStore;\n private nativeOwner: NativeRetirementOwner | undefined;\n private ready = false;\n constructor(ctx: Context, private readonly config: Config = {},\n private readonly createNativeOwner: (ctx: Context) => Promise<NativeRetirementOwner | undefined> = ctx => NativeRetirementOwner.open(ctx)) {\n super(ctx, 'sessionBin');\n }\n\n async [Service.init](): Promise<void> {\n const directory = this.config.coordinationDirectory ?? join(resolveDshHome(), 'session-bin');\n const release = await acquireBinLease(directory);\n const domains: Array<() => Promise<void>> = [];\n let stopListening: (() => void) | undefined;\n let disposed = false;\n let finishInitializing!: () => void;\n const initializing = new Promise<void>(resolve => { finishInitializing = resolve; });\n const closeDomains = async () => {\n const errors: unknown[] = [];\n for (const close of [...domains].reverse()) try { await close(); } catch (error) { errors.push(error); }\n if (errors.length) throw new AggregateError(errors, 'Session Bin domains failed to close.');\n };\n try {\n this.ctx.effect(() => async () => {\n disposed = true;\n this.ready = false;\n await initializing;\n const errors: unknown[] = [];\n try { if (this.module) await this.module.close(); } catch (error) { errors.push(error); }\n try { if (this.legacy) await this.legacy.close(); } catch (error) { errors.push(error); }\n try { if (this.nativeOwner) await this.nativeOwner.close(); } catch (error) { errors.push(error); }\n try { stopListening?.(); } catch (error) { errors.push(error); }\n try { await closeDomains(); } catch (error) { errors.push(error); }\n try { await release(); } catch (error) { errors.push(error); }\n if (errors.length) throw new AggregateError(errors, 'Session Bin teardown failed.');\n }, 'session-bin.dispose');\n } catch (error) {\n finishInitializing();\n await release();\n throw error;\n }\n try {\n const domain = await this.ctx.storageDomain.open(binDomainSpec);\n domains.push(() => domain.close());\n this.ctx.fiber.assertActive();\n const retirementDomain = await this.ctx.storageDomain.open(retirementDomainSpec);\n domains.push(() => retirementDomain.close());\n this.ctx.fiber.assertActive();\n const archiveDomain = await this.ctx.storageDomain.open(archiveDomainSpec);\n domains.push(() => archiveDomain.close());\n this.ctx.fiber.assertActive();\n const native = new DshBinPort(this.ctx);\n const legacyStore = new DomainBinStore(domain);\n const retirementStore = new DomainRetirementStore(retirementDomain);\n this.nativeOwner = this.config.permanentDeletion === false ? undefined : await this.createNativeOwner(this.ctx);\n this.ctx.fiber.assertActive();\n // Observation and migration remain inert; only explicit preparation adopts\n // a lifecycle supplied by the independently checked native Adapter.\n this.legacy = new SessionBinModule(legacyStore, native, {\n legacyReadOnly: true, retirement: { store: retirementStore, closeStore: false },\n });\n this.archiveStore = new DomainArchiveStore(archiveDomain);\n this.module = new ArchiveModule(this.archiveStore, native, {\n retirement: { store: retirementStore, closeStore: false,\n ...(this.nativeOwner ? { owner: this.nativeOwner } : {}),\n resolveOwner: async () => {\n if (this.config.permanentDeletion === false) return undefined;\n if (!this.nativeOwner) this.nativeOwner = await this.createNativeOwner(this.ctx);\n return this.nativeOwner;\n },\n verifiedNativeArchive: capabilities => this.nativeOwner !== undefined\n && capabilities.ownerId === 'session-bin-native-jsonl-owner'\n && capabilities.hostVersion === '0.2.0-rc.2' && capabilities.providerId === 'jsonl-session-records-v1' },\n operationIdClaimed: id => legacyStore.operation(id) !== undefined,\n pendingPurge: id => retirementStore.operations().some(operation => operation.phase !== 'done' && operation.plan.sessionId === id),\n reconcileLegacy: () => this.legacy.operations(),\n reconcileLegacyPurge: () => this.legacy.reconcilePurge(),\n });\n stopListening = this.ctx.root.on('domain/changed', change => {\n if (change.domain !== 'workspace' || change.table !== '' || change.operation !== 'put') return;\n const state = workspaceDomainState.parse(change.value);\n // Both consumers capture the frame synchronously before their queues yield.\n const legacy = this.legacy.observeArchives(state.archivedSessionIds);\n const archive = this.module.observeArchives(state.archivedSessionIds);\n void Promise.all([legacy, archive]).catch(error => {\n this.ctx.logger.warn(`session-bin: reconciliation failed: ${String(error)}`);\n });\n });\n await this.legacy.reconcile();\n await this.module.reconcile();\n this.ctx.fiber.assertActive();\n if (!disposed) this.ready = true;\n } finally { finishInitializing(); }\n }\n\n private requireModule(): ArchiveModule {\n if (!this.ready) throw new SessionBinError('bin/not-ready', 'Session Bin has not finished initialization or is unloading.');\n return this.module;\n }\n private checkLegacyClaim(operationId: string) {\n if (this.archiveStore.operation(operationId)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to an archive request.');\n }\n }\n prepare(request: ArchivePrepareRequest) { return this.requireModule().prepare(request); }\n preparePurge(request: PreparePurgeRequest) { return this.requireModule().preparePurge(request); }\n executePurge(input: PurgePlan) {\n const plan = purgePlanSchema.parse(input);\n if (plan.schemaVersion === 2) return this.requireModule().executePurge(plan);\n return this.requireModule().compatibility(async () => { this.checkLegacyClaim(plan.operationId); return this.legacy.executePurge(plan); });\n }\n getPurgeOperation(operationId: string) { return this.requireModule().getPurgeOperation(operationId); }\n purgeOperations() { return this.requireModule().purgeOperations(); }\n reconcilePurge() { return this.requireModule().reconcilePurge(); }\n execute(input: ArchivePlan | BinPlan) {\n if (input.schemaVersion === 2) return this.requireModule().execute(input);\n const plan = planSchema.parse(input);\n return this.requireModule().compatibility(async () => { this.checkLegacyClaim(plan.operationId); return this.legacy.execute(plan); });\n }\n list() { return this.requireModule().list(); }\n operations() { return this.requireModule().operations(); }\n getOperation(operationId: string) {\n return this.requireModule().compatibility(async () => this.archiveStore.operation(operationId) ?? await this.legacy.getOperation(operationId));\n }\n reconcile() { return this.requireModule().reconcile(); }\n}\nexport async function apply(ctx: Context, config: Config = {}) {\n await ctx.plugin(SessionBin, config);\n await installSessionBinRemote(ctx);\n}\n", "import { constants } from 'node:fs';\nimport { mkdir, open, realpath, lstat } from 'node:fs/promises';\nimport { isAbsolute, join } from 'node:path';\nimport { tryLockExclusive } from '@deepseek-ai/node-addon-system/flock';\n\nimport { acquireWindowsSemaphore, nativePlatformCandidate } from './platform-files.js';\n\nexport class BinLeaseError extends Error {\n readonly code = 'bin/lease-unavailable';\n}\n\n// Own only this plugin's lock. Never unlink it: flock coordinates an inode.\n// The directory must be shared by every composition using the same Bin domain.\n// Windows uses a kernel semaphore; the persistent marker is never the arbiter.\nexport async function acquireBinLease(directory: string): Promise<() => Promise<void>> {\n if (!nativePlatformCandidate()) throw new BinLeaseError('This Host platform has no implemented kernel lease.');\n if (!isAbsolute(directory)) throw new BinLeaseError('Coordination directory must be absolute.');\n await mkdir(directory, { recursive: true, mode: 0o700 });\n const root = await realpath(directory);\n const rootIdentity = await lstat(root, { bigint: true });\n const filename = join(root, 'writer.lock');\n try {\n const previous = await lstat(filename, { bigint: true });\n if (!previous.isFile() || previous.nlink !== 1n || previous.size !== 0n) throw new BinLeaseError('The existing coordination marker is not an empty exclusive regular file.');\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n const handle = await open(filename, constants.O_CREAT | constants.O_RDWR | (constants.O_NOFOLLOW ?? 0), 0o600);\n let unlock: (() => Promise<void>) | undefined;\n try {\n if (process.platform === 'win32') unlock = await acquireWindowsSemaphore(filename, 'plugin');\n else await tryLockExclusive(handle.fd);\n const held = await handle.stat({ bigint: true });\n const current = await lstat(filename, { bigint: true });\n const currentRoot = await lstat(root, { bigint: true });\n if (!held.isFile() || !current.isFile() || held.nlink !== 1n || current.nlink !== 1n || held.size !== 0n || current.size !== 0n\n || held.ino !== current.ino || held.dev !== current.dev || held.birthtimeNs !== current.birthtimeNs\n || !currentRoot.isDirectory() || currentRoot.ino !== rootIdentity.ino || currentRoot.dev !== rootIdentity.dev\n || currentRoot.birthtimeNs !== rootIdentity.birthtimeNs || await realpath(directory) !== root) {\n throw new BinLeaseError('The coordination lock identity changed.');\n }\n } catch (cause) {\n const errors = [cause];\n try { await unlock?.(); } catch (error) { errors.push(error); }\n try { await handle.close(); } catch (error) { errors.push(error); }\n throw new BinLeaseError('Cannot acquire exclusive Bin ownership.', { cause: errors.length === 1 ? cause : new AggregateError(errors) });\n }\n let release: Promise<void> | undefined;\n return () => release ??= (async () => {\n const errors: unknown[] = [];\n try { await unlock?.(); } catch (error) { errors.push(error); }\n try { await handle.close(); } catch (error) { errors.push(error); }\n if (errors.length) throw new AggregateError(errors, 'Bin kernel lease release failed.');\n })();\n}\n", "import { createHash } from 'node:crypto';\nimport { constants } from 'node:fs';\nimport { lstat, open } from 'node:fs/promises';\nimport type { FileHandle } from 'node:fs/promises';\nimport { resolve, toNamespacedPath } from 'node:path';\n\nexport type NativePlatform = 'darwin' | 'linux' | 'win32';\nexport function nativePlatformCandidate(platform = process.platform, arch = process.arch): boolean {\n return ['darwin', 'linux', 'win32'].includes(platform) && ['arm64', 'x64'].includes(arch);\n}\n/** Audited runtime carriers; production OS qualification remains independent. */\nexport function nativeRuntimeCandidate(node = process.versions.node, uv = process.versions.uv, electron = process.versions.electron): boolean {\n return uv === '1.52.1' && ((node === '24.18.1' && !electron) || (node === '24.21.0' && electron === '44.7.0'));\n}\n/** Actual erasure evidence is promoted separately from an implemented Adapter. */\nexport function nativePlatformVerified(platform = process.platform, arch = process.arch, node = process.versions.node, uv = process.versions.uv, electron = process.versions.electron): boolean {\n if (node === '24.21.0' && uv === '1.52.1' && electron === '44.7.0') return platform === 'darwin' && arch === 'arm64';\n if (node !== '24.18.1' || uv !== '1.52.1' || electron) return false;\n return new Set(['darwin/arm64', 'darwin/x64', 'linux/arm64', 'linux/x64', 'win32/x64']).has(`${platform}/${arch}`);\n}\n\ninterface WindowsKernel {\n createSemaphore(name: string): number;\n wait(handle: number): number;\n release(handle: number): number;\n close(handle: number): number;\n moveFile(source: string, destination: string, flags: number): number;\n lastError(): number;\n}\nlet windowsKernel: Promise<WindowsKernel> | undefined;\nfunction kernel(): Promise<WindowsKernel> {\n if (process.platform !== 'win32') throw new Error('Windows kernel operations require a native Windows runtime.');\n return windowsKernel ??= (async () => {\n const library = (await import('koffi')).default.load('kernel32.dll');\n const create = library.func('__stdcall', 'CreateSemaphoreW', 'intptr', ['void*', 'int', 'int', 'str16']);\n const wait = library.func('__stdcall', 'WaitForSingleObject', 'uint', ['intptr', 'uint']);\n const release = library.func('__stdcall', 'ReleaseSemaphore', 'int', ['intptr', 'int', 'void*']);\n const close = library.func('__stdcall', 'CloseHandle', 'int', ['intptr']);\n const moveFile = library.func('__stdcall', 'MoveFileExW', 'int', ['str16', 'str16', 'uint']);\n const lastError = library.func('__stdcall', 'GetLastError', 'uint', []);\n return { createSemaphore: name => create(null, 1, 1, name) as number,\n wait: handle => wait(handle, 0) as number, release: handle => release(handle, 1, null) as number,\n close: handle => close(handle) as number, moveFile: (source, destination, flags) => moveFile(source, destination, flags) as number,\n lastError: () => lastError() as number };\n })();\n}\n/** Session namespace matches the audited JSONL writer; plugin ownership is independent. */\nexport function windowsSemaphoreName(path: string, purpose: 'session' | 'plugin'): string {\n const digest = createHash('sha256').update(resolve(path).toLowerCase()).digest('hex');\n return `Local\\\\${purpose === 'session' ? 'dsh-session-lock' : 'dsh-session-bin-lock'}-${digest}`;\n}\nfunction windowsError(syscall: string, error: number): NodeJS.ErrnoException {\n return Object.assign(new Error(`${syscall} failed with Windows error ${error}.`),\n { code: [2, 3].includes(error) ? 'ENOENT' : [80, 183].includes(error) ? 'EEXIST' : error === 17 ? 'EXDEV'\n : error === 32 ? 'EBUSY' : error === 5 ? 'EACCES' : 'EIO', syscall, win32Code: error });\n}\n\n/** Same-volume rename whose metadata acknowledgement is written through. */\nexport async function renameWindowsWriteThrough(source: string, destination: string): Promise<void> {\n const api = await kernel();\n // MOVEFILE_WRITE_THROUGH only: replacing a destination or copying across a\n // volume would expand the caller's frozen path/identity scope.\n if (api.moveFile(toNamespacedPath(source), toNamespacedPath(destination), 8) === 0) throw windowsError('MoveFileExW', api.lastError());\n}\n/** No lock file, expiry, or stale-PID deletion; the last kernel handle owns its lifetime. */\nexport async function acquireWindowsSemaphore(path: string, purpose: 'session' | 'plugin'): Promise<() => Promise<void>> {\n const api = await kernel();\n const handle = api.createSemaphore(windowsSemaphoreName(path, purpose));\n if (handle === 0) throw windowsError('CreateSemaphoreW', api.lastError());\n const result = api.wait(handle);\n if (result !== 0) {\n const error = result === 258 ? 32 : api.lastError();\n if (api.close(handle) === 0) throw new AggregateError([windowsError('WaitForSingleObject', error), windowsError('CloseHandle', api.lastError())], 'Kernel lease acquisition cleanup failed.');\n throw windowsError('WaitForSingleObject', error);\n }\n let releasing: Promise<void> | undefined;\n return () => releasing ??= (async () => {\n const errors: Error[] = [];\n if (api.release(handle) === 0) errors.push(windowsError('ReleaseSemaphore', api.lastError()));\n if (api.close(handle) === 0) errors.push(windowsError('CloseHandle', api.lastError()));\n if (errors.length) throw new AggregateError(errors, 'Kernel lease release failed.');\n })();\n}\n\n/** POSIX namespace durability. Windows callers must use their audited owner protocol. */\nexport async function syncDirectory(path: string): Promise<void> {\n if (process.platform === 'win32') return;\n const handle = await open(path, constants.O_RDONLY | constants.O_NOFOLLOW);\n try { await handle.sync(); } finally { await handle.close(); }\n}\n\nexport class RegularFileRefusal extends Error {\n constructor(readonly code: 'platform/unsafe-file' | 'platform/file-changed' | 'platform/identity-unavailable', message: string) { super(message); }\n}\n\n/** Refuse symlinks and compare the opened identity even when O_NOFOLLOW is unavailable. */\nexport async function openRegularFile(path: string, access: 'read' | 'write'): Promise<FileHandle> {\n const before = await lstat(path, { bigint: true });\n if (!before.isFile() || before.nlink !== 1n) throw new RegularFileRefusal('platform/unsafe-file', 'An exclusive regular file is required.');\n if (before.ino <= 0n || before.birthtimeNs <= 0n) throw new RegularFileRefusal('platform/identity-unavailable', 'The filesystem cannot certify this file incarnation.');\n const handle = await open(path, (access === 'read' ? constants.O_RDONLY : constants.O_RDWR) | (constants.O_NOFOLLOW ?? 0));\n try {\n const actual = await handle.stat({ bigint: true });\n if (!actual.isFile() || actual.nlink !== 1n) throw new RegularFileRefusal('platform/unsafe-file', 'The opened file is not exclusive.');\n if (actual.ino <= 0n || actual.birthtimeNs <= 0n) throw new RegularFileRefusal('platform/identity-unavailable', 'The descriptor cannot certify this file incarnation.');\n if (before.dev !== actual.dev || before.ino !== actual.ino || before.birthtimeNs !== actual.birthtimeNs) {\n throw new RegularFileRefusal('platform/file-changed', 'The regular file changed while opening its descriptor.');\n }\n return handle;\n } catch (error) { await handle.close(); throw error; }\n}\n", "import type { Context } from '@deepseek-ai/cordis';\nimport { SessionId } from '@deepseek-ai/dsh-session';\nimport { WorkspaceActiveSessionError, WorkspaceUnknownSessionError, workspaceDomainState } from '@deepseek-ai/dsh-workspace';\nimport { SessionBinError } from './module.js';\nimport type { NativeBinPort, NativeSessionState } from './module.js';\n\n/** All native actions stay on public SDK methods; cold inspection claims no writer. */\nexport class DshBinPort implements NativeBinPort {\n constructor(private readonly ctx: Context) {}\n archivedSessionIds(): readonly string[] {\n // Domain events publish the committed global snapshot before the Registry's\n // in-memory projection resumes its await. Read that public snapshot so list\n // and admission share the same durable native member set as the frame.\n const domain = this.ctx.storageDomain.get('workspace');\n if (!domain) throw new Error('Native workspace domain is unavailable.');\n return workspaceDomainState.parse(domain.global.get()).archivedSessionIds;\n }\n async inspect(rawId: string): Promise<NativeSessionState> {\n const id = SessionId(rawId);\n const live = this.ctx.sessions.get(id);\n const persisted = live ? undefined : await this.ctx.sessionPersistence.stat(id);\n return {\n archived: this.archivedSessionIds().includes(id),\n known: live !== undefined || persisted !== undefined,\n workspaceId: this.ctx.workspaceRegistry.list().find(workspace => workspace.sessionIds.includes(id))?.id ?? null,\n };\n }\n async activity(rawId: string): Promise<string[]> {\n const activity = await this.ctx.waterfall('workspace/session-activity',\n { sessionId: SessionId(rawId) }, async () => []);\n return activity.map(item => String(item.kind));\n }\n async archive(rawId: string): Promise<void> {\n try {\n await this.ctx.workspaceRegistry.archiveSession(SessionId(rawId));\n } catch (cause) {\n if (cause instanceof WorkspaceActiveSessionError) {\n throw new SessionBinError('session-active', cause.message, { cause });\n }\n if (cause instanceof WorkspaceUnknownSessionError) {\n throw new SessionBinError('session-not-found', cause.message, { cause });\n }\n throw cause;\n }\n }\n unarchive(rawId: string): Promise<void> {\n return this.ctx.workspaceRegistry.unarchiveSession(SessionId(rawId));\n }\n}\n", "import { randomUUID } from 'node:crypto';\nimport { entrySchema, planSchema, prepareRequestSchema, resultSchema } from '../operations/schema.js';\nimport type { BinBlocker, BinEntry, BinOperation, BinPlan, BinResult, PrepareRequest } from '../operations/schema.js';\nimport type { BinStore } from './store.js';\nimport { SessionBinPurgeModule } from './retirement.js';\nimport type { RetirementOptions } from './retirement.js';\nimport { preparePurgeRequestSchema, purgePlanSchema } from '../operations/retirement.js';\nimport type { PreparePurgeRequest, PurgePlan } from '../operations/retirement.js';\n\nexport class SessionBinError extends Error {\n constructor(readonly code: string, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'SessionBinError';\n }\n}\nconst businessRefusals = new WeakSet<SessionBinError>();\n/** Internal marker: external failures using the same public Error class remain unknown. */\nexport function sessionBinRefusal(code: string, message: string): SessionBinError {\n const error = new SessionBinError(code, message);\n businessRefusals.add(error);\n return error;\n}\nexport function isSessionBinRefusal(error: unknown): boolean {\n return error instanceof SessionBinError && businessRefusals.has(error);\n}\nexport interface NativeSessionState {\n archived: boolean;\n known: boolean;\n workspaceId: string | null;\n}\nexport interface NativeBinPort {\n inspect(sessionId: string): Promise<NativeSessionState>;\n activity(sessionId: string): Promise<string[]>;\n archive(sessionId: string): Promise<void>;\n unarchive(sessionId: string): Promise<void>;\n}\nexport interface ReconcileReport {\n completed: BinResult[];\n retryRequired: string[];\n releasedEntries: string[];\n}\n\n/** One Host owns this Module; its caller holds the lifetime lease before open. */\nexport class SessionBinModule {\n private tail: Promise<unknown> = Promise.resolve();\n private closing = false;\n private failed = false;\n private failure: unknown;\n private closePromise: Promise<void> | undefined;\n private readonly invalidated = new Set<string>();\n private readonly observedArchived = new Set<string>();\n private readonly purge: SessionBinPurgeModule | undefined;\n\n constructor(private readonly store: BinStore, private readonly native: NativeBinPort,\n private readonly options: { retirement?: RetirementOptions; legacyReadOnly?: boolean } = {}) {\n this.purge = options.retirement ? new SessionBinPurgeModule(options.retirement, {\n newRequestsDisabled: options.legacyReadOnly === true,\n entry: id => this.store.entry(id), invalidated: id => this.invalidated.has(id),\n archived: async id => (await this.native.inspect(id)).archived,\n activity: id => this.native.activity(id), deleteEntry: id => this.store.deleteEntry(id),\n hasArchiveOperation: id => this.store.operation(id) !== undefined,\n hasPendingArchiveOperation: id => this.store.operations().some(item => item.phase !== 'done' && item.plan.sessionId === id),\n }) : undefined;\n }\n\n preparePurge(request: PreparePurgeRequest) {\n const input = preparePurgeRequestSchema.parse(request);\n return this.enqueue(async () => {\n await this.reconcileInner();\n return this.requirePurge().prepare(input);\n });\n }\n executePurge(input: PurgePlan) {\n const plan = purgePlanSchema.parse(input);\n return this.enqueue(() => this.requirePurge().execute(plan));\n }\n getPurgeOperation(operationId: string) { return this.enqueue(async () => this.requirePurge().operation(operationId)); }\n purgeOperations() { return this.enqueue(async () => this.requirePurge().operations()); }\n reconcilePurge() { return this.enqueue(() => this.requirePurge().reconcile(true)); }\n private requirePurge(): SessionBinPurgeModule {\n if (!this.purge) throw sessionBinRefusal('bin/permanent-deletion-unsupported', 'No retirement journal/owner is composed.');\n return this.purge;\n }\n\n prepare(request: PrepareRequest): Promise<BinPlan> {\n const input = prepareRequestSchema.parse(request);\n return this.enqueue(async () => {\n await this.reconcileInner();\n const state = await this.native.inspect(input.sessionId);\n const entry = this.store.entry(input.sessionId);\n const plan: BinPlan = {\n schemaVersion: 1,\n operationId: input.operationId ?? randomUUID(),\n action: input.action,\n sessionId: input.sessionId,\n expected: { archived: state.archived, entryId: entry?.entryId ?? null },\n blockers: [],\n };\n plan.blockers = await this.blockers(plan, state, entry);\n return planSchema.parse(plan);\n });\n }\n\n execute(input: BinPlan): Promise<BinResult> {\n // Snapshot at admission: callers cannot mutate an enqueued request.\n const plan = planSchema.parse(input);\n return this.enqueue(async () => {\n if (this.purge?.operation(plan.operationId)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to a purge request.');\n }\n const previous = this.store.operation(plan.operationId);\n if (previous) {\n if (!this.sameRequest(previous.plan, plan)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to a different request.');\n }\n if (previous.result) return resultSchema.parse(previous.result);\n if (previous.phase === 'applied') return this.finalize(previous);\n }\n if (this.options.legacyReadOnly) {\n await this.reconcileInner();\n const receipt = this.store.operation(plan.operationId)?.result;\n return receipt ? resultSchema.parse(receipt) : this.finish(this.emptyOperation(plan), 'rejected', 'legacy-operation-disabled');\n }\n await this.reconcileInner();\n const recovered = this.store.operation(plan.operationId);\n if (recovered?.result) return resultSchema.parse(recovered.result);\n const state = await this.native.inspect(plan.sessionId);\n const current = this.store.entry(plan.sessionId);\n const stale = state.archived !== plan.expected.archived\n || (current?.entryId ?? null) !== plan.expected.entryId\n || (recovered?.entry && this.invalidated.has(recovered.entry.entryId));\n if (stale) return this.finish(recovered ?? this.emptyOperation(plan), 'conflict', 'state-changed');\n const blockers = await this.blockers(plan, state, current);\n if (blockers.length) return this.finish(recovered ?? this.emptyOperation(plan), 'rejected', blockers[0]!.code);\n const entry = recovered?.entry ?? (plan.action === 'bin' ? entrySchema.parse({\n schemaVersion: 1,\n sessionId: plan.sessionId,\n entryId: randomUUID(),\n operationId: plan.operationId,\n binnedAt: new Date().toISOString(),\n workspaceIdAtBin: state.workspaceId,\n wasArchived: state.archived,\n }) : current!);\n const operation: BinOperation = recovered ?? {\n ...this.emptyOperation(plan), entry, phase: 'intent',\n };\n if (plan.action === 'bin' && !recovered) await this.purge?.capture(entry);\n await this.store.putOperation(operation);\n // The intent write itself yields. Check native state and activity again;\n // ordinary native archive still performs its own admission waterfall.\n const fresh = await this.native.inspect(plan.sessionId);\n if (fresh.archived !== plan.expected.archived || this.invalidated.has(entry.entryId)) {\n return this.finish(operation, 'conflict', 'state-changed');\n }\n if (!fresh.known) return this.finish(operation, 'rejected', 'session-not-found');\n try {\n if (plan.action === 'bin') {\n if ((await this.native.activity(plan.sessionId)).length) {\n return this.finish(operation, 'rejected', 'session-active');\n }\n const admitted = await this.native.inspect(plan.sessionId);\n if (admitted.archived !== plan.expected.archived || this.invalidated.has(entry.entryId)) {\n return this.finish(operation, 'conflict', 'state-changed');\n }\n if (!admitted.known) return this.finish(operation, 'rejected', 'session-not-found');\n await this.native.archive(plan.sessionId);\n } else if (!entry.wasArchived) {\n await this.native.unarchive(plan.sessionId);\n }\n } catch (error) {\n if (error instanceof SessionBinError\n && (error.code === 'session-active' || error.code === 'session-not-found')) {\n return this.finish(operation, 'rejected', error.code);\n }\n throw error;\n }\n const applied: BinOperation = { ...operation, phase: 'applied' };\n await this.store.putOperation(applied);\n return this.finalize(applied);\n });\n }\n\n list(): Promise<BinEntry[]> {\n return this.enqueue(async () => {\n await this.reconcileInner();\n return this.store.entries();\n });\n }\n operations(): Promise<BinOperation[]> {\n return this.enqueue(async () => {\n await this.reconcileInner();\n return this.store.operations();\n });\n }\n getOperation(operationId: string): Promise<BinOperation | undefined> {\n return this.enqueue(async () => this.store.operation(operationId));\n }\n reconcile(): Promise<ReconcileReport> {\n return this.enqueue(async () => {\n await this.purge?.reconcile(true);\n return this.reconcileInner();\n });\n }\n\n /** Capture each native archive frame NOW, before queued reconciliation yields.\n * An observed unarchive/rearchive must not restore an old entry's ownership.\n * No archive-generation token exists in the SDK for an unobserved restart ABA.\n */\n observeArchives(archivedSessionIds: readonly string[]): Promise<ReconcileReport> {\n if (this.failed) return Promise.reject(this.unavailable());\n const archived = new Set(archivedSessionIds);\n try {\n for (const entry of this.store.entries()) {\n if (!archived.has(entry.sessionId)) this.invalidated.add(entry.entryId);\n }\n for (const operation of this.store.operations()) {\n const entry = operation.entry;\n if (operation.phase === 'done' || !entry) continue;\n if (archived.has(entry.sessionId)) this.observedArchived.add(entry.entryId);\n else if (operation.phase === 'applied' || entry.wasArchived\n || this.observedArchived.has(entry.entryId)) this.invalidated.add(entry.entryId);\n }\n } catch (error) {\n // Capture runs outside the queue so frames cannot be lost behind a yield.\n // Store reads here are still external I/O boundaries, never business refusals.\n this.failed = true; this.failure = error;\n return Promise.reject(error);\n }\n return this.closing\n ? Promise.resolve({ completed: [], retryRequired: [], releasedEntries: [] })\n : this.enqueue(() => this.reconcileInner());\n }\n\n close(): Promise<void> {\n this.closing = true;\n return this.closePromise ??= this.tail.then(async () => {\n try {\n if (!this.failed) await this.reconcileInner();\n } finally {\n try { await this.purge?.close(); }\n finally { await this.store.close(); }\n }\n });\n }\n\n private emptyOperation(plan: BinPlan): BinOperation {\n return { schemaVersion: 1, plan, createdAt: new Date().toISOString(), phase: 'done', ownershipInvalidated: false, entry: null, result: null };\n }\n private sameRequest(a: BinPlan, b: BinPlan): boolean {\n return a.action === b.action && a.sessionId === b.sessionId\n && a.expected.archived === b.expected.archived && a.expected.entryId === b.expected.entryId;\n }\n private async blockers(plan: BinPlan, state: NativeSessionState, entry: BinEntry | undefined): Promise<BinBlocker[]> {\n const blockers: BinBlocker[] = [];\n if (this.purge?.blocks(plan.sessionId)) blockers.push({ code: 'pending-deletion' });\n if (!state.known) blockers.push({ code: 'session-not-found' });\n if (plan.action === 'bin' && entry) blockers.push({ code: 'already-in-bin' });\n if (plan.action === 'restore' && !entry) blockers.push({ code: 'not-in-bin' });\n if (this.store.operations().some(operation => operation.phase !== 'done'\n && operation.plan.sessionId === plan.sessionId && operation.plan.operationId !== plan.operationId)) {\n blockers.push({ code: 'pending-operation' });\n }\n if (plan.action === 'bin' && state.known) {\n const activity = await this.native.activity(plan.sessionId);\n if (activity.length) blockers.push({ code: 'session-active', activity });\n }\n return blockers;\n }\n private async finish(operation: BinOperation, status: BinResult['status'], reason: string | null): Promise<BinResult> {\n const result = resultSchema.parse({\n operationId: operation.plan.operationId,\n action: operation.plan.action,\n sessionId: operation.plan.sessionId,\n status, reason, entryId: operation.entry?.entryId ?? null,\n });\n const ownershipInvalidated = operation.ownershipInvalidated\n || (operation.entry !== null && this.invalidated.has(operation.entry.entryId))\n || reason === 'archive-changed';\n await this.store.putOperation({ ...operation, phase: 'done', ownershipInvalidated, result });\n return resultSchema.parse(result);\n }\n private async finalize(operation: BinOperation): Promise<BinResult> {\n const entry = operation.entry!;\n const state = await this.native.inspect(operation.plan.sessionId);\n const targetArchived = operation.plan.action === 'bin' || entry.wasArchived;\n const lost = this.invalidated.has(entry.entryId)\n && (operation.plan.action === 'bin' || entry.wasArchived);\n if (state.archived !== targetArchived || lost) {\n return this.finish(operation, 'conflict', 'archive-changed');\n }\n if (!state.known) return this.finish(operation, 'conflict', 'session-not-found');\n if (operation.plan.action === 'bin' && this.purge && !(await this.purge.bindingMatches(entry))) {\n return this.finish(operation, 'conflict', 'lifecycle-changed');\n }\n const current = this.store.entry(entry.sessionId);\n if (current && current.entryId !== entry.entryId) {\n return this.finish(operation, 'conflict', 'entry-changed');\n }\n if (operation.plan.action === 'bin') {\n if (!current) await this.store.putEntry(entry);\n if (this.invalidated.has(entry.entryId)) {\n const result = await this.finish(operation, 'conflict', 'archive-changed');\n await this.store.deleteEntry(entry.sessionId);\n return result;\n }\n } else if (current) {\n await this.store.deleteEntry(entry.sessionId);\n }\n return this.finish(operation, 'success', null);\n }\n private async reconcileInner(): Promise<ReconcileReport> {\n const report: ReconcileReport = { completed: [], retryRequired: [], releasedEntries: [] };\n await this.purge?.reconcile();\n for (const operation of this.store.operations()) {\n if (operation.ownershipInvalidated && operation.entry) this.invalidated.add(operation.entry.entryId);\n }\n for (const operation of this.store.operations()) {\n if (operation.phase === 'done') continue;\n if (operation.phase === 'applied') {\n report.completed.push(await this.finalize(operation));\n continue;\n }\n // Equal before/after booleans cannot prove whether a native call ran and\n // was then undone. Retain a terminal receipt; a NEW explicit plan is needed.\n report.completed.push(await this.finish(operation, 'conflict', 'interrupted'));\n report.retryRequired.push(operation.plan.operationId);\n }\n for (const entry of this.store.entries()) {\n if (this.purge?.ownsPendingEntry(entry.entryId)) continue;\n if (this.invalidated.has(entry.entryId) || !(await this.native.inspect(entry.sessionId)).archived) {\n const owner = this.store.operation(entry.operationId);\n if (!owner || owner.entry?.entryId !== entry.entryId) {\n throw new Error('Bin entry has no matching ownership journal.');\n }\n if (!owner.ownershipInvalidated) {\n await this.store.putOperation({ ...owner, ownershipInvalidated: true });\n }\n await this.store.deleteEntry(entry.sessionId);\n report.releasedEntries.push(entry.sessionId);\n }\n }\n return report;\n }\n private unavailable(): SessionBinError {\n return new SessionBinError(this.failed ? 'bin/recovery-required' : 'bin/closed',\n this.failed ? 'An unexpected failure suspended this Module. Close and reopen before retrying.' : 'Session Bin is closing.',\n this.failed ? { cause: this.failure } : undefined);\n }\n private enqueue<T>(work: () => Promise<T>): Promise<T> {\n if (this.closing || this.failed) return Promise.reject(this.unavailable());\n const result = this.tail.then(async () => {\n if (this.failed) throw this.unavailable();\n try { return await work(); }\n catch (error) {\n // An I/O rejection may follow a durable rename. Do not keep writing from\n // an in-memory snapshot that could now differ from the backend medium.\n if (!isSessionBinRefusal(error)) { this.failed = true; this.failure = error; }\n throw error;\n }\n });\n this.tail = result.then(() => undefined, () => undefined);\n return result;\n }\n}\n", "import { z } from 'zod';\n\nconst identity = z.string().min(1).max(1024);\nexport const actionSchema = z.enum(['bin', 'restore']);\nexport const blockerSchema = z.object({\n code: z.string().min(1),\n activity: z.array(z.string()).optional(),\n}).strict();\nexport const entrySchema = z.object({\n schemaVersion: z.literal(1),\n sessionId: identity,\n entryId: z.uuid(),\n operationId: identity,\n binnedAt: z.iso.datetime(),\n workspaceIdAtBin: identity.nullable(),\n wasArchived: z.boolean(),\n}).strict();\nexport const planSchema = z.object({\n schemaVersion: z.literal(1),\n operationId: identity,\n action: actionSchema,\n sessionId: identity,\n expected: z.object({ archived: z.boolean(), entryId: z.uuid().nullable() }).strict(),\n blockers: z.array(blockerSchema),\n}).strict();\nexport const resultSchema = z.object({\n operationId: identity,\n action: actionSchema,\n sessionId: identity,\n status: z.enum(['success', 'rejected', 'conflict']),\n reason: z.string().min(1).nullable(),\n entryId: z.uuid().nullable(),\n}).strict();\nexport const operationSchema = z.object({\n schemaVersion: z.literal(1),\n plan: planSchema,\n createdAt: z.iso.datetime(),\n phase: z.enum(['intent', 'applied', 'done']),\n ownershipInvalidated: z.boolean(),\n entry: entrySchema.nullable(),\n result: resultSchema.nullable(),\n}).strict().superRefine((operation, ctx) => {\n const { plan, entry, result, phase } = operation;\n if ((phase === 'done') !== (result !== null)) {\n ctx.addIssue({ code: 'custom', message: 'Only a done operation has a result.' });\n }\n if (phase !== 'done' && entry === null) {\n ctx.addIssue({ code: 'custom', message: 'An unfinished operation requires its entry snapshot.' });\n }\n if (entry && (entry.sessionId !== plan.sessionId\n || (plan.action === 'bin' && (entry.operationId !== plan.operationId\n || entry.wasArchived !== plan.expected.archived))\n || (plan.action === 'restore' && entry.entryId !== plan.expected.entryId))) {\n ctx.addIssue({ code: 'custom', message: 'Entry snapshot does not match the operation.' });\n }\n if (result && ((result.status === 'success') !== (result.reason === null)\n || result.entryId !== (entry?.entryId ?? null)\n || (result.status === 'success' && !entry))) {\n ctx.addIssue({ code: 'custom', message: 'Result outcome or entry snapshot is inconsistent.' });\n }\n if (operation.ownershipInvalidated && !entry) {\n ctx.addIssue({ code: 'custom', message: 'Ownership invalidation requires an entry identity.' });\n }\n if (result && (result.operationId !== plan.operationId\n || result.sessionId !== plan.sessionId || result.action !== plan.action)) {\n ctx.addIssue({ code: 'custom', message: 'Result does not match the operation.' });\n }\n});\nexport const prepareRequestSchema = z.object({\n action: actionSchema,\n sessionId: identity,\n operationId: identity.optional(),\n}).strict();\n\nexport type BinEntry = z.infer<typeof entrySchema>;\nexport type BinPlan = z.infer<typeof planSchema>;\nexport type BinResult = z.infer<typeof resultSchema>;\nexport type BinOperation = z.infer<typeof operationSchema>;\nexport type BinBlocker = z.infer<typeof blockerSchema>;\nexport type PrepareRequest = z.infer<typeof prepareRequestSchema>;\n", "import { createHash, randomUUID } from 'node:crypto';\nimport type { BinEntry } from '../operations/schema.js';\nimport type { ArchiveEntry } from '../operations/archive.js';\nimport {\n lifecycleEqual, lifecycleKeySchema, preparePurgeRequestSchema, purgePlanSchema, purgeResultSchema,\n retirementBindingSchema, retirementCapabilitiesSchema, retirementManifestSchema, retirementStateSchema,\n retirementAuthorizationSchema, retirementRequestSchema,\n} from '../operations/retirement.js';\nimport type {\n LifecycleKey, PreparePurgeRequest, PurgeOperation, PurgePlan, PurgeResult, RetirementBinding,\n RetirementCapabilities, RetirementManifest, RetirementRequest, RetirementState, RetirementAuthorization,\n} from '../operations/retirement.js';\nimport type { RetirementStore } from './retirement-store.js';\nimport { sessionBinRefusal, isSessionBinRefusal, SessionBinError } from './module.js';\n\nconst ownerRefusals = new WeakSet<Error>();\nexport function isRetirementOwnerRefusal(error: unknown): boolean { return error instanceof Error && ownerRefusals.has(error); }\nexport function retirementOwnerRefusal(reason: string): Error {\n const error = new Error(reason); ownerRefusals.add(error); return error;\n}\n\n/** The resource owner implements its own durable admission fence and recovery.\n * This interface is a plugin seam, not a native DSH SDK service. */\nexport interface SessionRetirementOwnerV1 {\n capabilities(): Promise<RetirementCapabilities>;\n eligibility?(sessionId: string): Promise<string | null>;\n inspect(sessionId: string): Promise<LifecycleKey | null>;\n prepare(expected: LifecycleKey): Promise<RetirementManifest>;\n retire(request: RetirementRequest, authorize: () => Promise<RetirementAuthorization>, frozenManifest?: RetirementManifest): Promise<RetirementState>;\n getOperation(operationId: string): Promise<RetirementState | null>;\n recover(operationId: string): Promise<RetirementState>;\n}\nexport interface RetirementOptions {\n store: RetirementStore;\n /** False when the composition closes a journal shared by multiple consumers after draining both. */\n closeStore?: boolean;\n owner?: SessionRetirementOwnerV1;\n resolveOwner?: () => Promise<SessionRetirementOwnerV1 | undefined>;\n /** Admission is supplied by the Host composition, never by owner self-report or Client Config. */\n verified?: (capabilities: RetirementCapabilities) => boolean;\n /** Separate qualification for native archive admission and visibility coordination. */\n verifiedNativeArchive?: (capabilities: RetirementCapabilities) => boolean;\n}\nexport interface PurgeHooks {\n newRequestsDisabled?: boolean;\n target?: 'native-archive';\n entry(sessionId: string): BinEntry | ArchiveEntry | undefined;\n invalidated(entryId: string): boolean;\n archived(sessionId: string): Promise<boolean>;\n activity(sessionId: string): Promise<string[]>;\n deleteEntry(sessionId: string): Promise<void>;\n hasArchiveOperation(operationId: string): boolean;\n hasPendingArchiveOperation(sessionId: string): boolean;\n}\nexport interface PurgeReconcileReport { completed: PurgeResult[]; pending: string[] }\n\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value && typeof value === 'object') {\n return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical((value as Record<string, unknown>)[key])}`).join(',')}}`;\n }\n return JSON.stringify(value);\n}\nfunction capabilitiesKey(value: RetirementCapabilities): string {\n return canonical({ ...value, participants: [...value.participants].sort((a, b) => a.id < b.id ? -1 : a.id > b.id ? 1 : 0) });\n}\nexport function retirementManifestDigest(input: RetirementManifest): string {\n const manifest = retirementManifestSchema.parse(input);\n const ordered = { ...manifest, capabilities: JSON.parse(capabilitiesKey(manifest.capabilities)),\n resources: [...manifest.resources].sort((a, b) => {\n const first = JSON.stringify([a.ownerId, a.resourceId]);\n const second = JSON.stringify([b.ownerId, b.resourceId]);\n return first < second ? -1 : first > second ? 1 : 0;\n }) };\n return createHash('sha256').update(canonical(ordered)).digest('hex');\n}\nfunction sameBinding(a: RetirementBinding, b: RetirementBinding): boolean {\n return a.schemaVersion === b.schemaVersion && a.entryId === b.entryId && a.entryVersion === b.entryVersion && lifecycleEqual(a.lifecycle, b.lifecycle)\n && capabilitiesKey(a.capabilities) === capabilitiesKey(b.capabilities);\n}\nfunction samePlan(a: PurgePlan, b: PurgePlan): boolean {\n return a.schemaVersion === b.schemaVersion && a.sessionId === b.sessionId && a.expectedEntryId === b.expectedEntryId\n && (a.binding === null ? b.binding === null : b.binding !== null && sameBinding(a.binding, b.binding))\n && (a.manifest === null ? b.manifest === null : b.manifest !== null && retirementManifestDigest(a.manifest) === retirementManifestDigest(b.manifest));\n}\nfunction requestFor(plan: PurgePlan): RetirementRequest {\n if (!plan.binding || !plan.manifest) throw new Error('Executable purge lacks its lifecycle witness.');\n return retirementRequestSchema.parse({ operationId: plan.operationId, expected: plan.binding.lifecycle,\n bin: plan.binding.schemaVersion === 2\n ? { kind: 'native-archive', entryId: plan.binding.entryId, entryVersion: 2 }\n : { entryId: plan.binding.entryId, entryVersion: 1 },\n manifestDigest: retirementManifestDigest(plan.manifest) });\n}\n\nfunction externalFailure(context: string, cause: unknown): Error {\n const message = cause instanceof Error ? cause.message : String(cause);\n return new Error(`${context}: ${message}`, { cause });\n}\nfunction externalRead<T>(context: string, work: () => T): T {\n try { return work(); } catch (cause) { throw externalFailure(context, cause); }\n}\nasync function externalCall<T>(context: string, work: () => Promise<T>): Promise<T> {\n try { return await work(); } catch (cause) { throw externalFailure(context, cause); }\n}\n\n/** Inner operations only: the owning archive/legacy Module supplies the queue, failure fence and lifetime lease. */\nexport class SessionBinPurgeModule {\n private readonly store: RetirementStore;\n constructor(private readonly options: RetirementOptions, private readonly hooks: PurgeHooks) {\n const store = options.store;\n this.store = {\n binding: id => externalRead('Retirement journal read failed', () => store.binding(id)),\n operation: id => externalRead('Retirement journal read failed', () => store.operation(id)),\n operations: () => externalRead('Retirement journal read failed', () => store.operations()),\n putBinding: value => externalCall('Retirement journal write failed', () => store.putBinding(value)),\n putOperation: value => externalCall('Retirement journal write failed', () => store.putOperation(value)),\n close: () => externalCall('Retirement journal close failed', () => store.close()),\n };\n for (const operation of this.store.operations()) {\n if (hooks.hasArchiveOperation(operation.plan.operationId)) throw new Error('An operation identity is claimed by both Bin journals.');\n if (operation.ownerState) this.validateOwnerState(operation.plan, operation.ownerState, operation.authorizationId);\n }\n }\n operation(operationId: string): PurgeOperation | undefined { return this.store.operation(operationId); }\n operations(): PurgeOperation[] { return this.store.operations(); }\n blocks(sessionId: string): boolean {\n return this.store.operations().some(item => item.plan.sessionId === sessionId && item.phase !== 'done');\n }\n blocksTarget(sessionId: string): boolean {\n const version = this.hooks.target === 'native-archive' ? 2 : 1;\n return this.store.operations().some(item => item.schemaVersion === version && item.plan.sessionId === sessionId && item.phase !== 'done');\n }\n ownsPendingEntry(entryId: string): boolean {\n return this.store.operations().some(item => item.entry?.entryId === entryId && item.phase !== 'done');\n }\n close(): Promise<void> { return this.options.closeStore === false ? Promise.resolve() : this.store.close(); }\n\n async capture(entry: BinEntry): Promise<void> {\n const capabilities = await this.admittedCapabilities();\n if (!capabilities) return;\n const observed = await this.ownerCall(() => this.options.owner!.inspect(entry.sessionId));\n if (observed === null) return;\n const lifecycle = lifecycleKeySchema.parse(observed);\n if (lifecycle.sessionId !== entry.sessionId || lifecycle.storeId !== capabilities.storeId) {\n throw new Error('Resource owner inspection returned a different session/store.');\n }\n await this.store.putBinding({ schemaVersion: 1, entryId: entry.entryId, entryVersion: 1, lifecycle, capabilities });\n }\n async bindingMatches(entry: BinEntry): Promise<boolean> {\n const binding = this.store.binding(entry.entryId);\n if (!binding) return true; // Legacy/reversible entries carry no destructive authority.\n const capabilities = await this.admittedCapabilities();\n if (!capabilities || capabilitiesKey(capabilities) !== capabilitiesKey(binding.capabilities)) return false;\n const observed = await this.ownerCall(() => this.options.owner!.inspect(entry.sessionId));\n return observed !== null && lifecycleEqual(binding.lifecycle, lifecycleKeySchema.parse(observed));\n }\n\n async prepare(input: PreparePurgeRequest): Promise<PurgePlan> {\n const request = preparePurgeRequestSchema.parse(input);\n const version = this.hooks.target === 'native-archive' ? 2 : 1;\n const entry = this.hooks.entry(request.sessionId);\n let binding = entry ? this.store.binding(entry.entryId) ?? null : null;\n const plan: PurgePlan = { schemaVersion: version, action: 'purge', operationId: request.operationId ?? randomUUID(),\n sessionId: request.sessionId, expectedEntryId: entry?.entryId ?? null, binding, manifest: null, blockers: [] };\n if (version === 2 && (this.hooks.hasArchiveOperation(plan.operationId) || this.store.operation(plan.operationId))) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Prepare requires a fresh operation identity.');\n }\n try {\n // Explicit preparation alone may bind an observed native member. Listing,\n // startup and old Bin migration never mint lifecycle witnesses.\n if (version === 2 && entry && !binding && !this.blocks(entry.sessionId)\n && !this.hooks.hasPendingArchiveOperation(entry.sessionId) && !this.hooks.invalidated(entry.entryId)\n && await this.hooks.archived(entry.sessionId)) {\n const capabilities = await this.admittedCapabilities();\n if (capabilities && await this.eligibility(entry.sessionId) === null) {\n const observed = await this.ownerCall(() => this.options.owner!.inspect(entry.sessionId));\n if (observed !== null) {\n binding = retirementBindingSchema.parse({ schemaVersion: 2, target: 'native-archive',\n entryId: entry.entryId, entryVersion: 2, lifecycle: lifecycleKeySchema.parse(observed), capabilities });\n if (binding.lifecycle.sessionId !== entry.sessionId) throw new Error('Owner inspection changed the target session.');\n if (!this.hooks.invalidated(entry.entryId) && this.hooks.entry(entry.sessionId)?.entryId === entry.entryId\n && await this.hooks.archived(entry.sessionId)) {\n await this.store.putBinding(binding);\n plan.binding = binding;\n }\n }\n }\n }\n const reason = await this.check(plan, false);\n if (reason) plan.blockers.push({ code: reason });\n else {\n const manifest = retirementManifestSchema.parse(await this.ownerCall(() => this.options.owner!.prepare(lifecycleKeySchema.parse(plan.binding!.lifecycle))));\n this.validateManifest(plan.binding!, manifest);\n plan.manifest = manifest;\n const changed = await this.check(plan, true);\n if (changed) plan.blockers.push({ code: changed });\n }\n } catch (error) {\n const reason = this.refusalReason(error);\n if (reason === null) throw error;\n plan.manifest = null; plan.blockers.push({ code: reason });\n }\n return purgePlanSchema.parse(plan);\n }\n\n async execute(input: PurgePlan): Promise<PurgeResult> {\n const plan = purgePlanSchema.parse(input);\n if (this.hooks.hasArchiveOperation(plan.operationId)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to an archive request.');\n }\n const previous = this.store.operation(plan.operationId);\n if (previous) {\n if (!samePlan(previous.plan, plan)) throw sessionBinRefusal('bin/operation-id-reused', 'Purge identity belongs to a different request.');\n if (previous.phase === 'done') return purgeResultSchema.parse(previous.result);\n if (plan.schemaVersion !== (this.hooks.target === 'native-archive' ? 2 : 1)) {\n throw sessionBinRefusal('bin/deletion-target-mismatch', 'Pending deletion requires its original target consumer.');\n }\n return this.recover(previous);\n }\n if (plan.schemaVersion !== (this.hooks.target === 'native-archive' ? 2 : 1)) {\n throw sessionBinRefusal('bin/deletion-target-mismatch', 'Deletion plan belongs to a different target protocol.');\n }\n const current = this.hooks.entry(plan.sessionId);\n const entry = current?.entryId === plan.expectedEntryId ? current : null;\n const operation: PurgeOperation = { schemaVersion: plan.schemaVersion, plan, createdAt: new Date().toISOString(),\n phase: 'intent', entry, authorizationId: null, ownerState: null, result: null };\n if ((current?.entryId ?? null) !== plan.expectedEntryId) return this.finish(operation, 'conflict', 'entry-changed');\n const reason = await this.check(plan, true);\n if (reason) return this.finish(operation, 'rejected', reason);\n let fresh: RetirementManifest;\n try { fresh = retirementManifestSchema.parse(await this.ownerCall(() => this.options.owner!.prepare(lifecycleKeySchema.parse(plan.binding!.lifecycle)))); }\n catch (error) {\n const refusal = this.refusalReason(error);\n if (refusal === null) throw error;\n return this.finish(operation, 'rejected', refusal);\n }\n this.validateManifest(plan.binding!, fresh);\n if (retirementManifestDigest(fresh) !== retirementManifestDigest(plan.manifest!)) {\n return this.finish(operation, 'conflict', 'resource-scope-changed');\n }\n // Query before saving intent: an owner record with no local journal must\n // not be overwritten or silently treated as a new authorization.\n const existingOwnerOperation = await this.ownerCall(() => this.options.owner!.getOperation(plan.operationId));\n if (existingOwnerOperation !== null) {\n retirementStateSchema.parse(existingOwnerOperation);\n return this.finish(operation, 'conflict', 'owner-operation-id-reused');\n }\n await this.store.putOperation(operation);\n let authorizationId: string | null = null;\n let callbackUsed = false;\n let revoked = false;\n let authorizing: Promise<RetirementAuthorization> | undefined;\n let callbackViolation: Error | undefined;\n const assertLive = () => {\n if (revoked) throw new Error('Retirement authorization capability has been revoked.');\n };\n const refusedCall = (error: Error): Promise<RetirementAuthorization> => {\n const refused = Promise.reject<RetirementAuthorization>(error);\n void refused.catch(() => {}); // Contain an owner that ignores its rejected capability.\n return refused;\n };\n const authorize = (): Promise<RetirementAuthorization> => {\n if (revoked) return refusedCall(new Error('Retirement authorization capability has been revoked.'));\n if (callbackUsed) {\n callbackViolation = new Error('Retirement authorization capability is single-use.');\n return refusedCall(callbackViolation);\n }\n callbackUsed = true;\n authorizing = (async (): Promise<RetirementAuthorization> => {\n const reason = await this.check(plan, true, true);\n assertLive();\n if (reason !== null) return { authorized: false, reason };\n const nonce = randomUUID();\n await this.store.putOperation({ ...operation, phase: 'authorizing', authorizationId: nonce });\n assertLive();\n const afterWrite = await this.check(plan, true, true);\n assertLive();\n if (afterWrite !== null) return { authorized: false, reason: afterWrite };\n // The nonce is never in the request. Only a completed successful callback\n // hands it to the owner; a mere persisted attempt cannot prove admission.\n authorizationId = nonce;\n return retirementAuthorizationSchema.parse({ authorized: true, authorizationId: nonce });\n })();\n void authorizing.catch(() => {});\n return authorizing;\n };\n let state: RetirementState | undefined;\n const failures: unknown[] = [];\n try {\n state = await this.ownerCall(() => this.options.owner!.retire(requestFor(plan), authorize,\n retirementManifestSchema.parse(plan.manifest)));\n } catch (error) { failures.push(error); }\n finally {\n revoked = true;\n // An owner that started but did not await authorization cannot leave\n // writes running after this request, a terminal receipt, or lease release.\n if (authorizing) try { await authorizing; } catch (error) { failures.push(error); }\n }\n if (callbackViolation) failures.push(callbackViolation);\n if (failures.length) throw new AggregateError(failures, 'Retirement admission/authorization failed.');\n if (!state) throw new Error('Resource owner returned no retirement state.');\n const validated = this.validateOwnerState(plan, state, authorizationId);\n return this.acceptState(this.store.operation(plan.operationId)!, validated);\n }\n\n async reconcile(resume = false): Promise<PurgeReconcileReport> {\n const report: PurgeReconcileReport = { completed: [], pending: [] };\n for (const operation of this.store.operations()) {\n if (operation.schemaVersion !== (this.hooks.target === 'native-archive' ? 2 : 1)) continue;\n if (operation.phase === 'done') continue;\n const result = await this.recover(operation, resume);\n if (['success', 'rejected', 'conflict'].includes(result.status)) report.completed.push(result);\n else report.pending.push(operation.plan.operationId);\n }\n return report;\n }\n private async ownerCall<T>(work: () => Promise<T>): Promise<T> {\n try { return await work(); }\n catch (cause) {\n if (cause instanceof Error && ownerRefusals.has(cause)) throw sessionBinRefusal('bin/retirement-refused', cause.message);\n throw externalFailure('Retirement resource owner failed', cause);\n }\n }\n private refusalReason(error: unknown): string | null {\n return error instanceof SessionBinError && isSessionBinRefusal(error) && error.code === 'bin/retirement-refused' ? error.message : null;\n }\n private async eligibility(sessionId: string): Promise<string | null> {\n const owner = this.options.owner;\n if (!owner?.eligibility) return null;\n const reason = await this.ownerCall(() => owner.eligibility!(sessionId));\n if (reason !== null && (typeof reason !== 'string' || !reason.length || reason.length > 1024)) {\n throw new Error('Resource owner returned an invalid eligibility refusal.');\n }\n return reason;\n }\n private async admittedCapabilities(): Promise<RetirementCapabilities | null> {\n if (!this.options.owner && this.options.resolveOwner) {\n const resolved = await this.ownerCall(() => this.options.resolveOwner!());\n if (resolved) this.options.owner = resolved;\n }\n if (!this.options.owner) return null;\n const capabilities = retirementCapabilitiesSchema.parse(await this.ownerCall(() => this.options.owner!.capabilities()));\n return this.options.verified?.(retirementCapabilitiesSchema.parse(capabilities)) === true ? capabilities : null;\n }\n private async check(plan: PurgePlan, requireManifest: boolean, authorizing = false): Promise<string | null> {\n try { return await this.checkInner(plan, requireManifest, authorizing); }\n catch (error) { const reason = this.refusalReason(error); if (reason !== null) return reason; throw error; }\n }\n private async checkInner(plan: PurgePlan, requireManifest: boolean, authorizing = false): Promise<string | null> {\n if (this.hooks.newRequestsDisabled) {\n if (this.store.operations().some(item => item.phase !== 'done' && item.plan.sessionId === plan.sessionId\n && item.plan.operationId !== plan.operationId)) return 'pending-deletion';\n return await this.hooks.archived(plan.sessionId) ? 'permanent-deletion-unsupported' : 'not-archived';\n }\n const entry = this.hooks.entry(plan.sessionId);\n if (!entry) return this.hooks.target === 'native-archive' ? 'not-archived' : 'not-in-bin';\n if (entry.entryId !== plan.expectedEntryId) return 'entry-changed';\n if (this.hooks.invalidated(entry.entryId) || !(await this.hooks.archived(plan.sessionId))) return 'archive-changed';\n if (this.hooks.hasPendingArchiveOperation(plan.sessionId)) return 'pending-operation';\n if (!authorizing && this.store.operations().some(item => item.phase !== 'done'\n && item.plan.sessionId === plan.sessionId && item.plan.operationId !== plan.operationId)) return 'pending-deletion';\n const capabilities = await this.admittedCapabilities();\n if (!capabilities) return 'permanent-deletion-unsupported';\n const eligibility = await this.eligibility(plan.sessionId);\n if (eligibility !== null) return eligibility;\n const binding = this.store.binding(entry.entryId);\n if (!binding || !plan.binding) return 'lifecycle-unbound';\n if (entry.schemaVersion !== plan.schemaVersion || binding.schemaVersion !== plan.schemaVersion\n || !sameBinding(binding, plan.binding) || capabilitiesKey(capabilities) !== capabilitiesKey(binding.capabilities)) return 'lifecycle-changed';\n const observed = await this.ownerCall(() => this.options.owner!.inspect(plan.sessionId));\n if (observed === null || !lifecycleEqual(binding.lifecycle, lifecycleKeySchema.parse(observed))) return 'lifecycle-changed';\n if ((await this.hooks.activity(plan.sessionId)).length) return 'session-active';\n // activity() yields; capture archive invalidation and entry replacement once more.\n if (this.hooks.invalidated(entry.entryId) || this.hooks.entry(plan.sessionId)?.entryId !== entry.entryId\n || !(await this.hooks.archived(plan.sessionId))) return 'archive-changed';\n if (requireManifest && !plan.manifest) return 'resource-manifest-required';\n return null;\n }\n private validateManifest(binding: RetirementBinding, manifest: RetirementManifest): void {\n if (!lifecycleEqual(binding.lifecycle, manifest.lifecycle)\n || capabilitiesKey(binding.capabilities) !== capabilitiesKey(manifest.capabilities)) {\n throw new Error('Resource manifest does not belong to the bound owner and lifecycle.');\n }\n }\n private validateOwnerState(plan: PurgePlan, input: RetirementState, authorizationId: string | null): RetirementState {\n const state = retirementStateSchema.parse(input);\n if (canonical(state.request) !== canonical(requestFor(plan))\n || retirementManifestDigest(state.manifest) !== retirementManifestDigest(plan.manifest!)\n || (state.authorizationId !== null && (authorizationId === null || state.authorizationId !== authorizationId))) {\n throw new Error('Owner receipt changed the operation, lifecycle, Bin binding, resource manifest or Host authorization grant.');\n }\n return state;\n }\n private async recover(operation: PurgeOperation, resume = true): Promise<PurgeResult> {\n // A locally persisted complete owner receipt needs no provider or native\n // existence observation: only the matching plugin entry remains to commit.\n if (operation.ownerState?.phase === 'done') return this.finalize(operation);\n const capabilities = await this.admittedCapabilities();\n if (!capabilities || !operation.plan.binding\n || capabilitiesKey(capabilities) !== capabilitiesKey(operation.plan.binding.capabilities)) {\n return this.pendingResult(operation, 'retirement-owner-unavailable');\n }\n const observed = await this.ownerCall(() => this.options.owner!.getOperation(operation.plan.operationId));\n if (observed === null) {\n if (operation.ownerState !== null) throw new Error('Resource owner lost a previously acknowledged durable operation.');\n return this.finish(operation, 'conflict', 'interrupted');\n }\n const state = this.validateOwnerState(operation.plan, observed, operation.authorizationId);\n if (['done', 'rejected', 'conflict'].includes(state.phase)) return this.acceptState(operation, state);\n this.assertProgress(operation.ownerState, state);\n if (!resume) {\n if (operation.ownerState && canonical(operation.ownerState) === canonical(state) && operation.result) {\n return purgeResultSchema.parse(operation.result);\n }\n return this.acceptState(operation, state);\n }\n // Persist the durable admission we have actually observed BEFORE recovery\n // can yield, erase another resource or fail. A later null/refusal cannot\n // erase this witness and release a half-retired entry.\n await this.acceptState(operation, state);\n const witnessed = this.store.operation(operation.plan.operationId)!;\n const recovered = this.validateOwnerState(operation.plan,\n await this.ownerCall(() => this.options.owner!.recover(operation.plan.operationId)), operation.authorizationId);\n this.assertProgress(state, recovered);\n return this.acceptState(witnessed, recovered);\n }\n private assertProgress(previous: RetirementState | null, next: RetirementState): void {\n if (!previous) return;\n const phases = ['fenced', 'quiesced', 'erasing', 'converging', 'done'];\n if (phases.indexOf(next.phase) < phases.indexOf(previous.phase)) throw new Error('Resource owner regressed a durable retirement phase.');\n for (const receipt of previous.resources.filter(item => item.status !== 'failed')) {\n const current = next.resources.find(item => item.ownerId === receipt.ownerId && item.resourceId === receipt.resourceId);\n if (!current || canonical(current) !== canonical(receipt)) throw new Error('Resource owner lost an acknowledged resource receipt.');\n }\n }\n private async acceptState(operation: PurgeOperation, state: RetirementState): Promise<PurgeResult> {\n this.assertProgress(operation.ownerState, state);\n if (state.phase === 'rejected' || state.phase === 'conflict') {\n return this.finish({ ...operation, ownerState: state }, state.phase, state.reason!);\n }\n const result = purgeResultSchema.parse({ action: 'purge', operationId: operation.plan.operationId,\n sessionId: operation.plan.sessionId, entryId: operation.entry!.entryId,\n status: state.resources.some(item => item.status === 'failed') ? 'partial-failure' : 'pending-recovery',\n reason: state.resources.some(item => item.status === 'failed') ? 'resource-failure' : 'owner-incomplete', ownerState: state });\n const saved: PurgeOperation = { ...operation, phase: 'owner-pending', ownerState: state, result };\n // Preserve the validated owner receipt BEFORE any plugin entry mutation.\n await this.store.putOperation(saved);\n return state.phase === 'done' ? this.finalize(saved) : result;\n }\n private pendingResult(operation: PurgeOperation, reason: string): PurgeResult {\n return purgeResultSchema.parse({ action: 'purge', operationId: operation.plan.operationId,\n sessionId: operation.plan.sessionId, entryId: operation.entry!.entryId,\n status: 'pending-recovery', reason, ownerState: operation.ownerState });\n }\n private async finalize(operation: PurgeOperation): Promise<PurgeResult> {\n const current = this.hooks.entry(operation.plan.sessionId);\n if (current?.entryId === operation.entry!.entryId) {\n await externalCall('Retirement entry commit failed', () => this.hooks.deleteEntry(current.sessionId));\n }\n return this.finish(operation, 'success', null);\n }\n private async finish(operation: PurgeOperation, status: 'success' | 'rejected' | 'conflict', reason: string | null): Promise<PurgeResult> {\n const result = purgeResultSchema.parse({ action: 'purge', operationId: operation.plan.operationId,\n sessionId: operation.plan.sessionId, entryId: operation.entry?.entryId ?? null,\n status, reason, ownerState: operation.ownerState });\n await this.store.putOperation({ ...operation, phase: 'done', result });\n return result;\n }\n}\n", "import { z } from 'zod';\nimport { blockerSchema, entrySchema } from './schema.js';\nimport { archiveEntrySchema } from './archive.js';\n\nconst key = z.string().min(1).max(1024);\nexport const lifecycleKeySchema = z.object({ storeId: key, sessionId: key, lifecycleId: key }).strict();\nexport const retirementParticipantSchema = z.object({ id: key, version: key }).strict();\nexport const retirementCapabilitiesSchema = z.object({\n protocolVersion: z.literal(1), ownerId: key, hostVersion: key, providerId: key, storeId: key,\n participants: z.array(retirementParticipantSchema).min(1).max(64),\n}).strict().superRefine((value, ctx) => {\n if (new Set(value.participants.map(item => item.id)).size !== value.participants.length) {\n ctx.addIssue({ code: 'custom', message: 'Participant identities must be unique.' });\n }\n});\nconst legacyRetirementBindingSchema = z.object({\n schemaVersion: z.literal(1), entryId: z.uuid(), entryVersion: z.literal(1),\n lifecycle: lifecycleKeySchema, capabilities: retirementCapabilitiesSchema,\n}).strict();\nconst nativeRetirementBindingSchema = z.object({\n schemaVersion: z.literal(2), target: z.literal('native-archive'), entryId: z.uuid(), entryVersion: z.literal(2),\n lifecycle: lifecycleKeySchema, capabilities: retirementCapabilitiesSchema,\n}).strict();\nexport const retirementBindingSchema = z.union([legacyRetirementBindingSchema, nativeRetirementBindingSchema]).superRefine((value, ctx) => {\n if (value.lifecycle.storeId !== value.capabilities.storeId) {\n ctx.addIssue({ code: 'custom', message: 'Binding store differs from its owner.' });\n }\n});\nexport const retirementResourceSchema = z.object({\n ownerId: key, resourceId: key, revision: key,\n kind: z.enum(['transcript', 'workspace', 'index', 'cache', 'attachment', 'spill', 'coordination']),\n disposition: z.enum(['erase', 'release-reference', 'retain-shared', 'retain-coordination']),\n retention: z.object({\n reason: z.enum(['shared-reference', 'coordination-identity']),\n retainedBy: z.array(lifecycleKeySchema).max(4096),\n }).strict().nullable(),\n}).strict();\nexport const retirementManifestSchema = z.object({\n schemaVersion: z.literal(1), lifecycle: lifecycleKeySchema,\n capabilities: retirementCapabilitiesSchema,\n resources: z.array(retirementResourceSchema).min(1).max(4096),\n}).strict().superRefine((value, ctx) => {\n const owners = new Set(value.capabilities.participants.map(item => item.id));\n const resourceKeys = value.resources.map(item => JSON.stringify([item.ownerId, item.resourceId]));\n if (new Set(resourceKeys).size !== resourceKeys.length || value.resources.some(item => !owners.has(item.ownerId))) {\n ctx.addIssue({ code: 'custom', message: 'Resources require unique keys and declared owners.' });\n }\n if (value.lifecycle.storeId !== value.capabilities.storeId\n || !value.resources.some(item => item.kind === 'transcript' && item.disposition === 'erase')) {\n ctx.addIssue({ code: 'custom', message: 'Manifest must identify its store and erase the target transcript.' });\n }\n for (const resource of value.resources) {\n if (resource.kind === 'coordination' && resource.disposition !== 'retain-coordination') {\n ctx.addIssue({ code: 'custom', message: 'Stable coordination identity must be retained.' });\n }\n const retained = resource.retention;\n if (resource.disposition === 'retain-shared') {\n if (!retained || retained.reason !== 'shared-reference' || !retained.retainedBy.length\n || retained.retainedBy.some(key => lifecycleEqual(key, value.lifecycle))\n || new Set(retained.retainedBy.map(key => JSON.stringify([key.storeId, key.sessionId, key.lifecycleId]))).size !== retained.retainedBy.length) {\n ctx.addIssue({ code: 'custom', message: 'Shared retention requires distinct surviving lifecycle witnesses.' });\n }\n } else if (resource.disposition === 'retain-coordination') {\n if (resource.kind !== 'coordination' || !retained || retained.reason !== 'coordination-identity' || retained.retainedBy.length) {\n ctx.addIssue({ code: 'custom', message: 'Coordination retention must state its identity purpose.' });\n }\n } else if (retained !== null) {\n ctx.addIssue({ code: 'custom', message: 'Erasure/reference release does not retain this resource.' });\n }\n }\n});\nexport const retirementRequestSchema = z.object({\n operationId: key, expected: lifecycleKeySchema,\n bin: z.union([\n z.object({ entryId: z.uuid(), entryVersion: z.literal(1) }).strict(),\n z.object({ kind: z.literal('native-archive'), entryId: z.uuid(), entryVersion: z.literal(2) }).strict(),\n ]),\n manifestDigest: z.string().regex(/^[a-f0-9]{64}$/),\n}).strict();\nexport const retirementResourceReceiptSchema = z.object({\n ownerId: key, resourceId: key,\n status: z.enum(['erased', 'reference-released', 'retained', 'failed']), reason: key.nullable(),\n}).strict().superRefine((value, ctx) => {\n if ((value.status === 'failed' || value.status === 'retained') !== (value.reason !== null)) {\n ctx.addIssue({ code: 'custom', message: 'Failure and retention require a reason; erased/released resources do not.' });\n }\n});\nexport const retirementAuthorizationSchema = z.discriminatedUnion('authorized', [\n z.object({ authorized: z.literal(true), authorizationId: z.uuid() }).strict(),\n z.object({ authorized: z.literal(false), reason: key }).strict(),\n]);\nexport const retirementStateSchema = z.object({\n schemaVersion: z.literal(1), request: retirementRequestSchema, manifest: retirementManifestSchema,\n authorizationId: z.uuid().nullable(),\n phase: z.enum(['rejected', 'conflict', 'fenced', 'quiesced', 'erasing', 'converging', 'done']),\n reason: key.nullable(), resources: z.array(retirementResourceReceiptSchema).max(4096),\n}).strict().superRefine((value, ctx) => {\n if (!lifecycleEqual(value.request.expected, value.manifest.lifecycle)) {\n ctx.addIssue({ code: 'custom', message: 'Owner state changed the requested lifecycle.' });\n }\n const refused = value.phase === 'rejected' || value.phase === 'conflict';\n if (refused !== (value.authorizationId === null)) {\n ctx.addIssue({ code: 'custom', message: 'Admitted owner state requires its handed-off authorization grant.' });\n }\n if (refused !== (value.reason !== null)) {\n ctx.addIssue({ code: 'custom', message: 'Admission refusal requires a reason.' });\n }\n const keys = value.resources.map(item => JSON.stringify([item.ownerId, item.resourceId]));\n if (new Set(keys).size !== keys.length) ctx.addIssue({ code: 'custom', message: 'Duplicate resource receipts.' });\n for (const receipt of value.resources) {\n const resource = value.manifest.resources.find(item => item.ownerId === receipt.ownerId && item.resourceId === receipt.resourceId);\n if (!resource) ctx.addIssue({ code: 'custom', message: 'Receipt is outside the frozen manifest.' });\n if (resource && receipt.status !== 'failed') {\n const expected = resource.disposition === 'erase' ? 'erased'\n : resource.disposition === 'release-reference' ? 'reference-released' : 'retained';\n if (receipt.status !== expected || (receipt.status === 'retained' && receipt.reason !== resource.retention?.reason)) {\n ctx.addIssue({ code: 'custom', message: 'Resource acknowledgement did not satisfy its frozen disposition and retention reason.' });\n }\n }\n }\n if (value.phase === 'done' && (value.resources.length !== value.manifest.resources.length\n || value.resources.some(receipt => receipt.status === 'failed'))) {\n ctx.addIssue({ code: 'custom', message: 'Completion requires every resource receipt without failures.' });\n }\n if (['rejected', 'conflict', 'fenced', 'quiesced'].includes(value.phase) && value.resources.length) {\n ctx.addIssue({ code: 'custom', message: 'Admission and quiescence phases cannot include resource erasure effects.' });\n }\n});\nexport const preparePurgeRequestSchema = z.object({ sessionId: key, operationId: key.optional() }).strict();\nexport const purgePlanSchema = z.object({\n schemaVersion: z.union([z.literal(1), z.literal(2)]), action: z.literal('purge'), operationId: key, sessionId: key,\n expectedEntryId: z.uuid().nullable(), binding: retirementBindingSchema.nullable(),\n manifest: retirementManifestSchema.nullable(), blockers: z.array(blockerSchema),\n}).strict().superRefine((value, ctx) => {\n if (value.binding && value.binding.schemaVersion !== value.schemaVersion) {\n ctx.addIssue({ code: 'custom', message: 'Legacy Bin and native archive deletion bindings cannot be interchanged.' });\n }\n if (value.binding && (value.binding.entryId !== value.expectedEntryId || value.binding.lifecycle.sessionId !== value.sessionId)) {\n ctx.addIssue({ code: 'custom', message: 'Purge binding differs from its target entry.' });\n }\n if (value.manifest && (!value.binding || !lifecycleEqual(value.binding.lifecycle, value.manifest.lifecycle))) {\n ctx.addIssue({ code: 'custom', message: 'Purge manifest differs from its bound lifecycle.' });\n }\n});\nexport const purgeResultSchema = z.object({\n action: z.literal('purge'), operationId: key, sessionId: key, entryId: z.uuid().nullable(),\n status: z.enum(['success', 'rejected', 'conflict', 'pending-recovery', 'partial-failure']), reason: key.nullable(),\n ownerState: retirementStateSchema.nullable(),\n}).strict().superRefine((value, ctx) => {\n if ((value.status === 'success') !== (value.reason === null)\n || (value.status === 'success' && value.ownerState?.phase !== 'done')) {\n ctx.addIssue({ code: 'custom', message: 'Success requires a complete owner receipt.' });\n }\n if (value.ownerState && (value.ownerState.request.operationId !== value.operationId\n || value.ownerState.request.expected.sessionId !== value.sessionId\n || value.ownerState.request.bin.entryId !== value.entryId)) {\n ctx.addIssue({ code: 'custom', message: 'Purge result differs from its owner receipt.' });\n }\n});\nexport const purgeOperationSchema = z.object({\n schemaVersion: z.union([z.literal(1), z.literal(2)]), plan: purgePlanSchema, createdAt: z.iso.datetime(),\n phase: z.enum(['intent', 'authorizing', 'owner-pending', 'done']), entry: z.union([entrySchema, archiveEntrySchema]).nullable(),\n authorizationId: z.uuid().nullable(),\n ownerState: retirementStateSchema.nullable(), result: purgeResultSchema.nullable(),\n}).strict().superRefine((value, ctx) => {\n const { plan, entry, result, ownerState } = value;\n if (value.schemaVersion !== plan.schemaVersion || (entry && entry.schemaVersion !== plan.schemaVersion)\n || (ownerState && ownerState.request.bin.entryVersion !== plan.schemaVersion)) {\n ctx.addIssue({ code: 'custom', message: 'Deletion journal target versions must agree.' });\n }\n if (entry && (entry.entryId !== plan.expectedEntryId || entry.sessionId !== plan.sessionId)) {\n ctx.addIssue({ code: 'custom', message: 'Purge journal entry differs from the plan.' });\n }\n if (value.phase !== 'done' && (!entry || !plan.binding || !plan.manifest)) {\n ctx.addIssue({ code: 'custom', message: 'Unfinished purge requires an entry, binding and manifest.' });\n }\n const terminalResult = result && ['success', 'rejected', 'conflict'].includes(result.status);\n if ((value.phase === 'done') !== Boolean(terminalResult)\n || (['intent', 'authorizing'].includes(value.phase) && (ownerState !== null || result !== null))\n || (value.phase === 'intent' && value.authorizationId !== null)\n || (value.phase === 'authorizing' && value.authorizationId === null)\n || (ownerState && ownerState.authorizationId !== null && ownerState.authorizationId !== value.authorizationId)\n || (value.phase === 'owner-pending' && (ownerState === null || result === null))) {\n ctx.addIssue({ code: 'custom', message: 'Purge journal phase and receipt are inconsistent.' });\n }\n if (result && (result.operationId !== plan.operationId || result.sessionId !== plan.sessionId\n || result.entryId !== (entry?.entryId ?? null) || JSON.stringify(result.ownerState) !== JSON.stringify(ownerState))) {\n ctx.addIssue({ code: 'custom', message: 'Purge journal result differs from its saved state.' });\n }\n});\n\nexport type LifecycleKey = z.infer<typeof lifecycleKeySchema>;\nexport type RetirementCapabilities = z.infer<typeof retirementCapabilitiesSchema>;\nexport type RetirementBinding = z.infer<typeof retirementBindingSchema>;\nexport type RetirementManifest = z.infer<typeof retirementManifestSchema>;\nexport type RetirementRequest = z.infer<typeof retirementRequestSchema>;\nexport type RetirementAuthorization = z.infer<typeof retirementAuthorizationSchema>;\nexport type RetirementState = z.infer<typeof retirementStateSchema>;\nexport type PurgePlan = z.infer<typeof purgePlanSchema>;\nexport type PurgeResult = z.infer<typeof purgeResultSchema>;\nexport type PurgeOperation = z.infer<typeof purgeOperationSchema>;\nexport type PreparePurgeRequest = z.infer<typeof preparePurgeRequestSchema>;\nexport function lifecycleEqual(a: LifecycleKey, b: LifecycleKey): boolean {\n return a.storeId === b.storeId && a.sessionId === b.sessionId && a.lifecycleId === b.lifecycleId;\n}\n", "import { z } from 'zod';\nimport { blockerSchema } from './schema.js';\n\nconst identity = z.string().min(1).max(1024);\nexport const archiveEntrySchema = z.object({\n schemaVersion: z.literal(2), sessionId: identity, entryId: z.uuid(),\n}).strict();\nexport const archivePlanSchema = z.object({\n schemaVersion: z.literal(2), operationId: identity, action: z.literal('unarchive'), sessionId: identity,\n expected: z.object({ archived: z.boolean(), entryId: z.uuid().nullable() }).strict(),\n blockers: z.array(blockerSchema),\n}).strict();\nexport const archiveResultSchema = z.object({\n operationId: identity, action: z.literal('unarchive'), sessionId: identity,\n status: z.enum(['success', 'rejected', 'conflict']), reason: z.string().min(1).nullable(), entryId: z.uuid().nullable(),\n}).strict();\nexport const archiveOperationSchema = z.object({\n schemaVersion: z.literal(2), plan: archivePlanSchema, createdAt: z.iso.datetime(),\n phase: z.enum(['intent', 'applied', 'done']), entry: archiveEntrySchema.nullable(), result: archiveResultSchema.nullable(),\n}).strict().superRefine(({ plan, entry, result, phase }, ctx) => {\n if ((phase === 'done') !== (result !== null) || (phase !== 'done' && (entry === null || !plan.expected.archived))) {\n ctx.addIssue({ code: 'custom', message: 'Only done operations have results; unfinished operations require an entry.' });\n }\n if (entry && (entry.sessionId !== plan.sessionId || entry.entryId !== plan.expected.entryId)) {\n ctx.addIssue({ code: 'custom', message: 'Entry snapshot does not match the plan.' });\n }\n if (result && (result.operationId !== plan.operationId || result.sessionId !== plan.sessionId\n || result.action !== plan.action || result.entryId !== (entry?.entryId ?? null)\n || (result.status === 'success') !== (result.reason === null) || (result.status === 'success' && !entry))) {\n ctx.addIssue({ code: 'custom', message: 'Result does not match the operation.' });\n }\n});\nexport const archivePrepareRequestSchema = z.object({\n action: z.literal('unarchive'), sessionId: identity, operationId: identity.optional(),\n}).strict();\nexport type ArchiveEntry = z.infer<typeof archiveEntrySchema>;\nexport type ArchivePlan = z.infer<typeof archivePlanSchema>;\nexport type ArchiveResult = z.infer<typeof archiveResultSchema>;\nexport type ArchiveOperation = z.infer<typeof archiveOperationSchema>;\nexport type ArchivePrepareRequest = z.infer<typeof archivePrepareRequestSchema>;\n", "import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';\nimport type { Domain } from '@deepseek-ai/dsh-storage-domain';\nimport { archiveEntrySchema, archiveOperationSchema } from '../operations/archive.js';\nimport type { ArchiveEntry, ArchiveOperation } from '../operations/archive.js';\nimport { entrySchema, operationSchema } from '../operations/schema.js';\nimport type { BinEntry, BinOperation } from '../operations/schema.js';\n\nexport const binDomainSpec = defineDomain({\n name: 'session_bin',\n version: 1,\n layout: 'single',\n tables: {\n entries: domainTable(entrySchema),\n operations: domainTable(operationSchema),\n },\n} as const);\n\nexport interface BinStore {\n entries(): BinEntry[];\n operations(): BinOperation[];\n entry(sessionId: string): BinEntry | undefined;\n operation(operationId: string): BinOperation | undefined;\n putEntry(entry: BinEntry): Promise<void>;\n deleteEntry(sessionId: string): Promise<void>;\n putOperation(operation: BinOperation): Promise<void>;\n close(): Promise<void>;\n}\n\n// Domain.put/update do not validate in the pinned SDK. Keep the handle private;\n// parse synchronously before enqueuing, and return independent read snapshots.\nexport class DomainBinStore implements BinStore {\n constructor(private readonly domain: Domain<typeof binDomainSpec>) {\n for (const [key, entry] of domain.table('entries').entries()) {\n if (key !== entry.sessionId) throw new Error('Bin entry key does not match its session.');\n const owner = domain.table('operations').get(entry.operationId);\n if (!owner || owner.plan.action !== 'bin' || owner.entry?.entryId !== entry.entryId\n || owner.entry.sessionId !== entry.sessionId) {\n throw new Error('Bin entry has no matching ownership journal.');\n }\n }\n for (const [key, operation] of domain.table('operations').entries()) {\n if (key !== operation.plan.operationId) throw new Error('Bin operation key does not match its identity.');\n }\n }\n entries(): BinEntry[] {\n return [...this.domain.table('entries').entries()].map(([, value]) => entrySchema.parse(value));\n }\n operations(): BinOperation[] {\n return [...this.domain.table('operations').entries()].map(([, value]) => operationSchema.parse(value));\n }\n entry(sessionId: string): BinEntry | undefined {\n const value = this.domain.table('entries').get(sessionId);\n return value === undefined ? undefined : entrySchema.parse(value);\n }\n operation(operationId: string): BinOperation | undefined {\n const value = this.domain.table('operations').get(operationId);\n return value === undefined ? undefined : operationSchema.parse(value);\n }\n putEntry(value: BinEntry): Promise<void> {\n const snapshot = entrySchema.parse(value);\n return this.domain.table('entries').put(snapshot.sessionId, snapshot);\n }\n async deleteEntry(sessionId: string): Promise<void> {\n await this.domain.table('entries').delete(sessionId);\n }\n putOperation(value: BinOperation): Promise<void> {\n const snapshot = operationSchema.parse(value);\n return this.domain.table('operations').put(snapshot.plan.operationId, snapshot);\n }\n close(): Promise<void> { return this.domain.close(); }\n}\n\n/** Observation identities live apart from the immutable v1 ownership journal. */\nexport const archiveDomainSpec = defineDomain({\n name: 'session_archive', version: 1, layout: 'single',\n tables: { entries: domainTable(archiveEntrySchema), operations: domainTable(archiveOperationSchema) },\n} as const);\nexport interface ArchiveStore {\n entries(): ArchiveEntry[];\n entry(sessionId: string): ArchiveEntry | undefined;\n operations(): ArchiveOperation[];\n operation(operationId: string): ArchiveOperation | undefined;\n putEntry(entry: ArchiveEntry): Promise<void>;\n deleteEntry(sessionId: string): Promise<void>;\n putOperation(operation: ArchiveOperation): Promise<void>;\n close(): Promise<void>;\n}\nexport class DomainArchiveStore implements ArchiveStore {\n constructor(private readonly domain: Domain<typeof archiveDomainSpec>) {\n for (const [key, entry] of domain.table('entries').entries()) {\n if (key !== entry.sessionId) throw new Error('Archive entry key does not match its session.');\n }\n for (const [key, operation] of domain.table('operations').entries()) {\n if (key !== operation.plan.operationId) throw new Error('Archive operation key does not match its identity.');\n }\n }\n entries() { return [...this.domain.table('entries').entries()].map(([, value]) => archiveEntrySchema.parse(value)); }\n entry(sessionId: string) {\n const value = this.domain.table('entries').get(sessionId);\n return value === undefined ? undefined : archiveEntrySchema.parse(value);\n }\n operations() { return [...this.domain.table('operations').entries()].map(([, value]) => archiveOperationSchema.parse(value)); }\n operation(operationId: string) {\n const value = this.domain.table('operations').get(operationId);\n return value === undefined ? undefined : archiveOperationSchema.parse(value);\n }\n putEntry(value: ArchiveEntry) {\n const snapshot = archiveEntrySchema.parse(value);\n return this.domain.table('entries').put(snapshot.sessionId, snapshot);\n }\n async deleteEntry(sessionId: string) { await this.domain.table('entries').delete(sessionId); }\n putOperation(value: ArchiveOperation) {\n const snapshot = archiveOperationSchema.parse(value);\n return this.domain.table('operations').put(snapshot.plan.operationId, snapshot);\n }\n close() { return this.domain.close(); }\n}\n", "import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';\nimport type { Domain } from '@deepseek-ai/dsh-storage-domain';\nimport { purgeOperationSchema, retirementBindingSchema } from '../operations/retirement.js';\nimport type { PurgeOperation, RetirementBinding } from '../operations/retirement.js';\n\n/** Separate sidecar accepts unchanged legacy v1 records and explicitly tagged native v2 records.\n * Its storage domain version stays 1; no automatic data migration or native mutation. */\nexport const retirementDomainSpec = defineDomain({\n name: 'session_bin_purge', version: 1, layout: 'single',\n tables: { bindings: domainTable(retirementBindingSchema), operations: domainTable(purgeOperationSchema) },\n} as const);\nexport interface RetirementStore {\n binding(entryId: string): RetirementBinding | undefined;\n putBinding(binding: RetirementBinding): Promise<void>;\n operation(operationId: string): PurgeOperation | undefined;\n operations(): PurgeOperation[];\n putOperation(operation: PurgeOperation): Promise<void>;\n close(): Promise<void>;\n}\nexport class DomainRetirementStore implements RetirementStore {\n constructor(private readonly domain: Domain<typeof retirementDomainSpec>) {\n for (const [key, value] of domain.table('bindings').entries()) {\n if (key !== value.entryId) throw new Error('Retirement binding key differs from its entry.');\n }\n for (const [key, value] of domain.table('operations').entries()) {\n if (key !== value.plan.operationId) throw new Error('Retirement operation key differs from its request.');\n }\n }\n binding(entryId: string): RetirementBinding | undefined {\n const value = this.domain.table('bindings').get(entryId);\n return value === undefined ? undefined : retirementBindingSchema.parse(value);\n }\n putBinding(value: RetirementBinding): Promise<void> {\n const snapshot = retirementBindingSchema.parse(value);\n const existing = this.binding(snapshot.entryId);\n if (existing && JSON.stringify(existing) !== JSON.stringify(snapshot)) {\n throw new Error('An immutable entry lifecycle binding cannot be replaced.');\n }\n return this.domain.table('bindings').put(snapshot.entryId, snapshot);\n }\n operation(operationId: string): PurgeOperation | undefined {\n const value = this.domain.table('operations').get(operationId);\n return value === undefined ? undefined : purgeOperationSchema.parse(value);\n }\n operations(): PurgeOperation[] {\n return [...this.domain.table('operations').entries()].map(([, value]) => purgeOperationSchema.parse(value));\n }\n putOperation(value: PurgeOperation): Promise<void> {\n const snapshot = purgeOperationSchema.parse(value);\n return this.domain.table('operations').put(snapshot.plan.operationId, snapshot);\n }\n close(): Promise<void> { return this.domain.close(); }\n}\n", "import { randomUUID } from 'node:crypto';\nimport { archiveEntrySchema, archivePlanSchema, archivePrepareRequestSchema, archiveResultSchema } from '../operations/archive.js';\nimport type { ArchiveEntry, ArchiveOperation, ArchivePlan, ArchivePrepareRequest, ArchiveResult } from '../operations/archive.js';\nimport type { BinBlocker } from '../operations/schema.js';\nimport type { ArchiveStore } from './store.js';\nimport { SessionBinError, sessionBinRefusal, isSessionBinRefusal } from './module.js';\nimport type { NativeSessionState } from './module.js';\nimport { SessionBinPurgeModule } from './retirement.js';\nimport type { RetirementOptions, PurgeReconcileReport } from './retirement.js';\nimport { preparePurgeRequestSchema, purgePlanSchema } from '../operations/retirement.js';\nimport type { PreparePurgeRequest, PurgePlan } from '../operations/retirement.js';\n\nexport interface NativeArchivePort {\n archivedSessionIds(): readonly string[];\n inspect(sessionId: string): Promise<NativeSessionState>;\n activity?(sessionId: string): Promise<string[]>;\n unarchive(sessionId: string): Promise<void>;\n}\nexport interface ArchiveOptions {\n retirement?: RetirementOptions;\n operationIdClaimed?: (operationId: string) => boolean;\n pendingPurge?: (sessionId: string) => boolean;\n reconcileLegacy?: () => Promise<unknown>;\n reconcileLegacyPurge?: () => Promise<PurgeReconcileReport>;\n}\n\n/** Native archive membership, with durable observation identities, never deletion grants. */\nexport class ArchiveModule {\n private tail: Promise<unknown> = Promise.resolve();\n private closing = false;\n private failed = false;\n private failure: unknown;\n private closePromise: Promise<void> | undefined;\n private readonly invalidated = new Set<string>();\n private readonly rearchived = new Set<string>();\n // Track allocated identities before put settles so a frame cannot miss them.\n private readonly identities = new Map<string, ArchiveEntry>();\n private readonly purge: SessionBinPurgeModule | undefined;\n constructor(private readonly store: ArchiveStore, private readonly native: NativeArchivePort,\n private readonly options: ArchiveOptions = {}) {\n this.purge = options.retirement ? new SessionBinPurgeModule({ ...options.retirement,\n verified: caps => options.retirement!.verifiedNativeArchive?.(caps) === true }, {\n target: 'native-archive', entry: id => store.entry(id), invalidated: id => this.invalidated.has(id),\n archived: async id => native.archivedSessionIds().includes(id),\n activity: id => {\n if (!native.activity) throw new Error('Native retirement requires an activity port.');\n return native.activity(id);\n },\n deleteEntry: id => store.deleteEntry(id),\n hasArchiveOperation: id => store.operation(id) !== undefined || options.operationIdClaimed?.(id) === true,\n hasPendingArchiveOperation: id => store.operations().some(item => item.phase !== 'done' && item.plan.sessionId === id),\n }) : undefined;\n for (const entry of store.entries()) this.identities.set(entry.entryId, entry);\n for (const operation of store.operations()) {\n this.checkClaim(operation.plan.operationId);\n if (operation.phase !== 'done' && operation.entry) this.identities.set(operation.entry.entryId, operation.entry);\n }\n }\n\n prepare(request: ArchivePrepareRequest): Promise<ArchivePlan> {\n const input = archivePrepareRequestSchema.parse(request);\n return this.enqueue(async () => {\n await this.reconcileInner();\n const state = await this.native.inspect(input.sessionId);\n await this.syncEntries();\n const entry = this.store.entry(input.sessionId);\n const plan: ArchivePlan = {\n schemaVersion: 2, operationId: input.operationId ?? randomUUID(), action: 'unarchive', sessionId: input.sessionId,\n expected: { archived: state.archived, entryId: entry?.entryId ?? null }, blockers: [],\n };\n this.checkClaim(plan.operationId);\n plan.blockers = this.blockers(plan, state, entry);\n return archivePlanSchema.parse(plan);\n });\n }\n\n execute(input: ArchivePlan): Promise<ArchiveResult> {\n const plan = archivePlanSchema.parse(input);\n return this.enqueue(async () => {\n this.checkClaim(plan.operationId);\n const previous = this.store.operation(plan.operationId);\n if (previous && !this.sameRequest(previous.plan, plan)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to a different request.');\n }\n if (previous?.result) return archiveResultSchema.parse(previous.result);\n await this.reconcileInner();\n const recovered = this.store.operation(plan.operationId);\n if (recovered?.result) return archiveResultSchema.parse(recovered.result);\n const state = await this.native.inspect(plan.sessionId);\n await this.syncEntries();\n const entry = this.store.entry(plan.sessionId);\n const operation: ArchiveOperation = {\n schemaVersion: 2, plan, createdAt: new Date().toISOString(), phase: 'done',\n entry: entry?.entryId === plan.expected.entryId ? entry : null, result: null,\n };\n if (this.stale(plan, state, entry)) return this.finish(operation, 'conflict', 'state-changed');\n const blockers = this.blockers(plan, state, entry);\n if (blockers.length) return this.finish(operation, 'rejected', blockers[0]!.code);\n const intent: ArchiveOperation = { ...operation, phase: 'intent' };\n await this.store.putOperation(intent);\n // The intent and existence inspection yield. Capture invalidation outside\n // this queue, then inspect the current member/identity immediately at admission.\n const fresh = await this.native.inspect(plan.sessionId);\n if (this.stale(plan, fresh, this.store.entry(plan.sessionId))) return this.finish(intent, 'conflict', 'state-changed');\n const freshBlockers = this.blockers(plan, fresh, this.store.entry(plan.sessionId));\n if (freshBlockers.length) return this.finish(intent, 'rejected', freshBlockers[0]!.code);\n await this.native.unarchive(plan.sessionId);\n const applied: ArchiveOperation = { ...intent, phase: 'applied' };\n await this.store.putOperation(applied);\n return this.finalize(applied);\n });\n }\n\n preparePurge(request: PreparePurgeRequest) {\n const input = preparePurgeRequestSchema.parse(request);\n return this.enqueue(async () => { await this.reconcileInner(); return this.requirePurge().prepare(input); });\n }\n executePurge(input: PurgePlan) {\n const plan = purgePlanSchema.parse(input);\n return this.enqueue(() => this.requirePurge().execute(plan));\n }\n getPurgeOperation(id: string) { return this.enqueue(async () => this.requirePurge().operation(id)); }\n purgeOperations() { return this.enqueue(async () => this.requirePurge().operations()); }\n reconcilePurge() {\n return this.enqueue(async () => {\n const legacy = await this.options.reconcileLegacyPurge?.();\n const native = await this.requirePurge().reconcile(true);\n return { completed: [...(legacy?.completed ?? []), ...native.completed], pending: [...(legacy?.pending ?? []), ...native.pending] };\n });\n }\n private requirePurge() {\n if (!this.purge) throw sessionBinRefusal('bin/permanent-deletion-unsupported', 'No retirement journal/owner is composed.');\n return this.purge;\n }\n compatibility<T>(work: () => Promise<T>): Promise<T> { return this.enqueue(work); }\n list(): Promise<ArchiveEntry[]> {\n return this.enqueue(async () => {\n await this.reconcileInner();\n return this.store.entries().filter(entry => this.native.archivedSessionIds().includes(entry.sessionId));\n });\n }\n getOperation(operationId: string): Promise<ArchiveOperation | undefined> {\n return this.enqueue(async () => this.store.operation(operationId));\n }\n operations(): Promise<ArchiveOperation[]> {\n return this.enqueue(async () => { await this.reconcileInner(); return this.store.operations(); });\n }\n reconcile(): Promise<void> {\n return this.enqueue(async () => {\n await this.options.reconcileLegacyPurge?.();\n await this.purge?.reconcile(true); await this.reconcileInner();\n });\n }\n observeArchives(ids: readonly string[]): Promise<void> {\n if (this.failed) return Promise.reject(this.unavailable());\n const members = new Set(ids);\n for (const entry of this.identities.values()) {\n if (!members.has(entry.sessionId)) this.invalidated.add(entry.entryId);\n else if (this.invalidated.has(entry.entryId)) this.rearchived.add(entry.entryId);\n }\n return this.closing ? Promise.resolve() : this.enqueue(() => this.reconcileInner());\n }\n close(): Promise<void> {\n this.closing = true;\n return this.closePromise ??= this.tail.then(async () => {\n try { if (!this.failed) await this.reconcileInner(); }\n finally {\n try { await this.purge?.close(); }\n finally { await this.store.close(); }\n }\n });\n }\n\n private checkClaim(operationId: string) {\n if (this.purge?.operation(operationId) || this.options.operationIdClaimed?.(operationId)) {\n throw sessionBinRefusal('bin/operation-id-reused', 'Operation identity belongs to a legacy or purge request.');\n }\n }\n private sameRequest(a: ArchivePlan, b: ArchivePlan) {\n return a.sessionId === b.sessionId && a.action === b.action\n && a.expected.archived === b.expected.archived && a.expected.entryId === b.expected.entryId;\n }\n private stale(plan: ArchivePlan, state: NativeSessionState, entry: ArchiveEntry | undefined) {\n return state.archived !== plan.expected.archived\n || this.native.archivedSessionIds().includes(plan.sessionId) !== plan.expected.archived\n || (entry?.entryId ?? null) !== plan.expected.entryId\n || (entry !== undefined && this.invalidated.has(entry.entryId));\n }\n private blockers(plan: ArchivePlan, state: NativeSessionState, entry: ArchiveEntry | undefined): BinBlocker[] {\n const blockers: BinBlocker[] = [];\n if (this.purge?.blocks(plan.sessionId) || this.options.pendingPurge?.(plan.sessionId)) blockers.push({ code: 'pending-deletion' });\n if (!state.known) blockers.push({ code: 'session-not-found' });\n if (!state.archived || !entry || this.invalidated.has(entry.entryId)) blockers.push({ code: 'not-archived' });\n if (this.store.operations().some(item => item.phase !== 'done' && item.plan.sessionId === plan.sessionId\n && item.plan.operationId !== plan.operationId)) blockers.push({ code: 'pending-operation' });\n return blockers;\n }\n private async finish(operation: ArchiveOperation, status: ArchiveResult['status'], reason: string | null) {\n const result = archiveResultSchema.parse({ operationId: operation.plan.operationId, action: 'unarchive',\n sessionId: operation.plan.sessionId, status, reason, entryId: operation.entry?.entryId ?? null });\n await this.store.putOperation({ ...operation, phase: 'done', result });\n return archiveResultSchema.parse(result);\n }\n private async finalize(operation: ArchiveOperation) {\n const state = await this.native.inspect(operation.plan.sessionId);\n if (state.archived || this.native.archivedSessionIds().includes(operation.plan.sessionId)\n || (operation.entry && this.rearchived.has(operation.entry.entryId))) {\n return this.finish(operation, 'conflict', 'archive-changed');\n }\n if (!state.known) return this.finish(operation, 'conflict', 'session-not-found');\n const current = this.store.entry(operation.plan.sessionId);\n if (current && current.entryId !== operation.entry?.entryId) return this.finish(operation, 'conflict', 'entry-changed');\n if (current) await this.store.deleteEntry(current.sessionId);\n return this.finish(operation, 'success', null);\n }\n private async reconcileInner(): Promise<void> {\n await this.options.reconcileLegacy?.();\n await this.purge?.reconcile(false);\n for (const operation of this.store.operations()) {\n if (operation.phase === 'done') continue;\n if (operation.phase === 'applied') await this.finalize(operation);\n else await this.finish(operation, 'conflict', 'interrupted');\n }\n await this.syncEntries();\n }\n private async syncEntries(): Promise<void> {\n // Re-read after every yielded write. A list is a complete current native\n // set even when another archive/unarchive happens during a slow sidecar put.\n while (true) {\n const before = new Set(this.native.archivedSessionIds());\n for (const entry of this.store.entries()) {\n if (this.purge?.ownsPendingEntry(entry.entryId)) continue;\n if (this.invalidated.has(entry.entryId) || !before.has(entry.sessionId)) {\n await this.store.deleteEntry(entry.sessionId);\n }\n }\n for (const sessionId of this.native.archivedSessionIds()) {\n const current = this.store.entry(sessionId);\n if (this.purge?.blocksTarget(sessionId)) continue;\n if (!current || this.invalidated.has(current.entryId)) {\n const entry = archiveEntrySchema.parse({ schemaVersion: 2, sessionId, entryId: randomUUID() });\n this.identities.set(entry.entryId, entry);\n await this.store.putEntry(entry);\n }\n }\n const members = new Set(this.native.archivedSessionIds());\n const entries = this.store.entries().filter(entry => !this.purge?.blocksTarget(entry.sessionId));\n const ordinary = [...members].filter(id => !this.purge?.blocksTarget(id));\n if (entries.length === ordinary.length && entries.every(entry => members.has(entry.sessionId)\n && !this.invalidated.has(entry.entryId))) break;\n }\n const retained = new Set(this.store.entries().map(entry => entry.entryId));\n for (const operation of this.store.operations()) {\n if (operation.phase !== 'done' && operation.entry) retained.add(operation.entry.entryId);\n }\n for (const entryId of this.identities.keys()) {\n if (retained.has(entryId)) continue;\n this.identities.delete(entryId);\n this.invalidated.delete(entryId);\n this.rearchived.delete(entryId);\n }\n }\n private unavailable() {\n return new SessionBinError(this.failed ? 'bin/recovery-required' : 'bin/closed',\n this.failed ? 'Close and reopen the archive service after an unexpected failure.' : 'Archive service is closing.',\n this.failed ? { cause: this.failure } : undefined);\n }\n private enqueue<T>(work: () => Promise<T>): Promise<T> {\n if (this.closing || this.failed) return Promise.reject(this.unavailable());\n const result = this.tail.then(async () => {\n if (this.failed) throw this.unavailable();\n try { return await work(); }\n catch (error) {\n if (!isSessionBinRefusal(error)) {\n this.failed = true; this.failure = error;\n }\n throw error;\n }\n });\n this.tail = result.then(() => undefined, () => undefined);\n return result;\n }\n}\n", "import { createHash, randomUUID } from 'node:crypto';\nimport { createRequire } from 'node:module';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport type { Context } from '@deepseek-ai/cordis';\nimport { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';\nimport type { Domain } from '@deepseek-ai/dsh-storage-domain';\nimport { SessionId } from '@deepseek-ai/dsh-session';\nimport { z } from 'zod';\nimport { nativePlatformCandidate, nativePlatformVerified, nativeRuntimeCandidate } from './platform-files.js';\nimport { legacyDurableHostContract, nativeRetirementSdkFingerprint } from './native-retirement-sdk.js';\nimport { NativeJsonlFiles, NativeJsonlRefusal, nativeJsonlInventorySchema } from './native-jsonl-files.js';\nimport type { NativeJsonlInventory } from './native-jsonl-files.js';\nimport { NativeMetadataAdapter, NativeMetadataRefusal, nativeMetadataSnapshotSchema } from './native-retirement-metadata.js';\nimport type { NativeMetadataSnapshot } from './native-retirement-metadata.js';\nimport { NativeAdmission, NativeAdmissionError } from './native-retirement-admission.js';\nimport { NativePersistenceAdapter, nativeServiceInstance } from './native-retirement-persistence.js';\nimport { RetirementOwnerCoordinator, RetirementOwnerError } from './retirement-owner.js';\nimport type { RetirementLifecycleScope, RetirementResourceParticipant, RetirementOwnerCoordinatorOptions } from './retirement-owner.js';\nimport { DomainRetirementOwnerStore, retirementOwnerDomainSpec } from './retirement-owner-store.js';\nimport type { RetirementOwnerStore } from './retirement-owner-store.js';\nimport { lifecycleKeySchema, lifecycleEqual, retirementCapabilitiesSchema } from '../operations/retirement.js';\nimport type { LifecycleKey, RetirementCapabilities, RetirementManifest, RetirementRequest, RetirementAuthorization, RetirementState } from '../operations/retirement.js';\nimport { retirementOwnerRefusal, isRetirementOwnerRefusal } from './retirement.js';\nimport type { SessionRetirementOwnerV1 } from './retirement.js';\nimport type { RetirementOwnerRecord } from '../operations/retirement-owner.js';\n\nconst nativeOwnerRegistry = Symbol.for('dsh-session-bin.native-retirement-owner');\ntype GuardRegistration = { owner: NativeRetirementOwner; root: string; fingerprint: string; storeId: string };\n\nconst witnessSchema = z.object({ schemaVersion: z.literal(1), lifecycle: lifecycleKeySchema,\n inventory: nativeJsonlInventorySchema, metadata: nativeMetadataSnapshotSchema }).strict().superRefine((value, ctx) => {\n if (value.lifecycle.sessionId !== value.inventory.sessionId || value.lifecycle.sessionId !== value.metadata.sessionId) {\n ctx.addIssue({ code: 'custom', message: 'Native witness resources differ from its exact lifecycle.' });\n }\n});\nexport const nativeRetirementDomainSpec = defineDomain({ name: 'session_bin_jsonl_resources', version: 1, layout: 'single',\n global: { schema: z.object({ schemaVersion: z.literal(1), storeId: z.uuid().nullable(), root: z.string().nullable(), fingerprint: z.string().nullable() }).strict(),\n initial: { schemaVersion: 1, storeId: null, root: null, fingerprint: null } },\n tables: { witnesses: domainTable(witnessSchema) } } as const);\nexport const nativeRetirementOwnerDomainSpec = defineDomain({ ...retirementOwnerDomainSpec, name: 'session_bin_jsonl_retirement_owner' } as const);\ntype Witness = z.infer<typeof witnessSchema>;\ntype Scope = { witness: Witness; inventory: NativeJsonlInventory; metadata: NativeMetadataSnapshot;\n blocked: string | null; lease: { release(): Promise<void> } | undefined; releaseAdmission: () => void };\n\nconst hash = (value: unknown) => createHash('sha256').update(JSON.stringify(value)).digest('hex');\nconst metadataRevision = (value: NativeMetadataSnapshot) => hash({ sessionId: value.sessionId, global: value.global,\n workspaces: value.workspaces.map(item => ({ workspaceId: item.workspaceId, path: item.record.path })).sort((a, b) => a.workspaceId.localeCompare(b.workspaceId)),\n cache: value.cache, queryProvider: value.queryProvider, queryPath: value.queryPath });\nconst equal = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b);\nfunction known(error: unknown): string | null {\n if (error instanceof NativeJsonlRefusal || error instanceof NativeMetadataRefusal) return error.code;\n if (error instanceof NativeAdmissionError) return 'native/session-busy';\n return null;\n}\nexport interface NativeRetirementOptions {\n /** Independent composition qualification, used by isolated candidate-platform fixtures.\n * The production Service never takes this callback from Host configuration. */\n platformQualification?: (runtime: { platform: NodeJS.Platform; arch: string; node: string }) => boolean;\n checkpoint?: RetirementOwnerCoordinatorOptions['checkpoint'];\n canAdvance?: RetirementOwnerCoordinatorOptions['canAdvance'];\n}\n\n/** Actual native log erasure, limited to the audited cold JSONL/Workspace composition. */\nexport class NativeRetirementOwner implements SessionRetirementOwnerV1 {\n private readonly scopes = new Map<string, Scope>();\n private readonly coordinator: RetirementOwnerCoordinator;\n private readonly descriptor: RetirementCapabilities;\n private readonly provider: NativePersistenceAdapter;\n private readonly originalProvider: object;\n private readonly restore: Array<() => Promise<void>> = [];\n private readonly observations = new Set<Promise<unknown>>();\n private fullyClosed = false;\n private observationsClosed = false;\n private closing: Promise<void> | undefined;\n\n private constructor(private readonly ctx: Context, private readonly files: NativeJsonlFiles,\n private readonly metadata: NativeMetadataAdapter, private readonly admission: NativeAdmission,\n private readonly domain: Domain<typeof nativeRetirementDomainSpec>, private readonly journal: RetirementOwnerStore,\n fingerprint: string, options: NativeRetirementOptions) {\n this.originalProvider = nativeServiceInstance(ctx.sessionPersistence);\n this.provider = new NativePersistenceAdapter(ctx.sessionPersistence, admission);\n this.descriptor = retirementCapabilitiesSchema.parse({ protocolVersion: 1, ownerId: 'session-bin-native-jsonl-owner',\n hostVersion: legacyDurableHostContract, providerId: 'jsonl-session-records-v1', storeId: domain.global.get().storeId,\n participants: [{ id: 'native-jsonl-files', version: fingerprint }, { id: 'native-metadata', version: fingerprint }] });\n for (const record of journal.operations()) if (!['rejected', 'conflict'].includes(record.state.phase)) admission.markRetired(record.state.request.expected.sessionId);\n const guardedStore: RetirementOwnerStore = {\n bindCapabilities: value => this.io(() => journal.bindCapabilities(value)),\n operation: id => this.read(() => journal.operation(id)), operations: () => this.read(() => journal.operations()),\n putOperation: value => this.io(async () => {\n // Fail closed even if a medium commit succeeds but acknowledgement fails.\n if (!['rejected', 'conflict'].includes(value.state.phase)) admission.markRetired(value.state.request.expected.sessionId);\n await journal.putOperation(value);\n }), close: () => journal.close(),\n };\n const participants = [this.fileParticipant(fingerprint), this.metadataParticipant(fingerprint)];\n this.coordinator = new RetirementOwnerCoordinator({ capabilities: this.descriptor, store: guardedStore,\n lifecycle: { inspect: id => this.inspect(id), bindGuards: async () => async () => {},\n acquire: (expected, maintenance) => this.acquire(expected, maintenance) }, participants,\n ...(options.checkpoint ? { checkpoint: options.checkpoint } : {}), ...(options.canAdvance ? { canAdvance: options.canAdvance } : {}) });\n }\n static async open(ctx: Context, options: NativeRetirementOptions = {}): Promise<NativeRetirementOwner | undefined> {\n // An implemented candidate is not production evidence. Never derive this\n // composition callback from permanentDeletion:true or client input.\n if (!nativeRuntimeCandidate() || !nativePlatformCandidate()) return;\n if (!nativePlatformVerified() && !options.platformQualification?.({\n platform: process.platform, arch: process.arch, node: process.versions.node,\n })) return;\n const fingerprint = await nativeRetirementSdkFingerprint();\n if (fingerprint === null) return;\n for (const name of ['sessionQuery', 'sessionProjectionCache', 'sessionController'] as const) {\n const pending = ctx.get(name, false);\n if (pending !== undefined && ctx.get(name) === undefined) {\n const instance = nativeServiceInstance(pending as object) as { ctx?: { fiber?: { await(): Promise<unknown> } } };\n if (!instance.ctx?.fiber) return;\n await instance.ctx.fiber.await();\n if (ctx.get(name) === undefined) return;\n }\n }\n const files = await NativeJsonlFiles.open(ctx.sessionPersistence);\n if (!files) return;\n const admission = new NativeAdmission();\n const providerInstance = nativeServiceInstance(ctx.sessionPersistence);\n const previous = Reflect.get(providerInstance, nativeOwnerRegistry) as GuardRegistration | undefined;\n if (previous && (!previous.owner.fullyClosed || previous.root !== files.root || previous.fingerprint !== fingerprint)) return;\n const metadata = await NativeMetadataAdapter.open(ctx, admission);\n if (!metadata) return;\n let domain: Domain<typeof nativeRetirementDomainSpec> | undefined;\n let journalDomain: Domain<typeof nativeRetirementOwnerDomainSpec> | undefined;\n let owner: NativeRetirementOwner | undefined;\n try {\n domain = await ctx.storageDomain.open(nativeRetirementDomainSpec);\n const global = domain.global.get();\n if (global.storeId === null) {\n await domain.global.set({ schemaVersion: 1, storeId: randomUUID(), root: files.root, fingerprint });\n } else if (global.root !== files.root || global.fingerprint !== fingerprint) {\n throw new Error('Native retirement resources belong to another root or audited composition.');\n }\n if (previous && previous.storeId !== domain.global.get().storeId) throw new Error('Native guard takeover belongs to another durable store.');\n journalDomain = await ctx.storageDomain.open(nativeRetirementOwnerDomainSpec);\n // Identical public record/global schemas; only this owner's domain name differs.\n const journal = new DomainRetirementOwnerStore(journalDomain as unknown as Domain<typeof retirementOwnerDomainSpec>);\n owner = new NativeRetirementOwner(ctx, files, metadata, admission, domain, journal, fingerprint, options);\n await owner.coordinator.initialize();\n admission.activate();\n if (previous) previous.owner.relinquishGuards();\n owner.restore.push(owner.provider.install());\n owner.restore.push(await metadata.install());\n Reflect.set(providerInstance, nativeOwnerRegistry, { owner, root: files.root, fingerprint, storeId: owner.descriptor.storeId } satisfies GuardRegistration);\n return owner;\n } catch (error) {\n admission.suspend();\n const errors = [error];\n for (const action of [() => owner?.close(), () => journalDomain?.close(), () => domain?.close()]) {\n try { await action(); } catch (cleanup) { errors.push(cleanup); }\n }\n if (errors.length > 1) throw new AggregateError(errors, 'Native retirement initialization/cleanup failed.');\n throw error;\n }\n }\n capabilities(): Promise<RetirementCapabilities> {\n if (this.admission.requiresRecovery()) return Promise.reject(new Error('Native retirement requires a complete reopen after unknown I/O.'));\n return this.coordinator.capabilities();\n }\n eligibility(id: string): Promise<string | null> { return this.observe(() => this.eligibilityInner(id)); }\n private async eligibilityInner(id: string): Promise<string | null> {\n if (nativeServiceInstance(this.ctx.sessionPersistence) !== this.originalProvider) return 'native/composition-changed';\n if (this.admission.isRetired(id)) return 'native/session-retired';\n try {\n const scope = this.scopes.get(id);\n if (scope) {\n if (this.provider.busy(id)) return 'native/persistence-retained';\n if (scope.blocked) return scope.blocked;\n await this.metadata.capture(id);\n return null;\n }\n const release = await this.admission.acquire(id);\n try {\n await this.metadata.releaseIdle(id);\n await this.admission.drain(id);\n if (this.provider.busy(id)) return 'native/persistence-retained';\n await this.metadata.capture(id);\n const snapshot = await this.provider.stat(id);\n if (!snapshot) return 'session-not-found';\n if (snapshot.header.origin === 'subagent') return 'native/subagent-unsupported';\n const inventory = await this.files.inspect(id, snapshot.header);\n const lease = await this.files.acquire(inventory);\n try { await this.files.current(inventory); } finally { await lease.release(); }\n return null;\n } finally { release(); }\n } catch (error) { const reason = known(error); if (reason !== null) return reason; this.admission.suspend(); throw error; }\n }\n inspect(id: string): Promise<LifecycleKey | null> { return this.observe(() => this.inspectInner(id)); }\n private async inspectInner(id: string): Promise<LifecycleKey | null> {\n if (this.admission.isRetired(id) && !this.scopes.has(id)) return null;\n const scope = this.scopes.get(id);\n if (scope) return scope.blocked ? null : lifecycleKeySchema.parse(scope.witness.lifecycle);\n const release = await this.admission.acquire(id);\n let lease: { release(): Promise<void> } | undefined;\n try {\n if (this.provider.busy(id)) throw retirementOwnerRefusal('native/persistence-retained');\n const snapshot = await this.provider.stat(id);\n if (!snapshot) return null;\n if (snapshot.header.origin === 'subagent') throw retirementOwnerRefusal('native/subagent-unsupported');\n const initial = await this.files.inspect(id, snapshot.header);\n lease = await this.files.acquire(initial);\n const inventory = await this.files.current(initial);\n const metadata = await this.metadata.capture(id);\n const previous = this.witness(id);\n const lifecycle = previous && equal(previous.inventory.anchor, inventory.anchor)\n ? previous.lifecycle : { storeId: this.descriptor.storeId, sessionId: id, lifecycleId: randomUUID() };\n await this.putWitness({ schemaVersion: 1, lifecycle, inventory, metadata });\n return lifecycleKeySchema.parse(lifecycle);\n } catch (error) {\n const reason = known(error); if (reason !== null) throw retirementOwnerRefusal(reason);\n throw error;\n } finally { try { await lease?.release(); } finally { release(); } }\n }\n async prepare(expected: LifecycleKey): Promise<RetirementManifest> {\n try { return await this.coordinator.prepare(expected); }\n catch (error) {\n if (this.coordinator.isRefusal(error)) throw retirementOwnerRefusal(error instanceof RetirementOwnerError ? error.code : 'native/lifecycle-changed');\n this.admission.suspend(); throw error;\n }\n }\n async retire(request: RetirementRequest, authorize: () => Promise<RetirementAuthorization>, manifest?: RetirementManifest): Promise<RetirementState> {\n try { return await this.coordinator.retire(request, authorize, manifest); }\n catch (error) {\n if (this.coordinator.isRefusal(error)) throw retirementOwnerRefusal(error instanceof RetirementOwnerError ? error.code : 'native/operation-refused');\n this.admission.suspend(); throw error;\n }\n }\n getOperation(id: string): Promise<RetirementState | null> { return this.coordinator.getOperation(id); }\n async recover(id: string): Promise<RetirementState> {\n try { return await this.coordinator.recover(id); }\n catch (error) {\n if (this.coordinator.isRefusal(error)) throw retirementOwnerRefusal(error instanceof RetirementOwnerError ? error.code : 'native/operation-refused');\n this.admission.suspend(); throw error;\n }\n }\n private async acquire(expected: LifecycleKey, maintenance: RetirementOwnerRecord | null): Promise<RetirementLifecycleScope> {\n const witness = this.witness(expected.sessionId);\n if (!witness || !lifecycleEqual(expected, witness.lifecycle)) throw new Error('Native lifecycle witness is missing or changed.');\n const releaseAdmission = await this.admission.acquire(expected.sessionId, maintenance !== null);\n const scope: Scope = { witness, inventory: witness.inventory, metadata: witness.metadata, blocked: null, lease: undefined, releaseAdmission };\n try {\n if (this.provider.busy(expected.sessionId)) scope.blocked = 'native/persistence-retained';\n if (!scope.blocked) {\n if (maintenance === null) {\n const snapshot = await this.provider.stat(expected.sessionId);\n if (!snapshot) scope.blocked = 'native/lifecycle-changed';\n else {\n const inventory = await this.files.inspect(expected.sessionId, snapshot.header);\n if (!equal(inventory.anchor, witness.inventory.anchor)) scope.blocked = 'native/lifecycle-changed';\n else scope.inventory = inventory;\n }\n }\n if (!scope.blocked) {\n scope.lease = await this.files.acquire(scope.inventory, { recovering: maintenance !== null });\n scope.inventory = await this.files.current(scope.inventory);\n if (maintenance === null) scope.metadata = await this.metadata.capture(expected.sessionId);\n }\n }\n } catch (error) {\n const reason = known(error);\n if (reason !== null && maintenance === null) scope.blocked = reason;\n else { this.admission.suspend(); try { await scope.lease?.release(); } finally { releaseAdmission(); } throw error; }\n }\n this.scopes.set(expected.sessionId, scope);\n return { lifecycle: expected, current: async () => scope.blocked ? null : expected,\n activity: async () => scope.blocked ? [scope.blocked] : (await this.ctx.waterfall('workspace/session-activity', { sessionId: SessionId(expected.sessionId) }, async () => [])).map(item => String(item.kind)),\n quiesce: async () => {\n await this.admission.drain(expected.sessionId);\n if (scope.blocked || this.provider.busy(expected.sessionId)) return false;\n await this.metadata.capture(expected.sessionId); return true;\n },\n finalize: async () => {\n if (this.provider.busy(expected.sessionId)) return false;\n this.provider.forget(expected.sessionId); return true;\n },\n release: async () => {\n this.scopes.delete(expected.sessionId);\n try { await scope.lease?.release(); } finally { releaseAdmission(); }\n } };\n }\n private observe<T>(work: () => Promise<T>): Promise<T> {\n if (this.admission.requiresRecovery()) return Promise.reject(new Error('Native retirement requires a complete reopen after unknown I/O.'));\n if (this.observationsClosed && !this.coordinator.ownsCurrentMaintenanceFrame()) return Promise.reject(retirementOwnerRefusal('native/closing'));\n const task = Promise.resolve().then(work).catch(error => {\n const reason = known(error);\n if (reason !== null) throw retirementOwnerRefusal(reason);\n // Only our trusted marker remains a business refusal; cleanup/FS errors\n // are unknown and fence the affected retirement candidates immediately.\n if (!isRetirementOwnerRefusal(error)) this.admission.suspend();\n throw error;\n });\n this.observations.add(task);\n void task.finally(() => this.observations.delete(task)).catch(() => {});\n return task;\n }\n private fileParticipant(version: string): RetirementResourceParticipant {\n return { identity: { id: 'native-jsonl-files', version }, bindGuards: async () => async () => {},\n manifest: async expected => {\n const scope = this.requireScope(expected);\n if (!scope.blocked) scope.inventory = await this.files.current(scope.inventory);\n return scope.inventory.files.map(row => ({ ownerId: 'native-jsonl-files', resourceId: row.resourceId, revision: row.revision,\n kind: 'transcript' as const, disposition: 'erase' as const, retention: null }));\n }, fence: async () => true, quiesce: async () => true,\n applyResource: async (request, resource) => {\n const scope = this.requireScope(request.expected);\n const row = scope.witness.inventory.files.find(item => item.resourceId === resource.resourceId && item.revision === resource.revision);\n if (!row || scope.blocked) throw new Error('Frozen native file witness is unavailable.');\n await this.files.erase(scope.witness.inventory, row);\n return { ownerId: resource.ownerId, resourceId: resource.resourceId, status: 'erased', reason: null };\n }, converge: async request => (await this.files.current(this.requireScope(request.expected).witness.inventory)).files.length === 0 };\n }\n private metadataParticipant(version: string): RetirementResourceParticipant {\n return { identity: { id: 'native-metadata', version }, bindGuards: async () => async () => {},\n manifest: async expected => {\n const scope = this.requireScope(expected);\n if (!scope.blocked) scope.metadata = await this.metadata.capture(expected.sessionId);\n // Commit the complete physical/metadata witness before the plan can be\n // admitted; recovery never resolves resources from a new same-ID object.\n if (!scope.blocked) {\n scope.witness = { ...scope.witness, inventory: scope.inventory, metadata: scope.metadata };\n await this.putWitness(scope.witness);\n }\n const kinds = ['workspace', ...(scope.metadata.cache.location !== null ? ['cache'] : []), ...(scope.metadata.queryProvider === 'sqlite-0.2.0-rc.2' ? ['index'] : [])] as const;\n return kinds.map(kind => ({ ownerId: 'native-metadata', resourceId: `native-${kind}`, revision: metadataRevision(scope.metadata),\n kind: kind as 'workspace' | 'cache' | 'index', disposition: 'erase' as const, retention: null }));\n }, fence: async () => true, quiesce: async () => true,\n applyResource: async (request, resource) => {\n const scope = this.requireScope(request.expected);\n if ((await this.files.current(scope.witness.inventory)).files.length !== 0) {\n return { ownerId: resource.ownerId, resourceId: resource.resourceId, status: 'failed', reason: 'native/files-remain' };\n }\n if (!await this.metadata.converge(scope.witness.metadata, request.expected, request)) {\n return { ownerId: resource.ownerId, resourceId: resource.resourceId, status: 'failed', reason: 'native/metadata-pending' };\n }\n return { ownerId: resource.ownerId, resourceId: resource.resourceId, status: 'erased', reason: null };\n }, converge: async request => {\n const scope = this.requireScope(request.expected);\n return this.metadata.converge(scope.witness.metadata, request.expected, request);\n } };\n }\n private requireScope(expected: LifecycleKey): Scope {\n const scope = this.scopes.get(expected.sessionId);\n if (!scope || !lifecycleEqual(scope.witness.lifecycle, expected)) throw new Error('Native resource action requires its exact held scope.');\n return scope;\n }\n private witness(id: string): Witness | undefined {\n return this.read(() => { const value = this.domain.table('witnesses').get(id); return value === undefined ? undefined : witnessSchema.parse(value); });\n }\n private putWitness(value: Witness): Promise<void> {\n const snapshot = witnessSchema.parse(value);\n return this.io(() => this.domain.table('witnesses').put(snapshot.lifecycle.sessionId, snapshot));\n }\n private read<T>(work: () => T): T { try { return work(); } catch (error) { this.admission.suspend(); throw error; } }\n private async io<T>(work: () => Promise<T>): Promise<T> { try { return await work(); } catch (error) { this.admission.suspend(); throw error; } }\n private relinquishGuards(): void {\n if (!this.fullyClosed) throw new Error('An active native retirement owner cannot surrender its guards.');\n this.metadata.forceRestore(); this.provider.forceRestore();\n }\n close(): Promise<void> {\n this.observationsClosed = true;\n return this.closing ??= (async () => {\n const errors: unknown[] = [];\n try { await this.coordinator.close(); } catch (error) { errors.push(error); }\n while (this.observations.size) await Promise.allSettled([...this.observations]);\n this.admission.beginClose();\n try { await this.admission.drain(); } catch (error) { errors.push(error); }\n for (const restore of this.restore.reverse()) try { await restore(); } catch (error) { errors.push(error); }\n try { await this.domain.close(); } catch (error) { errors.push(error); }\n this.fullyClosed = errors.length === 0;\n if (errors.length) throw new AggregateError(errors, 'Native retirement shutdown failed.');\n })();\n }\n}\n", "import { createRequire } from 'node:module';\nimport { readFile } from 'node:fs/promises';\nimport { dirname, join } from 'node:path';\nimport { createHash } from 'node:crypto';\n\n/** Locked public npm implementation files actually inspected and tested. */\nexport const nativeRetirementSdkSources = {\n \"cordis\": {\n \"version\": \"4.0.5\",\n \"files\": {\n \"lib/index.js\": \"6a9394c0877ff45218818c6e815edd038f8057e1a1deb390a8d43ec81c57691e\"\n }\n },\n \"dsh-session\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"2f5dd07cb5c744a29abbb8003a8a4cefd9e582c6e2538074ca299a0ddd02a3bf\",\n \"lib/types/index.js\": \"59cced30c7ee65813c62f4858c2fc15c8c636df96507b60c15543468178b72f2\"\n }\n },\n \"dsh-session-persistence\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"cc0b6d3a224133af611b428d5a49020e300f86c3b4ba28037aeb219029bde3eb\"\n }\n },\n \"dsh-session-persistence-jsonl\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"973dd78679b2661d6f492343bc22b124ae958aa597d3b36c698a2c650f909984\"\n }\n },\n \"dsh-session-format-catalog\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"836bbb772ab505c299f1a4a246164c50c7c08b67ab0d17f1251d7ea2cd8c1818\",\n \"lib/types/index.js\": \"c7d797760bf2b9bc654751f2f8cb0b8a6b98998c8d9c1e41323c71a4d5f316f2\"\n }\n },\n \"dsh-storage-domain\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"a54f7664d2f64fe04a08c7058ca5bff4fc69ed6a0d30c2bc11561b620698ef16\"\n }\n },\n \"dsh-storage-json\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"0a6b75d5569db3379edd93e863570170e1f4121b6c9fabd856f5b476cffe8df4\"\n }\n },\n \"dsh-workspace\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"931ca0cb10c5102066c7723690a887f0e6e8e7ab0ffdee1a782686745b0b934f\",\n \"lib/types/index.js\": \"ed69989d8286598fddb3a40030723810a1238968e91ccfec05fc84657bb5ec74\"\n }\n },\n \"dsh-session-query\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"76ce2944e561c12f48b5e240d68cafe54ce6d667b1d20722e6939ed834489939\"\n }\n },\n \"dsh-session-query-sqlite\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"dbecf83320e10d93d735b3d01384ab817a0b90102ccecb0a22c013c71dfe70a0\"\n }\n },\n \"dsh-session-projection-cache\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"faf307dce5db2fb7ff58b4c7d9e544fc7cad5de2f270a89326a8d7bb2bda9c80\"\n }\n },\n \"dsh-api-session-controller\": {\n \"version\": \"0.2.1-rc.2\",\n \"files\": {\n \"lib/index.js\": \"a9801acb577b03053c5d5a3191ff555c5f1d791d0acddec113bea4511e33b386\",\n \"lib/types/index.js\": \"616ced16623b7448afa908ff65093eb6ef2a478d32e5ef9bc22634bfa9f80472\"\n }\n }\n} as const;\n\n/** Schema-1 resource identity, preserved across the audited runtime upgrade.\n * These are historical wire identifiers, not the installed SDK version. */\nexport const legacyDurableHostContract = '0.2.0-rc.2';\nconst legacyDurableContractFingerprint = '2618a33decce99fe8ae893245236273d10ac5536bb9dd582dddd115ef27069f3';\n\nexport async function nativeRetirementSdkFingerprint(): Promise<string | null> {\n const root = createRequire(import.meta.url);\n const hostPath = root.resolve('@deepseek-ai/dsh/package.json');\n if (JSON.parse(await readFile(hostPath, 'utf8')).version !== '0.2.1-rc.2') return null;\n const base = createRequire(hostPath);\n for (const [name, expected] of Object.entries(nativeRetirementSdkSources)) {\n let path: string;\n try { path = root.resolve(`@deepseek-ai/${name}/package.json`); }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'MODULE_NOT_FOUND') throw error;\n try { path = base.resolve(`@deepseek-ai/${name}/package.json`); }\n catch (cause) { if ((cause as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') return null; throw cause; }\n }\n const meta = JSON.parse(await readFile(path, 'utf8')) as { version?: string };\n if (meta.version !== expected.version) return null;\n for (const [file, digest] of Object.entries(expected.files)) {\n if (createHash('sha256').update(await readFile(join(dirname(path), file))).digest('hex') !== digest) return null;\n }\n }\n // Idle API lifecycle release additionally uses the returned AgentHandle and\n // the driver's phase (maintenance is publicly reported as idle). These extra\n // runtime checks do not change the existing durable resource/journal identity.\n const runtime = createRequire(base.resolve('@deepseek-ai/dsh-base/package.json'));\n for (const [name, expected] of Object.entries({\n 'dsh-agent': '7b59cf82c2784c25bdce4e3e24e5e5303b02b9f1003efacf50255492d17baf8b',\n 'dsh-agent-loop': 'cf57e3ecd487ac5c2553455aaa5cef2c6fb41e6bd61be5aa455675d1d7193033',\n })) {\n let path: string;\n try { path = runtime.resolve(`@deepseek-ai/${name}/package.json`); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'MODULE_NOT_FOUND') return null; throw error; }\n if ((JSON.parse(await readFile(path, 'utf8')) as { version: string }).version !== '0.2.1-rc.2'\n || createHash('sha256').update(await readFile(join(dirname(path), 'lib/index.js'))).digest('hex') !== expected) return null;\n }\n return legacyDurableContractFingerprint;\n}\n", "import type { BigIntStats } from 'node:fs';\nimport { lstat, realpath, readdir, unlink } from 'node:fs/promises';\nimport type { FileHandle } from 'node:fs/promises';\nimport { isAbsolute, join, relative, resolve, sep } from 'node:path';\nimport { createHash } from 'node:crypto';\nimport { createRequire } from 'node:module';\nimport { zstdDecompressSync } from 'node:zlib';\nimport { SessionPersistence } from '@deepseek-ai/dsh-session-persistence';\nimport { SESSION_FORMAT_VERSION } from '@deepseek-ai/dsh-session';\nimport type { SessionHeader } from '@deepseek-ai/dsh-session';\nimport { sessionFormatCatalog } from '@deepseek-ai/dsh-session-format-catalog';\nimport { tryLockExclusive } from '@deepseek-ai/node-addon-system/flock';\nimport { acquireWindowsSemaphore, nativePlatformCandidate, openRegularFile, RegularFileRefusal, syncDirectory, windowsSemaphoreName } from './platform-files.js';\nimport { z } from 'zod';\nimport { nativeServiceInstance } from './native-retirement-persistence.js';\n\nconst integer = z.string().regex(/^\\d+$/);\nconst hash = z.string().regex(/^[a-f0-9]{64}$/);\nconst positiveInteger = z.string().regex(/^[1-9]\\d*$/);\nconst nodeIdentitySchema = z.object({ dev: integer, ino: positiveInteger, birthtimeNs: positiveInteger }).strict();\nconst fileIdentitySchema = nodeIdentitySchema.extend({ size: integer, mtimeNs: integer, ctimeNs: integer, nlink: z.literal('1') }).strict();\nconst lockIdentitySchema = nodeIdentitySchema.extend({ size: z.literal('0'), nlink: z.literal('1') }).strict();\nconst windowsLockSchema = z.object({ kind: z.literal('win32-semaphore'), name: z.string().min(1) }).strict();\nconst nativeLockSchema = z.union([lockIdentitySchema, windowsLockSchema]);\nconst headerIdentitySchema = z.object({ id: z.string().min(1), createdAt: z.number().int().nonnegative(), cwd: z.string().nullable(),\n parentSession: z.string().nullable(), origin: z.literal('subagent').nullable(), isSeeded: z.boolean(),\n delegationDepth: z.number().int().nonnegative(), agentPreset: z.string().nullable() }).strict();\nconst fileRowSchema = z.object({ resourceId: z.string().min(1), kind: z.enum(['generation', 'staging']),\n formatVersion: z.number().int().min(0).max(4), compression: z.enum(['none', 'zstd']),\n identity: fileIdentitySchema, digest: hash, header: headerIdentitySchema, revision: hash }).strict().superRefine((value, ctx) => {\n try {\n const kind = classify(value.resourceId);\n if (kind.kind !== value.kind || kind.version !== value.formatVersion || kind.compression !== value.compression\n || value.revision !== sha(JSON.stringify({ identity: value.identity, digest: value.digest, header: value.header }))) {\n ctx.addIssue({ code: 'custom', message: 'Resource classification and identity digest must agree.' });\n }\n } catch { ctx.addIssue({ code: 'custom', message: 'Unknown physical resource name.' }); }\n });\nexport const nativeJsonlFileSchema = fileRowSchema;\nexport const nativeJsonlInventorySchema = z.object({ schemaVersion: z.literal(1), root: z.string(),\n rootIdentity: nodeIdentitySchema, directory: z.string(), directoryIdentity: nodeIdentitySchema,\n sessionId: z.string().min(1), compression: z.enum(['none', 'zstd']), header: headerIdentitySchema,\n anchor: z.object({ resourceId: z.string(), identity: nodeIdentitySchema, header: headerIdentitySchema }).strict(),\n lock: nativeLockSchema, files: z.array(fileRowSchema).max(4096), revision: hash }).strict().superRefine((value, ctx) => {\n try {\n const anchor = generation(value.anchor.resourceId);\n if (!isAbsolute(value.root) || value.directory !== join(project(value.header.cwd), segment(value.sessionId))\n || value.header.id !== value.sessionId || !same(value.anchor.header, value.header)\n || !anchor || anchor.compression !== value.compression\n || new Set(value.files.map(row => row.resourceId)).size !== value.files.length\n || value.files.some(row => row.compression !== value.compression || !same(row.header, value.header))\n || value.revision !== sha(JSON.stringify(value.files))) {\n ctx.addIssue({ code: 'custom', message: 'Frozen directory, header identities, file scope and digest must agree.' });\n }\n } catch { ctx.addIssue({ code: 'custom', message: 'Invalid frozen directory or anchor.' }); }\n });\nexport type NativeJsonlInventory = z.infer<typeof nativeJsonlInventorySchema>;\nexport type NativeJsonlFileRow = z.infer<typeof fileRowSchema>;\ntype NodeIdentity = z.infer<typeof nodeIdentitySchema>;\ntype HeaderIdentity = z.infer<typeof headerIdentitySchema>;\ntype Encoding = 'none' | 'zstd';\n\nexport class NativeJsonlRefusal extends Error {\n constructor(readonly code: string, message: string) { super(message); this.name = 'NativeJsonlRefusal'; }\n}\nfunction refuse(code: string, message: string): never { throw new NativeJsonlRefusal(code, message); }\nfunction sha(value: string | Buffer): string { return createHash('sha256').update(value).digest('hex'); }\nfunction same(a: unknown, b: unknown): boolean { return JSON.stringify(a) === JSON.stringify(b); }\nfunction nodeIdentity(stat: BigIntStats): NodeIdentity {\n if (stat.ino <= 0n || stat.birthtimeNs <= 0n) refuse('jsonl/identity-unavailable', 'The filesystem does not provide a stable inode and creation identity.');\n return { dev: String(stat.dev), ino: String(stat.ino), birthtimeNs: String(stat.birthtimeNs) };\n}\nfunction nodeIdentityFromRow(row: NativeJsonlFileRow): NodeIdentity {\n return { dev: row.identity.dev, ino: row.identity.ino, birthtimeNs: row.identity.birthtimeNs };\n}\nfunction fileIdentity(stat: BigIntStats) {\n if (!stat.isFile() || stat.nlink !== 1n) refuse('jsonl/unsafe-file', 'Resources must be exclusive regular files without additional hard links.');\n return fileIdentitySchema.parse({ ...nodeIdentity(stat), size: String(stat.size), mtimeNs: String(stat.mtimeNs), ctimeNs: String(stat.ctimeNs), nlink: '1' });\n}\nfunction lockIdentity(stat: BigIntStats) {\n const identity = fileIdentity(stat);\n if (identity.size !== '0') refuse('jsonl/lock-invalid', 'The existing stable lock must contain no session content.');\n return lockIdentitySchema.parse({ ...nodeIdentity(stat), size: '0', nlink: '1' });\n}\nfunction headerIdentity(header: { id: string; createdAt: number; cwd?: string; parentSession?: string; origin?: 'subagent'; isSeeded: boolean; delegationDepth?: number; agentPreset?: string }): HeaderIdentity {\n return headerIdentitySchema.parse({ id: header.id, createdAt: header.createdAt, cwd: header.cwd ?? null,\n parentSession: header.parentSession ?? null, origin: header.origin ?? null, isSeeded: header.isSeeded,\n delegationDepth: header.delegationDepth ?? 0, agentPreset: header.agentPreset ?? null });\n}\n// Independently expressed rules of the pinned on-disk layout; no private SDK imports.\nfunction segment(value: string): string {\n if (!value) refuse('jsonl/identity-invalid', 'A path identity cannot be empty.');\n if (value === '.' || value === '..') return value.replace(/\\./g, '~002E');\n return value.replace(/[^A-Za-z0-9._-]/g, unit => `~${unit.charCodeAt(0).toString(16).toUpperCase().padStart(4, '0')}`);\n}\nfunction project(cwd: string | null): string {\n if (cwd === null) return '_no-cwd';\n if (!isAbsolute(cwd)) refuse('jsonl/identity-invalid', 'The stored cwd must be absolute.');\n const readable = segment(cwd.replace(/[/\\\\:]+/g, '-')).replace(/^-+/, '') || 'root';\n return `--${readable.slice(0, 251)}--`;\n}\nfunction generation(name: string): { version: number; compression: Encoding } | undefined {\n const match = /^session(?:\\.v([1-9]\\d*))?\\.jsonl(\\.zstd)?$/.exec(name);\n if (!match) return;\n const version = match[1] === undefined ? 0 : Number(match[1]);\n if (!Number.isSafeInteger(version) || version > SESSION_FORMAT_VERSION) refuse('jsonl/unsupported-generation', 'Unknown future physical generations cannot be retired.');\n return { version, compression: match[2] ? 'zstd' : 'none' };\n}\nfunction classify(name: string) {\n const committed = generation(name);\n if (committed) return { ...committed, kind: 'generation' as const };\n const materializing = /^(session(?:\\.v[1-9]\\d*)?\\.jsonl(?:\\.zstd)?)\\.[a-f0-9]{12}\\.tmp$/.exec(name);\n if (materializing) return { ...generation(materializing[1]!)!, kind: 'staging' as const };\n const migrating = /^session\\.migration\\.[a-f0-9]{16}\\.jsonl(\\.zstd)?\\.tmp$/.exec(name);\n if (migrating) return { version: SESSION_FORMAT_VERSION, compression: migrating[1] ? 'zstd' as const : 'none' as const, kind: 'staging' as const };\n refuse('jsonl/unknown-resource', `Unclassified session resource: ${name}`);\n}\n\nconst HEADER_LIMIT = 1024 * 1024;\n// Locate one standard Zstandard frame by its frame header and block lengths.\n// Decode exactly that frame; a torn later event frame does not hide the header.\nfunction firstFrameEnd(bytes: Buffer): number | undefined {\n if (bytes.length < 5) return;\n if (bytes.readUInt32LE(0) !== 0xfd2fb528) refuse('jsonl/header-invalid', 'The first Zstandard frame is not a standard frame.');\n const descriptor = bytes[4]!;\n if (descriptor & 0x18) refuse('jsonl/header-invalid', 'Reserved Zstandard frame flags are unsupported.');\n const single = Boolean(descriptor & 0x20);\n const sizeFlag = descriptor >>> 6;\n const dictionaryBytes = [0, 1, 2, 4][descriptor & 3]!;\n const sizeBytes = sizeFlag === 0 ? single ? 1 : 0 : [0, 2, 4, 8][sizeFlag]!;\n let cursor = 5 + (single ? 0 : 1) + dictionaryBytes + sizeBytes;\n if (cursor > bytes.length) return;\n for (;;) {\n if (cursor + 3 > bytes.length) return;\n const block = bytes.readUIntLE(cursor, 3);\n const type = (block >>> 1) & 3;\n if (type === 3) refuse('jsonl/header-invalid', 'Reserved Zstandard block type.');\n cursor += 3 + (type === 1 ? 1 : block >>> 3);\n if (cursor > bytes.length) return;\n if (block & 1) {\n cursor += descriptor & 4 ? 4 : 0;\n return cursor <= bytes.length ? cursor : undefined;\n }\n }\n}\nfunction decodeHeader(bytes: Buffer, compression: Encoding, version: number): HeaderIdentity {\n let line: Buffer;\n if (compression === 'none') {\n const newline = bytes.indexOf(10);\n if (newline < 0) refuse('jsonl/header-invalid', 'A complete physical header is required, including for staging.');\n line = bytes.subarray(0, newline);\n } else {\n const end = firstFrameEnd(bytes);\n if (end === undefined) refuse('jsonl/header-invalid', 'A complete Zstandard header frame is required.');\n let decoded: Buffer;\n try { decoded = zstdDecompressSync(bytes.subarray(0, end), { maxOutputLength: HEADER_LIMIT }); }\n catch { refuse('jsonl/header-invalid', 'The bounded first Zstandard frame cannot be decoded.'); }\n if (!decoded.length || decoded.indexOf(10) !== decoded.length - 1) refuse('jsonl/header-invalid', 'The header frame must contain exactly one newline-terminated record.');\n line = decoded.subarray(0, -1);\n }\n try {\n const raw: unknown = JSON.parse(new TextDecoder('utf-8', { fatal: true }).decode(line));\n const result = sessionFormatCatalog.readHeader(raw);\n if (result.status !== 'current' && result.status !== 'migration-required') refuse('jsonl/header-invalid', 'Malformed or unsupported physical Session header.');\n if (result.storedVersion !== version) refuse('jsonl/header-invalid', 'Physical filename and header versions differ.');\n return headerIdentity(result.header);\n } catch (error) {\n if (error instanceof NativeJsonlRefusal) throw error;\n refuse('jsonl/header-invalid', 'The physical Session header cannot be decoded and identified.');\n }\n}\nfunction missing(error: unknown): boolean { return (error as NodeJS.ErrnoException | undefined)?.code === 'ENOENT'; }\n\ninterface HeldFileLease {\n stamp: string;\n closing: boolean;\n tail: Promise<void>;\n pending: Set<Promise<void>>;\n recovering: boolean;\n}\nfunction leaseStamp(inventory: NativeJsonlInventory): string {\n return JSON.stringify({ root: inventory.root, rootIdentity: inventory.rootIdentity, directory: inventory.directory,\n directoryIdentity: inventory.directoryIdentity, sessionId: inventory.sessionId, compression: inventory.compression,\n header: inventory.header, anchor: inventory.anchor, lock: inventory.lock });\n}\n\n/** Exact file erasure; platform kernel leases share the audited JSONL writer namespace. */\nexport class NativeJsonlFiles {\n private readonly leases = new Map<string, HeldFileLease>();\n private constructor(private readonly provider: SessionPersistence & { config: { root: string; compression?: Encoding } }, readonly root: string, readonly compression: Encoding,\n private readonly rootIdentity: NodeIdentity) {}\n\n static async open(provider: unknown): Promise<NativeJsonlFiles | undefined> {\n if (!nativePlatformCandidate()) return;\n if (!(provider instanceof SessionPersistence) || provider.constructor.name !== 'JsonlSessionPersistence'\n || provider.name !== 'session-persistence-jsonl' || SESSION_FORMAT_VERSION !== 4) return;\n // The pinned SDK keeps the concrete class private. Verify its complete official npm\n // implementation instead of accepting a provider by a class-name match.\n if (createHash('sha256').update(Function.prototype.toString.call(nativeServiceInstance(provider).constructor)).digest('hex')\n !== 'bb0e12b14bd21adec58c51934f00014e482380102f09aa5e935536c57c0d6e1e') return;\n const internals = provider as unknown as { root?: unknown; compression?: unknown; config?: { root?: unknown; compression?: unknown } };\n const config = internals.config;\n if (typeof internals.root !== 'string' || !isAbsolute(internals.root)\n || (internals.compression !== 'none' && internals.compression !== 'zstd')\n || typeof config?.root !== 'string' || resolve(config.root) !== internals.root\n || (config.compression ?? 'zstd') !== internals.compression) return;\n const require = createRequire(import.meta.url);\n const metadata: unknown = require('@deepseek-ai/dsh-session-persistence-jsonl/package.json');\n if ((metadata as { version?: unknown }).version !== '0.2.1-rc.2') return;\n let root: string;\n try { root = await realpath(internals.root); }\n catch (error) { if (missing(error)) return; throw error; }\n if (process.platform === 'win32' && resolve(internals.root).toLowerCase() !== root.toLowerCase()) return;\n const identity = await lstat(root, { bigint: true });\n if (!identity.isDirectory()) refuse('jsonl/root-invalid', 'The configured root must be an existing directory.');\n if (identity.ino <= 0n || identity.birthtimeNs <= 0n) return;\n return new NativeJsonlFiles(provider as SessionPersistence & { config: { root: string; compression?: Encoding } }, root, internals.compression, nodeIdentity(identity));\n }\n\n async inspect(sessionId: string, header: SessionHeader): Promise<NativeJsonlInventory> {\n if (header.version !== SESSION_FORMAT_VERSION) refuse('jsonl/identity-invalid', 'Inspection requires the current logical Session header.');\n const identity = headerIdentity(header);\n if (sessionId !== identity.id) refuse('jsonl/identity-invalid', 'Requested session and header identities differ.');\n const directory = join(project(identity.cwd), segment(sessionId));\n const base = await this.directory(directory, sessionId, identity);\n const files = await this.rows(base.path, identity);\n const canonical = files.filter(row => row.kind === 'generation').sort((a, b) => a.formatVersion - b.formatVersion)[0];\n if (!canonical) refuse('jsonl/session-not-found', 'No identified committed generation exists.');\n const inventory = { schemaVersion: 1 as const, root: this.root, rootIdentity: this.rootIdentity,\n directory, directoryIdentity: base.identity, sessionId, compression: this.compression, header: identity,\n anchor: { resourceId: canonical.resourceId,\n identity: { dev: canonical.identity.dev, ino: canonical.identity.ino, birthtimeNs: canonical.identity.birthtimeNs }, header: identity },\n lock: await this.lockIdentity(base.path), files, revision: sha(JSON.stringify(files)) };\n await this.directory(directory, sessionId, identity);\n return nativeJsonlInventorySchema.parse(inventory);\n }\n\n /** Re-enumerate the entire scope without changing its original durable anchor. */\n async current(input: NativeJsonlInventory): Promise<NativeJsonlInventory> {\n const inventory = this.validate(input);\n const base = await this.assertDirectory(inventory);\n const files = await this.rows(base.path, inventory.header, inventory);\n const lock = await this.lockIdentity(base.path);\n if (!same(lock, inventory.lock)) refuse('jsonl/lock-changed', 'The stable coordination file changed.');\n return nativeJsonlInventorySchema.parse({ ...inventory, files, revision: sha(JSON.stringify(files)) });\n }\n\n async acquire(input: NativeJsonlInventory, options: { recovering?: boolean } = {}): Promise<{ release(): Promise<void> }> {\n const inventory = this.validate(input);\n const base = await this.assertDirectory(inventory);\n let fd: FileHandle | undefined;\n let unlock: (() => Promise<void>) | undefined;\n const record: HeldFileLease = { stamp: leaseStamp(inventory), closing: false, tail: Promise.resolve(), pending: new Set(),\n recovering: options.recovering === true };\n let held = false;\n try {\n if (process.platform === 'win32') {\n try { unlock = await acquireWindowsSemaphore(join(base.path, 'session.lock'), 'session'); }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'EBUSY') refuse('jsonl/writer-active', 'Another writer holds the session kernel lease.');\n throw error;\n }\n } else {\n fd = await this.openFile(join(base.path, 'session.lock'), 'write');\n if (!same(lockIdentity(await fd.stat({ bigint: true })), inventory.lock)) refuse('jsonl/lock-changed', 'The frozen stable lock changed.');\n try { await tryLockExclusive(fd.fd); }\n catch (error) {\n if (['EAGAIN', 'EWOULDBLOCK'].includes((error as NodeJS.ErrnoException).code ?? '')) refuse('jsonl/writer-active', 'Another writer holds the session lock.');\n throw error;\n }\n }\n await this.assertDirectory(inventory);\n if (!same(await this.lockIdentity(base.path), inventory.lock)) refuse('jsonl/lock-changed', 'The held lock no longer has its frozen namespace identity.');\n this.leases.set(inventory.directory, record);\n held = true;\n } finally {\n if (!held) {\n try { await unlock?.(); } finally { await fd?.close(); }\n }\n }\n let releasing: Promise<void> | undefined;\n return { release: () => releasing ??= (async () => {\n record.closing = true;\n await Promise.allSettled([...record.pending]);\n try { try { await unlock?.(); } finally { await fd?.close(); } }\n finally { if (this.leases.get(inventory.directory) === record) this.leases.delete(inventory.directory); }\n })() };\n }\n\n /** Caller must have persisted the exact retirement intent before this method. */\n async erase(input: NativeJsonlInventory, inputRow: NativeJsonlFileRow): Promise<void> {\n const inventory = this.validate(input); const row = fileRowSchema.parse(inputRow);\n const lease = this.leases.get(inventory.directory);\n if (!lease || lease.closing || lease.stamp !== leaseStamp(inventory)) refuse('jsonl/lease-required', 'Erasure requires the same stable namespace kernel lease.');\n if (!inventory.files.some(saved => same(saved, row))) refuse('jsonl/scope-changed', 'The resource is outside the frozen inventory.');\n const operation = lease.tail.then(() => this.eraseInner(inventory, row));\n lease.tail = operation.then(() => undefined, () => undefined);\n lease.pending.add(operation);\n try { await operation; } finally { lease.pending.delete(operation); }\n }\n\n private async eraseInner(inventory: NativeJsonlInventory, row: NativeJsonlFileRow): Promise<void> {\n const base = await this.assertDirectory(inventory);\n const names = await readdir(base.path);\n if (names.some(name => name !== 'session.lock' && !inventory.files.some(saved => saved.resourceId === name))) refuse('jsonl/scope-changed', 'A new or unknown file entered the frozen scope.');\n if (!same(await this.lockIdentity(base.path), inventory.lock)) refuse('jsonl/lock-changed', 'The held lock changed.');\n const absolute = join(base.path, row.resourceId);\n const target = resolve(absolute);\n if (target !== absolute || relative(base.path, target) !== row.resourceId) refuse('jsonl/path-invalid', 'The exact resource must be a direct child of its bound directory.');\n const remainder = await this.isWindowsErasureRemainder(inventory, row);\n try {\n if (!remainder) {\n const observed = await this.readRow(base.path, row.resourceId, inventory.header);\n if (!same(row, observed)) refuse('jsonl/resource-changed', 'The physical resource identity or bytes changed after confirmation.');\n }\n } catch (error) { if (missing(error)) { await this.syncDirectory(base.path); return; } throw error; }\n await this.assertDirectory(inventory);\n const latest = fileIdentity(await lstat(absolute, { bigint: true }));\n if (remainder ? latest.size !== '0' || !same(nodeIdentity(await lstat(absolute, { bigint: true })), nodeIdentityFromRow(row))\n : !same(latest, row.identity)) refuse('jsonl/resource-changed', 'The exact resource changed before erasure.');\n if (process.platform === 'win32') {\n // Node cannot fsync a Windows directory. Clear and sync the exact exclusive\n // file before removing its name, so an unlink rollback cannot restore logs.\n // Only a saved maintenance operation may resume an interrupted empty file.\n const handle = await this.openFile(absolute, 'write');\n try {\n const opened = fileIdentity(await handle.stat({ bigint: true }));\n if (remainder ? opened.size !== '0' || !same(nodeIdentity(await handle.stat({ bigint: true })), nodeIdentityFromRow(row))\n : !same(opened, row.identity)) refuse('jsonl/resource-changed', 'The opened erasure object differs from the frozen file.');\n await handle.truncate(0);\n await handle.sync();\n } finally { await handle.close(); }\n const cleared = await lstat(absolute, { bigint: true });\n if (!cleared.isFile() || cleared.nlink !== 1n || cleared.size !== 0n\n || !same(nodeIdentity(cleared), nodeIdentityFromRow(row))) refuse('jsonl/resource-changed', 'The cleared erasure object changed before unlink.');\n }\n await unlink(absolute);\n await this.syncDirectory(base.path);\n }\n\n private validate(input: NativeJsonlInventory): NativeJsonlInventory {\n const value = nativeJsonlInventorySchema.parse(input);\n if (value.root !== this.root || value.compression !== this.compression || !same(value.rootIdentity, this.rootIdentity)\n || value.sessionId !== value.header.id || value.directory !== join(project(value.header.cwd), segment(value.sessionId))\n || value.files.some(row => row.resourceId.includes(sep) || row.resourceId.includes('/') || row.resourceId.includes('\\\\')\n || row.resourceId === 'session.lock' || !same(row.header, value.header))) refuse('jsonl/binding-invalid', 'The inventory is not bound to this adapter and exact directory.');\n const windowsLock = 'kind' in value.lock;\n if ((process.platform === 'win32') !== windowsLock\n || ('kind' in value.lock && value.lock.name !== windowsSemaphoreName(join(this.root, value.directory, 'session.lock'), 'session'))) {\n refuse('jsonl/binding-invalid', 'The inventory kernel lease belongs to another platform or namespace.');\n }\n if (new Set(value.files.map(row => row.resourceId)).size !== value.files.length || value.revision !== sha(JSON.stringify(value.files))) refuse('jsonl/binding-invalid', 'The frozen resource inventory digest is invalid.');\n for (const row of value.files) {\n const classified = classify(row.resourceId);\n if (classified.kind !== row.kind || classified.version !== row.formatVersion || classified.compression !== row.compression\n || row.revision !== sha(JSON.stringify({ identity: row.identity, digest: row.digest, header: row.header }))) refuse('jsonl/binding-invalid', 'Frozen resource classification or digest changed.');\n }\n return value;\n }\n\n private async directory(directory: string, sessionId: string, header: HeaderIdentity) {\n const internals = this.provider as unknown as { root: string; compression: Encoding };\n if (await realpath(internals.root) !== this.root || internals.compression !== this.compression\n || (process.platform === 'win32' && resolve(internals.root).toLowerCase() !== this.root.toLowerCase())\n || resolve(this.provider.config.root) !== internals.root || (this.provider.config.compression ?? 'zstd') !== this.compression) refuse('jsonl/provider-changed', 'The provider root or encoding changed.');\n const root = await lstat(this.root, { bigint: true });\n if (!root.isDirectory() || !same(nodeIdentity(root), this.rootIdentity)) refuse('jsonl/root-changed', 'The configured root identity changed.');\n if (directory !== join(project(header.cwd), segment(sessionId))) refuse('jsonl/path-invalid', 'Directory does not match the stored identity.');\n const matches: string[] = [];\n for (const entry of await readdir(this.root, { withFileTypes: true })) {\n const projectPath = join(this.root, entry.name);\n if ([`${segment(sessionId)}.jsonl`, `${segment(sessionId)}.jsonl.zstd`].includes(entry.name)) refuse('jsonl/legacy-layout', 'Root-level flat session artifacts are not admitted.');\n if (entry.isSymbolicLink()) refuse('jsonl/unsafe-directory', 'Symlink project directories cannot certify a unique target.');\n if (!entry.isDirectory()) continue;\n for (const suffix of ['.jsonl', '.jsonl.zstd']) {\n try { await lstat(join(projectPath, segment(sessionId) + suffix)); refuse('jsonl/legacy-layout', 'Flat session artifacts are not admitted.'); }\n catch (error) { if (!missing(error)) throw error; }\n }\n const candidate = join(projectPath, segment(sessionId));\n try {\n const stat = await lstat(candidate, { bigint: true });\n if (!stat.isDirectory()) refuse('jsonl/unsafe-directory', 'Session directories must be direct regular directories.');\n matches.push(candidate);\n } catch (error) { if (!missing(error)) throw error; }\n }\n const path = join(this.root, directory);\n if (matches.length !== 1 || matches[0] !== path) refuse('jsonl/identity-ambiguous', 'The session directory is missing, misplaced, or duplicated across projects.');\n const actual = await realpath(path);\n const rel = relative(this.root, actual);\n if (actual !== path || rel !== directory || rel.startsWith(`..${sep}`) || isAbsolute(rel)) refuse('jsonl/unsafe-directory', 'The session directory leaves the configured root.');\n return { path, identity: nodeIdentity(await lstat(path, { bigint: true })) };\n }\n private async assertDirectory(inventory: NativeJsonlInventory) {\n const base = await this.directory(inventory.directory, inventory.sessionId, inventory.header);\n if (!same(base.identity, inventory.directoryIdentity)) refuse('jsonl/directory-changed', 'The bound directory incarnation changed.');\n return base;\n }\n private async lockIdentity(directory: string): Promise<z.infer<typeof nativeLockSchema>> {\n if (process.platform === 'win32') return { kind: 'win32-semaphore', name: windowsSemaphoreName(join(directory, 'session.lock'), 'session') };\n return lockIdentity(await lstat(join(directory, 'session.lock'), { bigint: true }));\n }\n private async isWindowsErasureRemainder(inventory: NativeJsonlInventory, row: NativeJsonlFileRow): Promise<boolean> {\n const lease = this.leases.get(inventory.directory);\n if (process.platform !== 'win32' || !lease?.recovering || lease.stamp !== leaseStamp(inventory)) return false;\n try {\n const handle = await this.openFile(join(this.root, inventory.directory, row.resourceId), 'read');\n try {\n const stat = await handle.stat({ bigint: true });\n return stat.size === 0n && same(nodeIdentity(stat), nodeIdentityFromRow(row));\n } finally { await handle.close(); }\n } catch (error) { if (missing(error)) return false; throw error; }\n }\n private async rows(directory: string, header: HeaderIdentity, frozen?: NativeJsonlInventory): Promise<NativeJsonlFileRow[]> {\n const names = (await readdir(directory)).sort();\n if (names.length > 4097) refuse('jsonl/scope-too-large', 'Session scope exceeds the bounded inventory.');\n const posix = process.platform !== 'win32';\n if (posix && !names.includes('session.lock')) refuse('jsonl/lock-missing', 'The existing stable writer lock is required.');\n const rows: NativeJsonlFileRow[] = [];\n for (const name of names) {\n if (posix && name === 'session.lock') continue;\n const original = frozen?.files.find(row => row.resourceId === name);\n if (frozen && original && await this.isWindowsErasureRemainder(frozen, original)) rows.push(original);\n else rows.push(await this.readRow(directory, name, header));\n }\n if (!same(names, (await readdir(directory)).sort())) refuse('jsonl/scope-changed', 'The directory changed while enumerating resources.');\n return rows;\n }\n private async readRow(directory: string, name: string, expected: HeaderIdentity): Promise<NativeJsonlFileRow> {\n const classified = classify(name);\n if (classified.compression !== this.compression) refuse('jsonl/encoding-mismatch', 'Mixed raw and Zstandard session generations are not admitted.');\n const path = join(directory, name);\n const before = fileIdentity(await lstat(path, { bigint: true }));\n const fd = await this.openFile(path, 'read');\n try {\n if (!same(before, fileIdentity(await fd.stat({ bigint: true })))) refuse('jsonl/resource-changed', 'Resource was replaced before reading.');\n const digest = createHash('sha256'); const chunks: Buffer[] = []; let headerBytes = 0;\n const buffer = Buffer.alloc(64 * 1024); let total = 0n;\n for (;;) {\n const { bytesRead } = await fd.read(buffer, 0, buffer.length, null);\n if (!bytesRead) break;\n total += BigInt(bytesRead); digest.update(buffer.subarray(0, bytesRead));\n if (headerBytes < HEADER_LIMIT) { const chunk = Buffer.from(buffer.subarray(0, Math.min(bytesRead, HEADER_LIMIT - headerBytes))); chunks.push(chunk); headerBytes += chunk.length; }\n }\n if (String(total) !== before.size || !same(before, fileIdentity(await fd.stat({ bigint: true })))\n || !same(before, fileIdentity(await lstat(path, { bigint: true })))) refuse('jsonl/resource-changed', 'The resource changed while hashing its exact bytes.');\n const header = decodeHeader(Buffer.concat(chunks), classified.compression, classified.version);\n if (!same(header, expected)) refuse('jsonl/identity-changed', 'A physical generation or staging header belongs to another lifecycle.');\n const value = { resourceId: name, kind: classified.kind, formatVersion: classified.version, compression: classified.compression,\n identity: before, digest: digest.digest('hex'), header };\n return fileRowSchema.parse({ ...value, revision: sha(JSON.stringify({ identity: value.identity, digest: value.digest, header })) });\n } finally { await fd.close(); }\n }\n private async openFile(path: string, access: 'read' | 'write'): Promise<FileHandle> {\n try { return await openRegularFile(path, access); }\n catch (error) {\n if (error instanceof RegularFileRefusal) refuse(error.code === 'platform/unsafe-file' ? 'jsonl/unsafe-file'\n : error.code === 'platform/identity-unavailable' ? 'jsonl/identity-unavailable' : 'jsonl/resource-changed', error.message);\n throw error;\n }\n }\n private async syncDirectory(directory: string) { await syncDirectory(directory); }\n}\n", "import type { SessionHeader } from '@deepseek-ai/dsh-session';\nimport { SessionId } from '@deepseek-ai/dsh-session';\nimport type { SessionHandle, SessionPersistence, SessionPersistenceSnapshot } from '@deepseek-ai/dsh-session-persistence';\nimport { NativeAdmission, NativeAdmissionError } from './native-retirement-admission.js';\n\ninterface PinnedJsonlInternals {\n tracker: { openHandles: Set<SessionHandle>; writers: Map<string, SessionHandle | null>; pending: Map<string, unknown> };\n migrationPreparations: Map<string, unknown>;\n coldLogMemo: Map<string, unknown>;\n [key: string]: unknown;\n}\n\nexport function nativeServiceInstance<T extends object>(value: T): T {\n return (Reflect.get(value, Symbol.for('cordis.original')) as T | undefined) ?? value;\n}\n\n/** Version-bound instance Adapter. It never patches prototypes or other Hosts. */\nexport class NativePersistenceAdapter {\n private readonly raw: PinnedJsonlInternals;\n private originalStat: SessionPersistence['stat'];\n private originalList: SessionPersistence['list'];\n private readonly restore: Array<() => void> = [];\n private detached = false;\n private active = true;\n private readonly managedHandles = new WeakSet<object>();\n constructor(private readonly provider: SessionPersistence, private readonly admission: NativeAdmission) {\n const raw = nativeServiceInstance(provider) as unknown as PinnedJsonlInternals;\n if (!(raw.tracker?.openHandles instanceof Set) || !(raw.tracker.writers instanceof Map)\n || !(raw.tracker.pending instanceof Map) || !(raw.migrationPreparations instanceof Map)\n || !(raw.coldLogMemo instanceof Map)) throw new Error('JSONL retirement runtime shape does not match the pinned provider.');\n this.raw = raw;\n this.originalStat = provider.stat.bind(provider);\n this.originalList = provider.list.bind(provider);\n }\n stat(id: string): Promise<SessionPersistenceSnapshot | undefined> { return this.originalStat(SessionId(id)); }\n list(): Promise<readonly SessionPersistenceSnapshot[]> { return this.originalList(); }\n busy(id: string): boolean {\n return this.raw.tracker.pending.has(id) || this.raw.tracker.writers.has(id)\n || [...this.raw.tracker.openHandles].some(handle => handle.id === id)\n || this.raw.migrationPreparations.size !== 0;\n }\n forget(id: string): void {\n if (this.busy(id)) throw new NativeAdmissionError('A persistence reference still owns this session.');\n this.raw.coldLogMemo.delete(id);\n }\n install(): () => Promise<void> {\n this.originalStat = this.provider.stat.bind(this.provider);\n this.originalList = this.provider.list.bind(this.provider);\n const route = (target: object, name: string, idFor: (args: unknown[]) => string, transform?: (value: unknown) => unknown, globalRead = false) => {\n target = nativeServiceInstance(target);\n const record = target as Record<string, unknown>;\n const original = record[name];\n if (typeof original !== 'function') throw new Error(`Missing pinned JSONL route ${name}.`);\n const own = Object.getOwnPropertyDescriptor(target, name);\n const adapter = this;\n const wrapper = function (this: object, ...args: unknown[]) {\n const receiver = this;\n if (adapter.detached) return Promise.reject(new NativeAdmissionError('This native guard belongs to a replaced retirement owner.'));\n const id = idFor(args);\n if (!adapter.active) {\n if (adapter.admission.isRetired(id)) return Promise.reject(new NativeAdmissionError('This session has a retirement tombstone.'));\n return Reflect.apply(original, receiver, args);\n }\n const run = () => adapter.admission.track(id, async () => {\n const value = await Reflect.apply(original, receiver, args);\n return transform ? transform(value) : value;\n });\n return globalRead ? adapter.admission.trackGlobal(run) : run();\n };\n Object.defineProperty(target, name, { configurable: true, writable: true, value: wrapper });\n this.restore.push(() => {\n if (record[name] !== wrapper) throw new Error(`JSONL route ${name} changed while retirement was installed.`);\n if (own) Object.defineProperty(target, name, own); else delete record[name];\n });\n };\n const headerId = (args: unknown[]) => String((args[0] as SessionHeader).id);\n route(this.provider, 'create', headerId, value => this.manage(value as SessionHandle));\n route(this.provider, 'open', args => String(args[0]), value => this.manage(value as SessionHandle), true);\n for (const method of ['persistBatch', 'persistHeader', 'truncateTornTail', 'acquireWriteLease']) {\n route(this.provider, method, headerId);\n }\n route(this.provider, 'readStoredLog', args => String(args[1]), undefined, true);\n route(this.provider, 'resolveCurrentLog', args => String(args[0]));\n // Metadata observations must omit admitted/retired lifecycles, including a\n // read which began before the durable fence and returns afterwards.\n const instance = nativeServiceInstance(this.provider);\n const rawStat = instance.stat;\n const rawList = instance.list;\n const adapter = this;\n instance.stat = async function (id, options) {\n if (adapter.detached) throw new NativeAdmissionError('This native observer belongs to a replaced retirement owner.');\n if (adapter.admission.isRetired(id)) return undefined;\n const value = await adapter.admission.trackGlobal(() => adapter.admission.track(id, () => rawStat.call(this, id, options)));\n return adapter.admission.isRetired(id) ? undefined : value;\n };\n instance.list = async function (options) {\n if (adapter.detached) throw new NativeAdmissionError('This native observer belongs to a replaced retirement owner.');\n return (await adapter.admission.trackGlobal(() => rawList.call(this, options))).filter(item => !adapter.admission.isRetired(item.header.id));\n };\n this.restore.push(() => { instance.stat = rawStat; instance.list = rawList; });\n return async () => {\n await this.admission.drain();\n this.active = false;\n // Retired IDs retain a narrow fail-closed guard after plugin withdrawal.\n // Other IDs continue to use the same original native instance routes.\n if (this.originalRetired()) return;\n for (const undo of [...this.restore].reverse()) undo();\n this.restore.length = 0;\n };\n }\n forceRestore(): void {\n this.detached = true; this.active = false;\n for (const undo of [...this.restore].reverse()) undo();\n this.restore.length = 0;\n }\n private originalRetired(): boolean {\n // Querying the native inventory cannot discover erased IDs; the controller\n // owns the durable tombstone snapshot independently of the closed domain.\n return this.admission.hasTombstones();\n }\n private manage(handle: SessionHandle): SessionHandle {\n if (this.managedHandles.has(handle)) return handle;\n this.managedHandles.add(handle);\n const methods = ['read', 'append', 'flush'] as const;\n for (const name of methods) {\n const original = handle[name];\n Object.defineProperty(handle, name, { configurable: true, writable: true,\n value: (...args: unknown[]) => !this.active && !this.admission.isRetired(handle.id)\n ? Reflect.apply(original, handle, args)\n : this.admission.track(handle.id, async () => Reflect.apply(original, handle, args)) });\n }\n return handle;\n }\n}\n", "import { AsyncLocalStorage } from 'node:async_hooks';\n\nexport class NativeAdmissionError extends Error { readonly code = 'native/session-busy'; }\n\n/** Shared per-target mutation gates and global header/migration read barriers. */\nexport class NativeAdmission {\n private readonly maintenance = new AsyncLocalStorage<{ id: string; active: boolean } | undefined>();\n private readonly acceptedFrames = new AsyncLocalStorage<symbol>();\n private readonly activeAcceptedFrames = new Set<symbol>();\n private readonly held = new Set<string>();\n private readonly released = new Map<string, { promise: Promise<void>; resolve(): void }>();\n private readonly pending = new Map<string, Set<Promise<unknown>>>();\n private readonly globalReads = new Set<Promise<unknown>>();\n private readonly retired = new Set<string>();\n private readonly candidates = new Set<string>();\n private closing = false;\n private failed = false;\n private ready = false;\n\n requiresRecovery(): boolean { return this.failed; }\n activate(): void { this.ready = true; }\n suspend(): void { this.failed = true; }\n beginClose(): void { this.closing = true; }\n isRetired(id: string): boolean { return this.retired.has(id) || (this.failed && this.candidates.has(id)); }\n hasTombstones(): boolean { return this.retired.size > 0 || (this.failed && this.candidates.size > 0); }\n markRetired(id: string): void { this.retired.add(id); }\n private isAcceptedFrame(): boolean { const frame = this.acceptedFrames.getStore(); return frame !== undefined && this.activeAcceptedFrames.has(frame); }\n assertAllowed(id: string): void {\n const maintenance = this.maintenance.getStore();\n if (maintenance?.active && maintenance.id === id && !(this.failed && this.candidates.has(id))) return;\n if (!this.ready || (this.closing && !this.isAcceptedFrame()) || (this.failed && this.candidates.has(id)) || this.retired.has(id)\n || (this.held.has(id) && !this.isAcceptedFrame())) {\n throw new NativeAdmissionError('The session is reserved for retirement or awaiting recovery.');\n }\n }\n bypass<T>(id: string, work: () => T): T {\n const token = { id, active: true };\n try {\n const value = this.maintenance.run(token, work);\n if (value && typeof (value as { then?: unknown }).then === 'function') {\n return Promise.resolve(value).finally(() => { token.active = false; }) as T;\n }\n token.active = false; return value;\n } catch (error) { token.active = false; throw error; }\n }\n withoutBypass<T>(work: () => T): T { return this.maintenance.run(undefined, work); }\n track<T>(id: string, work: () => Promise<T>): Promise<T> {\n this.assertAllowed(id);\n const tasks = this.pending.get(id) ?? new Set<Promise<unknown>>();\n this.pending.set(id, tasks);\n const frame = Symbol('native-accepted-operation');\n this.activeAcceptedFrames.add(frame);\n const task = this.acceptedFrames.run(frame, () => Promise.resolve().then(work));\n tasks.add(task);\n void task.finally(() => {\n this.activeAcceptedFrames.delete(frame);\n tasks.delete(task); if (!tasks.size) this.pending.delete(id);\n }).catch(() => {});\n return task;\n }\n async trackGlobal<T>(work: () => Promise<T>): Promise<T> {\n // Existing global reads may nest target reads; admission waits for the whole\n // accepted frame. New normal scans wait outside the drain set until release.\n if (this.closing && !this.isAcceptedFrame() && !this.maintenance.getStore()?.active) {\n throw new NativeAdmissionError('Native admission is closing.');\n }\n while (this.held.size && !this.maintenance.getStore()?.active && !this.isAcceptedFrame()) {\n await Promise.all([...this.released.values()].map(signal => signal.promise));\n }\n if (!this.ready || (this.closing && !this.isAcceptedFrame() && !this.maintenance.getStore()?.active)) {\n throw new NativeAdmissionError('Native admission is not accepting another request.');\n }\n const frame = Symbol('native-header-read');\n this.activeAcceptedFrames.add(frame);\n const task = this.acceptedFrames.run(frame, () => Promise.resolve().then(work));\n this.globalReads.add(task);\n try { return await task; }\n finally { this.activeAcceptedFrames.delete(frame); this.globalReads.delete(task); }\n }\n async drain(id?: string): Promise<void> {\n for (;;) {\n const tasks = id === undefined ? [...this.pending.values()].flatMap(set => [...set]) : [...(this.pending.get(id) ?? [])];\n tasks.push(...this.globalReads);\n if (!tasks.length) return;\n await Promise.allSettled(tasks);\n }\n }\n async acquire(id: string, recovery = false): Promise<() => void> {\n while (this.held.has(id)) await this.released.get(id)!.promise;\n if (this.failed || this.closing || !this.ready || (!recovery && this.retired.has(id))) {\n throw new NativeAdmissionError('The session cannot enter another retirement scope.');\n }\n let resolve!: () => void;\n const signal = { promise: new Promise<void>(done => { resolve = done; }), resolve: () => resolve() };\n this.held.add(id); this.released.set(id, signal); this.candidates.add(id);\n const release = () => {\n this.held.delete(id); this.released.delete(id); signal.resolve();\n };\n try { await this.drain(id); }\n catch (error) { release(); throw error; }\n let done = false;\n return () => { if (!done) { done = true; release(); } };\n }\n}\n", "import { AsyncLocalStorage } from 'node:async_hooks';\nimport { createHash } from 'node:crypto';\nimport { readdir, realpath, lstat, unlink } from 'node:fs/promises';\nimport type { FileHandle } from 'node:fs/promises';\nimport { openRegularFile, RegularFileRefusal, renameWindowsWriteThrough, syncDirectory } from './platform-files.js';\nimport { dirname, join, resolve } from 'node:path';\nimport type { Context } from '@deepseek-ai/cordis';\nimport { workspaceDomainState, workspaceRecord } from '@deepseek-ai/dsh-workspace';\nimport { z } from 'zod';\nimport type { LifecycleKey, RetirementRequest } from '../operations/retirement.js';\n\nexport interface NativeMetadataAdmission {\n assertAllowed(sessionId: string): void;\n track<T>(sessionId: string, work: () => Promise<T>): Promise<T>;\n trackGlobal<T>(work: () => Promise<T>): Promise<T>;\n isRetired(sessionId: string): boolean;\n bypass<T>(sessionId: string, work: () => T): T;\n withoutBypass<T>(work: () => T): T;\n}\nexport class NativeMetadataRefusal extends Error {\n constructor(readonly code: string, message: string) { super(message); this.name = 'NativeMetadataRefusal'; }\n}\nconst cachePhysicalIdentitySchema = z.object({\n dev: z.string().regex(/^\\d+$/), ino: z.string().regex(/^[1-9]\\d*$/), birthtimeNs: z.string().regex(/^[1-9]\\d*$/),\n}).strict();\nexport const nativeMetadataSnapshotSchema = z.object({\n schemaVersion: z.literal(1), sessionId: z.string().min(1),\n global: z.object({ archived: z.boolean(), pinned: z.boolean() }).strict(),\n workspaces: z.array(z.object({ workspaceId: z.string(), record: workspaceRecord }).strict()),\n cache: z.object({ present: z.boolean(), digest: z.string().nullable(), location: z.string().nullable(),\n documentDigest: z.string().nullable(), memoryDigest: z.string().nullable(), physicalIdentity: cachePhysicalIdentitySchema.optional() }).strict(),\n queryProvider: z.enum(['none', 'sqlite-0.2.0-rc.2', 'sqlite-memory-disabled-0.2.0-rc.2']), queryPath: z.string().nullable(),\n}).strict();\nexport type NativeMetadataSnapshot = z.infer<typeof nativeMetadataSnapshotSchema>;\n\ntype Method = (...args: any[]) => any;\ntype ObjectPort = Record<PropertyKey, any>;\nfunction object(value: unknown): ObjectPort | undefined {\n return value !== null && typeof value === 'object' ? value as ObjectPort : undefined;\n}\nfunction canonical(value: unknown): string {\n if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;\n if (value !== null && typeof value === 'object') return `{${Object.keys(value).sort().map(key => `${JSON.stringify(key)}:${canonical((value as Record<string, unknown>)[key])}`).join(',')}}`;\n return JSON.stringify(value);\n}\nfunction digest(value: unknown): string { return createHash('sha256').update(canonical(value)).digest('hex'); }\nconst methods = (port: ObjectPort, names: string[]) => names.every(name => typeof port[name] === 'function');\nconst windowsCacheStagePrefix = '.dsh-session-bin-cache-';\ntype CachePhysicalIdentity = NonNullable<NativeMetadataSnapshot['cache']['physicalIdentity']>;\nfunction physicalIdentity(stat: { dev: bigint; ino: bigint; birthtimeNs: bigint }): CachePhysicalIdentity {\n return { dev: String(stat.dev), ino: String(stat.ino), birthtimeNs: String(stat.birthtimeNs) };\n}\nfunction samePhysicalIdentity(left: CachePhysicalIdentity | undefined, right: CachePhysicalIdentity | undefined): boolean {\n return left !== undefined && right !== undefined && left.dev === right.dev && left.ino === right.ino\n && left.birthtimeNs === right.birthtimeNs;\n}\nfunction cacheStageBasename(snapshot: NativeMetadataSnapshot['cache'], expected: LifecycleKey, request: RetirementRequest): string {\n const value = digest({ schemaVersion: 1, expected, request, cache: snapshot });\n return `${windowsCacheStagePrefix}${value}.stage`;\n}\n\n/** Version-bound metadata participant. The composition verifies package/source\n * fingerprints before open; this adapter additionally checks concrete instance\n * shape. It neither removes files nor writes SQLite rows. */\nexport class NativeMetadataAdapter {\n private readonly targets = new Set<string>();\n private readonly retained = new Map<string, number>();\n private readonly followers = new Map<string, number>();\n private readonly followerStops = new Map<string, Set<() => Promise<void>>>();\n private readonly activationTarget = new AsyncLocalStorage<string>();\n private readonly apiHandles = new Map<string, ObjectPort>();\n private readonly operations = new Map<string, number>();\n private readonly queueTarget = new AsyncLocalStorage<string>();\n private readonly receivers = new AsyncLocalStorage<ObjectPort>();\n private readonly restores: Array<() => void> = [];\n private readonly guardedMethods: Array<{ port: ObjectPort; name: string; replacement: Method }> = [];\n private readonly guardedEntities = new WeakSet<object>();\n private installed = false;\n private disposed = false;\n private detached = false;\n private fallbackRetired = new Set<string>();\n private readonly queryConfiguration: { path: string; openAt: string } | undefined;\n private readonly queryProvider: NativeMetadataSnapshot['queryProvider'];\n private readonly cacheTable: ObjectPort | undefined;\n private readonly cacheDirectory: string | undefined;\n private readonly agents: ObjectPort | undefined;\n private moveCacheDocument = renameWindowsWriteThrough;\n private clearCacheStage = async (handle: FileHandle): Promise<void> => { await handle.truncate(0); await handle.sync(); };\n private removeCacheStage = unlink;\n\n private constructor(private readonly ctx: Context, private readonly admission: NativeMetadataAdmission,\n private readonly workspace: ObjectPort, private readonly sessions: ObjectPort,\n private readonly cache: ObjectPort | undefined, private readonly query: ObjectPort | undefined,\n private readonly controller: ObjectPort | undefined) {\n this.queryConfiguration = query ? { path: query.config.path, openAt: query.config.openAt } : undefined;\n this.queryProvider = !query ? 'none' : query.config.openAt === 'never' ? 'sqlite-memory-disabled-0.2.0-rc.2' : 'sqlite-0.2.0-rc.2';\n this.cacheTable = cache?.requireTable();\n this.cacheDirectory = this.cacheTable?.host.unit.dir;\n this.agents = controller ? NativeMetadataAdapter.get(ctx, 'agents') : undefined;\n }\n\n private static get(ctx: Context, name: string): ObjectPort | undefined {\n const value = object(ctx.get(name));\n return object(value?.[Symbol.for('cordis.original')] ?? value);\n }\n static async open(ctx: Context, admission: NativeMetadataAdmission): Promise<NativeMetadataAdapter | undefined> {\n const workspace = this.get(ctx, 'workspaceRegistry');\n const sessions = this.get(ctx, 'sessions');\n const cache = this.get(ctx, 'sessionProjectionCache');\n const query = this.get(ctx, 'sessionQuery');\n const controller = this.get(ctx, 'sessionController');\n if (!workspace || !sessions || workspace.constructor.name !== 'WorkspaceRegistry' || sessions.constructor.name !== 'SessionStore'\n || !methods(workspace, ['list', 'requireTable', 'requireState', 'setState', 'enqueueOperation', 'indexHeader', 'readSessionHeader'])\n || ![workspace.headers, workspace.sessionPaths, workspace.invalidSessionPaths].every(map => map instanceof Map)\n || !(workspace.missingSessionPaths instanceof Set)\n || !methods(sessions, ['get', 'prepare', 'enter', 'announce'])) return undefined;\n if (cache && (cache.constructor.name !== 'SessionProjectionCache' || !(cache.dirty instanceof Map)\n || !methods(cache, ['put', 'requireTable', 'write', 'coldSnapshot', 'hydratePrepared', 'cachedSnapshot', 'cachedPredecessorTitle']))) return undefined;\n if (cache) {\n const table = cache.requireTable(); const domain = ctx.storageDomain.get('session_projcache') as unknown as ObjectPort | undefined;\n if (table?.constructor.name !== 'KvTableImpl' || table.tableName !== 'sessions' || !(table.records instanceof Map)\n || table.host?.domainName !== 'session_projcache' || table.host.unit?.constructor.name !== 'PerRecordJsonUnit'\n || table.host.unit.descriptor?.name !== 'session_projcache' || table.host.unit.descriptor.version !== 7\n || table.host.unit.descriptor.layout !== 'per-record' || typeof table.host.unit.dir !== 'string'\n || !methods(table.host, ['enqueue', 'emitChanged', 'assertReadable'])\n || !methods(table.host.unit, ['loadAll', 'deleteRecord', 'tableDir']) || domain?.unit !== table.host.unit) return undefined;\n }\n if (query) {\n const enabled = ['startup', 'first-search'].includes(query.config?.openAt);\n const disabledMemory = query.config?.openAt === 'never' && query.config.path === ':memory:'\n && query._db === undefined && query._ready === undefined;\n if (query.constructor.name !== 'SqliteSessionQueryEngine' || (!enabled && !disabledMemory)\n || typeof query.config?.path !== 'string'\n || !methods(query, ['searchSessions', 'listSessions', 'observeSession', '_serialized']) || !(query._observations?.cache instanceof Map)\n || !methods(query._observations, ['read', 'store'])) return undefined;\n }\n if (controller && (controller.constructor.name !== 'SessionController' || !(controller.history?.closeFollowers instanceof Set)\n || !methods(controller.history, ['page', 'follow', 'sourceFor'])\n || controller.agents?.constructor.name !== 'ApiSessionAgentController'\n || !methods(controller.agents, ['resumeObserved', 'claim', 'createAgent'])\n || !methods(controller.listState ?? {}, ['summarizeCold'])\n || !methods(this.get(ctx, 'agents') ?? {}, ['create', 'resume', 'get']))) return undefined;\n return new NativeMetadataAdapter(ctx, admission, workspace, sessions, cache, query, controller);\n }\n private assert(id: string): void {\n this.targets.add(id);\n if (this.disposed) {\n if (this.fallbackRetired.has(id)) throw new NativeMetadataRefusal('native/retired', 'This retired session remains fenced after adapter withdrawal.');\n return;\n }\n this.admission.assertAllowed(id);\n }\n private tracked<T>(id: string, work: () => Promise<T>): Promise<T> {\n this.targets.add(id);\n if (this.disposed) { this.assert(id); return work(); }\n return this.admission.trackGlobal(() => this.admission.track(id, async () => {\n this.assert(id);\n this.increment(this.operations, id, 1);\n try { return await work(); }\n finally { this.increment(this.operations, id, -1); }\n }));\n }\n private increment(map: Map<string, number>, id: string, delta: number): void {\n const next = (map.get(id) ?? 0) + delta;\n if (next === 0) map.delete(id); else map.set(id, next);\n }\n private refuse(code: string, message: string): never { throw new NativeMetadataRefusal(code, message); }\n private assertInstances(): void {\n if (this.guardedMethods.some(({ port, name, replacement }) => port[name] !== replacement)) {\n this.refuse('native/guard-replaced', 'A native metadata admission guard was replaced.');\n }\n if (NativeMetadataAdapter.get(this.ctx, 'workspaceRegistry') !== this.workspace\n || NativeMetadataAdapter.get(this.ctx, 'sessions') !== this.sessions\n || NativeMetadataAdapter.get(this.ctx, 'sessionProjectionCache') !== this.cache\n || NativeMetadataAdapter.get(this.ctx, 'sessionQuery') !== this.query\n || NativeMetadataAdapter.get(this.ctx, 'sessionController') !== this.controller\n || (this.controller && NativeMetadataAdapter.get(this.ctx, 'agents') !== this.agents)\n || (this.cache && (this.cache.requireTable() !== this.cacheTable || this.cacheTable!.host.unit.dir !== this.cacheDirectory))\n || (this.query && (this.query.config.path !== this.queryConfiguration!.path\n || this.query.config.openAt !== this.queryConfiguration!.openAt))\n || (this.queryProvider === 'sqlite-memory-disabled-0.2.0-rc.2' && (this.query!._db !== undefined || this.query!._ready !== undefined))) {\n this.refuse('native/composition-changed', 'Native metadata service composition changed.');\n }\n }\n private assertCold(id: string): void {\n if (this.sessions.get(id) !== undefined || NativeMetadataAdapter.get(this.ctx, 'agents')?.get(id) !== undefined) {\n this.refuse('native/session-live', 'Native deletion currently accepts only cold sessions.');\n }\n const cached = this.query?._observations.cache.get(id);\n if (cached?.refs > 0 || (this.retained.get(id) ?? 0) > 0) this.refuse('native/query-retained', 'A retained query observation still owns this session.');\n if ((this.followers.get(id) ?? 0) > 0) this.refuse('native/follow-retained', 'A history follower still owns this session.');\n // Followers predating install have no target key in this SDK. Refuse rather\n // than closing unrelated streams or assuming that removed disposed them.\n const knownFollowers = [...this.followers.values()].reduce((sum, count) => sum + count, 0);\n if ((this.controller?.history.closeFollowers.size ?? 0) > knownFollowers) this.refuse('native/unknown-follow', 'A history follower predates native admission tracking.');\n if (this.cache && [...this.cache.dirty.keys()].some(session => session.id === id)) this.refuse('native/cache-dirty', 'Target cache write-behind is not quiescent.');\n }\n /** Explicit deletion preparation may unload an idle API-owned lifecycle.\n * No bare registry Agent, foreign handle, or unknown reader is disposed. */\n async releaseIdle(id: string): Promise<void> {\n this.assertInstances();\n const handle = this.apiHandles.get(id);\n if (!handle) return;\n const agent = handle.agent;\n const registry = this.agents!;\n if (registry.get(id) !== agent || this.sessions.get(id) !== agent.session) return;\n const activity = await this.admission.withoutBypass(() => this.ctx.waterfall('workspace/session-activity',\n { sessionId: id as never }, async () => []));\n // Inspect after the asynchronous activity query; dispose starts in this\n // same synchronous turn, before another activation can be admitted.\n if (activity.length || agent.constructor.name !== 'ReactLoopAgent' || agent.phase?.kind !== 'idle'\n || agent.status !== 'idle' || !Array.isArray(agent.inbox?.nextTurn)\n || !Array.isArray(agent.inbox?.nextStep) || agent.inbox.nextTurn.length || agent.inbox.nextStep.length) {\n this.refuse('native/session-active', 'Native deletion refuses active or queued work.');\n }\n if (!this.workspace.archivedSessionIds.includes(id)) this.refuse('native/not-archived', 'Only an archived target may be unloaded.');\n if (registry.get(id) !== agent || this.sessions.get(id) !== agent.session) this.refuse('native/session-live', 'The API lifecycle changed.');\n await this.admission.bypass(id, async () => {\n await handle.dispose();\n for (const stop of [...(this.followerStops.get(id) ?? [])]) await stop();\n // Disposal checkpoints projections asynchronously. Join its actual put\n // operations and the durable table queue before taking the cold snapshot.\n if (this.cache) await this.cache.requireTable().host.enqueue(async () => undefined);\n const summary = this.controller!.listState.summarizeCold({ header: agent.session.header });\n this.admission.withoutBypass(() => (this.ctx.emit as Method)('api-session/added', summary));\n });\n this.apiHandles.delete(id);\n }\n private async cacheView(table: ObjectPort, id: string, acceptedStage?: string): Promise<NativeMetadataSnapshot['cache']> {\n table.host.assertReadable();\n if (!/^[a-zA-Z0-9_-]+$/.test(id)) this.refuse('native/cache-key-unsupported', 'The pinned cache backend cannot own this record key.');\n const directory = resolve(table.host.unit.dir);\n // The pinned PerRecordJsonUnit bootstraps an empty tree from this retained\n // whole-unit file on every OS. Never certify erasure while that source exists.\n const legacyPath = join(dirname(directory), `${table.host.unit.descriptor.name}.json`);\n try {\n await lstat(legacyPath);\n this.refuse('native/cache-unclassified-resource', 'A legacy whole-unit cache could republish the retired target document.');\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n let location: string;\n try { location = await realpath(directory); }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error;\n location = join(await realpath(dirname(directory)), 'session_projcache');\n }\n const tableDirectory: string = table.host.unit.tableDir('sessions');\n let names: string[];\n try { names = await readdir(tableDirectory); }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; names = []; }\n if (names.some(name => name.startsWith(`${id}.json.bak.`) || /^\\.[a-f0-9-]+\\.tmp$/.test(name)\n || (name.startsWith(windowsCacheStagePrefix) && name !== acceptedStage))) {\n this.refuse('native/cache-unclassified-resource', 'A cache backup or unclassified staging document prevents complete target erasure.');\n }\n let documentDigest: string | null = null;\n let documentIdentity: CachePhysicalIdentity | undefined;\n const path = join(tableDirectory, `${id}.json`);\n try {\n let handle;\n try { handle = await openRegularFile(path, 'read'); }\n catch (error) {\n if (error instanceof RegularFileRefusal) this.refuse(error.code === 'platform/unsafe-file' ? 'native/cache-unsafe-document' : 'native/cache-document-changed', error.message);\n throw error;\n }\n try {\n const before = await handle.stat({ bigint: true });\n const bytes = await handle.readFile();\n const after = await handle.stat({ bigint: true });\n const current = await lstat(path, { bigint: true });\n if (!current.isFile() || before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size\n || before.birthtimeNs !== after.birthtimeNs || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs\n || after.nlink !== 1n || after.dev !== current.dev || after.ino !== current.ino\n || after.birthtimeNs !== current.birthtimeNs || after.size !== current.size\n || after.mtimeNs !== current.mtimeNs || after.ctimeNs !== current.ctimeNs) {\n this.refuse('native/cache-document-changed', 'The physical cache document changed while observing its bytes.');\n }\n documentDigest = createHash('sha256').update(bytes).digest('hex');\n if (process.platform === 'win32') documentIdentity = physicalIdentity(after);\n } finally { await handle.close(); }\n } catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n const memory = table.records.get(id);\n const memoryDigest = memory === undefined ? null : digest(memory);\n const present = documentDigest !== null || memoryDigest !== null;\n return { present, digest: present ? digest({ documentDigest, memoryDigest }) : null,\n location, documentDigest, memoryDigest, ...(documentIdentity ? { physicalIdentity: documentIdentity } : {}) };\n }\n private async openCacheDocument(path: string, access: 'read' | 'write'): Promise<FileHandle> {\n try { return await openRegularFile(path, access); }\n catch (error) {\n if (error instanceof RegularFileRefusal) this.refuse(error.code === 'platform/unsafe-file' ? 'native/cache-unsafe-document' : 'native/cache-document-changed', error.message);\n throw error;\n }\n }\n private async pathAbsent(path: string): Promise<boolean> {\n try { await lstat(path); return false; }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return true; throw error; }\n }\n private async frozenCacheBytes(handle: FileHandle, snapshot: NativeMetadataSnapshot['cache'], allowCleared: boolean): Promise<boolean> {\n const before = await handle.stat({ bigint: true });\n if (!before.isFile() || before.nlink !== 1n || !samePhysicalIdentity(physicalIdentity(before), snapshot.physicalIdentity)) return false;\n const bytes = await handle.readFile();\n const after = await handle.stat({ bigint: true });\n if (before.dev !== after.dev || before.ino !== after.ino || before.birthtimeNs !== after.birthtimeNs\n || before.size !== after.size || before.mtimeNs !== after.mtimeNs || before.ctimeNs !== after.ctimeNs || after.nlink !== 1n) return false;\n return allowCleared && bytes.length === 0\n || snapshot.documentDigest !== null && createHash('sha256').update(bytes).digest('hex') === snapshot.documentDigest;\n }\n private async eraseWindowsCache(snapshot: NativeMetadataSnapshot['cache'], id: string,\n expected: LifecycleKey, request: RetirementRequest, table: ObjectPort): Promise<boolean> {\n if (snapshot.documentDigest !== null && snapshot.physicalIdentity === undefined) return false;\n if (snapshot.documentDigest === null && snapshot.physicalIdentity !== undefined) return false;\n const tableDirectory: string = table.host.unit.tableDir('sessions');\n const originalPath = join(tableDirectory, `${id}.json`);\n const stageName = cacheStageBasename(snapshot, expected, request);\n const stagePath = join(tableDirectory, stageName);\n const current = await this.cacheView(table, id, stageName);\n if (current.location !== snapshot.location || (current.documentDigest !== null && current.documentDigest !== snapshot.documentDigest)\n || (current.memoryDigest !== null && current.memoryDigest !== snapshot.memoryDigest)\n || (!snapshot.present && current.present)) return false;\n let originalAbsent = await this.pathAbsent(originalPath);\n let stageAbsent = await this.pathAbsent(stagePath);\n if (!originalAbsent && !stageAbsent) return false;\n if (!originalAbsent) {\n if (snapshot.physicalIdentity === undefined || current.documentDigest !== snapshot.documentDigest\n || !samePhysicalIdentity(current.physicalIdentity, snapshot.physicalIdentity)) return false;\n let handle: FileHandle;\n try { handle = await this.openCacheDocument(originalPath, 'write'); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false; throw error; }\n try {\n if (!await this.frozenCacheBytes(handle, snapshot, false)) return false;\n try { await this.moveCacheDocument(originalPath, stagePath); }\n catch (error) {\n if (['EEXIST', 'EXDEV', 'ENOENT'].includes((error as NodeJS.ErrnoException).code ?? '')) return false;\n throw error;\n }\n } finally { await handle.close(); }\n originalAbsent = await this.pathAbsent(originalPath);\n stageAbsent = await this.pathAbsent(stagePath);\n if (!originalAbsent || stageAbsent) return false;\n }\n if (!stageAbsent) {\n let handle: FileHandle;\n try { handle = await this.openCacheDocument(stagePath, 'write'); }\n catch (error) { if ((error as NodeJS.ErrnoException).code === 'ENOENT') return false; throw error; }\n try {\n if (!await this.frozenCacheBytes(handle, snapshot, true)) return false;\n await this.clearCacheStage(handle);\n } finally { await handle.close(); }\n await this.removeCacheStage(stagePath);\n if (!await this.pathAbsent(stagePath)) return false;\n }\n if (!await this.pathAbsent(originalPath) || !await this.pathAbsent(stagePath)) return false;\n table.records.delete(id);\n this.admission.withoutBypass(() => table.host.emitChanged({ domain: table.host.domainName, table: 'sessions', key: id, operation: 'deleted' }));\n const final = await this.cacheView(table, id, stageName);\n return final.location === snapshot.location && !final.present && await this.pathAbsent(stagePath);\n }\n private async eraseCache(snapshot: NativeMetadataSnapshot['cache'], id: string,\n expected: LifecycleKey, request: RetirementRequest): Promise<boolean> {\n const table = this.cacheTable;\n if (!table) return !snapshot.present && snapshot.location === null;\n return table.host.enqueue(async () => {\n if (process.platform === 'win32') return this.eraseWindowsCache(snapshot, id, expected, request, table);\n const current = await this.cacheView(table, id);\n if (current.location !== snapshot.location || (current.documentDigest !== null && current.documentDigest !== snapshot.documentDigest)\n || (current.memoryDigest !== null && current.memoryDigest !== snapshot.memoryDigest)\n || (!snapshot.present && current.present)) return false;\n // KvTable.delete skips the medium when memory lacks the key. This owner\n // endpoint must remove the exact record document even after lost put ack.\n await table.host.unit.deleteRecord('sessions', id);\n const tableDirectory: string = table.host.unit.tableDir('sessions');\n try { await syncDirectory(tableDirectory); }\n catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }\n table.records.delete(id);\n this.admission.withoutBypass(() => table.host.emitChanged({ domain: table.host.domainName, table: 'sessions', key: id, operation: 'deleted' }));\n const final = await this.cacheView(table, id);\n return final.location === snapshot.location && !final.present;\n });\n }\n async capture(sessionId: string): Promise<NativeMetadataSnapshot> {\n return this.admission.bypass(sessionId, () => this.captureInner(sessionId));\n }\n private async captureInner(sessionId: string): Promise<NativeMetadataSnapshot> {\n this.targets.add(sessionId);\n this.assertInstances(); this.assertCold(sessionId);\n const activity = await this.admission.withoutBypass(() => this.ctx.waterfall('workspace/session-activity',\n { sessionId: sessionId as never }, async () => []));\n if (activity.length !== 0) this.refuse('native/session-active', 'Native deletion refuses active work.');\n this.assertCold(sessionId);\n const domain = this.ctx.storageDomain.get('workspace');\n if (!domain) throw new Error('Native workspace domain is unavailable.');\n const global = workspaceDomainState.parse(domain.global.get());\n if (!global.archivedSessionIds.some(id => id === sessionId)) this.refuse('native/not-archived', 'Native metadata preparation requires an archived session.');\n const workspaces: NativeMetadataSnapshot['workspaces'] = [];\n for (const [workspaceId, raw] of this.workspace.requireTable().entries()) {\n const record = workspaceRecord.parse(raw);\n if (!record.sessionIds.some(id => id === sessionId)) continue;\n if (record.sessionIds.some(id => id !== sessionId && this.workspace.sessionPaths.get(id) !== record.path\n && !this.workspace.missingSessionPaths.has(id))) {\n this.refuse('native/workspace-pruning-required', 'Target removal would prune an unrelated Workspace candidate.');\n }\n workspaces.push({ workspaceId, record });\n }\n const cache = this.cacheTable ? await this.cacheTable.host.enqueue(() => this.cacheView(this.cacheTable!, sessionId))\n : { present: false, digest: null, location: null, documentDigest: null, memoryDigest: null };\n return nativeMetadataSnapshotSchema.parse({ schemaVersion: 1, sessionId,\n global: { archived: global.archivedSessionIds.includes(sessionId as never), pinned: global.pinnedSessionIds.includes(sessionId as never) },\n workspaces, cache,\n queryProvider: this.queryProvider, queryPath: this.queryConfiguration?.path ?? null });\n }\n private wrap(port: ObjectPort, name: string, replace: (original: Method) => Method): void {\n const descriptor = Object.getOwnPropertyDescriptor(port, name);\n const original: Method = port[name];\n const adapter = this;\n const guarded = replace((...args: unknown[]) => Reflect.apply(original, adapter.receivers.getStore() ?? port, args));\n const replacement = function (this: ObjectPort, ...args: unknown[]) {\n if (adapter.detached) throw new NativeMetadataRefusal('native/stale-reference', 'Reacquire native methods after retirement adapter takeover.');\n return adapter.receivers.run(this, () => guarded(...args));\n };\n Object.defineProperty(port, name, { configurable: true, writable: true, value: replacement });\n this.guardedMethods.push({ port, name, replacement });\n this.restores.push(() => {\n if (port[name] !== replacement) throw new Error(`Native metadata guard ${name} was replaced before withdrawal.`);\n if (descriptor) Object.defineProperty(port, name, descriptor); else delete port[name];\n });\n }\n private guardEntity(entity: ObjectPort): void {\n if (this.guardedEntities.has(entity)) return;\n this.guardedEntities.add(entity);\n this.wrap(entity, 'attachSession', original => (id: string) => this.tracked(id, async () => {\n const result = await original(id); this.assert(id); return result;\n }));\n }\n private guardedObservation(id: string, observation: ObjectPort): ObjectPort {\n this.increment(this.retained, id, 1);\n let disposed = false;\n return new Proxy(observation, { get: (target, property) => {\n if (property === Symbol.dispose) return () => {\n if (disposed) return;\n disposed = true;\n try { target[Symbol.dispose](); }\n finally { this.increment(this.retained, id, -1); }\n };\n if (property === 'retain') return () => { this.assert(id); return this.guardedObservation(id, target.retain()); };\n if (property === 'events' || property === 'projections') this.assert(id);\n return Reflect.get(target, property, target);\n } });\n }\n async install(): Promise<() => Promise<void>> {\n if (this.installed) throw new Error('Native metadata adapter is already installed.');\n this.assertInstances(); this.installed = true;\n try {\n for (const name of ['workspace', ...(this.cache ? ['session_projcache'] : [])]) {\n const domain = this.ctx.storageDomain.get(name) as unknown as ObjectPort | undefined;\n if (!domain || domain.constructor.name !== 'DomainImpl' || !methods(domain, ['emitChanged'])) {\n throw new Error('Native metadata domain publication shape changed.');\n }\n this.wrap(domain, 'emitChanged', original => (change: unknown) => this.admission.withoutBypass(() => original(change)));\n }\n for (const name of ['archiveSession', 'unarchiveSession', 'pinSession', 'unpinSession']) {\n this.wrap(this.workspace, name, original => (id: string, ...args: unknown[]) => this.tracked(id,\n () => this.queueTarget.run(id, async () => original(id, ...args))));\n }\n this.wrap(this.workspace, 'enqueueOperation', original => (operation: () => Promise<unknown>) => {\n const id = this.queueTarget.getStore();\n return original(async () => { if (id !== undefined) this.assert(id); return operation(); });\n });\n this.wrap(this.workspace, 'setState', original => async (next: ObjectPort) => {\n const id = this.queueTarget.getStore();\n if (id !== undefined) this.assert(id);\n return original(next);\n });\n this.wrap(this.workspace, 'indexHeader', original => (header: ObjectPort) => this.tracked(header.id, async () => {\n const result = await original(header); this.assert(header.id); return result;\n }));\n this.wrap(this.workspace, 'readSessionHeader', original => (id: string) => this.tracked(id, async () => {\n const result = await original(id); this.assert(id); return result;\n }));\n for (const entity of this.workspace.list()) this.guardEntity(entity);\n for (const name of ['create', 'initializeDefault']) this.wrap(this.workspace, name, original => async (...args: unknown[]) => {\n const entity = await original(...args); if (entity) this.guardEntity(entity); return entity;\n });\n this.wrap(this.sessions, 'prepare', original => (id: string | undefined, ...args: unknown[]) => {\n if (id !== undefined) this.assert(id);\n const session = original(id, ...args); this.assert(session.id); return session;\n });\n for (const name of ['enter', 'announce']) this.wrap(this.sessions, name, original => (session: ObjectPort) => {\n this.assert(session.id); return original(session);\n });\n if (this.cache) {\n this.wrap(this.cache, 'put', original => (id: string, ...args: unknown[]) => this.tracked(id, async () => original(id, ...args)));\n for (const name of ['cachedSnapshot', 'cachedPredecessorTitle', 'coldSnapshot']) this.wrap(this.cache, name,\n original => (header: ObjectPort, ...args: unknown[]) => { this.assert(header.id); return original(header, ...args); });\n this.wrap(this.cache, 'hydratePrepared', original => (session: ObjectPort, ...args: unknown[]) => {\n this.assert(session.id); return original(session, ...args);\n });\n }\n if (this.query) {\n this.wrap(this.query, '_serialized', original => (signal: AbortSignal | undefined, operation: () => Promise<unknown>) =>\n this.admission.trackGlobal(async () => original(signal, operation)));\n this.wrap(this.query._observations, 'read', original => (id: string, ...args: unknown[]) => this.tracked(id, async () => {\n const observation = await original(id, ...args);\n try { this.assert(id); return this.guardedObservation(id, observation); }\n catch (error) { observation[Symbol.dispose](); throw error; }\n }));\n this.wrap(this.query._observations, 'store', original => (id: string, ...args: unknown[]) => { this.assert(id); return original(id, ...args); });\n for (const name of ['readSession', 'readTitle', 'readTitleSnapshot', 'listEvents', 'filterEvents', 'readSurface', 'traceSession']) {\n if (typeof this.query[name] === 'function') this.wrap(this.query, name, original => (id: string, ...args: unknown[]) =>\n this.tracked(id, async () => { const result = await original(id, ...args); this.assert(id); return result; }));\n }\n for (const name of ['searchEvents', 'readEvent', 'traceEvent']) if (typeof this.query[name] === 'function') {\n this.wrap(this.query, name, original => (request: ObjectPort, ...args: unknown[]) => this.tracked(request.sessionId,\n async () => { const result = await original(request, ...args); this.assert(request.sessionId); return result; }));\n }\n }\n if (this.controller) {\n const adapter = this;\n // API Session drops the returned AgentHandle after activation. Retain\n // that exact disposal capability only inside its matching target call.\n for (const name of ['resumeObserved', 'claim', 'createAgent']) {\n this.wrap(this.controller.agents, name, original => (id: string, ...args: unknown[]) =>\n this.tracked(id, () => this.activationTarget.run(id, async () => original(id, ...args))));\n }\n const agents = this.agents!;\n for (const name of ['create', 'resume']) {\n this.wrap(agents, name, original => (options: ObjectPort, ...args: unknown[]) => {\n const id = String(name === 'create' ? options.sessionId : options.resumeSessionId);\n return this.tracked(id, async () => {\n const handle = await original(options, ...args);\n if (this.activationTarget.getStore() === id && options.parentAgent === undefined\n && handle.agent.id === id && handle.agent.session.header.origin !== 'subagent'\n && typeof handle.dispose === 'function') this.apiHandles.set(id, handle);\n return handle;\n });\n });\n }\n this.restores.push((this.ctx.on as Method)('agent/disposed', ({ agent }: { agent: ObjectPort }) => {\n if (this.apiHandles.get(agent.id)?.agent === agent) this.apiHandles.delete(agent.id);\n }, { global: true }));\n this.wrap(this.controller.history, 'follow', original => function (request: ObjectPort, signal: AbortSignal) {\n const id = String(request.address.sessionId);\n adapter.assert(id);\n return (async function* () {\n adapter.assert(id); adapter.increment(adapter.followers, id, 1);\n const cancellation = new AbortController();\n const iterator = original(request, AbortSignal.any([signal, cancellation.signal]));\n const stops = adapter.followerStops.get(id) ?? new Set<() => Promise<void>>();\n adapter.followerStops.set(id, stops);\n let finished = false;\n const finish = () => {\n if (finished) return;\n finished = true;\n adapter.increment(adapter.followers, id, -1);\n stops.delete(stop); if (!stops.size) adapter.followerStops.delete(id);\n };\n const stop = async () => { cancellation.abort(); await iterator.return(); finish(); };\n stops.add(stop);\n try { for await (const frame of iterator) { adapter.assert(id); yield frame; } }\n finally { finish(); }\n })();\n });\n }\n } catch (error) {\n for (const restore of [...this.restores].reverse()) restore();\n this.restores.length = 0; this.installed = false; throw error;\n }\n let closing: Promise<void> | undefined;\n return () => closing ??= (async () => {\n this.fallbackRetired = new Set([...this.targets].filter(id => this.admission.isRetired(id)));\n this.disposed = true;\n this.apiHandles.clear();\n if (this.fallbackRetired.size === 0) {\n for (const restore of [...this.restores].reverse()) restore();\n this.restores.length = 0;\n }\n })();\n }\n /** The verified owner completes all asynchronous takeover work before this\n * synchronous restoration and installs its successor guards without yielding. */\n forceRestore(): void {\n if (this.restores.length && this.guardedMethods.some(({ port, name, replacement }) => port[name] !== replacement)) {\n throw new Error('Native metadata guards changed before trusted takeover.');\n }\n this.detached = true; this.disposed = true;\n for (const restore of [...this.restores].reverse()) restore();\n this.restores.length = 0; this.guardedMethods.length = 0; this.fallbackRetired.clear(); this.apiHandles.clear();\n }\n async converge(input: NativeMetadataSnapshot, expected: LifecycleKey, request: RetirementRequest): Promise<boolean> {\n const snapshot = nativeMetadataSnapshotSchema.parse(input);\n const id = snapshot.sessionId;\n this.targets.add(id); this.assertInstances();\n if (snapshot.queryProvider !== this.queryProvider\n || snapshot.queryPath !== (this.queryConfiguration?.path ?? null)) return false;\n if (id !== expected.sessionId || id !== request.expected.sessionId || expected.storeId !== request.expected.storeId\n || expected.lifecycleId !== request.expected.lifecycleId || !this.admission.isRetired(id)) {\n this.refuse('native/maintenance-binding-changed', 'Native convergence requires the exact durable retirement binding.');\n }\n if ((this.operations.get(id) ?? 0) > 0 || (this.retained.get(id) ?? 0) > 0 || (this.followers.get(id) ?? 0) > 0) return false;\n this.assertCold(id);\n return this.admission.bypass(id, async () => {\n if (!await this.eraseCache(snapshot.cache, id, expected, request)) return false;\n this.query?._observations.cache.delete(id);\n const frozenIds = new Set(snapshot.workspaces.map(item => item.workspaceId));\n const convergeWorkspace = async () => {\n for (const [workspaceId, raw] of this.workspace.requireTable().entries()) {\n const record = workspaceRecord.parse(raw);\n if (!record.sessionIds.some(sessionId => sessionId === id)) continue;\n if (!frozenIds.has(workspaceId) || record.sessionIds.some(other => other !== id\n && this.workspace.sessionPaths.get(other) !== record.path && !this.workspace.missingSessionPaths.has(other))) return false;\n const entity = this.workspace.get(workspaceId);\n if (!entity) throw new Error('Native Workspace account lost its runtime entity.');\n await entity.detachSession(id);\n }\n const state = workspaceDomainState.parse(this.workspace.requireState());\n if (state.archivedSessionIds.includes(id as never) || state.pinnedSessionIds.includes(id as never)) {\n await this.workspace.setState({ ...state,\n archivedSessionIds: state.archivedSessionIds.filter(other => other !== id),\n pinnedSessionIds: state.pinnedSessionIds.filter(other => other !== id) });\n }\n this.workspace.headers.delete(id); this.workspace.sessionPaths.delete(id); this.workspace.invalidSessionPaths.delete(id);\n this.workspace.missingSessionPaths.delete(id);\n return true;\n };\n if (!await this.workspace.enqueueOperation(convergeWorkspace)) return false;\n if (this.query) {\n if (this.queryProvider === 'sqlite-0.2.0-rc.2') {\n await this.query.searchSessions({ query: 'native-retirement-reconciliation', limit: 1 });\n }\n if ((await this.query.listSessions()).some((record: ObjectPort) => record.header.id === id)) return false;\n this.assertInstances();\n }\n // This is a presentation edge only. Resource completion comes from the\n // owner journal and query/Workspace confirmations above.\n this.admission.withoutBypass(() => (this.ctx.emit as Method)('api-session/removed', id));\n return true;\n });\n }\n}\n", "import { AsyncLocalStorage } from 'node:async_hooks';\nimport { z } from 'zod';\nimport {\n lifecycleEqual, lifecycleKeySchema, retirementAuthorizationSchema, retirementCapabilitiesSchema,\n retirementManifestSchema, retirementParticipantSchema, retirementRequestSchema,\n retirementResourceReceiptSchema, retirementResourceSchema, retirementStateSchema,\n} from '../operations/retirement.js';\nimport type {\n LifecycleKey, RetirementAuthorization, RetirementCapabilities, RetirementManifest, RetirementRequest, RetirementState,\n} from '../operations/retirement.js';\nimport { retirementOwnerRecordSchema } from '../operations/retirement-owner.js';\nimport type { RetirementOwnerRecord } from '../operations/retirement-owner.js';\nimport type { SessionRetirementOwnerV1 } from './retirement.js';\nimport { retirementManifestDigest } from './retirement.js';\nimport { sameRetirementCapabilities } from './retirement-owner-store.js';\nimport type { RetirementOwnerStore } from './retirement-owner-store.js';\n\nexport type RetirementResource = z.infer<typeof retirementResourceSchema>;\nexport type RetirementResourceReceipt = z.infer<typeof retirementResourceReceiptSchema>;\nexport interface RetirementOwnerGuards {\n /** Synchronous checks apply to retained handles and late writes as well as new opens. */\n assertCanUse(lifecycle: LifecycleKey): void;\n assertCanCreate(sessionId: string): void;\n}\nexport interface RetirementLifecycleScope {\n readonly lifecycle: LifecycleKey;\n current(): Promise<LifecycleKey | null>;\n activity(): Promise<string[]>;\n /** false acknowledges a known pending barrier; throws mean unknown outcome. */\n quiesce(request: RetirementRequest): Promise<boolean>;\n finalize(request: RetirementRequest): Promise<boolean>;\n release(): Promise<void>;\n}\nexport interface RetirementLifecyclePort {\n inspect(sessionId: string): Promise<LifecycleKey | null>;\n /** Teardown disables these routes/retained references, rather than making them unguarded. */\n bindGuards(guards: RetirementOwnerGuards): Promise<() => Promise<void>>;\n /** A saved record grants maintenance access to exactly its retired lifecycle.\n * Recovery must work after transcript removal/finalization without create/resume.\n * Every acquire must restore current runtime exclusion/reservations for all\n * participants; persisted quiescence acknowledgements are not live leases. */\n acquire(expected: LifecycleKey, maintenance: RetirementOwnerRecord | null): Promise<RetirementLifecycleScope>;\n}\nexport interface RetirementResourceParticipant {\n readonly identity: { id: string; version: string };\n bindGuards(guards: RetirementOwnerGuards): Promise<() => Promise<void>>;\n manifest(expected: LifecycleKey): Promise<RetirementResource[]>;\n fence(request: RetirementRequest): Promise<boolean>;\n quiesce(request: RetirementRequest): Promise<boolean>;\n /** Exact operation/resource/revision actions and all barriers are idempotent. */\n applyResource(request: RetirementRequest, resource: RetirementResource): Promise<RetirementResourceReceipt>;\n converge(request: RetirementRequest): Promise<boolean>;\n}\nexport interface RetirementOwnerCheckpoint {\n request: RetirementRequest;\n manifest: RetirementManifest;\n record: RetirementOwnerRecord | null;\n resource: RetirementResource | null;\n}\nexport interface RetirementOwnerCoordinatorOptions {\n capabilities: RetirementCapabilities;\n store: RetirementOwnerStore;\n lifecycle: RetirementLifecyclePort;\n participants: readonly RetirementResourceParticipant[];\n /** A bounded worker may pause only after a durable acknowledgement; the fence remains. */\n canAdvance?: (record: RetirementOwnerRecord) => boolean;\n checkpoint?: (name: string, context: RetirementOwnerCheckpoint) => Promise<void> | void;\n}\nexport class RetirementOwnerError extends Error {\n constructor(readonly code: string, message: string, options?: ErrorOptions) {\n super(message, options);\n this.name = 'RetirementOwnerError';\n }\n}\nfunction requestEqual(a: RetirementRequest, b: RetirementRequest): boolean {\n return a.operationId === b.operationId && lifecycleEqual(a.expected, b.expected)\n && a.bin.entryId === b.bin.entryId && a.bin.entryVersion === b.bin.entryVersion && a.manifestDigest === b.manifestDigest;\n}\nfunction refused(phase: RetirementState['phase']): boolean { return phase === 'rejected' || phase === 'conflict'; }\nfunction resourceOrder(a: RetirementResource, b: RetirementResource): number {\n const dispositions = ['release-reference', 'erase', 'retain-shared', 'retain-coordination'];\n const rank = dispositions.indexOf(a.disposition) - dispositions.indexOf(b.disposition);\n const first = JSON.stringify([a.ownerId, a.resourceId]);\n const second = JSON.stringify([b.ownerId, b.resourceId]);\n return rank || (first < second ? -1 : first > second ? 1 : 0);\n}\n\n/** Provider-neutral owner machinery. Ports must own the actual resources and\n * admission paths; this class supplies no native deletion or private-file adapter. */\nexport class RetirementOwnerCoordinator implements SessionRetirementOwnerV1 {\n private readonly descriptor: RetirementCapabilities;\n private readonly participants: readonly RetirementResourceParticipant[];\n private tail: Promise<unknown> = Promise.resolve();\n private failure: Error | undefined;\n private ready = false;\n private readonly frames = new AsyncLocalStorage<symbol>();\n private readonly activeFrames = new Set<symbol>();\n private readonly observations = new Set<Promise<unknown>>();\n private closing = false;\n private initializing: Promise<void> | undefined;\n private closePromise: Promise<void> | undefined;\n private readonly disposers: Array<() => Promise<void>> = [];\n private readonly expectedErrors = new WeakSet<Error>();\n readonly guards: RetirementOwnerGuards;\n\n constructor(private readonly options: RetirementOwnerCoordinatorOptions) {\n this.descriptor = retirementCapabilitiesSchema.parse(options.capabilities);\n this.participants = [...options.participants];\n this.verifyParticipants();\n this.validateJournal();\n this.guards = Object.freeze({\n assertCanUse: (input: LifecycleKey) => {\n this.requireReady();\n this.assertUnfenced(lifecycleKeySchema.parse(input));\n },\n assertCanCreate: (sessionId: string) => {\n this.requireReady();\n if (this.records().some(record => !refused(record.state.phase) && record.state.phase !== 'done'\n && record.state.request.expected.sessionId === sessionId)) {\n throw this.known('owner/session-fenced', 'An unfinished retirement fences this session identity.');\n }\n },\n });\n }\n initialize(): Promise<void> {\n if (this.closing) return Promise.reject(this.unavailable());\n return this.initializing ??= (async () => {\n try {\n await this.call('Owner journal capability binding', () => this.options.store.bindCapabilities(this.capabilitiesSnapshot()));\n this.validateJournal();\n const bind = async (work: () => Promise<() => Promise<void>>) => {\n const dispose = await this.call('Owner guard registration', work, false, false);\n if (typeof dispose !== 'function') throw new Error('Owner guard registration did not provide route teardown.');\n this.disposers.push(dispose);\n this.assertHealthy();\n if (this.closing) throw this.unavailable();\n };\n await bind(() => this.options.lifecycle.bindGuards(this.guards));\n for (const participant of this.participants) await bind(() => participant.bindGuards(this.guards));\n this.verifyParticipants();\n this.ready = true;\n } catch (error) {\n this.rememberFailure(error);\n this.ready = false;\n throw error;\n }\n })();\n }\n ownsCurrentMaintenanceFrame(): boolean {\n const frame = this.frames.getStore(); return frame !== undefined && this.activeFrames.has(frame);\n }\n isRefusal(error: unknown): boolean { return error instanceof Error && this.expectedErrors.has(error); }\n capabilities(): Promise<RetirementCapabilities> {\n this.requireControlReady();\n return Promise.resolve(this.capabilitiesSnapshot());\n }\n inspect(sessionId: string): Promise<LifecycleKey | null> {\n // Callback observations do not reenter the maintenance queue, but their\n // lifetime still belongs to close/drain and unknown-outcome handling.\n this.requireControlReady();\n const observation = (async () => {\n try {\n const input = await this.call('Owner lifecycle inspection', () => this.options.lifecycle.inspect(sessionId));\n this.requireControlReady();\n const value = input === null ? null : lifecycleKeySchema.parse(input);\n if (value && (value.sessionId !== sessionId || value.storeId !== this.descriptor.storeId)) throw new Error('Lifecycle observation belongs to another target/store.');\n return value;\n } catch (error) {\n if (!(error instanceof Error && this.expectedErrors.has(error))) this.rememberFailure(error);\n throw error;\n }\n })();\n this.observations.add(observation);\n void observation.finally(() => this.observations.delete(observation)).catch(() => {});\n return observation;\n }\n prepare(input: LifecycleKey): Promise<RetirementManifest> {\n const expected = lifecycleKeySchema.parse(input);\n return this.enqueue(async () => {\n this.assertMaintenanceUse(expected);\n return this.withScope(expected, null, async scope => {\n const current = await this.current(scope);\n if (!current || !lifecycleEqual(current, expected)) throw this.known('owner/lifecycle-changed', 'Lifecycle is not current.');\n this.assertMaintenanceUse(expected);\n return this.manifest(expected);\n });\n });\n }\n getOperation(operationId: string): Promise<RetirementState | null> {\n this.requireControlReady();\n const record = this.read(() => this.options.store.operation(operationId));\n return Promise.resolve(record ? retirementStateSchema.parse(record.state) : null);\n }\n getRecord(operationId: string): RetirementOwnerRecord | undefined {\n this.requireControlReady();\n const value = this.read(() => this.options.store.operation(operationId));\n return value ? retirementOwnerRecordSchema.parse(value) : undefined;\n }\n retire(input: RetirementRequest, authorize: () => Promise<RetirementAuthorization>, frozenInput?: RetirementManifest): Promise<RetirementState> {\n const request = retirementRequestSchema.parse(input);\n const frozen = frozenInput === undefined ? undefined : retirementManifestSchema.parse(frozenInput);\n return this.enqueue(async () => {\n const previous = this.read(() => this.options.store.operation(request.operationId));\n if (previous) {\n if (!requestEqual(previous.state.request, request)) throw this.known('owner/operation-id-reused', 'Operation identity already belongs to another request.');\n if (frozen) this.validateFrozen(request, frozen);\n return retirementStateSchema.parse(previous.state);\n }\n if (!frozen) throw this.known('owner/manifest-required', 'New retirement requires its full frozen confirmation manifest.');\n this.validateFrozen(request, frozen);\n this.assertMaintenanceUse(request.expected);\n return this.withScope(request.expected, null, async scope => {\n const current = await this.current(scope);\n if (!current || !lifecycleEqual(current, request.expected)) return this.refusal(request, frozen, 'conflict', 'lifecycle-changed');\n this.assertMaintenanceUse(request.expected);\n const fresh = await this.manifest(request.expected);\n if (retirementManifestDigest(fresh) !== request.manifestDigest) return this.refusal(request, frozen, 'conflict', 'resource-scope-changed');\n const activity = z.array(z.string().min(1).max(1024)).parse(await this.call('Owner activity inspection', () => scope.activity()));\n if (activity.length) return this.refusal(request, frozen, 'rejected', 'session-active');\n await this.checkpoint('before-authorize', this.context(request, frozen, null));\n const grant = retirementAuthorizationSchema.parse(await this.call('Host authorization callback', authorize));\n if (!grant.authorized) return this.refusal(request, frozen, 'rejected', grant.reason);\n const after = await this.current(scope);\n if (!after || !lifecycleEqual(after, request.expected)) return this.refusal(request, frozen, 'conflict', 'lifecycle-changed');\n if (retirementManifestDigest(await this.manifest(request.expected)) !== request.manifestDigest) return this.refusal(request, frozen, 'conflict', 'resource-scope-changed');\n const finalActivity = z.array(z.string().min(1).max(1024)).parse(await this.call('Owner final activity inspection', () => scope.activity()));\n if (finalActivity.length) return this.refusal(request, frozen, 'rejected', 'session-active');\n let record = this.emptyRecord({ schemaVersion: 1, request, manifest: frozen,\n authorizationId: grant.authorizationId, phase: 'fenced', reason: null, resources: [] });\n record = await this.save(record);\n await this.checkpoint('owner-fenced', this.contextFor(record));\n return this.advance(record, scope);\n });\n });\n }\n recover(operationId: string): Promise<RetirementState> {\n return this.enqueue(async () => {\n const record = this.read(() => this.options.store.operation(operationId));\n if (!record) throw this.known('owner/operation-not-found', 'Recovery requires a saved owner operation.');\n if (refused(record.state.phase) || record.state.phase === 'done') return retirementStateSchema.parse(record.state);\n return this.withScope(record.state.request.expected, record, scope => this.advance(record, scope));\n });\n }\n close(): Promise<void> {\n this.closing = true;\n return this.closePromise ??= (async () => {\n const errors: unknown[] = [];\n try { await this.initializing; } catch (error) { errors.push(error); }\n await this.tail;\n while (this.observations.size) await Promise.allSettled([...this.observations]);\n this.ready = false;\n for (const dispose of [...this.disposers].reverse()) try { await dispose(); } catch (error) { errors.push(error); }\n try { await this.options.store.close(); } catch (error) { errors.push(error); }\n if (errors.length) throw new AggregateError(errors, 'Retirement owner teardown failed.');\n })();\n }\n\n private async advance(input: RetirementOwnerRecord, scope: RetirementLifecycleScope): Promise<RetirementState> {\n let record = retirementOwnerRecordSchema.parse(input);\n const request = record.state.request;\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n if (record.state.phase === 'fenced') {\n for (const participant of this.participants) {\n const progress = record.participants.find(value => value.id === participant.identity.id)!;\n if (progress.fenced) continue;\n if (!await this.barrier('Participant fence', () => participant.fence(retirementRequestSchema.parse(request)))) {\n return this.pending(record, 'participant-fence-pending');\n }\n record = await this.save({ ...record, blockedReason: null,\n participants: record.participants.map(value => value.id === progress.id ? { ...value, fenced: true } : value) });\n await this.checkpoint('participant-fenced', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (!record.lifecycleQuiesced) {\n if (!await this.barrier('Lifecycle quiescence', () => scope.quiesce(retirementRequestSchema.parse(request)))) return this.pending(record, 'lifecycle-quiescence-pending');\n record = await this.save({ ...record, blockedReason: null, lifecycleQuiesced: true });\n await this.checkpoint('lifecycle-quiesced', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n for (const participant of this.participants) {\n const progress = record.participants.find(value => value.id === participant.identity.id)!;\n if (progress.quiesced) continue;\n if (!await this.barrier('Participant quiescence', () => participant.quiesce(retirementRequestSchema.parse(request)))) return this.pending(record, 'participant-quiescence-pending');\n record = await this.save({ ...record, blockedReason: null,\n participants: record.participants.map(value => value.id === progress.id ? { ...value, quiesced: true } : value) });\n await this.checkpoint('participant-quiesced', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n record = await this.save({ ...record, state: { ...record.state, phase: 'quiesced' }, blockedReason: null });\n await this.checkpoint('owner-quiesced', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (record.state.phase === 'quiesced') {\n // Draining can publish an already-admitted generation/write. Such a change\n // must not silently enlarge the confirmation, even under the durable fence.\n if (retirementManifestDigest(await this.manifest(request.expected)) !== request.manifestDigest) return this.pending(record, 'resource-scope-changed-after-quiescence');\n record = await this.save({ ...record, state: { ...record.state, phase: 'erasing' }, blockedReason: null });\n await this.checkpoint('owner-erasing', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (record.state.phase === 'erasing') {\n for (const resource of [...record.state.manifest.resources].sort(resourceOrder)) {\n const previous = record.state.resources.find(value => value.ownerId === resource.ownerId && value.resourceId === resource.resourceId);\n if (previous && previous.status !== 'failed') continue;\n const participant = this.participants.find(value => value.identity.id === resource.ownerId)!;\n const receipt = retirementResourceReceiptSchema.parse(await this.call('Participant resource action', () =>\n participant.applyResource(retirementRequestSchema.parse(request), retirementResourceSchema.parse(resource))));\n if (receipt.ownerId !== resource.ownerId || receipt.resourceId !== resource.resourceId) throw new Error('Participant receipt changed its frozen resource identity.');\n await this.checkpoint('resource-effect', this.contextFor(record, resource));\n record = await this.save({ ...record, blockedReason: receipt.status === 'failed' ? receipt.reason : null,\n state: { ...record.state, resources: [...record.state.resources.filter(value => value.ownerId !== resource.ownerId || value.resourceId !== resource.resourceId), receipt] } });\n await this.checkpoint('resource-receipt', this.contextFor(record, resource));\n if (receipt.status === 'failed' || !this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n record = await this.save({ ...record, state: { ...record.state, phase: 'converging' }, blockedReason: null });\n await this.checkpoint('owner-converging', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (record.state.phase === 'converging') {\n for (const participant of this.participants) {\n const progress = record.participants.find(value => value.id === participant.identity.id)!;\n if (progress.converged) continue;\n if (!await this.barrier('Participant convergence', () => participant.converge(retirementRequestSchema.parse(request)))) return this.pending(record, 'participant-convergence-pending');\n record = await this.save({ ...record, blockedReason: null,\n participants: record.participants.map(value => value.id === progress.id ? { ...value, converged: true } : value) });\n await this.checkpoint('participant-converged', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n if (!record.lifecycleFinalized) {\n if (!await this.barrier('Lifecycle finalization', () => scope.finalize(retirementRequestSchema.parse(request)))) return this.pending(record, 'lifecycle-finalization-pending');\n await this.checkpoint('lifecycle-finalize-effect', this.contextFor(record));\n record = await this.save({ ...record, blockedReason: null, lifecycleFinalized: true });\n await this.checkpoint('lifecycle-finalized', this.contextFor(record));\n if (!this.canAdvance(record)) return retirementStateSchema.parse(record.state);\n }\n record = await this.save({ ...record, state: { ...record.state, phase: 'done' }, blockedReason: null });\n await this.checkpoint('owner-done', this.contextFor(record));\n }\n return retirementStateSchema.parse(record.state);\n }\n private emptyRecord(state: RetirementState): RetirementOwnerRecord {\n return retirementOwnerRecordSchema.parse({ schemaVersion: 1, state,\n participants: this.descriptor.participants.map(value => ({ ...value, fenced: false, quiesced: false, converged: false })),\n lifecycleQuiesced: false, lifecycleFinalized: false, blockedReason: null });\n }\n private async refusal(request: RetirementRequest, manifest: RetirementManifest, phase: 'rejected' | 'conflict', reason: string): Promise<RetirementState> {\n const record = await this.save(this.emptyRecord({ schemaVersion: 1, request, manifest, authorizationId: null, phase, reason, resources: [] }));\n return retirementStateSchema.parse(record.state);\n }\n private async pending(record: RetirementOwnerRecord, reason: string): Promise<RetirementState> {\n return retirementStateSchema.parse((await this.save({ ...record, blockedReason: reason })).state);\n }\n private async manifest(expected: LifecycleKey): Promise<RetirementManifest> {\n const resources: RetirementResource[] = [];\n for (const participant of this.participants) {\n const owned = z.array(retirementResourceSchema).max(4096).parse(await this.call('Participant resource inventory', () => participant.manifest(lifecycleKeySchema.parse(expected))));\n if (owned.some(value => value.ownerId !== participant.identity.id)) throw new Error('Participant inventory claimed another owner.');\n resources.push(...owned);\n }\n return retirementManifestSchema.parse({ schemaVersion: 1, lifecycle: expected, capabilities: this.capabilitiesSnapshot(), resources });\n }\n private validateFrozen(request: RetirementRequest, manifest: RetirementManifest): void {\n if (!lifecycleEqual(request.expected, manifest.lifecycle) || !sameRetirementCapabilities(this.descriptor, manifest.capabilities)\n || retirementManifestDigest(manifest) !== request.manifestDigest) throw this.known('owner/manifest-mismatch', 'Frozen confirmation does not match the request and owner composition.');\n }\n private async current(scope: RetirementLifecycleScope): Promise<LifecycleKey | null> {\n const value = await this.call('Scoped lifecycle observation', () => scope.current());\n return value === null ? null : lifecycleKeySchema.parse(value);\n }\n private async withScope<T>(expected: LifecycleKey, record: RetirementOwnerRecord | null, work: (scope: RetirementLifecycleScope) => Promise<T>): Promise<T> {\n let scope: RetirementLifecycleScope | undefined;\n let result!: T;\n const errors: unknown[] = [];\n try {\n scope = await this.call('Lifecycle maintenance scope', () => this.options.lifecycle.acquire(\n lifecycleKeySchema.parse(expected), record ? retirementOwnerRecordSchema.parse(record) : null), false, false);\n this.assertHealthy();\n if (!lifecycleEqual(lifecycleKeySchema.parse(scope.lifecycle), expected)) throw new Error('Maintenance scope belongs to a different lifecycle.');\n result = await work(scope);\n } catch (error) {\n if (!(error instanceof Error && this.expectedErrors.has(error))) this.rememberFailure(error);\n errors.push(error);\n }\n const acquired = scope;\n if (acquired) try { await this.call('Lifecycle scope release', () => acquired.release(), true); } catch (error) { errors.push(error); }\n if (errors.length === 1) throw errors[0];\n if (errors.length) throw new AggregateError(errors, 'Retirement scope and release failed.');\n return result;\n }\n private context(request: RetirementRequest, manifest: RetirementManifest, record: RetirementOwnerRecord | null, resource: RetirementResource | null = null): RetirementOwnerCheckpoint {\n return { request: retirementRequestSchema.parse(request), manifest: retirementManifestSchema.parse(manifest),\n record: record ? retirementOwnerRecordSchema.parse(record) : null, resource: resource ? retirementResourceSchema.parse(resource) : null };\n }\n private contextFor(record: RetirementOwnerRecord, resource: RetirementResource | null = null): RetirementOwnerCheckpoint {\n return this.context(record.state.request, record.state.manifest, record, resource);\n }\n private async checkpoint(name: string, context: RetirementOwnerCheckpoint): Promise<void> {\n if (this.options.checkpoint) await this.call('Owner checkpoint observer', async () => { await this.options.checkpoint!(name, context); });\n }\n private canAdvance(record: RetirementOwnerRecord): boolean {\n this.assertHealthy();\n try {\n const allowed = this.options.canAdvance ? z.boolean().parse(this.options.canAdvance(retirementOwnerRecordSchema.parse(record))) : true;\n this.assertHealthy();\n return allowed;\n } catch (cause) { throw this.rememberFailure(new Error('Owner work budget failed.', { cause })); }\n }\n private async barrier(name: string, work: () => Promise<boolean>): Promise<boolean> { return z.boolean().parse(await this.call(name, work)); }\n private async save(input: RetirementOwnerRecord): Promise<RetirementOwnerRecord> {\n const record = retirementOwnerRecordSchema.parse(input);\n this.validateFrozen(record.state.request, record.state.manifest);\n await this.call('Owner journal write', () => this.options.store.putOperation(retirementOwnerRecordSchema.parse(record)));\n return retirementOwnerRecordSchema.parse(record);\n }\n private records(): RetirementOwnerRecord[] {\n return this.read(() => this.options.store.operations()).map(value => retirementOwnerRecordSchema.parse(value));\n }\n private validateJournal(): void {\n for (const record of this.records()) {\n this.validateFrozen(record.state.request, record.state.manifest);\n }\n }\n private verifyParticipants(): void {\n const actual = this.participants.map(value => retirementParticipantSchema.parse(value.identity));\n if (actual.length !== this.descriptor.participants.length || new Set(actual.map(value => value.id)).size !== actual.length\n || actual.some(value => !this.descriptor.participants.some(expected => expected.id === value.id && expected.version === value.version))) {\n throw new Error('Owner participant set/version does not match the fixed composition.');\n }\n }\n private capabilitiesSnapshot(): RetirementCapabilities { return retirementCapabilitiesSchema.parse(this.descriptor); }\n private known(code: string, message: string): RetirementOwnerError {\n const error = new RetirementOwnerError(code, message);\n this.expectedErrors.add(error);\n return error;\n }\n private unavailable(): RetirementOwnerError {\n return new RetirementOwnerError('owner/unavailable', 'Retirement owner is not ready, closing or requires a fresh journal reopen.', this.failure ? { cause: this.failure } : undefined);\n }\n private assertMaintenanceUse(expected: LifecycleKey): void {\n this.requireControlReady();\n this.assertUnfenced(expected);\n }\n private assertUnfenced(expected: LifecycleKey): void {\n if (expected.storeId !== this.descriptor.storeId) throw this.known('owner/store-mismatch', 'Lifecycle belongs to another store.');\n if (this.records().some(record => !refused(record.state.phase)\n && (record.state.phase === 'done' ? lifecycleEqual(record.state.request.expected, expected)\n : record.state.request.expected.sessionId === expected.sessionId))) {\n throw this.known('owner/lifecycle-retired', 'Lifecycle is fenced or permanently retired.');\n }\n }\n private rememberFailure(cause: unknown): Error {\n const error = cause instanceof Error ? cause : new Error('Retirement owner received an unexpected rejection.', { cause });\n this.failure ??= error;\n return error;\n }\n private requireControlReady(): void {\n const frame = this.frames.getStore();\n if (!this.ready || this.failure) throw this.unavailable();\n if (this.closing && (frame === undefined || !this.activeFrames.has(frame))) {\n throw this.known('owner/closing', 'Retirement owner control routes are closing.');\n }\n this.assertHealthy();\n }\n private requireReady(): void {\n if (!this.ready || this.closing || this.failure) throw this.unavailable();\n this.assertHealthy();\n }\n private read<T>(work: () => T): T {\n try { return work(); }\n catch (cause) { throw this.rememberFailure(new Error('Owner journal observation failed.', { cause })); }\n }\n private assertHealthy(): void {\n if (this.failure) throw this.unavailable();\n try { this.verifyParticipants(); } catch (error) { throw this.rememberFailure(error); }\n }\n private async call<T>(name: string, work: () => Promise<T>, cleanup = false, postcheck = true): Promise<T> {\n if (!cleanup) this.assertHealthy();\n try {\n const value = await work();\n if (!cleanup && postcheck) this.assertHealthy();\n return value;\n } catch (cause) {\n throw this.rememberFailure(new Error(`${name} failed.`, { cause }));\n }\n }\n private enqueue<T>(work: () => Promise<T>): Promise<T> {\n this.requireReady();\n const result = this.tail.then(() => {\n const frame = Symbol('retirement-maintenance');\n return this.frames.run(frame, async () => {\n if (this.failure) throw this.unavailable();\n this.assertHealthy();\n this.activeFrames.add(frame);\n try { return await work(); }\n catch (error) {\n if (!(error instanceof Error && this.expectedErrors.has(error))) throw this.rememberFailure(error);\n throw error;\n } finally { this.activeFrames.delete(frame); }\n });\n });\n this.tail = result.then(() => undefined, () => undefined);\n return result;\n }\n}\n", "import { z } from 'zod';\nimport { retirementCapabilitiesSchema, retirementParticipantSchema, retirementStateSchema } from './retirement.js';\n\nexport const retirementOwnerParticipantProgressSchema = retirementParticipantSchema.extend({\n fenced: z.boolean(), quiesced: z.boolean(), converged: z.boolean(),\n}).strict();\nexport const retirementOwnerRecordSchema = z.object({\n schemaVersion: z.literal(1), state: retirementStateSchema,\n participants: z.array(retirementOwnerParticipantProgressSchema).min(1).max(64),\n lifecycleQuiesced: z.boolean(), lifecycleFinalized: z.boolean(),\n blockedReason: z.string().min(1).max(1024).nullable(),\n}).strict().superRefine((record, ctx) => {\n const declared = record.state.manifest.capabilities.participants;\n const { phase } = record.state;\n const terminalRefusal = phase === 'rejected' || phase === 'conflict';\n if (record.participants.length !== declared.length\n || new Set(record.participants.map(participant => participant.id)).size !== record.participants.length\n || record.participants.some(participant => !declared.some(expected => expected.id === participant.id && expected.version === participant.version))) {\n ctx.addIssue({ code: 'custom', message: 'Owner progress must cover exactly the frozen participants.' });\n }\n if ((record.lifecycleQuiesced && record.participants.some(participant => !participant.fenced))\n || (!record.lifecycleQuiesced && record.participants.some(participant => participant.quiesced))) {\n ctx.addIssue({ code: 'custom', message: 'Lifecycle quiescence follows every fence and precedes participant quiescence.' });\n }\n if (record.participants.some(participant => (participant.quiesced && !participant.fenced)\n || (participant.converged && !participant.quiesced))) {\n ctx.addIssue({ code: 'custom', message: 'Participant confirmation stages must be ordered.' });\n }\n if (terminalRefusal && (record.lifecycleQuiesced || record.lifecycleFinalized\n || record.participants.some(participant => participant.fenced || participant.quiesced || participant.converged))) {\n ctx.addIssue({ code: 'custom', message: 'Refusal cannot acknowledge retirement effects.' });\n }\n if (['quiesced', 'erasing', 'converging', 'done'].includes(phase)\n && (!record.lifecycleQuiesced || record.participants.some(participant => !participant.fenced || !participant.quiesced))) {\n ctx.addIssue({ code: 'custom', message: 'Resource erasure requires every quiescence confirmation.' });\n }\n if ((record.lifecycleFinalized || record.participants.some(participant => participant.converged))\n && !['converging', 'done'].includes(phase)) {\n ctx.addIssue({ code: 'custom', message: 'Convergence cannot precede resource erasure.' });\n }\n if (['converging', 'done'].includes(phase) && (record.state.resources.length !== record.state.manifest.resources.length\n || record.state.resources.some(receipt => receipt.status === 'failed'))) {\n ctx.addIssue({ code: 'custom', message: 'Convergence requires every successful resource acknowledgement.' });\n }\n if (record.lifecycleFinalized && record.participants.some(participant => !participant.converged)) {\n ctx.addIssue({ code: 'custom', message: 'Lifecycle finalization requires every participant convergence acknowledgement.' });\n }\n if (phase === 'done' && (!record.lifecycleFinalized || record.participants.some(participant => !participant.converged))) {\n ctx.addIssue({ code: 'custom', message: 'Owner completion requires the lifecycle and every participant.' });\n }\n});\nexport const retirementOwnerGlobalSchema = z.object({\n schemaVersion: z.literal(1), capabilities: retirementCapabilitiesSchema.nullable(),\n}).strict();\nexport type RetirementOwnerRecord = z.infer<typeof retirementOwnerRecordSchema>;\nexport type RetirementOwnerParticipantProgress = z.infer<typeof retirementOwnerParticipantProgressSchema>;\n", "import { defineDomain, domainTable } from '@deepseek-ai/dsh-storage-domain';\nimport type { Domain } from '@deepseek-ai/dsh-storage-domain';\nimport { retirementCapabilitiesSchema } from '../operations/retirement.js';\nimport type { RetirementCapabilities } from '../operations/retirement.js';\nimport { retirementOwnerGlobalSchema, retirementOwnerRecordSchema } from '../operations/retirement-owner.js';\nimport type { RetirementOwnerRecord } from '../operations/retirement-owner.js';\nimport { retirementManifestDigest } from './retirement.js';\n\nexport const retirementOwnerDomainSpec = defineDomain({\n name: 'session_bin_retirement_owner', version: 1, layout: 'single',\n global: { schema: retirementOwnerGlobalSchema, initial: { schemaVersion: 1, capabilities: null } },\n tables: { operations: domainTable(retirementOwnerRecordSchema) },\n} as const);\nexport interface RetirementOwnerStore {\n bindCapabilities(capabilities: RetirementCapabilities): Promise<void>;\n operation(operationId: string): RetirementOwnerRecord | undefined;\n operations(): RetirementOwnerRecord[];\n putOperation(record: RetirementOwnerRecord): Promise<void>;\n close(): Promise<void>;\n}\nexport function sameRetirementCapabilities(a: RetirementCapabilities, b: RetirementCapabilities): boolean {\n const canonical = (value: RetirementCapabilities) => JSON.stringify([\n value.protocolVersion, value.ownerId, value.hostVersion, value.providerId, value.storeId,\n value.participants.map(participant => [participant.id, participant.version]).sort((first, second) =>\n JSON.stringify(first) < JSON.stringify(second) ? -1 : JSON.stringify(first) > JSON.stringify(second) ? 1 : 0),\n ]);\n return canonical(retirementCapabilitiesSchema.parse(a)) === canonical(retirementCapabilitiesSchema.parse(b));\n}\nfunction validateRecord(value: RetirementOwnerRecord): RetirementOwnerRecord {\n const record = retirementOwnerRecordSchema.parse(value);\n if (record.state.request.manifestDigest !== retirementManifestDigest(record.state.manifest)) {\n throw new Error('Owner record does not carry its original frozen manifest digest.');\n }\n return record;\n}\nfunction assertMonotonic(previous: RetirementOwnerRecord, next: RetirementOwnerRecord): void {\n const a = previous.state;\n const b = next.state;\n if (JSON.stringify(a.request) !== JSON.stringify(b.request)\n || retirementManifestDigest(a.manifest) !== retirementManifestDigest(b.manifest)\n || a.authorizationId !== b.authorizationId) throw new Error('Owner journal cannot change a saved request, manifest or grant.');\n const phases = ['fenced', 'quiesced', 'erasing', 'converging', 'done'];\n if (['rejected', 'conflict', 'done'].includes(a.phase)) {\n if (JSON.stringify(previous) !== JSON.stringify(next)) throw new Error('Terminal owner receipts are immutable.');\n return;\n }\n if (phases.indexOf(b.phase) < phases.indexOf(a.phase)) throw new Error('Owner journal phase cannot regress.');\n for (const part of previous.participants) {\n const current = next.participants.find(value => value.id === part.id && value.version === part.version);\n if (!current || (part.fenced && !current.fenced) || (part.quiesced && !current.quiesced) || (part.converged && !current.converged)) {\n throw new Error('Owner journal cannot lose a participant acknowledgement.');\n }\n }\n if ((previous.lifecycleQuiesced && !next.lifecycleQuiesced) || (previous.lifecycleFinalized && !next.lifecycleFinalized)) {\n throw new Error('Owner journal cannot lose lifecycle settlement.');\n }\n for (const receipt of a.resources.filter(value => value.status !== 'failed')) {\n const current = b.resources.find(value => value.ownerId === receipt.ownerId && value.resourceId === receipt.resourceId);\n if (!current || JSON.stringify(current) !== JSON.stringify(receipt)) throw new Error('Owner journal cannot lose a resource acknowledgement.');\n }\n}\n\n/** The caller must hold the composition's lifetime lease before opening this domain. */\nexport class DomainRetirementOwnerStore implements RetirementOwnerStore {\n constructor(private readonly domain: Domain<typeof retirementOwnerDomainSpec>) {\n const capabilities = domain.global.get().capabilities;\n for (const [key, value] of domain.table('operations').entries()) {\n const record = validateRecord(value);\n if (key !== record.state.request.operationId || !capabilities\n || !sameRetirementCapabilities(capabilities, record.state.manifest.capabilities)) {\n throw new Error('Owner operation has no matching journal identity and capability binding.');\n }\n }\n }\n async bindCapabilities(input: RetirementCapabilities): Promise<void> {\n const capabilities = retirementCapabilitiesSchema.parse(input);\n const previous = this.domain.global.get().capabilities;\n if (previous) {\n if (!sameRetirementCapabilities(previous, capabilities)) throw new Error('Owner journal belongs to a different composition.');\n return;\n }\n if (this.operations().length) throw new Error('Owner records cannot be adopted without their capability binding.');\n await this.domain.global.set({ schemaVersion: 1, capabilities });\n }\n operation(operationId: string): RetirementOwnerRecord | undefined {\n const value = this.domain.table('operations').get(operationId);\n return value === undefined ? undefined : validateRecord(value);\n }\n operations(): RetirementOwnerRecord[] {\n return [...this.domain.table('operations').entries()].map(([, value]) => validateRecord(value));\n }\n putOperation(input: RetirementOwnerRecord): Promise<void> {\n const record = validateRecord(input);\n const capabilities = this.domain.global.get().capabilities;\n if (!capabilities || !sameRetirementCapabilities(capabilities, record.state.manifest.capabilities)) {\n throw new Error('Cannot write an owner operation for an unbound composition.');\n }\n const previous = this.operation(record.state.request.operationId);\n if (previous) assertMonotonic(previous, record);\n return this.domain.table('operations').put(record.state.request.operationId, record);\n }\n close(): Promise<void> { return this.domain.close(); }\n}\n", "import { Context } from '@deepseek-ai/cordis';\nimport { RemoteError, TypertRemoteService } from '@deepseek-ai/dsh-typert-protocol';\nimport type { RemoteStream } from '@deepseek-ai/dsh-typert-protocol';\nimport type {} from '../index.js';\nimport { SessionBinError } from './module.js';\nimport { entriesSchema, optionalOperationSchema, sessionBinHostContribution, sessionBinRemoteNamespace,\n sessionBinRemoteServiceKey, snapshotSchema, binRemoteErrorCodes } from '../remote/contracts.js';\nimport type { BinRemoteErrorCode, BinSnapshot } from '../remote/contracts.js';\nimport { archivePlanSchema as planSchema, archiveResultSchema as resultSchema } from '../operations/archive.js';\nimport type { ArchiveOperation, ArchivePlan as BinPlan, ArchiveResult as BinResult, ArchivePrepareRequest as PrepareRequest } from '../operations/archive.js';\nimport type { BinOperation } from '../operations/schema.js';\nimport { nativePurgePlanSchema, optionalPurgeOperationSchema, purgeOperationsSchema } from '../remote/contracts.js';\nimport { purgeResultSchema } from '../operations/retirement.js';\nimport type { PreparePurgeRequest, PurgePlan, PurgeResult, PurgeOperation } from '../operations/retirement.js';\n\nconst knownRemoteCodes = new Set<string>(binRemoteErrorCodes);\nfunction isBinRemoteCode(code: string): code is BinRemoteErrorCode { return knownRemoteCodes.has(code); }\nfunction wakeGate(): { promise: Promise<void>; resolve: () => void } {\n let finish!: () => void;\n const promise = new Promise<void>(resolve => { finish = resolve; });\n return { promise, resolve: finish };\n}\n\n/** Public strict Typert adapter; all native mutation stays in the existing Module. */\nexport class SessionBinRemote extends TypertRemoteService {\n static inject = ['sessionBin', 'typert'];\n private readonly lifetime = new AbortController();\n private readonly streams = new Set<AsyncIterableIterator<BinSnapshot>>();\n private closed = false;\n\n constructor(ctx: Context) {\n super(ctx, sessionBinRemoteServiceKey, { namespace: sessionBinRemoteNamespace });\n ctx.typert.register(sessionBinHostContribution);\n ctx.effect(() => async () => {\n this.closed = true;\n this.lifetime.abort();\n const streams = [...this.streams];\n this.streams.clear();\n // Await generator cleanup even when a consumer paused after a snapshot.\n await Promise.allSettled(streams.map(stream => stream.return?.()));\n }, 'session-bin.remote.dispose');\n }\n\n prepare(request: PrepareRequest, signal: AbortSignal): Promise<BinPlan> {\n return this.call(signal, async () => planSchema.parse(await this.ctx.sessionBin.prepare(request)));\n }\n execute(plan: BinPlan, signal: AbortSignal): Promise<BinResult> {\n // Cancellation fences admission. An accepted operation is awaited through\n // durability, so a dropped reply can be recovered by its operation identity.\n return this.call(signal, async () => resultSchema.parse(await this.ctx.sessionBin.execute(plan)));\n }\n list(signal: AbortSignal) {\n return this.call(signal, async () => entriesSchema.parse(await this.ctx.sessionBin.list()));\n }\n getOperation(operationId: string, signal: AbortSignal): Promise<ArchiveOperation | BinOperation | null> {\n return this.call(signal, async () => optionalOperationSchema.parse(await this.ctx.sessionBin.getOperation(operationId) ?? null));\n }\n\n preparePurge(request: PreparePurgeRequest, signal: AbortSignal): Promise<PurgePlan> {\n return this.call(signal, async () => nativePurgePlanSchema.parse(await this.ctx.sessionBin.preparePurge(request)));\n }\n executePurge(input: PurgePlan, signal: AbortSignal): Promise<PurgeResult> {\n const plan = nativePurgePlanSchema.parse(input);\n return this.call(signal, async () => purgeResultSchema.parse(await this.ctx.sessionBin.executePurge(plan)));\n }\n getPurgeOperation(operationId: string, signal: AbortSignal): Promise<PurgeOperation | null> {\n return this.call(signal, async () => optionalPurgeOperationSchema.parse(await this.ctx.sessionBin.getPurgeOperation(operationId) ?? null));\n }\n\n purgeOperations(signal: AbortSignal): Promise<PurgeOperation[]> {\n return this.call(signal, async () => purgeOperationsSchema.parse(await this.ctx.sessionBin.purgeOperations()));\n }\n\n follow(signal: AbortSignal): RemoteStream<BinSnapshot> {\n const cancelled = new AbortController();\n const lifetime = AbortSignal.any([signal, this.lifetime.signal, cancelled.signal]);\n const source = this.snapshots(lifetime);\n const streams = this.streams;\n const iterator: AsyncIterableIterator<BinSnapshot> = {\n [Symbol.asyncIterator]() { return this; },\n async next() {\n try {\n const next = await source.next();\n if (next.done) streams.delete(iterator);\n return next;\n } catch (error) { streams.delete(iterator); throw error; }\n },\n async return() {\n cancelled.abort();\n streams.delete(iterator);\n return source.return();\n },\n async throw(error: unknown) {\n cancelled.abort(error);\n streams.delete(iterator);\n return source.throw(error);\n },\n };\n streams.add(iterator);\n return iterator;\n }\n\n private async *snapshots(signal: AbortSignal): AsyncGenerator<BinSnapshot, void, unknown> {\n if (signal.aborted || this.closed) return;\n let dirty = true;\n let deletionDirty = false;\n let wake = wakeGate();\n const changed = () => { dirty = true; wake.resolve(); };\n // Subscribe before the first list. Every generation receives a full baseline;\n // notifications are coalesced into replacement snapshots, with no replay cursor.\n const off = this.ctx.root.on('domain/changed', change => {\n if (change.domain === 'session_bin_purge') { deletionDirty = true; changed(); }\n else if (change.domain === 'session_archive' || change.domain === 'workspace') changed();\n });\n signal.addEventListener('abort', changed, { once: true });\n let previous: string | undefined;\n try {\n while (!signal.aborted && !this.closed) {\n if (dirty) {\n dirty = false;\n const snapshot = await this.call(signal, async () => snapshotSchema.parse({\n schemaVersion: 2, entries: await this.ctx.sessionBin.list(),\n }));\n if (signal.aborted || this.closed) return;\n const signature = JSON.stringify(snapshot);\n if (signature !== previous || deletionDirty) {\n previous = signature;\n deletionDirty = false;\n yield snapshot;\n }\n continue;\n }\n await wake.promise;\n wake = wakeGate();\n }\n } finally {\n off();\n signal.removeEventListener('abort', changed);\n }\n }\n\n private async call<Result>(signal: AbortSignal, operation: () => Promise<Result>): Promise<Result> {\n if (this.closed) throw new RemoteError('bin/closed', 'Session Bin Remote is unloading.', {});\n signal.throwIfAborted();\n try { return await operation(); }\n catch (error) {\n if (error instanceof SessionBinError && isBinRemoteCode(error.code)) {\n throw new RemoteError(error.code, error.message, {}, { cause: error });\n }\n throw error;\n }\n }\n}\n\n/** The parent Host calls this only after its SessionBin Module has initialized. */\nexport async function installSessionBinRemote(ctx: Context): Promise<() => Promise<void>> {\n const fiber = ctx.plugin(SessionBinRemote);\n try { await fiber; }\n catch (error) { await fiber.dispose(); throw error; }\n return async () => { await fiber.dispose(); };\n}\n", "import { z } from 'zod';\nimport type { InvocationDescriptor, RemoteResult, RemoteStreamHandle, TypertCodec, TypertRemoteContribution } from '@deepseek-ai/dsh-typert-protocol';\nimport type { TypertContribution } from '@deepseek-ai/dsh-typert-registry';\nimport { operationSchema } from '../operations/schema.js';\nimport type { BinOperation } from '../operations/schema.js';\nimport { archiveEntrySchema, archiveOperationSchema, archivePlanSchema, archivePrepareRequestSchema, archiveResultSchema } from '../operations/archive.js';\nimport type { ArchiveEntry, ArchiveOperation, ArchivePlan, ArchivePrepareRequest, ArchiveResult } from '../operations/archive.js';\nimport { preparePurgeRequestSchema, purgePlanSchema, purgeResultSchema, purgeOperationSchema } from '../operations/retirement.js';\nimport type { PreparePurgeRequest, PurgePlan, PurgeResult, PurgeOperation } from '../operations/retirement.js';\n\nexport const sessionBinRemoteNamespace = 'sessionBin';\nexport const sessionBinRemoteServiceKey = 'sessionBinRemote';\nexport const snapshotSchema = z.object({ schemaVersion: z.literal(2), entries: z.array(archiveEntrySchema) }).strict();\nexport type BinSnapshot = z.infer<typeof snapshotSchema>;\nexport type ArchiveSnapshot = BinSnapshot;\nexport const operationIdSchema = z.string().min(1).max(1024);\nexport const entriesSchema = z.array(archiveEntrySchema);\nexport const optionalOperationSchema = z.union([archiveOperationSchema, operationSchema]).nullable();\nexport const nativePurgePlanSchema = purgePlanSchema.refine(plan => plan.schemaVersion === 2, 'Only native archive v2 deletion plans may be executed remotely.');\nexport const optionalPurgeOperationSchema = purgeOperationSchema.nullable();\nexport const purgeOperationsSchema = z.array(purgeOperationSchema);\n\n/** Browser-safe contract. Native archive is the sole entry path. */\nexport interface SessionBinRemoteApi {\n prepare(request: ArchivePrepareRequest, signal?: AbortSignal): Promise<RemoteResult<ArchivePlan>>;\n execute(plan: ArchivePlan, signal?: AbortSignal): Promise<RemoteResult<ArchiveResult>>;\n list(signal?: AbortSignal): Promise<RemoteResult<ArchiveEntry[]>>;\n getOperation(operationId: string, signal?: AbortSignal): Promise<RemoteResult<ArchiveOperation | BinOperation | null>>;\n preparePurge(request: PreparePurgeRequest, signal?: AbortSignal): Promise<RemoteResult<PurgePlan>>;\n executePurge(plan: PurgePlan, signal?: AbortSignal): Promise<RemoteResult<PurgeResult>>;\n getPurgeOperation(operationId: string, signal?: AbortSignal): Promise<RemoteResult<PurgeOperation | null>>;\n purgeOperations(signal?: AbortSignal): Promise<RemoteResult<PurgeOperation[]>>;\n follow(signal?: AbortSignal): RemoteStreamHandle<BinSnapshot, never>;\n}\nexport const binRemoteErrorCodes = ['bin/closed', 'bin/recovery-required', 'bin/not-ready', 'bin/operation-id-reused'] as const;\nexport type BinRemoteErrorCode = typeof binRemoteErrorCodes[number];\ndeclare module '@deepseek-ai/dsh-typert-protocol' {\n interface RemoteErrorDetailsMap {\n 'bin/closed': {};\n 'bin/recovery-required': {};\n 'bin/not-ready': {};\n 'bin/operation-id-reused': {};\n }\n}\nfunction strictCodec<Output>(name: string, schema: z.ZodType<Output>): TypertCodec {\n return { mode: 'strict', typeSymbol: `@takboo/dsh-session-bin#${name}`, create: () => schema,\n encode: value => schema.parse(value), decode: value => schema.parse(value) };\n}\nconst codecs = {\n request: strictCodec('ArchivePrepareRequest', archivePrepareRequestSchema),\n plan: strictCodec('ArchivePlan', archivePlanSchema),\n result: strictCodec('ArchiveResult', archiveResultSchema),\n entries: strictCodec('ArchiveEntries', entriesSchema),\n operationId: strictCodec('OperationId', operationIdSchema),\n operation: strictCodec('OptionalArchiveOperation', optionalOperationSchema),\n purgeRequest: strictCodec('PreparePurgeRequest', preparePurgeRequestSchema),\n purgePlan: strictCodec('NativePurgePlan', nativePurgePlanSchema),\n purgeResult: strictCodec('PurgeResult', purgeResultSchema),\n purgeOperation: strictCodec('OptionalPurgeOperation', optionalPurgeOperationSchema),\n purgeOperations: strictCodec('PurgeOperations', purgeOperationsSchema),\n snapshot: strictCodec('ArchiveSnapshot', snapshotSchema),\n};\nfunction descriptor(method: string, parameters: InvocationDescriptor['parameters'], result: TypertCodec,\n mode?: 'stream'): InvocationDescriptor {\n return { id: `@takboo/dsh-session-bin#sessionBin/${method}`, service: sessionBinRemoteServiceKey,\n namespace: sessionBinRemoteNamespace, method, invocation: { kind: 'direct' }, parameters, result,\n cancellation: { parameter: 'signal' }, ...(mode === undefined ? {} : { mode }) };\n}\nconst descriptors: readonly InvocationDescriptor[] = [\n descriptor('prepare', [{ name: 'request', wire: 'request', source: 'json', codec: codecs.request }], codecs.plan),\n descriptor('execute', [{ name: 'plan', wire: 'plan', source: 'json', codec: codecs.plan }], codecs.result),\n descriptor('list', [], codecs.entries),\n descriptor('getOperation', [{ name: 'operationId', wire: 'operationId', source: 'json', codec: codecs.operationId }], codecs.operation),\n descriptor('preparePurge', [{ name: 'request', wire: 'request', source: 'json', codec: codecs.purgeRequest }], codecs.purgePlan),\n descriptor('executePurge', [{ name: 'plan', wire: 'plan', source: 'json', codec: codecs.purgePlan }], codecs.purgeResult),\n descriptor('getPurgeOperation', [{ name: 'operationId', wire: 'operationId', source: 'json', codec: codecs.operationId }], codecs.purgeOperation),\n descriptor('purgeOperations', [], codecs.purgeOperations),\n descriptor('follow', [], codecs.snapshot, 'stream'),\n];\nexport const sessionBinRemoteContribution: TypertRemoteContribution = { package: '@takboo/dsh-session-bin', descriptors };\nexport const sessionBinHostContribution: TypertContribution = {\n package: '@takboo/dsh-session-bin', face: 'host',\n schemas: [\n { name: 'ArchivePrepareRequest', create: () => archivePrepareRequestSchema },\n { name: 'ArchiveEntry', create: () => archiveEntrySchema },\n { name: 'ArchivePlan', create: () => archivePlanSchema },\n { name: 'ArchiveResult', create: () => archiveResultSchema },\n { name: 'ArchiveOperation', create: () => archiveOperationSchema },\n { name: 'ArchiveEntries', create: () => entriesSchema },\n { name: 'OperationId', create: () => operationIdSchema },\n { name: 'OptionalArchiveOperation', create: () => optionalOperationSchema },\n { name: 'PreparePurgeRequest', create: () => preparePurgeRequestSchema },\n { name: 'NativePurgePlan', create: () => nativePurgePlanSchema },\n { name: 'PurgeResult', create: () => purgeResultSchema },\n { name: 'OptionalPurgeOperation', create: () => optionalPurgeOperationSchema },\n { name: 'PurgeOperations', create: () => purgeOperationsSchema },\n { name: 'ArchiveSnapshot', create: () => snapshotSchema },\n ],\n model: { services: [{ key: sessionBinRemoteServiceKey, exportName: 'SessionBinRemote',\n description: 'Typed native archive management adapter.', tags: [], members: [\n { kind: 'method', name: 'prepare', signature: 'prepare(request: ArchivePrepareRequest, signal: AbortSignal): Promise<ArchivePlan>' },\n { kind: 'method', name: 'execute', signature: 'execute(plan: ArchivePlan, signal: AbortSignal): Promise<ArchiveResult>' },\n { kind: 'method', name: 'list', signature: 'list(signal: AbortSignal): Promise<ArchiveEntry[]>' },\n { kind: 'method', name: 'getOperation', signature: 'getOperation(operationId: string, signal: AbortSignal): Promise<ArchiveOperation | BinOperation | null>' },\n { kind: 'method', name: 'preparePurge', signature: 'preparePurge(request: PreparePurgeRequest, signal: AbortSignal): Promise<PurgePlan>' },\n { kind: 'method', name: 'executePurge', signature: 'executePurge(plan: PurgePlan, signal: AbortSignal): Promise<PurgeResult>' },\n { kind: 'method', name: 'getPurgeOperation', signature: 'getPurgeOperation(operationId: string, signal: AbortSignal): Promise<PurgeOperation | null>' },\n { kind: 'method', name: 'purgeOperations', signature: 'purgeOperations(signal: AbortSignal): Promise<PurgeOperation[]>' },\n { kind: 'method', name: 'follow', signature: 'follow(signal: AbortSignal): RemoteStream<ArchiveSnapshot>' },\n ], types: [] }], events: [], objects: [] }, invocations: descriptors,\n};\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,QAAAA,aAAY;AACrB,SAAkB,eAAe;AACjC,OAAO,YAAY;AACnB,SAAS,sBAAsB;AAC/B,SAAS,wBAAAC,6BAA4B;;;ACJrC,SAAS,aAAAC,kBAAiB;AAC1B,SAAS,OAAO,QAAAC,OAAM,UAAU,SAAAC,cAAa;AAC7C,SAAS,YAAY,YAAY;AACjC,SAAS,wBAAwB;;;ACHjC,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,OAAO,YAAY;AAE5B,SAAS,SAAS,wBAAwB;AAGnC,SAAS,wBAAwB,WAAW,QAAQ,UAAU,OAAO,QAAQ,MAAe;AACjG,SAAO,CAAC,UAAU,SAAS,OAAO,EAAE,SAAS,QAAQ,KAAK,CAAC,SAAS,KAAK,EAAE,SAAS,IAAI;AAC1F;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AkB,WAAW;AAAA,EAAG;AAAA,EACrG,kBAAkB;AAAE,WAAO,KAAK,cAAc,EAAE,gBAAgB;AAAA,EAAG;AAAA,EACnE,iBAAiB;AAAE,WAAO,KAAK,cAAc,EAAE,eAAe;AAAA,EAAG;AAAA,EACjE,QAAQ,OAA8B;AACpC,QAAI,MAAM,kBAAkB,EAAG,QAAO,KAAK,cAAc,EAAE,QAAQ,KAAK;AACxE,UAAM,OAAO,WAAW,MAAM,KAAK;AACnC,WAAO,KAAK,cAAc,EAAE,cAAc,YAAY;AAAE,WAAK,iBAAiB,KAAK,WAAW;AAAG,aAAO,KAAK,OAAO,QAAQ,IAAI;AAAA,IAAG,CAAC;AAAA,EACtI;AAAA,EACA,OAAO;AAAE,WAAO,KAAK,cAAc,EAAE,KAAK;AAAA,EAAG;AAAA,EAC7C,aAAa;AAAE,WAAO,KAAK,cAAc,EAAE,WAAW;AAAA,EAAG;AAAA,EACzD,aAAa,aAAqB;AAChC,WAAO,KAAK,cAAc,EAAE,cAAc,YAAY,KAAK,aAAa,UAAU,WAAW,KAAK,MAAM,KAAK,OAAO,aAAa,WAAW,CAAC;AAAA,EAC/I;AAAA,EACA,YAAY;AAAE,WAAO,KAAK,cAAc,EAAE,UAAU;AAAA,EAAG;AACzD;AACA,eAAsB,MAAM,KAAc,SAAiB,CAAC,GAAG;AAC7D,QAAM,IAAI,OAAO,YAAY,MAAM;AACnC,QAAM,wBAAwB,GAAG;AACnC;",
|
|
6
6
|
"names": ["join", "workspaceDomainState", "constants", "open", "lstat", "name", "digest", "lstat", "open", "constants", "randomUUID", "createHash", "z", "z", "identity", "z", "z", "key", "refused", "key", "createHash", "refused", "reason", "randomUUID", "key", "defineDomain", "domainTable", "defineDomain", "domainTable", "key", "randomUUID", "randomUUID", "createHash", "randomUUID", "defineDomain", "domainTable", "SessionId", "z", "join", "createHash", "name", "digest", "lstat", "realpath", "isAbsolute", "join", "resolve", "createHash", "createRequire", "tryLockExclusive", "z", "SessionId", "resolve", "done", "SessionId", "name", "adapter", "methods", "z", "isAbsolute", "join", "createHash", "identity", "name", "descriptor", "resolve", "require", "createRequire", "realpath", "lstat", "canonical", "tryLockExclusive", "digest", "AsyncLocalStorage", "createHash", "readdir", "realpath", "lstat", "unlink", "dirname", "join", "resolve", "workspaceDomainState", "z", "canonical", "key", "createHash", "name", "AsyncLocalStorage", "unlink", "lstat", "realpath", "readdir", "descriptor", "AsyncLocalStorage", "z", "z", "z", "defineDomain", "domainTable", "defineDomain", "domainTable", "canonical", "key", "AsyncLocalStorage", "z", "name", "z", "defineDomain", "domainTable", "hash", "createHash", "name", "randomUUID", "SessionId", "z", "z", "name", "schema", "resolve", "ctx", "join", "resolve", "workspaceDomainState"]
|
|
7
7
|
}
|