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

    Properties

    Accessors

    Methods

    Constructors

    • Type Parameters

      • TArg extends {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            respondsTo?: { argumentId: string; argumentVersion: number };
            version: number;
        } = {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            respondsTo?: { argumentId: string; argumentVersion: number };
            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;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundAspect: "statement"
                | "inference";
                boundExpressionId: 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;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundAspect: "statement"
                | "inference";
                boundExpressionId: 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 an expression-bound variable to a response: a variable that stands for one expression of the argument the response answers, either its truth (boundAspect: "statement") or whether its step holds ("inference"). Only a response may hold one, and it binds only into the argument and version named by respondsTo. A variable with the same referent — the same expression and aspect — is returned instead of a second one being added.

      Parameters

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

      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

    • Whether one link of this response follows from the response's other premises, read against the snapshot of the argument it answers. Each statement link is expanded into the expression it names, so the question is asked of what the links say rather than of the links as opaque values. See TLinkCheckResult for each answer.

      Answers invalid, without searching, when the snapshot is not the argument and version this response answers or validateLinks reports a problem.

      Parameters

      Returns TLinkCheckResult

      When this argument is not a response, or the premise is not one of its links.

    • Enumerates all 2^n variable assignments and checks for counterexamples.

      A counterexample is an admissible assignment where all supporting premises are true but the conclusion is false. The argument is valid if no counterexamples exist. This is the exhaustive entailment check; the single-assignment premisesHoldConclusionFalse fact is a weaker, reader-relative statement and not a countermodel.

      Premise-set satisfiability is computed once before the row loop and threaded into each row, since the generated assignments carry no operator decisions and the premise set never varies.

      Grounded claim-bound variables — axiomatic and citation — are excluded from the enumeration and pinned true on every row, so an argument with g of them enumerates 2^(k - g) assignments and no counterexample can rest on a cited claim reading false. Evaluation is deliberately different: it answers the reader's question, where a citation is only seeded true and remains assignable.

      Calls validateEvaluability() (including derivation pre-flight) before enumeration. If the argument is not evaluable, returns early with an appropriate result rather than throwing.

      Parameters

      Returns TCoreValidityCheckResult

      The validity check result including any counterexamples. A response always answers { ok: false } with ARGUMENT_IS_RESPONSE.

    • Clears the conclusion designation.

      Invariant guard: 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).

      A response is the exception: it has no conclusion (E-7 exempts it, E-8 reports one it was stored with), so the call always clears.

      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,
      >

    • Derives a default truth-value assignment for every variable in the argument, from claim type and immediate support structure alone. Values are true or null (unknown) — never false.

      D(claim) for the variable backing claim c:

      1. c is a citation or axiomatic claim → true.
      2. c is a normal claim: locate its derivation premise (the inference whose consequent is c's variable). Seed each variable referenced in that premise's immediate antecedent true iff it is itself bound to a citation/axiomatic claim, else null, and Kleene-evaluate the antecedent once. Antecedent true → true; otherwise null. No recursion — only the immediate antecedent claims' types are inspected, never their own supports.
      3. Anything else (no derivation premise, naked-Q derivation, a premise-bound variable) → null.

      The returned map is variable-keyed; use getVariableIdForClaim / getClaimIdForVariable to translate to/from claimId.

      Consistency with the axiomatic pre-pass: evaluate force-sets axiomatic-bound variables true and rejects any explicit assignment for them (AXIOM_VARIABLE_ASSIGNMENT_FORBIDDEN). This map reports those same variables as true (the two agree), but the axiom keys must not be passed to evaluate directly. Feed the map through evaluateWithDefaults (which drops them), or strip axiomatic-bound keys before calling evaluate yourself.

      Returns TCoreVariableAssignment

      3.1.0

    • 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"
              | "S-15"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "E-8"
              | "E-9"
              | "E-10"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5"
              | "P-6";
          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

    • Evaluates the argument under a three-valued expression assignment.

      Variables may be assigned true, false, or null (unknown). Evaluation reports a fourth value, CONTESTED, for anything the reader's assignments and the steps they granted force both true and false; null still means indeterminate. isAdmissibleAssignment, survivingSupportingPremisesTrue, conclusionTrue and premisesHoldConclusionFalse all range over the four values; premiseSetSatisfiable stays three-valued, since it is a classical search over the premise set alone.

      The result is a set of orthogonal facts, not a single outcome. In particular survivingSupportingPremisesTrue covers the argument's authored supporting premises — derivation premises are excluded, being engine wiring rather than authored support — and is vacuously true when every one of them is struck, so whether the argument reached its conclusion is conclusionAttribution.reachedWithoutAssertion and never that field. A rejected operator strikes its whole premise and asserts nothing.

      Calls validateEvaluability() internally before evaluation; if the argument is not structurally ready (including derivation pre-flight), the method returns early with { ok: false } and the validation details. Do not bypass evaluate to avoid this check.

      Axiomatic-bound variables are forced true by this method's pre-pass and passed down as forcedTrueVariableIds, so they are never read back as reader assertions and never enter the reached-without-assertion counterfactual. A caller's own forcedTrueVariableIds is unioned with that set, never substituted for it.

      The premise-set satisfiability search is given a wider set — satisfiabilityForcedTrueVariableIds, every grounded variable, citation as well as axiomatic. Whether the premises can hold together is a question about the argument, so a cited claim is taken at its source's word there, exactly as checkValidity does. The two sets are separate because the narrower one also decides what counts as the reader's own assertion, and a reader may disagree with a source: a citation belongs in the satisfiability question and not in that one.

      Parameters

      Returns TCoreArgumentEvaluationResult

      The evaluation result, or { ok: false } with validation details if the argument is not structurally evaluable. A response always answers { ok: false } with ARGUMENT_IS_RESPONSE: it has no conclusion to evaluate against; use checkLink and checkResponseCoherent.

    • Convenience: merge caller overrides over deriveDefaultAssignment() and evaluate in one call. Default-sourced axiomatic-bound keys are dropped before evaluation — the engine's pre-pass force-sets them true and rejects explicit axiom assignments, so passing the default true through would throw AXIOM_VARIABLE_ASSIGNMENT_FORBIDDEN. Dropping them keeps deriveDefaultAssignment (which reports axioms as true) and the pre-pass in agreement without double-applying. An override that names an axiomatic variable is left intact, so evaluate still enforces the one-way rule.

      Citations are different from axioms. The engine does not force citation-bound variables true and does not reject an explicit citation assignment — a citation is a free variable, so its default true is kept here (dropping it would leave the citation unknown at evaluation). Both citations and axioms read as true under defaults, but only the axiom true comes from the engine; the citation true is supplied by this map. That also makes citation defaults reviewer- overridable, whereas axioms stay locked.

      operatorAssignments is passed to evaluate unchanged; without it no operator decision is made. Values carried from a response go in overrides and operatorAssignments through mergeCarriedInput, so the order is defaults, then carried values, then the reader's own.

      Parameters

      Returns TCoreArgumentEvaluationResult

      3.1.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

    • Returns the claimId a claim-bound variable is bound to, or undefined when the variable is unknown or premise-bound (premise-bound variables have no claim). Inverse of getVariableIdForClaim.

      Parameters

      • variableId: string

      Returns string | undefined

      3.1.0

    • Returns the ID of the lowest-id claim-bound variable bound to claimId in this argument, or undefined if no variable is. Pure lookup — it never creates a variable (contrast ensureClaimBoundVariable).

      The engine's evaluation surface is variable-keyed, but consumers key their review/UI state by claimId; this accessor (with its inverse getClaimIdForVariable) is the documented seam for translating between the two.

      It answers for one variable, and a claim may bind several. The pick is deterministic and snapshot-stable — variables enumerate sorted by id — but arbitrary with respect to the claim: it is not "the authored one" or "the one an evaluation settled". When a claim may bind more than one and losing the others would be wrong, use getVariableIdsForClaim.

      Parameters

      • claimId: string

      Returns string | undefined

      3.1.0

    • Returns the IDs of every claim-bound variable bound to claimId in this argument, in the engine's id-sorted variable order, or [] when none is. Pure lookup — it never creates a variable (contrast ensureClaimBoundVariable).

      A claim may bind more than one variable: addVariable enforces no per-claim uniqueness, so an argument can carry several variables standing for the same proposition, each reached — and valued — independently by evaluation. Any translation that must not lose one of them (reading propagated values back onto a claim, say) belongs here rather than on the singular accessor.

      Parameters

      • claimId: string

      Returns string[]

      4.1.0

    • Returns the premise-bound variables bound to the given premise of this argument. A variable bound into another argument is never included, even when that argument's premise has the same ID. This is a linear scan over all variables.

      Parameters

      • premiseId: string

        The premise ID to filter by.

      Returns TVar[]

      An array of variables bound to the given premise.

    • Global normalize pass. 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.

      Every AN rule currently targets a Presentable invariant, so calls with tier ∈ {'structural', 'evaluable', 'derivable'} are effectively no-ops. The parameter is reserved so a future submit/finalize gate can add lower-tier rules without an API break.

      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, and marks the expression dirty — callers cannot patch without marking (stale checksum) or mark without patching (no-op). A field whose value is undefined is deleted rather than assigned, so clearing one restores the shape and the checksum the entity had before it was set.

      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

    • Moves a response to a newer version of the argument it answers.

      The classification is computed again here, as classifyBindings computes it, from targetFrom, targetTo and options. Then:

      • respondsTo becomes targetTo;
      • every unchanged binding is re-pointed to targetTo;
      • every changed or removed binding takes its decision from decisions.bindings: keep re-points it to the same expression, retarget to another expression of targetTo in the same aspect, and drop removes it with every premise its entry lists;
      • the response's claim-bound variables are left alone, whether or not either version uses their claims.

      Before returning, it checks that every expression-bound variable is bound to targetTo and names an expression present there, and that validateLinks against targetTo reports no fault, by code, variable and expression, that it did not report before. Any failure undoes the whole rebase. The changeset holds the argument with its new respondsTo and every variable re-pointed, added or removed.

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

      The classification the rebase acted on.

      When this argument is not a response, or the snapshots are not versions of the argument it answers; when canBind refuses targetTo; when a changed or removed binding has no decision, or a decision names a variable needing none; when a removed binding is kept; when a retarget names an expression absent from targetTo; when a keep or retarget would bind an expression another variable already binds in the same aspect; or when the check above fails.

    • 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"
              | "S-15"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "E-8"
              | "E-9"
              | "E-10"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5"
              | "P-6";
          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"
              | "S-15"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "E-8"
              | "E-9"
              | "E-10"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5"
              | "P-6";
          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: 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 (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"
              | "S-15"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "E-8"
              | "E-9"
              | "E-10"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5"
              | "P-6";
          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.

      Behavior is enforced entirely via the AN post-mutation hook in runAssistiveNormalization. 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. For expression-bound variables: symbol only — rebaseResponse re-points them. 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 updates change an expression-bound variable's binding fields.

      If the new boundPremiseId does not exist in this argument.

    • Four-tier grammar validation. 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 invariant sweep (schema conformance, reference integrity, ownership, conclusion ref, circularity, checksums) use validateInvariants instead.

      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"
              | "S-15"
              | "E-1"
              | "E-3"
              | "E-4"
              | "E-5"
              | "E-6"
              | "E-7"
              | "E-8"
              | "E-9"
              | "E-10"
              | "D-1"
              | "D-2"
              | "D-3"
              | "D-4"
              | "D-5"
              | "D-6"
              | "P-1"
              | "P-2"
              | "P-3"
              | "P-4"
              | "P-5"
              | "P-6";
          expressionId?: string;
          message: string;
          premiseId?: string;
          tier: "structural"
          | "evaluable"
          | "derivable"
          | "presentable";
          variableId?: string;
      }[]

    • 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 and are skipped by evaluation rather than throwing.

      Returns TCoreValidationResult

      A validation result with any issues found.

      0.11.0 — derivation pre-flight added to the sweep.

    • 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

    • 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;
            respondsTo?: { argumentId: string; argumentVersion: number };
            version: number;
        } = {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            respondsTo?: { argumentId: string; argumentVersion: number };
            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;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundAspect: "statement"
                | "inference";
                boundExpressionId: 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;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundAspect: "statement"
                | "inference";
                boundExpressionId: 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;
            respondsTo?: { argumentId: string; argumentVersion: number };
            version: number;
        } = {
            checksum: string;
            combinedChecksum: string;
            descendantChecksum: string | null;
            id: string;
            respondsTo?: { argumentId: string; argumentVersion: number };
            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;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundAspect: "statement"
                | "inference";
                boundExpressionId: 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;
            }
            | {
                argumentId: string;
                argumentVersion: number;
                boundArgumentId: string;
                boundArgumentVersion: number;
                boundAspect: "statement"
                | "inference";
                boundExpressionId: 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>