proposit-core
    Preparing search index...

    Class ArgumentEngine<TArg, TPremise, TExpr, TVar, TClaim>

    Manages a propositional logic argument composed of premises, variable assignments, and logical roles (supporting premises and a conclusion).

    Provides premise CRUD, role management, evaluation of individual assignments, and exhaustive validity checking via truth-table enumeration.

    Type Parameters

    Hierarchy

    • HierarchicalChecksumCache
      • ArgumentEngine

    Implements

    Index

    Constructors

    • Type Parameters

      • TArg extends {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            version: number;
        } = {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            version: number;
        }
      • TPremise extends
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "freeform";
            }
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                derivedClaimId: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "derivation";
            } =
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "freeform";
            }
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                derivedClaimId: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "derivation";
            }
      • TExpr extends TCorePropositionalExpression = TCorePropositionalExpression
      • TVar extends
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                claimId: string;
                claimVersion: number;
                id: string;
                symbol: string;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundPremiseId: string;
                checksum: string;
                id: string;
                symbol: string;
            } =
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                claimId: string;
                claimVersion: number;
                id: string;
                symbol: string;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundPremiseId: string;
                checksum: string;
                id: string;
                symbol: string;
            }
      • TClaim extends {
            checksum: string;
            frozen: boolean;
            id: string;
            type: "normal" | "citation" | "axiomatic";
            version: number;
        } = {
            checksum: string;
            frozen: boolean;
            id: string;
            type: "normal" | "citation" | "axiomatic";
            version: number;
        }

      Parameters

      Returns ArgumentEngine<TArg, TPremise, TExpr, TVar, TClaim>

    Properties

    cachedCombinedChecksum: string | undefined
    cachedDescendantChecksum: string | null | undefined
    cachedMetaChecksum: string | undefined
    checksumDirty: boolean = true

    Accessors

    • get behavior(): "assistive" | "permissive"

      Current engine behavior setting. Controls whether the auto-normalization (AN) rule set runs as a post-hook after every successful Structural mutation. See the JSDoc on TLogicEngineOptions.behavior for the full contract.

      Returns "assistive" | "permissive"

      1.0.0

    Methods

    • Registers a propositional variable for use across all premises.

      Parameters

      • variable: Omit<
            {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                claimId: string;
                claimVersion: number;
                id: string;
                symbol: string;
            },
            "checksum"
            | "descendantChecksum"
            | "combinedChecksum",
        > & Partial<
            Pick<
                {
                    argumentId: string;
                    argumentVersion: number;
                    checksum: string;
                    claimId: string;
                    claimVersion: number;
                    id: string;
                    symbol: string;
                },
                "checksum",
            >,
        > & Record<string, unknown>

        The variable entity to register.

      Returns TCoreMutationResult<TVar, TExpr, TVar, TPremise, TArg>

      The registered variable (with checksum) and changeset.

      If variable.symbol is already in use.

      If variable.id already exists.

      If the variable does not belong to this argument.

    • Adds a premise-bound variable that references another argument's conclusion premise.

      Parameters

      • variable: Omit<
            TOptionalChecksum<
                {
                    argumentId: string;
                    argumentVersion: number;
                    boundArgumentId: string;
                    boundArgumentVersion: number;
                    boundPremiseId: string;
                    checksum: string;
                    id: string;
                    symbol: string;
                },
            >,
            "boundPremiseId",
        > & Record<string, unknown>
      • conclusionPremiseId: string

      Returns TCoreMutationResult<TVar, TExpr, TVar, TPremise, TArg>

    • Adds a premise-bound variable that references a premise in a different argument.

      Parameters

      • variable: Omit<
            {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundPremiseId: string;
                checksum: string;
                id: string;
                symbol: string;
            },
            "checksum"
            | "descendantChecksum"
            | "combinedChecksum",
        > & Partial<
            Pick<
                {
                    argumentId: string;
                    argumentVersion: number;
                    boundArgumentId: string;
                    boundArgumentVersion: number;
                    boundPremiseId: string;
                    checksum: string;
                    id: string;
                    symbol: string;
                },
                "checksum",
            >,
        > & Record<string, unknown>

      Returns TCoreMutationResult<TVar, TExpr, TVar, TPremise, TArg>

    • Registers a premise-bound propositional variable whose truth value is derived from another premise's evaluation.

      Parameters

      • variable: Omit<
            {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundPremiseId: string;
                checksum: string;
                id: string;
                symbol: string;
            },
            "checksum"
            | "descendantChecksum"
            | "combinedChecksum",
        > & Partial<
            Pick<
                {
                    argumentId: string;
                    argumentVersion: number;
                    boundArgumentId: string;
                    boundArgumentVersion: number;
                    boundPremiseId: string;
                    checksum: string;
                    id: string;
                    symbol: string;
                },
                "checksum",
            >,
        > & Record<string, unknown>

        The premise-bound variable entity to register.

      Returns TCoreMutationResult<TVar, TExpr, TVar, TPremise, TArg>

      The registered variable (with checksum) and changeset.

      If variable.symbol is already in use.

      If variable.id already exists.

      If variable.boundPremiseId does not exist in this argument.

      If variable.boundArgumentId does not match this argument.

      If the variable does not belong to this argument.

    • Builds a Map keyed by a caller-supplied function over all variables. Useful for indexing by extension fields (e.g. statementId). The caller should cache the result — this is O(n) per call.

      Type Parameters

      • K

      Parameters

      • keyFn: (v: TVar) => K

        A function that extracts the map key from a variable.

      Returns Map<K, TVar>

      A Map from the extracted key to the variable.

    • Override point for subclasses to restrict cross-argument bindings. When this returns false, bindVariableToExternalPremise will throw.

      Parameters

      • _boundArgumentId: string
      • _boundArgumentVersion: number

      Returns boolean

    • Override point for subclasses to prevent forking. When this returns false, forkArgument will throw.

      Returns boolean

    • Clears the conclusion designation.

      Invariant guard (1.0.2): A non-empty argument always has a conclusion designated (E-7). On an argument with one or more premises this method is a no-op — it returns the current (unchanged) role state with an empty changeset rather than leaving the engine in an E-7-violating state. The only path to legitimately end up with no conclusion designated is to remove every premise first. On a zero-premise argument the call still clears (vacuously satisfies the invariant).

      Returns TCoreMutationResult<
          { conclusionPremiseId?: string },
          TExpr,
          TVar,
          TPremise,
          TArg,
      >

      The current role state and changeset. If premises exist, the changeset is empty (no-op); if zero premises, the role state is cleared and the changeset reflects the role change.

    • Collects all variables referenced by expressions across all premises, indexed both by variable ID and by symbol.

      Returns {
          byId: Record<string, { premiseIds: string[]; symbol: string }>;
          bySymbol: Record<string, { premiseIds: string[]; variableIds: string[] }>;
          variableIds: string[];
      }

      An object with variableIds, byId, and bySymbol indexes.

    • Creates a premise with a caller-supplied ID and registers it with this engine. Mirrors createPremise exactly, but accepts an explicit id as the first argument instead of generating one.

      Two call styles are supported:

      • Typed-bag (preferred, since 0.11.0):

        engine.createPremiseWithId(id, {
        type: "freeform", // or "derivation"
        derivedClaimId: claimId, // required when type === "derivation"
        extras: { label: "P1" },
        symbol: "P1",
        })
      • Legacy positional (kept for compatibility):

        engine.createPremiseWithId(id, extras, symbol)  // creates a freeform premise
        

      When type === "derivation", the same derivation initialization as createPremise runs: variable materialization and naked-Q tree setup.

      Parameters

      • id: string

        The ID to assign to the new premise.

      • Optionalextras: Record<string, unknown>
      • Optionalsymbol: string

      Returns TCoreMutationResult<
          PremiseEngine<TArg, TPremise, TExpr, TVar>,
          TExpr,
          TVar,
          TPremise,
          TArg,
      >

      InvariantViolationError(CREATE_DERIVATION_REQUIRES_DERIVED_CLAIM_ID) when type === "derivation" and derivedClaimId is absent.

      InvariantViolationError(CREATE_DERIVATION_CLAIM_NOT_FOUND) when type === "derivation" and the claim is not in the library.

      If a premise with the given ID already exists.

      0.11.0 — typed-bag overload; derivation premise initialization.

    • Parameters

      • id: string
      • options: {
            derivedClaimId?: string;
            extras?: Record<string, unknown>;
            symbol?: string;
            type?: "freeform" | "derivation";
        }

      Returns TCoreMutationResult<
          PremiseEngine<TArg, TPremise, TExpr, TVar>,
          TExpr,
          TVar,
          TPremise,
          TArg,
      >

    • Repair primitive: resolve D-3 violations (mixed-grounding antecedent — axioms + citations in one derivation) by deleting every axiom-bound variable expression from the offending antecedent subtree. The remaining citation-bound variables stay, giving the derivation a homogeneous citation-grounded antecedent.

      User-initiated; never auto-runs. Respects behavior. In 'assistive' mode, AN may collapse a resulting single-child OR via AN-3; in 'permissive' the OR may persist with one child (a downstream D-2 violation — follow up with removeOrphanOperators() if desired).

      Returns readonly {
          argumentId?: string;
          claimId?: string;
          code:
              | "S-1"
              | "S-2"
              | "S-3"
              | "S-4"
              | "S-5"
              | "S-6"
              | "S-7"
              | "S-8"
              | "S-9"
              | "S-10"
              | "S-11"
              | "S-12"
              | "S-13"
              | "S-14"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5";
          expressionId?: string;
          message: string;
          premiseId?: string;
          tier: "structural"
          | "evaluable"
          | "derivable"
          | "presentable";
          variableId?: string;
      }[]

      1.0.0

    • Ensures a claim-bound variable for the given claim exists in this argument. If one already exists, returns it. Otherwise creates a new claim-bound variable with a fresh UUID, the current version of the claim from the ClaimLibrary, and an auto-generated symbol.

      Parameters

      • claimId: string

      Returns {
          argumentId: string;
          argumentVersion: number;
          checksum: string;
          claimId: string;
          claimVersion: number;
          id: string;
          symbol: string;
      }

      InvariantViolationError(CLAIM_NOT_FOUND) when the claim is not in the library.

      0.11.0

    • Look up a claim by (id, version) in the engine's claim library. Returns undefined if the claim is not present. Exposed for repair primitives and other tooling that needs to inspect a claim's type discriminator at a particular version pinned by a claim-bound variable.

      Parameters

      • claimId: string
      • claimVersion: number

      Returns TClaim | undefined

      1.0.0

    • Global normalize pass per spec §6. Runs the AN rule set (AN-1..AN-4) everywhere it can fire, converging the argument toward tier (defaults to 'presentable').

      normalize is non-destructive in the logical-meaning sense — it does not delete variables, change claim references, or modify operator semantics. Recovery from Evaluable or Derivable violations requires user intent and is exposed via the repair primitives.

      In v1.0 every AN rule targets a Presentable invariant, so calls with tier ∈ {'structural', 'evaluable', 'derivable'} are effectively no-ops. The parameter exists as forward-compatible API surface for a future submit/finalize gate.

      Bypasses behavior. normalize() is user-initiated (the UI invokes it after the user confirms a Tidy / Normalize action), so cleanup runs regardless of whether the engine is in 'assistive' or 'permissive' mode. The engine's behavior setting is not mutated by this call.

      Parameters

      • tier: "structural" | "evaluable" | "derivable" | "presentable" = "presentable"

      Returns void

      1.0.0

    • Patches application-specific fields onto an expression across all premises, then marks the expression and its ancestors dirty so the next checksum flush recomputes from the patched values.

      This is the public API for consumers that need to attach app-level metadata (e.g. creatorId, createdOn) to expressions synthesized by the engine's auto-normalization. It resolves the owning premise internally, applies the patch in place via Object.assign, and marks the expression dirty — callers cannot patch without marking (stale checksum) or mark without patching (no-op).

      Parameters

      • expressionId: string

        The ID of the expression to patch.

      • fields: Partial<TExpr>

        Fields to merge into the expression.

      Returns void

      If no expression with the given ID exists.

      2.3.1

    • Mirror of populateFromCitations for axiom connections. Same factory contract: naked-Q-only, no throw on already-populated.

      Type Parameters

      • TConn extends {
            checksum: string;
            claimId: string;
            claimVersion: number;
            id: string;
            supportingClaimId: string;
            supportingClaimVersion: number;
        } = {
            checksum: string;
            claimId: string;
            claimVersion: number;
            id: string;
            supportingClaimId: string;
            supportingClaimVersion: number;
        }

      Parameters

      Returns TPopulateResult

      1.0.0

    • Construct (or no-op on) the per-claim derivation premise's antecedent from a citation lookup. Factory + naked-Q-only:

      • 0 connections → no-op (naked-Q stays).
      • 1 connection → IMPLIES(citation-var, Q).
      • ≥ 2 connections → IMPLIES(OR(c1, …, cn), Q). In 'assistive' mode the per-mutation AN-1 post-hook inserts a formula buffer between IMPLIES and OR; in 'permissive' the OR sits directly under IMPLIES (a P-1 violation surfaces via validate('presentable')).

      No throw on already-populated. Per the Structural-only mutation throw rule, if the target derivation premise is not in the naked-Q form the factory returns { kind: 'no-op', state: <existing> } without mutating. UI/caller is responsible for explicit user consent + clearing the antecedent via a repair primitive before re-calling. Preserves the no-changes-without- consent principle.

      Throws only when no derivation premise exists for the given derivedClaimId (legitimate entity-not-found Structural check).

      Type Parameters

      • TConn extends {
            checksum: string;
            claimId: string;
            claimVersion: number;
            id: string;
            supportingClaimId: string;
            supportingClaimVersion: number;
        } = {
            checksum: string;
            claimId: string;
            claimVersion: number;
            id: string;
            supportingClaimId: string;
            supportingClaimVersion: number;
        }

      Parameters

      Returns TPopulateResult

      1.0.0

    • Repair primitive: resolve E-6 violations (claim has > 1 derivation premise) by keeping one premise per derivedClaimId and deleting the rest. Strategy controls which premise is kept:

      • 'keep-first' (default): keep the premise with the lexicographically smallest id; delete the rest. Deterministic and snapshot-stable.
      • 'keep-largest-antecedent': keep the premise whose antecedent subtree has the most claim-bound variable expressions; tie-break by id.

      User-initiated; never auto-runs. Respects behavior.

      Parameters

      • strategy: "keep-first" | "keep-largest-antecedent" = "keep-first"

      Returns readonly {
          argumentId?: string;
          claimId?: string;
          code:
              | "S-1"
              | "S-2"
              | "S-3"
              | "S-4"
              | "S-5"
              | "S-6"
              | "S-7"
              | "S-8"
              | "S-9"
              | "S-10"
              | "S-11"
              | "S-12"
              | "S-13"
              | "S-14"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5";
          expressionId?: string;
          message: string;
          premiseId?: string;
          tier: "structural"
          | "evaluable"
          | "derivable"
          | "presentable";
          variableId?: string;
      }[]

      1.0.0

    • Repair primitive: resolve E-1 violations (operators with < 2 children) by running the AN-3 cleanup pass globally. Returns the violations resolved. The repair is non-meaning-changing — it only removes empty operators and promotes single-child operators — but lives alongside normalize() so the UI can present a focused "Remove N orphan operators" action with a precise return value.

      User-initiated; never auto-runs. Bypasses behavior — cleanup runs even in permissive mode (the user has already accepted the action by clicking the repair button).

      Returns readonly {
          argumentId?: string;
          claimId?: string;
          code:
              | "S-1"
              | "S-2"
              | "S-3"
              | "S-4"
              | "S-5"
              | "S-6"
              | "S-7"
              | "S-8"
              | "S-9"
              | "S-10"
              | "S-11"
              | "S-12"
              | "S-13"
              | "S-14"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5";
          expressionId?: string;
          message: string;
          premiseId?: string;
          tier: "structural"
          | "evaluable"
          | "derivable"
          | "presentable";
          variableId?: string;
      }[]

      1.0.0

    • Removes a premise and reassigns any role assignments that reference it.

      Invariant guard (1.0.2): when the removed premise was the conclusion AND other premises remain after the delete, the conclusion role is atomically reassigned to the lowest-id remaining premise (sorted lexicographically) rather than left undefined, preserving the engine-level invariant that a non-empty argument always has a conclusion designated (E-7). When the removed premise was the conclusion AND no premises remain, the role is cleared as before (vacuous invariant on the empty argument). Consumers that want a different reassignment policy (e.g., server-side createdOn ordering or a UI-defined sibling position) should issue their own setConclusionPremise(...) call immediately after this method returns — the post-mutation E-7 will continue to pass because a conclusion stays designated throughout.

      Parameters

      • premiseId: string

        The ID of the premise to remove.

      Returns TCoreMutationResult<TPremise | undefined, TExpr, TVar, TPremise, TArg>

      The removed premise data, or undefined if not found.

    • Repair primitive: resolve E-3 violations by deleting each unresolvable claim- or premise-bound variable, cascading the removal across all premises. Returns the violations resolved (for UX confirmation / undo / "we made N changes" feedback).

      User-initiated; never auto-runs. Respects behavior: in 'assistive' mode, the AN post-hook fires after each cascade mutation; in 'permissive' no AN runs.

      Returns readonly {
          argumentId?: string;
          claimId?: string;
          code:
              | "S-1"
              | "S-2"
              | "S-3"
              | "S-4"
              | "S-5"
              | "S-6"
              | "S-7"
              | "S-8"
              | "S-9"
              | "S-10"
              | "S-11"
              | "S-12"
              | "S-13"
              | "S-14"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5";
          expressionId?: string;
          message: string;
          premiseId?: string;
          tier: "structural"
          | "evaluable"
          | "derivable"
          | "presentable";
          variableId?: string;
      }[]

      1.0.0

    • Switches the engine's behavior at runtime. Going permissive → assistive does not auto-run a global normalize() pass; the UI is expected to prompt the user before invoking normalize() explicitly.

      As of v1.0 behavior is enforced entirely via the AN post-mutation hook in runAssistiveNormalization — the legacy per-flag grammarConfig plumbing that bridged behavior to premise-level enforcement is gone. Switching permissive → assistive makes the next successful Structural mutation trigger the AN pass; switching the other direction stops the AN pass from running until the user opts back in.

      Parameters

      • b: "assistive" | "permissive"

      Returns void

      1.0.0

    • Registers a listener that is called after every mutation.

      Parameters

      • listener: () => void

        The callback to invoke on mutation.

      Returns () => void

      An unsubscribe function that removes the listener.

    • Updates fields on an existing variable. Since all premises share the same VariableManager, the update is immediately visible everywhere.

      Parameters

      • variableId: string

        The ID of the variable to update.

      • updates: Record<string, unknown>

        Fields to update. For claim-bound variables: symbol, claimId, claimVersion. For premise-bound variables: symbol, boundPremiseId, boundArgumentId, boundArgumentVersion. claimId and claimVersion must be provided together on claim-bound variables.

      Returns TCoreMutationResult<TVar | undefined, TExpr, TVar, TPremise, TArg>

      The updated variable, or undefined if not found.

      If the new symbol is already in use by a different variable.

      If the new claim reference does not exist in the claim library.

      If updates include fields from the wrong binding type (e.g., boundPremiseId on a claim-bound variable).

      If the new boundPremiseId does not exist in this argument.

    • Four-tier grammar validation per spec §4. Returns the union of violations from Structural up through tier'structural' returns S-rule violations only, 'evaluable' returns S + E, 'derivable' returns S + E + D, 'presentable' returns the full union. Empty array means the argument is at the requested tier or stricter. Never throws on grammar issues.

      For the legacy pre-1.0 invariant sweep (schema conformance, reference integrity, ownership, conclusion ref, circularity, checksums) use validateInvariants instead. The pre-1.0 no-arg overload of validate() has been removed.

      Parameters

      • tier: "structural" | "evaluable" | "derivable" | "presentable"

      Returns readonly {
          argumentId?: string;
          claimId?: string;
          code:
              | "S-1"
              | "S-2"
              | "S-3"
              | "S-4"
              | "S-5"
              | "S-6"
              | "S-7"
              | "S-8"
              | "S-9"
              | "S-10"
              | "S-11"
              | "S-12"
              | "S-13"
              | "S-14"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5";
          expressionId?: string;
          message: string;
          premiseId?: string;
          tier: "structural"
          | "evaluable"
          | "derivable"
          | "presentable";
          variableId?: string;
      }[]

    • Returns the derivation-specific subset of validateEvaluability checks. Apps can pre-check derivation premise structures before invoking the full evaluation pipeline.

      Violations carry the underlying DERIVATION_STRUCTURE_INVALID code (per the derivation-validation utility). The pre-1.0 DERIVATION_STRUCTURE_INVALID_AT_EVALUATION override was removed alongside the legacy validate() no-arg overload — naked-Q is a valid Derivable state (per spec §4.2) and is skipped by evaluation rather than thrown.

      Returns TInvariantValidationResult

      0.11.0

    • Validates that this argument is structurally ready for evaluation: a conclusion must be set, all role references must point to existing premises, variable ID/symbol mappings must be consistent, every premise must be individually evaluable, and all derivation premise structures must be well-formed (naked-Q invariant; since 0.11.0).

      Derivation premises with structurally broken trees are flagged with DERIVATION_STRUCTURE_INVALID. Use validateDerivationStructures() to isolate derivation checks without running the full evaluability sweep.

      Naked-Q derivation premises (single-variable root) are not flagged — they are a valid Derivable state per spec §4.2 and are skipped by evaluation rather than throwing. The pre-1.0 DERIVATION_STRUCTURE_INVALID_AT_EVALUATION code has been removed.

      Returns TCoreValidationResult

      A validation result with any issues found.

      0.11.0 — derivation pre-flight added to the sweep.

    • Legacy invariant sweep — schema conformance, reference integrity, ownership, conclusion-ref + circularity, checksum stability, and per-premise validation. Returns a TInvariantValidationResult. Used internally by mutation-rollback and snapshot-load paths and exposed publicly for library-wide invariant checks (see ArgumentLibrary.validate and PropositCore.validate).

      Distinct from validate, which runs the four-tier grammar validator (Structural ⊇ Evaluable ⊇ Derivable ⊇ Presentable) and returns a readonly TViolation[]. The two are complementary — grammar tiers cover AST-shape rules; this method covers schema/reference/structural-bookkeeping invariants that sit outside the tier hierarchy.

      Returns TInvariantValidationResult

      1.0.0 — replaces the legacy validate() no-arg overload, which has been removed.

    • Creates a new ArgumentEngine from flat arrays of entities, as typically stored in a relational database. Expressions are grouped by their premiseId field and loaded in BFS order (roots first, then children of already-added nodes) to satisfy parent-existence requirements.

      Type Parameters

      • TArg extends {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            version: number;
        } = {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            version: number;
        }
      • TPremise extends
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "freeform";
            }
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                derivedClaimId: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "derivation";
            } =
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "freeform";
            }
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                derivedClaimId: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "derivation";
            }
      • TExpr extends TCorePropositionalExpression = TCorePropositionalExpression
      • TVar extends
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                claimId: string;
                claimVersion: number;
                id: string;
                symbol: string;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundPremiseId: string;
                checksum: string;
                id: string;
                symbol: string;
            } =
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                claimId: string;
                claimVersion: number;
                id: string;
                symbol: string;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundPremiseId: string;
                checksum: string;
                id: string;
                symbol: string;
            }
      • TClaim extends {
            checksum: string;
            frozen: boolean;
            id: string;
            type: "normal" | "citation" | "axiomatic";
            version: number;
        } = {
            checksum: string;
            frozen: boolean;
            id: string;
            type: "normal" | "citation" | "axiomatic";
            version: number;
        }

      Parameters

      Returns ArgumentEngine<TArg, TPremise, TExpr, TVar, TClaim>

    • Creates a new ArgumentEngine from a previously captured snapshot.

      Type Parameters

      • TArg extends {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            version: number;
        } = {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            version: number;
        }
      • TPremise extends
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "freeform";
            }
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                derivedClaimId: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "derivation";
            } =
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "freeform";
            }
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                combinedChecksum: string;
                derivedClaimId: string;
                descendantChecksum: string
                | null;
                id: string;
                type: "derivation";
            }
      • TExpr extends TCorePropositionalExpression = TCorePropositionalExpression
      • TVar extends
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                claimId: string;
                claimVersion: number;
                id: string;
                symbol: string;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundPremiseId: string;
                checksum: string;
                id: string;
                symbol: string;
            } =
            | {
                argumentId: string;
                argumentVersion: number;
                checksum: string;
                claimId: string;
                claimVersion: number;
                id: string;
                symbol: string;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundPremiseId: string;
                checksum: string;
                id: string;
                symbol: string;
            }
      • TClaim extends {
            checksum: string;
            frozen: boolean;
            id: string;
            type: "normal" | "citation" | "axiomatic";
            version: number;
        } = {
            checksum: string;
            frozen: boolean;
            id: string;
            type: "normal" | "citation" | "axiomatic";
            version: number;
        }

      Parameters

      Returns ArgumentEngine<TArg, TPremise, TExpr, TVar, TClaim>