<< lib/moral-capacitor/SLMoralCapacitor.sleela SLeeLa Standard Library Definition. Definition: Defines SLMoralCapacitor(TM) — the ethical gate every /lib library can place in front of a consequential operation. Like an electrical capacitor it accumulates charge and only discharges when enough has built up; here the charge is moral justification contributed by ethical frameworks (deontology, utilitarianism, virtue, beneficence, consent) and the discharge is permission to proceed. An operation runs only when stored charge reaches the policy threshold AND no absolute red line (SLMoralVeto) is tripped. Lifecycle: configure() -> appraise(operation) charges from the frameworks and arms vetoes -> evaluate(threshold) returns an SLMoralVerdict (PERMIT / DEFER / DENY) -> discharge() resets the stored charge so the capacitor is reusable. Family: moral-capacitor. Composes SLMoralCharge, SLMoralVeto, SLMoralFramework, SLMoralPolicy; returns SLMoralVerdict. >> #sleela 2.5 material; class SLMoralCapacitor { < ---- Descriptive metadata (version 1.11 nested-friendly accessors) ---- > << Eleven catalogued attributes with getter/setter pairs, so a GUI, loader, or catalog can read and (where appropriate) override this record. Values are faithful to the subject's real origin where publicly known. >> String metaVersion = "1.0.0"; int metaId = 10908; String metaAuthor = "Kiro Agent"; String metaDate = "2026-10-16"; String metaCopyright = "SLeeLa project"; String metaTrademark = "none"; String metaCorporation = "none"; < metaOrigin: National | | International | Galactic > String metaOrigin = "International"; String metaBirthDate = "2026-10-10"; < metaScienceRating: maturity/robustness on a 1..10 scale > int metaScienceRating = 9; < metaNationalSchedule: a real, citable instrument or "none" > String metaNationalSchedule = "none"; String getMetaVersion() { return metaVersion; } void setMetaVersion(String v) { metaVersion = v; } int getMetaId() { return metaId; } void setMetaId(int v) { metaId = v; } String getAuthor() { return metaAuthor; } void setAuthor(String v) { metaAuthor = v; } String getDate() { return metaDate; } void setDate(String v) { metaDate = v; } String getCopyright() { return metaCopyright; } void setCopyright(String v) { metaCopyright = v; } String getTrademark() { return metaTrademark; } void setTrademark(String v) { metaTrademark = v; } String getCorporation() { return metaCorporation; } void setCorporation(String v) { metaCorporation = v; } String getOrigin() { return metaOrigin; } void setOrigin(String v) { metaOrigin = v; } String getBirthDate() { return metaBirthDate; } void setBirthDate(String v) { metaBirthDate = v; } int getScienceRating() { return metaScienceRating; } void setScienceRating(int v) { metaScienceRating = v; } String getNationalSchedule() { return metaNationalSchedule; } void setNationalSchedule(String v) { metaNationalSchedule = v; } SLMoralCharge storedCharge; SLMoralVeto vetoes; SLMoralPolicy activePolicy; SLMoralOperation lastOp; int configured; void configure() { < capacity 16 > storedCharge = new SLMoralCharge(); storedCharge.configure(16); vetoes = new SLMoralVeto(); vetoes.configure(); activePolicy = new SLMoralPolicy(); activePolicy.vmDefault(); lastOp = null; configured = 1; } void setPolicy(SLMoralPolicy policy) { activePolicy = policy; } SLMoralPolicy policy() { return activePolicy; } < ---- Manual charging (a library may charge explicitly) ------------------ > < Add a framework's signed moral contribution. > void charge(int frameworkOrdinal, int delta) { storedCharge.add(frameworkOrdinal, delta); } < Arm a red line with a reason. > void arm(int redline, String reason) { vetoes.trip(redline, reason); } < ---- Automatic appraisal (frameworks score the operation) --------------- > < Charge the capacitor from each framework's reading of the operation, and > < arm any red line the operation plainly crosses. This is the default, > < honest appraisal; a library may follow it with additional charge/arm calls. > void appraise(SLMoralOperation op) { lastOp = op; < Consent / autonomy: a consented operation earns charge; a non-consented, > < irreversible one loses charge and (under a consent-requiring policy) trips > < the irreversible-harm red line. > if (op.hasConsent()) { storedCharge.add(SLMoralFramework.CONSENT, 2); } else { storedCharge.add(SLMoralFramework.CONSENT, -2); if (!op.isReversible() && activePolicy.consentRequired()) { vetoes.trip(SLMoralVeto.IRREVERSIBLE_HARM, "non-consensual irreversible operation on " + op.targetName()); } } < Beneficence: reversible operations are safer (do-no-harm); irreversible > < ones must justify themselves elsewhere. > if (op.isReversible()) { storedCharge.add(SLMoralFramework.BENEFICENCE, 2); } else { storedCharge.add(SLMoralFramework.BENEFICENCE, -1); } < Deontology: a duty to respect declared consent and scope. A consented, > < in-scope operation satisfies duty. > if (op.hasConsent()) { storedCharge.add(SLMoralFramework.DEONTOLOGY, 1); } < Utilitarianism: routine, reversible work tends to net positive utility. > if (op.isReversible()) { storedCharge.add(SLMoralFramework.UTILITARIANISM, 1); } < Virtue ethics: a transparent, consented action is what a good agent does. > if (op.hasConsent() && op.isReversible()) { storedCharge.add(SLMoralFramework.VIRTUE_ETHICS, 1); } < Red lines keyed on the action/target vocabulary. These are conservative > < string checks; a library should also arm vetoes it detects directly. > screenRedLines(op); } < Conservative red-line screen over the operation's action/target words. > void screenRedLines(SLMoralOperation op) { String a = op.actionVerb(); String t = op.targetName(); if (a == "weaponize" || t == "cbrn" || t == "weapon") { vetoes.trip(SLMoralVeto.WEAPONS_CBRN, "operation enables a weapon/CBRN capability"); } if (a == "surveil" || a == "track") { if (!op.hasConsent()) { vetoes.trip(SLMoralVeto.NONCONSENSUAL_SURVEILLANCE, "tracking without consent"); } } if (a == "impersonate" || a == "spoof" || a == "phish") { vetoes.trip(SLMoralVeto.DECEPTION, "deception / impersonation"); } if (a == "spam" || a == "botnet" || a == "mass-abuse") { vetoes.trip(SLMoralVeto.SCALED_ABUSE, "scaled abuse"); } } < ---- The decision ------------------------------------------------------- > < Evaluate the stored charge against a threshold and the armed vetoes. > SLMoralVerdict evaluate(int threshold) { SLMoralVerdict v = new SLMoralVerdict(); int level = storedCharge.level(); < 1. A tripped red line denies regardless of charge. > if (vetoes.anyTripped()) { v.configure(SLMoralVerdict.DENY, level, threshold, "veto: " + firstTrippedName(), vetoes.reason()); return v; } < 2. Sufficient charge discharges -> permit. > if (level >= threshold) { v.configure(SLMoralVerdict.PERMIT, level, threshold, frameworkName(storedCharge.dominantFramework()), "sufficient moral charge"); return v; } < 3. Partial charge: defer if the policy allows, else fail closed to deny. > if (level > 0 && activePolicy.defersAllowed()) { v.configure(SLMoralVerdict.DEFER, level, threshold, frameworkName(storedCharge.dominantFramework()), "insufficient charge; more justification or consent required"); return v; } < 4. No basis (or fail-closed policy) -> deny. > v.configure(SLMoralVerdict.DENY, level, threshold, "none", "no sufficient moral basis to proceed"); return v; } < Evaluate against the active policy's threshold. > SLMoralVerdict decide() { return evaluate(activePolicy.threshold()); } < One-call gate: appraise an operation under the active policy and decide. > SLMoralVerdict gate(SLMoralOperation op) { appraise(op); return decide(); } < Reset stored charge and vetoes so the capacitor can judge the next op. > void discharge() { storedCharge.reset(); vetoes = new SLMoralVeto(); vetoes.configure(); lastOp = null; } < ---- Introspection ------------------------------------------------------ > int chargeLevel() { return storedCharge.level(); } SLMoralCharge charge() { return storedCharge; } SLMoralVeto vetoSet() { return vetoes; } String firstTrippedName() { int i = 1; while (i <= SLMoralVeto.REDLINE_COUNT) { if (vetoes.isTripped(i)) { return vetoes.redlineName(i); } i = i + 1; } return "none"; } String frameworkName(int ordinal) { if (ordinal == 0) { return "none"; } SLMoralFramework f = new SLMoralFramework(); f.configure(ordinal); return f.name(); } }