open-agreements
Version:
Open-source legal template filling CLI and library
52 lines • 2.32 kB
TypeScript
import type { NormalizeConfig, FieldSelectorMetadata } from '../metadata.js';
import { type FieldSelectorManifest } from '../selectors/index.js';
export interface SourceStructureSignature {
paragraph_count: number;
heading_like_count: number;
short_placeholder_count: number;
long_clause_count: number;
unique_short_placeholders: string[];
}
export interface SourceDriftDiff {
missing_replacement_anchor_groups: string[];
missing_normalize_heading_anchors: string[];
missing_normalize_paragraph_anchors: string[];
missing_normalize_paragraph_end_anchors: string[];
/** Selector fields with at least one occurrence that did not resolve in the source. */
unresolved_selector_fields: string[];
/** Human-readable assertion failures (field → kind/detail) from selector resolution. */
assertion_failures: string[];
}
/** Selector-drift slice resolved against the source DOCX via safe-docx. */
export interface SelectorDriftResult {
unresolved_selector_fields: string[];
assertion_failures: string[];
}
/**
* Resolve every selector field's occurrence locators against the SOURCE DOCX
* (safe-docx parse path) and report drift: any unresolved occurrence or failed
* assertion means an upstream change broke a selector. This is the standing
* "did the form change under us?" gate; it runs at canary time, not fill time.
*/
export declare function checkSelectorDrift(sourcePath: string, manifests: FieldSelectorManifest[]): Promise<SelectorDriftResult>;
export interface SourceDriftCheckResult {
field_selector_id: string;
source_path: string;
expected_sha256?: string;
actual_sha256: string;
hash_match: boolean;
structure: SourceStructureSignature;
diff: SourceDriftDiff;
ok: boolean;
}
export declare function computeSourceStructureSignature(docxPath: string): SourceStructureSignature;
export declare function checkFieldSelectorSourceDrift(input: {
fieldSelectorId: string;
sourcePath: string;
metadata: FieldSelectorMetadata;
replacements: Record<string, string>;
normalizeConfig?: NormalizeConfig;
/** Pre-computed selector drift (from {@link checkSelectorDrift}); folded into diff + ok. */
selectorDrift?: SelectorDriftResult;
}): SourceDriftCheckResult;
//# sourceMappingURL=source-drift.d.ts.map