import type { ResolvedSkillListingBudget } from "../skill-listing-budget.js";
import type { RunnerDeps, TaskSpec, ToolSpec } from "../types.js";
import { type SkillGrantTable, type SkillSeatReader } from "../skill-grant.js";
import { type AllowEntryTable } from "../allow-entry.js";
import type { AnnounceOnceSink, Prepared, PrepareResume, RunInternals, ToolFaceSnapshot } from "./contracts.js";
import { type normalizeSkills } from "./synthetic-tools.js";
import { RosterBuilder } from "../tool-roster.js";
import { type RetiredNameView } from "../tool-name-aliases.js";
export interface PrepareProjectContextInput {
    /** borrowed-readonly — the deployment seams this phase reads: `onError` (the operator lane for an oversize skill),
     *  `sharedMemoryStores` (the shared-memory pair's switch: wired ⇒ mount). Receiver preserved (`deps.onError?.(…)`). */
    deps: Pick<RunnerDeps, "onError" | "sharedMemoryStores" | "onNotice" | "allowedTools">;
    /** borrowed-readonly — the REBOUND spec (`spec′`). Read: `sessionId` (the continuation projections), `skills` (the
     *  roster), `userInvokedSkills` (the person's invoked skills — their rows are written here), `principal` (the
     *  shared-memory tools' trusted identity), `instructionFamily` and `projectMemory` (the manifest's word: a declared
     *  family, and the request's off switch for it — the config door's one reading), `classifyAllShell` (the Skill card's
     *  auto strip). Never mutated. */
    spec: Pick<TaskSpec, "sessionId" | "skills" | "userInvokedSkills" | "principal" | "instructionFamily" | "projectMemory" | "classifyAllShell">;
    /** borrowed-readonly — trusted internals: `inheritedSkillGrants` (the parent's captured skill grant rows, seeded as
     *  `inherited`), `inheritedAllowedTools` (the parent's request entries, seeded as this leg's own). `undefined` on a
     *  standalone prepare. */
    internals: Pick<RunInternals, "inheritedSkillGrants" | "inheritedAllowedTools"> | undefined;
    /** borrowed-readonly — the request's `allowedTools`, screened and snapshotted at the config door (before the first await). */
    allowedTools: readonly import("../allow-entry.js").AllowListEntry[] | undefined;
    /** borrowed-mutable — the request's and the deployment's allow-entry tables (identity is the contract: the gate's lanes and
     *  the delegation capture alias these objects). Seeded here, once; nothing writes them after this phase. */
    allowedToolTables: {
        readonly request: AllowEntryTable;
        readonly deployment: AllowEntryTable;
    };
    /** borrowed-readonly — the acquired session's id (operator-line context). */
    sessionId: string;
    /** borrowed-readonly — the leg's minted task id (`legTaskIdOf`): the shared-memory tools' trusted task identity. */
    hostTaskId: string;
    /** borrowed-mutable — the run's skill grant table (identity is the contract: the `skill` tool, the gate's lane and the
     *  ctx capture alias this exact object). Mutated here: the parent's captured rows (`inherited`) and the person's invoked
     *  skills (`user`); after this phase only the `skill` tool writes (on activation). */
    skillGrants: SkillGrantTable;
    /** borrowed-mutable — the run's roster builder (later refs alias its read face; in-place contract). Mutated
     *  here: `mount` of the `skill` tool, the shared-memory pair and the engine-memory pair. Occupancy
     *  is judged on the ALREADY-MOUNTED read face (names + aliases). */
    roster: RosterBuilder;
    /** borrowed-readonly — the frozen task-start tool face; only `exclude` is read (pair yield ①). */
    toolFaceSnapshot: Pick<ToolFaceSnapshot, "selector">;
    /** borrowed-readonly — the leg's one reading of a retired tool name in a rule (`TaskStartDoors.retiredNames`): the allow tables and the
     *  skill table read their entries under it, as the policies are matched under it. */
    retiredNames: RetiredNameView;
    /** borrowed-readonly — the once-per-session ledger; only its deduplicated `onError` sink is invoked (a pair's mount shape is announced once). */
    onceLedger: AnnounceOnceSink;
    /** borrowed-readonly — the memory phase's engine-pair ToolSpecs (present iff the pair may mount). */
    memoryTools: ToolSpec[] | undefined;
    /** borrowed-readonly — the memory phase's session seat; only `!== undefined` is read (the blocked-mount disclosure fires only then). */
    memoryEngineSession: Prepared["memoryEngineSession"];
    /** borrowed-readonly — the engine pair's early conjuncts (computed before the memory phase). */
    memorySearchToolsPlanned: boolean;
    /** borrowed-readonly — the engine-pair name the exclusion valve removed, if any (disclosure text). */
    memoryPairExcludedName: string | undefined;
    /** borrowed-readonly — the engine-pair name a declared tool already occupies, if any (disclosure text). */
    memoryPairOccupiedName: string | undefined;
    /** borrowed-readonly — the durable-resume carrier; read for `!== undefined` (seedAnnounced),
     *  `seed.announcedListings.skills` (the removal-to-zero projection's gate) and `seed.skillGrants` (the frozen grant rows). */
    resume: Pick<PrepareResume, "seed"> | undefined;
    /** borrowed-readonly — the lowered listing-budget seats from the config door. The listing projection
     *  carries it to the boundary renderer, and the over-budget disclosure below is priced against it. */
    skillListingBudget: ResolvedSkillListingBudget;
}
export interface PrepareProjectContextResult {
    /** owned — `"on"` a family is declared and left on, `"disabled"` the request turned a declared family off, `"absent"` no family is declared. */
    projectMemoryFact: NonNullable<import("../wiring-manifest.js").WiringManifest["projectMemory"]>;
    /** owned — the normalized, load-gated skills (first-wins dedupe, name-sorted). Consumed inside this
     *  phase (tool + listing); exposed as the phase's own product. */
    skillSpecs: ReturnType<typeof normalizeSkills>;
    /** owned — the `Skill` tool's per-call seat over the loaded skills (`Execute skill: <name>`); `undefined` with no skill. */
    skillSeatOf: SkillSeatReader | undefined;
    /** owned — the skills-listing projection the run loop's announce lane consumes (`Prepared.skillsListing`). */
    skillsListing: Prepared["skillsListing"];
    /** owned — whether the shared-memory pair mounted here (the support-name pre-check reads it). */
    sharedMemoryPairMounted: boolean;
    /** owned — whether the engine-memory pair mounted here (the support-name pre-check reads it). */
    memoryEnginePairMounted: boolean;
}
/** The M9 phase body — prepareTask's project-context stretch, verbatim (see the module header). */
export declare function prepareProjectContext(input: PrepareProjectContextInput): Promise<PrepareProjectContextResult>;
