//#region src/effective.d.ts /** * @classytic/tax-core/effective — effective-dated rule windows. * * THE one implementation of "which entry is active on this date" for * every versioned tax table in every jurisdiction pack (rate schedules, * thresholds, withholding matrices, service tables, bracket tables). * * Tax rules change on three clocks — annual finance acts, mid-year * ordinances, rolling regulations — and old documents must recompute * under the law of THEIR date forever. The dating convention that makes * that work: * * - Windows are INCLUSIVE on both ends; an omitted `effectiveTo` means * "current law, still open". * - Never mutate an old entry's values — close its window * (`effectiveTo`) and push a new dated entry. * - Tables are ordered oldest → newest; "latest" = last element. * * Extracted verbatim from @classytic/bd-tax (the reference * implementation), where it consolidated five duplicated window-scans. */ interface EffectiveDated { /** First day the entry is in force (inclusive). */ effectiveFrom: Date; /** Last day the entry is in force (inclusive). Omitted = still current. */ effectiveTo?: Date | undefined; } /** * Provenance a rule entry SHOULD carry (jurisdiction packs embed this * alongside their fields): auditors and future maintainers ask "which * instrument set this rate" — make the answer part of the data. */ interface RuleProvenance { /** The legal instrument — 'SRO 140-Ain/2026/345-Mushak', 'ITA 2023 s.90', 'Bill C-59 §…'. */ sourceRef: string; /** ISO date the value was last verified against a primary text. */ verifiedOn?: string | undefined; /** Caveats / open verification flags. */ notes?: string | undefined; /** * Machine-checkable evidence: each cites a pinned source by id and quotes it VERBATIM. A pack's * provenance test asserts every quote is found in the pinned text, so a citation cannot drift from * the law it names. */ citations?: readonly StatuteCitation[] | undefined; } /** One verbatim quote from a pinned primary source. `source` is the pack's statute-manifest id. */ interface StatuteCitation { readonly source: string; readonly quote: string; } /** Is `entry` in force on `asOf`? */ declare function isEffectiveAt(entry: EffectiveDated, asOf: Date): boolean; /** All entries in force on `asOf`, preserving table order. */ declare function effectiveEntries(entries: readonly T[], asOf: Date): T[]; /** First entry in force on `asOf` (table order wins ties), or undefined. */ declare function firstEffectiveAt(entries: readonly T[], asOf: Date): T | undefined; /** * Latest entry by table convention (tables are ordered oldest → newest). * Used for undated lookups: "the current law". */ declare function latestEntry(entries: readonly T[]): T; /** * A rule EDITION: a deep, frozen copy of a pack's rule rows — shares nothing with its input, and its dates * lose their setters (`Object.freeze` alone leaves `Date#setTime` working). What was compiled is what * answers, whatever the caller does with its own rows afterwards. */ declare function freezeRuleEdition(value: T): T; /** A stable fingerprint of an edition's CONTENT (FNV-1a 64 over its canonical JSON), prefixed by `scope`. */ declare function ruleEditionFingerprint(scope: string, edition: unknown): string; //#endregion export { EffectiveDated, RuleProvenance, StatuteCitation, effectiveEntries, firstEffectiveAt, freezeRuleEdition, isEffectiveAt, latestEntry, ruleEditionFingerprint };