extensible-network-access.sleela
lib/cpu/examples/extensible-network-access.sleela · 152 line(s) · sleela
<< lib/cpu/examples/extensible-network-access.sleela
A runnable SLeeLa document for the SLExtensibleNetwork feature: a System of
files whose public / private / protected members are reinterpreted as system
roles, and whose backdrop the VM can infer from the compiled image.
public -> exposed hop (REST endpoint / hop controller); the three public
members form an ordered chain doc 1 -> doc 2 -> doc 3.
private -> local/admin/safety/security/backup concern (not exposed).
protected -> integrity-guarded connection (double-input, virus-scan, ...).
It registers the members, resolves (classify + order the hop chain), loads
(fail-closed) to realize the backdrop, then flattens to an SLAccessManifest
and attaches it to a program image — exactly how the VM reads it back. >>
#sleela 2.5
material;
class ExtensibleNetworkAccessExample {
< ---- 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 = 11103;
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-16";
< metaScienceRating: maturity/robustness on a 1..10 scale >
int metaScienceRating = 7;
< 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; }
void main() {
SLExtensibleNetwork net = new SLExtensibleNetwork();
net.initialize("OrderPipeline", "three-file ordered system");
SLAccessSemantics sem = new SLAccessSemantics();
< Register each file's surface member under its access modifier. >
< Three public members -> the ordered hop chain doc1 -> doc2 -> doc3. >
< doc 1 : intake endpoint (hop 1) >
net.registerMember(sem.MOD_PUBLIC);
< doc 2 : process endpoint (hop 2) >
net.registerMember(sem.MOD_PUBLIC);
< doc 3 : dispatch endpoint (hop 3) >
net.registerMember(sem.MOD_PUBLIC);
< admin/backup concern (local) >
net.registerMember(sem.MOD_PRIVATE);
< integrity-guarded intake check >
net.registerMember(sem.MOD_PROTECTED);
< Dynamite Connector lifecycle: resolve -> load (fail-closed). >
print("state after initialize: " + net.state());
net.resolve();
print("state after resolve: " + net.state());
boolean realized = net.load();
print("state after load: " + net.state() + ", realized=" + realized +
", ready=" + net.ready());
< What the network classified. >
print("members=" + net.members() + " -> exposed(public)=" + net.exposed() +
", local(private)=" + net.localMembers() +
", guarded(protected)=" + net.guardedMembers());
print("ordered hop chain length = " + net.hopCount() +
" (doc 1 -> doc 2 -> doc 3), competent=" + net.competent());
< The backdrop the VM stands up per role (default bundles). >
print("exposed backdrop = " + sem.exposeComponentName(net.exposureBackdrop()));
print("local backdrop = " + sem.localConcernName(net.localBackdrop()));
print("guard backdrop = " + sem.guardName(net.guardBackdrop()));
< Flatten to the manifest the compiled image carries, and attach it to a >
< program — the VM reads this back and sets up the same System backdrop. >
SLAccessManifest man = net.toManifest();
SLProgram prog = new SLProgram();
prog.configure("order-pipeline", 256);
prog.attachAccess(man);
print("program carries access semantics = " + prog.hasAccess() +
", competent = " + prog.accessCompetent());
print("manifest: exposed=" + man.exposed() + " local=" + man.local() +
" guarded=" + man.guarded() + " hops=" + man.hops() +
" ordered=" + man.ordered() + " classified=" + man.classifiedTotal());
< ------------------------------------------------------------------ >
< VM-SIDE ENFORCEMENT: build a class whose methods carry access roles, >
< load it with the manifest adopted, and show the VM gates resolution. >
< ------------------------------------------------------------------ >
SLVMClass svc = new SLVMClass();
svc.configure(1, "OrderService", -1, 0);
< public -> exposed hop (role 1) >
SLVMMethod intake = new SLVMMethod();
intake.configureAccess("intake", "(I)I", 0, 4, 1, 2, true, false, sem.ROLE_EXPOSED);
< private -> local only (role 2) >
SLVMMethod backup = new SLVMMethod();
backup.configureAccess("backup", "()V", 4, 3, 0, 1, true, false, sem.ROLE_LOCAL);
< protected -> integrity-guarded (role 3) >
SLVMMethod verify = new SLVMMethod();
verify.configureAccess("verify", "(I)Z", 7, 5, 1, 2, true, false, sem.ROLE_GUARDED);
svc.addMethod(intake); svc.addMethod(backup); svc.addMethod(verify);
SLVMModuleLoader loader = new SLVMModuleLoader();
loader.configure("/lib");
SLVMModule mod = loader.beginModule("order-pipeline", 64, 32, 16);
loader.defineClass(svc);
< adopt the manifest >
loader.finishModuleWithAccess(1, "intake", man);
print("module loaded, access realized = " + loader.accessRealized() +
", module.hasAccess = " + mod.hasAccess());
< A NETWORK caller (exposed-role caller) resolving against the module: >
SLVMMethod netIntake = mod.resolveExposedMethod(1, "intake");
SLVMMethod netBackup = mod.resolveExposedMethod(1, "backup");
print("network sees intake (public) -> " + (netIntake != null) + " [reachable]");
print("network sees backup (private) -> " + (netBackup != null) + " [must be false]");
< A LOCAL (in-system) caller can reach the private/protected members: >
SLVMMethod locBackup = mod.resolveMethodForCaller(1, "backup", sem.ROLE_LOCAL);
SLVMMethod locVerify = mod.resolveMethodForCaller(1, "verify", sem.ROLE_LOCAL);
SLVMMethod extBackup = mod.resolveMethodForCaller(1, "backup", sem.ROLE_EXPOSED);
print("local caller -> backup reachable=" + (locBackup != null) +
", verify(guarded) reachable=" + (locVerify != null));
print("external/network caller -> backup reachable=" + (extBackup != null) +
" [must be false: private is local-only]");
}
}