/** * graph.ts — relationships and reasoning over the project index. * * The index records *what each command list touches*; this module inverts that * into "who uses X" queries and walks the map transfer network, then layers * light reasoning on top so the MCP can answer questions like * "why does this door never open?" or "what breaks if I delete this map?". * * Roadmap #3 (Grafo del proyecto) and #8 (Comprensión del juego). */ import type { ProjectIndex, RefSource } from "./projectIndex.js"; import type { RefSet } from "./references.js"; export type RefKind = Extract; export type Role = "read" | "write" | "both"; export interface UsageHit { source: string; kind: RefSource["kind"] | "page-condition" | "common-event-trigger" | "encounter"; mapId?: number; eventId?: number; commonEventId?: number; troopId?: number; role?: Role; } /** Every place that references entity `id` of the given kind. */ export declare function findUsage(index: ProjectIndex, kind: RefKind, id: number): UsageHit[]; export interface SwitchReport { id: number; name: string; setters: UsageHit[]; readers: UsageHit[]; diagnosis: string; } /** Reason about a switch: who sets it, who reads it, and what's suspicious. */ export declare function explainSwitch(index: ProjectIndex, id: number): SwitchReport; export interface VariableReport { id: number; name: string; setters: UsageHit[]; readers: UsageHit[]; diagnosis: string; } export declare function explainVariable(index: ProjectIndex, id: number): VariableReport; export interface MapGraph { nodes: { id: number; name: string; }[]; edges: { from: number; to: number; via: number | null; }[]; } /** Directed graph of player transfers between maps. */ export declare function buildMapGraph(index: ProjectIndex): MapGraph; /** Map ids reachable from `startId` by following transfers (includes startId). */ export declare function reachableMaps(index: ProjectIndex, startId: number): number[]; /** Maps not reachable from the game's starting map (dead content). */ export declare function unreachableMaps(index: ProjectIndex): { id: number; name: string; }[]; export interface MapRemovalImpact { mapId: number; incomingTransfers: { fromMap: number; fromEvent: number | null; }[]; newlyUnreachable: { id: number; name: string; }[]; isStartMap: boolean; } /** What breaks if a given map is deleted: who pointed at it, what it stranded. */ export declare function whatBreaksIfMapRemoved(index: ProjectIndex, mapId: number): MapRemovalImpact;