Files
core/src/ast/nodes/EvidenceBodyNode.js
T
John Dvorak 717ae1031e initial commit: @arbiter/core authorization engine with js-rigor hardening
Zanzibar-style authorization graph engine (direct/chain/TTU/defeasible/
binary modes, condensed snapshots, value relations) with 39 rigor test
campaigns. Includes fixes for snapshot binary writer/reader format
mismatch (snapshot-of-snapshot corruption), possibility write-boundary
validation, empty-graph snapshot serialization, relation lookup cache
direction collision, config-redefinition cache invalidation, binary
threshold semantics, defeasible compiled routing, and comparator
reason whitelisting.
2026-07-31 13:44:06 -07:00

83 lines
1.9 KiB
JavaScript

import { BaseNode } from './BaseNode.js';
/**
* AST node for evidence body containing statements
* Represents: { statement1; statement2; ... }
*/
export class EvidenceBodyNode extends BaseNode {
constructor(location = null) {
super('EvidenceBody', location);
this.statements = [];
}
/**
* Add a statement to the evidence body
* @param {BaseNode} statement - Statement to add
*/
addStatement(statement) {
this.statements.push(statement);
this.addChild(statement);
}
/**
* Get all statements of a specific type
* @param {string} type - Statement type to filter by
* @returns {BaseNode[]} Filtered statements
*/
getStatementsOfType(type) {
return this.statements.filter(stmt => stmt.type === type);
}
/**
* Get all direct evidence statements
* @returns {DirectEvidenceNode[]} Direct evidence statements
*/
getDirectEvidence() {
return this.getStatementsOfType('DirectEvidence');
}
/**
* Get all pattern matching statements
* @returns {PatternMatchNode[]} Pattern matching statements
*/
getPatternMatches() {
return this.getStatementsOfType('PatternMatch');
}
/**
* Get all defeasible logic statements
* @returns {DefeasibleLogicNode[]} Defeasible logic statements
*/
getDefeasibleLogic() {
return this.getStatementsOfType('DefeasibleLogic');
}
/**
* Get all fusion statements
* @returns {FusionNode[]} Fusion statements
*/
getFusions() {
return this.getStatementsOfType('Fusion');
}
/**
* Validate the evidence body
* @returns {string[]} Array of error messages
*/
validate() {
const errors = [];
// Validate each statement
this.statements.forEach((stmt, index) => {
const stmtErrors = stmt.validate ? stmt.validate() : [];
errors.push(...stmtErrors.map(err => `Statement ${index + 1}: ${err}`));
});
return errors;
}
toString() {
return `EvidenceBody(${this.statements.length} statements)`;
}
}