/**
 * Per-owner realize runner — Phase 1 of the 2026-05-11-PER-OWNER-VS-PER-ACTION
 * proposal.
 *
 * Sibling of `per-action-runner.ts`. SAME spec-walking + owner-grouping
 * logic, DIFFERENT emission granularity: instead of calling
 * `emitActionBody` once per action, this runner calls the per-owner
 * LLM emit hook ONCE per owner and writes the resulting whole-file
 * content as `<Owner>.ai.ts`.
 *
 * Why this exists: the per-action emitter (Realize L3 Phase 3) gave
 * the LLM narrow context — one action's steps, no class shell, no
 * sibling methods, no manifest capabilities. Empirically on
 * idle-meta sonnet, that produced 29 of 94 actions as throw-stubs
 * because the LLM correctly refused to invent imports it couldn't
 * see were available. Per-owner restores the holistic context.
 *
 * Same `<Owner>.ai.ts` output shape (exported async functions per
 * action) → no consumer-interface change. The downstream controller
 * still does `import * as aiBehaviors from '../behaviors/X.ai.js'`.
 */
import { buildAvailableClientsByOwner, type MatcherFn, type SharedConvention } from './owner-emit-shared.js';
import type { PerOwnerEmitFn } from './per-owner-emit.js';
import type { PerActionRecoveryFn } from './per-action-recovery.js';
/** Options for {@link runPerOwnerEmission}. */
export interface RunPerOwnerEmissionOptions {
    /** Full inferred spec. */
    spec: any;
    /** Output directory — `.ai.ts` files go under `${outputDir}/backend/src/behaviors/`. */
    outputDir: string;
    /** Convention matcher (default: `matchAgainstConventions`). */
    matcher?: MatcherFn;
    /** Convention array for the matcher. */
    conventions?: ReadonlyArray<SharedConvention>;
    /** Per-owner LLM emit hook. Required — the whole point of this
     *  runner is to drive it once per owner. */
    perOwnerEmit: PerOwnerEmitFn;
    /** Tier 2 recovery hook (Phase 5a of
     *  `2026-05-14-PER-ACTION-RECOVERY-TIER.md`). When `perOwnerEmit`
     *  fails for an owner, this is tried before the γ-stub placeholder:
     *  it re-emits the owner action-by-action with full owner context.
     *  Optional — when absent, a Tier-1 failure goes straight to Tier 3
     *  (the pre-5a behaviour). Disabled at runtime via
     *  `SPECVERSE_REALIZE_NO_RECOVERY_TIER=1`; skipped for owners with
     *  more actions than `SPECVERSE_REALIZE_RECOVERY_MAX_ACTIONS`
     *  (default 40 — a guard against truly pathological owners, not a
     *  routine gate. The 5a trial showed the original cap of 12 excluded
     *  `MongoDBAdapter` (15 actions) — exactly the kind of large owner
     *  that fails Tier 1 and most needs decomposition. A big owner that
     *  already failed whole-owner emit is MORE worth decomposing, not
     *  less; the context-resend cost is bounded because it's only the
     *  hard tail). */
    perActionRecovery?: PerActionRecoveryFn;
    /** Pre-built availableClients map (from buildAvailableClientsByOwner). */
    availableClientsByOwner?: Map<string, string>;
    /** Manifest capability mappings text (NEW vs per-action runner).
     *  Format: pre-rendered string listing each mapping, e.g.
     *    "  - orm.client → PrismaClient (orms/prisma)\n  - jwt.signer → ..." */
    availableCapabilities?: string;
    /** Process context string per owner (optional). */
    processContextByOwner?: Map<string, string>;
    /** Skip the per-owner ✅ console.log lines (used by harness runs). */
    silent?: boolean;
    /** Test hook: don't write files to disk; just return the emission
     *  result for assertion. */
    dryRun?: boolean;
}
/** Result of {@link runPerOwnerEmission}. */
export interface RunPerOwnerEmissionResult {
    /** Per-owner emission records (file contents + outcome). */
    owners: PerOwnerOutcome[];
    /** Absolute paths of files written (empty when dryRun). */
    filesWritten: string[];
    /** Aggregate counters. */
    totals: {
        /** Number of owners walked. */
        ownerCount: number;
        /** Number of actions across all owners. */
        actionCount: number;
        /** Owners whose emit produced a usable file (Tier 1 whole-owner
         *  emit OR Tier 2 per-action recovery — both count as LLM-emitted). */
        ownersEmittedByLLM: number;
        /** Owners that produced a usable file specifically via the Tier 2
         *  per-action recovery path (subset of `ownersEmittedByLLM`). */
        ownersRecoveredByTier2: number;
        /** Owners whose emit failed at every tier; runner fell back to a
         *  deterministic placeholder file. */
        ownersFellBack: number;
    };
}
/** Per-owner emission outcome. */
export interface PerOwnerOutcome {
    ownerName: string;
    /** Number of actions on this owner. */
    actionCount: number;
    /** True when LLM produced a usable file. */
    llmEmitted: boolean;
    /** File contents written. Empty string when LLM declined entirely
     *  and the runner emitted a deterministic placeholder. */
    fileContents: string;
}
/**
 * Run per-owner LLM emission across every controller / service the
 * spec declares. For each owner:
 *   1. Collect its actions and resolve per-step matcher results.
 *   2. Call the perOwnerEmit hook with the whole owner's context.
 *   3. Write the returned file contents to disk (or fall back to a
 *      placeholder file containing one γ stub per action when emit
 *      returned null).
 */
export declare function runPerOwnerEmission(opts: RunPerOwnerEmissionOptions): Promise<RunPerOwnerEmissionResult>;
/** Build the availableCapabilities string consumed by the per-owner
 *  prompt's `availableCapabilities` slot. Walks the manifest's
 *  capabilityMappings and renders one line per mapping with a brief
 *  hint about what the factory provides. Exported so the realize
 *  caller can build it once and feed it to every owner.
 *
 *  Format example:
 *    - orm.client      → PrismaORM (provides Prisma's typed query API)
 *    - jwt.signer      → JsonWebToken (jsonwebtoken.sign / verify)
 *    - event.bus       → InMemoryEventBus (publish / subscribe)
 */
export declare function buildAvailableCapabilitiesString(manifest: any): string;
/**
 * Build the `availableSpecSurface` string consumed by the per-owner
 * prompt's slot of the same name. Walks every controller and service
 * in the spec EXCEPT the current owner (which already has its own
 * spec block in the prompt) and emits each operation's signature
 * formatted as `name(param: Type, ...) → ReturnType`.
 *
 * Purpose (TODO #60): the realize-owner prompt previously gave the
 * LLM only the OWNER's own spec block, no view of OTHER services'
 * operation signatures. When an action's step text said
 * `[call] AuthService.setTokensFromResponse(...)`, the LLM
 * faithfully called the method — without being able to check that
 * `setTokensFromResponse` was a declared operation on AuthService
 * with that arity. Empirically on idle-meta sonnet, this hallucinated-
 * method pattern produced 18 TS2554 (wrong arity) + 22 TS2339 +
 * 5 TS2551 errors. Pre-fix the LLM had no source of truth for
 * cross-service signatures.
 *
 * The surface lists every callable method by class so the LLM can
 * (a) verify a method exists before calling it, (b) match the
 * declared arity, (c) fall back to a γ-stub when the spec's step
 * text references an undeclared method.
 *
 * Format example:
 *   services/
 *     AuthService:
 *       - revokeToken(refreshToken: string, callerId: string) → any
 *       - verifyAccessToken(token: string, config: any) → any
 *
 *   controllers/
 *     AuthController:
 *       - register(input: any) → any
 *       - login(input: any) → any
 */
export declare function buildAvailableSpecSurface(spec: any, currentOwnerName?: string): string;
export { buildAvailableClientsByOwner };
//# sourceMappingURL=per-owner-runner.d.ts.map