@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
51 lines • 2.64 kB
TypeScript
import { type CompactContentStore, type LeafId } from "./compact-content-store.ts";
import { type ValueRef } from "./compact-values.ts";
/**
* Decoded-node budget of one compaction round's LRU (senpi#4559). A round's 128 rows land on up to 128 separate
* tree paths, about 1,000 nodes of about 0.9 KiB each (as accounted below) at 8,000 rows. The selection lookup and the
* batched apply walk the same paths, so the cache must hold a whole round's paths for the apply to reuse them.
* Measured at 8,000 settled rows: 32 KiB re-read 67,509 nodes from the spool, 512 KiB 58,175, 1 MiB 31,543.
*/
export declare const ROUND_CACHE_BYTES: number;
export interface PagedRoot {
readonly ref: ValueRef;
readonly height: number;
readonly size: number;
}
export interface PagedNode<T> {
readonly key: ValueRef;
readonly value: T;
readonly left?: PagedRoot;
readonly right?: PagedRoot;
}
/** Cold AVL paths live in owned storage leaves; only an operation's path is hydrated. */
export declare class CompactPagedTree<T> {
readonly store: CompactContentStore;
private readonly values;
private readonly leavesOf;
private dirty;
private cache;
private cacheBytes;
allocatedNodes: number;
constructor(store: CompactContentStore, leavesOf: (value: T) => readonly LeafId[]);
adjust(root: PagedRoot | undefined, live: number, pins: number): void;
/** A round-local `ROUND_CACHE_BYTES` LRU retains reused paths, including newly built ones; it ends with the round. */
cached<R>(operation: () => Promise<R>): Promise<R>;
private read;
private remember;
get(root: PagedRoot | undefined, key: string): Promise<T | undefined>;
/** Sorted requests share each descent instead of performing one root lookup per row. */
getMany(root: PagedRoot | undefined, keys: readonly string[]): Promise<Map<string, T>>;
entries(root: PagedRoot | undefined, after?: string): AsyncGenerator<readonly [string, T]>;
/** Applies one round's changes (undefined deletes) in one sorted pass; returns an owned root. */
apply(root: PagedRoot | undefined, changes: ReadonlyMap<string, T | undefined>): Promise<PagedRoot | undefined>;
private make;
/**
* Commits a round as `node-` files of at most 64 KiB each, published together once the last one is
* durable (RULING-54): nodes replaced within the round were released and are skipped, so only
* survivors are written. Until then a round's built nodes stay resident, at most 384 keys x 3 nodes per
* level x (height + 1).
*/
flush(): Promise<void>;
}
//# sourceMappingURL=compact-paged-tree.d.ts.map