import { type SafeReadResult } from "./safe-read.js"; import { type FileOutlineResult } from "./file-outline.js"; import { type ReadRangeResult } from "./read-range.js"; import { ObservationCache } from "./observation-cache.js"; import { GovernorTracker } from "../session/tracker.js"; import { type OutlineDiff } from "../parser/diff.js"; import type { JumpEntry, OutlineEntry } from "../parser/types.js"; import type { FileSystem } from "../ports/filesystem.js"; import { type WorkspaceReadView } from "./workspace-read-view.js"; import type { JsonCodec } from "../ports/codec.js"; import type { ProseProjectionProvider } from "./colorful-prose-projection.js"; export interface RepoWorkspaceRefusedResult { readonly path: string; readonly projection: "refused"; readonly reason: string; readonly reasonDetail: string; readonly next: string[]; readonly actual: { readonly lines: number; readonly bytes: number; }; } export interface RepoWorkspaceSafeReadCacheHitResult { readonly path: string; readonly projection: "cache_hit"; readonly reason: "REREAD_UNCHANGED"; readonly outline: readonly OutlineEntry[]; readonly jumpTable: readonly JumpEntry[]; readonly actual: Readonly<{ lines: number; bytes: number; }>; readonly readCount: number; readonly estimatedBytesAvoided: number; readonly lastReadAt: string; } export interface RepoWorkspaceSafeReadDiffResult { readonly path: string; readonly projection: "diff"; readonly reason: "CHANGED_SINCE_LAST_READ"; readonly diff: OutlineDiff; readonly outline: readonly OutlineEntry[]; readonly jumpTable: readonly JumpEntry[]; readonly actual: Readonly<{ lines: number; bytes: number; }>; readonly readCount: number; readonly lastReadAt: string; } export type RepoWorkspaceSafeReadResult = SafeReadResult | RepoWorkspaceSafeReadCacheHitResult | RepoWorkspaceSafeReadDiffResult; export type RepoWorkspaceFileOutlineResult = FileOutlineResult | RepoWorkspaceRefusedResult; export type RepoWorkspaceReadRangeResult = ReadRangeResult | RepoWorkspaceRefusedResult; export type RepoWorkspaceChangedSinceResult = { readonly status: "file_not_found"; } | { readonly status: "refused"; readonly reason: string; } | { readonly status: "unsupported"; readonly reason: "UNSUPPORTED_LANGUAGE"; } | { readonly status: "unchanged"; } | { readonly status: "no_previous_observation"; } | { readonly diff: OutlineDiff; readonly consumed: boolean; }; interface RepoWorkspaceCommonOptions { readonly projectRoot: string; readonly codec: JsonCodec; readonly graftignorePatterns?: readonly string[] | undefined; readonly resolvePath?: ((input: string) => string) | undefined; readonly toPolicyPath?: ((resolvedPath: string) => string) | undefined; readonly governor?: GovernorTracker | undefined; readonly cache?: ObservationCache | undefined; readonly proseProjector?: ProseProjectionProvider | undefined; } export type RepoWorkspaceOptions = RepoWorkspaceCommonOptions & ({ /** * The single read authority for this workspace. * * There is deliberately no filesystem parameter beside it. Two doors * would leave correctness resting on every code path remembering which * one is lawful; a workspace built over a settled observation must not * be able to reach the live disk at all. Callers that still want live * reads pass a `LiveWorkspaceReadSource` and are visible by name. */ readonly readView: WorkspaceReadView; readonly fs?: never; } | { /** * Compatibility input for the semver-public constructor. * * Normalized immediately to one live read authority used by every * analysis method. The same filesystem remains externally visible * through the legacy `fs` member but is never consulted internally. */ readonly fs: FileSystem; readonly readView?: never; }); /** An admitted read view whose evidence belongs to a different workspace. */ export declare class WorkspaceRootMismatchError extends Error { readonly projectRoot: string; readonly evidenceWorkspaceRoot: string; readonly code: "WORKSPACE_ROOT_MISMATCH"; constructor(projectRoot: string, evidenceWorkspaceRoot: string); } export declare class RepoWorkspace { private readonly resolveWorkspacePath; private readonly policyPathForWorkspaceFile; private readonly compatibilityFs; readonly projectRoot: string; readonly readView: WorkspaceReadView; readonly codec: JsonCodec; readonly graftignorePatterns: readonly string[]; readonly governor: GovernorTracker; readonly cache: ObservationCache; readonly proseProjector: ProseProjectionProvider | undefined; constructor(options: RepoWorkspaceOptions); /** * The filesystem supplied through the semver-public compatibility constructor. * * Analysis methods never use this member; they retain only `readView` as * their read authority. Snapshot-backed workspaces have no live filesystem * to expose and fail loudly if new code attempts to cross that boundary. */ get fs(): FileSystem; static loadGraftignorePatterns(fs: Pick, projectRoot: string): Promise; setBudget(bytes: number): void; getBudget(): { total: number; consumed: number; remaining: number; fraction: number; } | null; private evaluateRefusal; private invalidUtf8Refusal; /** * Observes a path exactly once, or reports that it could not be observed. * * A path the observation never admitted is a refusal, not an absence, and it * propagates. Folding it into not-found would report an authority escalation * as a cache miss, and would tell a caller a file does not exist when what * is true is that they may not read it. */ private observe; private outlineForSnapshot; safeRead(args: { readonly path: string; readonly intent?: string | undefined; }): Promise; fileOutline(args: { readonly path: string; }): Promise; readRange(args: { readonly path: string; readonly start: number; readonly end: number; }): Promise; changedSince(args: { readonly path: string; readonly consume?: boolean | undefined; }): Promise; } export {}; //# sourceMappingURL=repo-workspace.d.ts.map