/**
 * Repo-shared declarative mesh config — `.adhdev/mesh.json`
 *
 * A repo-committed, machine-independent file carrying ONLY the repo-shared
 * coordinator-prompt config and operating notes:
 *
 *   - coordinator       — systemPromptOverride (local wins, else repo) and
 *                         systemPromptAppend (repo append + local append BOTH
 *                         stack, repo first).
 *   - operatingNotes    — repo-declared baseline notes merged with the runtime
 *                         ledger notes; on duplicate text the ledger note wins.
 *   - limits            — advisory-only (`maxNoteChars`, `maxNotes`,
 *                         `coordinator.maxPromptChars`); recorded, never enforced in v1.
 *
 * POLICY IS NOT HERE. RepoMeshPolicy (the 15 scheduling/approval fields) is
 * MACHINE-LOCAL only — it lives in meshes.json and is never sourced from, merged
 * with, or overlaid by a repo file. There is no `policy` zone and no
 * `policy.scheduling` overlay in mesh.json; the scheduler reads the stored
 * machine-local policy directly. The repo file shapes the coordinator prompt and
 * operating notes, nothing else.
 *
 * The coordinator/operatingNotes merge is **in-memory only**: the on-disk
 * machine-local `meshes.json` is never mutated by this module.
 *
 * FILE SEPARATION: refine / worktree-bootstrap / change-impact configs live in
 * their OWN `.adhdev/*` files with their own loaders — they are NOT inlined into
 * mesh.json. `loadRepoSettings` (config/repo-settings.ts) assembles all of them
 * into one object for consumers.
 *
 * SECURITY: declarative only. JSON/YAML is parsed; arbitrary JS (.js) is NOT
 * supported, so loading a config can never execute code.
 */
import type { RepoMeshCoordinatorConfig, LocalMeshEntry } from '../repo-mesh-types.js';
import type { CoordinatorOperatingNote } from '../mesh/coordinator-prompt.js';
export interface RepoMeshDeclarativeCoordinatorConfig {
    /** Full mesh-level system prompt override. Same semantics as
     *  RepoMeshCoordinatorConfig.systemPromptOverride; LOCAL-WINS. */
    systemPromptOverride?: string;
    /** Mesh-level append stacked after the base prompt. Both the repo append
     *  and the machine-local append apply; the repo append comes first. */
    systemPromptAppend?: string;
    /** Advisory only in v1 — recorded but never enforced. */
    maxPromptChars?: number;
}
export interface RepoMeshDeclarativeLimits {
    /** Advisory only in v1 — recorded but never enforced. */
    maxNoteChars?: number;
    /** Advisory only in v1 — recorded but never enforced. */
    maxNotes?: number;
}
/**
 * Parsed + normalized `.adhdev/mesh.json` shape. Every field is optional except
 * version so a repo can declare only the zone(s) it cares about. Policy is NOT a
 * zone here — it is machine-local (meshes.json) only.
 */
export interface RepoMeshDeclarativeConfig {
    version: 1;
    coordinator?: RepoMeshDeclarativeCoordinatorConfig;
    operatingNotes?: CoordinatorOperatingNote[];
    limits?: RepoMeshDeclarativeLimits;
}
export interface RepoMeshJsonConfigLoadResult {
    config?: RepoMeshDeclarativeConfig;
    /** Relative location matched, or 'unavailable'/'invalid' marker. */
    source: string;
    sourceType: 'repo_file' | 'unavailable' | 'invalid';
    /** Absolute path of the matched file, when one was read. */
    path?: string;
    error?: string;
}
export declare const MESH_JSON_CONFIG_LOCATIONS: string[];
export declare const MESH_JSON_CONFIG_SCHEMA: {
    readonly $schema: "https://json-schema.org/draft/2020-12/schema";
    readonly title: "ADHDev Repo Mesh Declarative Config";
    readonly type: "object";
    readonly additionalProperties: false;
    readonly required: readonly ["version"];
    readonly properties: {
        readonly version: {
            readonly const: 1;
        };
        readonly coordinator: {
            readonly type: "object";
            readonly additionalProperties: false;
            readonly properties: {
                readonly systemPromptOverride: {
                    readonly type: "string";
                };
                readonly systemPromptAppend: {
                    readonly type: "string";
                };
                readonly maxPromptChars: {
                    readonly type: "number";
                    readonly minimum: 1;
                };
            };
        };
        readonly operatingNotes: {
            readonly type: "array";
            readonly maxItems: 200;
            readonly items: {
                readonly type: "object";
                readonly additionalProperties: false;
                readonly required: readonly ["text"];
                readonly properties: {
                    readonly text: {
                        readonly type: "string";
                        readonly minLength: 1;
                    };
                    readonly category: {
                        readonly enum: readonly ["provider_quirk", "pattern_to_avoid", "recovery_lesson"];
                    };
                    readonly createdAt: {
                        readonly type: "string";
                    };
                    readonly sourceCoordinator: {
                        readonly type: "string";
                    };
                };
            };
        };
        readonly limits: {
            readonly type: "object";
            readonly additionalProperties: false;
            readonly properties: {
                readonly maxNoteChars: {
                    readonly type: "number";
                    readonly minimum: 1;
                };
                readonly maxNotes: {
                    readonly type: "number";
                    readonly minimum: 1;
                };
            };
        };
    };
};
/**
 * Validate + normalize a parsed `.adhdev/mesh.json` object into a typed
 * RepoMeshDeclarativeConfig. Returns the config plus any non-fatal warnings;
 * `valid` is false only when the document is structurally unusable (not an
 * object / wrong version). Unknown top-level keys are tolerated (dropped) so a
 * newer repo file authored against a future schema still loads its known zones.
 */
export declare function normalizeRepoMeshDeclarativeConfig(parsed: unknown): {
    valid: boolean;
    config?: RepoMeshDeclarativeConfig;
    errors: string[];
};
/**
 * Load the repo-shared declarative mesh config for a coordinator workspace.
 *
 * Resolution: the coordinator node workspace is checked first; if it carries no
 * `.adhdev/mesh.json`, the calling process cwd is tried as a fallback (per the
 * design: "workspace path = coordinator node workspace's .adhdev/mesh.json,
 * else calling cwd"). The first existing file across both bases (and the
 * json/yaml/yml variants) wins.
 *
 * Read/parse errors never throw — they resolve to a sourceType:'invalid'
 * result so a broken repo file degrades to "no repo base" instead of blocking
 * coordinator launch.
 */
export declare function loadRepoMeshJsonConfig(workspace?: string): RepoMeshJsonConfigLoadResult;
/**
 * Effective coordinator config. systemPromptOverride: local wins, else repo.
 * systemPromptAppend: repo append + local append BOTH stack (repo first). Other
 * coordinator fields (providerType, preferredNodeId, …) are carried from the
 * machine-local config unchanged.
 */
export declare function mergeEffectiveCoordinatorConfig(repoCoord: RepoMeshDeclarativeCoordinatorConfig | undefined, localCoord: RepoMeshCoordinatorConfig | undefined): RepoMeshCoordinatorConfig;
/**
 * Effective operating notes = repo-declared baseline ⊕ runtime ledger notes.
 * Dedup by trimmed text with the LEDGER note winning (repo duplicates dropped),
 * so a runtime note's freshest wording/category survives. Order: repo baseline
 * first, then ledger notes. Returns undefined when nothing usable remains so the
 * prompt's "## Operating Notes" section is omitted exactly as before.
 */
export declare function mergeEffectiveOperatingNotes(repoNotes: CoordinatorOperatingNote[] | undefined, ledgerNotes: CoordinatorOperatingNote[] | undefined): CoordinatorOperatingNote[] | undefined;
/**
 * Produce an in-memory effective mesh by layering the repo declarative config
 * UNDER the machine-local mesh entry — coordinator zone ONLY. Policy is
 * machine-local and is left exactly as the stored mesh carries it (never sourced
 * from the repo file). Returns a new object; the input mesh and on-disk
 * meshes.json are never mutated. operatingNotes are merged separately at launch
 * (they ride the prompt context, not the mesh).
 */
export declare function applyRepoMeshConfig<T extends Pick<LocalMeshEntry, 'coordinator'>>(mesh: T, repoConfig: RepoMeshDeclarativeConfig | null | undefined): T;
/**
 * Build a `.adhdev/mesh.json` DRAFT from a machine-local mesh entry. This is a
 * scaffold for the operator to review and commit — NOT an automatic migration.
 * It captures the coordinator prompt override/append so a repo can adopt the
 * current machine's prompt customization as the shared base. Policy is NOT
 * exported — it is machine-local only and has no place in mesh.json. Operating
 * notes are intentionally NOT exported either: those are runtime ledger lessons,
 * and a repo should declare baseline notes deliberately.
 */
export declare function buildMeshJsonConfigScaffold(mesh: Pick<LocalMeshEntry, 'coordinator'>): RepoMeshDeclarativeConfig;
/** Serialize a scaffold to the canonical 2-space JSON draft text. */
export declare function serializeMeshJsonConfigScaffold(config: RepoMeshDeclarativeConfig): string;
