import type { TCoreClaim } from "../../schemata/claim.js"; import type { TCoreClaimConnection } from "../../schemata/claim-connection.js"; import type { TCoreArgumentForkRecord, TCorePremiseForkRecord, TCoreExpressionForkRecord, TCoreVariableForkRecord, TCoreClaimForkRecord } from "../../schemata/fork.js"; import type { TCoreOriginDocument, TCoreOriginLink, TCoreOriginAnchor, TOriginAnchorTargetType } from "../../schemata/origin.js"; import type { TInvariantValidationResult } from "../../types/validation.js"; import type { TCoreArgument, TCorePremise, TCorePropositionalExpression, TCorePropositionalVariable } from "../../schemata/index.js"; import type { TArgumentEngineSnapshot } from "../argument-engine.js"; import type { TCoreChecksumConfig } from "../../types/checksum.js"; import type { TCorePositionConfig } from "../../utils/position.js"; /** * Narrow read-only interface for claim lookups. Used by `ArgumentEngine` for * variable validation — callers that only need to verify claim existence * should depend on this rather than the full `ClaimLibrary`. */ export interface TClaimLookup { /** * Returns a claim by ID and version, or `undefined` if not found. * * @param id - The claim ID. * @param version - The claim version number. * @returns The claim entity, or `undefined`. */ get(id: string, version: number): TClaim | undefined; /** * Returns the latest version of a claim for the given ID, or `undefined` * if the claim does not exist in this lookup. * * Implementations backed by a flat array (e.g. `createLookup`) return the * item with the highest version number for the given ID. The full * `ClaimLibrary` class tracks versions natively and returns its internal * latest version directly. * * @param id - The claim ID. * @returns The latest claim entity, or `undefined`. */ getCurrent(id: string): TClaim | undefined; } /** * Full management interface for a versioned claim library. Extends * `TClaimLookup` with mutation, query, and snapshot methods. */ export interface TClaimLibraryManagement extends TClaimLookup { /** * Creates a new claim at version 0. The `version`, `frozen`, and * `checksum` fields are assigned automatically. The `id` field is * auto-generated when omitted. The `type` field is required and is * immutable across the claim's lifetime. * * @param claim - The claim data without system-managed fields. `id` is * optional (auto-generated when omitted) and `type` is required. * @returns The created claim entity with all fields populated. * @throws If a claim with the same ID already exists. */ create(claim: Omit | (Omit & { id?: string; })): TClaim; /** * Updates mutable fields on the current (latest, unfrozen) version of a * claim. System-managed fields (`id`, `version`, `frozen`, `checksum`) * cannot be updated. * * @param id - The claim ID. * @param updates - The fields to update. * @returns The updated claim entity. * @throws If the claim does not exist. * @throws If the current version is frozen. */ update(id: string, updates: Partial>): TClaim; /** * Freezes the current version of a claim (marking it immutable) and * creates a new mutable version at `version + 1`. * * @param id - The claim ID. * @returns An object containing the `frozen` version and the new * `current` (mutable) version. * @throws If the claim does not exist. * @throws If the current version is already frozen. */ freeze(id: string): { frozen: TClaim; current: TClaim; }; /** * Returns the latest version of a claim, or `undefined` if not found. * * @param id - The claim ID. * @returns The latest claim entity, or `undefined`. */ getCurrent(id: string): TClaim | undefined; /** * Returns all claim entities across all IDs and versions. * * @returns An array of all claim entities. */ getAll(): TClaim[]; /** * Returns all versions of a claim sorted by version number ascending. * * @param id - The claim ID. * @returns An array of claim entities, or an empty array if the ID does * not exist. */ getVersions(id: string): TClaim[]; /** * Returns a serializable snapshot of all claims in the library. * * @returns The claim library snapshot. */ snapshot(): TClaimLibrarySnapshot; /** * Run invariant validation on the claim library. * * @returns The invariant validation result. */ validate(): TInvariantValidationResult; } /** * Narrow read-only interface for claim-connection lookups. * Implemented by `ClaimCitationLibrary` and `ClaimAxiomLibrary`. * * A claim connection is a directional support edge between two claims. The * supported endpoint lives at `claimId`; the endpoint that supplies the * support lives at `supportingClaimId`. Specializations (citation vs. axiom) * differ in which library they live in and what type the supporting-side * claim must have. */ export interface TClaimConnectionLookup { /** * Returns all connections where the given claim is the supported * endpoint (i.e. the `claimId` side of the edge). * * @param claimId - The supported claim ID to filter by. * @returns An array of matching connections. */ getConnectionsForClaim(claimId: string): TConn[]; /** * Returns a connection by ID, or `undefined` if not found. * * @param id - The connection ID. * @returns The connection entity, or `undefined`. */ get(id: string): TConn | undefined; } /** * Full management interface for a claim-connection library. Extends * `TClaimConnectionLookup` with mutation, query, and snapshot methods. * Connections are create-or-delete only — no update path. */ export interface TClaimConnectionLibraryManagement extends TClaimConnectionLookup { /** * Creates a claim connection. Implementations validate that both the * supported and supporting claims exist in the underlying claim library * and that the supporting-side claim has the type required by this * specialization (e.g. `'citation'` for `ClaimCitationLibrary`, * `'axiomatic'` for `ClaimAxiomLibrary`). Citation libraries also * reject any edge that would introduce a cycle in the global * claim-citation graph. * * @param connection - The connection data without the `checksum` field. * @returns The created connection with `checksum` populated. * @throws If a connection with the same ID already exists. * @throws If either referenced claim does not exist in the claim library. * @throws If the supporting-side claim has the wrong `type` for this * specialization. * @throws If the connection would create a cycle (citation library only). */ add(connection: Omit): TConn; /** * Removes a claim connection by ID. * * @param id - The connection ID to remove. * @returns The removed connection entity. * @throws If the connection does not exist. */ remove(id: string): TConn; /** * Returns all connections in the library. * * @returns An array of all connection entities. */ getAll(): TConn[]; /** * Returns all connections matching the predicate. * * @param predicate - A filter function applied to each connection. * @returns An array of matching connections. */ filter(predicate: (c: TConn) => boolean): TConn[]; /** * Returns a serializable snapshot of all connections in the library. * * @returns The claim-connection library snapshot. */ snapshot(): TClaimConnectionLibrarySnapshot; /** * Run invariant validation on the claim-connection library. * * @returns The invariant validation result. */ validate(): TInvariantValidationResult; } export type TClaimConnectionLibrarySnapshot = { /** All claim-connection entities in the library. */ connections: TConn[]; }; /** * Read-only view of an origin library — the source texts an argument was * built from, their association with argument versions, and the spans of * those texts individual argument parts derive from. */ export interface TOriginLookup { /** Returns the document with the given ID, or `undefined`. */ getDocument(id: string): TDocument | undefined; /** Returns the link with the given ID, or `undefined`. */ getLink(id: string): TLink | undefined; /** Returns the anchor with the given ID, or `undefined`. */ getAnchor(id: string): TAnchor | undefined; /** Returns every link attached to the given argument version. */ getLinksForArgument(argumentId: string, argumentVersion: number): TLink[]; /** Returns every anchor recorded against the given argument version. */ getAnchorsForArgument(argumentId: string, argumentVersion: number): TAnchor[]; /** * Returns every anchor pointing at one target — a claim expression, a * premise, or the argument itself. */ getAnchorsForTarget(targetType: TOriginAnchorTargetType, targetId: string): TAnchor[]; } /** * Full management surface of an origin library: the read-only lookup plus * creation, removal, snapshotting, and validation. */ export interface TOriginLibraryManagement extends TOriginLookup { /** * Creates a document. The supplied text is normalized and its SHA-256 * digest computed by the library; neither is a caller input. */ addDocument(document: Omit): TDocument; /** Attaches a document to one argument version with a stance. */ addLink(link: Omit): TLink; /** Records the span of a document that one argument part derives from. */ addAnchor(anchor: Omit): TAnchor; /** Removes a document. Refuses while any link or anchor still references it. */ removeDocument(id: string): TDocument; /** Removes a link. */ removeLink(id: string): TLink; /** Removes an anchor. */ removeAnchor(id: string): TAnchor; /** Every document in the library. */ getAllDocuments(): TDocument[]; /** Every link in the library. */ getAllLinks(): TLink[]; /** Every anchor in the library. */ getAllAnchors(): TAnchor[]; /** Serializable snapshot of the whole library. */ snapshot(): TOriginLibrarySnapshot; /** Checks every entity against the schema and the library's invariants. */ validate(): TInvariantValidationResult; } /** Serializable snapshot of an `OriginLibrary`. */ export type TOriginLibrarySnapshot = { /** All origin documents in the library. */ documents: TDocument[]; /** All argument-version-to-document links. */ links: TLink[]; /** All origin anchors. */ anchors: TAnchor[]; }; /** * Serializable snapshot of a `ClaimLibrary`. Contains all claim entities * across all IDs and versions. */ export type TClaimLibrarySnapshot = { /** All claim entities in the library. */ claims: TClaim[]; }; /** * Serializable snapshot of a `ForkLibrary`. Contains arrays of fork records * for each entity type. */ export type TForkLibrarySnapshot = { /** All argument fork records. */ arguments: TArgFork[]; /** All premise fork records. */ premises: TPremiseFork[]; /** All expression fork records. */ expressions: TExprFork[]; /** All variable fork records. */ variables: TVarFork[]; /** All claim fork records. */ claims: TClaimFork[]; }; /** * Serializable snapshot of an `ArgumentLibrary`. Contains snapshots of all * managed `ArgumentEngine` instances. */ export type TArgumentLibrarySnapshot = { /** Snapshots of all argument engines in the library. */ arguments: TArgumentEngineSnapshot[]; }; /** * Serializable snapshot of a `PropositCore` instance. Contains snapshots of * all managed libraries: arguments, claims, claim citations, axioms, and fork * records. */ export type TPropositCoreSnapshot = { /** Snapshot of all argument engines. */ arguments: TArgumentLibrarySnapshot; /** Snapshot of the claim library. */ claims: TClaimLibrarySnapshot; /** Snapshot of the claim-citation library. */ citations: TClaimConnectionLibrarySnapshot; /** Snapshot of the claim-axiom library. */ axioms: TClaimConnectionLibrarySnapshot; /** Snapshot of the fork library. */ forks: TForkLibrarySnapshot; /** * Snapshot of the origin library. Optional on input only: a snapshot * written before origin data existed carries no such slot, and absence is * unambiguously "no origin data" — unlike the axiom slot, no earlier field * ever held it. `PropositCore.fromSnapshot` defaults it to an empty * library rather than refusing the payload. */ origins?: TOriginLibrarySnapshot; }; /** * Shared configuration options for `PropositCore`. These config values are * threaded to all internally constructed libraries and engines. */ export type TPropositCoreConfig = { /** Checksum config shared across all libraries and engines. */ checksumConfig?: TCoreChecksumConfig; /** Position config for argument engines. */ positionConfig?: TCorePositionConfig; /** * Default behavior for engines constructed via this core's * `arguments.create(...)`. Passed through to `TLogicEngineOptions.behavior`. * Defaults to `'assistive'` at engine level if omitted. * * @since 1.0.0 */ behavior?: "assistive" | "permissive"; /** UUID generator for new entity IDs. Defaults to `globalThis.crypto.randomUUID()`. */ generateId?: () => string; }; //# sourceMappingURL=library.interfaces.d.ts.map