Home /Modules/registry/SLRegistry.sleela

SLRegistry.sleela

lib/registry/SLRegistry.sleela · 197 line(s) · sleela

<< lib/registry/SLRegistry.sleela
   SLeeLa Standard Library Definition.
   Definition: Defines SLRegistry — the OOD equivalent of the native Sleela
     Registry (registry/sleela_registry.*): a Windows-style hierarchical store
     of keys (an HKEY-like path tree), each holding settings and feature-flag
     values and, where relevant, a sealed provenance record (file/date/author/
     version/hex-id/hash/originality-seal). A fresh SLeeLa install seeds a
     baseline registry that is reviewable from a terminal (sleela registry) or
     a Sleela terminal program. Persistence and SHA-256/seal computation cross
     the native bridge; this class is the Sleela-side model + review.
   
   Mirrors: sl_reg_create, seed_defaults, key_create, the set_* family,
     provenance_set, save, load, and review. The native OP for a registry
     service is reserved for a future opcode; today the terminal
     'sleela registry' is the review surface.
   
   Family: registry. Composes SLRegistryKey, SLRegistryValue,
     SLRegistryProvenance. >>
#sleela 3.0
material;
class SLRegistry {
  < ---- 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 = 11095;
  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-14";
  < 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; }
  < Eight direct object slots remain as the legacy display window. >
  < The complete membership index is the growable string-reference list. >
  static final int LEGACY_OBJECT_WINDOW = 8;
  String version;
  int count;
  SLList keyPaths;
  SLRegistryKey k0; SLRegistryKey k1; SLRegistryKey k2; SLRegistryKey k3;
  SLRegistryKey k4; SLRegistryKey k5; SLRegistryKey k6; SLRegistryKey k7;

  void boot() {
    version = "3.0.0";
    count = 0;
    keyPaths = new SLList();
  }

  boolean addKey(SLRegistryKey k) {
    if (k == null) { return false; }
    keyPaths.add(k.path);
    if (count == 0) { k0 = k; } else if (count == 1) { k1 = k; }
    else if (count == 2) { k2 = k; } else if (count == 3) { k3 = k; }
    else if (count == 4) { k4 = k; } else if (count == 5) { k5 = k; }
    else if (count == 6) { k6 = k; } else if (count == 7) { k7 = k; }
    count = count + 1;
    return true;
  }

  String keyPathAt(int idx) { return keyPaths.get(idx); }

  SLRegistryKey keyAt(int idx) {
    if (idx < 0 || idx >= count || idx >= LEGACY_OBJECT_WINDOW) { return null; }
    if (idx == 0) { return k0; } if (idx == 1) { return k1; }
    if (idx == 2) { return k2; } if (idx == 3) { return k3; }
    if (idx == 4) { return k4; } if (idx == 5) { return k5; }
    if (idx == 6) { return k6; } return k7;
  }

  < Seed the baseline a new install starts from (mirrors sl_reg_seed_defaults): >
  < System, System/VM, Settings, Features, Artifacts. >
  void seedDefaults() {
    boot();

    SLRegistryKey sys = new SLRegistryKey(); sys.configure("System");
    SLRegistryValue nm = new SLRegistryValue(); nm.setString("name", "Idea System(TM) / SLeeLa"); sys.add(nm);
    SLRegistryValue rv = new SLRegistryValue(); rv.setString("registryVersion", version); sys.add(rv);
    addKey(sys);

    SLRegistryKey vm = new SLRegistryKey(); vm.configure("System/VM");
    SLRegistryValue dv = new SLRegistryValue(); dv.setString("default", "native"); vm.add(dv);
    addKey(vm);

    SLRegistryKey settings = new SLRegistryKey(); settings.configure("Settings");
    SLRegistryValue mem = new SLRegistryValue(); mem.setInt("memoryLimitMiB", 2048); settings.add(mem);
    SLRegistryValue thr = new SLRegistryValue(); thr.setInt("threadCap", 128); settings.add(thr);
    SLRegistryValue vb  = new SLRegistryValue(); vb.setString("verbosity", "normal"); settings.add(vb);
    addKey(settings);

    SLRegistryKey feats = new SLRegistryKey(); feats.configure("Features");
    SLRegistryValue f1 = new SLRegistryValue(); f1.setBool("modium", true); feats.add(f1);
    SLRegistryValue f2 = new SLRegistryValue(); f2.setBool("vmSelect", true); feats.add(f2);
    SLRegistryValue f3 = new SLRegistryValue(); f3.setBool("premiumVms", true); feats.add(f3);
    addKey(feats);

    SLRegistryKey art = new SLRegistryKey(); art.configure("Artifacts");
    addKey(art);

    << Math: default start values for the precision norms and the Modium pi
       static reference. A fresh install begins from these; they are editable
       via lib/math/math-precision-norms.json (see MATH.PRECISION.NORMS.md).
       The pi head is the first 60 fractional digits of the 2048-digit catalog
       value in lib/math/SLPiReference.sleela. >>
    SLRegistryKey mathKey = new SLRegistryKey(); mathKey.configure("Math");
    SLRegistryValue nIrr = new SLRegistryValue(); nIrr.setInt("irrationalDigitCarry", 2048); mathKey.add(nIrr);
    SLRegistryValue nRep = new SLRegistryValue(); nRep.setInt("repeatingDigitCarry", 58); mathKey.add(nRep);
    SLRegistryValue nFin = new SLRegistryValue(); nFin.setInt("financeCarry", 1023); mathKey.add(nFin);
    SLRegistryValue piDigits = new SLRegistryValue(); piDigits.setInt("piReferenceDigits", 2048); mathKey.add(piDigits);
    SLRegistryValue piRef = new SLRegistryValue();
    piRef.setString("piReference",
      "3.141592653589793238462643383279502884197169399375105820974944");
    mathKey.add(piRef);
    << The large pi catalog reference: a locator (not the bytes) to the
       100,000,000-fractional-digit value in pi-generator/pi.100000000.digits.
       Per REGISTRY-3.0-MODIUM.md the registry stores only record identity and
       locator metadata; Modium resolves this path to the installed file on the
       host and loads it at subsystem startup (see sleela registry / modium).
       Verified genuine pi in pi-generator/VERIFIED.md. >>
    SLRegistryValue piBigDigits = new SLRegistryValue(); piBigDigits.setInt("piReferenceLargeDigits", 100000000); mathKey.add(piBigDigits);
    SLRegistryValue piBigPath = new SLRegistryValue();
    piBigPath.setString("piReferenceLargePath", "pi-generator/pi.100000000.digits");
    mathKey.add(piBigPath);
    addKey(mathKey);
  }

  boolean featureEnabled(String name) {
    < scan Features key values >
    int i = 0;
    while (i < count) {
      if (i < LEGACY_OBJECT_WINDOW) {
        SLRegistryKey k = keyAt(i);
        if (k != null && k.path == "Features") {
          int j = 0;
          while (j < k.count) {
            SLRegistryValue v = k.valueAt(j);
            if (v != null && v.name == name && v.isBool()) { return v.b == 1; }
            j = j + 1;
          }
        }
      }
      i = i + 1;
    }
    return false;
  }

  < Terminal review (mirrors sl_reg_review). >
  void show() {
    print("Sleela Registry " + version + "  (keys=" + count + ")");
    int i = 0;
    while (i < count) {
      if (i < LEGACY_OBJECT_WINDOW) {
        SLRegistryKey kk = keyAt(i);
        if (kk != null) { kk.show(); }
      } else {
        print("[" + keyPathAt(i) + "] (native record-backed key)");
      }
      i = i + 1;
    }
  }

  void main() {
    SLRegistry reg = new SLRegistry();
    reg.seedDefaults();
    reg.show();
    print("feature modium enabled: " + reg.featureEnabled("modium"));
  }
}