import type { Diagnostic, WorkspaceSource } from './compiler.js'; /** * Resolving a manifest without a filesystem (ADR 0156). * * `loadWorkspaceManifest` (workspace.ts) validates the manifest, expands its * patterns and reports what does not resolve. Only the expansion touches a * filesystem: it asks `globSync`, then `realpath` for confinement and for * aliasing. Everything else is arithmetic on the manifest and on the paths * the expansion hands back, so it lives here with the expansion injected, * and the Node loader is one caller of it. The other is * `resolveWorkspaceFrom`: the same manifest over a listed set of paths, which * is what a store with no filesystem has (`SourceStore.list()`, ADR 0100). * * The two agree on every diagnostic: YM701 for a pattern that is absolute, * carries `..` or a backslash, YM702 for a pattern matching nothing, YM703 * for one file claimed by two categories. */ export interface WorkspaceManifest { readonly format: 'yarramate/workspace/v1'; readonly id: string; readonly documents: readonly string[]; readonly profiles: readonly string[]; readonly projections: readonly string[]; readonly adapterMappings: readonly string[]; readonly patterns?: readonly string[]; readonly questions?: readonly string[]; readonly evidence?: readonly string[]; readonly contracts?: readonly string[]; /** * Glob patterns naming the artifacts the model intends to cover (#175, * ADR 0130). Not a document category: nothing here is loaded or compiled, * so it never joins ResolvedWorkspace. reconcile resolves the patterns * against the root of the git repository the manifest lives in and reports * every selected file no evidence observation claims. */ readonly coverage?: readonly string[]; } export interface ResolvedWorkspace { readonly id: string; readonly documents: readonly string[]; readonly profiles: readonly string[]; readonly projections: readonly string[]; readonly adapterMappings: readonly string[]; readonly patterns: readonly string[]; /** * Question catalogues the workspace itself carries (#345, ADR 0129). * ADDITIVE to the shipped catalogue: `--catalogue` replaces the base, this * adds to it, which is what lets a consultant author a question mid * engagement without a product release. * * OPTIONAL in the type although every resolver populates it, and that is * deliberate. `ResolvedWorkspace` is published, and adding `patterns` to * it as a required field broke a consumer's production module: a required * field is free for readers and a break for CONSTRUCTORS. Six fixtures in * this repository construct one, which is the same signal from inside. * Read it as `workspace.questions ?? []`. */ readonly questions?: readonly string[]; readonly evidence: readonly string[]; readonly contracts: readonly string[]; } export type WorkspaceManifestResult = { readonly ok: true; readonly manifest: WorkspaceManifest; readonly workspace: ResolvedWorkspace; } | { readonly ok: false; readonly diagnostics: readonly Diagnostic[]; }; export type ManifestCategory = 'documents' | 'profiles' | 'projections' | 'adapterMappings' | 'patterns' | 'questions' | 'evidence' | 'contracts'; /** One expanded match: where it is written, and what physical thing it is. */ export interface ExpandedMatch { /** The path as the resolved workspace will carry it. */ readonly path: string; /** * The identity two categories must not share (YM703): a real path on a * filesystem, the path itself in a store, which has no links. */ readonly identity: string; /** Set when the match lies outside the manifest directory (YM701). */ readonly outside?: true; } /** * How a pattern becomes files. Receives the pattern as written, already * screened for the shapes YM701 refuses on sight, and answers every match in * any order; the core sorts and de-duplicates. */ export type PatternExpander = (pattern: string) => readonly ExpandedMatch[]; export declare const resolveManifest: (source: WorkspaceSource, expand: PatternExpander) => WorkspaceManifestResult; /** * A manifest pattern as a regular expression over a `/`-separated relative * path: `**` crosses directories, `*` and `?` stay inside a segment, `{a,b}` * lists alternatives, `[...]` is a character class. What `globSync` accepts * for the shapes a manifest writes; a pattern with no wildcard matches its * own path exactly. */ export declare const patternToRegExp: (pattern: string) => RegExp; /** * The manifest over a file list: what `loadWorkspaceManifest` does over a * directory, with `paths` (every path the store holds, `/`-separated, * relative to the store root) in place of `globSync`. The manifest's own * path says where its patterns are rooted; the resolved paths are store * paths, rooted where `paths` are. A store holds no links, so a file's * identity is its path. */ export declare const resolveWorkspaceFrom: (manifest: WorkspaceSource, paths: readonly string[]) => WorkspaceManifestResult;