Home /Modules/moral-capacitor/SLMoralPolicy.sleela

SLMoralPolicy.sleela

lib/moral-capacitor/SLMoralPolicy.sleela · 95 line(s) · sleela

<< lib/moral-capacitor/SLMoralPolicy.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLMoralPolicy — a named moral stance a library applies
     consistently through the Moral Capacitor(TM). A policy bundles the discharge
     threshold (how much moral charge an operation needs to proceed) with the set
     of red lines that are armed for the surface, plus whether a DEFER is allowed
     or a partial charge should fail closed to DENY. The adapters ship ready
     policies: a lenient VM default, a strict OS-destructive policy, and a
     Machine-power policy.
   
   Making the stance a first-class object means a surface's ethical posture is
   declared once and reused, rather than re-expressed at every call site.
   
   Family: moral-capacitor. Consumed by SLMoralCapacitor and the adapters. >>
#sleela 2.5
material;
class SLMoralPolicy {
  < ---- 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 = 10917;
  String metaAuthor = "Kiro Agent";
  String metaDate = "2026-10-16";
  String metaCopyright = "SLeeLa project";
  String metaTrademark = "none";
  String metaCorporation = "none";
  < metaOrigin: National | <nation> | 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; }
  String label;
  < minimum charge to PERMIT >
  int dischargeThreshold;
  < 1: partial charge -> DEFER; 0: fail closed to DENY >
  int allowDefer;
  < 1: a non-consented irreversible op auto-trips a veto >
  int requireConsent;
  int configured;

  void configure(String name, int threshold) {
    label = name; dischargeThreshold = threshold; allowDefer = 1; requireConsent = 1;
    configured = 1;
  }

  < ---- Ready-made stances for the priority surfaces ---------------------- >
  < Routine VM work: a modest threshold, DEFER allowed. >
  void vmDefault() { configure("vm-default", 2); allowDefer = 1; requireConsent = 0; }
  < VM native/OS-bridge or process spawn: higher bar. >
  void vmBridge()  { configure("vm-bridge", 4); allowDefer = 1; requireConsent = 1; }
  < OS routine (read env, cwd): low bar. >
  void osRoutine() { configure("os-routine", 2); allowDefer = 1; requireConsent = 0; }
  < OS destructive (remove/format/install to disk): high bar, consent required, >
  < fail closed (no DEFER — an unsure destructive op is denied). >
  void osDestructive() { configure("os-destructive", 6); allowDefer = 0; requireConsent = 1; }
  < Machine power-on / boot a guest: high bar. >
  void machinePower()  { configure("machine-power", 5); allowDefer = 1; requireConsent = 1; }

  void setThreshold(int t) { dischargeThreshold = t; }
  void setAllowDefer(boolean on) { if (on) { allowDefer = 1; } else { allowDefer = 0; } }
  void setRequireConsent(boolean on) { if (on) { requireConsent = 1; } else { requireConsent = 0; } }

  String name()         { return label; }
  int threshold()       { return dischargeThreshold; }
  boolean defersAllowed() { return allowDefer == 1; }
  boolean consentRequired() { return requireConsent == 1; }
}