/** * Project identity resolution for memory scope isolation (ROADMAP.md Part I * [Committed] "Memory scope isolation"; plan docs/plans/2026-07-01-memory-scope-isolation.md S1). * * Resolution rules: * - The nearest ancestor of cwd (including cwd itself) containing a `.hippo` * directory is the project root; if none exists, the nearest ancestor * containing `.git` (directory or worktree file). * - The user home directory is NEVER a project, even though it contains the * global store at `~/.hippo`. Reaching home ends the walk. * - A directory with no marker anywhere up the walk is NOT a project: it * resolves to the user-global identity (empty name), so memories written * there stay injectable everywhere (matches pre-isolation behavior). * * NOTE: this module must stay free of imports from shared.ts / store.ts / * api.ts so any of them can import it without creating a cycle. */ /** The project a working directory belongs to. */ export interface ProjectIdentity { /** Realpath-resolved root directory of the project (the start dir when not in a project). */ root: string; /** Lowercased basename of the project root; empty string when not in a project. */ name: string; /** True when the directory resolves to the user home working set. */ isHome: boolean; } /** * Options for resolveProjectIdentity. Both fields are test seams; results are * not cached when either is set. stopDir bounds the upward walk so tests in a * temp sandbox never escape it and hit the host machine's real markers. */ export interface ResolveProjectIdentityOpts { homeDir?: string; stopDir?: string; } /** Clear the per-process identity cache (test seam). */ export declare function clearProjectIdentityCache(): void; /** * Canonicalize a path via realpath, falling back to path.resolve when the * path does not exist or realpath fails (mirrors importers.ts). */ export declare function realpathOrResolve(p: string): string; /** * Resolve the project identity for a working directory. * Defaults to process.cwd(). Results are cached per resolved input path. */ export declare function resolveProjectIdentity(cwd?: string, opts?: ResolveProjectIdentityOpts): ProjectIdentity; /** Nearest ancestor `.hippo` below home and the temp root (never projects; on Windows the temp root sits inside home). * Everything is realpath'd so a symlinked temp root or cwd still matches its bound. Design notes: docs/plans/2026-09-05-*.md */ export declare function findHippoStoreDir(cwd?: string, opts?: ResolveProjectIdentityOpts): string | null; /** * v39 memory scope isolation: classify a memory's origin_project against the * active project. `currentName === ''` means the session is not in a project * (home dir or markerless cwd) - everything is in scope there, matching * pre-isolation behavior. NULL/undefined origin is a legacy pre-v39 row and * is treated as cross-project (deny by default) - the safe direction for a * security partition. */ export declare function classifyOriginProject(origin: string | null | undefined, currentName: string): 'project' | 'user-global' | 'cross-project'; /** * The global Hippo store directory, resolved the same way shared.ts does: * $HIPPO_HOME > $XDG_DATA_HOME/hippo > ~/.hippo. Lives here (leaf module) so * db.ts migrations can use it without importing shared.ts (store.ts cycle); * shared.getGlobalRoot delegates to this. */ export declare function resolveGlobalRootDir(): string; /** * True when `p` IS the global store root. Used by the v39 migration so a * global store whose parent chain happens to contain `.git`/`.hippo` * (git-managed HIPPO_HOME, dotfiles setups) still backfills as user-global * ('') instead of being stamped with the surrounding repo's name - which * would hide the user's entire global corpus from every project. */ export declare function isGlobalStoreRoot(p: string): boolean; /** * Parse a memory's origin from its provenance `source` string, mirroring the * v39 migration's evidence rules: `shared::` and * `promoted:` identify the owning project; the user home dir's * basename maps to '' (user-global). Returns null when the source carries no * origin evidence. Pure string logic - recorded paths may no longer exist. */ export declare function originFromSource(source: string | null | undefined, homeName?: string): string | null; /** * The origin project to stamp on a memory written from cwd. * Returns the project name, or '' for user-global (written at/under home or * in a markerless directory) - injectable everywhere. Write sites must always * persist this value; a NULL origin_project column is reserved for legacy * pre-migration rows, which ambient context treats as deny (see plan * docs/plans/2026-07-01-memory-scope-isolation.md "Origin model"). */ export declare function deriveOriginProject(cwd?: string, opts?: ResolveProjectIdentityOpts): string; //# sourceMappingURL=project-identity.d.ts.map