/** * astroengine counterfactual -- a real chart, perturbed, and what changed. * * The `counterfactual` realm: take a resolved chart and ask "what if". Shift the * instant ("born an hour later") or the place -- a real ephemeris recompute -- * or splice a body to a new longitude ("Mars in the next sign") -- a geometry * what-if that keeps everything else and recomputes the aspects it touches. * {@link chartDiff} reports the difference so the change is legible, not buried * in two full charts. */ import { Engine, Chart, ChartOptions, Aspect } from "./chart.js"; import { AnchorRegistry } from "./provenance.js"; import { AnchoredChart, RealizedChart } from "./anchored.js"; /** A perturbation of a resolved chart. */ export interface CounterfactualEdit { /** Shift the resolved instant by a duration (e.g. `"1h"`, `"-30m"`, `"P1D"`). */ shiftTime?: string; /** Recompute at a different place. */ place?: { lat: number; lonEast: number; altM?: number; }; /** Move bodies to given ecliptic longitudes (degrees), keeping everything else * -- a geometry what-if. The moved body's house and the touched aspects are * recomputed; the angles and other bodies are untouched. */ setLongitudes?: Record; } /** A body whose sign or house changed between two charts. */ export interface BodyChange { body: string; /** Signed degrees the body moved (`b` minus `a`). */ dLon: number; signFrom: string; signTo: string; houseFrom: number; houseTo: number; } /** An angle whose sign changed. */ export interface AngleChange { angle: string; from: string; to: string; } /** What differs between two charts. */ export interface ChartDiff { /** Bodies whose sign or house changed. */ bodies: BodyChange[]; /** Aspects present in the variant but not the original. */ aspectsGained: Aspect[]; /** Aspects present in the original but not the variant. */ aspectsLost: Aspect[]; /** Angles whose sign changed. */ angles: AngleChange[]; } /** Diff two charts: body sign/house shifts, aspects gained/lost, angle sign * changes. Bodies and angles that did not change sign/house are omitted. */ export declare function chartDiff(a: Chart, b: Chart): ChartDiff; /** A counterfactual: a base chart and a perturbed variant, with the diff. */ export interface Counterfactual { edit: CounterfactualEdit; /** The realized base (its `chart` is the original). */ original: RealizedChart; /** The perturbed chart, or null when the base had no chart to perturb. */ variant: Chart | null; diff: ChartDiff | null; note: string; } /** * Realize an {@link AnchoredChart}, then apply a {@link CounterfactualEdit} and * diff the result -- "a real event, perturbed." A time/place edit recomputes the * ephemeris; a `setLongitudes` edit splices the geometry. * * @param engine The engine. * @param base The base chart to perturb (realized via {@link realize}). * @param edit The perturbation. * @param registry Anchor lookups for the base. * @param opts Chart options (house system, zodiac). * @returns A {@link Counterfactual}; `variant`/`diff` are null when the base * produced no chart (e.g. a constraints-only form). */ export declare function counterfactual(engine: Engine, base: AnchoredChart, edit: CounterfactualEdit, registry?: AnchorRegistry, opts?: ChartOptions): Counterfactual;