import MemoryBudgetError from "../errors/MemoryBudgetError.js";
import MemoryCapabilityPosture from "./MemoryCapabilityPosture.js";
/** One named bounded-memory capability and its current runtime truth posture. */
export default class MemoryCapability {
    name;
    posture;
    evidence;
    note;
    constructor(fields) {
        const validFields = requireMemoryCapabilityFields(fields);
        this.name = requireNonEmptyString(validFields.name, 'name');
        this.posture = normalizePosture(validFields.posture);
        this.evidence = requireNonEmptyString(validFields.evidence, 'evidence');
        this.note = requireNonEmptyString(validFields.note, 'note');
        Object.freeze(this);
    }
}
function requireMemoryCapabilityFields(fields) {
    if (fields !== null && typeof fields === 'object') {
        return fields;
    }
    throw new MemoryBudgetError('MemoryCapability requires object fields', {
        code: 'E_MEMORY_CAPABILITY_INVALID',
        context: { field: 'fields' },
    });
}
function normalizePosture(value) {
    if (value instanceof MemoryCapabilityPosture) {
        return value;
    }
    return new MemoryCapabilityPosture(value);
}
function requireNonEmptyString(value, field) {
    if (typeof value === 'string' && value.trim().length > 0) {
        return value;
    }
    throw new MemoryBudgetError('Memory capability requires non-empty fields', {
        code: 'E_MEMORY_CAPABILITY_INVALID',
        context: { field },
    });
}
