Skip to content

Commit 5e9358f

Browse files
committed
Science Commit 5.
1 parent 797b959 commit 5e9358f

1 file changed

Lines changed: 197 additions & 0 deletions

File tree

Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
1+
package black.presidential.Herb;// AFTER: Each transformation is a named step in the pipeline
2+
3+
import javax.xml.parsers.DocumentBuilderFactory;
4+
import org.w3c.dom.*;
5+
import java.io.File;
6+
import java.net.URI;
7+
import java.util.*;
8+
9+
/**
10+
* Green.Durham.Grass.and.Herb — Main entry point.
11+
*
12+
* <p>Appree is a careful and concernful program all the way down to the Mayor
13+
* of Chapel Hill and her study of students of the County.</p>
14+
*
15+
* <p>This is subtly an Appree project riding on NC Labor Laws &amp; Organization.</p>
16+
*/
17+
public class Main {
18+
19+
private static final String[] CONFIG_PATHS = {
20+
"configuration/appree-config.xml",
21+
"configuration/github-polling-config.xml",
22+
"configuration/ai-interpreter-config.xml",
23+
"configuration/ethical-db-config.xml",
24+
"configuration/labor-db-config.xml",
25+
"configuration/moral-db-config.xml",
26+
"configuration/mortality-db-config.xml",
27+
"configuration/known.port.49152.servers.xml",
28+
"configuration/jwstfj21-integration.xml"
29+
};
30+
31+
private static String baseDir = "";
32+
33+
public static void main(String... args) throws Exception {
34+
// Accept optional base directory argument, or detect from jar location
35+
if (args.length > 0) {
36+
baseDir = args[0].endsWith(File.separator) ? args[0] : args[0] + File.separator;
37+
} else {
38+
String jarPath = Main.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();
39+
File jarFile = new File(jarPath);
40+
File jarDir = jarFile.isDirectory() ? jarFile : jarFile.getParentFile();
41+
// Walk up to find "configuration" folder
42+
File dir = jarDir;
43+
while (dir != null && !new File(dir, "configuration").isDirectory()) dir = dir.getParentFile();
44+
if (dir != null) baseDir = dir.getPath() + File.separator;
45+
}
46+
47+
XmlReader reader = new XmlReader();
48+
Map<String, Document> configs = reader.loadAll(CONFIG_PATHS);
49+
50+
// Print version from appree-config.xml
51+
String version = "unknown";
52+
Document appreeDoc = configs.get("configuration/appree-config.xml");
53+
if (appreeDoc != null) {
54+
NodeList vNodes = appreeDoc.getElementsByTagName("version");
55+
if (vNodes.getLength() > 0) version = vNodes.item(0).getTextContent();
56+
}
57+
58+
System.out.println("=== Green.Durham.Grass.and.Herb . Java Finance and Moral Systems . Version "+version+" . Startup ===");
59+
60+
System.out.println("\n--- Module Status ---");
61+
62+
// DB modules
63+
String[] dbModules = {"ethical", "labor", "moral", "mortality"};
64+
boolean allDbLoaded = true;
65+
for (String mod : dbModules) {
66+
String key = "configuration/" + mod + "-db-config.xml";
67+
boolean found = configs.containsKey(key);
68+
System.out.println("[DB] " + mod + ": " + (found ? "LOADED" : "NOT FOUND"));
69+
if (!found) allDbLoaded = false;
70+
}
71+
72+
// AI modules
73+
boolean aiLoaded = configs.containsKey("configuration/ai-interpreter-config.xml");
74+
System.out.println("[AI] ai-interpreter: " + (aiLoaded ? "LOADED" : "NOT FOUND"));
75+
76+
// Check jars directory
77+
File jarsDir = new File(baseDir + "jars");
78+
boolean jarsFound = jarsDir.isDirectory() && jarsDir.list().length > 0;
79+
System.out.println("[AI] PyTorch jars: " + (jarsFound ? "FOUND (" + jarsDir.list().length + " jars)" : "NOT FOUND"));
80+
81+
// Appree config (starting XML)
82+
boolean appreeLoaded = configs.containsKey("configuration/appree-config.xml");
83+
boolean pollingLoaded = configs.containsKey("configuration/github-polling-config.xml");
84+
System.out.println("[CORE] appree-config: " + (appreeLoaded ? "LOADED" : "NOT FOUND"));
85+
System.out.println("[CORE] github-polling-config: " + (pollingLoaded ? "LOADED" : "NOT FOUND"));
86+
87+
// Final verdict
88+
boolean systemReady = allDbLoaded && aiLoaded && appreeLoaded;
89+
System.out.println("\n--- Result ---");
90+
System.out.println("[SYSTEM] All DB modules loaded: " + (allDbLoaded ? "YES" : "NO"));
91+
System.out.println("[SYSTEM] AI modules loaded: " + (aiLoaded ? "YES" : "NO"));
92+
System.out.println("[SYSTEM] Started from XML: " + (appreeLoaded ? "YES" : "NO"));
93+
System.out.println("[SYSTEM] Status: " + (systemReady ? "RUNNING" : "DEGRADED") + "\n");
94+
95+
// JWSTFJ21 integration — reflective masquerade
96+
if (configs.containsKey("configuration/jwstfj21-integration.xml")) {
97+
System.out.println("\n--- JWSTFJ21 Integration ---");
98+
try {
99+
Class<?> masqClass = Class.forName("integration.JWSTFJ21Masquerade");
100+
Object masquerade = masqClass.getDeclaredConstructor().newInstance();
101+
boolean integrated = (boolean) masqClass.getMethod("register").invoke(masquerade);
102+
System.out.println("[JWSTFJ21] Status: " + (integrated ? "INTEGRATED" : "STANDALONE"));
103+
} catch (ClassNotFoundException e) {
104+
System.out.println("[JWSTFJ21] Masquerade class not compiled — skipping.");
105+
} catch (Exception e) {
106+
System.out.println("[JWSTFJ21] Integration deferred: " + e.getMessage());
107+
}
108+
}
109+
110+
DecisionMaker dm = new DecisionMaker(configs);
111+
dm.evaluate();
112+
}
113+
114+
static class XmlReader {
115+
Map<String, Document> loadAll(String[] paths) {
116+
Map<String, Document> docs = new LinkedHashMap<>();
117+
for (String path : paths) {
118+
try {
119+
Document doc = DocumentBuilderFactory.newInstance()
120+
.newDocumentBuilder().parse(new File(baseDir + path));
121+
doc.getDocumentElement().normalize();
122+
docs.put(path, doc);
123+
System.out.println("[XML] Loaded: " + path);
124+
} catch (Exception e) {
125+
System.err.println("[XML] Failed: " + path + " - " + e.getMessage());
126+
}
127+
}
128+
return docs;
129+
}
130+
}
131+
132+
static class DecisionMaker {
133+
private final Map<String, Document> configs;
134+
135+
DecisionMaker(Map<String, Document> configs) {
136+
this.configs = configs;
137+
}
138+
139+
void evaluate() {
140+
System.out.println("\n[DECISION] Evaluating " + configs.size() + " config(s)...");
141+
142+
for (Map.Entry<String, Document> entry : configs.entrySet()) {
143+
String path = entry.getKey();
144+
Document doc = entry.getValue();
145+
146+
if (path.contains("appree") && !path.contains("github")) {
147+
evaluateListeners(doc);
148+
} else if (path.contains("github-polling")) {
149+
evaluateGithubPolling(doc);
150+
} else if (path.contains("ai-interpreter")) {
151+
evaluateInterpreters(doc);
152+
} else if (path.contains("db-config")) {
153+
evaluateDbConfig(path, doc);
154+
}
155+
}
156+
int total = 8; // total expected configs (incl. jwstfj21-integration)
157+
int loaded = configs.size();
158+
if (loaded == total) {
159+
System.out.println("\u001B[32m[DECISION] Evaluation complete.\u001B[0m");
160+
} else if (loaded > 0) {
161+
System.out.println("\u001B[33m[DECISION] Evaluation complete (" + (total - loaded) + " config(s) missing).\u001B[0m");
162+
} else {
163+
System.out.println("\u001B[31m[DECISION] Evaluation failed — program did not load.\u001B[0m");
164+
}
165+
}
166+
167+
private void evaluateListeners(Document doc) {
168+
NodeList nodes = doc.getElementsByTagName("listener");
169+
int enabled = 0;
170+
for (int i = 0; i < nodes.getLength(); i++) {
171+
if ("true".equals(((Element) nodes.item(i)).getAttribute("enabled"))) enabled++;
172+
}
173+
System.out.println("[DECISION] Listeners: " + enabled + "/" + nodes.getLength() + " enabled");
174+
}
175+
176+
private void evaluateInterpreters(Document doc) {
177+
NodeList nodes = doc.getElementsByTagName("interpreter");
178+
System.out.println("[DECISION] AI Interpreters configured: " + nodes.getLength());
179+
}
180+
181+
private void evaluateDbConfig(String path, Document doc) {
182+
String module = path.replaceAll(".*/", "").replace("-db-config.xml", "");
183+
NodeList urlNodes = doc.getElementsByTagName("url");
184+
String url = urlNodes.getLength() > 0 ? urlNodes.item(0).getTextContent() : "unknown";
185+
System.out.println("[DECISION] DB for " + module + ": " + url);
186+
}
187+
188+
private void evaluateGithubPolling(Document doc) {
189+
NodeList sites = doc.getElementsByTagName("site");
190+
int enabled = 0;
191+
for (int i = 0; i < sites.getLength(); i++) {
192+
if ("true".equals(((Element) sites.item(i)).getAttribute("enabled"))) enabled++;
193+
}
194+
System.out.println("[DECISION] GitHub polling: " + enabled + "/" + sites.getLength() + " sites enabled");
195+
}
196+
}
197+
}

0 commit comments

Comments
 (0)