/** * Semiring — the algebraic foundation for agent network computation. * * A semiring (S, ⊕, ⊗, 0, 1) satisfies: * (S, ⊕, 0) — commutative monoid (aggregation of parallel alternatives) * (S, ⊗, 1) — monoid (sequential composition) * ⊗ distributes over ⊕: a ⊗ (b ⊕ c) = (a ⊗ b) ⊕ (a ⊗ c) * 0 annihilates: a ⊗ 0 = 0 ⊗ a = 0 * * Different semirings model different routing concerns over the same graph: * Trust: (max, ×, 0, 1) → most trusted delegation chain * Cost: (min, +, ∞, 0) → cheapest agent pipeline * Latency: (min, +, ∞, 0) → fastest sequential path * Bottleneck: (max, min, 0, 1) → widest bottleneck path (capacity) * Reliability: (max, ×, 0, 1) → most reliable chain * Boolean: (∨, ∧, ⊥, ⊤) → reachability * * One graph. One algorithm. Swap the semiring. Different answer. */ export interface Semiring { /** Additive identity. The "worst" or "impossible" value. */ readonly zero: T; /** Multiplicative identity. Passthrough / no-op edge. */ readonly one: T; /** ⊕: aggregate parallel alternatives (commutative, associative). */ add(a: T, b: T): T; /** ⊗: compose sequential edges (associative). */ mul(a: T, b: T): T; /** * Value equality. Used by graph traversal for convergence detection. * Defaults to `===` when absent — correct for primitive semirings (number, boolean). * Required for compound semirings (record, product, annotated) where `add()` * returns a new object even when the value is semantically unchanged. * * Declared as a property (not method) so extracting it doesn't trigger * unbound-method lint — semiring objects are plain data, never class instances. */ readonly eq?: ((a: T, b: T) => boolean) | undefined; } /** (max, ×, 0, 1) — most trusted delegation chain through the network. */ export declare const TrustSemiring: Semiring; /** * (min, +, ∞, 0) — cheapest path through the agent network. * Tropical semiring. Same algebra as Dijkstra / Bellman-Ford. */ export declare const CostSemiring: Semiring; /** (min, +, ∞, 0) — fastest sequential path (sum of edge latencies). */ export declare const LatencySemiring: Semiring; /** (max, min, 0, ∞) — widest bottleneck path (capacity-limited routing). */ export declare const BottleneckSemiring: Semiring; /** (max, ×, 0, 1) — most reliable chain (probability product). */ export declare const ReliabilitySemiring: Semiring; /** * (min, +, ∞, 0) — lowest regulatory risk path. * Risk accumulates along delegation chains (additive composition), * parallel alternatives pick the lowest-risk route (min choice). * * Edge weights represent risk scores: 0 = no risk, ∞ = impossible. * Jurisdictional data handling, compliance requirements, audit depth — * all accumulate when one agent delegates to another. */ export declare const RegulatoryRiskSemiring: Semiring; /** (∨, ∧, false, true) — can agent A reach agent B? */ export declare const BooleanSemiring: Semiring; /** * (max, +, -∞, 0) — numerically stable max-product via log-space. * * Multiplying many small probabilities or confidences (each < 1) in * linear space underflows fast: twenty 0.1-confidence edges collapse * to 10⁻²⁰, which starts losing precision before then and hits * denormals by 50. In log space the product becomes a sum; max stays * max. Isomorphic to `ReliabilitySemiring` via x ↦ log(x), but callers * skip the intermediate floats and stay stable over deep chains. * * Used by memory-graph's `recallConfidentChain` lens — most-confident * reasoning chain through the memory graph. Also valid as the Viterbi * recurrence semiring on DAG-structured trellises (when HMM-shape * inference joins the codebase as a separate primitive). */ export declare const MaxProductLogSemiring: Semiring; /** * Product semiring: optimize multiple concerns simultaneously. * * (A × B, ⊕_A × ⊕_B, ⊗_A × ⊗_B, (0_A, 0_B), (1_A, 1_B)) * * One graph traversal computes trust × cost × latency in a single pass. */ export declare function productSemiring(sa: Semiring, sb: Semiring): Semiring; /** * Lift a scalar semiring into a named-fields record semiring. * Useful when you want labeled dimensions instead of nested tuples. * * const Multi = recordSemiring({ trust: TrustSemiring, cost: CostSemiring }); * // Semiring<{ trust: number; cost: number }> */ export declare function recordSemiring>(fields: { [K in keyof R]: Semiring; }): Semiring; /** * Map a semiring through an isomorphism. * Useful for wrapping/unwrapping branded types or unit conversions. */ export declare function mappedSemiring(base: Semiring, to: (t: T) => U, from: (u: U) => T): Semiring; //# sourceMappingURL=semiring.d.ts.map