proposit-core
    Preparing search index...

    Interface TVariableManagement<TArg, TPremise, TExpr, TVar>

    Variable CRUD and lookup across the argument.

    interface TVariableManagement<
        TArg extends TCoreArgument = TCoreArgument,
        TPremise extends TCorePremise = TCorePremise,
        TExpr extends TCorePropositionalExpression = TCorePropositionalExpression,
        TVar extends TCorePropositionalVariable = TCorePropositionalVariable,
    > {
        addVariable(
            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>,
        ): TCoreMutationResult<TVar, TExpr, TVar, TPremise, TArg>;
        bindVariableToPremise(
            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>,
        ): TCoreMutationResult<TVar, TExpr, TVar, TPremise, TArg>;
        buildVariableIndex<K>(keyFn: (v: TVar) => K): Map<K, TVar>;
        ensureClaimBoundVariable(
            claimId: string,
        ): {
            argumentId: string;
            argumentVersion: number;
            checksum: string;
            claimId: string;
            claimVersion: number;
            id: string;
            symbol: string;
        };
        getVariable(variableId: string): TVar | undefined;
        getVariableBySymbol(symbol: string): TVar | undefined;
        getVariables(): TVar[];
        getVariablesBoundToPremise(premiseId: string): TVar[];
        hasVariable(variableId: string): boolean;
        removeVariable(
            variableId: string,
        ): TCoreMutationResult<TVar | undefined, TExpr, TVar, TPremise, TArg>;
        updateVariable(
            variableId: string,
            updates: Record<string, unknown>,
        ): TCoreMutationResult<TVar | undefined, TExpr, TVar, TPremise, TArg>;
    }

    Type Parameters

    Implemented by

    Index

    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.

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

    • Idempotent lookup-or-create for a claim-bound variable. If a claim-bound variable for claimId already exists in this argument, it is returned as-is. Otherwise a new variable is created with a fresh UUID, the current version of the claim from the ClaimLibrary, and an auto-generated symbol.

      This method is used internally by derivation premise initialization but is also available to callers that need to pin a claim as a propositional variable without creating a full premise.

      Parameters

      • claimId: string

        The ID of the claim to bind a variable to.

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

      The existing or newly created TClaimBoundVariable.

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

      0.11.0

    • Returns all premise-bound variables whose boundPremiseId matches the given premise 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.

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