SLMoralCertificate.sleela
lib/moral-capacitor/SLMoralCertificate.sleela · 153 line(s) · sleela
<< lib/moral-capacitor/SLMoralCertificate.sleela
SLeeLa Standard Library Definition.
Definition: Defines SLMoralCertificate — the Certificate of Morals(TM): a
signed attestation that a SLeeLa software product embeds the Moral
Capacitor(TM) and operates under a named moral policy with the absolute
red-line veto set armed, carrying the SLMoralWarranty. The certificate names
the subject product, the issuer, the moral policy name and discharge
threshold, the number of armed red lines, an issue serial, a validity span,
and a cryptographic seal (digest/signature) over its canonical body so a
Guard can verify it was issued by the authority and not altered.
The certificate is the product-facing warranty: it travels WITH the software
and is what SLMoralCodeGuard checks before a product is allowed to run or
ship. The seal here is an abstract value filled by SLMoralCertificateAuthority
(optionally hardened with lib/crypto SLDigest/SLSignature in production).
Family: moral-capacitor. Carries SLMoralWarranty; issued by
SLMoralCertificateAuthority; verified by SLMoralCodeGuard. >>
#sleela 2.5
material;
class SLMoralCertificate {
< ---- 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 = 10909;
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; }
static final int SCHEMA_VERSION = 1;
< the product / software unit certified >
String subject;
< the authority that issued the certificate >
String issuer;
< the moral policy in force >
String policyName;
< the policy's discharge threshold >
int threshold;
< how many absolute red lines are armed >
int armedRedlines;
< 1 if a live Moral Capacitor is embedded >
int capacitorPresent;
SLMoralWarranty warranty;
< issue serial >
String serial;
< issue timestamp (as a String; set by the authority) >
String issuedAt;
< expiry timestamp (empty = non-expiring) >
String expiresAt;
< cryptographic seal over the canonical body >
String seal;
< 1 once a seal has been applied >
int sealed;
int configured;
void configure(String certifiedProduct, String issuingAuthority) {
subject = certifiedProduct; issuer = issuingAuthority;
policyName = ""; threshold = 0; armedRedlines = 0; capacitorPresent = 0;
warranty = new SLMoralWarranty(); warranty.configure(issuingAuthority, certifiedProduct);
serial = ""; issuedAt = ""; expiresAt = ""; seal = ""; sealed = 0; configured = 1;
}
< Record the moral posture the certificate attests to. >
void attest(String policy, int dischargeThreshold, int redlineCount, boolean capacitorEmbedded) {
policyName = policy; threshold = dischargeThreshold; armedRedlines = redlineCount;
if (capacitorEmbedded) { capacitorPresent = 1; } else { capacitorPresent = 0; }
}
void setValidity(String issued, String expires) { issuedAt = issued; expiresAt = expires; }
void setSerial(String s) { serial = s; }
< Apply the authority's seal over the canonical body. >
void applySeal(String sealValue) { seal = sealValue; sealed = 1; }
SLMoralWarranty warrantyOf() { return warranty; }
String subjectProduct() { return subject; }
String issuerName() { return issuer; }
String policy() { return policyName; }
int dischargeThreshold(){ return threshold; }
int redlinesArmed() { return armedRedlines; }
boolean embedsCapacitor() { return capacitorPresent == 1; }
String certificateSerial() { return serial; }
String issued() { return issuedAt; }
String expires() { return expiresAt; }
String sealValue() { return seal; }
boolean isSealed() { return sealed == 1; }
< The canonical body the seal is computed over. Stable field order so a Guard >
< can recompute and compare the seal. >
String canonicalBody() {
String b = "MORAL-CERTIFICATE v" + intToStr(SCHEMA_VERSION) + "\n";
b = b + "subject=" + subject + "\n";
b = b + "issuer=" + issuer + "\n";
b = b + "policy=" + policyName + "\n";
b = b + "threshold=" + intToStr(threshold) + "\n";
b = b + "redlines=" + intToStr(armedRedlines) + "\n";
b = b + "capacitor=" + intToStr(capacitorPresent) + "\n";
b = b + "serial=" + serial + "\n";
b = b + "issued=" + issuedAt + "\n";
b = b + "expires=" + expiresAt + "\n";
b = b + warranty.text();
return b;
}
< A certificate is well-formed when it attests an embedded capacitor under a >
< named policy with at least one red line armed, and carries a seal. >
boolean isWellFormed() {
return configured == 1 && capacitorPresent == 1 && policyName != ""
&& armedRedlines >= 1 && sealed == 1;
}
< The full presentable certificate (body + seal). >
String render() {
return canonicalBody() + "seal=" + seal + "\n";
}
String intToStr(int v) { return "" + v; }
}