Skip to content

Commit 0eeeab4

Browse files
committed
Science Commit 5.
1 parent b77edc0 commit 0eeeab4

8 files changed

Lines changed: 251 additions & 30 deletions

File tree

california/cia/source/CaliforniaCIAServer.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package source;
22

33
import commons.CommonRails;
4+
import commons.StrernaryConnector;
45
import commons.color.ColorPalette;
56

67
import java.io.*;
@@ -107,20 +108,32 @@ private void handleClient(Socket client) {
107108
}
108109

109110
private String searchReports(String keyword) {
111+
// Phase 1: Local DB search
112+
String localResults;
110113
try (var conn = database.N21AuthConfig.get();
111114
var ps = conn.prepareStatement(
112115
"SELECT id, category, LEFT(report_text, 80), created_at FROM intelligence_reports WHERE report_text LIKE ? OR category LIKE ? ORDER BY created_at DESC LIMIT 10")) {
113116
ps.setString(1, "%" + keyword + "%");
114117
ps.setString(2, "%" + keyword + "%");
115118
var rs = ps.executeQuery();
116-
StringBuilder sb = new StringBuilder("RESULTS|");
119+
StringBuilder sb = new StringBuilder();
117120
int count = 0;
118121
while (rs.next()) {
119122
sb.append(rs.getInt(1)).append(":").append(rs.getString(2)).append(":").append(rs.getString(3)).append("|");
120123
count++;
121124
}
122-
return count == 0 ? "RESULTS|none" : sb.toString();
123-
} catch (Exception e) { return "ERR|" + e.getMessage(); }
125+
localResults = count > 0 ? sb.toString() : null;
126+
} catch (Exception e) { localResults = null; }
127+
128+
// Phase 2: Strernary™ AI inference on port 20000
129+
String aiResult = StrernaryConnector.ask("CIA SEARCH category=" + keyword + " context=intelligence_reports");
130+
131+
// Combine results
132+
StringBuilder combined = new StringBuilder("RESULTS|");
133+
if (localResults != null) combined.append(localResults);
134+
if (aiResult != null) combined.append("AI|").append(aiResult.replace("\n", " "));
135+
if (localResults == null && aiResult == null) return "RESULTS|none";
136+
return combined.toString();
124137
}
125138

126139
private void storeReport(String category, String text) throws Exception {

california/fbi/source/CaliforniaFBIServer.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package source;
22

33
import commons.CommonRails;
4+
import commons.StrernaryConnector;
45
import commons.color.ColorPalette;
56

67
import java.io.*;
@@ -112,21 +113,32 @@ private String submitReport(String category, String text) {
112113
}
113114

114115
private String searchReports(String keyword) {
116+
// Phase 1: Local DB search
117+
String localResults;
115118
try (var conn = database.N21AuthConfig.get();
116119
var ps = conn.prepareStatement(
117120
"SELECT id, category, LEFT(report_text, 80), created_at FROM crime_reports WHERE report_text LIKE ? OR category LIKE ? ORDER BY created_at DESC LIMIT 10")) {
118121
ps.setString(1, "%" + keyword + "%");
119122
ps.setString(2, "%" + keyword + "%");
120123
var rs = ps.executeQuery();
121-
StringBuilder sb = new StringBuilder("RESULTS|");
124+
StringBuilder sb = new StringBuilder();
122125
int count = 0;
123126
while (rs.next()) {
124127
sb.append(rs.getInt(1)).append(":").append(rs.getString(2)).append(":").append(rs.getString(3)).append("|");
125128
count++;
126129
}
127-
if (count == 0) return "RESULTS|none";
128-
return sb.toString();
129-
} catch (Exception e) { return "ERR|" + e.getMessage(); }
130+
localResults = count > 0 ? sb.toString() : null;
131+
} catch (Exception e) { localResults = null; }
132+
133+
// Phase 2: Strernary™ AI inference on port 20000
134+
String aiResult = StrernaryConnector.ask("FBI SEARCH category=" + keyword + " context=crime_reports");
135+
136+
// Combine results
137+
StringBuilder combined = new StringBuilder("RESULTS|");
138+
if (localResults != null) combined.append(localResults);
139+
if (aiResult != null) combined.append("AI|").append(aiResult.replace("\n", " "));
140+
if (localResults == null && aiResult == null) return "RESULTS|none";
141+
return combined.toString();
130142
}
131143

132144
private void storeReport(String category, String text) throws Exception {

california/nsa/source/CaliforniaNSAServer.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package source;
22

33
import commons.CommonRails;
4+
import commons.StrernaryConnector;
45
import commons.color.ColorPalette;
56

67
import java.io.*;
@@ -105,20 +106,32 @@ private void handleClient(Socket client) {
105106
}
106107

107108
private String searchReports(String keyword) {
109+
// Phase 1: Local DB search
110+
String localResults;
108111
try (var conn = database.N21AuthConfig.get();
109112
var ps = conn.prepareStatement(
110113
"SELECT id, category, LEFT(report_text, 80), created_at FROM cyber_reports WHERE report_text LIKE ? OR category LIKE ? ORDER BY created_at DESC LIMIT 10")) {
111114
ps.setString(1, "%" + keyword + "%");
112115
ps.setString(2, "%" + keyword + "%");
113116
var rs = ps.executeQuery();
114-
StringBuilder sb = new StringBuilder("RESULTS|");
117+
StringBuilder sb = new StringBuilder();
115118
int count = 0;
116119
while (rs.next()) {
117120
sb.append(rs.getInt(1)).append(":").append(rs.getString(2)).append(":").append(rs.getString(3)).append("|");
118121
count++;
119122
}
120-
return count == 0 ? "RESULTS|none" : sb.toString();
121-
} catch (Exception e) { return "ERR|" + e.getMessage(); }
123+
localResults = count > 0 ? sb.toString() : null;
124+
} catch (Exception e) { localResults = null; }
125+
126+
// Phase 2: Strernary™ AI inference on port 20000
127+
String aiResult = StrernaryConnector.ask("NSA SEARCH category=" + keyword + " context=cyber_reports");
128+
129+
// Combine results
130+
StringBuilder combined = new StringBuilder("RESULTS|");
131+
if (localResults != null) combined.append(localResults);
132+
if (aiResult != null) combined.append("AI|").append(aiResult.replace("\n", " "));
133+
if (localResults == null && aiResult == null) return "RESULTS|none";
134+
return combined.toString();
122135
}
123136

124137
private void storeReport(String category, String text) throws Exception {

configuration/masquerade-modules.xml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,55 +128,60 @@
128128
<name>CaliforniaFBI™</name>
129129
<port>49210</port>
130130
<masquerade-aware>true</masquerade-aware>
131+
<strernary-capable>true</strernary-capable>
131132
<class>source.CaliforniaFBIServer</class>
132133
<trust-level>9.5</trust-level>
133134
<source>california/fbi</source>
134135
<block>California</block>
135-
<description>FBI crime reporting. AI categorization via Strernary™. tips.fbi.gov connector. Installer ID Tech™ secured.</description>
136+
<description>FBI crime reporting. AI categorization via Strernary™ port 20000. tips.fbi.gov connector. Installer ID Tech™ secured.</description>
136137
</module>
137138

138139
<module id="CaliforniaCIA">
139140
<name>CaliforniaCIA™</name>
140141
<port>49211</port>
141142
<masquerade-aware>true</masquerade-aware>
143+
<strernary-capable>true</strernary-capable>
142144
<class>source.CaliforniaCIAServer</class>
143145
<trust-level>9.5</trust-level>
144146
<source>california/cia</source>
145147
<block>California</block>
146-
<description>CIA intelligence reporting. AI categorization. cia.gov connector. FOIA support. Installer ID Tech™ secured.</description>
148+
<description>CIA intelligence reporting. AI categorization via Strernary™ port 20000. cia.gov connector. FOIA support. Installer ID Tech™ secured.</description>
147149
</module>
148150

149151
<module id="CaliforniaNSA">
150152
<name>CaliforniaNSA™</name>
151153
<port>49212</port>
152154
<masquerade-aware>true</masquerade-aware>
155+
<strernary-capable>true</strernary-capable>
153156
<class>source.CaliforniaNSAServer</class>
154157
<trust-level>9.5</trust-level>
155158
<source>california/nsa</source>
156159
<block>California</block>
157-
<description>NSA cybersecurity reporting. AI categorization. nsa.gov/CISA connector. Installer ID Tech™ secured.</description>
160+
<description>NSA cybersecurity reporting. AI categorization via Strernary™ port 20000. nsa.gov/CISA connector. Installer ID Tech™ secured.</description>
158161
</module>
159162

160163
<module id="DukeUniversity">
161164
<name>DukeUniversity™</name>
162165
<port>49213</port>
163166
<masquerade-aware>true</masquerade-aware>
167+
<strernary-capable>true</strernary-capable>
164168
<class>source.DukeUniversityServer</class>
165169
<trust-level>9.5</trust-level>
166170
<source>north/carolina/duke</source>
167171
<block>NC Socialist-College</block>
168-
<description>Duke University college interface. Academic programs, course catalog, admissions.</description>
172+
<description>Duke University college interface. AI-enhanced queries via Strernary™ port 20000. Academic programs, course catalog, admissions.</description>
169173
</module>
170174

171175
<module id="StanfordLibrary">
172176
<name>StanfordLibrary™</name>
173177
<port>49214</port>
174178
<masquerade-aware>true</masquerade-aware>
179+
<strernary-capable>true</strernary-capable>
175180
<class>source.StanfordLibraryServer</class>
176181
<trust-level>9.5</trust-level>
177182
<source>north/carolina/library</source>
178183
<block>NC Socialist-College</block>
179-
<description>Stanford Library interface. SearchWorks catalog, digital collections, resource requests.</description>
184+
<description>Stanford Library interface. AI-enhanced catalog search via Strernary™ port 20000. SearchWorks catalog, digital collections, resource requests.</description>
180185
</module>
181186

182187
</masquerade-modules>

configuration/nwe-config.xml

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,11 +263,13 @@
263263
<host>localhost</host>
264264
<port>49210</port>
265265
<masquerade-aware>true</masquerade-aware>
266+
<strernary-capable>true</strernary-capable>
266267
<description>
267268
California FBI crime reporting module. AI-assisted categorization via
268-
Strernary™ (port 20000). Connects to tips.fbi.gov and IC3 for federal
269-
tip forwarding. MySQL database: nwe_california_fbi. Installer ID Tech™
270-
secures all table writes.
269+
Strernary™ (port 20000). SEARCH commands query both local MySQL and
270+
Strernary inference. Falls back to DB-only if port 20000 offline.
271+
Connects to tips.fbi.gov and IC3 for federal tip forwarding.
272+
MySQL database: nwe_california_fbi. Installer ID Tech™ secures all table writes.
271273
</description>
272274
</server>
273275

@@ -278,8 +280,11 @@
278280
<host>localhost</host>
279281
<port>49211</port>
280282
<masquerade-aware>true</masquerade-aware>
283+
<strernary-capable>true</strernary-capable>
281284
<description>
282-
California CIA intelligence reporting module. AI-assisted categorization.
285+
California CIA intelligence reporting module. AI-assisted categorization
286+
via Strernary™ (port 20000). SEARCH commands query both local MySQL and
287+
Strernary inference. Falls back to DB-only if port 20000 offline.
283288
Connects to cia.gov/report-information and FOIA reading room.
284289
MySQL database: nwe_california_cia. Installer ID Tech™ secured.
285290
</description>
@@ -292,8 +297,11 @@
292297
<host>localhost</host>
293298
<port>49212</port>
294299
<masquerade-aware>true</masquerade-aware>
300+
<strernary-capable>true</strernary-capable>
295301
<description>
296-
California NSA cybersecurity module. AI-assisted incident categorization.
302+
California NSA cybersecurity module. AI-assisted incident categorization
303+
via Strernary™ (port 20000). SEARCH commands query both local MySQL and
304+
Strernary inference. Falls back to DB-only if port 20000 offline.
297305
Connects to nsa.gov/Cybersecurity and CISA for vulnerability disclosure.
298306
MySQL database: nwe_california_nsa. Installer ID Tech™ secured.
299307
</description>
@@ -306,7 +314,12 @@
306314
<host>localhost</host>
307315
<port>49213</port>
308316
<masquerade-aware>true</masquerade-aware>
309-
<description>Duke University college interface. AI-assisted. MySQL: nwe_duke.</description>
317+
<strernary-capable>true</strernary-capable>
318+
<description>
319+
Duke University college interface. AI-assisted SEARCH and QUERY via
320+
Strernary™ (port 20000). Falls back to DB-only if port 20000 offline.
321+
MySQL: nwe_duke.
322+
</description>
310323
</server>
311324

312325
<server id="StanfordLibrary">
@@ -316,7 +329,12 @@
316329
<host>localhost</host>
317330
<port>49214</port>
318331
<masquerade-aware>true</masquerade-aware>
319-
<description>Stanford Library interface. Connects to library.stanford.edu. MySQL: nwe_library.</description>
332+
<strernary-capable>true</strernary-capable>
333+
<description>
334+
Stanford Library interface. AI-assisted SEARCH and REQUEST via
335+
Strernary™ (port 20000). Falls back to DB-only if port 20000 offline.
336+
Connects to library.stanford.edu. MySQL: nwe_library.
337+
</description>
320338
</server>
321339

322340
<server id="Strernary">

north/carolina/duke/source/DukeUniversityServer.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package source;
22

33
import commons.CommonRails;
4+
import commons.StrernaryConnector;
45
import commons.color.ColorPalette;
56

67
import java.io.*;
@@ -90,7 +91,13 @@ private void handleClient(Socket client) {
9091
String[] parts = line.split("\\|", 3);
9192
if (parts.length < 3) { out.println("ERR|Usage: QUERY|<college>|<text>"); continue; }
9293
storeQuery(parts[1], parts[2]);
93-
out.println("OK|Query stored|college=" + parts[1]);
94+
// AI-enhanced response via Strernary™ port 20000
95+
String aiAnswer = StrernaryConnector.ask("DUKE QUERY college=" + parts[1] + " question=" + parts[2]);
96+
if (aiAnswer != null) {
97+
out.println("OK|Query stored|college=" + parts[1] + "|AI|" + aiAnswer.replace("\n", " "));
98+
} else {
99+
out.println("OK|Query stored|college=" + parts[1]);
100+
}
94101
continue;
95102
}
96103
out.println("ERR|Unknown command");
@@ -99,13 +106,25 @@ private void handleClient(Socket client) {
99106
}
100107

101108
private String searchLocal(String keyword) {
109+
// Phase 1: Local DB search
110+
String localResults;
102111
try (var conn = database.N21AuthConfig.get();
103112
var ps = conn.prepareStatement("SELECT id, college, LEFT(query_text,80), created_at FROM college_queries WHERE query_text LIKE ? OR college LIKE ? ORDER BY created_at DESC LIMIT 10")) {
104113
ps.setString(1, "%" + keyword + "%"); ps.setString(2, "%" + keyword + "%");
105-
var rs = ps.executeQuery(); StringBuilder sb = new StringBuilder("RESULTS|"); int c = 0;
114+
var rs = ps.executeQuery(); StringBuilder sb = new StringBuilder(); int c = 0;
106115
while (rs.next()) { sb.append(rs.getInt(1)).append(":").append(rs.getString(2)).append(":").append(rs.getString(3)).append("|"); c++; }
107-
return c == 0 ? "RESULTS|none" : sb.toString();
108-
} catch (Exception e) { return "ERR|" + e.getMessage(); }
116+
localResults = c > 0 ? sb.toString() : null;
117+
} catch (Exception e) { localResults = null; }
118+
119+
// Phase 2: Strernary™ AI inference on port 20000
120+
String aiResult = StrernaryConnector.ask("DUKE SEARCH keyword=" + keyword + " context=college_queries courses");
121+
122+
// Combine results
123+
StringBuilder combined = new StringBuilder("RESULTS|");
124+
if (localResults != null) combined.append(localResults);
125+
if (aiResult != null) combined.append("AI|").append(aiResult.replace("\n", " "));
126+
if (localResults == null && aiResult == null) return "RESULTS|none";
127+
return combined.toString();
109128
}
110129

111130
private void storeQuery(String college, String text) throws Exception {

north/carolina/library/source/StanfordLibraryServer.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package source;
22

33
import commons.CommonRails;
4+
import commons.StrernaryConnector;
45
import commons.color.ColorPalette;
56

67
import java.io.*;
@@ -89,7 +90,13 @@ private void handleClient(Socket client) {
8990
if (line.startsWith("REQUEST|")) {
9091
String resource = line.substring(8).trim();
9192
storeRequest(resource);
92-
out.println("OK|Request stored|resource=" + resource);
93+
// AI-enhanced resource lookup via Strernary™ port 20000
94+
String aiAnswer = StrernaryConnector.ask("LIBRARY REQUEST resource=" + resource + " context=stanford_catalog searchworks");
95+
if (aiAnswer != null) {
96+
out.println("OK|Request stored|resource=" + resource + "|AI|" + aiAnswer.replace("\n", " "));
97+
} else {
98+
out.println("OK|Request stored|resource=" + resource);
99+
}
93100
continue;
94101
}
95102
out.println("ERR|Unknown command");
@@ -98,13 +105,25 @@ private void handleClient(Socket client) {
98105
}
99106

100107
private String searchLocal(String keyword) {
108+
// Phase 1: Local DB search
109+
String localResults;
101110
try (var conn = database.N21AuthConfig.get();
102111
var ps = conn.prepareStatement("SELECT id, resource_type, LEFT(title,80), created_at FROM library_requests WHERE title LIKE ? OR resource_type LIKE ? ORDER BY created_at DESC LIMIT 10")) {
103112
ps.setString(1, "%" + keyword + "%"); ps.setString(2, "%" + keyword + "%");
104-
var rs = ps.executeQuery(); StringBuilder sb = new StringBuilder("RESULTS|"); int c = 0;
113+
var rs = ps.executeQuery(); StringBuilder sb = new StringBuilder(); int c = 0;
105114
while (rs.next()) { sb.append(rs.getInt(1)).append(":").append(rs.getString(2)).append(":").append(rs.getString(3)).append("|"); c++; }
106-
return c == 0 ? "RESULTS|none" : sb.toString();
107-
} catch (Exception e) { return "ERR|" + e.getMessage(); }
115+
localResults = c > 0 ? sb.toString() : null;
116+
} catch (Exception e) { localResults = null; }
117+
118+
// Phase 2: Strernary™ AI inference on port 20000
119+
String aiResult = StrernaryConnector.ask("LIBRARY SEARCH keyword=" + keyword + " context=catalog digital_collections");
120+
121+
// Combine results
122+
StringBuilder combined = new StringBuilder("RESULTS|");
123+
if (localResults != null) combined.append(localResults);
124+
if (aiResult != null) combined.append("AI|").append(aiResult.replace("\n", " "));
125+
if (localResults == null && aiResult == null) return "RESULTS|none";
126+
return combined.toString();
108127
}
109128

110129
private void storeRequest(String resource) throws Exception {

0 commit comments

Comments
 (0)