@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
43 lines • 2.15 kB
TypeScript
import { type FileEvent, type JsonValue, type PathSpec } from '../../../types.ts';
import type { RedisAccessor } from '../../../accessor/redis.ts';
/**
* Map one redis keyspace notification onto mount paths.
*
* The consumer subscribes to `__keyevent@<db>__:*` (which requires
* `notify-keyspace-events` to be configured; it is empty by default) and
* forwards the event verb with the key the message carried.
*
* Two limits are the protocol's, not this hook's, and both are reported
* honestly rather than guessed around:
*
* A `set` on a key that did not exist and one that did produce the same
* notification, so a create is reported as an UPDATE. Nothing is lost for a
* reader, because the hub evicts the parent listing for either, but a
* consumer that needs the distinction has to pull.
*
* A rename arrives as two independent messages (`rename_from` with the old
* key, `rename_to` with the new), so reconstructing a MOVE would need state
* this hook does not keep. They map to a DELETE and an UPDATE, which is what a
* poll-diff source reports for a rename too.
*
* Directories are the third limit, and the coarsest. Every directory on the
* mount is one member of a single `<prefix>dir` set, and a keyspace message
* carries the key, never the member, so an external `mkdir` or `rmdir` says
* only that some directory changed. An empty directory has no `file:` key at
* all, so nothing else reports it. That maps to UNKNOWN at the mount root,
* which re-inventories the whole mount: expensive, but it is exactly what
* UNKNOWN means and the protocol offers nothing narrower.
*
* Keys outside those two (the `modified:` and `attrs:` side keys) name nothing
* this mount serves and map to nothing.
*
* Mirrors Python `RedisEventHook` (`core/redis/events/hook.py`).
*/
export declare class RedisEventHook {
private readonly accessor;
constructor(accessor: RedisAccessor);
/** Mount-relative path for a redis key, or null if it names no file. */
private relative;
toEvents(root: PathSpec, eventType: string, payload: JsonValue): Promise<readonly FileEvent[]>;
}
//# sourceMappingURL=hook.d.ts.map