fix: close out remaining audit findings — type safety, equivalence, deprecations
lower-to-canonical.ts: clauseEquivalent now compares compoundOperator and compoundGroupId. Previously, compound assertions with different operators (.and vs .or) were considered equivalent. fol-compiler.ts: adaptGrammarFormulaToLogicAst validates node.kind against known formula kinds (forall/exists/and/or/not/implies/predicate) before passing through as FormulaNode. Previously any object with a 'kind' property was blindly cast. predicates.ts / registry.ts: @deprecated tags on globalPredicateRegistry and globalClauseRegistry. Both are still functional but consumers should transition to explicit injection via LogicEngineOptions / EvaluationOptions. 454 solver+DSL tests pass, zero regressions.
This commit is contained in:
@@ -36,12 +36,15 @@ import { FluentQuantifier as FQ, FluentRelation as FR } from 'imhotep-dsl'
|
||||
* - If the node has a `type` property, it's in grammar.ts shape and needs conversion.
|
||||
*/
|
||||
function adaptGrammarFormulaToLogicAst(node: any): FormulaNode {
|
||||
// Already in logic-ast.ts shape — pass through
|
||||
if (node && typeof node === 'object' && 'kind' in node) {
|
||||
return node as FormulaNode
|
||||
const kind = node.kind
|
||||
if (kind === 'forall' || kind === 'exists' || kind === 'and' || kind === 'or' ||
|
||||
kind === 'not' || kind === 'implies' || kind === 'predicate') {
|
||||
return node as FormulaNode
|
||||
}
|
||||
throw new TypeError(`Unknown formula kind: ${kind}`)
|
||||
}
|
||||
|
||||
// Not an object or null — cannot adapt
|
||||
if (!node || typeof node !== 'object') {
|
||||
throw new TypeError('Cannot adapt non-object formula node')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user