import { type TClaimBoundVariable, type TPremiseBoundVariable, type TExpressionBoundVariable, type TCoreArgument, type TCoreArgumentReference, type TCoreClaim, type TCorePremise, type TCorePropositionalExpression, type TCorePropositionalVariable, type TOptionalChecksum } from "../schemata/index.js"; import { type TClassifyBindingsOptions } from "./response/rebase.js"; import type { TBindingClassificationResult, TRebaseDecisions } from "../types/response.js"; import type { TCoreArgumentEvaluationOptions, TCoreArgumentEvaluationResult, TCoreArgumentRoleState, TCoreExpressionAssignment, TCoreValidationResult, TCoreValidityCheckOptions, TCoreValidityCheckResult, TCoreOperatorAssignment, TCoreVariableAssignment } from "../types/evaluation.js"; import type { TLinkCheckResult, TCarryAnswersOptions, TCarryResult, TLinkAnswer, TResponseCoherenceResult } from "../types/response.js"; import type { TCoreChecksumConfig } from "../types/checksum.js"; import type { TCorePositionConfig } from "../utils/position.js"; import type { TInvariantValidationResult } from "../types/validation.js"; import type { TCoreMutationResult } from "../types/mutation.js"; import type { TReactiveSnapshot } from "../types/reactive.js"; import { HierarchicalChecksumCache } from "./checksum-cache.js"; import type { TExpressionInput } from "./expression-manager.js"; import { type TPopulateResult } from "../grammar/populate-from.js"; import type { TGrammarTier, TViolation } from "../grammar/types.js"; import type { TCoreClaimConnection } from "../schemata/claim-connection.js"; import type { TClaimConnectionLookup } from "./interfaces/library.interfaces.js"; import { PremiseEngine } from "./premise-engine.js"; import type { TPremiseEngineSnapshot } from "./premise-engine.js"; import type { TVariableManagerSnapshot } from "./variable-manager.js"; import type { TPremiseCrud, TVariableManagement, TArgumentExpressionQueries, TArgumentRoleState, TArgumentEvaluation, TArgumentLifecycle, TArgumentIdentity, TDisplayable, THierarchicalChecksummable, TClaimLookup } from "./interfaces/index.js"; /** Default ID generator using the Web Crypto API (Node.js 20+, all modern browsers). */ export declare const defaultGenerateId: () => string; export type TLogicEngineOptions = { checksumConfig?: TCoreChecksumConfig; positionConfig?: TCorePositionConfig; /** * Engine behavior. Controls whether the auto-normalization (AN) rule * set runs as a post-hook after every successful Structural mutation. * * - `'assistive'` (default): AN runs after every successful Structural * mutation. AN preserves Presentable — if the pre-mutation state was * Presentable, the post-mutation state is Presentable. * - `'permissive'`: AN does not run. The engine accepts mutations that * leave the argument outside the Presentable/Derivable/Evaluable * tiers (down to but not including Structural, which is always * guaranteed). * * Switchable at runtime via `engine.setBehavior(...)`. See * `docs/Proposit_Grammar.md` §4 for the full contract. * * @since 1.0.0 */ behavior?: "assistive" | "permissive"; /** UUID generator for new entity IDs. Defaults to `globalThis.crypto.randomUUID()`. */ generateId?: () => string; }; export type TArgumentEngineSnapshot = { argument: TOptionalChecksum; variables: TVariableManagerSnapshot; premises: TPremiseEngineSnapshot[]; conclusionPremiseId?: string; config?: TLogicEngineOptions; }; /** * 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. */ export declare class ArgumentEngine extends HierarchicalChecksumCache implements TPremiseCrud, TVariableManagement, TArgumentExpressionQueries, TArgumentRoleState, TArgumentEvaluation, TArgumentLifecycle, TArgumentIdentity, TDisplayable, THierarchicalChecksummable<"premises" | "variables"> { private argument; private premises; private variables; private claimLibrary; private conclusionPremiseId; private checksumConfig?; private positionConfig?; private engineBehavior; private generateId; private restoringFromSnapshot; private applyingAN; private normalizationChanges; private cachedPremisesCollectionChecksum; private cachedVariablesCollectionChecksum; private expressionIndex; private listeners; private reactiveDirty; private cachedReactiveSnapshot; constructor(argument: TOptionalChecksum, claimLibrary: TClaimLookup, options?: TLogicEngineOptions); private createCircularityCheck; /** * The state the circularity check under `argument/` reads, built per call * and read once per call, as `asClaimVariableContext` is. */ private asCycleContext; private wireCircularityCheck; private wireEmptyBoundPremiseCheck; /** * Connects a premise engine to this argument: the circularity and * empty-bound-premise checks, the source of known variable ids, the * argument-level validation run after each premise mutation, the * change notification, and the normalization follow-up. Every place * that adds a premise engine to `this.premises` calls this once. */ private wirePremiseEngine; private wireArgumentValidation; private generateUniqueSymbol; subscribe: (listener: () => void) => (() => void); protected notifySubscribers(): void; private finalizeChanges; /** * Runs after every premise mutation, given the changeset it built. In * assistive behavior it runs normalization and returns the mutation's * changeset with what normalization changed composed onto it, so the * mutation reports everything the call changed. Returns undefined, which * leaves the mutation's own changeset in place, when normalization is * off or changed nothing. While normalization is running, the mutations * it makes arrive here too, and are collected rather than normalized * again. */ private followUpWithNormalization; /** Every added and modified entry, at its current value in this engine. */ private withCurrentEntries; private static readonly skipValidationResult; private suppressPremiseValidation; private restorePremiseValidation; protected withValidation(fn: () => T): T; getSnapshot: () => TReactiveSnapshot; protected buildReactiveSnapshot(): TReactiveSnapshot; private buildVariablesRecord; private buildAllPremisesRecord; private buildPremiseRecord; private markReactiveDirty; /** * 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. * * @since 1.0.0 */ get behavior(): "assistive" | "permissive"; /** * Access to the engine's ID generator function. Used by in-package * helpers that build new entity trees and need fresh IDs (e.g. the * `populateFromGrounding` factory in * `src/lib/grammar/populate-from.ts`). The generator is captured * once at construction (default `crypto.randomUUID`) and stays * immutable for the engine's lifetime; this accessor returns the * same function reference on every call. * * Replaces the prior `(engine as unknown as { generateId: () => * string }).generateId` cast in `populate-from.ts`. The accessor is * marked `@internal` so it is not surfaced in generated API docs / * type bundles — the in-package factory callers are its intended * consumers; external programmatic-construction use cases should * supply their own generator rather than borrowing the engine's. * * @internal * @since 1.0.0 */ get idGenerator(): () => string; /** * 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. * * @since 1.0.0 */ setBehavior(b: "assistive" | "permissive"): void; /** * Acquire the AN re-entrance guard. Returns `true` iff the guard * was acquired (i.e. AN is not already running for this engine); * the caller is then obligated to call `endApplyAN()` after the * AN sweep. Returns `false` if AN is already in progress, in * which case the caller short-circuits to avoid nested AN * sweeps. * * Used by `applyANToFixedPoint` in `src/lib/grammar/an-rules.ts` * (the single chokepoint for both `runAssistiveNormalization` * and `normalizeArgument`). The post-mutation follow-up calls * `runAssistiveNormalization(this)` which delegates to * `applyANToFixedPoint`; AN's own mutations re-fire the follow-up, * which would otherwise recurse. This guard * breaks the recursion. * * @internal * @since 1.0.0 */ beginApplyAN(): boolean; /** * Release the AN re-entrance guard. Pairs with `beginApplyAN()`. * * @internal * @since 1.0.0 */ endApplyAN(): void; getArgument(): TArg; getExtras(): Record; setExtras(extras: Record): TCoreMutationResult, TExpr, TVar, TPremise, TArg>; updateExtras(updates: Record): TCoreMutationResult, TExpr, TVar, TPremise, TArg>; toDisplayString(): string; createPremise(): TCoreMutationResult, TExpr, TVar, TPremise, TArg>; createPremise(extras: Record | undefined, symbol: string): TCoreMutationResult, TExpr, TVar, TPremise, TArg>; createPremise(extras: Record, symbol?: string): TCoreMutationResult, TExpr, TVar, TPremise, TArg>; createPremise(options: { type?: "freeform" | "derivation"; derivedClaimId?: string; extras?: Record; symbol?: string; }): TCoreMutationResult, TExpr, TVar, TPremise, TArg>; createPremiseWithId(id: string, extras?: Record, symbol?: string): TCoreMutationResult, TExpr, TVar, TPremise, TArg>; createPremiseWithId(id: string, options: { type?: "freeform" | "derivation"; derivedClaimId?: string; extras?: Record; symbol?: string; }): TCoreMutationResult, TExpr, TVar, TPremise, TArg>; removePremise(premiseId: string): TCoreMutationResult; getPremise(premiseId: string): PremiseEngine | undefined; hasPremise(premiseId: string): boolean; listPremiseIds(): string[]; listPremises(): PremiseEngine[]; /** * Throws unless the variable names this engine's argument id and * version, checking the id first. The messages are part of what * callers see, so they must not change. */ private assertVariableInThisArgument; /** * Computes the variable's checksum and adds it to the variable manager. * Returns the stored variable. Records no change and marks nothing * dirty; each caller does that itself. */ private storeNewVariable; /** * Stores a new variable and returns it with a changeset listing it as * added, after marking every premise dirty. The shared ending of the * public methods that add one variable. */ private addNewVariable; addVariable(variable: TOptionalChecksum & Record): TCoreMutationResult; /** * 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. * * @throws InvariantViolationError(CLAIM_NOT_FOUND) when the claim is not in * the library. * * @since 0.11.0 */ ensureClaimBoundVariable(claimId: string): TClaimBoundVariable; bindVariableToPremise(variable: TOptionalChecksum & Record): TCoreMutationResult; /** Adds a premise-bound variable that references a premise in a different argument. */ bindVariableToExternalPremise(variable: TOptionalChecksum & Record): TCoreMutationResult; /** * 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. */ bindVariableToExpression(variable: TOptionalChecksum & Record): TCoreMutationResult; /** The argument this response answers, or `undefined` for a standard argument. */ getRespondsTo(): TCoreArgumentReference | undefined; private findExpressionBinding; /** * 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 The classification the rebase acted on. * @throws 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. */ rebaseResponse(targetFrom: TArgumentEngineSnapshot, targetTo: TArgumentEngineSnapshot, decisions: TRebaseDecisions, options?: TClassifyBindingsOptions): TCoreMutationResult; /** * Binds an expression-bound variable to another expression and version * of the argument the response answers. The only path that changes these * fields: `updateVariable` refuses them. */ private repointExpressionBinding; /** Adds a premise-bound variable that references another argument's conclusion premise. */ bindVariableToArgument(variable: Omit, "boundPremiseId"> & Record, conclusionPremiseId: string): TCoreMutationResult; updateVariable(variableId: string, updates: Record): TCoreMutationResult; private removeVariableCore; removeVariable(variableId: string): TCoreMutationResult; getVariables(): TVar[]; getVariable(variableId: string): TVar | undefined; /** * 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. * * @since 1.0.0 */ getClaim(claimId: string, claimVersion: number): TClaim | undefined; hasVariable(variableId: string): boolean; getVariableBySymbol(symbol: string): TVar | undefined; buildVariableIndex(keyFn: (v: TVar) => K): Map; getVariablesBoundToPremise(premiseId: string): TVar[]; getExpression(expressionId: string): TExpr | undefined; hasExpression(expressionId: string): boolean; getExpressionPremiseId(expressionId: string): string | undefined; findPremiseByExpressionId(expressionId: string): PremiseEngine | undefined; getAllExpressions(): TExpr[]; getExpressionsByVariableId(variableId: string): TExpr[]; listRootExpressions(): TExpr[]; /** * 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. * * @param expressionId - The ID of the expression to patch. * @param fields - Fields to merge into the expression. * @throws If no expression with the given ID exists. * * @since 2.3.1 */ patchExpressionAppFields(expressionId: string, fields: Partial): void; /** * 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: * }` 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). * * @since 1.0.0 */ populateFromCitations(derivedClaimId: string, citationLookup: TClaimConnectionLookup): TPopulateResult; /** * Mirror of `populateFromCitations` for axiom connections. Same * factory contract: naked-Q-only, no throw on already-populated. * * @since 1.0.0 */ populateFromAxioms(derivedClaimId: string, axiomLookup: TClaimConnectionLookup): TPopulateResult; /** * 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. * * @since 1.0.0 */ removeUnresolvableVariables(): readonly TViolation[]; /** * 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). * * @since 1.0.0 */ removeOrphanOperators(): readonly TViolation[]; /** * 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`. * * @since 1.0.0 */ removeDuplicateDerivationPremises(strategy?: "keep-first" | "keep-largest-antecedent"): readonly TViolation[]; /** * 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). * * @since 1.0.0 */ dropAxiomsFromMixedAntecedent(): readonly TViolation[]; /** * 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. * * @since 1.0.0 */ normalize(tier?: TGrammarTier): void; getRoleState(): TCoreArgumentRoleState; setConclusionPremise(premiseId: string): TCoreMutationResult; clearConclusionPremise(): TCoreMutationResult; getConclusionPremise(): PremiseEngine | undefined; listSupportingPremises(): PremiseEngine[]; /** * Whether this argument is a response: it carries `respondsTo`, the * argument it answers pinned to one version, and has no conclusion. */ isResponse(): boolean; /** * Whether a premise of a response is a link: its whole content is one * variable expression, or `NOT` over one, whose variable is bound to an * expression of the argument the response answers. */ private isLinkPremise; snapshot(): TArgumentEngineSnapshot; /** Creates a new ArgumentEngine from a previously captured snapshot. */ static fromSnapshot(snapshot: TArgumentEngineSnapshot, claimLibrary: TClaimLookup, checksumVerification?: "ignore" | "strict", generateId?: () => string): ArgumentEngine; /** * 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. */ static fromData(argument: TOptionalChecksum, claimLibrary: TClaimLookup, variables: TOptionalChecksum[], premises: TOptionalChecksum[], expressions: TExpressionInput[], roles: TCoreArgumentRoleState, config?: TLogicEngineOptions, checksumVerification?: "ignore" | "strict"): ArgumentEngine; rollback(snapshot: TArgumentEngineSnapshot): void; private rollbackInternal; getCollectionChecksum(name: "premises" | "variables"): string | null; flushChecksums(): void; private markDirty; /** Invalidate all premise checksums (e.g. after variable changes). */ private markAllPremisesDirty; private attachVariableChecksum; collectReferencedVariables(): { variableIds: string[]; byId: Record; bySymbol: Record; }; private validateAfterPremiseMutation; /** * 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 * {@link validateInvariants} instead. */ validate(tier: TGrammarTier): readonly TViolation[]; /** * 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 {@link 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. * * @since 1.0.0 */ validateInvariants(): TInvariantValidationResult; /** * Construct the pure-data `TValidatorContext` consumed by the * grammar-tier validators. Claims are gathered by walking the * engine's claim-bound variables and looking each one up in the * claim library — the `TClaimLookup` contract doesn't expose * iteration, so we materialize the referenced subset only. */ private asGrammarValidatorContext; validateEvaluability(): TCoreValidationResult; /** * 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). A naked-Q derivation * premise is a valid Derivable state and is skipped by evaluation * rather than thrown. * * @since 0.11.0 */ validateDerivationStructures(): TInvariantValidationResult; private collectDerivationStructureIssues; private collectDerivationViolations; private asValidationContext; private asEvaluationContext; evaluate(assignment: TCoreExpressionAssignment, options?: TCoreArgumentEvaluationOptions): TCoreArgumentEvaluationResult; /** * 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. * * @throws When this argument is not a response, or the premise is not one * of its links. */ checkLink(linkPremiseId: string, targetSnapshot: TArgumentEngineSnapshot): TLinkCheckResult; /** * Whether all of this response's premises can hold at once, read against * the snapshot of the argument it answers. Uses the same expansion as * `checkLink`, so the two never disagree: when the premises cannot all * hold, every link checks as `incoherent`. * * @throws When this argument is not a response. */ checkResponseCoherent(targetSnapshot: TArgumentEngineSnapshot): TResponseCoherenceResult; /** * Reads what a reader's answers on this response's links carry into the * argument it answers, one step along a chain of answers. See * `TCarryResult` and `TNotCarriedReason`. * * Answers `invalid`, without carrying anything, when this argument is not * a response, the snapshot is not the argument and version it answers, or * `validateLinks` reports an error. It never throws on an answer it cannot * carry. * * @param targetSnapshot - The argument answered, at the version answered. * @param linkAnswers - The reader's answers, keyed by link premise id. * @param targetClaims - Resolves the answered argument's claims at the * versions it binds, to tell which are axioms. */ carryAnswers(targetSnapshot: TArgumentEngineSnapshot, linkAnswers: Record, targetClaims: TClaimLookup, options?: TCarryAnswersOptions): TCarryResult; /** * What makes every check of this response against the snapshot answer * `invalid`: a snapshot of another argument or version, or an error * `validateLinks` reports. */ private responseLinkProblems; private asResponseCheckInput; checkValidity(options?: TCoreValidityCheckOptions): TCoreValidityCheckResult; /** * The state the claim/variable functions under `argument/` read, as a * plain object built per call (accessor properties on such a context * slowed evaluation measurably in the premise engine). The fields are read * once per call; only a rollback replaces the variable manager, and * nothing this library calls rolls back during a read. */ private asClaimVariableContext; /** * 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. * * @since 4.1.0 */ getVariableIdsForClaim(claimId: string): string[]; /** * 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`. * * @since 3.1.0 */ getVariableIdForClaim(claimId: string): string | undefined; /** * 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`. * * @since 3.1.0 */ getClaimIdForVariable(variableId: string): string | undefined; /** * 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. * * @since 3.1.0 */ deriveDefaultAssignment(): TCoreVariableAssignment; /** * 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. * * @since 3.1.0 */ evaluateWithDefaults(overrides?: TCoreVariableAssignment, options?: TCoreArgumentEvaluationOptions, operatorAssignments?: Record): TCoreArgumentEvaluationResult; /** * Override point for subclasses to prevent forking. When this returns * `false`, `forkArgument` will throw. */ canFork(): boolean; /** * Override point for subclasses to restrict cross-argument bindings. * When this returns `false`, `bindVariableToExternalPremise` will throw. */ protected canBind(_boundArgumentId: string, _boundArgumentVersion: number): boolean; } //# sourceMappingURL=argument-engine.d.ts.map