/** * HoloWeight v1 — backend-neutral planning for contract-carrying model-weight changes. * * This module never loads tensors, trains a model, mutates serving state, or pretends an * empirical behavior claim is statically proven. It validates physical compatibility and graph * integrity, then exposes the behavioral receipts still required for an external admission * transaction. */ export type ContentDigest = `sha256:${string}`; export type WeightArtifactFormat = 'safetensors' | 'gguf' | 'onnx' | 'peft' | 'other'; export interface WeightArtifactRef { digest: ContentDigest; format: WeightArtifactFormat; } export interface WeightCompatibility { baseDigest: ContentDigest; architecture: string; tokenizerDigest: ContentDigest; targetModules: string[]; dtype?: string; rank?: number; } export type WeightDeltaRole = 'generator' | 'critic' | 'router' | 'teacher'; export type WeightActivationMode = 'global' | 'task_scoped' | 'shadow_only'; /** * Declares what a weight delta is allowed to do at runtime. The planner defaults * legacy deltas to a global, user-visible generator. Any narrower activation * scope must fail closed to an immutable previously admitted head. */ export interface WeightRoleContract { role: WeightDeltaRole; activation: { mode: WeightActivationMode; taskTags?: string[]; minRouterConfidence?: number; allowUserVisibleOutput: boolean; fallbackHead?: ContentDigest; }; } export interface WeightDelta { id: string; artifact: WeightArtifactRef; compatibility: WeightCompatibility; provides: string[]; mustPreserve: string[]; producerRef: string; roleContract?: WeightRoleContract; } export type EvaluationRule = { kind: 'minimum'; value: number; } | { kind: 'maximum'; value: number; } | { kind: 'improves_by'; value: number; } | { kind: 'non_regression'; tolerance: number; }; export type EvaluatorPolicy = 'deterministic' | 'provenance_independent' | 'cross_family'; export interface EvaluationRequirement { id: string; subject: string; metric: string; suiteDigest: ContentDigest; rule: EvaluationRule; minSeeds: number; evaluatorPolicy: EvaluatorPolicy; } export interface EvaluationReceiptRef { requirementId: string; candidateDigest: ContentDigest; receiptDigest: ContentDigest; evaluatorRef: string; /** * Consensus metadata is optional for deterministic evaluators, but is required by * provenance_independent and cross_family policies. `signatureVerified` is asserted by the * receipt-verification boundary (for example HoloTune's EIP-191 verifier), not by this planner. */ evaluatorFamily?: string; signerAddress?: string; signatureVerified?: boolean; seed?: number; seedCount: number; passed: boolean; } export type WeightCompositionMethod = 'linear' | 'concat' | 'ties' | 'dare_ties' | 'custom'; export interface WeightComposition { id: string; inputs: string[]; method: WeightCompositionMethod; parameters?: Record; } export interface WeightDeltaGraph { schema: 'holoweight.graph.v1'; id: string; /** * Exact content identity supplied by the materialization/content-addressing layer. * V1 validates and binds this digest but deliberately does not generate it. */ candidateDigest: ContentDigest; base: { artifact: WeightArtifactRef; architecture: string; tokenizerDigest: ContentDigest; }; deltas: WeightDelta[]; compositions: WeightComposition[]; requirements: EvaluationRequirement[]; receipts?: EvaluationReceiptRef[]; previousAdmittedHead?: ContentDigest; } export type WeightGraphReadiness = 'invalid' | 'candidate' | 'ready'; export type WeightPlanIssueCode = 'INVALID_GRAPH_SCHEMA' | 'GRAPH_ID_REQUIRED' | 'CANDIDATE_DIGEST_INVALID' | 'BASE_DIGEST_INVALID' | 'BASE_ARCHITECTURE_REQUIRED' | 'BASE_TOKENIZER_DIGEST_INVALID' | 'DELTA_ID_REQUIRED' | 'DUPLICATE_NODE_ID' | 'DELTA_ARTIFACT_DIGEST_INVALID' | 'DELTA_PRODUCER_REQUIRED' | 'WEIGHT_BASE_MISMATCH' | 'WEIGHT_ARCHITECTURE_MISMATCH' | 'WEIGHT_TOKENIZER_MISMATCH' | 'TARGET_MODULES_REQUIRED' | 'TARGET_MODULE_REQUIRED' | 'DUPLICATE_TARGET_MODULE' | 'INVALID_ADAPTER_RANK' | 'SEMANTIC_LABEL_REQUIRED' | 'WEIGHT_ROLE_INVALID' | 'ACTIVATION_MODE_INVALID' | 'ACTIVATION_TASK_TAG_REQUIRED' | 'ACTIVATION_TASK_TAG_INVALID' | 'DUPLICATE_ACTIVATION_TASK_TAG' | 'ACTIVATION_TASK_TAGS_FORBIDDEN' | 'ACTIVATION_ROUTER_CONFIDENCE_REQUIRED' | 'ACTIVATION_ROUTER_CONFIDENCE_INVALID' | 'ROLE_OUTPUT_VISIBILITY_INVALID' | 'ROLE_OUTPUT_VISIBILITY_FORBIDDEN' | 'ROLE_FALLBACK_HEAD_REQUIRED' | 'ROLE_FALLBACK_HEAD_INVALID' | 'ROLE_FALLBACK_HEAD_MISMATCH' | 'COMPOSITION_ID_REQUIRED' | 'COMPOSITION_INPUT_REQUIRED' | 'DUPLICATE_COMPOSITION_INPUT' | 'COMPOSITION_INPUT_FORWARD_REFERENCE' | 'COMPOSITION_INPUT_NOT_FOUND' | 'REQUIREMENT_REQUIRED' | 'REQUIREMENT_ID_REQUIRED' | 'DUPLICATE_REQUIREMENT_ID' | 'REQUIREMENT_SUBJECT_REQUIRED' | 'REQUIREMENT_SUBJECT_NOT_DECLARED' | 'REQUIREMENT_METRIC_REQUIRED' | 'REQUIREMENT_SUITE_DIGEST_INVALID' | 'REQUIREMENT_MIN_SEEDS_INVALID' | 'REQUIREMENT_RULE_INVALID' | 'RECEIPT_REQUIREMENT_NOT_FOUND' | 'RECEIPT_DIGEST_INVALID' | 'RECEIPT_EVALUATOR_REQUIRED' | 'RECEIPT_SEED_COUNT_INVALID' | 'CONFLICTING_REQUIREMENT_RECEIPTS' | 'PREVIOUS_HEAD_DIGEST_INVALID'; export interface WeightPlanIssue { code: WeightPlanIssueCode; severity: 'error' | 'warning'; path: string; message: string; } export type AdmissionRequirementStatus = 'missing' | 'candidate_mismatch' | 'under_seeded' | 'failed' | 'invalid_receipt' | 'unverified_evaluator' | 'insufficient_independence' | 'insufficient_families' | 'satisfied'; export interface AdmissionRequirementPlan { requirementId: string; status: AdmissionRequirementStatus; receipt?: EvaluationReceiptRef; receipts?: EvaluationReceiptRef[]; evaluatorEvidence?: { verifiedSigners: string[]; evaluatorFamilies: string[]; seedCount: number; }; } export type WeightExecutionStep = { kind: 'select-base'; artifact: WeightArtifactRef; architecture: string; tokenizerDigest: ContentDigest; } | { kind: 'apply-delta'; deltaId: string; artifact: WeightArtifactRef; roleContract: WeightRoleContract; } | { kind: 'compose'; compositionId: string; inputs: string[]; method: WeightCompositionMethod; parameters?: Record; } | { kind: 'evaluate'; requirementId: string; candidateDigest: ContentDigest; suiteDigest: ContentDigest; minSeeds: number; evaluatorPolicy: EvaluatorPolicy; } | { kind: 'admit'; candidateDigest: ContentDigest; ready: boolean; } | { kind: 'select-rollback-head'; head: ContentDigest; }; export interface WeightExecutionPlan { graphId: string; candidateDigest: ContentDigest; readiness: WeightGraphReadiness; issues: WeightPlanIssue[]; steps: WeightExecutionStep[]; semanticLabels: { provides: string[]; mustPreserve: string[]; }; admissionRequirements: AdmissionRequirementPlan[]; rollbackHead?: ContentDigest; } /** * Validate a HoloWeight graph and emit the deterministic work/evidence plan for its exact * candidate. `ready` means ready for an external admission transaction; this function does not * perform that transaction. */ export declare function planWeightDeltaGraph(graph: WeightDeltaGraph): WeightExecutionPlan;